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:08:39 GMT
Repository: phoenix
Updated Branches:
  refs/heads/3.0 9ba71569b -> 3d4ecad36


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/3d4ecad3
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/3d4ecad3
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/3d4ecad3

Branch: refs/heads/3.0
Commit: 3d4ecad367c849c1680ffd5f54a2ee4b372f2f3d
Parents: 9ba7156
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:11:45 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/3d4ecad3/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/3d4ecad3/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 d65e09c..3245bc5 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
@@ -211,7 +211,12 @@ public class SkipScanFilter extends FilterBase {
                 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