Repository: phoenix
Updated Branches:
  refs/heads/4.0 f7f470528 -> 6a6a9c0f2


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

Branch: refs/heads/4.0
Commit: 6a6a9c0f20118a57f9e1f43a16e63f9eeaeb3d57
Parents: f7f4705
Author: James Taylor <jtay...@salesforce.com>
Authored: Tue Jul 29 22:11:45 2014 -0700
Committer: James Taylor <jtay...@salesforce.com>
Committed: Tue Jul 29 22:13:24 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/6a6a9c0f/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/6a6a9c0f/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++) {

Reply via email to