n3nash commented on a change in pull request #1274: [HUDI-571] Add 'commits 
show archived' command to CLI
URL: https://github.com/apache/incubator-hudi/pull/1274#discussion_r372572403
 
 

 ##########
 File path: 
hudi-cli/src/main/java/org/apache/hudi/cli/commands/CommitsCommand.java
 ##########
 @@ -62,26 +111,38 @@ public String showCommits(
       throws IOException {
 
     HoodieActiveTimeline activeTimeline = 
HoodieCLI.getTableMetaClient().getActiveTimeline();
-    HoodieTimeline timeline = 
activeTimeline.getCommitsTimeline().filterCompletedInstants();
-    List<HoodieInstant> commits = 
timeline.getReverseOrderedInstants().collect(Collectors.toList());
-    List<Comparable[]> rows = new ArrayList<>();
-    for (HoodieInstant commit : commits) {
-      HoodieCommitMetadata commitMetadata =
-          
HoodieCommitMetadata.fromBytes(timeline.getInstantDetails(commit).get(), 
HoodieCommitMetadata.class);
-      rows.add(new Comparable[] {commit.getTimestamp(), 
commitMetadata.fetchTotalBytesWritten(),
-          commitMetadata.fetchTotalFilesInsert(), 
commitMetadata.fetchTotalFilesUpdated(),
-          commitMetadata.fetchTotalPartitionsWritten(), 
commitMetadata.fetchTotalRecordsWritten(),
-          commitMetadata.fetchTotalUpdateRecordsWritten(), 
commitMetadata.fetchTotalWriteErrors()});
-    }
-
-    Map<String, Function<Object, String>> fieldNameToConverterMap = new 
HashMap<>();
-    fieldNameToConverterMap.put("Total Bytes Written", entry -> 
NumericUtils.humanReadableByteCount((Double.parseDouble(entry.toString()))));
+    return printCommits(activeTimeline, limit, sortByField, descending, 
headerOnly);
+  }
 
-    TableHeader header = new 
TableHeader().addTableHeaderField("CommitTime").addTableHeaderField("Total 
Bytes Written")
-        .addTableHeaderField("Total Files Added").addTableHeaderField("Total 
Files Updated")
-        .addTableHeaderField("Total Partitions 
Written").addTableHeaderField("Total Records Written")
-        .addTableHeaderField("Total Update Records 
Written").addTableHeaderField("Total Errors");
-    return HoodiePrintHelper.print(header, fieldNameToConverterMap, 
sortByField, descending, limit, headerOnly, rows);
+  @CliCommand(value = "commits show archived", help = "Show the archived 
commits")
+  public String showArchivedCommits(
+          @CliOption(key = {"startTs"},  mandatory = false, help = "start time 
for commits, default: now - 10 days")
+          String startTs,
+          @CliOption(key = {"endTs"},  mandatory = false, help = "end time for 
commits, default: now - 1 day")
+          String endTs,
+          @CliOption(key = {"limit"}, mandatory = false, help = "Limit 
commits", unspecifiedDefaultValue = "-1")
+          final Integer limit,
+          @CliOption(key = {"sortBy"}, help = "Sorting Field", 
unspecifiedDefaultValue = "")
+          final String sortByField,
+          @CliOption(key = {"desc"}, help = "Ordering", 
unspecifiedDefaultValue = "false")
+          final boolean descending,
+          @CliOption(key = {"headeronly"}, help = "Print Header Only", 
unspecifiedDefaultValue = "false")
+          final boolean headerOnly)
+          throws IOException {
+    if (StringUtils.isNullOrEmpty(startTs)) {
 
 Review comment:
   You can use a defaultValue during the cliOption itself so you don't have to 
use these checks ?

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to