cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alek...@apache.org
Subject git commit: Support range tombstones in thrift
Date Sun, 14 Jul 2013 22:00:22 GMT
Updated Branches:
  refs/heads/trunk 295984dbd -> b60f63d54


Support range tombstones in thrift

patch by Edward Capriolo and Aleksey Yeschenko for CASSANDRA-5435


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/b60f63d5
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/b60f63d5
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/b60f63d5

Branch: refs/heads/trunk
Commit: b60f63d5438be5ea3f564e7d00e32d1fdb4001de
Parents: 295984d
Author: Aleksey Yeschenko <aleksey@apache.org>
Authored: Mon Jul 15 00:54:54 2013 +0300
Committer: Aleksey Yeschenko <aleksey@apache.org>
Committed: Mon Jul 15 00:54:54 2013 +0300

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/thrift/CassandraServer.java       | 17 ++++-
 .../cassandra/thrift/ThriftValidation.java      |  4 -
 test/system/test_thrift_server.py               | 78 +++++++++++++++++---
 4 files changed, 86 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b60f63d5/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 4656160..194d7cb 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,7 @@
  * Allow nodetool with no args, and with help to run without a server (CASSANDRA-5734)
  * Cleanup AbstractType/TypeSerializer classes (CASSANDRA-5744)
  * Remove unimplemented cli option schema-mwt (CASSANDRA-5754)
+ * Support range tombstones in thrift (CASSANDRA-5435)
 
 2.0.0-beta1
  * Removed on-heap row cache (CASSANDRA-5348)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b60f63d5/src/java/org/apache/cassandra/thrift/CassandraServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java b/src/java/org/apache/cassandra/thrift/CassandraServer.java
