danny0405 commented on code in PR #12379:
URL: https://github.com/apache/hudi/pull/12379#discussion_r1864082260
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/table/action/compact/HoodieCompactor.java:
##########
@@ -130,9 +159,27 @@ public HoodieData<WriteStatus> compact(
TaskContextSupplier taskContextSupplier = table.getTaskContextSupplier();
// if this is a MDT, set up the instant range of log reader just like
regular MDT snapshot reader.
Option<InstantRange> instantRange =
CompactHelpers.getInstance().getInstantRange(metaClient);
- return context.parallelize(operations).map(operation -> compact(
- compactionHandler, metaClient, config, operation,
compactionInstantTime, maxInstantTime, instantRange, taskContextSupplier,
executionHelper))
- .flatMap(List::iterator);
+
+ // do one upfront processing to detect if we need partial update.
+ // if yes, call prepareBroadcast.
+ HoodiePairData<CompactionOperation, Boolean> operationPartialUpdatePair =
context.parallelize(operations)
+ .mapToPair(operation -> Pair.of(operation,
containsPartialUpdate(compactionHandler, metaClient, config, operation,
compactionInstantTime, maxInstantTime,
+ instantRange, taskContextSupplier, executionHelper)));
+ // should we persist operationPartialUpdatePair?
+
+ boolean containsPartialUpdate =
operationPartialUpdatePair.values().collectAsList().stream().anyMatch(partialUpdate
-> partialUpdate);
+ Option<PartialUpdateReaderContext> partialUpdateReaderContextOpt =
Option.empty();
+ if (containsPartialUpdate) {
+ partialUpdateReaderContextOpt = getPartialUpdateReaderContext(context);
+ // Broadcast ParquetFileReader for file group reader if needed.
+ ValidationUtils.checkArgument(partialUpdateReaderContextOpt.isPresent(),
"Partial update cannot be supported without PartialUpdateReaderContext");
+ partialUpdateReaderContextOpt.get().prepareReaderContext();
+ }
+
+ Option<PartialUpdateReaderContext> finalPartialUpdateReaderContextOpt =
partialUpdateReaderContextOpt;
+ return
operationPartialUpdatePair.map((SerializableFunction<Pair<CompactionOperation,
Boolean>, List<WriteStatus>>) v1 -> compact(
Review Comment:
Can we just enable the fg reader compaction for spark then, so that the
detection of partial update log files can be eliminated and the logic can be
simplified a lot.
Another fact is only Spark supports writing partial updates and the fg
reader as of now.
--
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]