hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject hbase git commit: HBASE-14657 Remove unneeded API from EncodedSeeker (Heng Chen)
Date Fri, 23 Oct 2015 04:41:18 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.0 252b641e2 -> 47a2b991b


HBASE-14657 Remove unneeded API from EncodedSeeker (Heng Chen)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/47a2b991
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/47a2b991
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/47a2b991

Branch: refs/heads/branch-1.0
Commit: 47a2b991bc5e02ae4fb5221e9660ae2e36c9c08d
Parents: 252b641
Author: stack <stack@apache.org>
Authored: Thu Oct 22 21:32:51 2015 -0700
Committer: stack <stack@apache.org>
Committed: Thu Oct 22 21:41:09 2015 -0700

----------------------------------------------------------------------
 .../io/encoding/BufferedDataBlockEncoder.java   | 34 --------------------
 .../hbase/io/encoding/DataBlockEncoder.java     |  3 --
 .../codec/prefixtree/PrefixTreeSeeker.java      |  8 -----
 .../io/encoding/TestDataBlockEncoders.java      | 14 ++++----
 4 files changed, 7 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/47a2b991/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java
b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java
index dacabe6..74e0567 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/BufferedDataBlockEncoder.java
@@ -595,40 +595,6 @@ abstract class BufferedDataBlockEncoder implements DataBlockEncoder {
     }
 
     @Override
-    public ByteBuffer getKeyValueBuffer() {
-      ByteBuffer kvBuffer = createKVBuffer();
-      kvBuffer.putInt(current.keyLength);
-      kvBuffer.putInt(current.valueLength);
-      kvBuffer.put(current.keyBuffer, 0, current.keyLength);
-      ByteBufferUtils.copyFromBufferToBuffer(kvBuffer, currentBuffer, current.valueOffset,
-          current.valueLength);
-      if (current.tagsLength > 0) {
-        // Put short as unsigned
-        kvBuffer.put((byte) (current.tagsLength >> 8 & 0xff));
-        kvBuffer.put((byte) (current.tagsLength & 0xff));
-        if (current.tagsOffset != -1) {
-          // the offset of the tags bytes in the underlying buffer is marked. So the temp
-          // buffer,tagsBuffer was not been used.
-          ByteBufferUtils.copyFromBufferToBuffer(kvBuffer, currentBuffer, current.tagsOffset,
-              current.tagsLength);
-        } else {
-          // When tagsOffset is marked as -1, tag compression was present and so the tags
were
-          // uncompressed into temp buffer, tagsBuffer. Let us copy it from there
-          kvBuffer.put(current.tagsBuffer, 0, current.tagsLength);
-        }
-      }
-      kvBuffer.rewind();
-      return kvBuffer;
-    }
-
-    protected ByteBuffer createKVBuffer() {
-      int kvBufSize = (int) KeyValue.getKeyValueDataStructureSize(current.keyLength,
-          current.valueLength, current.tagsLength);
-      ByteBuffer kvBuffer = ByteBuffer.allocate(kvBufSize);
-      return kvBuffer;
-    }
-
-    @Override
     public Cell getKeyValue() {
       return current.shallowCopy();
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/47a2b991/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DataBlockEncoder.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DataBlockEncoder.java
b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DataBlockEncoder.java
index 7218ad5..a9f693b 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DataBlockEncoder.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/DataBlockEncoder.java
@@ -154,9 +154,6 @@ public interface DataBlockEncoder {
      */
     ByteBuffer getValueShallowCopy();
     
-    //TODO : to be removed - currently used in testcases only
-    /** @return a key value buffer with the position set at the beginning of the buffer */
-    ByteBuffer getKeyValueBuffer();
 
     /**
      * @return the KeyValue object at the current position. Includes memstore

http://git-wip-us.apache.org/repos/asf/hbase/blob/47a2b991/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/PrefixTreeSeeker.java
----------------------------------------------------------------------
diff --git a/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/PrefixTreeSeeker.java
b/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/PrefixTreeSeeker.java
index b95055c..2888e59 100644
--- a/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/PrefixTreeSeeker.java
+++ b/hbase-prefix-tree/src/main/java/org/apache/hadoop/hbase/codec/prefixtree/PrefixTreeSeeker.java
@@ -88,14 +88,6 @@ public class PrefixTreeSeeker implements EncodedSeeker {
    * currently must do deep copy into new array
    */
   @Override
-  public ByteBuffer getKeyValueBuffer() {
-    return KeyValueUtil.copyToNewByteBuffer(ptSearcher.current());
-  }
-
-  /**
-   * currently must do deep copy into new array
-   */
-  @Override
   public Cell getKeyValue() {
     Cell cell = ptSearcher.current();
     if (cell == null) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/47a2b991/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java
index 1f3525d..896027e 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/io/encoding/TestDataBlockEncoders.java
@@ -256,17 +256,17 @@ public class TestDataBlockEncoders {
       int i = 0;
       do {
         KeyValue expectedKeyValue = sampleKv.get(i);
-        ByteBuffer keyValue = seeker.getKeyValueBuffer();
-        if (0 != Bytes.compareTo(keyValue.array(), keyValue.arrayOffset(), keyValue.limit(),
+        KeyValue keyValue = KeyValueUtil.copyToNewKeyValue(seeker.getKeyValue());
+        if (0 != Bytes.compareTo(keyValue.getBuffer(), keyValue.getOffset(), keyValue.getLength(),
             expectedKeyValue.getBuffer(), expectedKeyValue.getOffset(),
             expectedKeyValue.getLength())) {
 
           int commonPrefix = 0;
-          byte[] left = keyValue.array();
+          byte[] left = keyValue.getBuffer();
           byte[] right = expectedKeyValue.getBuffer();
-          int leftOff = keyValue.arrayOffset();
+          int leftOff = keyValue.getOffset();
           int rightOff = expectedKeyValue.getOffset();
-          int length = Math.min(keyValue.limit(), expectedKeyValue.getLength());
+          int length = Math.min(keyValue.getLength(), expectedKeyValue.getLength());
           while (commonPrefix < length
               && left[commonPrefix + leftOff] == right[commonPrefix + rightOff])
{
             commonPrefix++;
@@ -276,7 +276,7 @@ public class TestDataBlockEncoders {
               + "encoder: %s i: %d commonPrefix: %d" + "\n expected %s\n actual      %s",
encoder
               .toString(), i, commonPrefix, Bytes.toStringBinary(expectedKeyValue.getBuffer(),
               expectedKeyValue.getOffset(), expectedKeyValue.getLength()), Bytes
-              .toStringBinary(keyValue)));
+              .toStringBinary(keyValue.getBuffer())));
         }
         i++;
       } while (seeker.next());
@@ -324,7 +324,7 @@ public class TestDataBlockEncoders {
       seeker.seekToKeyInBlock(keyValue, seekBefore);
       seeker.rewind();
 
-      ByteBuffer actualKeyValue = seeker.getKeyValueBuffer();
+      ByteBuffer actualKeyValue = KeyValueUtil.copyKeyToNewByteBuffer(seeker.getKeyValue());
       ByteBuffer actualKey = seeker.getKeyDeepCopy();
       ByteBuffer actualValue = seeker.getValueShallowCopy();
 


Mime
View raw message