cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r886886 - in /incubator/cassandra/trunk: ./ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/db/filter/ test/system/ test/unit/org/apache/cassandra/db/
Date Thu, 03 Dec 2009 19:17:04 GMT
Author: jbellis
Date: Thu Dec  3 19:17:03 2009
New Revision: 886886

URL: http://svn.apache.org/viewvc?rev=886886&view=rev
Log:
Fix not returning live subcolumns of deleted supercolumns
patch by jbellis; reviewed by junrao for CASSANDRA-583

Modified:
    incubator/cassandra/trunk/CHANGES.txt
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Column.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/IColumn.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
    incubator/cassandra/trunk/test/system/test_server.py
    incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java

Modified: incubator/cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/CHANGES.txt?rev=886886&r1=886885&r2=886886&view=diff
==============================================================================
--- incubator/cassandra/trunk/CHANGES.txt (original)
+++ incubator/cassandra/trunk/CHANGES.txt Thu Dec  3 19:17:03 2009
@@ -7,6 +7,9 @@
  * fix cleanup of local "system" keyspace (CASSANDRA-576)
  * improve computation of cluster load balance (CASSANDRA-554)
  * added count and column/row delete to cassandra-cli (CASSANDRA-594)
+ * fix returning live subcolumns of deleted supercolumns (CASSANDRA-583)
+ * respect JAVA_HOME in bin/ scripts (several tickets)
+ * add StorageService.initClient for fat clients on the JVM (CASSANDRA-535)
 
 
 0.5.0 beta

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Column.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Column.java?rev=886886&r1=886885&r2=886886&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Column.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Column.java Thu Dec  3 19:17:03
2009
@@ -132,7 +132,7 @@
         return timestamp;
     }
 
-    public long mostRecentChangeAt()
+    public long mostRecentLiveChangeAt()
     {
         return timestamp;
     }

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=886886&r1=886885&r2=886886&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 Thu
Dec  3 19:17:03 2009
@@ -1117,7 +1117,7 @@
             if (filter.path.superColumnName != null)
             {
                 QueryFilter nameFilter = new NamesQueryFilter(filter.key, new QueryPath(columnFamily_),
filter.path.superColumnName);
-                ColumnFamily cf = getColumnFamilyInternal(nameFilter, getDefaultGCBefore());
+                ColumnFamily cf = getColumnFamilyInternal(nameFilter, gcBefore);
                 if (cf == null || cf.getColumnCount() == 0)
                     return cf;
 

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/IColumn.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/IColumn.java?rev=886886&r1=886885&r2=886886&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/IColumn.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/IColumn.java Thu Dec  3 19:17:03
2009
@@ -30,7 +30,7 @@
 
     public boolean isMarkedForDelete();
     public long getMarkedForDeleteAt();
-    public long mostRecentChangeAt();
+    public long mostRecentLiveChangeAt();
     public byte[] name();
     public int size();
     public int serializedSize();

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java?rev=886886&r1=886885&r2=886886&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java Thu Dec  3
19:17:03 2009
@@ -20,7 +20,6 @@
 
 import java.io.*;
 import java.util.Collection;
-import java.util.Arrays;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.ConcurrentSkipListMap;
 import java.security.MessageDigest;
@@ -158,14 +157,14 @@
     	throw new IllegalArgumentException("Timestamp was requested for a column that does not
exist.");
     }
 
-    public long mostRecentChangeAt()
+    public long mostRecentLiveChangeAt()
     {
         long max = Long.MIN_VALUE;
         for (IColumn column : columns_.values())
         {
-            if (column.mostRecentChangeAt() > max)
+            if (!column.isMarkedForDelete() && column.timestamp() > max)
             {
-                max = column.mostRecentChangeAt();
+                max = column.timestamp();
             }
         }
         return max;

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java?rev=886886&r1=886885&r2=886886&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
Thu Dec  3 19:17:03 2009
@@ -86,7 +86,7 @@
         while (reducedColumns.hasNext())
         {
             IColumn column = reducedColumns.next();
-            if (!column.isMarkedForDelete() || column.getLocalDeletionTime() > gcBefore)
+            if (QueryFilter.isRelevant(column, container, gcBefore))
                 container.addColumn(column);
         }
     }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java?rev=886886&r1=886885&r2=886886&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java Thu
Dec  3 19:17:03 2009
@@ -111,4 +111,14 @@
     {
         return path.columnFamilyName;
     }
+
+    public static boolean isRelevant(IColumn column, IColumnContainer container, int gcBefore)
+    {
+        // the column itself must be not gc-able (it is live, or a still relevant tombstone,
or has live subcolumns), (1)
+        // and if its container is deleted, the column must be changed more recently than
the container tombstone (2)
+        // (since otherwise, the only thing repair cares about is the container tombstone)
+        long maxChange = column.mostRecentLiveChangeAt();
+        return (!column.isMarkedForDelete() || column.getLocalDeletionTime() > gcBefore
|| maxChange > column.getMarkedForDeleteAt()) // (1)
+               && (!container.isMarkedForDelete() || maxChange > container.getMarkedForDeleteAt());
// (2)
+    }
 }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java?rev=886886&r1=886885&r2=886886&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
