cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From xe...@apache.org
Subject git commit: skip reading saved key cache if CF's caching strategy is NONE or ROWS_ONLY patch by Pavel Yaskevich; reviewed by Jonathan Ellis for CASSANDRA-3954
Date Fri, 16 Mar 2012 11:00:31 GMT
Updated Branches:
  refs/heads/cassandra-1.1.0 c29037290 -> 6423bfe79


skip reading saved key cache if CF's caching strategy is NONE or ROWS_ONLY
patch by Pavel Yaskevich; reviewed by Jonathan Ellis for CASSANDRA-3954


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

Branch: refs/heads/cassandra-1.1.0
Commit: 6423bfe791fb7fc9f1b84cd18e614c7725797aaa
Parents: c290372
Author: Pavel Yaskevich <xedin@apache.org>
Authored: Wed Mar 14 22:59:23 2012 +0300
Committer: Pavel Yaskevich <xedin@apache.org>
Committed: Fri Mar 16 13:58:08 2012 +0300

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../org/apache/cassandra/config/CFMetaData.java    |    1 +
 .../org/apache/cassandra/db/ColumnFamilyStore.java |   25 ++++++++++++---
 3 files changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/6423bfe7/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 65b1961..f0de7d1 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -22,6 +22,7 @@
  * Add type information to new schema_ columnfamilies and remove thrift
    serialization for schema (CASSANDRA-3792)
  * add missing column validator options to the CLI help (CASSANDRA-3926)
+ * skip reading saved key cache if CF's caching strategy is NONE or ROWS_ONLY (CASSANDRA-3954)
 Merged from 1.0:
  * always compact away deleted hints immediately after handoff (CASSANDRA-3955)
  * delete hints from dropped ColumnFamilies on handoff instead of

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6423bfe7/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 bebd9f6..157bb9e 100644
--- a/src/java/org/apache/cassandra/config/CFMetaData.java
+++ b/src/java/org/apache/cassandra/config/CFMetaData.java
@@ -324,6 +324,7 @@ public final class CFMetaData
                              .keyValidator(info.getValidator())
                              .readRepairChance(0.0)
                              .dcLocalReadRepairChance(0.0)
+                             .caching(Caching.NONE)
                              .reloadSecondaryIndexMetadata(parent);
     }
 

http://git-wip-us.apache.org/repos/asf/cassandra/blob/6423bfe7/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 a69989e..ef9bc90 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -71,6 +71,8 @@ import org.apache.cassandra.utils.*;
 import org.apache.cassandra.utils.IntervalTree.Interval;
 import org.cliffc.high_scale_lib.NonBlockingHashMap;
 
+import static org.apache.cassandra.config.CFMetaData.Caching;
+
 public class ColumnFamilyStore implements ColumnFamilyStoreMBean
 {
     private static Logger logger = LoggerFactory.getLogger(ColumnFamilyStore.class);
@@ -199,7 +201,12 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         metadata.compressionParameters = CompressionParameters.create(opts);
     }
 
-    private ColumnFamilyStore(Table table, String columnFamilyName, IPartitioner partitioner,
int generation, CFMetaData metadata, Directories directories)
+    private ColumnFamilyStore(Table table,
+                              String columnFamilyName,
+                              IPartitioner partitioner,
+                              int generation,
+                              CFMetaData metadata,
+                              Directories directories)
     {
         assert metadata != null : "null metadata for " + table + ":" + columnFamilyName;
 
@@ -213,12 +220,17 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         this.indexManager = new SecondaryIndexManager(this);
         fileIndexGenerator.set(generation);
 
+        Caching caching = metadata.getCaching();
+
         if (logger.isDebugEnabled())
             logger.debug("Starting CFS {}", columnFamily);
 
         // scan for sstables corresponding to this cf and load them
         data = new DataTracker(this);
-        Set<DecoratedKey> savedKeys = CacheService.instance.keyCache.readSaved(table.name,
columnFamily);
+        Set<DecoratedKey> savedKeys = caching == Caching.NONE || caching == Caching.ROWS_ONLY
+                                       ? Collections.<DecoratedKey>emptySet()
+                                       : CacheService.instance.keyCache.readSaved(table.name,
columnFamily);
+
         Directories.SSTableLister sstables = directories.sstableLister().skipCompacted(true).skipTemporary(true);
         data.addInitialSSTables(SSTableReader.batchOpen(sstables.list().entrySet(), savedKeys,
data, metadata, this.partitioner));
 
@@ -298,7 +310,10 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         return createColumnFamilyStore(table, columnFamily, StorageService.getPartitioner(),
Schema.instance.getCFMetaData(table.name, columnFamily));
     }
 
-    public static synchronized ColumnFamilyStore createColumnFamilyStore(Table table, String
columnFamily, IPartitioner partitioner, CFMetaData metadata)
+    public static synchronized ColumnFamilyStore createColumnFamilyStore(Table table,
+                                                                         String columnFamily,
+                                                                         IPartitioner partitioner,
+                                                                         CFMetaData metadata)
     {
         // get the max generation number, to prevent generation conflicts
         Directories directories = Directories.create(table.name, columnFamily);
@@ -1940,8 +1955,8 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
 
     private boolean isRowCacheEnabled()
     {
-        return !(metadata.getCaching() == CFMetaData.Caching.NONE
-              || metadata.getCaching() == CFMetaData.Caching.KEYS_ONLY
+        return !(metadata.getCaching() == Caching.NONE
+              || metadata.getCaching() == Caching.KEYS_ONLY
               || CacheService.instance.rowCache.getCapacity() == 0);
     }
 


Mime
View raw message