nsivabalan commented on a change in pull request #2206:
URL: https://github.com/apache/hudi/pull/2206#discussion_r511623934



##########
File path: hudi-spark/src/main/java/org/apache/hudi/PreCombineRow.java
##########
@@ -0,0 +1,38 @@
+/*
+ * 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.hudi;
+
+import org.apache.spark.sql.Row;
+
+import java.io.Serializable;
+
+/**
+ * Interface used to preCombine two Spark sql Rows.
+ */
+public interface PreCombineRow extends Serializable {

Review comment:
       @bvaradar : Is there some other option to go about deduping multiple 
Rows. Bcoz, in Bulksert with Rows, we don't have any HoodiePayload. Hence we 
have to operate on "Row"s only. So, have to group by keys and reduce by a 
function. In this patch, I have designed the function as this interface. 
   So, two questions.
   a. Is there a better option. 
   b. Even if we go with this option, I am getting task not serializable when 
executing this, since avro Schema is also sent along with Row. Also, wondering 
this might have any performance complications. 
   
   ```
   Caused by: java.io.NotSerializableException: 
org.apache.avro.Schema$RecordSchema
   Serialization stack:
        - object not serializable (class: org.apache.avro.Schema$RecordSchema, 
value: 
{"type":"record","name":"trip","namespace":"example.schema","fields":[{"name":"_row_key","type":"string"},{"name":"partition","type":"string"},{"name":"ts","type":["long","null"]}]})
        - field (class: org.apache.hudi.TestHoodieDatasetBulkInsertHelper, 
name: schema, type: class org.apache.avro.Schema)
        - object (class org.apache.hudi.TestHoodieDatasetBulkInsertHelper, 
org.apache.hudi.TestHoodieDatasetBulkInsertHelper@8d7718e)
        - field (class: 
org.apache.hudi.TestHoodieDatasetBulkInsertHelper$TestPreCombineRow, name: 
this$0, type: class org.apache.hudi.TestHoodieDatasetBulkInsertHelper)
        - object (class 
org.apache.hudi.TestHoodieDatasetBulkInsertHelper$TestPreCombineRow, 
org.apache.hudi.TestHoodieDatasetBulkInsertHelper$TestPreCombineRow@3436d3d7)
        - element of array (index: 0)
        - array (class [Ljava.lang.Object;, size 1)
        - field (class: java.lang.invoke.SerializedLambda, name: capturedArgs, 
type: class [Ljava.lang.Object;)
        - object (class java.lang.invoke.SerializedLambda, 
SerializedLambda[capturingClass=class org.apache.hudi.SparkRowWriteHelper, 
functionalInterfaceMethod=org/apache/spark/api/java/function/ReduceFunction.call:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;,
 implementation=invokeStatic 
org/apache/hudi/SparkRowWriteHelper.lambda$deduplicateRows$14bf715c$1:(Lorg/apache/hudi/PreCombineRow;Lorg/apache/spark/sql/Row;Lorg/apache/spark/sql/Row;)Lorg/apache/spark/sql/Row;,
 
instantiatedMethodType=(Lorg/apache/spark/sql/Row;Lorg/apache/spark/sql/Row;)Lorg/apache/spark/sql/Row;,
 numCaptured=1])
        - writeReplace data (class: java.lang.invoke.SerializedLambda)
        - object (class 
org.apache.hudi.SparkRowWriteHelper$$Lambda$306/2078785618, 
org.apache.hudi.SparkRowWriteHelper$$Lambda$306/2078785618@19d9ba89)
        - field (class: 
org.apache.spark.sql.KeyValueGroupedDataset$$anonfun$reduceGroups$1, name: f$4, 
type: interface org.apache.spark.api.java.function.ReduceFunction)
        - object (class 
org.apache.spark.sql.KeyValueGroupedDataset$$anonfun$reduceGroups$1, 
<function2>)
        - field (class: org.apache.spark.sql.expressions.ReduceAggregator, 
name: func, type: interface scala.Function2)
        - object (class org.apache.spark.sql.expressions.ReduceAggregator, 
org.apache.spark.sql.expressions.ReduceAggregator@14af73e1)
   ```
   




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


Reply via email to