HBASE-21618 Scan with the same startRow(inclusive=true) and stopRow(inclusive=false) returns one result
This commit is contained in:
parent
787567336a
commit
ad819380c7
|
@ -937,9 +937,7 @@ public final class ProtobufUtil {
|
||||||
if (!scan.includeStartRow()) {
|
if (!scan.includeStartRow()) {
|
||||||
scanBuilder.setIncludeStartRow(false);
|
scanBuilder.setIncludeStartRow(false);
|
||||||
}
|
}
|
||||||
if (scan.includeStopRow()) {
|
scanBuilder.setIncludeStopRow(scan.includeStopRow());
|
||||||
scanBuilder.setIncludeStopRow(true);
|
|
||||||
}
|
|
||||||
if (scan.getReadType() != Scan.ReadType.DEFAULT) {
|
if (scan.getReadType() != Scan.ReadType.DEFAULT) {
|
||||||
scanBuilder.setReadType(toReadType(scan.getReadType()));
|
scanBuilder.setReadType(toReadType(scan.getReadType()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1081,9 +1081,7 @@ public final class ProtobufUtil {
|
||||||
if (!scan.includeStartRow()) {
|
if (!scan.includeStartRow()) {
|
||||||
scanBuilder.setIncludeStartRow(false);
|
scanBuilder.setIncludeStartRow(false);
|
||||||
}
|
}
|
||||||
if (scan.includeStopRow()) {
|
scanBuilder.setIncludeStopRow(scan.includeStopRow());
|
||||||
scanBuilder.setIncludeStopRow(true);
|
|
||||||
}
|
|
||||||
if (scan.getReadType() != Scan.ReadType.DEFAULT) {
|
if (scan.getReadType() != Scan.ReadType.DEFAULT) {
|
||||||
scanBuilder.setReadType(toReadType(scan.getReadType()));
|
scanBuilder.setReadType(toReadType(scan.getReadType()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,6 +246,7 @@ public class TestProtobufUtil {
|
||||||
scanBuilder.setCacheBlocks(false);
|
scanBuilder.setCacheBlocks(false);
|
||||||
scanBuilder.setCaching(1024);
|
scanBuilder.setCaching(1024);
|
||||||
scanBuilder.setTimeRange(ProtobufUtil.toTimeRange(TimeRange.allTime()));
|
scanBuilder.setTimeRange(ProtobufUtil.toTimeRange(TimeRange.allTime()));
|
||||||
|
scanBuilder.setIncludeStopRow(false);
|
||||||
ClientProtos.Scan expectedProto = scanBuilder.build();
|
ClientProtos.Scan expectedProto = scanBuilder.build();
|
||||||
|
|
||||||
ClientProtos.Scan actualProto = ProtobufUtil.toScan(
|
ClientProtos.Scan actualProto = ProtobufUtil.toScan(
|
||||||
|
|
|
@ -1094,7 +1094,7 @@ public class TestFromClientSide3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
Scan scan = new Scan();
|
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);
|
.setMaxResultSize(4 * 1024 * 1024);
|
||||||
Result result;
|
Result result;
|
||||||
try (ResultScanner scanner = table.getScanner(scan)) {
|
try (ResultScanner scanner = table.getScanner(scan)) {
|
||||||
|
@ -1117,7 +1117,7 @@ public class TestFromClientSide3 {
|
||||||
}
|
}
|
||||||
|
|
||||||
scan = new Scan();
|
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);
|
.setMaxResultSize(4 * 1024 * 1024);
|
||||||
try (ResultScanner scanner = table.getScanner(scan)) {
|
try (ResultScanner scanner = table.getScanner(scan)) {
|
||||||
List<Result> list = new ArrayList<>();
|
List<Result> list = new ArrayList<>();
|
||||||
|
|
|
@ -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.assertArrayEquals;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -319,6 +319,7 @@ public class TestProtobufUtil {
|
||||||
scanBuilder.setCacheBlocks(false);
|
scanBuilder.setCacheBlocks(false);
|
||||||
scanBuilder.setCaching(1024);
|
scanBuilder.setCaching(1024);
|
||||||
scanBuilder.setTimeRange(ProtobufUtil.toTimeRange(TimeRange.allTime()));
|
scanBuilder.setTimeRange(ProtobufUtil.toTimeRange(TimeRange.allTime()));
|
||||||
|
scanBuilder.setIncludeStopRow(false);
|
||||||
ClientProtos.Scan expectedProto = scanBuilder.build();
|
ClientProtos.Scan expectedProto = scanBuilder.build();
|
||||||
|
|
||||||
ClientProtos.Scan actualProto = ProtobufUtil.toScan(
|
ClientProtos.Scan actualProto = ProtobufUtil.toScan(
|
||||||
|
|
Loading…
Reference in New Issue