cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [4/10] git commit: ignore maxtimestamp unless it includes row tombstones correctly patch by jbellis; reviewed by yukim for CASSANDRA-4205
Date Thu, 03 May 2012 23:35:44 GMT
ignore maxtimestamp unless it includes row tombstones correctly
patch by jbellis; reviewed by yukim for CASSANDRA-4205


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

Branch: refs/heads/trunk
Commit: c1148cec0d24532b213dd3e3c2f50d0cce4ca964
Parents: abb39c2
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Wed May 2 12:06:03 2012 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Thu May 3 18:04:53 2012 -0500

----------------------------------------------------------------------
 .../apache/cassandra/io/sstable/Descriptor.java    |   15 +++++++++++++--
 .../cassandra/io/sstable/SSTableMetadata.java      |    4 +++-
 2 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/c1148cec/src/java/org/apache/cassandra/io/sstable/Descriptor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/Descriptor.java b/src/java/org/apache/cassandra/io/sstable/Descriptor.java
index 67fe8ad..10c56c9 100644
--- a/src/java/org/apache/cassandra/io/sstable/Descriptor.java
+++ b/src/java/org/apache/cassandra/io/sstable/Descriptor.java
@@ -58,7 +58,8 @@ public class Descriptor
     // h (1.0): tracks max client timestamp in metadata component
     // hb (1.0.3): records compression ration in metadata component
     // hc (1.0.4): records partitioner in metadata component
-    public static final String CURRENT_VERSION = "hc";
+    // hd (1.0.10): includes row tombstones in maxtimestamp
+    public static final String CURRENT_VERSION = "hd";
 
     public final File directory;
     /** version has the following format: <code>[a-z]+</code> */
@@ -103,7 +104,7 @@ public class Descriptor
         hasEncodedKeys = version.compareTo("e") < 0;
         usesOldBloomFilter = version.compareTo("f") < 0;
         metadataIncludesReplayPosition = version.compareTo("g") >= 0;
-        tracksMaxTimestamp = version.compareTo("h") >= 0;
+        tracksMaxTimestamp = version.compareTo("hd") >= 0;
         hasCompressionRatio = version.compareTo("hb") >= 0;
         hasPartitioner = version.compareTo("hc") >= 0;
         isLatestVersion = version.compareTo(CURRENT_VERSION) == 0;
@@ -272,6 +273,16 @@ public class Descriptor
         return isCompatible() && version.charAt(0) >= 'f';
     }
 
+    /**
+     * Versions [h..hc] contained a timestamp value that was computed incorrectly, ignoring
row tombstones.
+     * containsTimestamp returns true if there is a timestamp value in the metadata file;
to know if it
+     * actually contains a *correct* timestamp, see tracksMaxTimestamp.
+     */
+    public boolean containsTimestamp()
+    {
+        return version.compareTo("h") >= 0;
+    }
+
     @Override
     public String toString()
     {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/c1148cec/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java b/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java
index 4e52993..c141606 100644
--- a/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java
+++ b/src/java/org/apache/cassandra/io/sstable/SSTableMetadata.java
@@ -206,7 +206,9 @@ public class SSTableMetadata
             ReplayPosition replayPosition = desc.metadataIncludesReplayPosition
                                           ? ReplayPosition.serializer.deserialize(dis)
                                           : ReplayPosition.NONE;
-            long maxTimestamp = desc.tracksMaxTimestamp ? dis.readLong() : Long.MIN_VALUE;
+            long maxTimestamp = desc.containsTimestamp() ? dis.readLong() : Long.MIN_VALUE;
+            if (!desc.tracksMaxTimestamp) // see javadoc to Descriptor.containsTimestamp
+                maxTimestamp = Long.MIN_VALUE;
             double compressionRatio = desc.hasCompressionRatio
                                     ? dis.readDouble()
                                     : Double.MIN_VALUE;


Mime
View raw message