You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/01/24 06:52:06 UTC

[GitHub] [incubator-hudi] n3nash commented on a change in pull request #1274: [HUDI-571] Add 'commits show archived' command to CLI

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_r370493642
 
 

 ##########
 File path: hudi-cli/src/main/java/org/apache/hudi/cli/commands/CommitsCommand.java
 ##########
 @@ -62,26 +110,33 @@ 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()});
-    }
+    return printCommits(activeTimeline, limit, sortByField, descending, headerOnly);
+  }
 
-    Map<String, Function<Object, String>> fieldNameToConverterMap = new HashMap<>();
-    fieldNameToConverterMap.put("Total Bytes Written", entry -> NumericUtils.humanReadableByteCount((Double.parseDouble(entry.toString()))));
+  @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 {
 
-    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);
+    if (startTs == null || startTs.isEmpty()) {
 
 Review comment:
   Can we use StringUtils.isNullOrEmpty (in all other places as well) ?

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


With regards,
Apache Git Services