Skip to content

Commit

Permalink
HBASE-23846 Removed deprecated setMaxVersions(int) from Scan
Browse files Browse the repository at this point in the history
Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Viraj Jasani <vjasani@apache.org>
  • Loading branch information
HorizonNet committed Mar 31, 2020
1 parent 3d4124c commit fded2b9
Show file tree
Hide file tree
Showing 35 changed files with 96 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1189,7 +1189,7 @@ public List<String> listBackupSets() throws IOException {
List<String> list = new ArrayList<>();
try (Table table = connection.getTable(tableName)) {
Scan scan = createScanForBackupSetList();
scan.setMaxVersions(1);
scan.readVersions(1);
try (ResultScanner scanner = table.getScanner(scan)) {
Result res;
while ((res = scanner.next()) != null) {
Expand Down Expand Up @@ -1504,7 +1504,7 @@ private Scan createScanForBackupHistory() {
scan.withStartRow(startRow);
scan.setStopRow(stopRow);
scan.addFamily(BackupSystemTable.SESSIONS_FAMILY);
scan.setMaxVersions(1);
scan.readVersions(1);
return scan;
}

Expand Down Expand Up @@ -1585,7 +1585,7 @@ private Scan createScanForReadRegionServerLastLogRollResult(String backupRoot) {
scan.withStartRow(startRow);
scan.setStopRow(stopRow);
scan.addFamily(BackupSystemTable.META_FAMILY);
scan.setMaxVersions(1);
scan.readVersions(1);

return scan;
}
Expand Down Expand Up @@ -1859,7 +1859,7 @@ static Scan createScanForOrigBulkLoadedFiles(TableName table) {
scan.withStartRow(startRow);
scan.withStopRow(stopRow);
scan.addFamily(BackupSystemTable.META_FAMILY);
scan.setMaxVersions(1);
scan.readVersions(1);
return scan;
}

Expand Down Expand Up @@ -1894,7 +1894,7 @@ static Scan createScanForBulkLoadedFiles(String backupId) {
scan.withStartRow(startRow);
scan.setStopRow(stopRow);
scan.addFamily(BackupSystemTable.META_FAMILY);
scan.setMaxVersions(1);
scan.readVersions(1);
return scan;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
* To only retrieve columns with a specific timestamp, call {@link #setTimestamp(long) setTimestamp}
* .
* <p>
* To limit the number of versions of each column to be returned, call {@link #setMaxVersions(int)}.
* To limit the number of versions of each column to be returned, call {@link #readVersions(int)}.
* <p>
* To limit the maximum number of values returned for each call to next(), call
* {@link #setBatch(int) setBatch}.
Expand Down Expand Up @@ -341,7 +341,7 @@ public Scan addColumn(byte [] family, byte [] qualifier) {
* @param minStamp minimum timestamp value, inclusive
* @param maxStamp maximum timestamp value, exclusive
* @see #readAllVersions()
* @see #setMaxVersions(int)
* @see #readVersions(int)
* @return this
*/
public Scan setTimeRange(long minStamp, long maxStamp) throws IOException {
Expand All @@ -356,7 +356,7 @@ public Scan setTimeRange(long minStamp, long maxStamp) throws IOException {
* defaut.
* @param timestamp version timestamp
* @see #readAllVersions()
* @see #setMaxVersions(int)
* @see #readVersions(int)
* @return this
* @deprecated As of release 2.0.0, this will be removed in HBase 3.0.0.
* Use {@link #setTimestamp(long)} instead
Expand All @@ -374,7 +374,7 @@ public Scan setTimeStamp(long timestamp)
* defaut.
* @param timestamp version timestamp
* @see #readAllVersions()
* @see #setMaxVersions(int)
* @see #readVersions(int)
* @return this
*/
public Scan setTimestamp(long timestamp) {
Expand Down Expand Up @@ -516,20 +516,6 @@ public Scan setRowPrefixFilter(byte[] rowPrefix) {
return this;
}

/**
* Get up to the specified number of versions of each column.
* @param maxVersions maximum versions for each column
* @return this
* @deprecated since 2.0.0 and will be removed in 3.0.0. It is easy to misunderstand with column
* family's max versions, so use {@link #readVersions(int)} instead.
* @see #readVersions(int)
* @see <a href="https://issues.apache.org/jira/browse/HBASE-17125">HBASE-17125</a>
*/
@Deprecated
public Scan setMaxVersions(int maxVersions) {
return readVersions(maxVersions);
}

/**
* Get all available versions.
* @return this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ public static Scan toScan(
scan.setCacheBlocks(proto.getCacheBlocks());
}
if (proto.hasMaxVersions()) {
scan.setMaxVersions(proto.getMaxVersions());
scan.readVersions(proto.getMaxVersions());
}
if (proto.hasStoreLimit()) {
scan.setMaxResultsPerColumnFamily(proto.getStoreLimit());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,7 @@ private void runCheck() throws IOException, ClassNotFoundException, InterruptedE
Scan scan = new Scan();
scan.addFamily(CHAIN_FAM);
scan.addFamily(SORT_FAM);
scan.setMaxVersions(1);
scan.readVersions(1);
scan.setCacheBlocks(false);
scan.setBatch(1000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ protected boolean doAction() throws Exception {
s.setBatch(2);
s.addFamily(FAMILY);
s.setFilter(new KeyOnlyFilter());
s.setMaxVersions(1);
s.readVersions(1);

rs = table.getScanner(s);
Result result = rs.next();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private static Scan getConfiguredScanForJob(Configuration conf, String[] args)
// Set Scan Versions
if (conf.get(TableInputFormat.SCAN_MAXVERSIONS) == null) {
// default to all versions unless explicitly set
s.setMaxVersions(Integer.MAX_VALUE);
s.readVersions(Integer.MAX_VALUE);
}
s.setCacheBlocks(false);
// Set RowFilter or Prefix Filter if applicable.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ static Scan getScanFromCommandLine(Configuration conf, String[] args) throws IOE
// Optional arguments.
// Set Scan Versions
int versions = args.length > 2? Integer.parseInt(args[2]): 1;
s.setMaxVersions(versions);
s.readVersions(versions);
// Set Scan Range
long startTime = args.length > 3? Long.parseLong(args[3]): 0L;
long endTime = args.length > 4? Long.parseLong(args[4]): Long.MAX_VALUE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Scan initScan() throws IOException {
scan.setBatch(scanBatch);
}
if (versions >= 0) {
scan.setMaxVersions(versions);
scan.readVersions(versions);
}
if (!isTableStartRow(startRow)) {
scan.withStartRow(startRow);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public static Scan createScanFromConfiguration(Configuration conf) throws IOExce
}

if (conf.get(SCAN_MAXVERSIONS) != null) {
scan.setMaxVersions(Integer.parseInt(conf.get(SCAN_MAXVERSIONS)));
scan.readVersions(Integer.parseInt(conf.get(SCAN_MAXVERSIONS)));
}

if (conf.get(SCAN_CACHEDROWS) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public void map(ImmutableBytesWritable row, final Result value,
int versions = conf.getInt(NAME+".versions", -1);
LOG.info("Setting number of version inside map as: " + versions);
if (versions >= 0) {
scan.setMaxVersions(versions);
scan.readVersions(versions);
}
TableName tableName = TableName.valueOf(conf.get(NAME + ".tableName"));
sourceConnection = ConnectionFactory.createConnection(conf);
Expand Down Expand Up @@ -459,7 +459,7 @@ public Job createSubmittableJob(Configuration conf, String[] args)
scan.setBatch(batch);
}
if (versions >= 0) {
scan.setMaxVersions(versions);
scan.readVersions(versions);
LOG.info("Number of versions set to " + versions);
}
if(families != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public int run(String[] args) throws IOException, InterruptedException {
// a full table scan and don't want to impact other clients badly.
scan.setCaching(conf.getInt(HConstants.HBASE_CLIENT_SCANNER_CACHING, 10000));
scan.setCacheBlocks(false);
scan.setMaxVersions(maxVersions);
scan.readVersions(maxVersions);
conf.set(REPORT_JOB_ID, id);

job = Job.getInstance(conf);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ protected void testHdfsStreaming(Path filename) throws IOException {
private Scan getScan() {
Scan scan = new Scan(); // default scan settings
scan.setCacheBlocks(false);
scan.setMaxVersions(1);
scan.readVersions(1);
scan.setScanMetricsEnabled(true);
if (caching != null) {
scan.setCaching(Integer.parseInt(caching));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ private void runTestOnTable()
private void verify(final Table table) throws IOException {
Scan scan = new Scan();
scan.addColumn(FAMILY_NAME, COLUMN_NAME);
scan.setMaxVersions(1);
scan.readVersions(1);
ResultScanner scanner = table.getScanner(scan);
for (Result r: scanner) {
for (Cell kv : r.listCells()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public ScannerResultGenerator(final String tableName, final RowSpec rowspec,
}
}
scan.setTimeRange(rowspec.getStartTime(), rowspec.getEndTime());
scan.setMaxVersions(rowspec.getMaxVersions());
scan.readVersions(rowspec.getMaxVersions());
if (filter != null) {
scan.setFilter(filter);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public TableScanResource getScanResource(
}
Table hTable = RESTServlet.getInstance().getTable(this.table);
tableScan.setBatch(batchSize);
tableScan.setMaxVersions(maxVersions);
tableScan.readVersions(maxVersions);
tableScan.setTimeRange(startTime, endTime);
if (!startRow.isEmpty()) {
tableScan.withStartRow(Bytes.toBytes(startRow));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ private HRegionInfo createRandomRegion(final String name) {
Scan scan = new Scan(startRow, stopRow);
scan.addColumn(fam, qf1);
scan.setTimeRange(ts, ts+1);
scan.setMaxVersions(maxVersions);
scan.readVersions(maxVersions);

ClientProtos.Scan scanProto = ProtobufUtil.toScan(scan);
Scan desScan = ProtobufUtil.toScan(scanProto);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ protected void scanVersionRangeAndVerifyGreaterThan(Table ht, byte [] row,
int start, int end) throws IOException {
Scan scan = new Scan(row);
scan.addColumn(family, qualifier);
scan.setMaxVersions(Integer.MAX_VALUE);
scan.readVersions(Integer.MAX_VALUE);
scan.setTimeRange(stamps[start+1], Long.MAX_VALUE);
Result result = getSingleScanResult(ht, scan);
assertNResult(result, row, family, qualifier, stamps, values, start+1, end);
Expand All @@ -596,7 +596,7 @@ protected void scanVersionRangeAndVerify(Table ht, byte [] row, byte [] family,
byte [] qualifier, long [] stamps, byte [][] values, int start, int end) throws IOException {
Scan scan = new Scan(row);
scan.addColumn(family, qualifier);
scan.setMaxVersions(Integer.MAX_VALUE);
scan.readVersions(Integer.MAX_VALUE);
scan.setTimeRange(stamps[start], stamps[end]+1);
Result result = getSingleScanResult(ht, scan);
assertNResult(result, row, family, qualifier, stamps, values, start, end);
Expand All @@ -606,7 +606,7 @@ protected void scanAllVersionsAndVerify(Table ht, byte [] row, byte [] family,
byte [] qualifier, long [] stamps, byte [][] values, int start, int end) throws IOException {
Scan scan = new Scan(row);
scan.addColumn(family, qualifier);
scan.setMaxVersions(Integer.MAX_VALUE);
scan.readVersions(Integer.MAX_VALUE);
Result result = getSingleScanResult(ht, scan);
assertNResult(result, row, family, qualifier, stamps, values, start, end);
}
Expand Down Expand Up @@ -636,7 +636,7 @@ protected void scanVersionAndVerify(Table ht, byte [] row, byte [] family,
Scan scan = new Scan(row);
scan.addColumn(family, qualifier);
scan.setTimestamp(stamp);
scan.setMaxVersions(Integer.MAX_VALUE);
scan.readVersions(Integer.MAX_VALUE);
Result result = getSingleScanResult(ht, scan);
assertSingleResult(result, row, family, qualifier, stamp, value);
}
Expand All @@ -646,7 +646,7 @@ protected void scanVersionAndVerifyMissing(Table ht, byte [] row,
Scan scan = new Scan(row);
scan.addColumn(family, qualifier);
scan.setTimestamp(stamp);
scan.setMaxVersions(Integer.MAX_VALUE);
scan.readVersions(Integer.MAX_VALUE);
Result result = getSingleScanResult(ht, scan);
assertNullResult(result);
}
Expand Down
Loading

0 comments on commit fded2b9

Please sign in to comment.