cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r832796 - in /incubator/cassandra/trunk/test: conf/storage-conf.xml unit/org/apache/cassandra/db/RemoveSuperColumnTest.java
Date Wed, 04 Nov 2009 17:07:37 GMT
Author: jbellis
Date: Wed Nov  4 17:07:37 2009
New Revision: 832796

URL: http://svn.apache.org/viewvc?rev=832796&view=rev
Log:
add failing test for removing a single subcolumn.
patch by jbellis; reviewed by gdusbabek for CASSANDRA-510

Modified:
    incubator/cassandra/trunk/test/conf/storage-conf.xml
    incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java

Modified: incubator/cassandra/trunk/test/conf/storage-conf.xml
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/conf/storage-conf.xml?rev=832796&r1=832795&r2=832796&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/conf/storage-conf.xml (original)
+++ incubator/cassandra/trunk/test/conf/storage-conf.xml Wed Nov  4 17:07:37 2009
@@ -49,6 +49,7 @@
        <ColumnFamily CompareWith="LongType" Name="StandardLong2"/>
        <ColumnFamily ColumnType="Super" CompareSubcolumnsWith="LongType" Name="Super1"/>
        <ColumnFamily ColumnType="Super" CompareSubcolumnsWith="LongType" Name="Super2"/>
+       <ColumnFamily ColumnType="Super" CompareSubcolumnsWith="LongType" Name="Super3"/>
      </Keyspace>
      <Keyspace Name = "Keyspace2">
        <ColumnFamily Name="Standard1"/>

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=832796&r1=832795&r2=832796&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
Wed Nov  4 17:07:37 2009
@@ -32,6 +32,8 @@
 import org.apache.cassandra.db.filter.QueryPath;
 import static org.apache.cassandra.Util.addMutation;
 import static org.apache.cassandra.Util.getBytes;
+import org.apache.cassandra.Util;
+import static junit.framework.Assert.assertNotNull;
 
 public class RemoveSuperColumnTest
 {
@@ -63,6 +65,37 @@
         validateRemoveCompacted();
     }
 
+    @Test
+    public void testRemoveDeletedSubColumn() throws IOException, ExecutionException, InterruptedException
+    {
+        ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Super3");
+        RowMutation rm;
+
+        // add data
+        rm = new RowMutation("Keyspace1", "key1");
+        addMutation(rm, "Super3", "SC1", 1, "val1", 0);
+        addMutation(rm, "Super3", "SC1", 2, "val1", 0);
+        rm.apply();
+        store.forceBlockingFlush();
+
+        // remove
+        rm = new RowMutation("Keyspace1", "key1");
+        rm.delete(new QueryPath("Super3", "SC1".getBytes(), Util.getBytes(1)), 1);
+        rm.apply();
+
+        validateRemoveSubColumn();
+
+        store.forceBlockingFlush();
+        validateRemoveSubColumn();
+    }
+
+    private void validateRemoveSubColumn() throws IOException
+    {
+        ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Super3");
+        assertNull(store.getColumnFamily(new NamesQueryFilter("key1", new QueryPath("Super3",
"SC1".getBytes()), Util.getBytes(1)), Integer.MAX_VALUE));
+        assertNotNull(store.getColumnFamily(new NamesQueryFilter("key1", new QueryPath("Super3",
"SC1".getBytes()), Util.getBytes(2)), Integer.MAX_VALUE));
+    }
+
     private void validateRemoveTwoSources() throws IOException
     {
         ColumnFamilyStore store = Table.open("Keyspace1").getColumnFamilyStore("Super1");
@@ -70,6 +103,8 @@
         assert resolved.getSortedColumns().iterator().next().getMarkedForDeleteAt() == 1;
         assert resolved.getSortedColumns().iterator().next().getSubColumns().size() == 0;
         assertNull(ColumnFamilyStore.removeDeleted(resolved, Integer.MAX_VALUE));
+        assertNull(store.getColumnFamily(new NamesQueryFilter("key1", new QueryPath("Super1"),
"SC1".getBytes()), Integer.MAX_VALUE));
+        assertNull(store.getColumnFamily(new IdentityQueryFilter("key1", new QueryPath("Super1")),
Integer.MAX_VALUE));
         assertNull(ColumnFamilyStore.removeDeleted(store.getColumnFamily(new IdentityQueryFilter("key1",
new QueryPath("Super1"))), Integer.MAX_VALUE));
     }
 



Mime
View raw message