cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r803284 - in /incubator/cassandra/trunk/src/java/org/apache/cassandra: db/ db/filter/ io/
Date Tue, 11 Aug 2009 20:34:21 GMT
Author: jbellis
Date: Tue Aug 11 20:34:21 2009
New Revision: 803284

URL: http://svn.apache.org/viewvc?rev=803284&view=rev
Log:
Move CFSerializer into its own file.  Rename deserializeEmpty to deserializeFromSSTableNoColumns;
add serializeForSSTable and serializeWithIndexes to do the without-metadata serialization.
 Add SSTableReader.makeColumnFamily to create the CF skeleton w/o reading any data.
patch by jbellis; reviewed by Sandeep Tata for CASSANDRA-233

Added:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilySerializer.java
Removed:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CompactSerializerInvocationHandler.java
Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnIndexer.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/FileStruct.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IteratingRow.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTableReader.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java?rev=803284&r1=803283&r2=803284&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamily.java Tue Aug 11
20:34:21 2009
@@ -18,8 +18,6 @@
 
 package org.apache.cassandra.db;
 
-import java.io.*;
-import java.lang.reflect.Proxy;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
@@ -34,13 +32,10 @@
 
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.utils.FBUtilities;
-import org.apache.cassandra.io.ICompactSerializer;
 import org.apache.cassandra.io.ICompactSerializer2;
-import org.apache.cassandra.io.BufferedRandomAccessFile;
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.db.marshal.AbstractType;
 import org.apache.cassandra.db.marshal.MarshalException;
-import org.apache.cassandra.db.marshal.LongType;
 
 
 public final class ColumnFamily implements IColumnContainer
@@ -51,7 +46,7 @@
 
     private static Logger logger_ = Logger.getLogger( ColumnFamily.class );
     private static Map<String, String> columnTypes_ = new HashMap<String, String>();
-    private String type_;
+    String type_;
     private String table_;
 
     static
@@ -66,15 +61,6 @@
         return serializer_;
     }
 
-    /*
-     * This method returns the serializer whose methods are
-     * preprocessed by a dynamic proxy.
-    */
-    public static ICompactSerializer2<ColumnFamily> serializerWithIndexes()
-    {
-        return (ICompactSerializer2<ColumnFamily>)Proxy.newProxyInstance( ColumnFamily.class.getClassLoader(),
new Class[]{ICompactSerializer2.class}, new CompactSerializerInvocationHandler<ColumnFamily>(serializer_)
);
-    }
-
     public static String getColumnType(String key)
     {
     	if ( key == null )
@@ -93,8 +79,8 @@
     private String name_;
 
     private transient ICompactSerializer2<IColumn> columnSerializer_;
-    private long markedForDeleteAt = Long.MIN_VALUE;
-    private int localDeletionTime = Integer.MIN_VALUE;
+    long markedForDeleteAt = Long.MIN_VALUE;
+    int localDeletionTime = Integer.MIN_VALUE;
     private AtomicInteger size_ = new AtomicInteger(0);
     private ConcurrentSkipListMap<byte[], IColumn> columns_;
 
@@ -409,12 +395,12 @@
         return type_;
     }
 
-    private String getComparatorName()
+    String getComparatorName()
     {
         return getComparator().getClass().getCanonicalName();
     }
 
-    private String getSubComparatorName()
+    String getSubComparatorName()
     {
         AbstractType subcolumnComparator = getSubComparator();
         return subcolumnComparator == null ? "" : subcolumnComparator.getClass().getCanonicalName();
@@ -450,95 +436,4 @@
         }
         return cf;
     }
