cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [5/9] git commit: Avoid using row cache on 2i CFs patch by Sam Tunnicliffe and jbellis for CASSANDRA-5732
Date Sun, 13 Oct 2013 16:14:06 GMT
Avoid using row cache on 2i CFs
patch by Sam Tunnicliffe and jbellis for CASSANDRA-5732


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

Branch: refs/heads/cassandra-2.0
Commit: 7290abd198d6c63f1109094cf237d9c84f617f7d
Parents: dc2dd52
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu Oct 10 14:45:46 2013 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Sun Oct 13 11:09:25 2013 -0500

----------------------------------------------------------------------
 CHANGES.txt                                      |  1 +
 .../org/apache/cassandra/config/CFMetaData.java  | 10 ++++++++--
 .../apache/cassandra/db/ColumnFamilyStore.java   |  8 ++------
 .../AbstractSimplePerColumnSecondaryIndex.java   | 19 -------------------
 4 files changed, 11 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/7290abd1/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index afb1464..7f43031 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -22,6 +22,7 @@
  * Handle JMX notification failure for repair (CASSANDRA-6097)
  * (Hadoop) Fetch no more than 128 splits in parallel (CASSANDRA-6169)
  * stress: add username/password authentication support (CASSANDRA-6068)
+ * Fix indexed queries with row cache enabled on parent table (CASSANDRA-5732)
 
 
 1.2.10

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7290abd1/src/java/org/apache/cassandra/config/CFMetaData.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/config/CFMetaData.java b/src/java/org/apache/cassandra/config/CFMetaData.java
index 4355737..fcbd012 100644
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@ -309,7 +309,13 @@ public final class CFMetaData
 
     CFMetaData(String keyspace, String name, ColumnFamilyType type, AbstractType<?>
comp, AbstractType<?> subcc, UUID id)
     {
-        // Final fields must be set in constructor
+        assert keyspace != null;
+        assert name != null;
+        assert type != null;
+        assert id != null;
+        // (subcc may be null for non-supercolumns)
+        // (comp may also be null for custom indexes, which is kind of broken if you ask
me)
+
         ksName = keyspace;
         cfName = name;
         cfType = type;
@@ -387,7 +393,7 @@ public final class CFMetaData
     public static CFMetaData newIndexMetadata(CFMetaData parent, ColumnDefinition info, AbstractType<?>
columnComparator)
     {
         // Depends on parent's cache setting, turn on its index CF's cache.
-        // Here, only key cache is enabled, but later (in KeysIndex) row cache will be turned
on depending on cardinality.
+        // Row caching is never enabled; see CASSANDRA-5732
         Caching indexCaching = parent.getCaching() == Caching.ALL || parent.getCaching()
== Caching.KEYS_ONLY
                              ? Caching.KEYS_ONLY
                              : Caching.NONE;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7290abd1/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
index a7e8605..39359b7 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1190,12 +1190,8 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         {
             if (isRowCacheEnabled())
             {
-                UUID cfId = Schema.instance.getId(table.name, columnFamily);
-                if (cfId == null)
-                {
-                    logger.trace("no id found for {}.{}", table.name, columnFamily);
-                    return null;
-                }
+                assert !isIndex(); // CASSANDRA-5732
+                UUID cfId = metadata.cfId;
 
                 ColumnFamily cached = getThroughCache(cfId, filter);
                 if (cached == null)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/7290abd1/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
b/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
index 2ff2d27..caa7e20 100644
--- a/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
+++ b/src/java/org/apache/cassandra/db/index/AbstractSimplePerColumnSecondaryIndex.java
@@ -49,25 +49,6 @@ public abstract class AbstractSimplePerColumnSecondaryIndex extends PerColumnSec
                                                              indexedCfMetadata.cfName,
                                                              new LocalPartitioner(columnDef.getValidator()),
                                                              indexedCfMetadata);
-
-        // enable and initialize row cache based on parent's setting and indexed column's
cardinality
-        CFMetaData.Caching baseCaching = baseCfs.metadata.getCaching();
-        if (baseCaching == CFMetaData.Caching.ALL || baseCaching == CFMetaData.Caching.ROWS_ONLY)
-        {
-            /*
-             * # of index CF's key = cardinality of indexed column.
-             * if # of keys stored in index CF is more than average column counts (means
tall table),
-             * then consider it as high cardinality.
-             */
-            double estimatedKeys = indexCfs.estimateKeys();
-            double averageColumnCount = indexCfs.getMeanColumns();
-            if (averageColumnCount > 0 && estimatedKeys / averageColumnCount >
1)
-            {
-                logger.debug("turning row cache on for " + indexCfs.getColumnFamilyName());
-                indexCfs.metadata.caching(baseCaching);
-                indexCfs.initRowCache();
-            }
-        }
     }
 
     protected abstract void init(ColumnDefinition columnDef);


Mime
View raw message