JingsongLi commented on a change in pull request #13921:
URL: https://github.com/apache/flink/pull/13921#discussion_r642178367



##########
File path: 
flink-table/flink-table-planner-blink/src/main/java/org/apache/flink/table/planner/plan/nodes/exec/stream/StreamExecRank.java
##########
@@ -207,18 +209,35 @@ public StreamExecRank(
 
         AbstractTopNFunction processFunction;
         if (rankStrategy instanceof RankProcessStrategy.AppendFastStrategy) {
-            processFunction =
-                    new AppendOnlyTopNFunction(
-                            minIdleStateRetentionTime,
-                            maxIdleStateRetentionTime,
-                            inputRowTypeInfo,
-                            sortKeyComparator,
-                            sortKeySelector,
-                            rankType,
-                            rankRange,
-                            generateUpdateBefore,
-                            outputRankNumber,
-                            cacheSize);
+            if (sortFields.length == 1
+                    && inputType.getChildren().get(sortFields[0]).getTypeRoot()
+                            == LogicalTypeRoot.TIMESTAMP_WITHOUT_TIME_ZONE

Review comment:
       Just `TIMESTAMP_WITHOUT_TIME_ZONE`? I don't see any `proc-time`.

##########
File path: 
flink-table/flink-table-runtime-blink/src/main/java/org/apache/flink/table/runtime/operators/rank/AppendOnlyFirstNFunction.java
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.operators.rank;
+
+import org.apache.flink.api.common.state.StateTtlConfig;
+import org.apache.flink.api.common.state.ValueState;
+import org.apache.flink.api.common.state.ValueStateDescriptor;
+import org.apache.flink.api.common.typeinfo.Types;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.table.data.RowData;
+import org.apache.flink.table.runtime.generated.GeneratedRecordComparator;
+import org.apache.flink.table.runtime.keyselector.RowDataKeySelector;
+import org.apache.flink.table.runtime.typeutils.InternalTypeInfo;
+import org.apache.flink.types.RowKind;
+import org.apache.flink.util.Collector;
+import org.apache.flink.util.Preconditions;
+
+import static 
org.apache.flink.table.runtime.util.StateConfigUtil.createTtlConfig;
+
+/**
+ * A variant of {@link AppendOnlyTopNFunction} to handle first-n case.
+ *
+ * <p>The input stream should only contain INSERT messages.
+ */
+public class AppendOnlyFirstNFunction extends AbstractTopNFunction {
+
+    private static final long serialVersionUID = -889227691088906246L;

Review comment:
       serialVersionUID  should be 1L at first, From the Flink code style.




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


Reply via email to