-
-    public static class ColumnFamilySerializer implements ICompactSerializer2<ColumnFamily>
-    {
-        /*
-         * We are going to create indexes, and write out that information as well. The format
-         * of the data serialized is as follows.
-         *
-         * 1) Without indexes:
-         *  // written by the data
-         * 	<boolean false (index is not present)>
-         * 	<column family id>
-         * 	<is marked for delete>
-         * 	<total number of columns>
-         * 	<columns data>
-
-         * 	<boolean true (index is present)>
-         *
-         *  This part is written by the column indexer
-         * 	<size of index in bytes>
-         * 	<list of column names and their offsets relative to the first column>
-         *
-         *  <size of the cf in bytes>
-         * 	<column family id>
-         * 	<is marked for delete>
-         * 	<total number of columns>
-         * 	<columns data>
-        */
-        public void serialize(ColumnFamily columnFamily, DataOutput dos) throws IOException
-        {
-            Collection<IColumn> columns = columnFamily.getSortedColumns();
-
-            dos.writeUTF(columnFamily.name());
-            dos.writeUTF(columnFamily.type_);
-            dos.writeUTF(columnFamily.getComparatorName());
-            dos.writeUTF(columnFamily.getSubComparatorName());
-            dos.writeInt(columnFamily.localDeletionTime);
-            dos.writeLong(columnFamily.markedForDeleteAt);
-
-            dos.writeInt(columns.size());
-            for ( IColumn column : columns )
-            {
-                columnFamily.getColumnSerializer().serialize(column, dos);
-            }
-        }
-
-        public ColumnFamily deserialize(DataInput dis) throws IOException
-        {
-            ColumnFamily cf = deserializeEmpty(dis);
-            int size = dis.readInt();
-            IColumn column;
-            for (int i = 0; i < size; ++i)
-            {
-                column = cf.getColumnSerializer().deserialize(dis);
-                cf.addColumn(column);
-            }
-            return cf;
-        }
-
-        private AbstractType readComparator(DataInput dis) throws IOException
-        {
-            String className = dis.readUTF();
-            if (className.equals(""))
-            {
-                return null;
-            }
-
-            try
-            {
-                return (AbstractType)Class.forName(className).getConstructor().newInstance();
-            }
-            catch (ClassNotFoundException e)
-            {
-                throw new RuntimeException("Unable to load comparator class '" + className
+ "'.  probably this means you have obsolete sstables lying around", e);
-            }
-            catch (Exception e)
-            {
-                throw new RuntimeException(e);
-            }
-        }
-
-        public ColumnFamily deserializeEmpty(DataInput input) throws IOException
-        {
-            ColumnFamily cf = new ColumnFamily(input.readUTF(),
-                                               input.readUTF(),
-                                               readComparator(input),
-                                               readComparator(input));
-            cf.delete(input.readInt(), input.readLong());
-            return cf;
-        }
-    }
 }
-

