incubator-accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1210519 - /incubator/accumulo/branches/1.3/src/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
Date Mon, 05 Dec 2011 16:28:15 GMT
Author: ecn
Date: Mon Dec  5 16:28:15 2011
New Revision: 1210519

URL: http://svn.apache.org/viewvc?rev=1210519&view=rev
Log:
ACCUMULO-201: adding tools used to recover from OOM condition during a major compaction

Modified:
    incubator/accumulo/branches/1.3/src/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java

Modified: incubator/accumulo/branches/1.3/src/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.3/src/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java?rev=1210519&r1=1210518&r2=1210519&view=diff
==============================================================================
--- incubator/accumulo/branches/1.3/src/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
(original)
+++ incubator/accumulo/branches/1.3/src/core/src/main/java/org/apache/accumulo/core/file/rfile/PrintInfo.java
Mon Dec  5 16:28:15 2011
@@ -40,9 +40,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);
@@ -51,17 +59,30 @@ public class PrintInfo {
       
       iter.printInfo();
       
-      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));
+        }
+      }
     }
   }
 }



Mime
View raw message