wuchong commented on a change in pull request #8203: 
[Flink-12208][table-planner-blink] Support translation from StreamExecSort / 
TemporalSort / SortLimit/ Limit to StreamTransformation.
URL: https://github.com/apache/flink/pull/8203#discussion_r277193178
 
 

 ##########
 File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/sort/RowTimeSortOperator.java
 ##########
 @@ -0,0 +1,143 @@
+/*
+ * 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.sort;
+
+import org.apache.flink.api.common.state.MapState;
+import org.apache.flink.api.common.state.MapStateDescriptor;
+import org.apache.flink.api.common.state.ValueState;
+import org.apache.flink.api.common.state.ValueStateDescriptor;
+import org.apache.flink.api.common.typeinfo.BasicTypeInfo;
+import org.apache.flink.api.java.typeutils.ListTypeInfo;
+import org.apache.flink.runtime.state.VoidNamespace;
+import org.apache.flink.streaming.api.operators.InternalTimer;
+import org.apache.flink.streaming.runtime.streamrecord.StreamRecord;
+import org.apache.flink.table.dataformat.BaseRow;
+import org.apache.flink.table.generated.GeneratedRecordComparator;
+import org.apache.flink.table.generated.RecordComparator;
+import org.apache.flink.table.typeutils.BaseRowTypeInfo;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * Sort based on event-time and possibly additional secondary sort attributes.
+ */
+public class RowTimeSortOperator extends BaseTemporalSortOperator {
+
+       private static final long serialVersionUID = 2085278292749212811L;
+
+       private static final Logger LOG = 
LoggerFactory.getLogger(RowTimeSortOperator.class);
+
+       private final BaseRowTypeInfo inputRowType;
+       private final int rowTimeIdx;
+
+       private GeneratedRecordComparator gComparator;
+       private transient RecordComparator comparator;
+
+       // State to collect rows between watermarks.
+       private transient MapState<Long, List<BaseRow>> dataState;
+       // State to keep the last triggering timestamp. Used to filter late 
events.
+       private transient ValueState<Long> lastTriggeringTsState;
+
+       /**
+        * @param inputRowType The data type of the input data.
+        * @param rowTimeIdx The index of the rowTime field.
+        * @param gComparator generated comparator, could be null if only sort 
on RowTime field
+        */
+       public RowTimeSortOperator(BaseRowTypeInfo inputRowType, int 
rowTimeIdx, GeneratedRecordComparator gComparator) {
+               this.inputRowType = inputRowType;
+               this.rowTimeIdx = rowTimeIdx;
 
 Review comment:
   Add a validation check for rowTimeIdx to avoid invalid index ? 

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