hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From open...@apache.org
Subject hbase git commit: HBASE-21473 RowIndexSeekerV1 may return cell with extra two \x00\x00 bytes which has no tags
Date Wed, 14 Nov 2018 15:14:55 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-2.1 0f295de15 -> f8213a719


HBASE-21473 RowIndexSeekerV1 may return cell with extra two \x00\x00 bytes which has no tags


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

Branch: refs/heads/branch-2.1
Commit: f8213a719f1d0322b277435eeca85cfe1e347e3c
Parents: 0f295de
Author: huzheng <openinx@gmail.com>
Authored: Tue Nov 13 11:33:22 2018 +0800
Committer: huzheng <openinx@gmail.com>
Committed: Wed Nov 14 23:17:52 2018 +0800

----------------------------------------------------------------------
 .../hbase/io/encoding/RowIndexSeekerV1.java     |  2 +-
 .../io/encoding/TestDataBlockEncoders.java      | 25 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/f8213a71/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java
----------------------------------------------------------------------
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java
b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java
index 1dd4e19..5c7ca53 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java
+++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/encoding/RowIndexSeekerV1.java
@@ -356,7 +356,7 @@ public class RowIndexSeekerV1 extends AbstractEncodedSeeker {
 
     protected int getCellBufSize() {
       int kvBufSize = KEY_VALUE_LEN_SIZE + keyLength + valueLength;
-      if (includesTags()) {
+      if (includesTags() && tagsLength > 0) {
         kvBufSize += Bytes.SIZEOF_SHORT + tagsLength;
       }
       return kvBufSize;

http://git-wip-us.apache.org/repos/asf/hbase/blob/f8213a71/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 5eb350f..5766517 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
@@ -43,6 +43,7 @@ import org.apache.hadoop.hbase.PrivateCellUtil;
 import org.apache.hadoop.hbase.Tag;
 import org.apache.hadoop.hbase.io.ByteArrayOutputStream;
 import org.apache.hadoop.hbase.io.compress.Compression;
+import org.apache.hadoop.hbase.io.compress.Compression.Algorithm;
 import org.apache.hadoop.hbase.io.hfile.HFileContext;
 import org.apache.hadoop.hbase.io.hfile.HFileContextBuilder;
 import org.apache.hadoop.hbase.nio.SingleByteBuff;
@@ -50,6 +51,7 @@ import org.apache.hadoop.hbase.testclassification.IOTests;
 import org.apache.hadoop.hbase.testclassification.LargeTests;
 import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.hadoop.hbase.util.RedundantKVGenerator;
+import org.junit.Assert;
 import org.junit.ClassRule;
 import org.junit.Test;
 import org.junit.experimental.categories.Category;
@@ -323,6 +325,29 @@ public class TestDataBlockEncoders {
     }
   }
 
+  @Test
+  public void testRowIndexWithTagsButNoTagsInCell() throws IOException {
+    List<KeyValue> kvList = new ArrayList<>();
+    byte[] row = new byte[0];
+    byte[] family = new byte[0];
+    byte[] qualifier = new byte[0];
+    byte[] value = new byte[0];
+    KeyValue expectedKV = new KeyValue(row, family, qualifier, -1L, Type.Put, value);
+    kvList.add(expectedKV);
+    DataBlockEncoding encoding = DataBlockEncoding.ROW_INDEX_V1;
+    DataBlockEncoder encoder = encoding.getEncoder();
+    ByteBuffer encodedBuffer =
+        encodeKeyValues(encoding, kvList, getEncodingContext(Algorithm.NONE, encoding), false);
+    HFileContext meta =
+        new HFileContextBuilder().withHBaseCheckSum(false).withIncludesMvcc(includesMemstoreTS)
+            .withIncludesTags(includesTags).withCompression(Compression.Algorithm.NONE).build();
+    DataBlockEncoder.EncodedSeeker seeker = encoder.createSeeker(CellComparatorImpl.COMPARATOR,
+      encoder.newDataBlockDecodingContext(meta));
+    seeker.setCurrentBuffer(new SingleByteBuff(encodedBuffer));
+    Cell cell = seeker.getCell();
+    Assert.assertEquals(expectedKV.getLength(), ((KeyValue) cell).getLength());
+  }
+
   private void checkSeekingConsistency(List<DataBlockEncoder.EncodedSeeker> encodedSeekers,
       boolean seekBefore, Cell keyValue) {
     Cell expectedKeyValue = null;


Mime
View raw message