cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r898179 - in /incubator/cassandra/trunk/src/java/org/apache/cassandra/db: ColumnFamilyStore.java Table.java
Date Tue, 12 Jan 2010 04:05:29 GMT
Author: jbellis
Date: Tue Jan 12 04:05:28 2010
New Revision: 898179

URL: http://svn.apache.org/viewvc?rev=898179&view=rev
Log:
update cached rows in-place instead of invalidating & reloading.  should make it more
suitable for relatively wide rows, especially if updates are to a small number of columns.
patch by jbellis; reviewed by goffinet for CASSANDRA-678

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=898179&r1=898178&r2=898179&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Tue
Jan 12 04:05:28 2010
@@ -1260,15 +1260,9 @@
         return ssTables_.size();
     }
 
-    public void invalidate(String key)
+    public ColumnFamily getCachedRow(String key)
     {
-        if (rowCache != null)
-            rowCache.remove(key);
-    }
-
-    public boolean isRowCacheEnabled()
-    {
-        return rowCache != null;
+        return rowCache == null ? null : rowCache.get(key);
     }
 
     /**

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=898179&r1=898178&r2=898179&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Tue Jan 12 04:05:28
2010
@@ -32,6 +32,8 @@
 import org.apache.cassandra.io.util.FileUtils;
 
 import java.net.InetAddress;
+
+import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.*;
 import org.apache.cassandra.db.filter.*;
 
@@ -407,7 +409,6 @@
         HashMap<ColumnFamilyStore,Memtable> memtablesToFlush = new HashMap<ColumnFamilyStore,
Memtable>(2);
 
         // write the mutation to the commitlog and memtables
-        boolean invalidateRequired = false;
         flusherLock.readLock().lock();
         try
         {
@@ -417,10 +418,13 @@
             for (ColumnFamily columnFamily : mutation.getColumnFamilies())
             {
                 Memtable memtableToFlush;
-                ColumnFamilyStore cfStore = columnFamilyStores.get(columnFamily.name());
-                invalidateRequired |= cfStore.isRowCacheEnabled();
-                if ((memtableToFlush=cfStore.apply(mutation.key(), columnFamily)) != null)
-                    memtablesToFlush.put(cfStore, memtableToFlush);
+                ColumnFamilyStore cfs = columnFamilyStores.get(columnFamily.name());
+                if ((memtableToFlush=cfs.apply(mutation.key(), columnFamily)) != null)
+                    memtablesToFlush.put(cfs, memtableToFlush);
+
+                ColumnFamily cachedRow = cfs.getCachedRow(mutation.key());
+                if (cachedRow != null)
+                    cachedRow.addAll(columnFamily);
             }
         }
         finally
@@ -428,16 +432,6 @@
             flusherLock.readLock().unlock();
         }
 
-        // invalidate cache.  2nd loop over CFs here to avoid prolonging the lock section
unnecessarily.
-        if (invalidateRequired)
-        {
-            for (ColumnFamily cf : mutation.getColumnFamilies())
-            {
-                ColumnFamilyStore cfs = columnFamilyStores.get(cf.name());
-                cfs.invalidate(mutation.key());
-            }
-        }
-
         // flush memtables that got filled up.  usually mTF will be empty and this will be
a no-op
         for (Map.Entry<ColumnFamilyStore, Memtable> entry : memtablesToFlush.entrySet())
             entry.getKey().switchMemtable(entry.getValue(), writeCommitLog);



Mime
View raw message