hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From la...@apache.org
Subject svn commit: r1541312 - in /hbase/trunk: hbase-common/src/main/java/org/apache/hadoop/hbase/ hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/ hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/
Date Tue, 12 Nov 2013 23:30:21 GMT
Author: larsh
Date: Tue Nov 12 23:30:20 2013
New Revision: 1541312

URL: http://svn.apache.org/r1541312
Log:
HBASE-9956 Remove keyLength cache from KeyValue

Modified:
    hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java

Modified: hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java?rev=1541312&r1=1541311&r2=1541312&view=diff
==============================================================================
--- hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java (original)
+++ hbase/trunk/hbase-common/src/main/java/org/apache/hadoop/hbase/KeyValue.java Tue Nov 12
23:30:20 2013
@@ -332,21 +332,6 @@ public class KeyValue implements Cell, H
     this.length = length;
   }
 
-  /**
-   * Creates a KeyValue from the specified byte array, starting at offset,
-   * for length <code>length</code>, and a known <code>keyLength</code>.
-   * @param bytes byte array
-   * @param offset offset to start of the KeyValue
-   * @param length length of the KeyValue
-   * @param keyLength length of the key portion of the KeyValue
-   */
-  public KeyValue(final byte [] bytes, final int offset, final int length, final int keyLength)
{
-    this.bytes = bytes;
-    this.offset = offset;
-    this.length = length;
-    this.keyLength = keyLength;
-  }
-
   /** Constructors that build a new backing byte array from fields */
 
   /**
@@ -1231,13 +1216,8 @@ public class KeyValue implements Cell, H
   /**
    * @return Length of key portion.
    */
-  private int keyLength = 0;
-
   public int getKeyLength() {
-    if (keyLength == 0) {
-      keyLength = Bytes.toInt(this.bytes, this.offset);
-    }
-    return keyLength;
+    return Bytes.toInt(this.bytes, this.offset);
   }
 
   /**
@@ -2856,7 +2836,7 @@ public class KeyValue implements Cell, H
     sum += ClassSize.REFERENCE;// pointer to "bytes"
     sum += ClassSize.align(ClassSize.ARRAY);// "bytes"
     sum += ClassSize.align(length);// number of bytes of data in the "bytes" array
-    sum += 3 * Bytes.SIZEOF_INT;// offset, length, keyLength
+    sum += 2 * Bytes.SIZEOF_INT;// offset, length
     sum += Bytes.SIZEOF_LONG;// memstoreTS
     return ClassSize.align(sum);
   }

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java?rev=1541312&r1=1541311&r2=1541312&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/HFileReaderV2.java
Tue Nov 12 23:30:20 2013
@@ -651,7 +651,7 @@ public class HFileReaderV2 extends Abstr
         return null;
 
       KeyValue ret = new KeyValue(blockBuffer.array(), blockBuffer.arrayOffset()
-          + blockBuffer.position(), getCellBufSize(), currKeyLen);
+          + blockBuffer.position(), getCellBufSize());
       if (this.reader.shouldIncludeMemstoreTS()) {
         ret.setMvccVersion(currMemstoreTS);
       }

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java?rev=1541312&r1=1541311&r2=1541312&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.java
Tue Nov 12 23:30:20 2013
@@ -247,11 +247,12 @@ public class ScanQueryMatcher {
 
     byte [] bytes = kv.getBuffer();
     int offset = kv.getOffset();
-    int initialOffset = offset;
 
     int keyLength = Bytes.toInt(bytes, offset, Bytes.SIZEOF_INT);
     offset += KeyValue.ROW_OFFSET;
 
+    int initialOffset = offset;
+
     short rowLength = Bytes.toShort(bytes, offset, Bytes.SIZEOF_SHORT);
     offset += Bytes.SIZEOF_SHORT;
 
@@ -282,10 +283,10 @@ public class ScanQueryMatcher {
     byte familyLength = bytes [offset];
     offset += familyLength + 1;
 
-    int qualLength = keyLength + KeyValue.ROW_OFFSET -
+    int qualLength = keyLength -
       (offset - initialOffset) - KeyValue.TIMESTAMP_TYPE_SIZE;
 
-    long timestamp = kv.getTimestamp();
+    long timestamp = Bytes.toLong(bytes, initialOffset + keyLength - KeyValue.TIMESTAMP_TYPE_SIZE);
     // check for early out based on timestamp alone
     if (columns.isDone(timestamp)) {
         return columns.getNextRowOrNextColumn(bytes, offset, qualLength);
@@ -304,7 +305,7 @@ public class ScanQueryMatcher {
      * 7. Delete marker need to be version counted together with puts
      *    they affect
      */
-    byte type = kv.getTypeByte();
+    byte type = bytes[initialOffset + keyLength - 1];
     if (kv.isDelete()) {
       if (!keepDeletedCells) {
         // first ignore delete markers if the scanner can do so, and the



Mime
View raw message