Author: gdusbabek
Date: Wed Dec 15 15:17:03 2010
New Revision: 1049583

URL: http://svn.apache.org/viewvc?rev=1049583&view=rev
Log:
track row deletions when merging cols to form a row. patch by gdusbabek and 
jbellis. CASSANDRA-1837

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/db/RowIteratorFactory.java
    
cassandra/trunk/src/java/org/apache/cassandra/db/columniterator/IColumnIterator.java

Modified: 
cassandra/trunk/src/java/org/apache/cassandra/db/RowIteratorFactory.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/RowIteratorFactory.java?rev=1049583&r1=1049582&r2=1049583&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/RowIteratorFactory.java 
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/RowIteratorFactory.java 
Wed Dec 15 15:17:03 2010
@@ -18,6 +18,8 @@
 package org.apache.cassandra.db;
 
 import java.io.Closeable;
+import java.io.IOError;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Comparator;
@@ -128,8 +130,7 @@ public class RowIteratorFactory
                 Comparator<IColumn> colComparator = 
filter.filter.getColumnComparator(comparator);
                 Iterator<IColumn> colCollated = 
IteratorUtils.collatedIterator(colComparator, colIters);
 
-                ColumnFamily returnCF = null;
-                
+                ColumnFamily returnCF;
                 // First check if this row is in the rowCache. If it is we can 
skip the rest
                 ColumnFamily cached = cfs.getRawCachedRow(key);
                 if (cached != null)
@@ -137,23 +138,34 @@ public class RowIteratorFactory
                     QueryFilter keyFilter = new QueryFilter(key, filter.path, 
filter.filter);
                     returnCF = cfs.filterColumnFamily(cached, keyFilter, 
gcBefore);
                 }
-                else
+                else if (colCollated.hasNext())
                 {
-                    returnCF = firstMemtable.getColumnFamily(key);            
+                    returnCF = firstMemtable.getColumnFamily(key);
                     // TODO this is a little subtle: the Memtable 
ColumnIterator has to be a shallow clone of the source CF,
                     // with deletion times set correctly, so we can use it as 
the "base" CF to add query results to.
                     // (for sstable ColumnIterators we do not care if it is a 
shallow clone or not.)
                     returnCF = returnCF == null ? 
ColumnFamily.create(firstMemtable.getTableName(), filter.getColumnFamilyName())
-                            : returnCF.cloneMeShallow();
-
-                    if (colCollated.hasNext())
-                    {
-                        filter.collectCollatedColumns(returnCF, colCollated, 
gcBefore);
-                    }
-                    else
+                                                : returnCF.cloneMeShallow();
+                    long lastDeletedAt = Long.MIN_VALUE;
+                    for (IColumnIterator columns : colIters)
                     {
-                        returnCF = null;
+                        columns.hasNext(); // force cf initializtion
+                        try
+                        {
+                            if (columns.getColumnFamily().isMarkedForDelete())
+                                lastDeletedAt = Math.max(lastDeletedAt, 
columns.getColumnFamily().getMarkedForDeleteAt());
+                        }
+                        catch (IOException e)
+                        {
+                            throw new IOError(e);
+                        }
                     }
+                    returnCF.markedForDeleteAt.set(lastDeletedAt);
+                    filter.collectCollatedColumns(returnCF, colCollated, 
gcBefore);
+                }
+                else
+                {
+                    returnCF = null;
                 }
 
                 Row rv = new Row(key, returnCF);

Modified: 
cassandra/trunk/src/java/org/apache/cassandra/db/columniterator/IColumnIterator.java
URL: 
http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/columniterator/IColumnIterator.java?rev=1049583&r1=1049582&r2=1049583&view=diff
==============================================================================
--- 
cassandra/trunk/src/java/org/apache/cassandra/db/columniterator/IColumnIterator.java
 (original)
+++ 
cassandra/trunk/src/java/org/apache/cassandra/db/columniterator/IColumnIterator.java
 Wed Dec 15 15:17:03 2010
@@ -31,8 +31,9 @@ import org.apache.cassandra.db.ColumnFam
 public interface IColumnIterator extends Iterator<IColumn>
 {
     /**
-     *  returns the CF of the column being iterated.  Do not modify the 
returned CF; clone first.
-     *  The CF is only guaranteed to be available after a call to next() or 
hasNext().
+     * returns the CF of the column being iterated.  Do not modify the 
returned CF; clone first.
+     * The CF is only guaranteed to be available after a call to next() or 
hasNext().
+     * Guaranteed to be non-null.
      * @throws IOException 
      */
     public abstract ColumnFamily getColumnFamily() throws IOException;


Reply via email to