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 2014/08/12 20:59:20 UTC

[1/2] git commit: Fix thrift range filtering w/out 2ary index lookups

Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 70f277f50 -> 17193da39


Fix thrift range filtering w/out 2ary index lookups

Patch by Sam Tunnicliffe; review by Tyler Hobbs for CASSANDRA-7741


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

Branch: refs/heads/cassandra-2.1
Commit: 59a8e1c6b6bcb93ee63b2f309bf379b8a97cdffa
Parents: 5172860
Author: beobal <sa...@beobal.com>
Authored: Tue Aug 12 13:57:52 2014 -0500
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Tue Aug 12 13:58:49 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/service/StorageProxy.java  | 44 ++++++++++++--------
 2 files changed, 28 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/59a8e1c6/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index de45aeb..be91bbc 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.0-rc6
+ * Fix Thrift range filtering without 2ary index lookups (CASSANDRA-7741)
  * Add tracing entries about concurrent range requests (CASSANDRA-7599)
  * (cqlsh) Fix DESCRIBE for NTS keyspaces (CASSANDRA-7729)
  * Remove netty buffer ref-counting (CASSANDRA-7735)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/59a8e1c6/src/java/org/apache/cassandra/service/StorageProxy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java
index d963ee0..d37ac0a 100644
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@ -1413,14 +1413,19 @@ public class StorageProxy implements StorageProxyMBean
         if (command.rowFilter != null && !command.rowFilter.isEmpty())
         {
             List<SecondaryIndexSearcher> searchers = cfs.indexManager.getIndexSearchersForQuery(command.rowFilter);
-            assert !searchers.isEmpty() : "Got row filter with no matching SecondaryIndexSearchers";
-
-            // Secondary index query (cql3 or otherwise).  Estimate result rows based on most selective 2ary index.
-            for (SecondaryIndexSearcher searcher : searchers)
+            if (searchers.isEmpty())
             {
-                // use our own mean column count as our estimate for how many matching rows each node will have
-                SecondaryIndex highestSelectivityIndex = searcher.highestSelectivityIndex(command.rowFilter);
-                resultRowsPerRange = Math.min(resultRowsPerRange, highestSelectivityIndex.estimateResultRows());
+                resultRowsPerRange = calculateResultRowsUsingEstimatedKeys(cfs);
+            }
+            else
+            {
+                // Secondary index query (cql3 or otherwise).  Estimate result rows based on most selective 2ary index.
+                for (SecondaryIndexSearcher searcher : searchers)
+                {
+                    // use our own mean column count as our estimate for how many matching rows each node will have
+                    SecondaryIndex highestSelectivityIndex = searcher.highestSelectivityIndex(command.rowFilter);
+                    resultRowsPerRange = Math.min(resultRowsPerRange, highestSelectivityIndex.estimateResultRows());
+                }
             }
         }
         else if (!command.countCQL3Rows())
@@ -1430,22 +1435,27 @@ public class StorageProxy implements StorageProxyMBean
         }
         else
         {
-            if (cfs.metadata.comparator.isDense())
-            {
-                // one storage row per result row, so use key estimate directly
-                resultRowsPerRange = cfs.estimateKeys();
-            }
-            else
-            {
-                float resultRowsPerStorageRow = ((float) cfs.getMeanColumns()) / cfs.metadata.regularColumns().size();
-                resultRowsPerRange = resultRowsPerStorageRow * (cfs.estimateKeys());
-            }
+            resultRowsPerRange = calculateResultRowsUsingEstimatedKeys(cfs);
         }
 
         // adjust resultRowsPerRange by the number of tokens this node has and the replication factor for this ks
         return (resultRowsPerRange / DatabaseDescriptor.getNumTokens()) / keyspace.getReplicationStrategy().getReplicationFactor();
     }
 
+    private static float calculateResultRowsUsingEstimatedKeys(ColumnFamilyStore cfs)
+    {
+        if (cfs.metadata.comparator.isDense())
+        {
+            // one storage row per result row, so use key estimate directly
+            return cfs.estimateKeys();
+        }
+        else
+        {
+            float resultRowsPerStorageRow = ((float) cfs.getMeanColumns()) / cfs.metadata.regularColumns().size();
+            return resultRowsPerStorageRow * (cfs.estimateKeys());
+        }
+    }
+
     public static List<Row> getRangeSlice(AbstractRangeCommand command, ConsistencyLevel consistency_level)
     throws UnavailableException, ReadTimeoutException
     {


[2/2] git commit: Merge branch 'cassandra-2.1.0' into cassandra-2.1

Posted by ty...@apache.org.
Merge branch 'cassandra-2.1.0' into cassandra-2.1


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

Branch: refs/heads/cassandra-2.1
Commit: 17193da39ac0040b64db7f8ac9e13b6a0c23b4f5
Parents: 70f277f 59a8e1c
Author: Tyler Hobbs <ty...@datastax.com>
Authored: Tue Aug 12 13:59:10 2014 -0500
Committer: Tyler Hobbs <ty...@datastax.com>
Committed: Tue Aug 12 13:59:10 2014 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../apache/cassandra/service/StorageProxy.java  | 44 ++++++++++++--------
 2 files changed, 28 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/17193da3/CHANGES.txt
----------------------------------------------------------------------
diff --cc CHANGES.txt
index 7957eda,be91bbc..c2dc249
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@@ -1,25 -1,5 +1,26 @@@
 +2.1.1
 + * Avoid IOOBE when building SyntaxError message snippet (CASSANDRA-7569)
 + * SSTableExport uses correct validator to create string representation of partition
 +   keys (CASSANDRA-7498)
 + * Avoid NPEs when receiving type changes for an unknown keyspace (CASSANDRA-7689)
 + * Add support for custom 2i validation (CASSANDRA-7575)
 + * Pig support for hadoop CqlInputFormat (CASSANDRA-6454)
 + * Add listen_interface and rpc_interface options (CASSANDRA-7417)
 + * Improve schema merge performance (CASSANDRA-7444)
 + * Adjust MT depth based on # of partition validating (CASSANDRA-5263)
 + * Optimise NativeCell comparisons (CASSANDRA-6755)
 + * Configurable client timeout for cqlsh (CASSANDRA-7516)
 + * Include snippet of CQL query near syntax error in messages (CASSANDRA-7111)
 +Merged from 2.0:
 + * Fix IncompatibleClassChangeError from hadoop2 (CASSANDRA-7229)
 + * Add 'nodetool sethintedhandoffthrottlekb' (CASSANDRA-7635)
 + * (cqlsh) Add tab-completion for CREATE/DROP USER IF [NOT] EXISTS (CASSANDRA-7611)
 + * Catch errors when the JVM pulls the rug out from GCInspector (CASSANDRA-5345)
 + * cqlsh fails when version number parts are not int (CASSANDRA-7524)
 +
 +
  2.1.0-rc6
+  * Fix Thrift range filtering without 2ary index lookups (CASSANDRA-7741)
   * Add tracing entries about concurrent range requests (CASSANDRA-7599)
   * (cqlsh) Fix DESCRIBE for NTS keyspaces (CASSANDRA-7729)
   * Remove netty buffer ref-counting (CASSANDRA-7735)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/17193da3/src/java/org/apache/cassandra/service/StorageProxy.java
----------------------------------------------------------------------