You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2012/07/10 19:07:02 UTC
[3/6] git commit: merge from 1.0
merge from 1.0
Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/485c8789
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/485c8789
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/485c8789
Branch: refs/heads/trunk
Commit: 485c878983ad6e218553544456e48b91d623c1c4
Parents: c716fc7 84a1d60
Author: Jonathan Ellis <jb...@apache.org>
Authored: Tue Jul 10 08:37:19 2012 -0500
Committer: Jonathan Ellis <jb...@apache.org>
Committed: Tue Jul 10 08:37:19 2012 -0500
----------------------------------------------------------------------
.../cassandra/db/AbstractColumnContainer.java | 3 +-
.../cassandra/db/compaction/CompactionsTest.java | 39 +++++++++++++++
2 files changed, 41 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cassandra/blob/485c8789/src/java/org/apache/cassandra/db/AbstractColumnContainer.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/db/AbstractColumnContainer.java
index c35c63c,439c5e4..aece78a
--- a/src/java/org/apache/cassandra/db/AbstractColumnContainer.java
+++ b/src/java/org/apache/cassandra/db/AbstractColumnContainer.java
@@@ -199,11 -253,12 +199,12 @@@ public abstract class AbstractColumnCon
public boolean hasIrrelevantData(int gcBefore)
{
- if (isMarkedForDelete() && getLocalDeletionTime() < gcBefore)
+ if (getLocalDeletionTime() < gcBefore)
return true;
+ long deletedAt = getMarkedForDeleteAt();
for (IColumn column : columns)
- if (column.mostRecentLiveChangeAt() < getLocalDeletionTime() || column.hasIrrelevantData(gcBefore))
+ if (column.mostRecentLiveChangeAt() <= deletedAt || column.hasIrrelevantData(gcBefore))
return true;
return false;
http://git-wip-us.apache.org/repos/asf/cassandra/blob/485c8789/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
----------------------------------------------------------------------
diff --cc test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
index 4f87c86,46c0054..6339224
--- a/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
+++ b/test/unit/org/apache/cassandra/db/compaction/CompactionsTest.java
@@@ -131,23 -118,60 +133,60 @@@ public class CompactionsTest extends Sc
rm.apply();
inserted.add(key);
}
- store.forceBlockingFlush();
- assertMaxTimestamp(store, maxTimestampExpected);
- assertEquals(inserted.toString(), inserted.size(), Util.getRangeSlice(store, superColumn).size());
+ cfs.forceBlockingFlush();
+ assertMaxTimestamp(cfs, maxTimestampExpected);
+ assertEquals(inserted.toString(), inserted.size(), Util.getRangeSlice(cfs, superColumn).size());
}
- forceCompactions(store);
+ forceCompactions(cfs);
- assertEquals(inserted.size(), Util.getRangeSlice(store, superColumn).size());
+ assertEquals(inserted.size(), Util.getRangeSlice(cfs, superColumn).size());
// make sure max timestamp of compacted sstables is recorded properly after compaction.
- assertMaxTimestamp(store, maxTimestampExpected);
+ assertMaxTimestamp(cfs, maxTimestampExpected);
}
+ @Test
+ public void testSuperColumnTombstones() throws IOException, ExecutionException, InterruptedException
+ {
+ Table table = Table.open(TABLE1);
+ ColumnFamilyStore cfs = table.getColumnFamilyStore("Super1");
+ cfs.disableAutoCompaction();
+
+ DecoratedKey key = Util.dk("tskey");
+ ByteBuffer scName = ByteBufferUtil.bytes("TestSuperColumn");
+
+ // a subcolumn
+ RowMutation rm = new RowMutation(TABLE1, key.key);
+ rm.add(new QueryPath("Super1", scName, ByteBufferUtil.bytes(0)),
+ ByteBufferUtil.EMPTY_BYTE_BUFFER,
+ FBUtilities.timestampMicros());
+ rm.apply();
+ cfs.forceBlockingFlush();
+
+ // shadow the subcolumn with a supercolumn tombstone
+ rm = new RowMutation(TABLE1, key.key);
+ rm.delete(new QueryPath("Super1", scName), FBUtilities.timestampMicros());
+ rm.apply();
+ cfs.forceBlockingFlush();
+
+ CompactionManager.instance.performMaximal(cfs);
+ assertEquals(1, cfs.getSSTables().size());
+
+ // check that the shadowed column is gone
+ SSTableReader sstable = cfs.getSSTables().iterator().next();
+ SSTableScanner scanner = sstable.getScanner(new QueryFilter(null, new QueryPath("Super1", scName), new IdentityQueryFilter()));
+ scanner.seekTo(key);
+ IColumnIterator iter = scanner.next();
+ assertEquals(key, iter.getKey());
+ SuperColumn sc = (SuperColumn) iter.next();
+ assert sc.getSubColumns().isEmpty();
+ }
+
- public void assertMaxTimestamp(ColumnFamilyStore store, long maxTimestampExpected)
+ public void assertMaxTimestamp(ColumnFamilyStore cfs, long maxTimestampExpected)
{
long maxTimestampObserved = Long.MIN_VALUE;
- for (SSTableReader sstable : store.getSSTables())
+ for (SSTableReader sstable : cfs.getSSTables())
maxTimestampObserved = Math.max(sstable.getMaxTimestamp(), maxTimestampObserved);
assertEquals(maxTimestampExpected, maxTimestampObserved);
}