AlecCh0402 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_r327182330
 
 

 ##########
 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:
   Hi Jark, thanks for the kind and thorough review. I've updated the commit. 
`testHarness.setProcessingTime` is truly the right way to trigger timer.  It 
sounds a little bit weird but I just want to explain what I was thinking, is 
based on the assumption that timer is always triggered correctly, and the only 
thing to test is when `onTimer` is called directly, the state will be cleaned 
anyway. And since the test itself is based on a keyed stream , so the cleanup 
would only happen on the latest processed partition key's related states. 
Thanks anyway for the review :)

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to