You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/09/23 03:14:25 UTC

[GitHub] [flink] wuchong commented on a change in pull request #9741: [FLINK-14119][table] Clean idle state for RetractableTopNFunction

wuchong commented on a change in pull request #9741: [FLINK-14119][table] Clean idle state for RetractableTopNFunction
URL: https://github.com/apache/flink/pull/9741#discussion_r326939628
 
 

 ##########
 File path: flink-table/flink-table-runtime-blink/src/test/java/org/apache/flink/table/runtime/operators/rank/RetractableTopNFunctionTest.java
 ##########
 @@ -219,4 +219,38 @@ public void testDisableGenerateRetraction() throws Exception {
 				.assertOutputEqualsSorted("output wrong.", expectedOutput, testHarness.getOutput());
 	}
 
+	@Test
+	public void testCleanIdleState() throws Exception {
+		AbstractTopNFunction func = createFunction(RankType.ROW_NUMBER, new ConstantRankRange(1, 2), true,
+			true);
+		OneInputStreamOperatorTestHarness<BaseRow, BaseRow> testHarness = createTestHarness(func);
+		testHarness.open();
+
+		testHarness.processElement(record("book", 1L, 12));
+		testHarness.processElement(retractRecord("book", 1L, 12));
+		testHarness.processElement(record("fruit", 4L, 33));
+		testHarness.processElement(record("book", 2L, 19));
+		testHarness.processElement(record("fruit", 3L, 22));
+		testHarness.processElement(record("fruit", 5L, 43));
+
+		// cleanup state explicitly
+		func.onTimer(System.currentTimeMillis(), null, null);
 
 Review comment:
   We should not call methods on the function directly. It can't clear the state correctly.
   Instead, we should call `testHarness.setProcessingTime` to trigger the `onTimer`.
   
   You can take `OverWindowHarnessTest` as an example. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services