HBASE-26090 Remove the deprecated methods in Scan which should be removed in 3.0.0 (#3493)

Signed-off-by: Yi Mei <myimeiyi@gmail.com>
Signed-off-by: Anoop Sam John <anoopsamjohn@apache.org>
This commit is contained in:
Duo Zhang 2021-07-16 22:27:22 +08:00 committed by GitHub
parent 3666357ba0
commit 83d1bf1667
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 38 additions and 132 deletions

View File

@ -63,12 +63,6 @@ public final class ImmutableScan extends Scan {
throw new UnsupportedOperationException("ImmutableScan does not allow access to setTimeRange");
}
@Deprecated
@Override
public Scan setTimeStamp(long timestamp) {
throw new UnsupportedOperationException("ImmutableScan does not allow access to setTimeStamp");
}
@Override
public Scan setTimestamp(long timestamp) {
throw new UnsupportedOperationException("ImmutableScan does not allow access to setTimestamp");
@ -183,12 +177,6 @@ public final class ImmutableScan extends Scan {
throw new UnsupportedOperationException("ImmutableScan does not allow access to setRaw");
}
@Override
@Deprecated
public Scan setSmall(boolean small) {
throw new UnsupportedOperationException("ImmutableScan does not allow access to setSmall");
}
@Override
public Scan setAttribute(String name, byte[] value) {
throw new UnsupportedOperationException("ImmutableScan does not allow access to setAttribute");
@ -412,12 +400,6 @@ public final class ImmutableScan extends Scan {
return this.delegateScan.isRaw();
}
@Override
@Deprecated
public boolean isSmall() {
return this.delegateScan.isSmall();
}
@Override
public boolean isScanMetricsEnabled() {
return this.delegateScan.isScanMetricsEnabled();

View File

@ -144,17 +144,6 @@ public class Scan extends Query {
*/
public static final boolean DEFAULT_HBASE_CLIENT_SCANNER_ASYNC_PREFETCH = false;
/**
* Set it true for small scan to get better performance Small scan should use pread and big scan
* can use seek + read seek + read is fast but can cause two problem (1) resource contention (2)
* cause too much network io [89-fb] Using pread for non-compaction read request
* https://issues.apache.org/jira/browse/HBASE-7266 On the other hand, if setting it true, we
* would do openScanner,next,closeScanner in one RPC call. It means the better performance for
* small scan. [HBASE-9488]. Generally, if the scan range is within one data block(64KB), it could
* be considered as a small scan.
*/
private boolean small = false;
/**
* The mvcc read point to use when open a scanner. Remember to clear it after switching regions as
* the mvcc is only valid within region scope.
@ -203,7 +192,6 @@ public class Scan extends Query {
this.setIsolationLevel(scan.getIsolationLevel());
reversed = scan.isReversed();
asyncPrefetch = scan.isAsyncPrefetch();
small = scan.isSmall();
allowPartialResults = scan.getAllowPartialResults();
tr = scan.getTimeRange(); // TimeRange is immutable
Map<byte[], NavigableSet<byte[]>> fams = scan.getFamilyMap();
@ -320,24 +308,6 @@ public class Scan extends Query {
return this;
}
/**
* Get versions of columns with the specified timestamp. Note, default maximum
* versions to return is 1. If your time range spans more than one version
* and you want all versions returned, up the number of versions beyond the
* defaut.
* @param timestamp version timestamp
* @see #readAllVersions()
* @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
*/
@Deprecated
public Scan setTimeStamp(long timestamp)
throws IOException {
return this.setTimestamp(timestamp);
}
/**
* Get versions of columns with the specified timestamp. Note, default maximum
* versions to return is 1. If your time range spans more than one version
@ -874,45 +844,6 @@ public class Scan extends Query {
return attr == null ? false : Bytes.toBoolean(attr);
}
/**
* Set whether this scan is a small scan
* <p>
* Small scan should use pread and big scan can use seek + read seek + read is fast but can cause
* two problem (1) resource contention (2) cause too much network io [89-fb] Using pread for
* non-compaction read request https://issues.apache.org/jira/browse/HBASE-7266 On the other hand,
* if setting it true, we would do openScanner,next,closeScanner in one RPC call. It means the
* better performance for small scan. [HBASE-9488]. Generally, if the scan range is within one
* data block(64KB), it could be considered as a small scan.
* @param small
* @deprecated since 2.0.0 and will be removed in 3.0.0. Use {@link #setLimit(int)} and
* {@link #setReadType(ReadType)} instead. And for the one rpc optimization, now we will also
* fetch data when openScanner, and if the number of rows reaches the limit then we will close
* the scanner automatically which means we will fall back to one rpc.
* @see #setLimit(int)
* @see #setReadType(ReadType)
* @see <a href="https://issues.apache.org/jira/browse/HBASE-17045">HBASE-17045</a>
*/
@Deprecated
public Scan setSmall(boolean small) {
this.small = small;
if (small) {
this.readType = ReadType.PREAD;
}
return this;
}
/**
* Get whether this scan is a small scan
* @return true if small scan
* @deprecated since 2.0.0 and will be removed in 3.0.0. See the comment of
* {@link #setSmall(boolean)}
* @see <a href="https://issues.apache.org/jira/browse/HBASE-17045">HBASE-17045</a>
*/
@Deprecated
public boolean isSmall() {
return small;
}
@Override
public Scan setAttribute(String name, byte[] value) {
return (Scan) super.setAttribute(name, value);

View File

@ -1026,9 +1026,6 @@ public final class ProtobufUtil {
if (scan.getMaxResultSize() > 0) {
scanBuilder.setMaxResultSize(scan.getMaxResultSize());
}
if (scan.isSmall()) {
scanBuilder.setSmall(scan.isSmall());
}
if (scan.getAllowPartialResults()) {
scanBuilder.setAllowPartialResults(scan.getAllowPartialResults());
}
@ -1179,9 +1176,6 @@ public final class ProtobufUtil {
if (proto.hasMaxResultSize()) {
scan.setMaxResultSize(proto.getMaxResultSize());
}
if (proto.hasSmall()) {
scan.setSmall(proto.getSmall());
}
if (proto.hasAllowPartialResults()) {
scan.setAllowPartialResults(proto.getAllowPartialResults());
}
@ -1212,9 +1206,7 @@ public final class ProtobufUtil {
if (proto.hasMvccReadPoint()) {
PackagePrivateFieldAccessor.setMvccReadPoint(scan, proto.getMvccReadPoint());
}
if (scan.isSmall()) {
scan.setReadType(Scan.ReadType.PREAD);
} else if (proto.hasReadType()) {
if (proto.hasReadType()) {
scan.setReadType(toReadType(proto.getReadType()));
}
if (proto.getNeedCursorResult()) {

View File

@ -19,6 +19,9 @@
package org.apache.hadoop.hbase.client;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@ -39,8 +42,6 @@ import org.junit.experimental.categories.Category;
import org.mockito.Mockito;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
/**
* Small tests for ImmutableScan
@ -85,7 +86,6 @@ public class TestImmutableScan {
.setRowOffsetPerColumnFamily(5)
.setRowPrefixFilter(Bytes.toBytes("row_"))
.setScanMetricsEnabled(true)
.setSmall(true)
.setReadType(Scan.ReadType.STREAM)
.withStartRow(Bytes.toBytes("row_1"))
.withStopRow(Bytes.toBytes("row_2"))

View File

@ -18,14 +18,12 @@
package org.apache.hadoop.hbase.client;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.Arrays;
import java.util.Set;
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HConstants;
@ -40,6 +38,7 @@ import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.apache.hadoop.hbase.shaded.protobuf.ProtobufUtil;
import org.apache.hadoop.hbase.shaded.protobuf.generated.ClientProtos;
@ -249,7 +248,6 @@ public class TestScan {
.setRowOffsetPerColumnFamily(5)
.setRowPrefixFilter(Bytes.toBytes("row_"))
.setScanMetricsEnabled(true)
.setSmall(true)
.setReadType(ReadType.STREAM)
.withStartRow(Bytes.toBytes("row_1"))
.withStopRow(Bytes.toBytes("row_2"))
@ -297,11 +295,8 @@ public class TestScan {
@Test
public void testScanReadType() throws Exception {
Scan scan = new Scan();
assertFalse(scan.isSmall());
assertEquals(ReadType.DEFAULT, scan.getReadType());
Scan copyScan = new Scan(scan);
copyScan.setSmall(scan.isSmall());
assertFalse(copyScan.isSmall());
assertEquals(ReadType.DEFAULT, copyScan.getReadType());
}
}

View File

@ -80,6 +80,7 @@ import org.apache.hadoop.hbase.client.RegionLocator;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.client.ResultScanner;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.Scan.ReadType;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.client.TableDescriptor;
import org.apache.hadoop.hbase.client.TableDescriptorBuilder;
@ -4234,7 +4235,7 @@ public class HBaseTestingUtility extends HBaseZKTestingUtility {
public Result getClosestRowBefore(Region r, byte[] row, byte[] family) throws IOException {
Scan scan = new Scan().withStartRow(row);
scan.setSmall(true);
scan.setReadType(ReadType.PREAD);
scan.setCaching(1);
scan.setReversed(true);
scan.addFamily(family);

View File

@ -54,6 +54,7 @@ import org.apache.hadoop.hbase.ServerName;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNameTestRule;
import org.apache.hadoop.hbase.Waiter;
import org.apache.hadoop.hbase.client.Scan.ReadType;
import org.apache.hadoop.hbase.client.metrics.ScanMetrics;
import org.apache.hadoop.hbase.coprocessor.MultiRowMutationEndpoint;
import org.apache.hadoop.hbase.filter.BinaryComparator;
@ -237,7 +238,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
private Result getReverseScanResult(Table table, byte[] row) throws IOException {
Scan scan = new Scan().withStartRow(row);
scan.setSmall(true);
scan.setReadType(ReadType.PREAD);
scan.setReversed(true);
scan.setCaching(1);
scan.addFamily(HConstants.CATALOG_FAMILY);
@ -1336,7 +1337,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
scan2 = new Scan();
scan2.setScanMetricsEnabled(true);
scan2.setCaching(1);
scan2.setSmall(true);
scan2.setReadType(ReadType.PREAD);
try (ResultScanner scanner = ht.getScanner(scan2)) {
int numBytes = 0;
for (Result result : scanner) {
@ -1908,7 +1909,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
// small scan
Scan scan = new Scan().withStartRow(HConstants.EMPTY_START_ROW)
.withStopRow(HConstants.EMPTY_END_ROW, true);
scan.setSmall(true);
scan.setReadType(ReadType.PREAD);
scan.setCaching(2);
try (ResultScanner scanner = table.getScanner(scan)) {
int count = 0;
@ -2433,12 +2434,13 @@ public class TestFromClientSide5 extends FromClientSideBase {
assertEquals(12, count);
}
reverseScanTest(table, false);
reverseScanTest(table, true);
reverseScanTest(table, ReadType.STREAM);
reverseScanTest(table, ReadType.PREAD);
reverseScanTest(table, ReadType.DEFAULT);
}
}
private void reverseScanTest(Table table, boolean small) throws IOException {
private void reverseScanTest(Table table, ReadType readType) throws IOException {
// scan backward
Scan scan = new Scan();
scan.setReversed(true);
@ -2460,7 +2462,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
}
scan = new Scan();
scan.setSmall(small);
scan.setReadType(readType);
scan.setReversed(true);
scan.withStartRow(Bytes.toBytes("002"));
try (ResultScanner scanner = table.getScanner(scan)) {
@ -2481,7 +2483,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
}
scan = new Scan();
scan.setSmall(small);
scan.setReadType(readType);
scan.setReversed(true);
scan.withStartRow(Bytes.toBytes("002"));
scan.withStopRow(Bytes.toBytes("000"));
@ -2503,7 +2505,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
}
scan = new Scan();
scan.setSmall(small);
scan.setReadType(readType);
scan.setReversed(true);
scan.withStartRow(Bytes.toBytes("001"));
try (ResultScanner scanner = table.getScanner(scan)) {
@ -2524,7 +2526,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
}
scan = new Scan();
scan.setSmall(small);
scan.setReadType(readType);
scan.setReversed(true);
scan.withStartRow(Bytes.toBytes("000"));
try (ResultScanner scanner = table.getScanner(scan)) {
@ -2545,7 +2547,7 @@ public class TestFromClientSide5 extends FromClientSideBase {
}
scan = new Scan();
scan.setSmall(small);
scan.setReadType(readType);
scan.setReversed(true);
scan.withStartRow(Bytes.toBytes("006"));
scan.withStopRow(Bytes.toBytes("002"));

View File

@ -21,6 +21,7 @@ import java.io.IOException;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Scan.ReadType;
import org.apache.hadoop.hbase.testclassification.MediumTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.After;
@ -34,16 +35,16 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Category(MediumTests.class)
public class TestSmallReversedScanner {
public class TestPreadReversedScanner {
@ClassRule
public static final HBaseClassTestRule CLASS_RULE =
HBaseClassTestRule.forClass(TestSmallReversedScanner.class);
HBaseClassTestRule.forClass(TestPreadReversedScanner.class);
public static final Logger LOG = LoggerFactory.getLogger(TestSmallReversedScanner.class);
public static final Logger LOG = LoggerFactory.getLogger(TestPreadReversedScanner.class);
private final static HBaseTestingUtility TEST_UTIL = new HBaseTestingUtility();
private static final TableName TABLE_NAME = TableName.valueOf("testReversedSmall");
private static final TableName TABLE_NAME = TableName.valueOf("testPreadSmall");
private static final byte[] COLUMN_FAMILY = Bytes.toBytes("columnFamily");
private static Table htable = null;
@ -74,10 +75,9 @@ public class TestSmallReversedScanner {
/**
* all rowKeys are fit in the last region.
* @throws IOException
*/
@Test
public void testSmallReversedScan01() throws IOException {
public void testPreadReversedScan01() throws IOException {
String[][] keysCases = new String[][] {
{ "d0", "d1", "d2", "d3" }, // all rowKeys fit in the last region.
{ "a0", "a1", "a2", "a3" }, // all rowKeys fit in the first region.
@ -85,12 +85,12 @@ public class TestSmallReversedScanner {
};
for (int caseIndex = 0; caseIndex < keysCases.length; caseIndex++) {
testSmallReversedScanInternal(keysCases[caseIndex]);
testPreadReversedScanInternal(keysCases[caseIndex]);
TEST_UTIL.truncateTable(TABLE_NAME);
}
}
private void testSmallReversedScanInternal(String[] inputRowKeys) throws IOException {
private void testPreadReversedScanInternal(String[] inputRowKeys) throws IOException {
int rowCount = inputRowKeys.length;
for (int i = 0; i < rowCount; i++) {
@ -101,7 +101,7 @@ public class TestSmallReversedScanner {
Scan scan = new Scan();
scan.setReversed(true);
scan.setSmall(true);
scan.setReadType(ReadType.PREAD);
ResultScanner scanner = htable.getScanner(scan);
Result r;
@ -116,9 +116,10 @@ public class TestSmallReversedScanner {
/**
* Corner case:
* HBase has 4 regions, (-oo,b),[b,c),[c,d),[d,+oo), and only rowKey with byte[]={0x00} locate in region (-oo,b) .
* test whether reversed small scanner will return infinity results with RowKey={0x00}.
* @throws IOException
* <p/>
* HBase has 4 regions, (-oo,b),[b,c),[c,d),[d,+oo), and only rowKey with byte[]={0x00} locate in
* region (-oo,b) . test whether reversed pread scanner will return infinity results with
* RowKey={0x00}.
*/
@Test
public void testSmallReversedScan02() throws IOException {
@ -129,7 +130,7 @@ public class TestSmallReversedScanner {
Scan scan = new Scan();
scan.setCaching(1);
scan.setReversed(true);
scan.setSmall(true);
scan.setReadType(ReadType.PREAD);
ResultScanner scanner = htable.getScanner(scan);
Result r;

View File

@ -49,6 +49,7 @@ import org.apache.hadoop.hbase.StartMiniClusterOption;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.TableNameTestRule;
import org.apache.hadoop.hbase.TableNotFoundException;
import org.apache.hadoop.hbase.client.Scan.ReadType;
import org.apache.hadoop.hbase.exceptions.DeserializationException;
import org.apache.hadoop.hbase.filter.BinaryComparator;
import org.apache.hadoop.hbase.filter.ColumnPrefixFilter;
@ -338,7 +339,7 @@ public class TestScannersFromClientSide {
Table table, boolean reversed, int rows, int columns) throws Exception {
Scan baseScan = new Scan();
baseScan.setReversed(reversed);
baseScan.setSmall(true);
baseScan.setReadType(ReadType.PREAD);
Scan scan = new Scan(baseScan);
verifyExpectedCounts(table, scan, rows, columns);

View File

@ -26,6 +26,7 @@ import java.util.Map.Entry;
import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseTestingUtility;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Scan.ReadType;
import org.apache.hadoop.hbase.testclassification.LargeTests;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.AfterClass;
@ -137,7 +138,7 @@ public class TestSizeFailures {
Connection conn = TEST_UTIL.getConnection();
try (Table table = conn.getTable(TABLENAME)) {
Scan s = new Scan();
s.setSmall(true);
s.setReadType(ReadType.PREAD);
s.addFamily(FAMILY);
s.setMaxResultSize(-1);
s.setBatch(-1);