You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by ty...@apache.org on 2015/01/20 18:40:16 UTC

cassandra git commit: Fix missing results in 2i queries on collections with filtering

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 5a8497647 -> 2445d4d09


Fix missing results in 2i queries on collections with filtering

Patch by Benjamin Lerer; reviewed by Tyler Hobbs for CASSANDRA-8421


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

Branch: refs/heads/cassandra-2.1
Commit: 2445d4d09f24c266075617fc5a572415e07045fc
Parents: 5a84976
Author: blerer <b_...@hotmail.com>
Authored: Tue Jan 20 11:39:30 2015 -0600
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Tue Jan 20 11:39:30 2015 -0600

----------------------------------------------------------------------
 CHANGES.txt                                       |  2 ++
 .../db/index/composites/CompositesSearcher.java   |  1 +
 .../cassandra/cql3/ContainsRelationTest.java      | 18 ++++++++++++++++++
 3 files changed, 21 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/2445d4d0/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 695ae6f..1b14c62 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,6 @@
 2.1.3
+ * Fix missing results in secondary index queries on collections
+   with ALLOW FILTERING (CASSANDRA-8421)
  * Expose EstimatedHistogram metrics for range slices (CASSANDRA-8627)
  * (cqlsh) Escape clqshrc passwords properly (CASSANDRA-8618)
  * Fix NPE when passing wrong argument in ALTER TABLE statement (CASSANDRA-8355)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2445d4d0/src/java/org/apache/cassandra/db/index/composites/CompositesSearcher.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/composites/CompositesSearcher.java b/src/java/org/apache/cassandra/db/index/composites/CompositesSearcher.java
index 8cc8aa8..3e523f4 100644
--- a/src/java/org/apache/cassandra/db/index/composites/CompositesSearcher.java
+++ b/src/java/org/apache/cassandra/db/index/composites/CompositesSearcher.java
@@ -219,6 +219,7 @@ public class CompositesSearcher extends SecondaryIndexSearcher
                         {
                             DecoratedKey previousKey = currentKey;
                             currentKey = dk;
+                            previousPrefix = null;
 
                             // We're done with the previous row, return it if it had data, continue otherwise
                             indexCells.addFirst(cell);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/2445d4d0/test/unit/org/apache/cassandra/cql3/ContainsRelationTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/cql3/ContainsRelationTest.java b/test/unit/org/apache/cassandra/cql3/ContainsRelationTest.java
index 335636b..b51a639 100644
--- a/test/unit/org/apache/cassandra/cql3/ContainsRelationTest.java
+++ b/test/unit/org/apache/cassandra/cql3/ContainsRelationTest.java
@@ -76,6 +76,24 @@ public class ContainsRelationTest extends CQLTester
     }
 
     @Test
+    public void testListContainsWithFiltering() throws Throwable
+    {
+        createTable("CREATE TABLE %s (e int PRIMARY KEY, f list<text>, s int)");
+        createIndex("CREATE INDEX ON %s(f)");
+        for(int i = 0; i < 3; i++)
+        {
+            execute("INSERT INTO %s (e, f, s) VALUES (?, ?, ?)", i, list("Dubai"), 4);
+        }
+        for(int i = 3; i < 5; i++)
+        {
+            execute("INSERT INTO %s (e, f, s) VALUES (?, ?, ?)", i, list("Dubai"), 3);
+        }
+        assertRows(execute("SELECT * FROM %s WHERE f CONTAINS ? AND s=? allow filtering", "Dubai", 3),
+                   row(3, list("Dubai"), 3),
+                   row(4, list("Dubai"), 3));
+    }
+
+    @Test
     public void testMapKeyContains() throws Throwable
     {
         createTable("CREATE TABLE %s (account text, id int, categories map<text,text>, PRIMARY KEY (account, id))");