JingsongLi commented on a change in pull request #8102: 
[FLINK-12087][table-runtime-blink] Introduce over window operators to blink 
batch
URL: https://github.com/apache/flink/pull/8102#discussion_r273303176
 
 

 ##########
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/aggregate/over/frame/RowSlidingOverFrame.java
 ##########
 @@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.runtime.aggregate.over.frame;
+
+import org.apache.flink.table.dataformat.BaseRow;
+import org.apache.flink.table.generated.GeneratedAggsHandleFunction;
+import org.apache.flink.table.runtime.util.ResettableExternalBuffer;
+import org.apache.flink.table.type.RowType;
+
+/**
+ * The sliding window frame calculates frames with the following SQL form:
+ * ... ROW BETWEEN 1 PRECEDING AND 1 FOLLOWING
+ */
+public class RowSlidingOverFrame extends SlidingOverFrame {
+
+       private final int leftOffset;
+       private final int rightOffset;
+
+       /**
+        * Index of the first input row with a value greater than the upper 
bound of the current
+        * output row.
+        */
+       private int inputHighIndex = 0;
+
+       /**
+        * Index of the first input row with a value equal to or greater than 
the lower bound of the
+        * current output row.
+        */
+       private int inputLowIndex = 0;
+
+       public RowSlidingOverFrame(
+                       RowType inputType,
+                       RowType valueType,
+                       GeneratedAggsHandleFunction aggsHandleFunction,
+                       int leftOffset,
+                       int rightOffset) {
+               super(inputType, valueType, aggsHandleFunction);
+               this.leftOffset = leftOffset;
+               this.rightOffset = rightOffset;
+       }
+
+       @Override
+       public void prepare(ResettableExternalBuffer rows) throws Exception {
+               super.prepare(rows);
+               inputHighIndex = 0;
+               inputLowIndex = 0;
+       }
+
+       @Override
+       public BaseRow process(int index, BaseRow current) throws Exception {
+               boolean bufferUpdated = index == 0;
+
+               // Drop all rows from the buffer for which the input row value 
is smaller than
+               // the output row lower bound.
+               while (!buffer.isEmpty() && inputLowIndex < index + leftOffset) 
{
 
 Review comment:
   leftOffset is negative value.
   I will change it to positive value to better understood.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to