cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r955483 - in /cassandra/branches/cassandra-0.6: CHANGES.txt src/java/org/apache/cassandra/thrift/ThriftValidation.java test/system/test_server.py
Date Thu, 17 Jun 2010 05:25:29 GMT
Author: jbellis
Date: Thu Jun 17 05:25:28 2010
New Revision: 955483

URL: http://svn.apache.org/viewvc?rev=955483&view=rev
Log:
allow removing entire row through batch_mutate Deletion.  patch by Sylvain Lebresne; backported
to 0.6 by jbellis for CASSANDRA-1027

Modified:
    cassandra/branches/cassandra-0.6/CHANGES.txt
    cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/thrift/ThriftValidation.java
    cassandra/branches/cassandra-0.6/test/system/test_server.py

Modified: cassandra/branches/cassandra-0.6/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/CHANGES.txt?rev=955483&r1=955482&r2=955483&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.6/CHANGES.txt Thu Jun 17 05:25:28 2010
@@ -23,6 +23,7 @@
  * force anti-entropy service to stream files on the stream stage to avoid
    sending streams out of order (CASSANDRA-1169)
  * remove inactive stream managers after AES streams files (CASSANDRA-1169)
+ * allow removing entire row through batch_mutate Deletion (CASSANDRA-1027)
 
 
 0.6.2

Modified: cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/thrift/ThriftValidation.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/thrift/ThriftValidation.java?rev=955483&r1=955482&r2=955483&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/thrift/ThriftValidation.java
(original)
+++ cassandra/branches/cassandra-0.6/src/java/org/apache/cassandra/thrift/ThriftValidation.java
Thu Jun 17 05:25:28 2010
@@ -248,11 +248,6 @@ public class ThriftValidation
 
     public static void validateDeletion(String keyspace, String cfName, Deletion del) throws
InvalidRequestException
     {
-        if (del.super_column == null && del.predicate == null)
-        {
-            throw new InvalidRequestException("A Deletion must have a SuperColumn, a SlicePredicate
or both.");
-        }
-
         if (del.predicate != null)
         {
             validateSlicePredicate(keyspace, cfName, del.super_column, del.predicate);

Modified: cassandra/branches/cassandra-0.6/test/system/test_server.py
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.6/test/system/test_server.py?rev=955483&r1=955482&r2=955483&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.6/test/system/test_server.py (original)
+++ cassandra/branches/cassandra-0.6/test/system/test_server.py Thu Jun 17 05:25:28 2010
@@ -171,6 +171,22 @@ def _expect_exception(fn, type_):
 def _expect_missing(fn):
     _expect_exception(fn, NotFoundException)
 
+def waitfor(secs, fn, *args, **kwargs):
+    start = time.time()
+    success = False
+    last_exception = None
+    while not success and time.time() < start + secs:
+        try:
+            fn(*args, **kwargs)
+            success = True
+        except KeyboardInterrupt:
+            raise
+        except Exception, e:
+            last_exception = e
+            pass
+    if not success and last_exception:
+        raise last_exception
+
 
 class TestMutations(CassandraTester):
     def test_insert(self):
@@ -359,6 +375,23 @@ class TestMutations(CassandraTester):
                 for key in keys:
                     _assert_no_columnpath('Keyspace1', key, ColumnPath(column_family, column=c.name))
 
+    def test_batch_mutate_remove_standard_row(self):
+        column_families = ['Standard1', 'Standard2']
+        keys = ['key_%d' % i for i in range(11,21)]
+        _insert_multi(keys)
+
+        mutations = [Mutation(deletion=Deletion(20))]
+        mutation_map = dict((column_family, mutations) for column_family in column_families)
+
+        keyed_mutations = dict((key, mutation_map) for key in keys)
+
+        client.batch_mutate('Keyspace1', keyed_mutations, ConsistencyLevel.ONE)
+
+        for column_family in column_families:
+            for c in _SIMPLE_COLUMNS:
+                for key in keys:
+                    _assert_no_columnpath('Keyspace1', key, ColumnPath(column_family, column=c.name))
+
     def test_batch_mutate_remove_super_columns_with_standard_under(self):
         column_families = ['Super1', 'Super2']
         keys = ['key_%d' % i for i in range(11,21)]
@@ -412,6 +445,31 @@ class TestMutations(CassandraTester):
                 for key in keys:
                     _assert_no_columnpath('Keyspace1', key, ColumnPath('Super1', super_column=sc.name))
 
+    def test_batch_mutate_remove_super_columns_entire_row(self):
+        keys = ['key_%d' % i for i in range(17,21)]
+
+        for key in keys:
+            _insert_super(key)
+
+        mutations = []
+
+        mutations.append(Mutation(deletion=Deletion(20)))
+
+        mutation_map = {'Super1': mutations}
+
+        keyed_mutations = dict((key, mutation_map) for key in keys)
+
+        # Sanity check
+        for sc in _SUPER_COLUMNS:
+            for key in keys:
+                _assert_columnpath_exists('Keyspace1', key, ColumnPath('Super1', super_column=sc.name))
+
+        client.batch_mutate('Keyspace1', keyed_mutations, ConsistencyLevel.ZERO)
+
+        for sc in _SUPER_COLUMNS:
+          for key in keys:
+            waitfor(5, _assert_no_columnpath, 'Keyspace1', key, ColumnPath('Super1', super_column=sc.name))
+
     def test_batch_mutate_insertions_and_deletions(self):
         first_insert = SuperColumn("sc1",
                                    columns=[Column(_i64(20), 'value20', 3),
@@ -466,13 +524,6 @@ class TestMutations(CassandraTester):
                                                      super_column='sc1',
                                                      column=c))
 
-    def test_batch_mutate_validates_deletions(self):
-        def empty_deletion():
-            client.batch_mutate('Keyspace1',
-                                {'key_33': {'Standard1': [Mutation(deletion=Deletion(2))]}},
-                                ConsistencyLevel.ONE)
-        _expect_exception(empty_deletion, InvalidRequestException)
-
     def test_batch_mutate_does_not_accept_cosc_and_deletion_in_same_mutation(self):
         def too_full():
             col = ColumnOrSuperColumn(column=Column("foo", 'bar', 0))



Mime
View raw message