Added: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilySerializer.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilySerializer.java?rev=803284&view=auto
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilySerializer.java
(added)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilySerializer.java
Tue Aug 11 20:34:21 2009
@@ -0,0 +1,106 @@
+package org.apache.cassandra.db;
+
+import java.io.DataOutput;
+import java.io.IOException;
+import java.io.DataInput;
+import java.util.Collection;
+
+import org.apache.cassandra.io.ICompactSerializer2;
+import org.apache.cassandra.db.marshal.AbstractType;
+
+public class ColumnFamilySerializer implements ICompactSerializer2<ColumnFamily>
+{
+    /*
+     * Serialized ColumnFamily format:
+     *
+     * [serialized for intra-node writes only, e.g. returning a query result]
+     * <cf name>
+     * <cf type [super or standard]>
+     * <cf comparator name>
+     * <cf subcolumn comparator name>
+     *
+     * [in sstable only]
+     * <column bloom filter>
+     * <sparse column index, start/finish columns every ColumnIndexSizeInKB of data>
+     *
+     * [always present]
+     * <local deletion time>
+     * <client-provided deletion time>
+     * <column count>
+     * <columns, serialized individually>
+    */
+    public void serialize(ColumnFamily columnFamily, DataOutput dos) throws IOException
+    {
+        dos.writeUTF(columnFamily.name());
+        dos.writeUTF(columnFamily.type_);
+        dos.writeUTF(columnFamily.getComparatorName());
+        dos.writeUTF(columnFamily.getSubComparatorName());
+        serializeForSSTable(columnFamily, dos);
+    }
+
+    public void serializeForSSTable(ColumnFamily columnFamily, DataOutput dos) throws IOException
+    {
+        dos.writeInt(columnFamily.localDeletionTime);
+        dos.writeLong(columnFamily.markedForDeleteAt);
+
+        Collection<IColumn> columns = columnFamily.getSortedColumns();
+        dos.writeInt(columns.size());
+        for ( IColumn column : columns )
+        {
+            columnFamily.getColumnSerializer().serialize(column, dos);
+        }
+    }
+
+    public void serializeWithIndexes(ColumnFamily columnFamily, DataOutput dos) throws IOException
+    {
+        ColumnIndexer.serialize(columnFamily, dos);
+        serializeForSSTable(columnFamily, dos);
+    }
+
+    public ColumnFamily deserialize(DataInput dis) throws IOException
+    {
+        ColumnFamily cf = deserializeFromSSTableNoColumns(dis.readUTF(), dis.readUTF(), readComparator(dis),
readComparator(dis), dis);
+        int size = dis.readInt();
+        IColumn column;
+        for (int i = 0; i < size; ++i)
+        {
+            column = cf.getColumnSerializer().deserialize(dis);
+            cf.addColumn(column);
+        }
+        return cf;
+    }
+
+    private AbstractType readComparator(DataInput dis) throws IOException
+    {
+        String className = dis.readUTF();
+        if (className.equals(""))
+        {
+            return null;
+        }
+
+        try
+        {
+            return (AbstractType)Class.forName(className).getConstructor().newInstance();
+        }
+        catch (ClassNotFoundException e)
+        {
+            throw new RuntimeException("Unable to load comparator class '" + className +
"'.  probably this means you have obsolete sstables lying around", e);
+        }
+        catch (Exception e)
+        {
+            throw new RuntimeException(e);
+        }
+    }
+
+    public ColumnFamily deserializeFromSSTableNoColumns(String name, String type, AbstractType
comparator, AbstractType subComparator, DataInput input) throws IOException
+    {
+        ColumnFamily cf = new ColumnFamily(name, type, comparator, subComparator);
+        return deserializeFromSSTableNoColumns(cf, input);
+    }
+
+    public ColumnFamily deserializeFromSSTableNoColumns(ColumnFamily cf, DataInput input)
throws IOException
+    {
+        cf.delete(input.readInt(), input.readLong());
+        return cf;
+    }
+}

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=803284&r1=803283&r2=803284&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Tue
Aug 11 20:34:21 2009
@@ -969,14 +969,14 @@
                     columnFamilies.clear();
                     if (columnFamily != null)
                     {
-                        ColumnFamily.serializerWithIndexes().serialize(columnFamily, bufOut);
+                        ColumnFamily.serializer().serializeWithIndexes(columnFamily, bufOut);
                     }
                 }
                 else
                 {
                     // TODO deserializing only to reserialize is dumb
                     FileStruct filestruct = lfs.get(0);
-                    ColumnFamily.serializerWithIndexes().serialize(filestruct.getColumnFamily(),
bufOut);
+                    ColumnFamily.serializer().serializeWithIndexes(filestruct.getColumnFamily(),
bufOut);
                 }
                 if (Range.isTokenInRanges(StorageService.getPartitioner().getInitialToken(lastkey),
ranges))
                 {
@@ -1139,14 +1139,14 @@
                     columnFamilies.clear();
                     if (columnFamily != null)
                     {
-                        ColumnFamily.serializerWithIndexes().serialize(columnFamily, bufOut);
+                        ColumnFamily.serializer().serializeWithIndexes(columnFamily, bufOut);
                     }
                 }
                 else
                 {
                     // TODO deserializing only to reserialize is dumb
                     FileStruct filestruct = lfs.get(0);
-                    ColumnFamily.serializerWithIndexes().serialize(filestruct.getColumnFamily(),
bufOut);
+                    ColumnFamily.serializer().serializeWithIndexes(filestruct.getColumnFamily(),
bufOut);
                 }
 
                 if (writer == null)
