From commits-return-11514-archive-asf-public=cust-asf.ponee.io@hudi.apache.org Thu Feb 13 20:03:32 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 9FA991802C7 for ; Thu, 13 Feb 2020 21:03:32 +0100 (CET) Received: (qmail 91428 invoked by uid 500); 13 Feb 2020 20:03:32 -0000 Mailing-List: contact commits-help@hudi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hudi.apache.org Delivered-To: mailing list commits@hudi.apache.org Received: (qmail 91417 invoked by uid 99); 13 Feb 2020 20:03:32 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Feb 2020 20:03:32 +0000 From: GitBox To: commits@hudi.apache.org Subject: [GitHub] [incubator-hudi] nbalajee commented on a change in pull request #1312: [HUDI-571] Add "compactions show archived" command to CLI Message-ID: <158162421191.14279.13977408550974489852.gitbox@gitbox.apache.org> References: In-Reply-To: Date: Thu, 13 Feb 2020 20:03:31 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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: users@infra.apache.org With regards, Apache Git Services