phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From els...@apache.org
Subject [5/5] phoenix git commit: PHOENIX-4576 Correct local index wrongly using child region scanners
Date Mon, 19 Mar 2018 17:29:48 GMT
PHOENIX-4576 Correct local index wrongly using child region scanners

Was causing failures in LocalIndexSplitMergeIT.

Signed-off-by: Josh Elser <elserj@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/9e936094
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/9e936094
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/9e936094

Branch: refs/heads/4.x-HBase-0.98
Commit: 9e936094cd782e6f3a9b6f9c895951eb9a962e0f
Parents: d924343
Author: Rajeshbabu Chintaguntla <rajeshbabu@apache.org>
Authored: Mon Mar 19 12:32:08 2018 -0400
Committer: Josh Elser <elserj@apache.org>
Committed: Mon Mar 19 13:07:05 2018 -0400

----------------------------------------------------------------------
 .../regionserver/IndexHalfStoreFileReaderGenerator.java | 10 ++++++++++
 .../phoenix/coprocessor/BaseScannerRegionObserver.java  |  2 +-
 .../src/main/java/org/apache/phoenix/util/ScanUtil.java | 12 +++++-------
 3 files changed, 16 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/9e936094/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
index ac90f88..034cce5 100644
--- a/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
+++ b/phoenix-core/src/main/java/org/apache/hadoop/hbase/regionserver/IndexHalfStoreFileReaderGenerator.java
@@ -360,6 +360,16 @@ public class IndexHalfStoreFileReaderGenerator extends BaseRegionObserver
{
                 ());
         final List<KeyValueScanner> keyValueScanners = new ArrayList<>(store
                 .getStorefiles().size() + 1);
+        byte[] startKey = c.getEnvironment().getRegionInfo().getStartKey();
+        byte[] endKey = c.getEnvironment().getRegionInfo().getEndKey();
+        // If the region start key is not the prefix of the scan start row then we can return
empty
+        // scanners. This is possible during merge where one of the child region scan should
not return any
+        // results as we go through merged region.
+        if (Bytes.compareTo(scan.getStartRow(), 0, startKey.length == 0 ? endKey.length
+                : startKey.length, startKey.length == 0 ? new byte[endKey.length] : startKey,
0,
+            startKey.length == 0 ? endKey.length : startKey.length) != 0) {
+            return keyValueScanners;
+        }
         for (StoreFile storeFile : storeFiles) {
             if (storeFile.isReference()) {
                 referenceStoreFiles.add(storeFile);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/9e936094/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java
index 61be45a..150f48d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/BaseScannerRegionObserver.java
@@ -179,7 +179,7 @@ abstract public class BaseScannerRegionObserver extends BaseRegionObserver
{
             throw new DoNotRetryIOException(cause.getMessage(), cause);
         }
         if(isLocalIndex) {
-            ScanUtil.setupLocalIndexScan(scan, lowerInclusiveRegionKey, upperExclusiveRegionKey);
+            ScanUtil.setupLocalIndexScan(scan);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/9e936094/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
index a844226..9c710c1 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/ScanUtil.java
@@ -652,15 +652,13 @@ public class ScanUtil {
     }
 
     /**
-     * prefix region start key to the start row/stop row suffix and set as scan boundaries.
+     * Start key and stop key of the original scan from client are regions start and end
keys so
+     * prefix scan start/stop key to the start row/stop row suffix and set them as scan boundaries.
      * @param scan
-     * @param lowerInclusiveRegionKey
-     * @param upperExclusiveRegionKey
      */
-    public static void setupLocalIndexScan(Scan scan, byte[] lowerInclusiveRegionKey,
-            byte[] upperExclusiveRegionKey) {
-        byte[] prefix = lowerInclusiveRegionKey.length == 0 ? new byte[upperExclusiveRegionKey.length]:
lowerInclusiveRegionKey;
-        int prefixLength = lowerInclusiveRegionKey.length == 0? upperExclusiveRegionKey.length:
lowerInclusiveRegionKey.length;
+    public static void setupLocalIndexScan(Scan scan) {
+        byte[] prefix = scan.getStartRow().length == 0 ? new byte[scan.getStopRow().length]:
scan.getStartRow();
+        int prefixLength = scan.getStartRow().length == 0? scan.getStopRow().length: scan.getStartRow().length;
         if(scan.getAttribute(SCAN_START_ROW_SUFFIX)!=null) {
             scan.setStartRow(ScanRanges.prefixKey(scan.getAttribute(SCAN_START_ROW_SUFFIX),
0, prefix, prefixLength));
         }


Mime
View raw message