From 9ff961ac2290ec26de1ea9896ec1ed5002535a07 Mon Sep 17 00:00:00 2001 From: John Leach Date: Fri, 2 Dec 2016 09:06:47 -0600 Subject: [PATCH] HBASE-17242 Isolate Legacy Scanner Logic --- .../java/org/apache/hadoop/hbase/client/Scan.java | 17 ++++++++++++- .../hadoop/hbase/regionserver/StoreScanner.java | 28 +++++++--------------- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java index 9d659b8..eae382e 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java @@ -997,4 +997,19 @@ public class Scan extends Query { Scan resetMvccReadPoint() { return setMvccReadPoint(-1L); } -} + + /** + * + * Determine whether we should use legacy query matcher. If true, we do not + * consider the scan object in our code. ** Only used to + * keep compatibility for coprocessor. + * + */ + public boolean useLegacyQueryMatcher() { + return hasFilter() || + (getStartRow() != null && getStartRow().length > 0) + || (getStopRow() != null && getStopRow().length > 0) + || !getTimeRange().isAllTime(); + } + +} \ No newline at end of file diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java index 7e08eca..7aebc4d 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java @@ -271,19 +271,13 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner long earliestPutTs, byte[] dropDeletesFromRow, byte[] dropDeletesToRow) throws IOException { this(store, scan, scanInfo, null, ((HStore) store).getHRegion().getReadPoint(IsolationLevel.READ_COMMITTED), false); - if (scan.hasFilter() || (scan.getStartRow() != null && scan.getStartRow().length > 0) - || (scan.getStopRow() != null && scan.getStopRow().length > 0) - || !scan.getTimeRange().isAllTime()) { - // use legacy query matcher since we do not consider the scan object in our code. Only used to - // keep compatibility for coprocessor. - matcher = LegacyScanQueryMatcher.create(scan, scanInfo, null, scanType, smallestReadPoint, + matcher = scan.useLegacyQueryMatcher()? // Legacy? + LegacyScanQueryMatcher.create(scan, scanInfo, null, scanType, smallestReadPoint, earliestPutTs, oldestUnexpiredTS, now, dropDeletesFromRow, dropDeletesToRow, - store.getCoprocessorHost()); - } else { - matcher = CompactionScanQueryMatcher.create(scanInfo, scanType, smallestReadPoint, + store.getCoprocessorHost()): + CompactionScanQueryMatcher.create(scanInfo, scanType, smallestReadPoint, earliestPutTs, oldestUnexpiredTS, now, dropDeletesFromRow, dropDeletesToRow, store.getCoprocessorHost()); - } // Filter the list of scanners using Bloom filters, time range, TTL, etc. scanners = selectScannersFrom(scanners); @@ -324,17 +318,11 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner this.matcher = UserScanQueryMatcher.create(scan, scanInfo, columns, oldestUnexpiredTS, now, null); } else { - if (scan.hasFilter() || (scan.getStartRow() != null && scan.getStartRow().length > 0) - || (scan.getStopRow() != null && scan.getStopRow().length > 0) - || !scan.getTimeRange().isAllTime() || columns != null) { - // use legacy query matcher since we do not consider the scan object in our code. Only used - // to keep compatibility for coprocessor. - matcher = LegacyScanQueryMatcher.create(scan, scanInfo, columns, scanType, Long.MAX_VALUE, - earliestPutTs, oldestUnexpiredTS, now, null, null, store.getCoprocessorHost()); - } else { - this.matcher = CompactionScanQueryMatcher.create(scanInfo, scanType, Long.MAX_VALUE, + matcher = (scan.useLegacyQueryMatcher() || columns != null)? // Legacy? + LegacyScanQueryMatcher.create(scan, scanInfo, columns, scanType, Long.MAX_VALUE, + earliestPutTs, oldestUnexpiredTS, now, null, null, store.getCoprocessorHost()): + CompactionScanQueryMatcher.create(scanInfo, scanType, Long.MAX_VALUE, earliestPutTs, oldestUnexpiredTS, now, null, null, null); - } } // Seek all scanners to the initial key -- 2.9.3 (Apple Git-75)