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/cassandra-3.8
Commit: 2764e85a557c140f44ffc08c09e4b06a61e1ef4e
Parents: 90afc58 84426d1
Author: Benjamin Lerer <b.le...@gmail.com>
Authored: Thu Jul 14 21:44:34 2016 +0200
Committer: Benjamin Lerer <b.le...@gmail.com>
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));
+     }
  }

Reply via email to