jsbali commented on a change in pull request #2678:
URL: https://github.com/apache/hudi/pull/2678#discussion_r615619290
##########
File path:
hudi-cli/src/main/java/org/apache/hudi/cli/commands/CommitsCommand.java
##########
@@ -431,4 +429,23 @@ public String syncCommits(@CliOption(key = {"path"}, help
= "Path of the table t
return "Load sync state between " +
HoodieCLI.getTableMetaClient().getTableConfig().getTableName() + " and "
+ HoodieCLI.syncTableMetadata.getTableConfig().getTableName();
}
+
+ /*
+ Checks whether a commit or replacecommit action exists in the timeline.
+ * */
+ private Option<HoodieCommitMetadata>
getCommitMetadataForInstant(HoodieTimeline timeline, String instantTime) throws
IOException {
+ List<HoodieInstant> instants = Arrays.asList(
+ new HoodieInstant(false, HoodieTimeline.COMMIT_ACTION,
instantTime),
+ new HoodieInstant(false, HoodieTimeline.REPLACE_COMMIT_ACTION,
instantTime),
+ new HoodieInstant(false, HoodieTimeline.DELTA_COMMIT_ACTION,
instantTime));
+
+ Option<HoodieInstant> hoodieInstant =
Option.fromJavaOptional(instants.stream().filter(timeline::containsInstant).findAny());
Review comment:
Ok, so instead of 3*n we do a linear search and then do 3 comparisons.
Is this what you meant?
`Option<HoodieInstant> instant =
Option.fromJavaOptional(timeline.findInstantsBeforeOrEquals(instantTime).getReverseOrderedInstants().findFirst());`
`if (instant.isPresent()) {
Option<HoodieInstant> hoodieInstant =
Option.fromJavaOptional(instants.stream().filter(i ->
i.equals(instant.get())).findAny());
return hoodieInstant;
}`
--
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]