cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xe...@apache.org
Subject [2/2] git commit: fix KEYS index from skipping results patch by Pavel Yaskevich; reviewed by Jonathan Ellis for CASSANDRA-3996
Date Tue, 27 Mar 2012 22:22:20 GMT
fix KEYS index from skipping results
patch by Pavel Yaskevich; reviewed by Jonathan Ellis for CASSANDRA-3996


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

Branch: refs/heads/cassandra-1.1
Commit: baf130094938ac03a91844cd5c3a70f54d5bcff3
Parents: 5bd78ed
Author: Pavel Yaskevich <xedin@apache.org>
Authored: Wed Mar 28 00:49:17 2012 +0300
Committer: Pavel Yaskevich <xedin@apache.org>
Committed: Wed Mar 28 01:16:57 2012 +0300

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../cassandra/db/index/keys/KeysSearcher.java      |    2 -
 .../apache/cassandra/db/ColumnFamilyStoreTest.java |   31 +++++++++++++++
 3 files changed, 32 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/baf13009/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index a1cd359..ae2b0f1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,7 @@
 1.1-dev
  * Adds caching and bloomFilterFpChange to CQL options (CASSANDRA-4042)
  * Adds posibility to autoconfigure size of the KeyCache (CASSANDRA-4087)
+ * fix KEYS index from skipping results (CASSANDRA-3996)
 
 
 1.1-beta2

http://git-wip-us.apache.org/repos/asf/cassandra/blob/baf13009/src/java/org/apache/cassandra/db/index/keys/KeysSearcher.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/keys/KeysSearcher.java b/src/java/org/apache/cassandra/db/index/keys/KeysSearcher.java
index bd4be7e..686f810 100644
--- a/src/java/org/apache/cassandra/db/index/keys/KeysSearcher.java
+++ b/src/java/org/apache/cassandra/db/index/keys/KeysSearcher.java
@@ -159,14 +159,12 @@ public class KeysSearcher extends SecondaryIndexSearcher
                         {
                             // skip the row we already saw w/ the last page of results
                             indexColumns.next();
-                            columnsRead--;
                             logger.debug("Skipping {}", baseCfs.metadata.getKeyValidator().getString(firstColumn.name()));
                         }
                         else if (range instanceof Range && indexColumns.hasNext()
&& firstColumn.name().equals(startKey))
                         {
                             // skip key excluded by range
                             indexColumns.next();
-                            columnsRead--;
                             logger.debug("Skipping first key as range excludes it");
                         }
                     }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/baf13009/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
index a0ee315..18dea98 100644
--- a/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
+++ b/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
@@ -34,6 +34,7 @@ import org.apache.cassandra.db.columniterator.IdentityQueryFilter;
 import org.apache.cassandra.db.filter.*;
 import org.apache.cassandra.db.index.SecondaryIndex;
 import org.apache.cassandra.db.marshal.LexicalUUIDType;
+import org.apache.cassandra.db.marshal.LongType;
 import org.apache.cassandra.dht.*;
 import org.apache.cassandra.io.sstable.Component;
 import org.apache.cassandra.io.sstable.Descriptor;
@@ -899,6 +900,36 @@ public class ColumnFamilyStoreTest extends SchemaLoader
         assert rows.get(rows.size() - 1).key.equals(idk(6));
     }
 
+    @Test
+    public void testKeysSearcher() throws Exception
+    {
+        // Create secondary index and flush to disk
+        Table table = Table.open("Keyspace1");
+        ColumnFamilyStore store = table.getColumnFamilyStore("Indexed1");
+
+        store.truncate();
+
+        for (int i = 0; i < 10; i++)
+        {
+            ByteBuffer key = ByteBufferUtil.bytes(String.valueOf("k" + i));
+            RowMutation rm = new RowMutation("Keyspace1", key);
+
+            rm.add(new QueryPath("Indexed1", null, ByteBufferUtil.bytes("birthdate")),
+                   LongType.instance.decompose(1L),
+                   System.currentTimeMillis());
+
+            rm.apply();
+        }
+
+        store.forceBlockingFlush();
+
+        IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("birthdate"), IndexOperator.EQ,
LongType.instance.decompose(1L));
+        // explicitly tell to the KeysSearcher to use column limiting for rowsPerQuery to
trigger bogus columnsRead--; (CASSANDRA-3996)
+        List<Row> rows = store.search(Arrays.asList(expr), Util.range("", ""), 10,
new IdentityQueryFilter(), true);
+
+        assert rows.size() == 10;
+    }
+
     private static String keys(List<Row> rows) throws Throwable
     {
         String k = "";


Mime
View raw message