cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [3/3] git commit: Use correct partitioner when saving + loading caches patch by jbellis; reviewed by xedin for CASSANDRA-4331
Date Wed, 27 Jun 2012 07:20:19 GMT
Use correct partitioner when saving + loading caches
patch by jbellis; reviewed by xedin for CASSANDRA-4331


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

Branch: refs/heads/cassandra-1.1
Commit: 0627c8aaec966d01500f2bb957aaefb9873fff38
Parents: 98dc413
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Wed Jun 27 02:18:04 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Wed Jun 27 02:18:04 2012 -0500

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 .../apache/cassandra/cache/AutoSavingCache.java    |    5 +++--
 .../org/apache/cassandra/db/ColumnFamilyStore.java |    4 ++--
 .../unit/org/apache/cassandra/db/RowCacheTest.java |    4 ++--
 4 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/0627c8aa/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 1d9f20b..4c2b836 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 1.1.2
+ * Use correct partitioner when saving + loading caches (CASSANDRA-4331)
  * Check schema before trying to export sstable (CASSANDRA-2760)
  * Raise a meaningful exception instead of NPE when PFS encounters
    an unconfigured node + no default (CASSANDRA-4349)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0627c8aa/src/java/org/apache/cassandra/cache/AutoSavingCache.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cache/AutoSavingCache.java b/src/java/org/apache/cassandra/cache/AutoSavingCache.java
index 7eed2a0..004e46e 100644
--- a/src/java/org/apache/cassandra/cache/AutoSavingCache.java
+++ b/src/java/org/apache/cassandra/cache/AutoSavingCache.java
@@ -36,6 +36,7 @@ import org.apache.cassandra.db.compaction.CompactionInfo;
 import org.apache.cassandra.db.compaction.CompactionManager;
 import org.apache.cassandra.db.compaction.OperationType;
 import org.apache.cassandra.db.DecoratedKey;
+import org.apache.cassandra.dht.IPartitioner;
 import org.apache.cassandra.io.util.FileUtils;
 import org.apache.cassandra.io.util.SequentialWriter;
 import org.apache.cassandra.service.CacheService;
@@ -92,7 +93,7 @@ public class AutoSavingCache<K extends CacheKey, V> extends InstrumentingCache<K
         }
     }
 
-    public Set<DecoratedKey> readSaved(String ksName, String cfName)
+    public Set<DecoratedKey> readSaved(String ksName, String cfName, IPartitioner partitioner)
     {
         File path = getCachePath(ksName, cfName);
         Set<DecoratedKey> keys = new TreeSet<DecoratedKey>();
@@ -114,7 +115,7 @@ public class AutoSavingCache<K extends CacheKey, V> extends InstrumentingCache<K
                     DecoratedKey key;
                     try
                     {
-                        key = StorageService.getPartitioner().decorateKey(buffer);
+                        key = partitioner.decorateKey(buffer);
                     }
                     catch (Exception e)
                     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0627c8aa/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 582c097..5c7e3b2 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -228,7 +228,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         data = new DataTracker(this);
         Set<DecoratedKey> savedKeys = caching == Caching.NONE || caching == Caching.ROWS_ONLY
                                        ? Collections.<DecoratedKey>emptySet()
-                                       : CacheService.instance.keyCache.readSaved(table.name,
columnFamily);
+                                       : CacheService.instance.keyCache.readSaved(table.name,
columnFamily, partitioner);
 
         Directories.SSTableLister sstables = directories.sstableLister().skipCompacted(true).skipTemporary(true);
         data.addInitialSSTables(SSTableReader.batchOpen(sstables.list().entrySet(), savedKeys,
data, metadata, this.partitioner));
@@ -412,7 +412,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
 
         // results are sorted on read (via treeset) because there are few reads and many
writes and reads only happen at startup
         int cachedRowsRead = 0;
-        for (DecoratedKey key : rowCache.readSaved(table.name, columnFamily))
+        for (DecoratedKey key : rowCache.readSaved(table.name, columnFamily, partitioner))
         {
             ColumnFamily data = getTopLevelColumns(QueryFilter.getIdentityFilter(key, new
QueryPath(columnFamily)),
                                                    Integer.MIN_VALUE,

http://git-wip-us.apache.org/repos/asf/cassandra/blob/0627c8aa/test/unit/org/apache/cassandra/db/RowCacheTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/RowCacheTest.java b/test/unit/org/apache/cassandra/db/RowCacheTest.java
index e6b4578..7535968 100644
--- a/test/unit/org/apache/cassandra/db/RowCacheTest.java
+++ b/test/unit/org/apache/cassandra/db/RowCacheTest.java
@@ -133,7 +133,7 @@ public class RowCacheTest extends SchemaLoader
     {
         CompactionManager.instance.disableAutoCompaction();
 
-        ColumnFamilyStore store = Table.open(KEYSPACE).getColumnFamilyStore(COLUMN_FAMILY);
+        ColumnFamilyStore cfs = Table.open(KEYSPACE).getColumnFamilyStore(COLUMN_FAMILY);
 
         // empty the cache
         CacheService.instance.invalidateRowCache();
@@ -153,6 +153,6 @@ public class RowCacheTest extends SchemaLoader
         // empty the cache again to make sure values came from disk
         CacheService.instance.invalidateRowCache();
         assert CacheService.instance.rowCache.size() == 0;
-        assert CacheService.instance.rowCache.readSaved(KEYSPACE, COLUMN_FAMILY).size() ==
(keysToSave == Integer.MAX_VALUE ? totalKeys : keysToSave);
+        assert CacheService.instance.rowCache.readSaved(KEYSPACE, COLUMN_FAMILY, cfs.partitioner).size()
== (keysToSave == Integer.MAX_VALUE ? totalKeys : keysToSave);
     }
 }


Mime
View raw message