n3nash commented on a change in pull request #2374:
URL: https://github.com/apache/hudi/pull/2374#discussion_r550972084
##########
File path:
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/AbstractHoodieWriteClient.java
##########
@@ -821,6 +865,38 @@ protected void finalizeWrite(HoodieTable<T, I, K, O>
table, String instantTime,
}
}
+ private HoodieCommitMetadata resolveWriteConflictIfAny(HoodieTable<T, I, K,
O> table, final String instantTime,
+ HoodieCommitMetadata
thisCommitMetadata) {
+ Long currentTimeInSecs = System.currentTimeMillis() / 1000;
+ ConflictResolutionStrategy resolutionStrategy =
config.getWriteConflictResolutionStrategy();
+ Option<HoodieInstant> lastCompletedInstantBeforeWriterStarted =
this.latestWriteInstantCompletedBeforeWriter.get();
+ String lastInstantTimestamp =
lastCompletedInstantBeforeWriterStarted.isPresent()
+ ? lastCompletedInstantBeforeWriterStarted.get().getTimestamp() : "0";
+ Stream<HoodieInstant> instantStream = table.getActiveTimeline()
+ .getAllCommitsTimeline()
+ .getCommitsAndCompactionTimeline()
+ .filterCompletedInstants()
+ .findInstantsInRange(lastInstantTimestamp,
String.valueOf(currentTimeInSecs))
+ .getInstants();
+
+ LOG.info("Current eligible instants during write oHoodieWriteConfigf
instant " + instantTime + " = "
+ + instantStream.collect(Collectors.toList()));
+
+ boolean hasConflict = instantStream.anyMatch(instant -> {
+ try {
+ return resolutionStrategy.hasConflict(thisCommitMetadata,
HoodieCommitMetadata.fromBytes(
+ table.getActiveTimeline().getInstantDetails(instant).get(),
HoodieCommitMetadata.class));
+ } catch (IOException io) {
+ throw new HoodieCommitException("Unable to determine if conflict
exists", io);
+ }
+ });
+ HoodieCommitMetadata newMetadataAfterConflictResolution =
thisCommitMetadata;
+ if (hasConflict) {
+ newMetadataAfterConflictResolution =
resolutionStrategy.resolveConflict(config, hadoopConf);
Review comment:
Done
----------------------------------------------------------------
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]