[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-08 Thread GitBox
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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-08 Thread GitBox
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_r273303052
 
 

 ##
 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
 
 Review comment:
   wrong comment


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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-08 Thread GitBox
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_r273303013
 
 

 ##
 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
 
 Review comment:
   I will add detail comment


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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-08 Thread GitBox
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_r273299696
 
 

 ##
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/aggregate/over/frame/RangeUnboundedPrecedingOverFrame.java
 ##
 @@ -0,0 +1,66 @@
+/*
+ * 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.generated.GeneratedRecordComparator;
+import org.apache.flink.table.generated.RecordComparator;
+import org.apache.flink.table.runtime.context.ExecutionContext;
+
+/**
+ * The UnboundPreceding window frame calculates frames with the following SQL 
form:
+ * ... ROW BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW.
 
 Review comment:
   Yes, I will change it.


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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-04 Thread GitBox
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_r272034292
 
 

 ##
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/generated/BoundComparator.java
 ##
 @@ -0,0 +1,49 @@
+/*
+ * 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.generated;
+
+import org.apache.flink.table.dataformat.BaseRow;
+
+import java.io.Serializable;
+
+/**
+ * comparing boundary values.
+ */
+public interface BoundComparator extends Serializable {
+
+   /**
+* reset the comparator.
+*/
+   void reset();
+
+   /**
+* Compares its two row.  Returns a negative integer,
+* zero, or a positive integer as the first argument is less than, equal
+* to, or greater than the second.
+*
+* @param inputRow the first row to be compared.
+* @param inputIndex   the index for the first row.
+* @param currentRow   the second row to be compared.
+* @param currentIndex the index for the second row.
+* @return a negative integer, zero, or a positive integer as the
+* first argument is less than, equal to, or greater than the
+* second.
+*/
+   long compare(BaseRow inputRow, int inputIndex, BaseRow currentRow, int 
currentIndex);
 
 Review comment:
   index is the number of current partition(window).


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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-04 Thread GitBox
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_r272038501
 
 

 ##
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/aggregate/over/frame/OverWindowFrame.java
 ##
 @@ -0,0 +1,44 @@
+/*
+ * 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.dataformat.BinaryRow;
+import org.apache.flink.table.runtime.context.ExecutionContext;
+import org.apache.flink.table.runtime.util.ResettableExternalBuffer;
+
+import java.io.Serializable;
+
+/**
+ * A window frame calculates the results for those records belong to a window 
frame.
+ * Before use a frame must be prepared by passing it all the records in the 
current partition.
+ */
+public interface OverWindowFrame extends Serializable {
+
+   void open(ExecutionContext ctx) throws Exception;
+
+   void resetBuffer(ResettableExternalBuffer rows) throws Exception;
+
+   //return the ACC of the window frame.
+   BaseRow write(int index, BaseRow current) throws Exception;
 
 Review comment:
   Method `write` need modify to `process`.
   
   Over AGG means that every Row has a corresponding output.
   OverWindowFrame is called by:
   1. Get all data and invoke `prepare(ResettableExternalBuffer rows)` for 
partition
   2. Then each Row is traversed one by one to invoke `BaseRow process(int 
index, BaseRow current)`to get the calculation results of the currentRow.


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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-04 Thread GitBox
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_r272038501
 
 

 ##
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/aggregate/over/frame/OverWindowFrame.java
 ##
 @@ -0,0 +1,44 @@
+/*
+ * 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.dataformat.BinaryRow;
+import org.apache.flink.table.runtime.context.ExecutionContext;
+import org.apache.flink.table.runtime.util.ResettableExternalBuffer;
+
+import java.io.Serializable;
+
+/**
+ * A window frame calculates the results for those records belong to a window 
frame.
+ * Before use a frame must be prepared by passing it all the records in the 
current partition.
+ */
+public interface OverWindowFrame extends Serializable {
+
+   void open(ExecutionContext ctx) throws Exception;
+
+   void resetBuffer(ResettableExternalBuffer rows) throws Exception;
+
+   //return the ACC of the window frame.
+   BaseRow write(int index, BaseRow current) throws Exception;
 
 Review comment:
   Method `write` need modify to `process`.
   
   Over AGG means that every Row has a corresponding output.
   OverWindowFrame is called by:
   1. Get all data and invoke `prepare(Resettable External Buffer rows)` for 
partition
   2. Then each Row is traversed one by one to invoke `BaseRow process(int 
index, BaseRow current)`to get the calculation results of the currentRow.


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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-04 Thread GitBox
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_r272036049
 
 

 ##
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/aggregate/over/frame/OverWindowFrame.java
 ##
 @@ -0,0 +1,44 @@
+/*
+ * 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.dataformat.BinaryRow;
+import org.apache.flink.table.runtime.context.ExecutionContext;
+import org.apache.flink.table.runtime.util.ResettableExternalBuffer;
+
+import java.io.Serializable;
+
+/**
+ * A window frame calculates the results for those records belong to a window 
frame.
+ * Before use a frame must be prepared by passing it all the records in the 
current partition.
+ */
+public interface OverWindowFrame extends Serializable {
+
+   void open(ExecutionContext ctx) throws Exception;
+
+   void resetBuffer(ResettableExternalBuffer rows) throws Exception;
 
 Review comment:
   Means prepare for next partition(window).


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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-04 Thread GitBox
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_r272035934
 
 

 ##
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/aggregate/over/frame/OverWindowFrame.java
 ##
 @@ -0,0 +1,44 @@
+/*
+ * 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.dataformat.BinaryRow;
+import org.apache.flink.table.runtime.context.ExecutionContext;
+import org.apache.flink.table.runtime.util.ResettableExternalBuffer;
+
+import java.io.Serializable;
+
+/**
+ * A window frame calculates the results for those records belong to a window 
frame.
+ * Before use a frame must be prepared by passing it all the records in the 
current partition.
+ */
+public interface OverWindowFrame extends Serializable {
+
+   void open(ExecutionContext ctx) throws Exception;
+
+   void resetBuffer(ResettableExternalBuffer rows) throws Exception;
 
 Review comment:
   Naming `prepare` is more appropriate


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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-04 Thread GitBox
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_r272036049
 
 

 ##
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/aggregate/over/frame/OverWindowFrame.java
 ##
 @@ -0,0 +1,44 @@
+/*
+ * 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.dataformat.BinaryRow;
+import org.apache.flink.table.runtime.context.ExecutionContext;
+import org.apache.flink.table.runtime.util.ResettableExternalBuffer;
+
+import java.io.Serializable;
+
+/**
+ * A window frame calculates the results for those records belong to a window 
frame.
+ * Before use a frame must be prepared by passing it all the records in the 
current partition.
+ */
+public interface OverWindowFrame extends Serializable {
+
+   void open(ExecutionContext ctx) throws Exception;
+
+   void resetBuffer(ResettableExternalBuffer rows) throws Exception;
 
 Review comment:
   Means prepare for next partition.


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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-04 Thread GitBox
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_r272034292
 
 

 ##
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/generated/BoundComparator.java
 ##
 @@ -0,0 +1,49 @@
+/*
+ * 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.generated;
+
+import org.apache.flink.table.dataformat.BaseRow;
+
+import java.io.Serializable;
+
+/**
+ * comparing boundary values.
+ */
+public interface BoundComparator extends Serializable {
+
+   /**
+* reset the comparator.
+*/
+   void reset();
+
+   /**
+* Compares its two row.  Returns a negative integer,
+* zero, or a positive integer as the first argument is less than, equal
+* to, or greater than the second.
+*
+* @param inputRow the first row to be compared.
+* @param inputIndex   the index for the first row.
+* @param currentRow   the second row to be compared.
+* @param currentIndex the index for the second row.
+* @return a negative integer, zero, or a positive integer as the
+* first argument is less than, equal to, or greater than the
+* second.
+*/
+   long compare(BaseRow inputRow, int inputIndex, BaseRow currentRow, int 
currentIndex);
 
 Review comment:
   index is the number of current window.


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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-04 Thread GitBox
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_r272033859
 
 

 ##
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/generated/BoundComparator.java
 ##
 @@ -0,0 +1,49 @@
+/*
+ * 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.generated;
+
+import org.apache.flink.table.dataformat.BaseRow;
+
+import java.io.Serializable;
+
+/**
+ * comparing boundary values.
 
 Review comment:
   
https://docs.oracle.com/cd/E17952_01/mysql-8.0-en/window-functions-frames.html
   Above url has explanation, e.g.:
   CURRENT ROW: For ROWS, the bound is the current row. For RANGE, the bound is 
the peers of the current row.
   UNBOUNDED PRECEDING: The bound is the first partition row.
   UNBOUNDED FOLLOWING: The bound is the last partition row.


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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-04 Thread GitBox
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_r272033041
 
 

 ##
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/generated/BoundComparator.java
 ##
 @@ -0,0 +1,49 @@
+/*
+ * 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.generated;
+
+import org.apache.flink.table.dataformat.BaseRow;
+
+import java.io.Serializable;
+
+/**
+ * comparing boundary values.
+ */
+public interface BoundComparator extends Serializable {
+
+   /**
+* reset the comparator.
+*/
+   void reset();
 
 Review comment:
   Because the field getter of currentRow may be cached.
   For example, the `UnboundedFollowingOverWindowFrame`, when calculating its 
tail boundary, may cross multiple Rows in iterator. The 
`BoundComparator.compare` will be invoked many times is the same `currentRow` 
input, so it is not necessary to get its field value every time, so cached its 
field value in `BoundComparator`.
   `reset` is designed to clear the cache of `BoundComparator`.


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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-04 Thread GitBox
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_r272031198
 
 

 ##
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/generated/BoundComparator.java
 ##
 @@ -0,0 +1,49 @@
+/*
+ * 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.generated;
+
+import org.apache.flink.table.dataformat.BaseRow;
+
+import java.io.Serializable;
+
+/**
+ * comparing boundary values.
+ */
+public interface BoundComparator extends Serializable {
 
 Review comment:
   For example, 
   `SELECT d, e, sum(e) over (partition by d order by e desc range between 5 
PRECEDING and 4 PRECEDING) FROM Table`
   The above SQL is ranged according to the `e` field.
   The previous 5 PRECEDING means that the `e` value of current Row should be 
greater than or equal to the `e` value of range header plus 5.
   So the `BoundComparator` is used to code generate this logic.


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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-03 Thread GitBox
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_r272008044
 
 

 ##
 File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/disk/RandomAccessInputView.java
 ##
 @@ -85,4 +85,9 @@ protected MemorySegment nextSegment(MemorySegment current) 
throws EOFException {
protected int getLimitForSegment(MemorySegment segment) {
return this.currentSegmentIndex == this.segments.size() - 1 ? 
this.limitInLastSegment : this.segmentSize;
}
+
+   public void updateLimitInLastSegment(int value) {
+   this.limitInLastSegment = value;
+   updateCurrentSegmentLimit();
 
 Review comment:
   Merge malfunction, I will delete it.


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


[GitHub] [flink] JingsongLi commented on a change in pull request #8102: [FLINK-12087][table-runtime-blink] Introduce over window operators to blink batch

2019-04-03 Thread GitBox
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_r272007149
 
 

 ##
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/aggregate/over/frame/OverWindowFrame.java
 ##
 @@ -0,0 +1,44 @@
+/*
+ * 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.dataformat.BinaryRow;
+import org.apache.flink.table.runtime.context.ExecutionContext;
+import org.apache.flink.table.runtime.util.ResettableExternalBuffer;
+
+import java.io.Serializable;
+
+/**
+ * A window frame calculates the results for those records belong to a window 
frame.
+ * Before use a frame must be prepared by passing it all the records in the 
current partition.
+ */
+public interface OverWindowFrame extends Serializable {
 
 Review comment:
   
https://docs.oracle.com/cd/E17952_01/mysql-8.0-en/window-functions-frames.html
   window frame is a concept of standard SQL, I'll add some comments.


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