vinothchandar commented on a change in pull request #2106:
URL: https://github.com/apache/hudi/pull/2106#discussion_r509896892
##########
File path:
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/commit/AbstractWriteHelper.java
##########
@@ -25,6 +25,7 @@
import org.apache.hudi.table.HoodieTable;
import org.apache.hudi.table.action.HoodieWriteMetadata;
+import scala.Option;
Review comment:
please use the `Option` class in hudi-common.
##########
File path:
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/table/action/commit/SparkBulkInsertHelper.java
##########
@@ -73,7 +73,7 @@ public static SparkBulkInsertHelper newInstance() {
if (performDedupe) {
dedupedRecords = (JavaRDD<HoodieRecord<T>>)
SparkWriteHelper.newInstance().combineOnCondition(config.shouldCombineBeforeInsert(),
inputRecords,
- config.getBulkInsertShuffleParallelism(), table);
+ config.getBulkInsertShuffleParallelism(), table, null);
Review comment:
same here
##########
File path:
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/commit/AbstractWriteHelper.java
##########
@@ -39,10 +40,23 @@
int shuffleParallelism,
BaseCommitActionExecutor<T, I, K, O, R>
executor,
boolean performTagging) {
+ return write(instantTime, inputRecords, context, table, shouldCombine,
shuffleParallelism,
+ null, executor, performTagging);
Review comment:
given schema is an option, may be passing Option.empty is better?
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/model/OverwritePrecombineAvroPayload.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.common.model;
+
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hudi.avro.HoodieAvroUtils;
+import org.apache.hudi.common.util.Option;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * subclass of OverwriteWithLatestAvroPayload used for delta streamer.
Review comment:
nit: please remove "used for delta streamer". its also used on spark
datasource path
##########
File path:
hudi-client/hudi-spark-client/src/main/java/org/apache/hudi/table/action/commit/SparkWriteHelper.java
##########
@@ -58,7 +60,8 @@ public static SparkWriteHelper newInstance() {
return new Tuple2<>(key, record);
}).reduceByKey((rec1, rec2) -> {
@SuppressWarnings("unchecked")
- T reducedData = (T) rec1.getData().preCombine(rec2.getData());
+ T reducedData = schema != null && !schema.get().isEmpty() ? (T)
rec1.getData().preCombine(rec2.getData(), new
Schema.Parser().parse(schema.get()))
Review comment:
parsing the schema every record will give us performance issues.
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/model/HoodieRecordPayload.java
##########
@@ -41,9 +41,19 @@
* When more than one HoodieRecord have the same HoodieKey, this function
combines them before attempting to
* insert/upsert (if combining turned on in HoodieClientConfig).
*/
- @PublicAPIMethod(maturity = ApiMaturityLevel.STABLE)
+ @Deprecated
T preCombine(T another);
+ /**
+ * When more than one HoodieRecord have the same HoodieKey, this function
combines all fields(which is not null)
+ * before attempting to insert/upsert (if combining turned on in
HoodieClientConfig).
+ *
+ */
+ @PublicAPIMethod(maturity = ApiMaturityLevel.STABLE)
+ default T preCombine(T another, Schema schema) throws IOException {
Review comment:
@bvaradar is exploring if we can just use `combineAndGetUpdateValue()`
for preCombine as well. but I guess, preCombine works with the payload, not
avro records.
WOuld be good to get his inputs as well
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/model/PartialAvroPayload.java
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.common.model;
+
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.avro.generic.IndexedRecord;
+import org.apache.hudi.avro.HoodieAvroUtils;
+import org.apache.hudi.common.util.Option;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * subclass of OverwriteWithLatestAvroPayload used for delta streamer.
+ *
+ * <ol>
+ * <li>Extract the features of OverwritePrecombineAvroPayload and
OverwriteNonDefaultsWithLatestAvroPayload
Review comment:
little bit more explanation on what this class does?
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/model/PartialAvroPayload.java
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.common.model;
+
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.avro.generic.IndexedRecord;
+import org.apache.hudi.avro.HoodieAvroUtils;
+import org.apache.hudi.common.util.Option;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * subclass of OverwriteWithLatestAvroPayload used for delta streamer.
+ *
+ * <ol>
+ * <li>Extract the features of OverwritePrecombineAvroPayload and
OverwriteNonDefaultsWithLatestAvroPayload
+ * </ol>
+ */
+public class PartialAvroPayload extends OverwriteWithLatestAvroPayload {
+ public PartialAvroPayload(GenericRecord record, Comparable orderingVal) {
+ super(record, orderingVal);
+ }
+
+ public PartialAvroPayload(Option<GenericRecord> record) {
+ super(record);
+ }
+
+ @Override
+ public OverwriteWithLatestAvroPayload
preCombine(OverwriteWithLatestAvroPayload another, Schema schema) throws
IOException {
+ // pick the payload with greatest ordering value and aggregate all the
fields,choosing the
+ // value that is not null
+ GenericRecord thisValue = (GenericRecord)
HoodieAvroUtils.bytesToAvro(this.recordBytes, schema);
Review comment:
is the cast necessary? (same question above as well)
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/model/PartialAvroPayload.java
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.common.model;
+
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.avro.generic.IndexedRecord;
+import org.apache.hudi.avro.HoodieAvroUtils;
+import org.apache.hudi.common.util.Option;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * subclass of OverwriteWithLatestAvroPayload used for delta streamer.
Review comment:
fix java docs?
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/model/OverwritePrecombineAvroPayload.java
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.common.model;
+
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.hudi.avro.HoodieAvroUtils;
+import org.apache.hudi.common.util.Option;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * subclass of OverwriteWithLatestAvroPayload used for delta streamer.
+ *
+ * <ol>
+ * <li>preCombine - When more than one HoodieRecord have the same HoodieKey,
this function combines all fields(which is not null)
+ * before attempting to insert/upsert.
+ * eg: 1)
+ * Before:
+ * id name age ts
+ * 1 Karl null 0.0
+ * 1 null 18 0.0
+ * After:
+ * id name age ts
+ * 1 Karl 18 0.0
+ * </ol>
+ */
+public class OverwritePrecombineAvroPayload extends
OverwriteWithLatestAvroPayload {
Review comment:
can we name this better? actually did you intend to add 2 new payloads?
(given there is only test for 1)
##########
File path:
hudi-common/src/main/java/org/apache/hudi/common/model/PartialAvroPayload.java
##########
@@ -0,0 +1,102 @@
+/*
+ * 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.common.model;
+
+import org.apache.avro.Schema;
+import org.apache.avro.generic.GenericRecord;
+import org.apache.avro.generic.IndexedRecord;
+import org.apache.hudi.avro.HoodieAvroUtils;
+import org.apache.hudi.common.util.Option;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * subclass of OverwriteWithLatestAvroPayload used for delta streamer.
+ *
+ * <ol>
+ * <li>Extract the features of OverwritePrecombineAvroPayload and
OverwriteNonDefaultsWithLatestAvroPayload
+ * </ol>
+ */
+public class PartialAvroPayload extends OverwriteWithLatestAvroPayload {
Review comment:
can't this extend OverwritePrecombineWith.... and avoid the code
duplication for preCombine()/combineAllFields()?
----------------------------------------------------------------
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]