@@ -1441,7 +1441,7 @@
             List<SSTableReader> sstables = new ArrayList<SSTableReader>(ssTables_.values());
             for (SSTableReader sstable : sstables)
             {
-                iter = filter.getSSTableColumnIterator(sstable, getComparator());
+                iter = filter.getSSTableColumnIterator(sstable);
                 if (iter.hasNext()) // initializes iter.CF
                 {
                     returnCF.delete(iter.getColumnFamily());

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnIndexer.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnIndexer.java?rev=803284&r1=803283&r2=803284&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnIndexer.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnIndexer.java Tue Aug
11 20:34:21 2009
@@ -20,6 +20,7 @@
 
 import java.io.DataOutputStream;
 import java.io.IOException;
+import java.io.DataOutput;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.List;
@@ -45,7 +46,7 @@
 	 * @param dos data output stream
 	 * @throws IOException
 	 */
-    public static void serialize(ColumnFamily columnFamily, DataOutputStream dos) throws
IOException
+    public static void serialize(ColumnFamily columnFamily, DataOutput dos) throws IOException
 	{
         Collection<IColumn> columns = columnFamily.getSortedColumns();
         BloomFilter bf = createColumnBloomFilter(columns);                    
@@ -101,7 +102,7 @@
      *            to be written.
      * @throws IOException
      */
-    private static void doIndexing(AbstractType comparator, Collection<IColumn> columns,
DataOutputStream dos) throws IOException
+    private static void doIndexing(AbstractType comparator, Collection<IColumn> columns,
DataOutput dos) throws IOException
     {
         assert !columns.isEmpty();
 

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java?rev=803284&r1=803283&r2=803284&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java Tue Aug 11 20:34:21
2009
@@ -208,10 +208,10 @@
         {
             buffer.reset();
             ColumnFamily columnFamily = columnFamilies_.get(key);
-            if ( columnFamily != null )
+            if (columnFamily != null)
             {
                 /* serialize the cf with column indexes */
-                ColumnFamily.serializerWithIndexes().serialize( columnFamily, buffer );
+                ColumnFamily.serializer().serializeWithIndexes(columnFamily, buffer);
                 /* Now write the key and value to disk */
                 writer.append(partitioner.decorateKey(key), buffer);
             }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java?rev=803284&r1=803283&r2=803284&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
Tue Aug 11 20:34:21 2009
@@ -7,6 +7,7 @@
 import org.apache.cassandra.utils.ReducingIterator;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.marshal.AbstractType;
+import org.apache.cassandra.config.DatabaseDescriptor;
 
 public class NamesQueryFilter extends QueryFilter
 {
@@ -42,9 +43,9 @@
         return memtable.getNamesIterator(this);
     }
 
-    public ColumnIterator getSSTableColumnIterator(SSTableReader sstable, AbstractType comparator)
throws IOException
+    public ColumnIterator getSSTableColumnIterator(SSTableReader sstable) throws IOException
     {
-        return new SSTableNamesIterator(sstable.getFilename(), key, getColumnFamilyName(),
columns);
+        return new SSTableNamesIterator(sstable, key, columns);
     }
 
     public SuperColumn filterSuperColumn(SuperColumn superColumn, int gcBefore)

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java?rev=803284&r1=803283&r2=803284&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java Tue
Aug 11 20:34:21 2009
@@ -31,7 +31,7 @@
      * returns an iterator that returns columns from the given SSTable
      * matching the Filter criteria in sorted order.
      */
-    public abstract ColumnIterator getSSTableColumnIterator(SSTableReader sstable, AbstractType
comparator) throws IOException;
+    public abstract ColumnIterator getSSTableColumnIterator(SSTableReader sstable) throws
IOException;
 
     /**
      * collects columns from reducedColumns into returnCF.  Termination is determined

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java?rev=803284&r1=803283&r2=803284&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java
Tue Aug 11 20:34:21 2009
@@ -16,18 +16,17 @@
     private Iterator<IColumn> iter;
     public final SortedSet<byte[]> columns;
 
-    public SSTableNamesIterator(String filename, String key, String cfName, SortedSet<byte[]>
columnNames) throws IOException
+    public SSTableNamesIterator(SSTableReader ssTable, String key, SortedSet<byte[]>
columnNames) throws IOException
     {
         assert columnNames != null;
         this.columns = columnNames;
-        SSTableReader ssTable = SSTableReader.open(filename);
 
         String decoratedKey = ssTable.getPartitioner().decorateKey(key);
         long position = ssTable.getPosition(decoratedKey);
         if (position < 0)
             return;
 
-        BufferedRandomAccessFile file = new BufferedRandomAccessFile(filename, "r", DatabaseDescriptor.getIndexedReadBufferSizeInKB()
* 1024);
+        BufferedRandomAccessFile file = new BufferedRandomAccessFile(ssTable.getFilename(),
"r", DatabaseDescriptor.getIndexedReadBufferSizeInKB() * 1024);
         try
         {
             file.seek(position);
@@ -53,11 +52,11 @@
 
             List<IndexHelper.IndexInfo> indexList = IndexHelper.deserializeIndex(file);
 
-            cf = ColumnFamily.serializer().deserializeEmpty(file);
+            cf = ColumnFamily.serializer().deserializeFromSSTableNoColumns(ssTable.makeColumnFamily(),
file);
             file.readInt(); // column count
 
             /* get the various column ranges we have to read */
-            AbstractType comparator = DatabaseDescriptor.getComparator(SSTable.parseTableName(filename),
cfName);
+            AbstractType comparator = ssTable.getColumnComparator();
             SortedSet<IndexHelper.IndexInfo> ranges = new TreeSet<IndexHelper.IndexInfo>(IndexHelper.getComparator(comparator));
             for (byte[] name : filteredColumnNames)
             {

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java?rev=803284&r1=803283&r2=803284&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
Tue Aug 11 20:34:21 2009
@@ -20,20 +20,19 @@
     private final AbstractType comparator;
     private ColumnGroupReader reader;
 
-    public SSTableSliceIterator(String filename, String key, AbstractType comparator, byte[]
startColumn, boolean reversed)
+    public SSTableSliceIterator(SSTableReader ssTable, String key, byte[] startColumn, boolean
reversed)
     throws IOException
     {
         // TODO push finishColumn down here too, so we can tell when we're done and optimize
away the slice when the index + start/stop shows there's nothing to scan for
         this.reversed = reversed;
-        SSTableReader ssTable = SSTableReader.open(filename);
 
         /* Morph key into actual key based on the partition type. */
         String decoratedKey = ssTable.getPartitioner().decorateKey(key);
         long position = ssTable.getPosition(decoratedKey);
-        this.comparator = comparator;
+        this.comparator = ssTable.getColumnComparator();
         this.startColumn = startColumn;
         if (position >= 0)
-            reader = new ColumnGroupReader(filename, decoratedKey, position);
+            reader = new ColumnGroupReader(ssTable, decoratedKey, position);
     }
 
     private boolean isColumnNeeded(IColumn column)
@@ -85,9 +84,9 @@
         private int curRangeIndex;
         private Deque<IColumn> blockColumns = new ArrayDeque<IColumn>();
 
-        public ColumnGroupReader(String filename, String key, long position) throws IOException
+        public ColumnGroupReader(SSTableReader ssTable, String key, long position) throws
IOException
         {
-            this.file = new BufferedRandomAccessFile(filename, "r", DatabaseDescriptor.getSlicedReadBufferSizeInKB()
* 1024);
+            this.file = new BufferedRandomAccessFile(ssTable.getFilename(), "r", DatabaseDescriptor.getSlicedReadBufferSizeInKB()
* 1024);
 
             file.seek(position);
             String keyInDisk = file.readUTF();
@@ -97,7 +96,7 @@
             IndexHelper.skipBloomFilter(file);
             indexes = IndexHelper.deserializeIndex(file);
 
-            emptyColumnFamily = ColumnFamily.serializer().deserializeEmpty(file);
+            emptyColumnFamily = ColumnFamily.serializer().deserializeFromSSTableNoColumns(ssTable.makeColumnFamily(),
file);
             file.readInt(); // column count
 
             columnStartPosition = file.getFilePointer();

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java?rev=803284&r1=803283&r2=803284&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
Tue Aug 11 20:34:21 2009
@@ -13,6 +13,7 @@
 import org.apache.cassandra.io.SSTableReader;
 import org.apache.cassandra.db.*;
 import org.apache.cassandra.db.marshal.AbstractType;
+import org.apache.cassandra.config.DatabaseDescriptor;
 
 public class SliceQueryFilter extends QueryFilter
 {
@@ -34,9 +35,9 @@
         return memtable.getSliceIterator(this, comparator);
     }
 
-    public ColumnIterator getSSTableColumnIterator(SSTableReader sstable, AbstractType comparator)
throws IOException
+    public ColumnIterator getSSTableColumnIterator(SSTableReader sstable) throws IOException
     {
-        return new SSTableSliceIterator(sstable.getFilename(), key, comparator, start, reversed);
+        return new SSTableSliceIterator(sstable, key, start, reversed);
     }
 
     public SuperColumn filterSuperColumn(SuperColumn superColumn, int gcBefore)

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/FileStruct.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/FileStruct.java?rev=803284&r1=803283&r2=803284&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/FileStruct.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/FileStruct.java Tue Aug 11
20:34:21 2009
@@ -121,7 +121,7 @@
             return;
         }
 
-        row = new IteratingRow(file);
+        row = new IteratingRow(file, sstable);
         if (materialize)
         {
             while (row.hasNext())

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java?rev=803284&r1=803283&r2=803284&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java Tue Aug 11
20:34:21 2009
@@ -159,7 +159,7 @@
             this.width = width;
         }
 
-        public void serialize(DataOutputStream dos) throws IOException
+        public void serialize(DataOutput dos) throws IOException
         {
             ColumnSerializer.writeName(firstName, dos);
             ColumnSerializer.writeName(lastName, dos);

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IteratingRow.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IteratingRow.java?rev=803284&r1=803283&r2=803284&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IteratingRow.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IteratingRow.java Tue Aug 11
20:34:21 2009
@@ -4,6 +4,8 @@
 
 import org.apache.cassandra.db.ColumnFamily;
 import org.apache.cassandra.db.IColumn;
+import org.apache.cassandra.db.marshal.AbstractType;
+import org.apache.cassandra.config.DatabaseDescriptor;
 import com.google.common.collect.AbstractIterator;
 
 public class IteratingRow extends AbstractIterator<IColumn>
@@ -13,7 +15,7 @@
     private final ColumnFamily emptyColumnFamily;
     private final BufferedRandomAccessFile file;
 
-    public IteratingRow(BufferedRandomAccessFile file) throws IOException
+    public IteratingRow(BufferedRandomAccessFile file, SSTableReader sstable) throws IOException
     {
         this.file = file;
 
@@ -22,7 +24,7 @@
         long dataStart = file.getFilePointer();
         finishedAt = dataStart + dataSize;
         IndexHelper.skipBloomFilterAndIndex(file);
-        emptyColumnFamily = ColumnFamily.serializer().deserializeEmpty(file);
+        emptyColumnFamily = ColumnFamily.serializer().deserializeFromSSTableNoColumns(sstable.makeColumnFamily(),
file);
         file.readInt(); // column count. breaking serializer encapsulation is less fugly
than adding a wrapper class to allow deserializeEmpty to return both values
     }
 

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java?rev=803284&r1=803283&r2=803284&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTable.java Tue Aug 11 20:34:21
2009
@@ -7,6 +7,8 @@
 
 import org.apache.cassandra.dht.IPartitioner;
 import org.apache.cassandra.utils.BloomFilter;
+import org.apache.cassandra.db.ColumnFamily;
+import org.apache.cassandra.config.DatabaseDescriptor;
 
 /**
  * This class is built on top of the SequenceFile. It stores
@@ -26,6 +28,7 @@
     protected IPartitioner partitioner;
     protected BloomFilter bf;
     protected List<KeyPosition> indexPositions;
+    protected String columnFamilyName;
 
     /* Every 128th index entry is loaded into memory so we know where to start looking for
the actual key w/o seeking */
     public static final int INDEX_INTERVAL = 128;/* Required extension for temporary files
created during compactions. */
@@ -34,6 +37,7 @@
     public SSTable(String filename, IPartitioner partitioner)
     {
         assert filename.endsWith("-Data.db");
+        columnFamilyName = new File(filename).getName().split("-")[0];
         this.path = filename;
         this.partitioner = partitioner;
     }
@@ -67,6 +71,11 @@
         return path;
     }
 
+    public String getColumnFamilyName()
+    {
+        return columnFamilyName;
+    }
+
     public static String parseTableName(String filename)
     {
         return new File(filename).getParentFile().getName();        

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTableReader.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTableReader.java?rev=803284&r1=803283&r2=803284&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTableReader.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTableReader.java Tue Aug
11 20:34:21 2009
@@ -28,6 +28,8 @@
 import org.apache.cassandra.utils.FileUtils;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.config.DatabaseDescriptor;
+import org.apache.cassandra.db.ColumnFamily;
+import org.apache.cassandra.db.marshal.AbstractType;
 import org.cliffc.high_scale_lib.NonBlockingHashMap;
 import com.reardencommerce.kernel.collections.shared.evictable.ConcurrentLinkedHashMap;
 
@@ -324,6 +326,19 @@
         return parseTableName(path);
     }
 
+    public AbstractType getColumnComparator()
+    {
+        return DatabaseDescriptor.getComparator(getTableName(), getColumnFamilyName());
+    }
+
+    public ColumnFamily makeColumnFamily()
+    {
+        return new ColumnFamily(getColumnFamilyName(),
+                                DatabaseDescriptor.getColumnType(getTableName(), getColumnFamilyName()),
+                                getColumnComparator(),
+                                DatabaseDescriptor.getSubComparator(getTableName(), getColumnFamilyName()));
+    }
+
     public static void deleteAll() throws IOException
     {
         for (SSTableReader sstable : openedFiles.values())



Mime
View raw message