cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [1/6] cassandra git commit: Don't try to index clustering values of static rows
Date Tue, 19 Jan 2016 09:08:45 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 851763566 -> c7cbde218
  refs/heads/cassandra-3.3 289ad7713 -> 456581e54
  refs/heads/trunk 0e9819733 -> e13ea8db6


Don't try to index clustering values of static rows

Patch Stefan Podkowinski; reviewed by Sam Tunnicliffe for
CASSANDRA-11021


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

Branch: refs/heads/cassandra-3.0
Commit: c7cbde218de62aa47d9e942957ee4444bd9c7568
Parents: 8517635
Author: Stefan Podkowinski <stefan.podkowinski@1und1.de>
Authored: Mon Jan 18 18:04:00 2016 +0000
Committer: Sam Tunnicliffe <sam@beobal.com>
Committed: Tue Jan 19 08:53:19 2016 +0000

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../index/internal/CassandraIndex.java          |  7 ++++++
 .../validation/entities/SecondaryIndexTest.java | 24 ++++++++++++++++++++
 3 files changed, 32 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c7cbde21/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 165e5d1..9c0ab85 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 3.0.3
+ * Don't attempt to index clustering values of static rows (CASSANDRA-11021)
  * Remove checksum files after replaying hints (CASSANDRA-10947)
  * Support passing base table metadata to custom 2i validation (CASSANDRA-10924)
  * Ensure stale index entries are purged during reads (CASSANDRA-11013)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c7cbde21/src/java/org/apache/cassandra/index/internal/CassandraIndex.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/index/internal/CassandraIndex.java b/src/java/org/apache/cassandra/index/internal/CassandraIndex.java
index 6223d8a..158b127 100644
--- a/src/java/org/apache/cassandra/index/internal/CassandraIndex.java
+++ b/src/java/org/apache/cassandra/index/internal/CassandraIndex.java
@@ -342,6 +342,9 @@ public abstract class CassandraIndex implements Index
 
             public void insertRow(Row row)
             {
+                if (row.isStatic() != indexedColumn.isStatic())
+                    return;
+
                 if (isPrimaryKeyIndex())
                 {
                     indexPrimaryKey(row.clustering(),
@@ -370,6 +373,10 @@ public abstract class CassandraIndex implements Index
 
             public void updateRow(Row oldRow, Row newRow)
             {
+                assert oldRow.isStatic() == newRow.isStatic();
+                if (newRow.isStatic() != indexedColumn.isStatic())
+                    return;
+
                 if (isPrimaryKeyIndex())
                     indexPrimaryKey(newRow.clustering(),
                                     newRow.primaryKeyLivenessInfo(),

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c7cbde21/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
index 38402d9..06f1987 100644
--- a/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
+++ b/test/unit/org/apache/cassandra/cql3/validation/entities/SecondaryIndexTest.java
@@ -960,6 +960,30 @@ public class SecondaryIndexTest extends CQLTester
         assertNull(QueryProcessor.instance.getPreparedForThrift(thriftId));
     }
 
+    // See CASSANDRA-11021
+    @Test
+    public void testIndexesOnNonStaticColumnsWhereSchemaIncludesStaticColumns() throws Throwable
+    {
+        createTable("CREATE TABLE %s (a int, b int, c int static, d int, PRIMARY KEY (a,
b))");
+        createIndex("CREATE INDEX b_idx on %s(b)");
+        createIndex("CREATE INDEX d_idx on %s(d)");
+
+        execute("INSERT INTO %s (a, b, c ,d) VALUES (0, 0, 0, 0)");
+        execute("INSERT INTO %s (a, b, c, d) VALUES (1, 1, 1, 1)");
+        assertRows(execute("SELECT * FROM %s WHERE b = 0"), row(0, 0, 0, 0));
+        assertRows(execute("SELECT * FROM %s WHERE d = 1"), row(1, 1, 1, 1));
+
+        execute("UPDATE %s SET c = 2 WHERE a = 0");
+        execute("UPDATE %s SET c = 3, d = 4 WHERE a = 1 AND b = 1");
+        assertRows(execute("SELECT * FROM %s WHERE b = 0"), row(0, 0, 2, 0));
+        assertRows(execute("SELECT * FROM %s WHERE d = 4"), row(1, 1, 3, 4));
+
+        execute("DELETE FROM %s WHERE a = 0");
+        execute("DELETE FROM %s WHERE a = 1 AND b = 1");
+        assertEmpty(execute("SELECT * FROM %s WHERE b = 0"));
+        assertEmpty(execute("SELECT * FROM %s WHERE d = 3"));
+    }
+
     private ResultMessage.Prepared prepareStatement(String cql, boolean forThrift)
     {
         return QueryProcessor.prepare(String.format(cql, KEYSPACE, currentTable()),


Mime
View raw message