Merge branch 'cassandra-3.11' into trunk

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

Branch: refs/heads/trunk
Commit: 69aa1737d17089278c725cffeca3f69fb25f0aa0
Parents: bf1cd8e f33cdcb
Author: adelapena <[email protected]>
Authored: Wed May 10 11:47:20 2017 +0100
Committer: adelapena <[email protected]>
Committed: Wed May 10 11:47:20 2017 +0100

----------------------------------------------------------------------
 .../validation/entities/SecondaryIndexTest.java | 42 ++++++++++++++++++++
 1 file changed, 42 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/69aa1737/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
----------------------------------------------------------------------
diff --cc 
test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
index c5fb45d,3aed07a..29ceb3b
--- 
a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
+++ 
b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
@@@ -1524,13 -1535,56 +1524,55 @@@ public class SecondaryIndexTest extend
          assertInvalidMessage("full() indexes can only be created on frozen 
collections", "CREATE INDEX ON %s (full(v))");
      }
  
+     @Test
+     public void testIndexOnPartitionKeyInsertExpiringColumn() throws Throwable
+     {
+         createTable("CREATE TABLE %s (k1 int, k2 int, a int, b int, PRIMARY 
KEY ((k1, k2)))");
+         createIndex("CREATE INDEX on %s(k1)");
+         execute("INSERT INTO %s (k1, k2, a, b) VALUES (1, 2, 3, 4)");
+         assertRows(execute("SELECT * FROM %s WHERE k1 = 1"), row(1, 2, 3, 4));
+         execute("UPDATE %s USING TTL 1 SET b = 10 WHERE k1 = 1 AND k2 = 2");
+         Thread.sleep(1000);
+         assertRows(execute("SELECT * FROM %s WHERE k1 = 1"), row(1, 2, 3, 
null));
+     }
+ 
+     @Test
+     public void testIndexOnClusteringKeyInsertExpiringColumn() throws 
Throwable
+     {
+         createTable("CREATE TABLE %s (pk int, ck int, a int, b int, PRIMARY 
KEY (pk, ck))");
+         createIndex("CREATE INDEX on %s(ck)");
+         execute("INSERT INTO %s (pk, ck, a, b) VALUES (1, 2, 3, 4)");
+         assertRows(execute("SELECT * FROM %s WHERE ck = 2"), row(1, 2, 3, 4));
+         execute("UPDATE %s USING TTL 1 SET b = 10 WHERE pk = 1 AND ck = 2");
+         Thread.sleep(1000);
+         assertRows(execute("SELECT * FROM %s WHERE ck = 2"), row(1, 2, 3, 
null));
+     }
+ 
+     @Test
+     public void testIndexOnRegularColumnInsertExpiringColumn() throws 
Throwable
+     {
+         createTable("CREATE TABLE %s (pk int, ck int, a int, b int, PRIMARY 
KEY (pk, ck))");
+         createIndex("CREATE INDEX on %s(a)");
+         execute("INSERT INTO %s (pk, ck, a, b) VALUES (1, 2, 3, 4)");
+         assertRows(execute("SELECT * FROM %s WHERE a = 3"), row(1, 2, 3, 4));
+ 
+         execute("UPDATE %s USING TTL 1 SET b = 10 WHERE pk = 1 AND ck = 2");
+         Thread.sleep(1000);
+         assertRows(execute("SELECT * FROM %s WHERE a = 3"), row(1, 2, 3, 
null));
+ 
+         execute("UPDATE %s USING TTL 1 SET a = 5 WHERE pk = 1 AND ck = 2");
+         Thread.sleep(1000);
+         assertEmpty(execute("SELECT * FROM %s WHERE a = 3"));
+         assertEmpty(execute("SELECT * FROM %s WHERE a = 5"));
+     }
+ 
 -    private ResultMessage.Prepared prepareStatement(String cql, boolean 
forThrift)
 +    private ResultMessage.Prepared prepareStatement(String cql)
      {
          return QueryProcessor.prepare(String.format(cql, KEYSPACE, 
currentTable()),
 -                                      ClientState.forInternalCalls(),
 -                                      forThrift);
 +                                      ClientState.forInternalCalls());
      }
  
 -    private void validateCell(Cell cell, ColumnDefinition def, ByteBuffer 
val, long timestamp)
 +    private void validateCell(Cell cell, ColumnMetadata def, ByteBuffer val, 
long timestamp)
      {
          assertNotNull(cell);
          assertEquals(0, def.type.compare(cell.value(), val));


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to