HBASE-23848 Removed deprecated setStopRow from Scan (#1184)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
This commit is contained in:
Jan Hentschel 2020-04-22 09:15:17 +02:00 committed by GitHub
parent bc9184ee00
commit 75c717d4c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 44 additions and 71 deletions

View File

@ -1502,7 +1502,7 @@ public final class BackupSystemTable implements Closeable {
byte[] stopRow = Arrays.copyOf(startRow, startRow.length);
stopRow[stopRow.length - 1] = (byte) (stopRow[stopRow.length - 1] + 1);
scan.withStartRow(startRow);
scan.setStopRow(stopRow);
scan.withStopRow(stopRow);
scan.addFamily(BackupSystemTable.SESSIONS_FAMILY);
scan.readVersions(1);
return scan;
@ -1542,7 +1542,7 @@ public final class BackupSystemTable implements Closeable {
byte[] stopRow = Arrays.copyOf(startRow, startRow.length);
stopRow[stopRow.length - 1] = (byte) (stopRow[stopRow.length - 1] + 1);
scan.withStartRow(startRow);
scan.setStopRow(stopRow);
scan.withStopRow(stopRow);
scan.addFamily(BackupSystemTable.META_FAMILY);
return scan;
@ -1583,7 +1583,7 @@ public final class BackupSystemTable implements Closeable {
byte[] stopRow = Arrays.copyOf(startRow, startRow.length);
stopRow[stopRow.length - 1] = (byte) (stopRow[stopRow.length - 1] + 1);
scan.withStartRow(startRow);
scan.setStopRow(stopRow);
scan.withStopRow(stopRow);
scan.addFamily(BackupSystemTable.META_FAMILY);
scan.readVersions(1);
@ -1892,7 +1892,7 @@ public final class BackupSystemTable implements Closeable {
byte[] stopRow = Arrays.copyOf(startRow, startRow.length);
stopRow[stopRow.length - 1] = (byte) (stopRow[stopRow.length - 1] + 1);
scan.withStartRow(startRow);
scan.setStopRow(stopRow);
scan.withStopRow(stopRow);
scan.addFamily(BackupSystemTable.META_FAMILY);
scan.readVersions(1);
return scan;
@ -1940,7 +1940,7 @@ public final class BackupSystemTable implements Closeable {
byte[] stopRow = Arrays.copyOf(startRow, startRow.length);
stopRow[stopRow.length - 1] = (byte) (stopRow[stopRow.length - 1] + 1);
scan.withStartRow(startRow);
scan.setStopRow(stopRow);
scan.withStopRow(stopRow);
scan.addFamily(BackupSystemTable.META_FAMILY);
return scan;
}
@ -1967,7 +1967,7 @@ public final class BackupSystemTable implements Closeable {
byte[] stopRow = Arrays.copyOf(startRow, startRow.length);
stopRow[stopRow.length - 1] = (byte) (stopRow[stopRow.length - 1] + 1);
scan.withStartRow(startRow);
scan.setStopRow(stopRow);
scan.withStopRow(stopRow);
scan.addFamily(BackupSystemTable.META_FAMILY);
return scan;
}

View File

@ -577,7 +577,7 @@ public class MetaTableAccessor {
Scan scan = getMetaScan(connection, -1);
scan.withStartRow(startKey);
scan.setStopRow(stopKey);
scan.withStopRow(stopKey);
return scan;
}

View File

@ -399,34 +399,6 @@ public class Scan extends Query {
return this;
}
/**
* Set the stop row of the scan.
* <p>
* The scan will include rows that are lexicographically less than the provided stopRow.
* <p>
* <b>Note:</b> When doing a filter for a rowKey <u>Prefix</u> use
* {@link #setRowPrefixFilter(byte[])}. The 'trailing 0' will not yield the desired result.
* </p>
* @param stopRow row to end at (exclusive)
* @return this
* @throws IllegalArgumentException if stopRow does not meet criteria for a row key (when length
* exceeds {@link HConstants#MAX_ROW_LENGTH})
* @deprecated since 2.0.0 and will be removed in 3.0.0. Use {@link #withStopRow(byte[])} instead.
* This method may change the inclusive of the stop row to keep compatible with the old
* behavior.
* @see #withStopRow(byte[])
* @see <a href="https://issues.apache.org/jira/browse/HBASE-17320">HBASE-17320</a>
*/
@Deprecated
public Scan setStopRow(byte[] stopRow) {
withStopRow(stopRow);
if (ClientUtil.areScanStartRowAndStopRowEqual(this.startRow, this.stopRow)) {
// for keeping the old behavior that a scan with the same start and stop row is a get scan.
this.includeStopRow = true;
}
return this;
}
/**
* Set the stop row of the scan.
* <p>
@ -471,7 +443,7 @@ public class Scan extends Query {
* <p>This is a utility method that converts the desired rowPrefix into the appropriate values
* for the startRow and stopRow to achieve the desired result.</p>
* <p>This can safely be used in combination with setFilter.</p>
* <p><b>NOTE: Doing a {@link #withStartRow(byte[])} and/or {@link #setStopRow(byte[])}
* <p><b>NOTE: Doing a {@link #withStartRow(byte[])} and/or {@link #withStopRow(byte[])}
* after this method will yield undefined results.</b></p>
* @param rowPrefix the prefix all rows must start with. (Set <i>null</i> to remove the filter.)
* @return this
@ -479,10 +451,10 @@ public class Scan extends Query {
public Scan setRowPrefixFilter(byte[] rowPrefix) {
if (rowPrefix == null) {
withStartRow(HConstants.EMPTY_START_ROW);
setStopRow(HConstants.EMPTY_END_ROW);
withStopRow(HConstants.EMPTY_END_ROW);
} else {
this.withStartRow(rowPrefix);
this.setStopRow(ClientUtil.calculateTheClosestNextRowKeyForPrefix(rowPrefix));
this.withStopRow(ClientUtil.calculateTheClosestNextRowKeyForPrefix(rowPrefix));
}
return this;
}

View File

@ -205,11 +205,11 @@ public class TestScan {
fail("expected IllegalArgumentException to be thrown");
}
scan.setStopRow(null);
scan.setStopRow(new byte[1]);
scan.setStopRow(new byte[HConstants.MAX_ROW_LENGTH]);
scan.withStopRow(null);
scan.withStopRow(new byte[1]);
scan.withStopRow(new byte[HConstants.MAX_ROW_LENGTH]);
try {
scan.setStopRow(new byte[HConstants.MAX_ROW_LENGTH+1]);
scan.withStopRow(new byte[HConstants.MAX_ROW_LENGTH+1]);
fail("should've thrown exception");
} catch (IllegalArgumentException iae) {
} catch (Exception e) {

View File

@ -1655,8 +1655,9 @@ public class IntegrationTestBigLinkedList extends IntegrationTestBase {
if (cmd.hasOption("s"))
scan.withStartRow(Bytes.toBytesBinary(cmd.getOptionValue("s")));
if (cmd.hasOption("e"))
scan.setStopRow(Bytes.toBytesBinary(cmd.getOptionValue("e")));
if (cmd.hasOption("e")) {
scan.withStopRow(Bytes.toBytesBinary(cmd.getOptionValue("e")));
}
int limit = 0;
if (cmd.hasOption("l"))

View File

@ -124,7 +124,7 @@ public final class ExportUtils {
s.withStartRow(Bytes.toBytesBinary(conf.get(TableInputFormat.SCAN_ROW_START)));
}
if (conf.get(TableInputFormat.SCAN_ROW_STOP) != null) {
s.setStopRow(Bytes.toBytesBinary(conf.get(TableInputFormat.SCAN_ROW_STOP)));
s.withStopRow(Bytes.toBytesBinary(conf.get(TableInputFormat.SCAN_ROW_STOP)));
}
// Set Scan Column Family
boolean raw = Boolean.parseBoolean(conf.get(RAW_SCAN));

View File

@ -198,7 +198,7 @@ public class HashTable extends Configured implements Tool {
scan.withStartRow(startRow);
}
if (!isTableEndRow(stopRow)) {
scan.setStopRow(stopRow);
scan.withStopRow(stopRow);
}
if(families != null) {
for(String fam : families.split(",")) {

View File

@ -39,13 +39,13 @@ import org.apache.hadoop.hbase.client.Scan;
*
* Scan scan1 = new Scan();
* scan1.withStartRow(firstRow1);
* scan1.setStopRow(lastRow1);
* scan1.withStopRow(lastRow1);
* scan1.setAttribute(Scan.SCAN_ATTRIBUTES_TABLE_NAME, table1);
* scans.add(scan1);
*
* Scan scan2 = new Scan();
* scan2.withStartRow(firstRow2);
* scan2.setStopRow(lastRow2);
* scan2.withStopRow(lastRow2);
* scan1.setAttribute(Scan.SCAN_ATTRIBUTES_TABLE_NAME, table2);
* scans.add(scan2);
*

View File

@ -99,7 +99,7 @@ public abstract class MultiTableInputFormatBase extends
try {
Scan sc = tSplit.getScan();
sc.withStartRow(tSplit.getStartRow());
sc.setStopRow(tSplit.getEndRow());
sc.withStopRow(tSplit.getEndRow());
trr.setScan(sc);
trr.setTable(table);
return new RecordReader<ImmutableBytesWritable, Result>() {

View File

@ -172,7 +172,7 @@ public class RowCounter extends AbstractHBaseTool {
if (size == 1) {
MultiRowRangeFilter.RowRange range = rowRangeList.get(0);
scan.withStartRow(range.getStartRow()); //inclusive
scan.setStopRow(range.getStopRow()); //exclusive
scan.withStopRow(range.getStopRow()); //exclusive
} else if (size > 1) {
scan.setFilter(new MultiRowRangeFilter(rowRangeList));
}

View File

@ -341,7 +341,7 @@ public class SyncTable extends Configured implements Tool {
ImmutableBytesWritable stopRow) throws IOException, InterruptedException {
Scan scan = sourceTableHash.initScan();
scan.withStartRow(startRow.copyBytes());
scan.setStopRow(stopRow.copyBytes());
scan.withStopRow(stopRow.copyBytes());
ResultScanner sourceScanner = sourceTable.getScanner(scan);
CellScanner sourceCells = new CellScanner(sourceScanner.iterator());
@ -683,9 +683,9 @@ public class SyncTable extends Configured implements Tool {
Scan scan = sourceTableHash.initScan();
scan.withStartRow(splitEndRow);
if (nextSourceKey == null) {
scan.setStopRow(sourceTableHash.stopRow);
scan.withStopRow(sourceTableHash.stopRow);
} else {
scan.setStopRow(nextSourceKey.copyBytes());
scan.withStopRow(nextSourceKey.copyBytes());
}
ResultScanner targetScanner = null;

View File

@ -152,7 +152,7 @@ implements Configurable {
}
if (conf.get(SCAN_ROW_STOP) != null) {
scan.setStopRow(Bytes.toBytesBinary(conf.get(SCAN_ROW_STOP)));
scan.withStopRow(Bytes.toBytesBinary(conf.get(SCAN_ROW_STOP)));
}
if (conf.get(SCAN_COLUMNS) != null) {

View File

@ -182,7 +182,7 @@ public abstract class TableInputFormatBase
this.tableRecordReader != null ? this.tableRecordReader : new TableRecordReader();
Scan sc = new Scan(this.scan);
sc.withStartRow(tSplit.getStartRow());
sc.setStopRow(tSplit.getEndRow());
sc.withStopRow(tSplit.getEndRow());
trr.setScan(sc);
trr.setTable(getTable());
return new RecordReader<ImmutableBytesWritable, Result>() {

View File

@ -208,7 +208,7 @@ public class VerifyReplication extends Configured implements Tool {
endRow = ((TableSplit) tableSplit).getEndRow();
}
scan.setStopRow(endRow);
scan.withStopRow(endRow);
String peerSnapshotName = conf.get(NAME + ".peerSnapshotName", null);
if (peerSnapshotName != null) {
@ -514,7 +514,7 @@ public class VerifyReplication extends Configured implements Tool {
scan.withStartRow(startPrefixRow);
byte[] stopRow = Bytes.add(Bytes.head(lastPrefixRow, lastPrefixRow.length - 1),
new byte[]{(byte) (lastPrefixRow[lastPrefixRow.length - 1] + 1)});
scan.setStopRow(stopRow);
scan.withStopRow(stopRow);
}
@VisibleForTesting

View File

@ -241,7 +241,7 @@ public abstract class MultiTableInputFormatTestBase {
scan.withStartRow(Bytes.toBytes(start));
}
if (stop != null) {
scan.setStopRow(Bytes.toBytes(stop));
scan.withStopRow(Bytes.toBytes(stop));
}
scans.add(scan);

View File

@ -170,7 +170,7 @@ public class TestTableInputFormat {
new org.apache.hadoop.hbase.mapreduce.TableRecordReaderImpl();
Scan s = new Scan();
s.withStartRow(Bytes.toBytes("aaa"));
s.setStopRow(Bytes.toBytes("zzz"));
s.withStopRow(Bytes.toBytes("zzz"));
s.addFamily(FAMILY);
trr.setScan(s);
trr.setHTable(table);

View File

@ -156,7 +156,7 @@ public class TableResource extends ResourceBase {
if (!startRow.isEmpty()) {
tableScan.withStartRow(Bytes.toBytes(startRow));
}
tableScan.setStopRow(Bytes.toBytes(endRow));
tableScan.withStopRow(Bytes.toBytes(endRow));
for (String col : column) {
byte [][] parts = CellUtil.parseColumn(Bytes.toBytes(col.trim()));
if (parts.length == 1) {

View File

@ -1320,7 +1320,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
Scan scan = new Scan();
scan.withStartRow(Bytes.toBytes(1));
scan.setStopRow(Bytes.toBytes(3));
scan.withStopRow(Bytes.toBytes(3));
scan.addColumn(FAMILY, FAMILY);
scan.setFilter(new RowFilter(CompareOperator.NOT_EQUAL,
new BinaryComparator(Bytes.toBytes(1))));
@ -2139,7 +2139,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
scan.setSmall(small);
scan.setReversed(true);
scan.withStartRow(Bytes.toBytes("002"));
scan.setStopRow(Bytes.toBytes("000"));
scan.withStopRow(Bytes.toBytes("000"));
try (ResultScanner scanner = table.getScanner(scan)) {
int count = 0;
byte[] lastRow = null;
@ -2203,7 +2203,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
scan.setSmall(small);
scan.setReversed(true);
scan.withStartRow(Bytes.toBytes("006"));
scan.setStopRow(Bytes.toBytes("002"));
scan.withStopRow(Bytes.toBytes("002"));
try (ResultScanner scanner = table.getScanner(scan)) {
int count = 0;
byte[] lastRow = null;

View File

@ -908,7 +908,7 @@ public class TestScannersFromClientSide {
scan.addFamily(Bytes.toBytes("c"));
scan.setAttribute(Scan.SCAN_ATTRIBUTES_TABLE_NAME, tableName.getName());
scan.setMaxResultSize(10001);
scan.setStopRow(Bytes.toBytes("bbbb"));
scan.withStopRow(Bytes.toBytes("bbbb"));
scan.setFilter(new LimitKVsReturnFilter());
ResultScanner rs = table.getScanner(scan);
Result result;

View File

@ -159,7 +159,7 @@ public class TestFilterListOrOperatorWithBlkCnt {
scan.withStartRow(startRow);
}
if(!Bytes.toString(stopRow).isEmpty()) {
scan.setStopRow(stopRow);
scan.withStopRow(stopRow);
}
ResultScanner scanner = ht.getScanner(scan);
List<Cell> kvList = new ArrayList<>();

View File

@ -101,7 +101,7 @@ public class TestCleanupCompactedFileOnRegionClose {
//Create a scanner and keep it open to add references to StoreFileReaders
Scan scan = new Scan();
scan.setStopRow(Bytes.toBytes(refSFCount-2));
scan.withStopRow(Bytes.toBytes(refSFCount-2));
scan.setCaching(1);
ResultScanner scanner = table.getScanner(scan);
Result res = scanner.next();

View File

@ -221,7 +221,7 @@ public class TestSeekOptimizations {
{
final byte[] scannerStopRow =
rowBytes(endRow + (startRow != endRow ? 1 : 0));
scan.setStopRow(scannerStopRow);
scan.withStopRow(scannerStopRow);
}
final long initialSeekCount = StoreFileScanner.getSeekCount();

View File

@ -242,7 +242,7 @@ public class TestCellACLs extends SecureTestUtil {
public List<Cell> run() throws Exception {
Scan scan = new Scan();
scan.withStartRow(TEST_ROW);
scan.setStopRow(Bytes.add(TEST_ROW, new byte[]{ 0 } ));
scan.withStopRow(Bytes.add(TEST_ROW, new byte[]{ 0 }));
scan.addFamily(TEST_FAMILY);
Connection connection = ConnectionFactory.createConnection(conf);
Table t = connection.getTable(testTable.getTableName());

View File

@ -974,7 +974,7 @@ public class TestWithDisabledAuthorization extends SecureTestUtil {
public List<Cell> run() throws Exception {
Scan scan = new Scan();
scan.withStartRow(TEST_ROW);
scan.setStopRow(Bytes.add(TEST_ROW, new byte[]{ 0 } ));
scan.withStopRow(Bytes.add(TEST_ROW, new byte[]{ 0 }));
scan.addFamily(TEST_FAMILY);
Connection connection = ConnectionFactory.createConnection(conf);
Table t = connection.getTable(testTable.getTableName());

View File

@ -886,7 +886,7 @@ public class ThriftHBaseServiceHandler extends HBaseServiceHandler implements Hb
scan.withStartRow(tScan.getStartRow());
}
if (tScan.isSetStopRow()) {
scan.setStopRow(tScan.getStopRow());
scan.withStopRow(tScan.getStopRow());
}
if (tScan.isSetTimestamp()) {
scan.setTimeRange(0, tScan.getTimestamp());

View File

@ -525,7 +525,7 @@ public final class ThriftUtilities {
out.withStartRow(in.getStartRow());
}
if (in.isSetStopRow()) {
out.setStopRow(in.getStopRow());
out.withStopRow(in.getStopRow());
}
if (in.isSetCaching()) {
out.setCaching(in.getCaching());