index 8aa0fdb..15ab9d0 100644
--- a/src/java/org/apache/cassandra/thrift/CassandraServer.java
+++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java
@@ -870,7 +870,7 @@ public class CassandraServer implements Cassandra.Iface
     {
         if (del.predicate != null && del.predicate.column_names != null)
         {
-            for(ByteBuffer c : del.predicate.column_names)
+            for (ByteBuffer c : del.predicate.column_names)
             {
                 if (del.super_column == null && Schema.instance.getColumnFamilyType(rm.getKeyspaceName(),
cfName) == ColumnFamilyType.Super)
                     rm.deleteRange(cfName, SuperColumns.startOf(c), SuperColumns.endOf(c),
del.timestamp);
@@ -880,6 +880,21 @@ public class CassandraServer implements Cassandra.Iface
                     rm.delete(cfName, c, del.timestamp);
             }
         }
+        else if (del.predicate != null && del.predicate.slice_range != null)
+        {
+            if (del.super_column == null && Schema.instance.getColumnFamilyType(rm.getKeyspaceName(),
cfName) == ColumnFamilyType.Super)
+                rm.deleteRange(cfName,
+                               SuperColumns.startOf(del.predicate.getSlice_range().start),
+                               SuperColumns.startOf(del.predicate.getSlice_range().finish),
+                               del.timestamp);
+            else if (del.super_column != null)
+                rm.deleteRange(cfName,
+                               CompositeType.build(del.super_column, del.predicate.getSlice_range().start),
+                               CompositeType.build(del.super_column, del.predicate.getSlice_range().finish),
+                               del.timestamp);
+            else
+                rm.deleteRange(cfName, del.predicate.getSlice_range().start, del.predicate.getSlice_range().finish,
del.timestamp);
+        }
         else
         {
             if (del.super_column != null)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b60f63d5/src/java/org/apache/cassandra/thrift/ThriftValidation.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/thrift/ThriftValidation.java b/src/java/org/apache/cassandra/thrift/ThriftValidation.java
index af2496a..23d21f8 100644
--- a/src/java/org/apache/cassandra/thrift/ThriftValidation.java
+++ b/src/java/org/apache/cassandra/thrift/ThriftValidation.java
@@ -357,11 +357,7 @@ public class ThriftValidation
             validateColumnNames(metadata, (ByteBuffer)null, Arrays.asList(del.super_column));
 
         if (del.predicate != null)
-        {
             validateSlicePredicate(metadata, del.super_column, del.predicate);
-            if (del.predicate.slice_range != null)
-                throw new org.apache.cassandra.exceptions.InvalidRequestException("Deletion
does not yet support SliceRange predicates.");
-        }
 
         if (metadata.cfType == ColumnFamilyType.Standard && del.super_column != null)
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/b60f63d5/test/system/test_thrift_server.py
----------------------------------------------------------------------
diff --git a/test/system/test_thrift_server.py b/test/system/test_thrift_server.py
index 2b50c1e..5d4a167 100644
--- a/test/system/test_thrift_server.py
+++ b/test/system/test_thrift_server.py
@@ -619,6 +619,75 @@ class TestMutations(ThriftTester):
           for key in keys:
             _assert_no_columnpath(key, ColumnPath('Super1', super_column=sc.name))
 
+    def test_batch_mutate_remove_slice_standard(self):
+        _set_keyspace('Keyspace1')
+
+        columns = [Column('c1', 'value1', 0),
+                   Column('c2', 'value2', 0),
+                   Column('c3', 'value3', 0),
+                   Column('c4', 'value4', 0),
+                   Column('c5', 'value5', 0)]
+
+        for column in columns:
+            client.insert('key', ColumnParent('Standard1'), column, ConsistencyLevel.ONE)
+
+        d = Deletion(1, predicate=SlicePredicate(slice_range=SliceRange(start='c2', finish='c5')))
+        client.batch_mutate({'key': {'Standard1' : [Mutation(deletion=d)]}}, ConsistencyLevel.ONE)
+
+        _assert_columnpath_exists('key', ColumnPath('Standard1', column='c1'))
+        _assert_no_columnpath('key', ColumnPath('Standard1', column='c2'))
+        _assert_no_columnpath('key', ColumnPath('Standard1', column='c3'))
+        _assert_no_columnpath('key', ColumnPath('Standard1', column='c4'))
+        _assert_columnpath_exists('key', ColumnPath('Standard1', column='c5'))
+
+    def test_batch_mutate_remove_slice_of_entire_supercolumns(self):
+        _set_keyspace('Keyspace1')
+
+        columns = [SuperColumn(name='sc1', columns=[Column(_i64(1), 'value1', 0)]),
+                   SuperColumn(name='sc2',
+                               columns=[Column(_i64(2), 'value2', 0), Column(_i64(3), 'value3',
0)]),
+                   SuperColumn(name='sc3', columns=[Column(_i64(4), 'value4', 0)]),
+                   SuperColumn(name='sc4',
+                               columns=[Column(_i64(5), 'value5', 0), Column(_i64(6), 'value6',
0)]),
+                   SuperColumn(name='sc5', columns=[Column(_i64(7), 'value7', 0)])]
+
+        for column in columns:
+            for subcolumn in column.columns:
+                client.insert('key', ColumnParent('Super1', column.name), subcolumn, ConsistencyLevel.ONE)
+
+        d = Deletion(1, predicate=SlicePredicate(slice_range=SliceRange(start='sc2', finish='sc5')))
+        client.batch_mutate({'key': {'Super1' : [Mutation(deletion=d)]}}, ConsistencyLevel.ONE)
+
+        _assert_columnpath_exists('key', ColumnPath('Super1', super_column='sc1', column=_i64(1)))
+        _assert_no_columnpath('key', ColumnPath('Super1', super_column='sc2', column=_i64(2)))
+        _assert_no_columnpath('key', ColumnPath('Super1', super_column='sc2', column=_i64(3)))
+        _assert_no_columnpath('key', ColumnPath('Super1', super_column='sc3', column=_i64(4)))
+        _assert_no_columnpath('key', ColumnPath('Super1', super_column='sc4', column=_i64(5)))
+        _assert_no_columnpath('key', ColumnPath('Super1', super_column='sc4', column=_i64(6)))
+        _assert_columnpath_exists('key', ColumnPath('Super1', super_column='sc5', column=_i64(7)))
+
+    def test_batch_mutate_remove_slice_part_of_supercolumns(self):
+        _set_keyspace('Keyspace1')
+
+        columns = [Column(_i64(1), 'value1', 0),
+                   Column(_i64(2), 'value2', 0),
+                   Column(_i64(3), 'value3', 0),
+                   Column(_i64(4), 'value4', 0),
+                   Column(_i64(5), 'value5', 0)]
+
+        for column in columns:
+            client.insert('key', ColumnParent('Super1', 'sc1'), column, ConsistencyLevel.ONE)
+
+        r = SliceRange(start=_i64(2), finish=_i64(5))
+        d = Deletion(1, super_column='sc1', predicate=SlicePredicate(slice_range=r))
+        client.batch_mutate({'key': {'Super1' : [Mutation(deletion=d)]}}, ConsistencyLevel.ONE)
+
+        _assert_columnpath_exists('key', ColumnPath('Super1', super_column='sc1', column=_i64(1)))
+        _assert_no_columnpath('key', ColumnPath('Super1', super_column='sc1', column=_i64(2)))
+        _assert_no_columnpath('key', ColumnPath('Super1', super_column='sc1', column=_i64(3)))
+        _assert_no_columnpath('key', ColumnPath('Super1', super_column='sc1', column=_i64(4)))
+        _assert_columnpath_exists('key', ColumnPath('Super1', super_column='sc1', column=_i64(5)))
+
     def test_batch_mutate_insertions_and_deletions(self):
         _set_keyspace('Keyspace1')
         
@@ -684,15 +753,6 @@ class TestMutations(ThriftTester):
                                  ConsistencyLevel.ONE)
         _expect_exception(too_full, InvalidRequestException)
 
-        # test_batch_mutate_does_not_yet_accept_slice_ranges
-        def send_range():
-            _set_keyspace('Keyspace1')
-            sp = SlicePredicate(slice_range=SliceRange(start='0', finish="", count=10))
-            d = Deletion(2, predicate=sp)
-            client.batch_mutate({'key_35': {'Standard1':[Mutation(deletion=d)]}},
-                                 ConsistencyLevel.ONE)
-        _expect_exception(send_range, InvalidRequestException)
-
         # test_batch_mutate_does_not_accept_cosc_on_undefined_cf:
         def bad_cf():
             _set_keyspace('Keyspace1')


Mime
View raw message