You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2009/09/16 04:44:21 UTC

svn commit: r815591 - in /hadoop/hbase/branches/0.20: CHANGES.txt src/java/org/apache/hadoop/hbase/io/hfile/HFile.java

Author: stack
Date: Wed Sep 16 02:44:20 2009
New Revision: 815591

URL: http://svn.apache.org/viewvc?rev=815591&view=rev
Log:
HBASE-1818 HFile code review and refinement

Modified:
    hadoop/hbase/branches/0.20/CHANGES.txt
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/io/hfile/HFile.java

Modified: hadoop/hbase/branches/0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/CHANGES.txt?rev=815591&r1=815590&r2=815591&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.20/CHANGES.txt Wed Sep 16 02:44:20 2009
@@ -14,6 +14,7 @@
                timestamp provided
    HBASE-1821  Filtering by SingleColumnValueFilter bug
    HBASE-1840  RowLock fails when used with IndexTable
+   HBASE-1818  HFile code review and refinement (Schubert Zhang via Stack)
 
   IMPROVEMENTS
    HBASE-1819  Update to 0.20.1 hadoop and zk 3.2.1

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/io/hfile/HFile.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/io/hfile/HFile.java?rev=815591&r1=815590&r2=815591&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/io/hfile/HFile.java (original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/io/hfile/HFile.java Wed Sep 16 02:44:20 2009
@@ -168,7 +168,7 @@
     protected String name;
 
     // Total uncompressed bytes, maybe calculate a compression ratio later.
-    private int totalBytes = 0;
+    private long totalBytes = 0;
 
     // Total # of key/value entries, ie: how many times add() was called.
     private int entryCount = 0;
@@ -320,13 +320,12 @@
      */
     private void finishBlock() throws IOException {
       if (this.out == null) return;
-      long size = releaseCompressingStream(this.out);
+      int size = releaseCompressingStream(this.out);
       this.out = null;
       blockKeys.add(firstKey);
-      int written = longToInt(size);
       blockOffsets.add(Long.valueOf(blockBegin));
-      blockDataSizes.add(Integer.valueOf(written));
-      this.totalBytes += written;
+      blockDataSizes.add(Integer.valueOf(size));
+      this.totalBytes += size;
     }
 
     /*
@@ -620,7 +619,7 @@
       appendFileInfo(this.fileinfo, FileInfo.AVG_KEY_LEN,
         Bytes.toBytes(avgKeyLen), false);
       int avgValueLen = this.entryCount == 0? 0:
-        (int)(this.keylength/this.entryCount);
+        (int)(this.valuelength/this.entryCount);
       appendFileInfo(this.fileinfo, FileInfo.AVG_VALUE_LEN,
         Bytes.toBytes(avgValueLen), false);
       appendFileInfo(this.fileinfo, FileInfo.COMPARATOR,
@@ -898,7 +897,7 @@
       if (blockIndex == null) {
         throw new IOException("Block index not loaded");
       }
-      if (block < 0 || block > blockIndex.count) {
+      if (block < 0 || block >= blockIndex.count) {
         throw new IOException("Requested block is out of range: " + block +
           ", max: " + blockIndex.count);
       }
@@ -1251,6 +1250,7 @@
           block.rewind();
           currKeyLen = block.getInt();
           currValueLen = block.getInt();
+          return true;
         }
         currBlock = 0;
         block = reader.readBlock(currBlock, cacheBlocks);