You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/04/15 01:41:46 UTC

[GitHub] [flink] JingsongLi commented on a change in pull request #8156: [FLINK-12168][table-planner-blink] Support e2e limit, sortLimit, rank, union in blink batch

JingsongLi commented on a change in pull request #8156: [FLINK-12168][table-planner-blink] Support e2e limit, sortLimit, rank, union in blink batch
URL: https://github.com/apache/flink/pull/8156#discussion_r275187480
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/plan/nodes/physical/batch/BatchExecRank.scala
 ##########
 @@ -103,4 +111,67 @@ class BatchExecRank(
     val costFactory = planner.getCostFactory.asInstanceOf[FlinkCostFactory]
     costFactory.makeCost(rowCount, cpuCost, 0, 0, memCost)
   }
+
+  override def getDamBehavior: DamBehavior = DamBehavior.PIPELINED
+
+  override def getInputNodes: util.List[ExecNode[BatchTableEnvironment, _]] =
+    List(getInput.asInstanceOf[ExecNode[BatchTableEnvironment, _]])
+
+  override def translateToPlanInternal(
+      tableEnv: BatchTableEnvironment): StreamTransformation[BaseRow] = {
+    val input = getInputNodes.get(0).translateToPlan(tableEnv)
+        .asInstanceOf[StreamTransformation[BaseRow]]
+    val outputType = FlinkTypeFactory.toInternalRowType(getRowType)
+    val partitionBySortingKeys = partitionKey.toArray
+    // The collation for the partition-by fields is inessential here, we only use the
+    // comparator to distinguish different groups.
+    // (order[is_asc], null_is_last)
+    val partitionBySortCollation = partitionBySortingKeys.map(_ => (true, true))
+
+    val inputRowType = FlinkTypeFactory.toInternalRowType(getInput.getRowType)
+    val partitionByCodeGen = new SortCodeGenerator(
+      tableEnv.getConfig,
+      partitionBySortingKeys,
+      partitionBySortingKeys.map(inputRowType.getTypeAt),
+      partitionBySortCollation.map(_._1),
+      partitionBySortCollation.map(_._2))
+
+
+    // The collation for the order-by fields is inessential here, we only use the
+    // comparator to distinguish order-by fields change.
+    // (order[is_asc], null_is_last)
+    val orderByCollation = orderKey.getFieldCollations.map(_ => (true, true)).toArray
+    val orderByKeys = orderKey.getFieldCollations.map(_.getFieldIndex).toArray
+
+    val orderBySortCodeGen = new SortCodeGenerator(
+      tableEnv.getConfig,
+      orderByKeys,
+      orderByKeys.map(inputRowType.getTypeAt),
+      orderByCollation.map(_._1),
+      orderByCollation.map(_._2))
+
+
+    //operator needn't cache data
+    val operator = new RankOperator(
+      partitionByCodeGen.generateRecordComparator("PartitionByComparator"),
 
 Review comment:
   Totally agree.

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


With regards,
Apache Git Services