phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject git commit: PHOENIX-1130 SkipScanFilter gets IndexOutOfBoundsException when intersecting salted tables (Kyle Buzsaki)
Date Wed, 30 Jul 2014 05:18:41 GMT
Repository: phoenix
Updated Branches:
  refs/heads/master e7868db3d -> 382f901a6


PHOENIX-1130 SkipScanFilter gets IndexOutOfBoundsException when intersecting salted tables
(Kyle Buzsaki)


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

Branch: refs/heads/master
Commit: 382f901a6b30f582ed26c5d31c0011fc529cfc75
Parents: e7868db
Author: James Taylor <jtaylor@salesforce.com>
Authored: Tue Jul 29 22:11:45 2014 -0700
Committer: James Taylor <jtaylor@salesforce.com>
Committed: Tue Jul 29 22:18:13 2014 -0700

----------------------------------------------------------------------
 .../apache/phoenix/end2end/SkipScanQueryIT.java | 24 +++++++++++++++++++-
 .../apache/phoenix/filter/SkipScanFilter.java   |  7 +++++-
 2 files changed, 29 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/382f901a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanQueryIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanQueryIT.java
index 540197c..db5d15b 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanQueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/SkipScanQueryIT.java
@@ -274,4 +274,26 @@ public class SkipScanQueryIT extends BaseHBaseManagedTimeIT {
         }
     }
     
-}
+    @Test
+    public void testSkipScanIntersectionAtEnd() throws Exception {
+        Connection conn = DriverManager.getConnection(getUrl());
+        
+        PreparedStatement stmt = conn.prepareStatement("create table splits_test "
+            + "(pk1 UNSIGNED_TINYINT NOT NULL, pk2 UNSIGNED_TINYINT NOT NULL, pk3 UNSIGNED_TINYINT
NOT NULL, kv VARCHAR "
+            + "CONSTRAINT pk PRIMARY KEY (pk1, pk2, pk3)) SPLIT ON (?, ?, ?)");
+        stmt.setBytes(1, new byte[] {1, 1});
+        stmt.setBytes(2, new byte[] {2, 1});
+        stmt.setBytes(3, new byte[] {3, 1});
+        stmt.execute();
+        
+        conn.createStatement().execute("upsert into splits_test values (0, 1, 1, 'a')");
+        conn.createStatement().execute("upsert into splits_test values (1, 1, 1, 'a')");
+        conn.createStatement().execute("upsert into splits_test values (2, 1, 1, 'a')");
+        conn.createStatement().execute("upsert into splits_test values (3, 1, 1, 'a')");
+        conn.commit();
+        
+        ResultSet rs = conn.createStatement().executeQuery("select count(kv) from splits_test
where pk1 in (0, 1, 2, 3) AND pk2 = 1");
+        assertTrue(rs.next());
+        assertEquals(4, rs.getInt(1));
+        assertFalse(rs.next());
+    }}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/382f901a/phoenix-core/src/main/java/org/apache/phoenix/filter/SkipScanFilter.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/filter/SkipScanFilter.java b/phoenix-core/src/main/java/org/apache/phoenix/filter/SkipScanFilter.java
index 5d23376..13113c8 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/filter/SkipScanFilter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/filter/SkipScanFilter.java
@@ -220,7 +220,12 @@ public class SkipScanFilter extends FilterBase implements Writable {
                 return false;
             }
         } else if (filterAllRemaining()) {
-            return true;
+            // We wrapped around the position array. We know there's an intersection, but
it can only at the last
+            // slot position. So reset the position array here to the last position index
for each slot. This will
+            // be used below as the end bounds to formulate the list of intersecting slots.
+            for (int i = 0; i <= lastSlot; i++) {
+                position[i] = slots.get(i).size() - 1;
+            }
         }
         // Copy inclusive all positions 
         for (int i = 0; i <= lastSlot; i++) {


Mime
View raw message