cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r898894 - in /incubator/cassandra/trunk: src/java/org/apache/cassandra/db/ColumnFamilyStore.java src/java/org/apache/cassandra/db/Table.java test/system/test_server.py
Date Wed, 13 Jan 2010 19:14:02 GMT
Author: jbellis
Date: Wed Jan 13 19:14:02 2010
New Revision: 898894

URL: http://svn.apache.org/viewvc?rev=898894&view=rev
Log:
add missing gcBefore parameter to removeDeleted; clone SC from cache before modifying
patch by jbellis; reviewed by goffinet for CASSANDRA-689

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
    incubator/cassandra/trunk/test/system/test_server.py

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=898894&r1=898893&r2=898894&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 Wed
Jan 13 19:14:02 2010
@@ -30,7 +30,6 @@
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 
-import com.reardencommerce.kernel.collections.shared.evictable.ConcurrentLinkedHashMap;
 import org.apache.cassandra.service.SliceRange;
 import org.apache.log4j.Logger;
 
@@ -752,15 +751,15 @@
         return getColumnFamily(filter, CompactionManager.getDefaultGCBefore());
     }
 
-    private ColumnFamily getCachedRow(QueryFilter filter) throws IOException
+    private ColumnFamily cacheRow(String key) throws IOException
     {
         ColumnFamily cached;
-        if ((cached = rowCache.get(filter.key)) == null)
+        if ((cached = rowCache.get(key)) == null)
         {
-            cached = getTopLevelColumns(new IdentityQueryFilter(filter.key, new QueryPath(columnFamily_)),
Integer.MIN_VALUE);
+            cached = getTopLevelColumns(new IdentityQueryFilter(key, new QueryPath(columnFamily_)),
Integer.MIN_VALUE);
             if (cached == null)
                 return null;
-            rowCache.put(filter.key, cached);
+            rowCache.put(key, cached);
         }
         return cached;
     }
@@ -782,11 +781,11 @@
                 if (rowCache == null)
                     return removeDeleted(getTopLevelColumns(filter, gcBefore), gcBefore);
 
-                ColumnFamily cached = getCachedRow(filter);
+                ColumnFamily cached = cacheRow(filter.key);
                 ColumnIterator ci = filter.getMemColumnIterator(memtable_, cached, getComparator());
// TODO passing memtable here is confusing since it's almost entirely unused
                 ColumnFamily returnCF = ci.getColumnFamily();
                 filter.collectCollatedColumns(returnCF, ci, gcBefore);
-                return removeDeleted(returnCF);
+                return removeDeleted(returnCF, gcBefore);
             }
 
             // we are querying subcolumns of a supercolumn: fetch the supercolumn with NQF,
then filter in-memory.
@@ -804,12 +803,13 @@
             }
             else
             {
-                cf = getCachedRow(filter);
+                cf = cacheRow(filter.key);
                 if (cf == null)
                     return null;
                 sc = (SuperColumn)cf.getColumn(filter.path.superColumnName);
                 if (sc == null)
                     return null;
+                sc = (SuperColumn)sc.cloneMe();
             }
             
             SuperColumn scFiltered = filter.filterSuperColumn(sc, gcBefore);
@@ -1229,7 +1229,8 @@
         return ssTables_.size();
     }
 
-    public ColumnFamily getCachedRow(String key)
+    /** raw cached row -- does not fetch the row if it is not present */
+    public ColumnFamily getRawCachedRow(String key)
     {
         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=898894&r1=898893&r2=898894&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 Wed Jan 13 19:14:02
2010
@@ -33,7 +33,6 @@
 
 import java.net.InetAddress;
 
-import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.*;
 import org.apache.cassandra.db.filter.*;
 
@@ -422,7 +421,7 @@
                 if ((memtableToFlush=cfs.apply(mutation.key(), columnFamily)) != null)
                     memtablesToFlush.put(cfs, memtableToFlush);
 
-                ColumnFamily cachedRow = cfs.getCachedRow(mutation.key());
+                ColumnFamily cachedRow = cfs.getRawCachedRow(mutation.key());
                 if (cachedRow != null)
                     cachedRow.addAll(columnFamily);
             }

Modified: incubator/cassandra/trunk/test/system/test_server.py
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/system/test_server.py?rev=898894&r1=898893&r2=898894&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/system/test_server.py (original)
+++ incubator/cassandra/trunk/test/system/test_server.py Wed Jan 13 19:14:02 2010
@@ -183,6 +183,8 @@
 
     def test_missing_super(self):
         _expect_missing(lambda: client.get('Keyspace1', 'key1', ColumnPath('Super1', 'sc1',
_i64(1)), ConsistencyLevel.ONE))
+        _insert_super()
+        _expect_missing(lambda: client.get('Keyspace1', 'key1', ColumnPath('Super1', 'sc1',
_i64(1)), ConsistencyLevel.ONE))
 
     def test_count(self):
         _insert_simple()
@@ -585,8 +587,8 @@
         assert _big_slice('Keyspace1', 'key1', ColumnParent('Standard1')) == []
         # Next, w/ a newer timestamp; it should come back:
         client.insert('Keyspace1', 'key1', ColumnPath('Standard1', column='c1'), 'value1',
4, ConsistencyLevel.ONE)
-        assert _big_slice('Keyspace1', 'key1', ColumnParent('Standard1')) == \
-            [ColumnOrSuperColumn(column=Column('c1', 'value1', 4))]
+        result = _big_slice('Keyspace1', 'key1', ColumnParent('Standard1'))
+        assert result == [ColumnOrSuperColumn(column=Column('c1', 'value1', 4))], result
 
         # check removing the entire super cf, too.
         client.remove('Keyspace1', 'key1', ColumnPath('Super1'), 3, ConsistencyLevel.ONE)



Mime
View raw message