Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

test and fix for CF clone bug during remove. patch by Jun Rao; review…

…ed by jbellis for #33
  • Loading branch information...
commit c646fcf5d2aea73a130bfb65acbad9eca87b9f67 1 parent d0ad5f6
Jonathan Ellis authored
View
4 src/org/apache/cassandra/db/Memtable.java
@@ -315,7 +315,7 @@ ColumnFamily getLocalCopy(String key, String columnFamilyColumn, IFilter filter)
IColumn column = cFamily.getColumn(values[1]); // super or normal column
if (column != null )
{
- columnFamily = new ColumnFamily(cfName_, cFamily.type());
+ columnFamily = cFamily.cloneMeShallow();
columnFamily.addColumn(column);
}
}
@@ -328,7 +328,7 @@ ColumnFamily getLocalCopy(String key, String columnFamilyColumn, IFilter filter)
IColumn subColumn = superColumn.getSubColumn(values[2]);
if (subColumn != null)
{
- columnFamily = new ColumnFamily(cfName_, cFamily.type());
+ columnFamily = cFamily.cloneMeShallow();
columnFamily.addColumn(values[1] + ":" + values[2], subColumn.value(), subColumn.timestamp(), subColumn.isMarkedForDelete());
}
}
View
48 test/org/apache/cassandra/db/ColumnFamilyStoreTest.java
@@ -275,6 +275,29 @@ public void testRemoveColumnFamily() throws IOException, ColumnFamilyNotDefinedE
// add data
rm = new RowMutation("Table1", "key1");
rm.add("Standard1:Column1", "asdf".getBytes(), 0);
+ rm.apply();
+
+ // remove
+ rm = new RowMutation("Table1", "key1");
+ rm.delete("Standard1", 1);
+ rm.apply();
+
+ ColumnFamily retrieved = store.getColumnFamily("key1", "Standard1:Column1", new IdentityFilter());
+ assert retrieved.isMarkedForDelete();
+ assertNull(retrieved.getColumn("Column1"));
+ assertNull(ColumnFamilyStore.removeDeleted(retrieved, Integer.MAX_VALUE));
+ }
+
+ @Test
+ public void testRemoveColumnFamilyWithFlush1() throws IOException, ColumnFamilyNotDefinedException, ExecutionException, InterruptedException
+ {
+ Table table = Table.open("Table1");
+ ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
+ RowMutation rm;
+
+ // add data
+ rm = new RowMutation("Table1", "key1");
+ rm.add("Standard1:Column1", "asdf".getBytes(), 0);
rm.add("Standard1:Column2", "asdf".getBytes(), 0);
rm.apply();
store.forceBlockingFlush();
@@ -286,7 +309,30 @@ public void testRemoveColumnFamily() throws IOException, ColumnFamilyNotDefinedE
ColumnFamily retrieved = store.getColumnFamily("key1", "Standard1", new IdentityFilter());
assert retrieved.isMarkedForDelete();
- assertEquals(retrieved.getColumnCount(), 0);
+ assertNull(retrieved.getColumn("Column1"));
+ assertNull(ColumnFamilyStore.removeDeleted(retrieved, Integer.MAX_VALUE));
+ }
+
+ @Test
+ public void testRemoveColumnFamilyWithFlush2() throws IOException, ColumnFamilyNotDefinedException, ExecutionException, InterruptedException
+ {
+ Table table = Table.open("Table1");
+ ColumnFamilyStore store = table.getColumnFamilyStore("Standard1");
+ RowMutation rm;
+
+ // add data
+ rm = new RowMutation("Table1", "key1");
+ rm.add("Standard1:Column1", "asdf".getBytes(), 0);
+ rm.apply();
+ // remove
+ rm = new RowMutation("Table1", "key1");
+ rm.delete("Standard1", 1);
+ rm.apply();
+ store.forceBlockingFlush();
+
+ ColumnFamily retrieved = store.getColumnFamily("key1", "Standard1:Column1", new IdentityFilter());
+ assert retrieved.isMarkedForDelete();
+ assertNull(retrieved.getColumn("Column1"));
assertNull(ColumnFamilyStore.removeDeleted(retrieved, Integer.MAX_VALUE));
}
Please sign in to comment.
Something went wrong with that request. Please try again.