[GitHub] [incubator-hudi] nbalajee commented on a change in pull request #1312: [HUDI-571] Add "compactions show archived" command to CLI

2020-02-13 Thread GitBox
nbalajee commented on a change in pull request #1312: [HUDI-571] Add 
"compactions show archived" command to CLI
URL: https://github.com/apache/incubator-hudi/pull/1312#discussion_r379089359
 
 

 ##
 File path: 
hudi-cli/src/main/java/org/apache/hudi/cli/commands/CompactionCommand.java
 ##
 @@ -95,51 +101,9 @@ public String compactionsAll(
   throws IOException {
 HoodieTableMetaClient client = checkAndGetMetaClient();
 HoodieActiveTimeline activeTimeline = client.getActiveTimeline();
-HoodieTimeline timeline = activeTimeline.getCommitsAndCompactionTimeline();
-HoodieTimeline commitTimeline = 
activeTimeline.getCommitTimeline().filterCompletedInstants();
-Set committed = 
commitTimeline.getInstants().map(HoodieInstant::getTimestamp).collect(Collectors.toSet());
-
-List instants = 
timeline.getReverseOrderedInstants().collect(Collectors.toList());
-List rows = new ArrayList<>();
-for (HoodieInstant instant : instants) {
-  HoodieCompactionPlan compactionPlan = null;
-  if (!HoodieTimeline.COMPACTION_ACTION.equals(instant.getAction())) {
-try {
-  // This could be a completed compaction. Assume a compaction request 
file is present but skip if fails
-  compactionPlan = AvroUtils.deserializeCompactionPlan(
-  activeTimeline.readCompactionPlanAsBytes(
-  
HoodieTimeline.getCompactionRequestedInstant(instant.getTimestamp())).get());
-} catch (HoodieIOException ioe) {
-  // SKIP
-}
-  } else {
-compactionPlan = 
AvroUtils.deserializeCompactionPlan(activeTimeline.readCompactionPlanAsBytes(
-
HoodieTimeline.getCompactionRequestedInstant(instant.getTimestamp())).get());
-  }
-
-  if (null != compactionPlan) {
-State state = instant.getState();
-if (committed.contains(instant.getTimestamp())) {
-  state = State.COMPLETED;
-}
-if (includeExtraMetadata) {
-  rows.add(new Comparable[] {instant.getTimestamp(), state.toString(),
-  compactionPlan.getOperations() == null ? 0 : 
compactionPlan.getOperations().size(),
-  compactionPlan.getExtraMetadata().toString()});
-} else {
-  rows.add(new Comparable[] {instant.getTimestamp(), state.toString(),
-  compactionPlan.getOperations() == null ? 0 : 
compactionPlan.getOperations().size()});
-}
-  }
-}
-
-Map> fieldNameToConverterMap = new 
HashMap<>();
-TableHeader header = new TableHeader().addTableHeaderField("Compaction 
Instant Time").addTableHeaderField("State")
-.addTableHeaderField("Total FileIds to be Compacted");
-if (includeExtraMetadata) {
-  header = header.addTableHeaderField("Extra Metadata");
-}
-return HoodiePrintHelper.print(header, fieldNameToConverterMap, 
sortByField, descending, limit, headerOnly, rows);
+return printAllCompactions(activeTimeline,
+compactionPlanReader(this::readCompactionPlanForActiveTimeline, 
activeTimeline),
 
 Review comment:
   Got it.  LGTM.


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:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] [incubator-hudi] nbalajee commented on a change in pull request #1312: [HUDI-571] Add "compactions show archived" command to CLI

2020-02-12 Thread GitBox
nbalajee commented on a change in pull request #1312: [HUDI-571] Add 
"compactions show archived" command to CLI
URL: https://github.com/apache/incubator-hudi/pull/1312#discussion_r378433086
 
 

 ##
 File path: 
hudi-cli/src/main/java/org/apache/hudi/cli/commands/CompactionCommand.java
 ##
 @@ -95,51 +101,9 @@ public String compactionsAll(
   throws IOException {
 HoodieTableMetaClient client = checkAndGetMetaClient();
 HoodieActiveTimeline activeTimeline = client.getActiveTimeline();
-HoodieTimeline timeline = activeTimeline.getCommitsAndCompactionTimeline();
-HoodieTimeline commitTimeline = 
activeTimeline.getCommitTimeline().filterCompletedInstants();
-Set committed = 
commitTimeline.getInstants().map(HoodieInstant::getTimestamp).collect(Collectors.toSet());
-
-List instants = 
timeline.getReverseOrderedInstants().collect(Collectors.toList());
-List rows = new ArrayList<>();
-for (HoodieInstant instant : instants) {
-  HoodieCompactionPlan compactionPlan = null;
-  if (!HoodieTimeline.COMPACTION_ACTION.equals(instant.getAction())) {
-try {
-  // This could be a completed compaction. Assume a compaction request 
file is present but skip if fails
-  compactionPlan = AvroUtils.deserializeCompactionPlan(
-  activeTimeline.readCompactionPlanAsBytes(
-  
HoodieTimeline.getCompactionRequestedInstant(instant.getTimestamp())).get());
-} catch (HoodieIOException ioe) {
-  // SKIP
-}
-  } else {
-compactionPlan = 
AvroUtils.deserializeCompactionPlan(activeTimeline.readCompactionPlanAsBytes(
-
HoodieTimeline.getCompactionRequestedInstant(instant.getTimestamp())).get());
-  }
-
-  if (null != compactionPlan) {
-State state = instant.getState();
-if (committed.contains(instant.getTimestamp())) {
-  state = State.COMPLETED;
-}
-if (includeExtraMetadata) {
-  rows.add(new Comparable[] {instant.getTimestamp(), state.toString(),
-  compactionPlan.getOperations() == null ? 0 : 
compactionPlan.getOperations().size(),
-  compactionPlan.getExtraMetadata().toString()});
-} else {
-  rows.add(new Comparable[] {instant.getTimestamp(), state.toString(),
-  compactionPlan.getOperations() == null ? 0 : 
compactionPlan.getOperations().size()});
-}
-  }
-}
-
-Map> fieldNameToConverterMap = new 
HashMap<>();
-TableHeader header = new TableHeader().addTableHeaderField("Compaction 
Instant Time").addTableHeaderField("State")
-.addTableHeaderField("Total FileIds to be Compacted");
-if (includeExtraMetadata) {
-  header = header.addTableHeaderField("Extra Metadata");
-}
-return HoodiePrintHelper.print(header, fieldNameToConverterMap, 
sortByField, descending, limit, headerOnly, rows);
+return printAllCompactions(activeTimeline,
+compactionPlanReader(this::readCompactionPlanForActiveTimeline, 
activeTimeline),
 
 Review comment:
   Pass timeline containing commit + compaction actions only, instead of 
activeTimeline (which may have other actions)?
   
   HoodieTimeline timeline = activeTimeline.getCommitsAndCompactionTimeline();
   


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:
us...@infra.apache.org


With regards,
Apache Git Services