cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ble...@apache.org
Subject [5/6] cassandra git commit: Merge branch cassandra-3.0 into cassandra-3.11
Date Mon, 26 Jun 2017 11:32:48 GMT
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/eaa3da1d
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/eaa3da1d
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/eaa3da1d

Branch: refs/heads/cassandra-3.11
Commit: eaa3da1d1290d3f909103442d88d2e390a86cf86
Parents: 56c8f0c 57c590f
Author: Benjamin Lerer <b.lerer@gmail.com>
Authored: Mon Jun 26 13:24:33 2017 +0200
Committer: Benjamin Lerer <b.lerer@gmail.com>
Committed: Mon Jun 26 13:24:33 2017 +0200

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/cql3/selection/Selection.java     |  2 +-
 .../validation/entities/SecondaryIndexTest.java | 43 ++++++++++++++++++++
 3 files changed, 45 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/eaa3da1d/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 6f2d509,d90d220..4297a15
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,5 -1,5 +1,6 @@@
 -3.0.15
 +3.11.1
 +Merged from 3.0:
+  * Fix secondary index queries on COMPACT tables (CASSANDRA-13627)
   * Nodetool listsnapshots output is missing a newline, if there are no snapshots (CASSANDRA-13568)
  
  

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eaa3da1d/src/java/org/apache/cassandra/cql3/selection/Selection.java
----------------------------------------------------------------------

http://git-wip-us.apache.org/repos/asf/cassandra/blob/eaa3da1d/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
index 3aed07a,0f6cba7..bda0166
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
@@@ -1577,53 -1274,46 +1577,96 @@@ public class SecondaryIndexTest extend
          assertEmpty(execute("SELECT * FROM %s WHERE a = 5"));
      }
  
+     @Test
+     public void testIndicesOnCompactTable() throws Throwable
+     {
+         assertInvalidMessage("COMPACT STORAGE with composite PRIMARY KEY allows no more
than one column not part of the PRIMARY KEY (got: v1, v2)",
+                              "CREATE TABLE test (pk int, c int, v1 int, v2 int, PRIMARY
KEY(pk, c)) WITH COMPACT STORAGE");
+ 
+         createTable("CREATE TABLE %s (pk int, c int, v int, PRIMARY KEY(pk, c)) WITH COMPACT
STORAGE");
+         assertInvalidMessage("Secondary indexes are not supported on COMPACT STORAGE tables
that have clustering columns",
+                              "CREATE INDEX ON %s(v)");
+ 
+         createTable("CREATE TABLE %s (pk int PRIMARY KEY, v int) WITH COMPACT STORAGE");
+         createIndex("CREATE INDEX ON %s(v)");
+ 
+         execute("INSERT INTO %s (pk, v) VALUES (?, ?)", 1, 1);
+         execute("INSERT INTO %s (pk, v) VALUES (?, ?)", 2, 1);
+         execute("INSERT INTO %s (pk, v) VALUES (?, ?)", 3, 3);
+ 
+         assertRows(execute("SELECT pk, v FROM %s WHERE v = 1"),
+                    row(1, 1),
+                    row(2, 1));
+ 
+         assertRows(execute("SELECT pk, v FROM %s WHERE v = 3"),
+                    row(3, 3));
+ 
+         assertEmpty(execute("SELECT pk, v FROM %s WHERE v = 5"));
+ 
+         createTable("CREATE TABLE %s (pk int PRIMARY KEY, v1 int, v2 int) WITH COMPACT STORAGE");
+         createIndex("CREATE INDEX ON %s(v1)");
+ 
+         execute("INSERT INTO %s (pk, v1, v2) VALUES (?, ?, ?)", 1, 1, 1);
+         execute("INSERT INTO %s (pk, v1, v2) VALUES (?, ?, ?)", 2, 1, 2);
+         execute("INSERT INTO %s (pk, v1, v2) VALUES (?, ?, ?)", 3, 3, 3);
+ 
+         assertRows(execute("SELECT pk, v2 FROM %s WHERE v1 = 1"),
+                    row(1, 1),
+                    row(2, 2));
+ 
+         assertRows(execute("SELECT pk, v2 FROM %s WHERE v1 = 3"),
+                    row(3, 3));
+ 
+         assertEmpty(execute("SELECT pk, v2 FROM %s WHERE v1 = 5"));
+     }
++    
 +    private ResultMessage.Prepared prepareStatement(String cql, boolean forThrift)
 +    {
 +        return QueryProcessor.prepare(String.format(cql, KEYSPACE, currentTable()),
 +                                      ClientState.forInternalCalls(),
 +                                      forThrift);
 +    }
 +
 +    private void validateCell(Cell cell, ColumnDefinition def, ByteBuffer val, long timestamp)
 +    {
 +        assertNotNull(cell);
 +        assertEquals(0, def.type.compare(cell.value(), val));
 +        assertEquals(timestamp, cell.timestamp());
 +    }
 +
 +    private static void assertColumnValue(int expected, String name, Row row, CFMetaData
cfm)
 +    {
 +        ColumnDefinition col = cfm.getColumnDefinition(new ColumnIdentifier(name, true));
 +        AbstractType<?> type = col.type;
 +        assertEquals(expected, type.compose(row.getCell(col).value()));
 +    }
 +
 +    /**
 +     * <code>CassandraIndex</code> that blocks during the initialization.
 +     */
 +    public static class IndexBlockingOnInitialization extends CustomCassandraIndex
 +    {
 +        private final CountDownLatch latch = new CountDownLatch(1);
 +
 +        public IndexBlockingOnInitialization(ColumnFamilyStore baseCfs, IndexMetadata indexDef)
 +        {
 +            super(baseCfs, indexDef);
 +        }
 +
 +        @Override
 +        public Callable<?> getInitializationTask()
 +        {
 +            return () -> {
 +                latch.await();
 +                return null;
 +            };
 +        }
 +
 +        @Override
 +        public Callable<?> getInvalidateTask()
 +        {
 +            latch.countDown();
 +            return super.getInvalidateTask();
 +        }
 +    }
  }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org


Mime
View raw message