mirror of https://github.com/apache/cassandra
Revert "Simplify row cache invalidation code"
This reverts commit d867ac1f41.
This commit is contained in:
parent
d867ac1f41
commit
48b685e852
|
|
@ -1226,7 +1226,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
|
|||
return String.format("%.2f/%.2f", onHeap, offHeap);
|
||||
}
|
||||
|
||||
public void maybeInvalidateCachedRow(DecoratedKey key)
|
||||
public void maybeUpdateRowCache(DecoratedKey key)
|
||||
{
|
||||
if (!isRowCacheEnabled())
|
||||
return;
|
||||
|
|
@ -1247,7 +1247,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
|
|||
long start = System.nanoTime();
|
||||
Memtable mt = data.getMemtableFor(opGroup, replayPosition);
|
||||
final long timeDelta = mt.put(key, columnFamily, indexer, opGroup);
|
||||
maybeInvalidateCachedRow(key);
|
||||
maybeUpdateRowCache(key);
|
||||
metric.samplers.get(Sampler.WRITES).addSample(key.getKey(), key.hashCode(), 1);
|
||||
metric.writeLatency.addNano(System.nanoTime() - start);
|
||||
if(timeDelta < Long.MAX_VALUE)
|
||||
|
|
@ -2047,7 +2047,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
|
|||
RowCacheKey key = keyIter.next();
|
||||
DecoratedKey dk = partitioner.decorateKey(ByteBuffer.wrap(key.key));
|
||||
if (key.ksAndCFName.equals(metadata.ksAndCFName) && !Range.isInRanges(dk.getToken(), ranges))
|
||||
maybeInvalidateCachedRow(dk);
|
||||
invalidateCachedRow(dk);
|
||||
}
|
||||
|
||||
if (metadata.isCounter())
|
||||
|
|
@ -2532,6 +2532,15 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
|
|||
CacheService.instance.rowCache.remove(key);
|
||||
}
|
||||
|
||||
public void invalidateCachedRow(DecoratedKey key)
|
||||
{
|
||||
UUID cfId = Schema.instance.getId(keyspace.getName(), this.name);
|
||||
if (cfId == null)
|
||||
return; // secondary index
|
||||
|
||||
invalidateCachedRow(new RowCacheKey(metadata.ksAndCFName, key));
|
||||
}
|
||||
|
||||
public ClockAndCount getCachedCounter(ByteBuffer partitionKey, CellName cellName)
|
||||
{
|
||||
if (CacheService.instance.counterCache.getCapacity() == 0L) // counter cache disabled.
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.apache.cassandra.db.ColumnFamilyStore;
|
||||
import org.apache.cassandra.db.lifecycle.SSTableIntervalTree;
|
||||
import org.apache.cassandra.db.lifecycle.Tracker;
|
||||
import org.apache.cassandra.db.DecoratedKey;
|
||||
import org.apache.cassandra.db.RowPosition;
|
||||
import org.apache.cassandra.utils.AlwaysPresentFilter;
|
||||
|
|
@ -189,7 +191,7 @@ public class CompactionController implements AutoCloseable
|
|||
|
||||
public void invalidateCachedRow(DecoratedKey key)
|
||||
{
|
||||
cfs.maybeInvalidateCachedRow(key);
|
||||
cfs.invalidateCachedRow(key);
|
||||
}
|
||||
|
||||
public void close()
|
||||
|
|
|
|||
|
|
@ -934,7 +934,7 @@ public class CompactionManager implements CompactionManagerMBean
|
|||
if (Range.isInRanges(row.getKey().getToken(), ranges))
|
||||
return row;
|
||||
|
||||
cfs.maybeInvalidateCachedRow(row.getKey());
|
||||
cfs.invalidateCachedRow(row.getKey());
|
||||
|
||||
if (indexedColumnsInRow != null)
|
||||
indexedColumnsInRow.clear();
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.apache.cassandra.io.sstable;
|
|||
import java.util.*;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.util.concurrent.Runnables;
|
||||
|
||||
import org.apache.cassandra.cache.InstrumentingCache;
|
||||
import org.apache.cassandra.cache.KeyCacheKey;
|
||||
|
|
@ -118,7 +119,7 @@ public class SSTableRewriter extends Transactional.AbstractTransactional impleme
|
|||
{
|
||||
if (index == null)
|
||||
{
|
||||
cfs.maybeInvalidateCachedRow(row.key);
|
||||
cfs.invalidateCachedRow(row.key);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -171,6 +171,6 @@ public class StreamReader
|
|||
{
|
||||
DecoratedKey key = StorageService.getPartitioner().decorateKey(ByteBufferUtil.readWithShortLength(in));
|
||||
writer.appendFromStream(key, cfs.metadata, in, inputVersion);
|
||||
cfs.maybeInvalidateCachedRow(key);
|
||||
cfs.invalidateCachedRow(key);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ public class RowCacheTest
|
|||
int keysLeft = 109;
|
||||
for (int i = 109; i >= 10; i--)
|
||||
{
|
||||
cachedStore.maybeInvalidateCachedRow(Util.dk("key" + i));
|
||||
cachedStore.invalidateCachedRow(Util.dk("key" + i));
|
||||
assert CacheService.instance.rowCache.size() == keysLeft;
|
||||
keysLeft--;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ public class CompactionsPurgeTest
|
|||
|
||||
// major compact and test that all columns but the resurrected one is completely gone
|
||||
FBUtilities.waitOnFutures(CompactionManager.instance.submitMaximal(cfs, Integer.MAX_VALUE, false));
|
||||
cfs.maybeInvalidateCachedRow(key);
|
||||
cfs.invalidateCachedRow(key);
|
||||
ColumnFamily cf = cfs.getColumnFamily(QueryFilter.getIdentityFilter(key, cfName, System.currentTimeMillis()));
|
||||
assertColumns(cf, "5");
|
||||
assertNotNull(cf.getColumn(cellname(String.valueOf(5))));
|
||||
|
|
|
|||
Loading…
Reference in New Issue