mirror of https://github.com/apache/cassandra
Use correct partitioner when saving + loading caches
patch by jbellis; reviewed by xedin for CASSANDRA-4331
This commit is contained in:
parent
98dc41393f
commit
0627c8aaec
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue