flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [flink] KurtYoung commented on a change in pull request #8109: [FLINK-12017][table-planner-blink] Support translation from Rank/Deduplicate to StreamTransformation
Date Mon, 08 Apr 2019 08:27:45 GMT
KurtYoung commented on a change in pull request #8109: [FLINK-12017][table-planner-blink] Support
translation from Rank/Deduplicate to StreamTransformation
URL: https://github.com/apache/flink/pull/8109#discussion_r272878296
 
 

 ##########
 File path: flink-table/flink-table-planner-blink/src/main/scala/org/apache/flink/table/codegen/EqualiserCodeGenerator.scala
 ##########
 @@ -0,0 +1,148 @@
+/*
+ * 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.codegen
+
+import org.apache.flink.table.api.TableConfig
+import org.apache.flink.table.codegen.CodeGenUtils._
+import org.apache.flink.table.codegen.Indenter.toISC
+import org.apache.flink.table.dataformat.{BaseRow, BinaryRow}
+import org.apache.flink.table.generated.{GeneratedRecordEqualiser, RecordEqualiser}
+import org.apache.flink.table.`type`.{DateType, InternalType, PrimitiveType, RowType, TimeType,
TimestampType}
+
+class EqualiserCodeGenerator(fieldTypes: Seq[InternalType]) {
+
+  private val BASE_ROW = className[BaseRow]
+  private val BINARY_ROW = className[BinaryRow]
+  private val RECORD_EQUALISER = className[RecordEqualiser]
+  private val LEFT_INPUT = "left"
+  private val RIGHT_INPUT = "right"
+
+  def generateRecordEqualiser(name: String): GeneratedRecordEqualiser = {
+    // ignore time zone
+    val ctx = CodeGeneratorContext(new TableConfig)
+    val className = newName(name)
+    val header =
+      s"""
+         |if ($LEFT_INPUT.getHeader() != $RIGHT_INPUT.getHeader()) {
+         |  return false;
+         |}
+       """.stripMargin
+
+    val codes = for (i <- fieldTypes.indices) yield {
+      val fieldType = fieldTypes(i)
+      val fieldTypeTerm = primitiveTypeTermForType(fieldType)
+      val result = s"cmp$i"
+      val leftNullTerm = "leftIsNull$" + i
+      val rightNullTerm = "rightIsNull$" + i
+      val leftFieldTerm = "leftField$" + i
+      val rightFieldTerm = "rightField$" + i
+      val equalsCode = if (isInternalPrimitive(fieldType)) {
+        s"$leftFieldTerm == $rightFieldTerm"
+      } else if (isBaseRow(fieldType)) {
+        val equaliserGenerator =
+          new EqualiserCodeGenerator(fieldType.asInstanceOf[RowType].getFieldTypes)
+        val generatedEqualiser = equaliserGenerator
+                                 .generateRecordEqualiser("field$" + i + "GeneratedEqualiser")
 
 Review comment:
   proper indent

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

Mime
View raw message