incubator-blur-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amccu...@apache.org
Subject [1/3] git commit: Making the list-snapshot command more useful.
Date Tue, 19 Jan 2016 21:05:46 GMT
Repository: incubator-blur
Updated Branches:
  refs/heads/master d9fd6953e -> c65c81d9c


Making the list-snapshot command more useful.


Project: http://git-wip-us.apache.org/repos/asf/incubator-blur/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-blur/commit/31d56a10
Tree: http://git-wip-us.apache.org/repos/asf/incubator-blur/tree/31d56a10
Diff: http://git-wip-us.apache.org/repos/asf/incubator-blur/diff/31d56a10

Branch: refs/heads/master
Commit: 31d56a10e68de22e6b8f7ccf79dee46d99a2cac4
Parents: d9fd695
Author: Aaron McCurry <amccurry@gmail.com>
Authored: Tue Jan 19 15:21:16 2016 -0500
Committer: Aaron McCurry <amccurry@gmail.com>
Committed: Tue Jan 19 15:21:16 2016 -0500

----------------------------------------------------------------------
 .../apache/blur/shell/ListSnapshotsCommand.java | 23 +++++++++++---------
 1 file changed, 13 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-blur/blob/31d56a10/blur-shell/src/main/java/org/apache/blur/shell/ListSnapshotsCommand.java
----------------------------------------------------------------------
diff --git a/blur-shell/src/main/java/org/apache/blur/shell/ListSnapshotsCommand.java b/blur-shell/src/main/java/org/apache/blur/shell/ListSnapshotsCommand.java
index bf53552..ea6f829 100644
--- a/blur-shell/src/main/java/org/apache/blur/shell/ListSnapshotsCommand.java
+++ b/blur-shell/src/main/java/org/apache/blur/shell/ListSnapshotsCommand.java
@@ -22,34 +22,37 @@ import java.io.PrintWriter;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.TreeMap;
 
 import org.apache.blur.thirdparty.thrift_0_9_0.TException;
-import org.apache.blur.thrift.generated.BlurException;
 import org.apache.blur.thrift.generated.Blur.Iface;
+import org.apache.blur.thrift.generated.BlurException;
 
 public class ListSnapshotsCommand extends Command implements TableFirstArgCommand {
 
   @Override
-  public void doit(PrintWriter out, Iface client, String[] args)
-      throws CommandException, TException, BlurException {
+  public void doit(PrintWriter out, Iface client, String[] args) throws CommandException,
TException, BlurException {
     if (args.length != 2) {
       throw new CommandException("Invalid args: " + help());
     }
     String tablename = args[1];
     Map<String, List<String>> snapshotsPerShard = client.listSnapshots(tablename);
+    Map<String, Long> snapshotCounts = new TreeMap<String, Long>();
     for (Entry<String, List<String>> entry : snapshotsPerShard.entrySet()) {
-      String shard = entry.getKey();
-      out.print(shard + " : ");
-      int count = 0;
       for (String snapshot : entry.getValue()) {
-        count++;
-        if (count == entry.getValue().size()) {
-          out.println(snapshot);
+        Long count = snapshotCounts.get(snapshot);
+        if (count == null) {
+          snapshotCounts.put(snapshot, 1L);
         } else {
-          out.print(snapshot + ", ");
+          snapshotCounts.put(snapshot, count + 1L);
         }
       }
     }
+
+    for (Entry<String, Long> e : snapshotCounts.entrySet()) {
+      out.println(e.getKey() + " => shards:" + e.getValue());
+    }
+
   }
 
   @Override


Mime
View raw message