You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2011/12/02 16:43:22 UTC

svn commit: r1209540 - in /incubator/accumulo/trunk: ./ src/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java

Author: ecn
Date: Fri Dec  2 15:43:22 2011
New Revision: 1209540

URL: http://svn.apache.org/viewvc?rev=1209540&view=rev
Log:
ACCUMULO-201: merge to trunk

Modified:
    incubator/accumulo/trunk/   (props changed)
    incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java

Propchange: incubator/accumulo/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Dec  2 15:43:22 2011
@@ -1,2 +1,2 @@
 /incubator/accumulo/branches/1.3:1190280,1190413,1190420,1190427,1190500,1195622,1195625,1195629,1195635,1196044,1196054,1196057,1196071-1196072,1196106,1197066,1198935,1199383,1203683,1204625,1205547,1205880,1206169,1208031,1209124,1209526,1209532
-/incubator/accumulo/branches/1.4:1201902-1209288,1209528,1209535
+/incubator/accumulo/branches/1.4:1201902-1209288,1209528,1209531,1209535

Modified: incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java?rev=1209540&r1=1209539&r2=1209540&view=diff
==============================================================================
--- incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java (original)
+++ incubator/accumulo/trunk/src/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java Fri Dec  2 15:43:22 2011
@@ -44,9 +44,17 @@ public class PrintInfo {
     Options opts = new Options();
     Option dumpKeys = new Option("d", "dump", false, "dump the key/value pairs");
     opts.addOption(dumpKeys);
+    Option histogramOption = new Option("h", "histogram", false, "print a histogram of the key-value sizes");
+    opts.addOption(histogramOption);
     
     CommandLine commandLine = new BasicParser().parse(opts, args);
     
+    boolean dump = commandLine.hasOption(dumpKeys.getOpt());
+    boolean doHistogram = commandLine.hasOption(histogramOption.getOpt());
+    long countBuckets[] = new long[11];
+    long sizeBuckets[] = new long[countBuckets.length];
+    long totalSize = 0;
+
     for (String arg : commandLine.getArgs()) {
       
       Path path = new Path(arg);
@@ -57,17 +65,30 @@ public class PrintInfo {
       System.out.println();
       org.apache.accumulo.core.file.rfile.bcfile.PrintInfo.main(new String[] {arg});
       
-      if (commandLine.hasOption(dumpKeys.getOpt())) {
+      if (doHistogram || dump) {
         iter.seek(new Range((Key) null, (Key) null), new ArrayList<ByteSequence>(), false);
         while (iter.hasTop()) {
           Key key = iter.getTopKey();
           Value value = iter.getTopValue();
-          System.out.println(key + " -> " + value);
+          if (dump)
+            System.out.println(key + " -> " + value);
+          if (doHistogram) {
+            long size = key.getSize() + value.getSize();
+            int bucket = (int) Math.log10(size);
+            countBuckets[bucket]++;
+            sizeBuckets[bucket] += size;
+            totalSize += size;
+          }
           iter.next();
         }
       }
-      
       iter.close();
+      if (doHistogram) {
+        System.out.println("Up to size      count      %-age");
+        for (int i = 1; i < countBuckets.length; i++) {
+          System.out.println(String.format("%11.0f : %10d %6.2f%%", Math.pow(10, i), countBuckets[i], sizeBuckets[i] * 100. / totalSize));
+        }
+      }
     }
   }
 }