avoid caching token-only decoratedkeys

patch by jbellis; reviewed by slebresne for CASSANDRA-2416

git-svn-id: https://svn.apache.org/repos/asf/cassandra/branches/cassandra-0.7@1094647 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Ellis 2011-04-18 16:56:57 +00:00
parent 5d63a26cfd
commit 86f6184d0d
2 changed files with 5 additions and 2 deletions

View File

@ -29,6 +29,7 @@
* re-set bootstrapped flag after move finishes (CASSANDRA-2435)
* use 64KB flush buffer instead of in_memory_compaction_limit (CASSANDRA-2463)
* fix duplicate results from CFS.scan (CASSANDRA-2406)
* avoid caching token-only decoratedkeys (CASSANDRA-2416)
0.7.4

View File

@ -417,8 +417,9 @@ public class SSTableReader extends SSTable implements Comparable<SSTableReader>
public void cacheKey(DecoratedKey key, Long info)
{
assert key.key != null;
// avoid keeping a permanent reference to the original key buffer
DecoratedKey copiedKey = new DecoratedKey(key.token, key.key == null ? null : ByteBufferUtil.clone(key.key));
DecoratedKey copiedKey = new DecoratedKey(key.token, ByteBufferUtil.clone(key.key));
keyCache.put(new Pair<Descriptor, DecoratedKey>(descriptor, copiedKey), info);
}
@ -487,7 +488,8 @@ public class SSTableReader extends SSTable implements Comparable<SSTableReader>
if (op == Operator.EQ)
bloomFilterTracker.addTruePositive();
// store exact match for the key
cacheKey(decoratedKey, dataPosition);
if (decoratedKey.key != null)
cacheKey(decoratedKey, dataPosition);
}
return dataPosition;
}