Return-Path: X-Original-To: apmail-phoenix-commits-archive@minotaur.apache.org Delivered-To: apmail-phoenix-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8C7AA11C5E for ; Wed, 30 Jul 2014 05:18:41 +0000 (UTC) Received: (qmail 6718 invoked by uid 500); 30 Jul 2014 05:18:41 -0000 Delivered-To: apmail-phoenix-commits-archive@phoenix.apache.org Received: (qmail 6674 invoked by uid 500); 30 Jul 2014 05:18:41 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 6665 invoked by uid 99); 30 Jul 2014 05:18:41 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Jul 2014 05:18:41 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 3BF6E950407; Wed, 30 Jul 2014 05:18:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jamestaylor@apache.org To: commits@phoenix.apache.org Message-Id: <99c55535cab841739e3173861c9faf44@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: PHOENIX-1130 SkipScanFilter gets IndexOutOfBoundsException when intersecting salted tables (Kyle Buzsaki) Date: Wed, 30 Jul 2014 05:18:41 +0000 (UTC) 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 Authored: Tue Jul 29 22:11:45 2014 -0700 Committer: James Taylor 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++) {