yihua commented on code in PR #12826:
URL: https://github.com/apache/hudi/pull/12826#discussion_r1971032326
##########
hudi-cli/src/main/java/org/apache/hudi/cli/commands/CompactionCommand.java:
##########
@@ -181,7 +181,7 @@ public String compactionShowArchived(
try {
archivedTimeline.loadCompactionDetailsInMemory(compactionInstantTime);
HoodieCompactionPlan compactionPlan =
-
TimelineMetadataUtils.deserializeCompactionPlan(archivedTimeline.getInstantDetails(instant).get());
+
TimelineMetadataUtils.deserializeCompactionPlan(archivedTimeline.getInstantContentStream(instant));
Review Comment:
Could we remove the utils in `TimelineMetadataUtils` and provide an API from
the timeline to directly deserialize the avro data:
```
archivedTimeline.deserializeInstantContent(instant, clazz)
```
instead of
```
TimelineMetadataUtils.deserializeCompactionPlan(archivedTimeline.getInstantContentStream(instant))
```
so it's much simpler for the caller to use, and code is easier to understand?
##########
hudi-cli/src/main/java/org/apache/hudi/cli/commands/DiffCommand.java:
##########
@@ -118,14 +117,12 @@ private String printDiffWithMetadata(HoodieTimeline
timeline, Integer limit, Str
.getInstantsAsStream().sorted(instantComparator.requestedTimeOrderedComparator().reversed()).collect(Collectors.toList());
for (final HoodieInstant commit : commits) {
- Option<byte[]> instantDetails = timeline.getInstantDetails(commit);
- if (instantDetails.isPresent()) {
- HoodieCommitMetadata commitMetadata =
layout.getCommitMetadataSerDe().deserialize(commit, instantDetails.get(),
HoodieCommitMetadata.class);
- for (Map.Entry<String, List<HoodieWriteStat>> partitionWriteStat :
- commitMetadata.getPartitionToWriteStats().entrySet()) {
- for (HoodieWriteStat hoodieWriteStat :
partitionWriteStat.getValue()) {
- populateRows(rows, commit, hoodieWriteStat, diffEntity,
diffEntityChecker);
- }
+ HoodieCommitMetadata commitMetadata =
layout.getCommitMetadataSerDe().deserialize(
+ commit, timeline.getInstantContentStream(commit), () ->
timeline.isEmpty(commit), HoodieCommitMetadata.class);
Review Comment:
I think it would be better to expose a simpler API from the timeline to
deserialize the commit metadata, sth like
```
timeline.deserialize(commit, clazz)
```
which calls `metaClient.getCommitMetadataSerDe().deserialize(
commit, getInstantContentStream(commit), () -> isEmpty(commit),
clazz)`
##########
hudi-cli/src/main/java/org/apache/hudi/cli/commands/ExportCommand.java:
##########
@@ -204,7 +204,7 @@ private int copyNonArchivedInstants(List<HoodieInstant>
instants, int limit, Str
switch (instant.getAction()) {
case HoodieTimeline.CLEAN_ACTION: {
HoodieCleanMetadata metadata =
TimelineMetadataUtils.deserializeHoodieCleanMetadata(
- timeline.getInstantDetails(instant).get());
+ timeline.getInstantContentStream(instant));
Review Comment:
Similar here and in other classes on removing `TimelineMetadataUtils` utils
as much as possible.
--
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]