phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject [1/2] phoenix git commit: PHOENIX-2900 Unable to find hash cache once a salted table 's first region has split
Date Sun, 24 Jul 2016 16:57:17 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.0 a05e798c3 -> be74b73fd


PHOENIX-2900 Unable to find hash cache once a salted table 's first region has split


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

Branch: refs/heads/4.x-HBase-1.0
Commit: 37fe5d223670b716a475a123d8abdd279252a163
Parents: a05e798
Author: James Taylor <jamestaylor@apache.org>
Authored: Sun Jul 24 09:30:31 2016 -0700
Committer: James Taylor <jamestaylor@apache.org>
Committed: Sun Jul 24 09:55:50 2016 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/compile/ScanRanges.java  |  5 ++-
 .../phoenix/compile/QueryCompilerTest.java      | 42 ++++++++++++++++++++
 .../phoenix/compile/SaltedScanRangesTest.java   |  8 ++++
 3 files changed, 54 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/37fe5d22/phoenix-core/src/main/java/org/apache/phoenix/compile/ScanRanges.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/ScanRanges.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/ScanRanges.java
index f3d5bba..95eee60 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/ScanRanges.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/ScanRanges.java
@@ -419,7 +419,10 @@ public class ScanRanges {
             return true;
         }
         
-        return intersectScan(null, regionStartKey, regionEndKey, 0, false) == HAS_INTERSECTION;
+        boolean crossesSaltBoundary = isSalted && ScanUtil.crossesPrefixBoundary(regionEndKey,
+                ScanUtil.getPrefix(regionStartKey, SaltingUtil.NUM_SALTING_BYTES), 
+                SaltingUtil.NUM_SALTING_BYTES);        
+        return intersectScan(null, regionStartKey, regionEndKey, 0, crossesSaltBoundary)
== HAS_INTERSECTION;
     }
     
     public SkipScanFilter getSkipScanFilter() {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/37fe5d22/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
index 7aab048..c91b855 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
@@ -41,6 +41,7 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 
+import org.apache.hadoop.hbase.HRegionLocation;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.filter.Filter;
 import org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter;
@@ -48,6 +49,7 @@ import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.phoenix.compile.OrderByCompiler.OrderBy;
 import org.apache.phoenix.coprocessor.BaseScannerRegionObserver;
 import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.execute.HashJoinPlan;
 import org.apache.phoenix.expression.Expression;
 import org.apache.phoenix.expression.LiteralExpression;
 import org.apache.phoenix.expression.aggregator.Aggregator;
@@ -2385,4 +2387,44 @@ public class QueryCompilerTest extends BaseConnectionlessQueryTest
{
             conn.close();
         }
     }
+    
+    @Test
+    public void testSaltTableJoin() throws Exception{
+
+        PhoenixConnection conn = (PhoenixConnection)DriverManager.getConnection(getUrl());
+        try {
+            conn.createStatement().execute("drop table if exists SALT_TEST2900");
+
+            conn.createStatement().execute(
+                "create table SALT_TEST2900"+
+                        "("+
+                        "id UNSIGNED_INT not null primary key,"+
+                        "appId VARCHAR"+
+                    ")SALT_BUCKETS=2");
+
+
+
+            conn.createStatement().execute("drop table if exists RIGHT_TEST2900 ");
+            conn.createStatement().execute(
+                "create table RIGHT_TEST2900"+
+                        "("+
+                        "appId VARCHAR not null primary key,"+
+                        "createTime VARCHAR"+
+                    ")");
+
+            
+            String sql="select * from SALT_TEST2900 a inner join RIGHT_TEST2900 b on a.appId=b.appId
where a.id>=3 and a.id<=5";
+            HashJoinPlan plan = (HashJoinPlan)getQueryPlan(sql, Collections.emptyList());
+            ScanRanges ranges=plan.getContext().getScanRanges();
+
+            List<HRegionLocation> regionLocations=
+                    conn.getQueryServices().getAllTableRegions(Bytes.toBytes("SALT_TEST2900"));
+            for (HRegionLocation regionLocation : regionLocations) {
+                assertTrue(ranges.intersectRegion(regionLocation.getRegionInfo().getStartKey(),
+                    regionLocation.getRegionInfo().getEndKey(), false));
+            }
+        } finally {
+            conn.close();
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/37fe5d22/phoenix-core/src/test/java/org/apache/phoenix/compile/SaltedScanRangesTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/SaltedScanRangesTest.java
b/phoenix-core/src/test/java/org/apache/phoenix/compile/SaltedScanRangesTest.java
index f8eb3a0..d89f024 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/compile/SaltedScanRangesTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/SaltedScanRangesTest.java
@@ -151,6 +151,14 @@ public class SaltedScanRangesTest {
                     KeyRange.getKeyRange(ByteUtil.concat(new byte[]{1}, Bytes.toBytes("f")),
ByteUtil.concat(new byte[]{1}, Bytes.toBytes("g"))),
                     true,
                     false));
+        testCases.addAll(
+                foreach(new KeyRange[][]{{
+                        PVarchar.INSTANCE.getKeyRange(Bytes.toBytes("c"), true, KeyRange.UNBOUND,
false),
+                    }},
+                    new int[] {1},
+                    KeyRange.getKeyRange(new byte[]{1,0},new byte[]{2,0}),
+                    false,
+                    true));
         return testCases;
     }
 


Mime
View raw message