JackieTien97 commented on code in PR #14368:
URL: https://github.com/apache/iotdb/pull/14368#discussion_r1883647853


##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/join/merge/comparator/JoinKeyComparatorFactory.java:
##########
@@ -21,8 +21,20 @@
 
 import org.apache.tsfile.read.common.type.Type;
 
+import java.util.ArrayList;
+import java.util.List;
+
 public class JoinKeyComparatorFactory {
 
+  public static List<JoinKeyComparator> getComparators(
+      List<Type> joinKeyTypes, boolean isAscending) {
+    List<JoinKeyComparator> comparators = new ArrayList<>(joinKeyTypes.size());
+    for (Type joinKeyType : joinKeyTypes) {
+      comparators.add(getComparator(joinKeyType, isAscending));
+    }
+    return comparators;
+  }
+
   public static JoinKeyComparator getComparator(Type type, boolean 
isAscending) {

Review Comment:
   private?



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/planner/optimizations/QueryCardinalityUtil.java:
##########
@@ -207,6 +208,11 @@ public Range<Long> visitTopK(TopKNode node, Void context) {
     //            return node.getSource().accept(this, null);
     //        }
 
+    @Override
+    public Range<Long> visitAggregationTableScan(AggregationTableScanNode 
node, Void context) {
+      return Range.atMost((long) node.getDeviceEntries().size());

Review Comment:
   what if there exists date_bin



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/planner/TableOperatorGenerator.java:
##########
@@ -1315,66 +1323,64 @@ public Operator visitJoin(JoinNode node, 
LocalExecutionPlanContext context) {
       return new MergeSortFullOuterJoinOperator(
           operatorContext,
           leftChild,
-          leftJoinKeyPosition,
+          leftJoinKeyPositions,
           leftOutputSymbolIdx,
           rightChild,
-          rightJoinKeyPosition,
+          rightJoinKeyPositions,
           rightOutputSymbolIdx,
-          JoinKeyComparatorFactory.getComparator(leftJoinKeyType, true),
+          JoinKeyComparatorFactory.getComparators(joinKeyTypes, true),
           dataTypes,
-          leftJoinKeyType,
-          buildUpdateLastRowFunction(leftJoinKeyType.getTypeEnum()));
+          buildUpdateLastRowFunction(joinKeyTypes));
     }
 
     throw new IllegalStateException("Unsupported join type: " + 
node.getJoinType());
   }
 
-  private BiFunction<Column, Integer, TsBlock> 
buildUpdateLastRowFunction(TypeEnum type) {
-    switch (type) {
-      case INT32:
-      case DATE:
-        return (column, rowIndex) ->
-            new TsBlock(
-                1,
-                TIME_COLUMN_TEMPLATE,
-                new IntColumn(1, Optional.empty(), new int[] 
{column.getInt(rowIndex)}));
-      case INT64:
-      case TIMESTAMP:
-        return (column, rowIndex) ->
-            new TsBlock(
-                1,
-                TIME_COLUMN_TEMPLATE,
-                new LongColumn(1, Optional.empty(), new long[] 
{column.getLong(rowIndex)}));
-      case FLOAT:
-        return (column, rowIndex) ->
-            new TsBlock(
-                1,
-                TIME_COLUMN_TEMPLATE,
-                new FloatColumn(1, Optional.empty(), new float[] 
{column.getFloat(rowIndex)}));
-      case DOUBLE:
-        return (column, rowIndex) ->
-            new TsBlock(
-                1,
-                TIME_COLUMN_TEMPLATE,
-                new DoubleColumn(1, Optional.empty(), new double[] 
{column.getDouble(rowIndex)}));
-      case BOOLEAN:
-        return (column, rowIndex) ->
-            new TsBlock(
-                1,
-                TIME_COLUMN_TEMPLATE,
+  private BiFunction<Column[], Integer, TsBlock> buildUpdateLastRowFunction(

Review Comment:
   it seems that you change it back to the old way, it will still do 
switch-case for each call of the BiFunction



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