Thu Dec  3 19:17:03 2009
@@ -35,7 +35,6 @@
 import org.apache.cassandra.io.SSTableReader;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.marshal.AbstractType;
-import org.apache.cassandra.config.DatabaseDescriptor;
 
 public class SliceQueryFilter extends QueryFilter
 {
@@ -124,20 +123,14 @@
             // only count live columns towards the `count` criteria
             if (!column.isMarkedForDelete()
                 && (!container.isMarkedForDelete()
-                    || column.mostRecentChangeAt() > container.getMarkedForDeleteAt()))
+                    || column.mostRecentLiveChangeAt() > container.getMarkedForDeleteAt()))
             {
                 liveColumns++;
             }
 
             // but we need to add all non-gc-able columns to the result for read repair:
-            // the column itself must be not gc-able, (1)
-            // and if its container is deleted, the column must be changed more recently
than the container tombstone (2)
-            // (since otherwise, the only thing repair cares about is the container tombstone)
-            if ((!column.isMarkedForDelete() || column.getLocalDeletionTime() > gcBefore)
// (1)
-                && (!container.isMarkedForDelete() || column.mostRecentChangeAt()
> container.getMarkedForDeleteAt())) // (2)
-            {
+            if (QueryFilter.isRelevant(column, container, gcBefore))
                 container.addColumn(column);
-            }
         }
     }
 }

Modified: incubator/cassandra/trunk/test/system/test_server.py
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/system/test_server.py?rev=886886&r1=886885&r2=886886&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/system/test_server.py (original)
+++ incubator/cassandra/trunk/test/system/test_server.py Thu Dec  3 19:17:03 2009
@@ -452,7 +452,7 @@
 
         # Test resurrection.  First, re-insert the value w/ older timestamp, 
         # and make sure it stays removed:
-        client.insert('Keyspace1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), 'value5',
0, ConsistencyLevel.ONE)
+        client.insert('Keyspace1', 'key1', ColumnPath('Super1', 'sc2', _i64(5)), 'value5',
1, ConsistencyLevel.ONE)
         super_columns = [result.super_column
                          for result in _big_slice('Keyspace1', 'key1', ColumnParent('Super1'))]
         assert super_columns == super_columns_expected, super_columns
@@ -465,6 +465,12 @@
                                   SuperColumn(name='sc2', columns=[Column(_i64(5), 'value5',
6)])]
         assert super_columns == super_columns_expected, super_columns
 
+        # check slicing at the subcolumn level too
+        p = SlicePredicate(slice_range=SliceRange('', '', False, 1000))
+        columns = [result.column
+                   for result in client.get_slice('Keyspace1', 'key1', ColumnParent('Super1',
'sc2'), p, ConsistencyLevel.ONE)]
+        assert columns == [Column(_i64(5), 'value5', 6)], columns
+
 
     def test_empty_range(self):
         assert client.get_key_range('Keyspace1', 'Standard1', '', '', 1000, ConsistencyLevel.ONE)
== []

Modified: incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java?rev=886886&r1=886885&r2=886886&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java
(original)
+++ incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java
Thu Dec  3 19:17:03 2009
@@ -153,7 +153,7 @@
     private void validateRemoveWithNewData() throws IOException
     {
         ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Super2");
-        ColumnFamily resolved = store.getColumnFamily(new NamesQueryFilter("key1", new QueryPath("Super2",
"SC1".getBytes()), getBytes(2)));
+        ColumnFamily resolved = store.getColumnFamily(new NamesQueryFilter("key1", new QueryPath("Super2",
"SC1".getBytes()), getBytes(2)), Integer.MAX_VALUE);
         Collection<IColumn> subColumns = resolved.getSortedColumns().iterator().next().getSubColumns();
         assert subColumns.size() == 1;
         assert subColumns.iterator().next().timestamp() == 2;



Mime
View raw message