cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r964290 - in /cassandra/trunk/src/java/org/apache/cassandra/io/sstable: Descriptor.java SSTableReader.java SSTableWriter.java
Date Thu, 15 Jul 2010 03:02:58 GMT
Author: jbellis
Date: Thu Jul 15 03:02:57 2010
New Revision: 964290

URL: http://svn.apache.org/viewvc?rev=964290&view=rev
Log:
Calculate feature flags on Descriptor creation
patch by Stu Hood; reviewed by jbellis for CASSANDRA-1249

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Descriptor.java
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Descriptor.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Descriptor.java?rev=964290&r1=964289&r2=964290&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Descriptor.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/Descriptor.java Thu Jul 15 03:02:57
2010
@@ -25,6 +25,11 @@ public class Descriptor
     public final boolean temporary;
     private final int hashCode;
 
+    public final boolean hasStringsInBloomFilter;
+    public final boolean hasIntRowSize;
+    public final boolean hasEncodedKeys;
+    public final boolean isLatestVersion;
+
     /**
      * A descriptor that assumes CURRENT_VERSION.
      */
@@ -43,6 +48,11 @@ public class Descriptor
         this.generation = generation;
         temporary = temp;
         hashCode = Objects.hashCode(directory, generation, ksname, cfname);
+
+        hasStringsInBloomFilter = version.compareTo("c") < 0;
+        hasIntRowSize = version.compareTo("d") < 0;
+        hasEncodedKeys = version.compareTo("e") < 0;
+        isLatestVersion = version.compareTo(CURRENT_VERSION) == 0;
     }
 
     /**
@@ -149,24 +159,4 @@ public class Descriptor
     {
         return hashCode;
     }
-
-    public boolean hasStringsInBloomFilter()
-    {
-        return version.compareTo("c") < 0;
-    }
-
-    public boolean hasIntRowSize()
-    {
-        return version.compareTo("d") < 0;
-    }
-
-    public boolean hasEncodedKeys()
-    {
-        return version.compareTo("e") < 0;
-    }
-
-    public boolean isLatestVersion()
-    {
-        return version.compareTo(CURRENT_VERSION) == 0;
-    }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java?rev=964290&r1=964289&r2=964290&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableReader.java Thu Jul 15
03:02:57 2010
@@ -182,7 +182,7 @@ public class SSTableReader extends SSTab
         SSTableReader sstable = new SSTableReader(desc, partitioner, null, null, null, null,
System.currentTimeMillis());
 
         // versions before 'c' encoded keys as utf-16 before hashing to the filter
-        if (desc.hasStringsInBloomFilter())
+        if (desc.hasStringsInBloomFilter)
         {
             sstable.load(true);
         }
@@ -551,7 +551,7 @@ public class SSTableReader extends SSTab
 
     public static long readRowSize(DataInput in, Descriptor d) throws IOException
     {
-        if (d.hasIntRowSize())
+        if (d.hasIntRowSize)
             return in.readInt();
         return in.readLong();
     }
@@ -561,7 +561,7 @@ public class SSTableReader extends SSTab
      */
     public static DecoratedKey decodeKey(IPartitioner p, Descriptor d, byte[] bytes)
     {
-        if (d.hasEncodedKeys())
+        if (d.hasEncodedKeys)
             return p.convertFromDiskFormat(bytes);
         return p.decorateKey(bytes);
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java?rev=964290&r1=964289&r2=964290&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableWriter.java Thu Jul 15
03:02:57 2010
@@ -267,7 +267,9 @@ public class SSTableWriter extends SSTab
      */
     public static SSTableReader recoverAndOpen(Descriptor desc) throws IOException
     {
-        if (!desc.isLatestVersion())
+        if (!desc.isLatestVersion)
+            // TODO: streaming between different versions will fail: need support for
+            // recovering other versions to provide a stable streaming api
             throw new RuntimeException(String.format("Cannot recover SSTable with version
%s (current version %s).",
                                                      desc.version, Descriptor.CURRENT_VERSION));
 



Mime
View raw message