hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1002310 - /hbase/trunk/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java
Date Tue, 28 Sep 2010 18:29:53 GMT
Author: stack
Date: Tue Sep 28 18:29:53 2010
New Revision: 1002310

URL: http://svn.apache.org/viewvc?rev=1002310&view=rev
Log:
HBASE-3040 BlockIndex readIndex too slowly in heavy write scenario; add in fix to address
kannan review

Modified:
    hbase/trunk/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java

Modified: hbase/trunk/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java
URL: http://svn.apache.org/viewvc/hbase/trunk/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java?rev=1002310&r1=1002309&r2=1002310&view=diff
==============================================================================
--- hbase/trunk/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java (original)
+++ hbase/trunk/src/main/java/org/apache/hadoop/hbase/io/hfile/HFile.java Tue Sep 28 18:29:53
2010
@@ -830,11 +830,12 @@ public class HFile {
     DataInputStream dis = new DataInputStream(bis);
 
       // Read in the data index.
-    this.blockIndex = BlockIndex.readIndexEx(this.comparator, dis, this.trailer.dataIndexCount);
+    this.blockIndex =
+      BlockIndex.readIndex(this.comparator, dis, this.trailer.dataIndexCount);
 
       // Read in the metadata index.
       if (trailer.metaIndexCount > 0) {
-      this.metaIndex = BlockIndex.readIndexEx(Bytes.BYTES_RAWCOMPARATOR, dis,
+      this.metaIndex = BlockIndex.readIndex(Bytes.BYTES_RAWCOMPARATOR, dis,
         this.trailer.metaIndexCount);
       }
       this.fileInfoLoaded = true;
@@ -1670,45 +1671,13 @@ public class HFile {
     /*
      * Read in the index that is at <code>indexOffset</code>
      * Must match what was written by writeIndex in the Writer.close.
+     * @param c Comparator to use.
      * @param in
-     * @param indexOffset
+     * @param indexSize
      * @throws IOException
      */
     static BlockIndex readIndex(final RawComparator<byte []> c,
-        final FSDataInputStream in, final long indexOffset, final int indexSize)
-    throws IOException {
-      BlockIndex bi = new BlockIndex(c);
-      bi.blockOffsets = new long[indexSize];
-      bi.blockKeys = new byte[indexSize][];
-      bi.blockDataSizes = new int[indexSize];
-      // If index size is zero, no index was written.
-      if (indexSize > 0) {
-        in.seek(indexOffset);
-        byte [] magic = new byte[INDEXBLOCKMAGIC.length];
-        IOUtils.readFully(in, magic, 0, magic.length);
-        if (!Arrays.equals(magic, INDEXBLOCKMAGIC)) {
-          throw new IOException("Index block magic is wrong: " +
-            Arrays.toString(magic));
-        }
-        for (int i = 0; i < indexSize; ++i ) {
-          long offset   = in.readLong();
-          int dataSize  = in.readInt();
-          byte [] key = Bytes.readByteArray(in);
-          bi.add(key, offset, dataSize);
-        }
-      }
-      return bi;
-    }
-
-    /*
-     * Read in the index that is at <code>indexOffset</code>
-     * Must match what was written by writeIndex in the Writer.close.
-     * @param in
-     * @param indexOffset
-     * @throws IOException
-     */
-    static BlockIndex readIndexEx(final RawComparator<byte []> c, DataInputStream in,
-        final int indexSize)
+        DataInputStream in, final int indexSize)
     throws IOException {
       BlockIndex bi = new BlockIndex(c);
       bi.blockOffsets = new long[indexSize];



Mime
View raw message