Repository: cassandra Updated Branches: refs/heads/trunk 55a45b58d -> 5c6cdc60a
Fix clustering indexes in presence of static columns in SASI Patch by Alex Petrov; reviewed by Pavel Yaskevich for CASSANDRA-12378 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/5c6cdc60 Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/5c6cdc60 Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/5c6cdc60 Branch: refs/heads/trunk Commit: 5c6cdc60a7c05bc82f5eae848eeb9ab99ff6a53f Parents: 55a45b5 Author: Alex Petrov <oleksandr.pet...@gmail.com> Authored: Fri Aug 5 16:12:34 2016 +0200 Committer: Pavel Yaskevich <xe...@apache.org> Committed: Wed Aug 17 14:45:02 2016 -0700 ---------------------------------------------------------------------- CHANGES.txt | 1 + .../org/apache/cassandra/index/sasi/conf/ColumnIndex.java | 4 ++++ test/unit/org/apache/cassandra/SchemaLoader.java | 1 + .../org/apache/cassandra/index/sasi/SASIIndexTest.java | 10 +++++----- 4 files changed, 11 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/5c6cdc60/CHANGES.txt ---------------------------------------------------------------------- diff --git a/CHANGES.txt b/CHANGES.txt index d5e220c..fa7ec69 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,4 +1,5 @@ 3.10 + * Fix clustering indexes in presence of static columns in SASI (CASSANDRA-12378) * Fix queries on columns with reversed type on SASI indexes (CASSANDRA-12223) * Added slow query log (CASSANDRA-12403) * Count full coordinated request against timeout (CASSANDRA-12256) http://git-wip-us.apache.org/repos/asf/cassandra/blob/5c6cdc60/src/java/org/apache/cassandra/index/sasi/conf/ColumnIndex.java ---------------------------------------------------------------------- diff --git a/src/java/org/apache/cassandra/index/sasi/conf/ColumnIndex.java b/src/java/org/apache/cassandra/index/sasi/conf/ColumnIndex.java index 3f268e3..440d475 100644 --- a/src/java/org/apache/cassandra/index/sasi/conf/ColumnIndex.java +++ b/src/java/org/apache/cassandra/index/sasi/conf/ColumnIndex.java @@ -232,6 +232,10 @@ public class ColumnIndex switch (column.kind) { case CLUSTERING: + // skip indexing of static clustering when regular column is indexed + if (row.isStatic()) + return null; + return row.clustering().get(column.position()); // treat static cell retrieval the same was as regular http://git-wip-us.apache.org/repos/asf/cassandra/blob/5c6cdc60/test/unit/org/apache/cassandra/SchemaLoader.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/SchemaLoader.java b/test/unit/org/apache/cassandra/SchemaLoader.java index 81d25b9..c178ee0 100644 --- a/test/unit/org/apache/cassandra/SchemaLoader.java +++ b/test/unit/org/apache/cassandra/SchemaLoader.java @@ -596,6 +596,7 @@ public class SchemaLoader .addClusteringColumn("age", Int32Type.instance) .addRegularColumn("height", Int32Type.instance) .addRegularColumn("score", DoubleType.instance) + .addStaticColumn("nickname", UTF8Type.instance) .build(); Indexes indexes = cfm.getIndexes(); http://git-wip-us.apache.org/repos/asf/cassandra/blob/5c6cdc60/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java ---------------------------------------------------------------------- diff --git a/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java b/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java index da1d0e3..e2797e2 100644 --- a/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java +++ b/test/unit/org/apache/cassandra/index/sasi/SASIIndexTest.java @@ -1661,9 +1661,9 @@ public class SASIIndexTest { ColumnFamilyStore store = Keyspace.open(KS_NAME).getColumnFamilyStore(CLUSTERING_CF_NAME_1); - executeCQL(CLUSTERING_CF_NAME_1, "INSERT INTO %s.%s (name, location, age, height, score) VALUES (?, ?, ?, ?, ?)", "Pavel", "US", 27, 183, 1.0); - executeCQL(CLUSTERING_CF_NAME_1, "INSERT INTO %s.%s (name, location, age, height, score) VALUES (?, ?, ?, ?, ?)", "Pavel", "BY", 28, 182, 2.0); - executeCQL(CLUSTERING_CF_NAME_1 ,"INSERT INTO %s.%s (name, location, age, height, score) VALUES (?, ?, ?, ?, ?)", "Jordan", "US", 27, 182, 1.0); + executeCQL(CLUSTERING_CF_NAME_1, "INSERT INTO %s.%s (name, nickname, location, age, height, score) VALUES (?, ?, ?, ?, ?, ?)", "Pavel", "xedin", "US", 27, 183, 1.0); + executeCQL(CLUSTERING_CF_NAME_1, "INSERT INTO %s.%s (name, nickname, location, age, height, score) VALUES (?, ?, ?, ?, ?, ?)", "Pavel", "xedin", "BY", 28, 182, 2.0); + executeCQL(CLUSTERING_CF_NAME_1 ,"INSERT INTO %s.%s (name, nickname, location, age, height, score) VALUES (?, ?, ?, ?, ?, ?)", "Jordan", "jrwest", "US", 27, 182, 1.0); if (forceFlush) store.forceBlockingFlush(); @@ -1749,8 +1749,8 @@ public class SASIIndexTest // check restrictions on non-indexed clustering columns when preceding columns are indexed store = Keyspace.open(KS_NAME).getColumnFamilyStore(CLUSTERING_CF_NAME_2); - executeCQL(CLUSTERING_CF_NAME_2 ,"INSERT INTO %s.%s (name, location, age, height, score) VALUES (?, ?, ?, ?, ?)", "Tony", "US", 43, 184, 2.0); - executeCQL(CLUSTERING_CF_NAME_2 ,"INSERT INTO %s.%s (name, location, age, height, score) VALUES (?, ?, ?, ?, ?)", "Christopher", "US", 27, 180, 1.0); + executeCQL(CLUSTERING_CF_NAME_2 ,"INSERT INTO %s.%s (name, nickname, location, age, height, score) VALUES (?, ?, ?, ?, ?, ?)", "Tony", "tony", "US", 43, 184, 2.0); + executeCQL(CLUSTERING_CF_NAME_2 ,"INSERT INTO %s.%s (name, nickname, location, age, height, score) VALUES (?, ?, ?, ?, ?, ?)", "Christopher", "chis", "US", 27, 180, 1.0); if (forceFlush) store.forceBlockingFlush();