the-other-tim-brown commented on code in PR #13588:
URL: https://github.com/apache/hudi/pull/13588#discussion_r2223065077
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/commit/BaseWriteHelper.java:
##########
@@ -85,9 +103,118 @@ public I combineOnCondition(
* @return Collection of HoodieRecord already be deduplicated
*/
public I deduplicateRecords(I records, HoodieTable<T, I, K, O> table, int
parallelism) {
- HoodieRecordMerger recordMerger =
HoodieRecordUtils.mergerToPreCombineMode(table.getConfig().getRecordMerger());
- return deduplicateRecords(records, table.getIndex(), parallelism,
table.getConfig().getSchema(), table.getConfig().getProps(), recordMerger);
+ HoodieReaderContext<T> readerContext =
table.getContext().<T>getReaderContextFactory(table.getMetaClient()).getContext();
+ Option<String> orderingFieldNameOpt = getOrderingFieldName(readerContext,
table.getConfig().getProps(), table.getMetaClient());
+ BufferedRecordMerger<T> recordMerger = BufferedRecordMergerFactory.create(
+ readerContext,
+ table.getConfig().getRecordMergeMode(),
+ false,
+ Option.ofNullable(table.getConfig().getRecordMerger()),
+ orderingFieldNameOpt,
+ Option.ofNullable(table.getConfig().getPayloadClass()),
+ new SerializableSchema(table.getConfig().getSchema()).get(),
+ table.getConfig().getProps(),
+ table.getMetaClient().getTableConfig().getPartialUpdateMode());
+ this.shouldCheckCustomDeleteMarker =
readerContext.getSchemaHandler().getCustomDeleteMarkerKeyValue().isPresent();
+ this.shouldCheckBuiltInDeleteMarker =
readerContext.getSchemaHandler().hasBuiltInDelete();
+ return deduplicateRecords(
+ records,
+ table.getIndex(),
+ parallelism,
+ table.getConfig().getSchema(),
+ table.getConfig().getProps(),
+ recordMerger,
+ readerContext,
+ orderingFieldNameOpt);
+ }
+
+ public abstract I deduplicateRecords(I records,
+ HoodieIndex<?, ?> index,
+ int parallelism,
+ String schema,
+ TypedProperties props,
+ BufferedRecordMerger<T> merger,
+ HoodieReaderContext<T> readerContext,
+ Option<String> orderingFieldNameOpt);
+
+ public static Option<String> getOrderingFieldName(HoodieReaderContext
readerContext,
+ TypedProperties props,
+ HoodieTableMetaClient
metaClient) {
+ return readerContext.getMergeMode() == RecordMergeMode.COMMIT_TIME_ORDERING
+ ? Option.empty()
+ : Option.ofNullable(ConfigUtils.getOrderingField(props))
+ .or(() -> {
+ String preCombineField =
metaClient.getTableConfig().getPreCombineField();
+ if (StringUtils.isNullOrEmpty(preCombineField)) {
+ return Option.empty();
+ }
+ return Option.of(preCombineField);
+ });
+ }
+
+ /**
+ * Check if the value of column "_hoodie_is_deleted" is true.
+ */
+ public static <T> boolean isBuiltInDeleteRecord(T record,
Review Comment:
These delete checks are the same as the FileGroupReader. Is it possible to
move these utilities into the `BufferedRecord` constructors or at least into
some common class to keep the logic consistent? We can also wrap the three
checks into a single call?
--
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]