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/07/29 06:43:16 UTC

[GitHub] [flink] wuchong commented on a change in pull request #9248: [FLINK-13446][table-runtime-blink] Fix assign logic for row count sliding window

wuchong commented on a change in pull request #9248: [FLINK-13446][table-runtime-blink] Fix assign logic for row count sliding window
URL: https://github.com/apache/flink/pull/9248#discussion_r308074550
 
 

 ##########
 File path: flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/operators/window/assigners/CountSlidingWindowAssigner.java
 ##########
 @@ -67,17 +67,19 @@ public void open(InternalWindowProcessFunction.Context<?, CountWindow> ctx) thro
 		Long countValue = count.value();
 		long currentCount = countValue == null ? 0L : countValue;
 		count.update(currentCount + 1);
-		long lastId = currentCount / windowSlide;
-		long lastStart = lastId * windowSlide;
-		long lastEnd = lastStart + windowSize - 1;
+		long windowId = currentCount / windowSlide;
+		long windowEnd = windowId * windowSlide + windowSlide - 1;
+		long windowStart = windowEnd - windowSize + 1;
 		List<CountWindow> windows = new ArrayList<>();
-		while (lastId >= 0 && lastStart <= currentCount && currentCount <= lastEnd) {
-			if (lastStart <= currentCount && currentCount <= lastEnd) {
-				windows.add(new CountWindow(lastId));
+		while ((windowStart <= currentCount) && (currentCount <= windowEnd)) {
+			if (0 > windowStart) {
+				windows.add(new CountWindow(windowId, windowSize + windowStart));
+			} else {
+				windows.add(new CountWindow(windowId, windowSize));
 
 Review comment:
   What about to encode CountWindow as "countStart, countEnd" like TimeWindow. Then the logic of assigning windows will be similar to `SlidingWindowAssigner` which is much simpler IMO. What do you think?

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