Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2830D200B50 for ; Thu, 14 Jul 2016 21:46:52 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 26CB4160A63; Thu, 14 Jul 2016 19:46:52 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 46EEF160A60 for ; Thu, 14 Jul 2016 21:46:51 +0200 (CEST) Received: (qmail 68729 invoked by uid 500); 14 Jul 2016 19:46:50 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 68708 invoked by uid 99); 14 Jul 2016 19:46:50 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Jul 2016 19:46:50 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 478C3E964E; Thu, 14 Jul 2016 19:46:50 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: blerer@apache.org To: commits@cassandra.apache.org Date: Thu, 14 Jul 2016 19:46:51 -0000 Message-Id: <007f11c451e341b68f29663e33b22a8d@git.apache.org> In-Reply-To: <3f5243629253439180f0cd95a168d89e@git.apache.org> References: <3f5243629253439180f0cd95a168d89e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/3] cassandra git commit: Merge branch cassandra-3.0 into cassandra-3.9 archived-at: Thu, 14 Jul 2016 19:46:52 -0000 Merge branch cassandra-3.0 into cassandra-3.9 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/2764e85a Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/2764e85a Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/2764e85a Branch: refs/heads/trunk Commit: 2764e85a557c140f44ffc08c09e4b06a61e1ef4e Parents: 90afc58 84426d1 Author: Benjamin Lerer Authored: Thu Jul 14 21:44:34 2016 +0200 Committer: Benjamin Lerer Committed: Thu Jul 14 21:44:34 2016 +0200 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../apache/cassandra/db/filter/DataLimits.java | 3 +- .../validation/operations/SelectLimitTest.java | 32 +++++++++++++++++++- 3 files changed, 33 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/2764e85a/CHANGES.txt ---------------------------------------------------------------------- diff --cc CHANGES.txt index ba8e299,59f0a5f..4c46695 --- a/CHANGES.txt +++ b/CHANGES.txt @@@ -1,9 -1,5 +1,10 @@@ -3.0.9 +3.9 + * Partial revert of CASSANDRA-11971, cannot recycle buffer in SP.sendMessagesToNonlocalDC (CASSANDRA-11950) + * Fix hdr logging for single operation workloads (CASSANDRA-12145) + * Fix SASI PREFIX search in CONTAINS mode with partial terms (CASSANDRA-12073) + * Increase size of flushExecutor thread pool (CASSANDRA-12071) +Merged from 3.0: + * Fix paging logic for deleted partitions with static columns (CASSANDRA-12107) * Wait until the message is being send to decide which serializer must be used (CASSANDRA-11393) * Fix migration of static thrift column names with non-text comparators (CASSANDRA-12147) * Fix upgrading sparse tables that are incorrectly marked as dense (CASSANDRA-11315) http://git-wip-us.apache.org/repos/asf/cassandra/blob/2764e85a/src/java/org/apache/cassandra/db/filter/DataLimits.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/2764e85a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectLimitTest.java ---------------------------------------------------------------------- diff --cc test/unit/org/apache/cassandra/cql3/validation/operations/SelectLimitTest.java index 528d9f6,aeb3d56..21c48dd --- a/test/unit/org/apache/cassandra/cql3/validation/operations/SelectLimitTest.java +++ b/test/unit/org/apache/cassandra/cql3/validation/operations/SelectLimitTest.java @@@ -26,7 -26,7 +26,6 @@@ import org.junit.Test import org.apache.cassandra.config.DatabaseDescriptor; import org.apache.cassandra.cql3.CQLTester; import org.apache.cassandra.dht.ByteOrderedPartitioner; --import org.apache.cassandra.exceptions.InvalidRequestException; public class SelectLimitTest extends CQLTester { @@@ -135,114 -135,33 +134,145 @@@ } @Test + public void testPerPartitionLimit() throws Throwable + { + perPartitionLimitTest(false); + } + + @Test + public void testPerPartitionLimitWithCompactStorage() throws Throwable + { + perPartitionLimitTest(true); + } + + private void perPartitionLimitTest(boolean withCompactStorage) throws Throwable + { + String query = "CREATE TABLE %s (a int, b int, c int, PRIMARY KEY (a, b))"; + + if (withCompactStorage) + createTable(query + " WITH COMPACT STORAGE"); + else + createTable(query); + + for (int i = 0; i < 5; i++) + { + for (int j = 0; j < 5; j++) + { + execute("INSERT INTO %s (a, b, c) VALUES (?, ?, ?)", i, j, j); + } + } + + assertInvalidMessage("LIMIT must be strictly positive", + "SELECT * FROM %s PER PARTITION LIMIT ?", 0); + assertInvalidMessage("LIMIT must be strictly positive", + "SELECT * FROM %s PER PARTITION LIMIT ?", -1); + + assertRowsIgnoringOrder(execute("SELECT * FROM %s PER PARTITION LIMIT ?", 2), + row(0, 0, 0), + row(0, 1, 1), + row(1, 0, 0), + row(1, 1, 1), + row(2, 0, 0), + row(2, 1, 1), + row(3, 0, 0), + row(3, 1, 1), + row(4, 0, 0), + row(4, 1, 1)); + + // Combined Per Partition and "global" limit + assertRowCount(execute("SELECT * FROM %s PER PARTITION LIMIT ? LIMIT ?", 2, 6), + 6); + + // odd amount of results + assertRowCount(execute("SELECT * FROM %s PER PARTITION LIMIT ? LIMIT ?", 2, 5), + 5); + + // IN query + assertRows(execute("SELECT * FROM %s WHERE a IN (2,3) PER PARTITION LIMIT ?", 2), + row(2, 0, 0), + row(2, 1, 1), + row(3, 0, 0), + row(3, 1, 1)); + + assertRows(execute("SELECT * FROM %s WHERE a IN (2,3) PER PARTITION LIMIT ? LIMIT 3", 2), + row(2, 0, 0), + row(2, 1, 1), + row(3, 0, 0)); + + assertRows(execute("SELECT * FROM %s WHERE a IN (1,2,3) PER PARTITION LIMIT ? LIMIT 3", 2), + row(1, 0, 0), + row(1, 1, 1), + row(2, 0, 0)); + + // with restricted partition key + assertRows(execute("SELECT * FROM %s WHERE a = ? PER PARTITION LIMIT ?", 2, 3), + row(2, 0, 0), + row(2, 1, 1), + row(2, 2, 2)); + + // with ordering + assertRows(execute("SELECT * FROM %s WHERE a IN (3, 2) ORDER BY b DESC PER PARTITION LIMIT ?", 2), + row(2, 4, 4), + row(3, 4, 4), + row(2, 3, 3), + row(3, 3, 3)); + + assertRows(execute("SELECT * FROM %s WHERE a IN (3, 2) ORDER BY b DESC PER PARTITION LIMIT ? LIMIT ?", 3, 4), + row(2, 4, 4), + row(3, 4, 4), + row(2, 3, 3), + row(3, 3, 3)); + + assertRows(execute("SELECT * FROM %s WHERE a = ? ORDER BY b DESC PER PARTITION LIMIT ?", 2, 3), + row(2, 4, 4), + row(2, 3, 3), + row(2, 2, 2)); + + // with filtering + assertRows(execute("SELECT * FROM %s WHERE a = ? AND b > ? PER PARTITION LIMIT ? ALLOW FILTERING", 2, 0, 2), + row(2, 1, 1), + row(2, 2, 2)); + + assertRows(execute("SELECT * FROM %s WHERE a = ? AND b > ? ORDER BY b DESC PER PARTITION LIMIT ? ALLOW FILTERING", 2, 2, 2), + row(2, 4, 4), + row(2, 3, 3)); + + assertInvalidMessage("PER PARTITION LIMIT is not allowed with SELECT DISTINCT queries", + "SELECT DISTINCT a FROM %s PER PARTITION LIMIT ?", 3); + assertInvalidMessage("PER PARTITION LIMIT is not allowed with SELECT DISTINCT queries", + "SELECT DISTINCT a FROM %s PER PARTITION LIMIT ? LIMIT ?", 3, 4); + assertInvalidMessage("PER PARTITION LIMIT is not allowed with aggregate queries.", + "SELECT COUNT(*) FROM %s PER PARTITION LIMIT ?", 3); + } ++ ++ @Test + public void testLimitWithDeletedRowsAndStaticColumns() throws Throwable + { + createTable("CREATE TABLE %s (pk int, c int, v int, s int static, PRIMARY KEY (pk, c))"); + + execute("INSERT INTO %s (pk, c, v, s) VALUES (1, -1, 1, 1)"); + execute("INSERT INTO %s (pk, c, v, s) VALUES (2, -1, 1, 1)"); + execute("INSERT INTO %s (pk, c, v, s) VALUES (3, -1, 1, 1)"); + execute("INSERT INTO %s (pk, c, v, s) VALUES (4, -1, 1, 1)"); + execute("INSERT INTO %s (pk, c, v, s) VALUES (5, -1, 1, 1)"); + + assertRows(execute("SELECT * FROM %s"), + row(1, -1, 1, 1), + row(2, -1, 1, 1), + row(3, -1, 1, 1), + row(4, -1, 1, 1), + row(5, -1, 1, 1)); + + execute("DELETE FROM %s WHERE pk = 2"); + + assertRows(execute("SELECT * FROM %s"), + row(1, -1, 1, 1), + row(3, -1, 1, 1), + row(4, -1, 1, 1), + row(5, -1, 1, 1)); + + assertRows(execute("SELECT * FROM %s LIMIT 2"), + row(1, -1, 1, 1), + row(3, -1, 1, 1)); + } }