fix maxTimestamp to include row tombstones
patch by Sam Tunnicliffe and jbellis for CASSANDRA-4116


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

Branch: refs/heads/cassandra-1.1
Commit: 48a22695f471f7477bc015db8113d777a36406c1
Parents: 2b7672f
Author: Jonathan Ellis <jbel...@apache.org>
Authored: Wed May 2 09:51:52 2012 -0500
Committer: Jonathan Ellis <jbel...@apache.org>
Committed: Wed May 2 09:52:10 2012 -0500

----------------------------------------------------------------------
 CHANGES.txt                                        |    1 +
 src/java/org/apache/cassandra/db/ColumnFamily.java |    2 +-
 .../cassandra/io/sstable/SSTableWriterTest.java    |   56 +++++++++++++++
 3 files changed, 58 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/48a22695/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 5b58681..bd508c6 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 1.0.10
+ * fix maxTimestamp to include row tombstones (CASSANDRA-4116)
  * avoid streaming empty files with bulk loader if sstablewriter errors out
    (CASSANDRA-3946)
  * support PropertyFileSnitch in bulk loader (CASSANDRA-4145)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48a22695/src/java/org/apache/cassandra/db/ColumnFamily.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/db/ColumnFamily.java 
b/src/java/org/apache/cassandra/db/ColumnFamily.java
index 0b1e399..184cef6 100644
--- a/src/java/org/apache/cassandra/db/ColumnFamily.java
+++ b/src/java/org/apache/cassandra/db/ColumnFamily.java
@@ -272,7 +272,7 @@ public class ColumnFamily extends AbstractColumnContainer
 
     public long maxTimestamp()
     {
-        long maxTimestamp = Long.MIN_VALUE;
+        long maxTimestamp = getMarkedForDeleteAt();
         for (IColumn column : columns)
             maxTimestamp = Math.max(maxTimestamp, column.maxTimestamp());
         return maxTimestamp;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/48a22695/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java
----------------------------------------------------------------------
diff --git a/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java 
b/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java
new file mode 100644
index 0000000..0754ec5
--- /dev/null
+++ b/test/unit/org/apache/cassandra/io/sstable/SSTableWriterTest.java
@@ -0,0 +1,56 @@
+package org.apache.cassandra.io.sstable;
+/*
+ * 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ * 
+ */
+
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.concurrent.ExecutionException;
+
+import org.apache.cassandra.CleanupHelper;
+import org.apache.cassandra.db.ColumnFamilyStore;
+import org.apache.cassandra.db.RowMutation;
+import org.apache.cassandra.db.Table;
+import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.utils.ByteBufferUtil;
+import org.junit.Test;
+
+public class SSTableWriterTest extends CleanupHelper
+{
+    @Test
+    public void testRowDeleteTimestampRecordedCorrectly() throws IOException, 
ExecutionException, InterruptedException
+    {
+        Table table = Table.open("Keyspace1");
+        ColumnFamilyStore store = table.getColumnFamilyStore("Standard2");
+        ByteBuffer key = ByteBufferUtil.bytes(String.valueOf("key1"));
+        
+        RowMutation rm = new RowMutation("Keyspace1", key);
+        rm.delete(new QueryPath("Standard2"), 0);
+        rm.apply();
+
+        store.forceBlockingFlush();
+        
+        SSTableReader sstable = store.getSSTables().iterator().next();
+        assertEquals(0, sstable.getMaxTimestamp());
+    }
+}

Reply via email to