You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by op...@apache.org on 2018/11/14 15:07:47 UTC
hbase git commit: HBASE-21473 RowIndexSeekerV1 may return cell with
extra two \x00\x00 bytes which has no tags
Repository: hbase
Updated Branches:
refs/heads/master 640a5e390 -> a8b642067
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/a8b64206
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/a8b64206
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/a8b64206
Branch: refs/heads/master
Commit: a8b642067d208fa2a55f72e607f3639137c07985
Parents: 640a5e3
Author: huzheng <op...@gmail.com>
Authored: Tue Nov 13 11:33:22 2018 +0800
Committer: openinx <op...@gmail.com>
Committed: Wed Nov 14 23:00:12 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/a8b64206/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 e1f00e2..e4c48fa 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/a8b64206/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;