You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by mj...@apache.org on 2017/06/20 18:25:35 UTC

[2/4] accumulo git commit: ACCUMULO-4656 print all index levels

ACCUMULO-4656 print all index levels


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/7543ea2b
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/7543ea2b
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/7543ea2b

Branch: refs/heads/master
Commit: 7543ea2b31977c20460c7622f605913d3f3ba9dc
Parents: 5757c89
Author: Keith Turner <kt...@apache.org>
Authored: Tue Jun 20 09:42:56 2017 -0400
Committer: Michael Wall <mj...@gmail.com>
Committed: Tue Jun 20 12:54:37 2017 -0400

----------------------------------------------------------------------
 .../core/file/rfile/MultiLevelIndex.java        | 50 ++++++++++++++++----
 .../apache/accumulo/core/file/rfile/RFile.java  | 11 +++--
 2 files changed, 48 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/7543ea2b/core/src/main/java/org/apache/accumulo/core/file/rfile/MultiLevelIndex.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/MultiLevelIndex.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/MultiLevelIndex.java
index 7ac253d..e129b7b 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/MultiLevelIndex.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/MultiLevelIndex.java
@@ -83,14 +83,6 @@ public class MultiLevelIndex {
       }
     }
 
-    public void printInfo(PrintStream out) {
-      out.println("Key: " + key.toString() + 
-                  " NumEntries: " + entries +
-                  " Offset: " + offset +
-                  " CompressedSize: " + compressedSize +
-                  " RawSize: " + rawSize);
-    }
-    
     @Override
     public void write(DataOutput out) throws IOException {
       key.write(out);
@@ -863,9 +855,49 @@ public class MultiLevelIndex {
       getIndexInfo(rootBlock, sizes, counts);
     }
 
+    private void printIndex(IndexBlock ib, String prefix, PrintStream out) throws IOException {
+      List<IndexEntry> index = ib.getIndex();
+
+      StringBuilder sb = new StringBuilder();
+      sb.append(prefix);
+
+      sb.append("Level: ");
+      sb.append(ib.getLevel());
+
+      int resetLen = sb.length();
+
+      String recursePrefix = prefix + "  ";
+
+      for (IndexEntry ie : index) {
+
+        sb.setLength(resetLen);
+
+        sb.append(" Key: ");
+        sb.append(ie.key);
+        sb.append(" NumEntries: ");
+        sb.append(ie.entries);
+        sb.append(" Offset: ");
+        sb.append(ie.offset);
+        sb.append(" CompressedSize: ");
+        sb.append(ie.compressedSize);
+        sb.append(" RawSize : ");
+        sb.append(ie.rawSize);
+
+        out.println(sb.toString());
+
+        if (ib.getLevel() > 0) {
+          IndexBlock cib = getIndexBlock(ie);
+          printIndex(cib, recursePrefix, out);
+        }
+      }
+    }
+
+    public void printIndex(String prefix, PrintStream out) throws IOException {
+      printIndex(rootBlock, prefix, out);
+    }
+
     public Key getLastKey() {
       return rootBlock.getIndex().get(rootBlock.getIndex().size() - 1).getKey();
     }
   }
-
 }

http://git-wip-us.apache.org/repos/asf/accumulo/blob/7543ea2b/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
index 7ffc5c8..3b11d51 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/RFile.java
@@ -311,13 +311,16 @@ public class RFile {
       while (countIter.hasNext()) {
         IndexEntry indexEntry = countIter.next();
         numKeys += indexEntry.getNumEntries();
-        if (includeIndexDetails) {
-          indexEntry.printInfo(out);
-        }
       }
 
       out.printf("\t%-22s : %,d\n", "Num entries", numKeys);
       out.printf("\t%-22s : %s\n", "Column families", (isDefaultLG && columnFamilies == null ? "<UNKNOWN>" : columnFamilies.keySet()));
+
+      if (includeIndexDetails) {
+        out.printf("\t%-22s :\n", "Index Entries", lastKey);
+        String prefix = String.format("\t   ", "");
+        indexReader.printIndex(prefix, out);
+      }
     }
 
   }
@@ -1386,7 +1389,7 @@ public class RFile {
     public void printInfo() throws IOException {
       printInfo(false);
     }
-    
+
     public void printInfo(boolean includeIndexDetails) throws IOException {
 
       System.out.printf("%-24s : %d\n", "RFile Version", rfileVersion);