cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject cassandra git commit: Simplify row cache invalidation code
Date Mon, 09 Nov 2015 20:07:58 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.2 b0def95b5 -> d867ac1f4


Simplify row cache invalidation code

patch by Jonathan Ellis; reviewed by Aleksey Yeschenko for
CASSANDRA-10396


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

Branch: refs/heads/cassandra-2.2
Commit: d867ac1f41c59b31f8fb4f54a06c0118018cfc81
Parents: b0def95
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Thu Sep 24 13:24:57 2015 -0700
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Mon Nov 9 20:05:32 2015 +0000

----------------------------------------------------------------------
 .../org/apache/cassandra/db/ColumnFamilyStore.java   | 15 +++------------
 .../db/compaction/CompactionController.java          |  4 +---
 .../cassandra/db/compaction/CompactionManager.java   |  2 +-
 .../apache/cassandra/io/sstable/SSTableRewriter.java |  3 +--
 .../org/apache/cassandra/streaming/StreamReader.java |  2 +-
 test/unit/org/apache/cassandra/db/RowCacheTest.java  |  2 +-
 .../db/compaction/CompactionsPurgeTest.java          |  2 +-
 7 files changed, 9 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/d867ac1f/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 d553f4d..b112e0e 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
@@ -1226,7 +1226,7 @@ public class ColumnFamilyStore implements ColumnFamilyStoreMBean
         return String.format("%.2f/%.2f", onHeap, offHeap);
     }
 
-    public void maybeUpdateRowCache(DecoratedKey key)
+    public void maybeInvalidateCachedRow(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);
-        maybeUpdateRowCache(key);
+        maybeInvalidateCachedRow(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))
-                invalidateCachedRow(dk);
+                maybeInvalidateCachedRow(dk);
         }
 
         if (metadata.isCounter())
@@ -2532,15 +2532,6 @@ 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.

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d867ac1f/src/java/org/apache/cassandra/db/compaction/CompactionController.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionController.java b/src/java/org/apache/cassandra/db/compaction/CompactionController.java
index 5f0a198..24ef843 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionController.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionController.java
@@ -24,8 +24,6 @@ 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;
@@ -191,7 +189,7 @@ public class CompactionController implements AutoCloseable
 
     public void invalidateCachedRow(DecoratedKey key)
     {
-        cfs.invalidateCachedRow(key);
+        cfs.maybeInvalidateCachedRow(key);
     }
 
     public void close()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d867ac1f/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
index 0c6e24f..8537aca 100644
--- a/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
+++ b/src/java/org/apache/cassandra/db/compaction/CompactionManager.java
@@ -934,7 +934,7 @@ public class CompactionManager implements CompactionManagerMBean
                 if (Range.isInRanges(row.getKey().getToken(), ranges))
                     return row;
 
-                cfs.invalidateCachedRow(row.getKey());
+                cfs.maybeInvalidateCachedRow(row.getKey());
 
                 if (indexedColumnsInRow != null)
                     indexedColumnsInRow.clear();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d867ac1f/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java b/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
index dc4fe75..b08b038 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableRewriter.java
@@ -20,7 +20,6 @@ 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;
@@ -119,7 +118,7 @@ public class SSTableRewriter extends Transactional.AbstractTransactional
impleme
         {
             if (index == null)
             {
-                cfs.invalidateCachedRow(row.key);
+                cfs.maybeInvalidateCachedRow(row.key);
             }
             else
             {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d867ac1f/src/java/org/apache/cassandra/streaming/StreamReader.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/streaming/StreamReader.java b/src/java/org/apache/cassandra/streaming/StreamReader.java
index 1ccebb0..88591da 100644
--- a/src/java/org/apache/cassandra/streaming/StreamReader.java
+++ b/src/java/org/apache/cassandra/streaming/StreamReader.java
@@ -171,6 +171,6 @@ public class StreamReader
     {
         DecoratedKey key = StorageService.getPartitioner().decorateKey(ByteBufferUtil.readWithShortLength(in));
         writer.appendFromStream(key, cfs.metadata, in, inputVersion);
-        cfs.invalidateCachedRow(key);
+        cfs.maybeInvalidateCachedRow(key);
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d867ac1f/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 5912d7c..69c831d 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
         int keysLeft = 109;
         for (int i = 109; i >= 10; i--)
         {
-            cachedStore.invalidateCachedRow(Util.dk("key" + i));
+            cachedStore.maybeInvalidateCachedRow(Util.dk("key" + i));
             assert CacheService.instance.rowCache.size() == keysLeft;
             keysLeft--;
         }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/d867ac1f/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java b/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java
index e5baab6..bfe8042 100644
--- a/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/CompactionsPurgeTest.java
@@ -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.invalidateCachedRow(key);
+        cfs.maybeInvalidateCachedRow(key);
         ColumnFamily cf = cfs.getColumnFamily(QueryFilter.getIdentityFilter(key, cfName,
System.currentTimeMillis()));
         assertColumns(cf, "5");
         assertNotNull(cf.getColumn(cellname(String.valueOf(5))));


Mime
View raw message