Author: jbellis
Date: Thu Jun 23 16:03:27 2011
New Revision: 1138959

URL: http://svn.apache.org/viewvc?rev=1138959&view=rev
Log:
allow deleting a rowand updating indexed columns init in the same mutation
patch by jbellis; reviewed by slebresne for CASSANDRA-2773

Modified:
    cassandra/branches/cassandra-0.8/CHANGES.txt
    cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/Table.java

Modified: cassandra/branches/cassandra-0.8/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/CHANGES.txt?rev=1138959&r1=1138958&r2=1138959&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.8/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.8/CHANGES.txt Thu Jun 23 16:03:27 2011
@@ -1,5 +1,8 @@
 0.8.2
  * improve thread-safety in StreamOutSession (CASSANDRA-2792)
+ * allow deleting a row and updating indexed columns in it in the
+   same mutation (CASSANDRA-2773)
+
 
 0.8.1
  * CQL:

Modified: 
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/Table.java
URL: 
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/Table.java?rev=1138959&r1=1138958&r2=1138959&view=diff
==============================================================================
--- 
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/Table.java 
(original)
+++ 
cassandra/branches/cassandra-0.8/src/java/org/apache/cassandra/db/Table.java 
Thu Jun 23 16:03:27 2011
@@ -481,6 +481,8 @@ public class Table
 
     private static void ignoreObsoleteMutations(ColumnFamily cf, 
SortedSet<ByteBuffer> mutatedIndexedColumns, ColumnFamily oldIndexedColumns)
     {
+        // DO NOT modify the cf object here, it can race w/ the CL write (see 
https://issues.apache.org/jira/browse/CASSANDRA-2604)
+
         if (oldIndexedColumns == null)
             return;
 
@@ -489,7 +491,16 @@ public class Table
             ByteBuffer name = iter.next();
             IColumn newColumn = cf.getColumn(name); // null == row delete or 
it wouldn't be marked Mutated
             if (newColumn != null && cf.isMarkedForDelete())
-                throw new UnsupportedOperationException("Index manager cannot 
support deleting and inserting into a row in the same mutation");
+            {
+                // row is marked for delete, but column was also updated.  if 
column is timestamped less than
+                // the row tombstone, treat it as if it didn't exist.  
Otherwise we don't care about row
+                // tombstone for the purpose of the index update and we can 
proceed as usual.
+                if (newColumn.timestamp() <= cf.getMarkedForDeleteAt())
+                {
+                    // don't remove from the cf object; that can race w/ 
CommitLog write.  Leaving it is harmless.
+                    newColumn = null;
+                }
+            }
             IColumn oldColumn = oldIndexedColumns.getColumn(name);
 
             // deletions are irrelevant to the index unless we're changing 
state from live -> deleted, i.e.,


Reply via email to