fapaul commented on a change in pull request #18982:
URL: https://github.com/apache/flink/pull/18982#discussion_r829061834



##########
File path: 
flink-streaming-java/src/test/java/org/apache/flink/streaming/runtime/operators/windowing/TimeWindowTest.java
##########
@@ -29,23 +29,38 @@
 public class TimeWindowTest {
     @Test
     public void testGetWindowStartWithOffset() {
-        // [0, 7), [7, 14), [14, 21)...
+        // [-21, 14), [-14, -7), [-7, 0), [0, 7), [7, 14), [14, 21)...

Review comment:
       ```suggestion
           // [-21, -14), [-14, -7), [-7, 0), [0, 7), [7, 14), [14, 21)...
   ```

##########
File path: 
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/window/TimeWindow.java
##########
@@ -220,7 +220,13 @@ public TimeWindowSerializerSnapshot() {
      * @return window start
      */
     public static long getWindowStartWithOffset(long timestamp, long offset, 
long windowSize) {
-        return timestamp - (timestamp - offset + windowSize) % windowSize;
+        long remainder = (timestamp - offset) % windowSize;

Review comment:
       I know you haven't introduced this method but what do you think about 
removing this method in favor of the other 
`TimeWindow#getWindowStartWithOffset`. I am afraid that it is easy to miss that 
we have the same method twice in the code base.
   
   I am also fine to do this as followup if you think it is too much for this 
PR.

##########
File path: 
flink-streaming-java/src/main/java/org/apache/flink/streaming/api/windowing/windows/TimeWindow.java
##########
@@ -262,6 +262,12 @@ public int compare(TimeWindow o1, TimeWindow o2) {
      * @return window start
      */
     public static long getWindowStartWithOffset(long timestamp, long offset, 
long windowSize) {
-        return timestamp - (timestamp - offset + windowSize) % windowSize;
+        long remainder = (timestamp - offset) % windowSize;

Review comment:
       Nit:
   ```suggestion
           final long remainder = (timestamp - offset) % windowSize;
   ```

##########
File path: 
flink-table/flink-table-runtime/src/main/java/org/apache/flink/table/runtime/operators/window/TimeWindow.java
##########
@@ -220,7 +220,13 @@ public TimeWindowSerializerSnapshot() {
      * @return window start
      */
     public static long getWindowStartWithOffset(long timestamp, long offset, 
long windowSize) {
-        return timestamp - (timestamp - offset + windowSize) % windowSize;
+        long remainder = (timestamp - offset) % windowSize;

Review comment:
       Yes no worries this can also be done outside of the PR.




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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to