You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zg...@apache.org on 2018/12/21 01:50:01 UTC
hbase git commit: HBASE-21618 Scan with the same
startRow(inclusive=true) and stopRow(inclusive=false) returns one result
Repository: hbase
Updated Branches:
refs/heads/master 787567336 -> ad819380c
HBASE-21618 Scan with the same startRow(inclusive=true) and stopRow(inclusive=false) returns one result
Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/ad819380
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/ad819380
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/ad819380
Branch: refs/heads/master
Commit: ad819380c744678e719431fb8b1b5e1951bc31b6
Parents: 7875673
Author: Guanghao Zhang <zg...@apache.org>
Authored: Thu Dec 20 11:03:54 2018 +0800
Committer: Guanghao Zhang <zg...@apache.org>
Committed: Fri Dec 21 09:49:24 2018 +0800
----------------------------------------------------------------------
.../hadoop/hbase/protobuf/ProtobufUtil.java | 4 +--
.../hbase/shaded/protobuf/ProtobufUtil.java | 4 +--
.../hbase/shaded/protobuf/TestProtobufUtil.java | 1 +
.../hbase/client/TestFromClientSide3.java | 4 +--
.../client/TestScannersFromClientSide.java | 38 ++++++++++++++++++++
.../hadoop/hbase/protobuf/TestProtobufUtil.java | 1 +
6 files changed, 44 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/hbase/blob/ad819380/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
index 4d54528..a3d49b5 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java
@@ -937,9 +937,7 @@ public final class ProtobufUtil {
if (!scan.includeStartRow()) {
scanBuilder.setIncludeStartRow(false);
}
- if (scan.includeStopRow()) {
- scanBuilder.setIncludeStopRow(true);
- }
+ scanBuilder.setIncludeStopRow(scan.includeStopRow());
if (scan.getReadType() != Scan.ReadType.DEFAULT) {
scanBuilder.setReadType(toReadType(scan.getReadType()));
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/ad819380/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
index cf4c831..fea81f1 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java
@@ -1081,9 +1081,7 @@ public final class ProtobufUtil {
if (!scan.includeStartRow()) {
scanBuilder.setIncludeStartRow(false);
}
- if (scan.includeStopRow()) {
- scanBuilder.setIncludeStopRow(true);
- }
+ scanBuilder.setIncludeStopRow(scan.includeStopRow());
if (scan.getReadType() != Scan.ReadType.DEFAULT) {
scanBuilder.setReadType(toReadType(scan.getReadType()));
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/ad819380/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java
index be51e96..2d8a74a 100644
--- a/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java
+++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/shaded/protobuf/TestProtobufUtil.java
@@ -246,6 +246,7 @@ public class TestProtobufUtil {
scanBuilder.setCacheBlocks(false);
scanBuilder.setCaching(1024);
scanBuilder.setTimeRange(ProtobufUtil.toTimeRange(TimeRange.allTime()));
+ scanBuilder.setIncludeStopRow(false);
ClientProtos.Scan expectedProto = scanBuilder.build();
ClientProtos.Scan actualProto = ProtobufUtil.toScan(
http://git-wip-us.apache.org/repos/asf/hbase/blob/ad819380/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
index 0dee20b..cbfa1bf 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestFromClientSide3.java
@@ -1094,7 +1094,7 @@ public class TestFromClientSide3 {
}
Scan scan = new Scan();
- scan.withStartRow(ROW).withStopRow(ROW).addFamily(FAMILY).setBatch(3)
+ scan.withStartRow(ROW).withStopRow(ROW, true).addFamily(FAMILY).setBatch(3)
.setMaxResultSize(4 * 1024 * 1024);
Result result;
try (ResultScanner scanner = table.getScanner(scan)) {
@@ -1117,7 +1117,7 @@ public class TestFromClientSide3 {
}
scan = new Scan();
- scan.withStartRow(ROW).withStopRow(ROW).addFamily(FAMILY).setBatch(2)
+ scan.withStartRow(ROW).withStopRow(ROW, true).addFamily(FAMILY).setBatch(2)
.setMaxResultSize(4 * 1024 * 1024);
try (ResultScanner scanner = table.getScanner(scan)) {
List<Result> list = new ArrayList<>();
http://git-wip-us.apache.org/repos/asf/hbase/blob/ad819380/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java
index 5e8d107..b91e205 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java
@@ -22,6 +22,7 @@ import static org.apache.hadoop.hbase.ipc.RpcClient.DEFAULT_CODEC_CLASS;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
@@ -897,4 +898,41 @@ public class TestScannersFromClientSide {
}
}
}
+
+ @Test
+ public void testScanWithSameStartRowStopRow() throws IOException {
+ TableName tableName = TableName.valueOf(name.getMethodName());
+ try (Table table = TEST_UTIL.createTable(tableName, FAMILY)) {
+ table.put(new Put(ROW).addColumn(FAMILY, QUALIFIER, VALUE));
+
+ Scan scan = new Scan().withStartRow(ROW).withStopRow(ROW);
+ try (ResultScanner scanner = table.getScanner(scan)) {
+ assertNull(scanner.next());
+ }
+
+ scan = new Scan().withStartRow(ROW, true).withStopRow(ROW, true);
+ try (ResultScanner scanner = table.getScanner(scan)) {
+ Result result = scanner.next();
+ assertNotNull(result);
+ assertArrayEquals(ROW, result.getRow());
+ assertArrayEquals(VALUE, result.getValue(FAMILY, QUALIFIER));
+ assertNull(scanner.next());
+ }
+
+ scan = new Scan().withStartRow(ROW, true).withStopRow(ROW, false);
+ try (ResultScanner scanner = table.getScanner(scan)) {
+ assertNull(scanner.next());
+ }
+
+ scan = new Scan().withStartRow(ROW, false).withStopRow(ROW, false);
+ try (ResultScanner scanner = table.getScanner(scan)) {
+ assertNull(scanner.next());
+ }
+
+ scan = new Scan().withStartRow(ROW, false).withStopRow(ROW, true);
+ try (ResultScanner scanner = table.getScanner(scan)) {
+ assertNull(scanner.next());
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/hbase/blob/ad819380/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java
index 300f029..ff29df8 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/protobuf/TestProtobufUtil.java
@@ -319,6 +319,7 @@ public class TestProtobufUtil {
scanBuilder.setCacheBlocks(false);
scanBuilder.setCaching(1024);
scanBuilder.setTimeRange(ProtobufUtil.toTimeRange(TimeRange.allTime()));
+ scanBuilder.setIncludeStopRow(false);
ClientProtos.Scan expectedProto = scanBuilder.build();
ClientProtos.Scan actualProto = ProtobufUtil.toScan(