cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [3/6] git commit: Trace index selection patch by Lyuben Todorov and jbellis for CASSANDRA-6001
Date Tue, 08 Oct 2013 16:17:19 GMT
Trace index selection
patch by Lyuben Todorov and jbellis for CASSANDRA-6001


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

Branch: refs/heads/trunk
Commit: 241c70a37a89334657c9983736b35db0611fb874
Parents: fe56518
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Tue Oct 8 09:52:42 2013 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Tue Oct 8 10:00:25 2013 -0500

----------------------------------------------------------------------
 CHANGES.txt                                         |  1 +
 .../db/index/composites/CompositesSearcher.java     | 16 ++++++++++++++--
 .../cassandra/db/index/keys/KeysSearcher.java       | 16 ++++++++++++++--
 3 files changed, 29 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/241c70a3/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 35bd832..adbae91 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -15,6 +15,7 @@
  * Fix skipping columns with multiple slices (CASSANDRA-6119)
  * Expose connected thrift + native client counts (CASSANDRA-5084)
  * Optimize auth setup (CASSANDRA-6122)
+ * Trace index selection (CASSANDRA-6001)
 
 
 1.2.10

http://git-wip-us.apache.org/repos/asf/cassandra/blob/241c70a3/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 1e9d59d..82e227f 100644
--- a/src/java/org/apache/cassandra/db/index/composites/CompositesSearcher.java
+++ b/src/java/org/apache/cassandra/db/index/composites/CompositesSearcher.java
@@ -36,7 +36,9 @@ import org.apache.cassandra.dht.AbstractBounds;
 import org.apache.cassandra.dht.Range;
 import org.apache.cassandra.thrift.IndexExpression;
 import org.apache.cassandra.thrift.IndexOperator;
+import org.apache.cassandra.tracing.Tracing;
 import org.apache.cassandra.utils.ByteBufferUtil;
+import org.apache.cassandra.utils.FBUtilities;
 
 public class CompositesSearcher extends SecondaryIndexSearcher
 {
@@ -54,22 +56,32 @@ public class CompositesSearcher extends SecondaryIndexSearcher
     {
         IndexExpression best = null;
         int bestMeanCount = Integer.MAX_VALUE;
+        Map<SecondaryIndex, Integer> candidates = new HashMap<>();
+
         for (IndexExpression expression : clause)
         {
-            //skip columns belonging to a different index type
-            if(!columns.contains(expression.column_name))
+            // skip columns belonging to a different index type
+            if (!columns.contains(expression.column_name))
                 continue;
 
             SecondaryIndex index = indexManager.getIndexForColumn(expression.column_name);
             if (index == null || (expression.op != IndexOperator.EQ))
                 continue;
             int columns = index.getIndexCfs().getMeanColumns();
+            candidates.put(index, columns);
             if (columns < bestMeanCount)
             {
                 best = expression;
                 bestMeanCount = columns;
             }
         }
+
+        if (best == null)
+            Tracing.trace("No applicable indexes found");
+        else
+            Tracing.trace("Candidate index mean cardinalities are {}. Scanning with {}.",
+                          FBUtilities.toString(candidates), indexManager.getIndexForColumn(best.column_name).getIndexName());
+
         return best;
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/241c70a3/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 4be7988..7d23e6c 100644
--- a/src/java/org/apache/cassandra/db/index/keys/KeysSearcher.java
+++ b/src/java/org/apache/cassandra/db/index/keys/KeysSearcher.java
@@ -32,7 +32,9 @@ import org.apache.cassandra.dht.AbstractBounds;
 import org.apache.cassandra.dht.Range;
 import org.apache.cassandra.thrift.IndexExpression;
 import org.apache.cassandra.thrift.IndexOperator;
+import org.apache.cassandra.tracing.Tracing;
 import org.apache.cassandra.utils.ByteBufferUtil;
+import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.HeapAllocator;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -50,22 +52,32 @@ public class KeysSearcher extends SecondaryIndexSearcher
     {
         IndexExpression best = null;
         int bestMeanCount = Integer.MAX_VALUE;
+        Map<SecondaryIndex, Integer> candidates = new HashMap<>();
+
         for (IndexExpression expression : clause)
         {
-            //skip columns belonging to a different index type
-            if(!columns.contains(expression.column_name))
+            // skip columns belonging to a different index type
+            if (!columns.contains(expression.column_name))
                 continue;
 
             SecondaryIndex index = indexManager.getIndexForColumn(expression.column_name);
             if (index == null || (expression.op != IndexOperator.EQ))
                 continue;
             int columns = index.getIndexCfs().getMeanColumns();
+            candidates.put(index, columns);
             if (columns < bestMeanCount)
             {
                 best = expression;
                 bestMeanCount = columns;
             }
         }
+
+        if (best == null)
+            Tracing.trace("No applicable indexes found");
+        else
+            Tracing.trace("Candidate index mean cardinalities are {}. Scanning with {}.",
+                          FBUtilities.toString(candidates), indexManager.getIndexForColumn(best.column_name).getIndexName());
+
         return best;
     }
 


Mime
View raw message