Merge branch cassandra-3.0 into cassandra-3.11

Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/e8053dd8
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/e8053dd8
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/e8053dd8

Branch: refs/heads/trunk
Commit: e8053dd8b003839e23ca8953f42d8a660899d69e
Parents: 6b87e49 828ca7c
Author: Benjamin Lerer <b.le...@gmail.com>
Authored: Tue Apr 4 14:28:51 2017 +0200
Committer: Benjamin Lerer <b.le...@gmail.com>
Committed: Tue Apr 4 14:28:51 2017 +0200

----------------------------------------------------------------------
 .../index/internal/CassandraIndexTest.java      | 29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/e8053dd8/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java
index 59d6860,6c309ac..bfe3c32
--- a/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java
+++ b/test/unit/org/apache/cassandra/index/internal/CassandraIndexTest.java
@@@ -358,32 -358,34 +359,60 @@@ public class CassandraIndexTest extend
      }
  
      @Test
 +    public void indexOnStaticColumn() throws Throwable
 +    {
 +        Object[] row1 = row("k0", "c0", "s0");
 +        Object[] row2 = row("k0", "c1", "s0");
 +        Object[] row3 = row("k1", "c0", "s1");
 +        Object[] row4 = row("k1", "c1", "s1");
 +
 +        createTable("CREATE TABLE %s (k text, c text, s text static, PRIMARY 
KEY (k, c));");
 +        createIndex("CREATE INDEX sc_index on %s(s)");
 +
 +        execute("INSERT INTO %s (k, c, s) VALUES (?, ?, ?)", row1);
 +        execute("INSERT INTO %s (k, c, s) VALUES (?, ?, ?)", row2);
 +        execute("INSERT INTO %s (k, c, s) VALUES (?, ?, ?)", row3);
 +        execute("INSERT INTO %s (k, c, s) VALUES (?, ?, ?)", row4);
 +
 +        assertRows(execute("SELECT * FROM %s WHERE s = ?", "s0"), row1, row2);
 +        assertRows(execute("SELECT * FROM %s WHERE s = ?", "s1"), row3, row4);
 +
 +        assertRows(execute("SELECT * FROM %s WHERE s = ? AND token(k) >= 
token(?)", "s0", "k0"), row1, row2);
 +        assertRows(execute("SELECT * FROM %s WHERE s = ? AND token(k) >= 
token(?)", "s1", "k1"), row3, row4);
 +
 +        assertEmpty(execute("SELECT * FROM %s WHERE s = ? AND token(k) < 
token(?)", "s0", "k0"));
 +        assertEmpty(execute("SELECT * FROM %s WHERE s = ? AND token(k) < 
token(?)", "s1", "k1"));
 +    }
 +
 +    @Test
+     public void indexOnClusteringColumnWithoutRegularColumns() throws 
Throwable
+     {
+         Object[] row1 = row("k0", "c0");
+         Object[] row2 = row("k0", "c1");
+         Object[] row3 = row("k1", "c0");
+         Object[] row4 = row("k1", "c1");
+         String tableName = createTable("CREATE TABLE %s (k text, c text, 
PRIMARY KEY(k, c))");
+         createIndex("CREATE INDEX no_regulars_idx ON %s(c)");
+ 
+         execute("INSERT INTO %s (k, c) VALUES (?, ?)", row1);
+         execute("INSERT INTO %s (k, c) VALUES (?, ?)", row2);
+         execute("INSERT INTO %s (k, c) VALUES (?, ?)", row3);
+         execute("INSERT INTO %s (k, c) VALUES (?, ?)", row4);
+ 
+         assertRowsIgnoringOrder(execute("SELECT * FROM %s WHERE c = ?", 
"c0"), row1, row3);
+         assertRowsIgnoringOrder(execute("SELECT * FROM %s WHERE c = ?", 
"c1"), row2, row4);
+         assertEmpty(execute("SELECT * FROM %s WHERE c = ?", "c3"));
+ 
+         dropIndex("DROP INDEX %s.no_regulars_idx");
+         createIndex("CREATE INDEX no_regulars_idx ON %s(c)");
+         assertTrue(waitForIndex(keyspace(), tableName, "no_regulars_idx"));
+ 
+         assertRowsIgnoringOrder(execute("SELECT * FROM %s WHERE c = ?", 
"c0"), row1, row3);
+         assertRowsIgnoringOrder(execute("SELECT * FROM %s WHERE c = ?", 
"c1"), row2, row4);
+         assertEmpty(execute("SELECT * FROM %s WHERE c = ?", "c3"));
+     }
+ 
+     @Test
      public void createIndexesOnMultipleMapDimensions() throws Throwable
      {
          Object[] row1 = row(0, 0, ImmutableMap.of("a", 10, "b", 20, "c", 30));

Reply via email to