cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r793053 - in /incubator/cassandra/trunk: src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/db/filter/ src/java/org/apache/cassandra/io/ src/java/org/apache/cassandra/test/ test/unit/org/apache/cassandra/db/
Date Fri, 10 Jul 2009 17:49:02 GMT
Author: jbellis
Date: Fri Jul 10 17:49:01 2009
New Revision: 793053

URL: http://svn.apache.org/viewvc?rev=793053&view=rev
Log:
replace namesfilter with NamesQueryFilter.  mv filter code into separate package.
patch by jbellis; reviewed by Jun Rao for CASSANDRA-287

Added:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/AbstractColumnIterator.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/ColumnIterator.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
      - copied, changed from r793052, incubator/cassandra/trunk/src/java/org/apache/cassandra/db/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
      - copied, changed from r793052, incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnIterator.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SimpleAbstractColumnIterator.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
      - copied, changed from r793052, incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceQueryFilter.java
Removed:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnIterator.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/NamesFilter.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/QueryFilter.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceQueryFilter.java
Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Column.java
    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/Memtable.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/TimeFilter.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IFileReader.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IndexHelper.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SSTableReader.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SequenceFile.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/test/TestRunner.java
    incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Column.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Column.java?rev=793053&r1=793052&r2=793053&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Column.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Column.java Fri Jul 10 17:49:01 2009
@@ -22,6 +22,7 @@
 import java.io.DataOutputStream;
 import java.io.IOException;
 import java.util.Collection;
+import java.util.Map;
 import java.nio.ByteBuffer;
 
 import org.apache.commons.lang.ArrayUtils;

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=793053&r1=793052&r2=793053&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 Fri Jul 10 17:49:01 2009
@@ -133,7 +133,7 @@
         this(cfName, columnType, ColumnComparatorFactory.getComparator(indexType));
     }
 
-    ColumnFamily cloneMeShallow()
+    public ColumnFamily cloneMeShallow()
     {
         ColumnFamily cf = new ColumnFamily(name_, type_, getComparator());
         cf.markedForDeleteAt = markedForDeleteAt;
@@ -218,7 +218,7 @@
 		addColumn(column);
     }
 
-    void clear()
+    public void clear()
     {
         if (logger_.isDebugEnabled())
           logger_.debug("clearing");
@@ -230,7 +230,7 @@
      * If we find an old column that has the same name
      * the ask it to resolve itself else add the new column .
     */
-    void addColumn(IColumn column)
+    public void addColumn(IColumn column)
     {
         String name = column.name();
         IColumn oldColumn = columns_.get(name);

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=793053&r1=793052&r2=793053&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 Fri Jul 10 17:49:01 2009
@@ -39,9 +39,12 @@
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.*;
 import org.apache.cassandra.concurrent.DebuggableThreadPoolExecutor;
+import org.apache.cassandra.db.filter.QueryFilter;
+import org.apache.cassandra.db.filter.ColumnIterator;
+import org.apache.cassandra.db.filter.NamesQueryFilter;
+
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.collections.IteratorUtils;
-import org.apache.commons.collections.comparators.ReverseComparator;
 
 import org.cliffc.high_scale_lib.NonBlockingHashMap;
 import org.cliffc.high_scale_lib.NonBlockingHashSet;
@@ -663,8 +666,7 @@
                 // don't operate directly on the supercolumn, it could be the one in the memtable.
                 // instead, create a new SC and add in the subcolumns that qualify.
                 cf.remove(cname);
-                SuperColumn sc = new SuperColumn(cname);
-                sc.markForDeleteAt(c.getLocalDeletionTime(), c.getMarkedForDeleteAt());
+                SuperColumn sc = ((SuperColumn)c).cloneMeShallow();
                 for (IColumn subColumn : c.getSubColumns())
                 {
                     if (subColumn.timestamp() > minTimestamp)
@@ -1556,8 +1558,23 @@
      * only the latest version of a column is returned
      */
     public ColumnFamily getColumnFamily(QueryFilter filter)
-    throws IOException, ExecutionException, InterruptedException
+    throws IOException
     {
+        String[] values = RowMutation.getColumnAndColumnFamily(filter.columnFamilyColumn);
+
+        // if we are querying subcolumns of a supercolumn, fetch the supercolumn with NQF, then filter in-memory.
+        if (values.length > 1)
+        {
+            QueryFilter nameFilter = new NamesQueryFilter(filter.key, values[0], values[1]);
+            ColumnFamily cf = getColumnFamily(nameFilter);
+            for (IColumn column : cf.getAllColumns())
+            {
+                filter.filterSuperColumn((SuperColumn) column);
+            }
+            return removeDeleted(cf);
+        }
+
+        // we are querying top-level columns, do a merging fetch with indexes.
         sstableLock_.readLock().lock();
         List<ColumnIterator> iterators = new ArrayList<ColumnIterator>();
         try
@@ -1606,7 +1623,7 @@
             Comparator<IColumn> comparator = filter.getColumnComparator();
             Iterator collated = IteratorUtils.collatedIterator(comparator, iterators);
             if (!collated.hasNext())
-                return ColumnFamily.create(table_, filter.getColumnFamilyName());
+                return ColumnFamily.create(table_, columnFamily_);
 
             filter.collectColumns(returnCF, collated);
 

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=793053&r1=793052&r2=793053&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 Fri Jul 10 17:49:01 2009
@@ -23,7 +23,6 @@
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.atomic.AtomicInteger;
 
-import org.apache.commons.collections.comparators.ReverseComparator;
 import org.apache.commons.lang.ArrayUtils;
 
 import org.apache.cassandra.config.DatabaseDescriptor;
@@ -33,6 +32,8 @@
 import org.apache.cassandra.io.SSTableWriter;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.DestructivePQIterator;
+import org.apache.cassandra.db.filter.*;
+
 import org.apache.log4j.Logger;
 
 /**
@@ -234,8 +235,7 @@
                     if (subColumn != null)
                     {
                         columnFamily = cFamily.cloneMeShallow();
-                        SuperColumn container = new SuperColumn(superColumn.name());
-                        container.markForDeleteAt(superColumn.getLocalDeletionTime(), superColumn.getMarkedForDeleteAt());
+                        SuperColumn container = superColumn.cloneMeShallow();
                         container.addColumn(subColumn);
                         columnFamily.addColumn(container);
                     }
@@ -321,42 +321,28 @@
     /**
      * obtain an iterator of columns in this memtable in the specified order starting from a given column.
      */
-    ColumnIterator getColumnIterator(final String key, final String cfName, final boolean isAscending, String startColumn)
+    public ColumnIterator getSliceIterator(SliceQueryFilter filter)
     {
-        ColumnFamily cf = columnFamilies_.get(key);
-        final ColumnFamily columnFamily;
-        if (cf != null)
-            columnFamily = cf.cloneMeShallow();
-        else
-            columnFamily = ColumnFamily.create(table_, cfName);
+        ColumnFamily cf = columnFamilies_.get(filter.key);
+        final ColumnFamily columnFamily = cf == null ? ColumnFamily.create(table_, filter.getColumnFamilyName()) : cf.cloneMeShallow();
 
         final IColumn columns[] = (cf == null ? columnFamily : cf).getAllColumns().toArray(new IColumn[columnFamily.getAllColumns().size()]);
         // TODO if we are dealing with supercolumns, we need to clone them while we have the read lock since they can be modified later
-        if (!isAscending)
+        if (!filter.isAscending)
             ArrayUtils.reverse(columns);
         IColumn startIColumn;
-        if (DatabaseDescriptor.getColumnFamilyType(table_, cfName).equals("Standard"))
-            startIColumn = new Column(startColumn);
+        if (DatabaseDescriptor.getColumnFamilyType(table_, filter.getColumnFamilyName()).equals("Standard"))
+            startIColumn = new Column(filter.start);
         else
-            startIColumn = new SuperColumn(startColumn);
+            startIColumn = new SuperColumn(filter.start);
 
         // can't use a ColumnComparatorFactory comparator since those compare on both name and time (and thus will fail to match
         // our dummy column, since the time there is arbitrary).
-        Comparator<IColumn> comparator = new Comparator<IColumn>()
-        {
-            public int compare(IColumn column1, IColumn column2)
-            {
-                return column1.name().compareTo(column2.name());
-            }
-        };
-        if (!isAscending)
-        {
-            comparator = new ReverseComparator(comparator);
-        }
+        Comparator<IColumn> comparator = filter.getColumnComparator();
         int index = Arrays.binarySearch(columns, startIColumn, comparator);
         final int startIndex = index < 0 ? -(index + 1) : index;
 
-        return new ColumnIterator()
+        return new AbstractColumnIterator()
         {
             private int curIndex_ = startIndex;
 
@@ -374,12 +360,39 @@
             {
                 return columns[curIndex_++];
             }
+        };
+    }
+
+    public ColumnIterator getNamesIterator(final NamesQueryFilter filter)
+    {
+        ColumnFamily cf = columnFamilies_.get(filter.key);
+        final ColumnFamily columnFamily = cf == null ? ColumnFamily.create(table_, filter.getColumnFamilyName()) : cf.cloneMeShallow();
+        final Map<String, IColumn> columnsContainer = cf == null ? null : cf.getColumns();
 
-            public void close() throws IOException {}
+        return new SimpleAbstractColumnIterator()
+        {
+            private Iterator<String> iter = filter.columns.iterator();
+            private String current;
 
-            public void remove()
+            public ColumnFamily getColumnFamily()
             {
-                throw new UnsupportedOperationException();
+                return columnFamily;
+            }
+
+            protected IColumn computeNext()
+            {
+                if (columnsContainer == null)
+                {
+                    return endOfData();
+                }
+                while (iter.hasNext())
+                {
+                    current = iter.next();
+                    IColumn column = columnsContainer.get(current);
+                    if (column != null)
+                        return column;
+                }
+                return endOfData();
             }
         };
     }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java?rev=793053&r1=793052&r2=793053&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java Fri Jul 10 17:49:01 2009
@@ -20,22 +20,20 @@
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
 
 import org.apache.commons.lang.StringUtils;
 
 public class SliceByNamesReadCommand extends ReadCommand
 {
     public final String columnFamily;
-    public final List<String> columnNames;
+    public final SortedSet<String> columnNames;
 
-    public SliceByNamesReadCommand(String table, String key, String columnFamily, List<String> columnNames)
+    public SliceByNamesReadCommand(String table, String key, String columnFamily, Collection<String> columnNames)
     {
         super(table, key, CMD_TYPE_GET_SLICE_BY_NAMES);
         this.columnFamily = columnFamily;
-        this.columnNames = Collections.unmodifiableList(columnNames);
+        this.columnNames = new TreeSet<String>(columnNames);
     }
 
     @Override

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java?rev=793053&r1=793052&r2=793053&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java Fri Jul 10 17:49:01 2009
@@ -24,6 +24,7 @@
 import java.io.Serializable;
 import java.util.Collection;
 import java.util.Set;
+import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.commons.lang.ArrayUtils;
@@ -62,6 +63,13 @@
     	name_ = name;
     }
 
+    public SuperColumn cloneMeShallow()
+    {
+        SuperColumn sc = new SuperColumn(name_);
+        sc.markForDeleteAt(localDeletionTime, markedForDeleteAt);
+        return sc;
+    }
+
 	public boolean isMarkedForDelete()
 	{
 		return markedForDeleteAt > Long.MIN_VALUE;

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=793053&r1=793052&r2=793053&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Fri Jul 10 17:49:01 2009
@@ -43,6 +43,10 @@
 import org.apache.cassandra.net.io.StreamContextManager;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.*;
+import org.apache.cassandra.db.filter.QueryFilter;
+import org.apache.cassandra.db.filter.SliceQueryFilter;
+import org.apache.cassandra.db.filter.NamesQueryFilter;
+
 import org.apache.log4j.Logger;
 
 /**
@@ -495,6 +499,7 @@
     /**
      * Selects the row associated with the given key.
     */
+    @Deprecated // CF should be our atom of work, not Row
     public Row get(String key) throws IOException
     {        
         Row row = new Row(table_, key);
@@ -520,13 +525,14 @@
     /**
      * Selects the specified column family for the specified key.
     */
-    public ColumnFamily get(String key, String cf) throws IOException
+    @Deprecated // single CFs could be larger than memory
+    public ColumnFamily get(String key, String columnFamilyColumn) throws IOException
     {
-        String[] values = RowMutation.getColumnAndColumnFamily(cf);
+        String[] values = RowMutation.getColumnAndColumnFamily(columnFamilyColumn);
         long start = System.currentTimeMillis();
         ColumnFamilyStore cfStore = columnFamilyStores_.get(values[0]);
-        assert cfStore != null : "Column family " + cf + " has not been defined";
-        ColumnFamily columnFamily = cfStore.getColumnFamily(key, cf, new IdentityFilter());
+        assert cfStore != null : "Column family " + columnFamilyColumn + " has not been defined";
+        ColumnFamily columnFamily = cfStore.getColumnFamily(key, columnFamilyColumn, new IdentityFilter());
         long timeTaken = System.currentTimeMillis() - start;
         dbAnalyticsSource_.updateReadStatistics(timeTaken);
         return columnFamily;
@@ -567,19 +573,11 @@
      *  param @ cf - column family we are interested in.
      *  param @ columns - columns that are part of the above column family.
     */
-    public Row getRow(String key, String cf, List<String> columns) throws IOException
+    public Row getRow(String key, String columnFamilyColumn, SortedSet<String> columns) throws IOException
     {
-    	Row row = new Row(table_, key);
-        String[] values = RowMutation.getColumnAndColumnFamily(cf);
-        ColumnFamilyStore cfStore = columnFamilyStores_.get(values[0]);
-
-        if ( cfStore != null )
-        {
-        	ColumnFamily columnFamily = cfStore.getColumnFamily(key, cf, new NamesFilter(new ArrayList<String>(columns)));
-        	if ( columnFamily != null )
-        		row.addColumnFamily(columnFamily);
-        }
-    	return row;
+        // TODO for large CFs we will want a specialized iterator
+        QueryFilter filter = new NamesQueryFilter(key, columnFamilyColumn, columns);
+        return getRow(key, filter);
     }
 
     /**
@@ -587,12 +585,17 @@
     */
     public Row getRow(String key, String cfName, String start, String finish, boolean isAscending, int offset, int count) throws IOException
     {
+        QueryFilter filter = new SliceQueryFilter(key, cfName, start, finish, isAscending, offset, count);
+        return getRow(key, filter);
+    }
+
+    private Row getRow(String key, QueryFilter filter) throws IOException
+    {
+        ColumnFamilyStore cfStore = columnFamilyStores_.get(filter.getColumnFamilyName());
         Row row = new Row(table_, key);
-        ColumnFamilyStore cfStore = columnFamilyStores_.get(cfName);
         long start1 = System.currentTimeMillis();
         try
         {
-            QueryFilter filter = new SliceQueryFilter(key, cfName, start, finish, isAscending, offset, count);
             ColumnFamily columnFamily = cfStore.getColumnFamily(filter);
             if (columnFamily != null)
                 row.addColumnFamily(columnFamily);

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/TimeFilter.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/TimeFilter.java?rev=793053&r1=793052&r2=793053&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/TimeFilter.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/TimeFilter.java Fri Jul 10 17:49:01 2009
@@ -74,8 +74,7 @@
             for (IColumn column : columns)
             {
                 SuperColumn superColumn = (SuperColumn) column;
-                SuperColumn filteredSuperColumn = new SuperColumn(superColumn.name());
-                filteredSuperColumn.markForDeleteAt(column.getLocalDeletionTime(), column.getMarkedForDeleteAt());
+                SuperColumn filteredSuperColumn = superColumn.cloneMeShallow();
                 filteredCf.addColumn(filteredSuperColumn);
                 Collection<IColumn> subColumns = superColumn.getSubColumns();
                 for (IColumn subColumn : subColumns)

Added: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/AbstractColumnIterator.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/AbstractColumnIterator.java?rev=793053&view=auto
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/AbstractColumnIterator.java (added)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/AbstractColumnIterator.java Fri Jul 10 17:49:01 2009
@@ -0,0 +1,14 @@
+package org.apache.cassandra.db.filter;
+
+import java.io.IOException;
+
+public abstract class AbstractColumnIterator implements ColumnIterator
+{
+    public void close() throws IOException
+    {}
+
+    public void remove()
+    {
+        throw new UnsupportedOperationException();
+    }
+}

Added: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/ColumnIterator.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/ColumnIterator.java?rev=793053&view=auto
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/ColumnIterator.java (added)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/ColumnIterator.java Fri Jul 10 17:49:01 2009
@@ -0,0 +1,20 @@
+package org.apache.cassandra.db.filter;
+
+import java.util.Iterator;
+import java.io.IOException;
+
+import org.apache.cassandra.db.IColumn;
+import org.apache.cassandra.db.ColumnFamily;
+
+public interface ColumnIterator extends Iterator<IColumn>
+{
+    /**
+     *  returns the CF of the column being iterated.
+     *  The CF is only guaranteed to be available after a call to next() or hasNext().
+     */
+    public abstract ColumnFamily getColumnFamily();
+
+    /** clean up any open resources */
+    public void close() throws IOException;
+}
+

Added: 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=793053&view=auto
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java (added)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java Fri Jul 10 17:49:01 2009
@@ -0,0 +1,59 @@
+package org.apache.cassandra.db.filter;
+
+import java.io.IOException;
+import java.util.SortedSet;
+import java.util.Arrays;
+import java.util.TreeSet;
+
+import org.apache.cassandra.io.SSTableReader;
+import org.apache.cassandra.utils.ReducingIterator;
+import org.apache.cassandra.db.filter.ColumnIterator;
+import org.apache.cassandra.db.Memtable;
+import org.apache.cassandra.db.ColumnFamily;
+import org.apache.cassandra.db.IColumn;
+import org.apache.cassandra.db.SuperColumn;
+
+public class NamesQueryFilter extends QueryFilter
+{
+    public final SortedSet<String> columns;
+
+    public NamesQueryFilter(String key, String columnFamilyColumn, SortedSet<String> columns)
+    {
+        super(key, columnFamilyColumn);
+        this.columns = columns;
+    }
+
+    public NamesQueryFilter(String key, String columnFamilyColumn, String column)
+    {
+        this(key, columnFamilyColumn, new TreeSet<String>(Arrays.asList(column)));
+    }
+
+    public ColumnIterator getMemColumnIterator(Memtable memtable)
+    {
+        return memtable.getNamesIterator(this);
+    }
+
+    public ColumnIterator getSSTableColumnIterator(SSTableReader sstable) throws IOException
+    {
+        return new SSTableNamesIterator(sstable.getFilename(), key, getColumnFamilyName(), columns);
+    }
+
+    public void filterSuperColumn(SuperColumn superColumn)
+    {
+        for (IColumn column : superColumn.getSubColumns())
+        {
+            if (!columns.contains(column.name()))
+            {
+                superColumn.remove(column.name());
+            }
+        }
+    }
+
+    public void collectColumns(ColumnFamily returnCF, ReducingIterator<IColumn> reducedColumns)
+    {
+        for (IColumn column : reducedColumns)
+        {
+            returnCF.addColumn(column);
+        }
+    }
+}

Copied: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java (from r793052, incubator/cassandra/trunk/src/java/org/apache/cassandra/db/QueryFilter.java)
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java?p2=incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java&p1=incubator/cassandra/trunk/src/java/org/apache/cassandra/db/QueryFilter.java&r1=793052&r2=793053&rev=793053&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/QueryFilter.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java Fri Jul 10 17:49:01 2009
@@ -1,16 +1,12 @@
-package org.apache.cassandra.db;
+package org.apache.cassandra.db.filter;
 
 import java.io.IOException;
-import java.util.List;
 import java.util.Comparator;
 import java.util.Iterator;
-import java.util.Collection;
-
-import org.apache.commons.collections.comparators.ReverseComparator;
-import org.apache.commons.collections.IteratorUtils;
 
 import org.apache.cassandra.io.SSTableReader;
 import org.apache.cassandra.utils.ReducingIterator;
+import org.apache.cassandra.db.*;
 
 public abstract class QueryFilter
 {
@@ -42,7 +38,13 @@
      */
     public abstract void collectColumns(ColumnFamily returnCF, ReducingIterator<IColumn> reducedColumns);
 
-    protected Comparator<IColumn> getColumnComparator()
+    /**
+     * subcolumns of a supercolumn are unindexed, so to pick out parts of those we operate in-memory.
+     * @param superColumn
+     */
+    public abstract void filterSuperColumn(SuperColumn superColumn);
+
+    public Comparator<IColumn> getColumnComparator()
     {
         return new Comparator<IColumn>()
         {
@@ -84,6 +86,6 @@
 
     public String getColumnFamilyName()
     {
-        return RowMutation.getColumnAndColumnFamily(columnFamilyColumn)[0]);
+        return RowMutation.getColumnAndColumnFamily(columnFamilyColumn)[0];
     }
 }

Added: 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=793053&view=auto
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java (added)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java Fri Jul 10 17:49:01 2009
@@ -0,0 +1,45 @@
+package org.apache.cassandra.db.filter;
+
+import java.io.IOException;
+import java.util.SortedSet;
+import java.util.Iterator;
+
+import org.apache.cassandra.db.ColumnFamily;
+import org.apache.cassandra.db.IColumn;
+import org.apache.cassandra.io.SSTableReader;
+import org.apache.cassandra.io.DataInputBuffer;
+
+public class SSTableNamesIterator extends SimpleAbstractColumnIterator
+{
+    private ColumnFamily cf;
+    private Iterator<IColumn> iter;
+    public final SortedSet<String> columns;
+
+    // TODO make this actually iterate so we don't have to read + deserialize + filter data that we don't need due to merging other sstables
+    public SSTableNamesIterator(String filename, String key, String cfName, SortedSet<String> columns) throws IOException
+    {
+        this.columns = columns;
+        SSTableReader ssTable = SSTableReader.open(filename);
+        DataInputBuffer buffer = ssTable.next(key, cfName, columns);
+        cf = ColumnFamily.serializer().deserialize(buffer);
+        iter = cf.getAllColumns().iterator();
+    }
+
+    public ColumnFamily getColumnFamily()
+    {
+        return cf;
+    }
+
+    protected IColumn computeNext()
+    {
+        if (iter == null)
+            return endOfData();
+        while (iter.hasNext())
+        {
+            IColumn c = iter.next();
+            if (columns.contains(c.name()))
+                return c;
+        }
+        return endOfData();
+    }
+}

Copied: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java (from r793052, incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnIterator.java)
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java?p2=incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java&p1=incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnIterator.java&r1=793052&r2=793053&rev=793053&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnIterator.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java Fri Jul 10 17:49:01 2009
@@ -1,133 +1,105 @@
-/**
- * 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.
- */
-package org.apache.cassandra.db;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.apache.cassandra.io.DataInputBuffer;
-import org.apache.cassandra.io.DataOutputBuffer;
-import org.apache.cassandra.io.SSTableReader;
-import org.apache.cassandra.io.SequenceFile.ColumnGroupReader;
-import com.google.common.collect.AbstractIterator;
-
-public interface ColumnIterator extends Iterator<IColumn>
-{
-    /**
-     *  returns the CF of the column being iterated.
-     *  The CF is only guaranteed to be available after a call to next() or hasNext().
-     */
-    public abstract ColumnFamily getColumnFamily();
-
-    /** clean up any open resources */
-    public void close() throws IOException;
-}
-
-/**
- *  A Column Iterator over SSTable
- */
-class SSTableColumnIterator extends AbstractIterator<IColumn> implements ColumnIterator
-{
-    protected boolean isAscending;
-    private String startColumn;
-    private DataOutputBuffer outBuf = new DataOutputBuffer();
-    private DataInputBuffer inBuf = new DataInputBuffer();
-    private int curColumnIndex;
-    private ColumnFamily curCF = null;
-    private ArrayList<IColumn> curColumns = new ArrayList<IColumn>();
-    private ColumnGroupReader reader;
-
-    public SSTableColumnIterator(String filename, String key, String cfName, String startColumn, boolean isAscending)
-    throws IOException
-    {
-        this.isAscending = isAscending;
-        SSTableReader ssTable = SSTableReader.open(filename);
-        reader = ssTable.getColumnGroupReader(key, cfName, startColumn, isAscending);
-        this.startColumn = startColumn;
-        curColumnIndex = isAscending ? 0 : -1;
-    }
-
-    private boolean isColumnNeeded(IColumn column)
-    {
-        if (isAscending)
-            return (column.name().compareTo(startColumn) >= 0);
-        else
-            return (column.name().compareTo(startColumn) <= 0);
-    }
-
-    private void getColumnsFromBuffer() throws IOException
-    {
-        inBuf.reset(outBuf.getData(), outBuf.getLength());
-        ColumnFamily columnFamily = ColumnFamily.serializer().deserialize(inBuf);
-
-        if (curCF == null)
-            curCF = columnFamily.cloneMeShallow();
-        curColumns.clear();
-        for (IColumn column : columnFamily.getAllColumns())
-            if (isColumnNeeded(column))
-                curColumns.add(column);
-
-        if (isAscending)
-            curColumnIndex = 0;
-        else
-            curColumnIndex = curColumns.size() - 1;
-    }
-
-    public ColumnFamily getColumnFamily()
-    {
-        return curCF;
-    }
-
-    protected IColumn computeNext()
-    {
-        while (true)
-        {
-            if (isAscending)
-            {
-                if (curColumnIndex < curColumns.size())
-                {
-                    return curColumns.get(curColumnIndex++);
-                }
-            }
-            else
-            {
-                if (curColumnIndex >= 0)
-                {
-                    return curColumns.get(curColumnIndex--);
-                }
-            }
-
-            try
-            {
-                if (!reader.getNextBlock(outBuf))
-                    return endOfData();
-                getColumnsFromBuffer();
-            }
-            catch (IOException e)
-            {
-                throw new RuntimeException(e);
-            }
-        }
-    }
-
-    public void close() throws IOException
-    {
-        reader.close();
-    }
-}
+package org.apache.cassandra.db.filter;
+
+import java.util.ArrayList;
+import java.io.IOException;
+
+import org.apache.cassandra.db.IColumn;
+import org.apache.cassandra.db.ColumnFamily;
+import org.apache.cassandra.io.DataOutputBuffer;
+import org.apache.cassandra.io.DataInputBuffer;
+import org.apache.cassandra.io.SequenceFile;
+import org.apache.cassandra.io.SSTableReader;
+import com.google.common.collect.AbstractIterator;
+
+/**
+ *  A Column Iterator over SSTable
+ */
+class SSTableSliceIterator extends AbstractIterator<IColumn> implements ColumnIterator
+{
+    protected boolean isAscending;
+    private String startColumn;
+    private DataOutputBuffer outBuf = new DataOutputBuffer();
+    private DataInputBuffer inBuf = new DataInputBuffer();
+    private int curColumnIndex;
+    private ColumnFamily curCF = null;
+    private ArrayList<IColumn> curColumns = new ArrayList<IColumn>();
+    private SequenceFile.ColumnGroupReader reader;
+
+    public SSTableSliceIterator(String filename, String key, String cfName, String startColumn, boolean isAscending)
+    throws IOException
+    {
+        this.isAscending = isAscending;
+        SSTableReader ssTable = SSTableReader.open(filename);
+        reader = ssTable.getColumnGroupReader(key, cfName, startColumn, isAscending);
+        this.startColumn = startColumn;
+        curColumnIndex = isAscending ? 0 : -1;
+    }
+
+    private boolean isColumnNeeded(IColumn column)
+    {
+        if (isAscending)
+            return (column.name().compareTo(startColumn) >= 0);
+        else
+            return (column.name().compareTo(startColumn) <= 0);
+    }
+
+    private void getColumnsFromBuffer() throws IOException
+    {
+        inBuf.reset(outBuf.getData(), outBuf.getLength());
+        ColumnFamily columnFamily = ColumnFamily.serializer().deserialize(inBuf);
+
+        if (curCF == null)
+            curCF = columnFamily.cloneMeShallow();
+        curColumns.clear();
+        for (IColumn column : columnFamily.getAllColumns())
+            if (isColumnNeeded(column))
+                curColumns.add(column);
+
+        if (isAscending)
+            curColumnIndex = 0;
+        else
+            curColumnIndex = curColumns.size() - 1;
+    }
+
+    public ColumnFamily getColumnFamily()
+    {
+        return curCF;
+    }
+
+    protected IColumn computeNext()
+    {
+        while (true)
+        {
+            if (isAscending)
+            {
+                if (curColumnIndex < curColumns.size())
+                {
+                    return curColumns.get(curColumnIndex++);
+                }
+            }
+            else
+            {
+                if (curColumnIndex >= 0)
+                {
+                    return curColumns.get(curColumnIndex--);
+                }
+            }
+
+            try
+            {
+                if (!reader.getNextBlock(outBuf))
+                    return endOfData();
+                getColumnsFromBuffer();
+            }
+            catch (IOException e)
+            {
+                throw new RuntimeException(e);
+            }
+        }
+    }
+
+    public void close() throws IOException
+    {
+        reader.close();
+    }
+}

Added: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SimpleAbstractColumnIterator.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SimpleAbstractColumnIterator.java?rev=793053&view=auto
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SimpleAbstractColumnIterator.java (added)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SimpleAbstractColumnIterator.java Fri Jul 10 17:49:01 2009
@@ -0,0 +1,11 @@
+package org.apache.cassandra.db.filter;
+
+import java.io.IOException;
+
+import org.apache.cassandra.db.IColumn;
+import com.google.common.collect.AbstractIterator;
+
+public abstract class SimpleAbstractColumnIterator extends AbstractIterator<IColumn> implements ColumnIterator
+{
+    public void close() throws IOException {}
+}

Copied: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java (from r793052, incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceQueryFilter.java)
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java?p2=incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java&p1=incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceQueryFilter.java&r1=793052&r2=793053&rev=793053&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/SliceQueryFilter.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java Fri Jul 10 17:49:01 2009
@@ -1,4 +1,4 @@
-package org.apache.cassandra.db;
+package org.apache.cassandra.db.filter;
 
 import java.io.IOException;
 import java.util.Comparator;
@@ -7,6 +7,7 @@
 
 import org.apache.cassandra.io.SSTableReader;
 import org.apache.cassandra.utils.ReducingIterator;
+import org.apache.cassandra.db.*;
 
 public class SliceQueryFilter extends QueryFilter
 {
@@ -26,16 +27,22 @@
 
     public ColumnIterator getMemColumnIterator(Memtable memtable)
     {
-        return memtable.getColumnIterator(key, columnFamilyColumn, isAscending, start);
+        return memtable.getSliceIterator(this);
     }
 
     public ColumnIterator getSSTableColumnIterator(SSTableReader sstable) throws IOException
     {
-        return new SSTableColumnIterator(sstable.getFilename(), key, columnFamilyColumn, start, isAscending);
+        return new SSTableSliceIterator(sstable.getFilename(), key, getColumnFamilyName(), start, isAscending);
+    }
+
+    public void filterSuperColumn(SuperColumn superColumn)
+    {
+        // TODO write this after CASSANDRA-240 is done
+        throw new UnsupportedOperationException();
     }
 
     @Override
-    protected Comparator<IColumn> getColumnComparator()
+    public Comparator<IColumn> getColumnComparator()
     {
         Comparator<IColumn> comparator = super.getColumnComparator();
         return isAscending ? comparator : new ReverseComparator(comparator);

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IFileReader.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IFileReader.java?rev=793053&r1=793052&r2=793053&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IFileReader.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/IFileReader.java Fri Jul 10 17:49:01 2009
@@ -20,6 +20,7 @@
 
 import java.io.IOException;
 import java.util.List;
+import java.util.SortedSet;
 
 /**
  * Interface to read from the SequenceFile abstraction.
@@ -78,7 +79,7 @@
      * @return number of bytes read.
      *
     */
-    public long next(String key, DataOutputBuffer bufOut, String columnFamilyName, List<String> columnNames, IndexHelper.TimeRange timeRange, long position) throws IOException;
+    public long next(String key, DataOutputBuffer bufOut, String columnFamilyName, SortedSet<String> columnNames, IndexHelper.TimeRange timeRange, long position) throws IOException;
 
     /**
      * Close the file after reading.

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=793053&r1=793052&r2=793053&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 Fri Jul 10 17:49:01 2009
@@ -221,7 +221,7 @@
 	 * @param totalNumCols the total number of columns
 	 * @return a list of subranges which contain all the columns in columnNames
 	 */
-	static List<ColumnRange> getMultiColumnRangesFromNameIndex(List<String> columnNames, List<IndexHelper.ColumnIndexInfo> columnIndexList, int dataSize, int totalNumCols)
+	static List<ColumnRange> getMultiColumnRangesFromNameIndex(SortedSet<String> columnNames, List<IndexHelper.ColumnIndexInfo> columnIndexList, int dataSize, int totalNumCols)
 	{
 		List<ColumnRange> columnRanges = new ArrayList<ColumnRange>();				
 

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=793053&r1=793052&r2=793053&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 Fri Jul 10 17:49:01 2009
@@ -285,12 +285,12 @@
         }
     }
 
-    public DataInputBuffer next(final String clientKey, String cfName, List<String> columnNames) throws IOException
+    public DataInputBuffer next(final String clientKey, String cfName, SortedSet<String> columnNames) throws IOException
     {
         return next(clientKey, cfName, columnNames, null);
     }
 
-    public DataInputBuffer next(final String clientKey, String cfName, List<String> columnNames, IndexHelper.TimeRange timeRange) throws IOException
+    public DataInputBuffer next(final String clientKey, String cfName, SortedSet<String> columnNames, IndexHelper.TimeRange timeRange) throws IOException
     {
         IFileReader dataReader = null;
         try
@@ -327,8 +327,8 @@
     {
         String[] values = RowMutation.getColumnAndColumnFamily(columnFamilyColumn);
         String columnFamilyName = values[0];
-        List<String> cnNames = (values.length == 1) ? null : Arrays.asList(values[1]);
-        return next(clientKey, columnFamilyName, cnNames);
+        SortedSet<String> columnNames = (values.length == 1) ? null : new TreeSet<String>(Arrays.asList(values[1]));
+        return next(clientKey, columnFamilyName, columnNames);
     }
 
     /**

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SequenceFile.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SequenceFile.java?rev=793053&r1=793052&r2=793053&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SequenceFile.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/io/SequenceFile.java Fri Jul 10 17:49:01 2009
@@ -20,10 +20,7 @@
 
 import java.io.*;
 import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Arrays;
+import java.util.*;
 
 import org.apache.cassandra.config.DatabaseDescriptor;
 import org.apache.cassandra.utils.BloomFilter;
@@ -485,7 +482,7 @@
          * @return number of bytes that were read.
          * @throws IOException
          */
-        public long next(String key, DataOutputBuffer bufOut, String columnFamilyName, List<String> columnNames, IndexHelper.TimeRange timeRange, long position) throws IOException
+        public long next(String key, DataOutputBuffer bufOut, String columnFamilyName, SortedSet<String> columnNames, IndexHelper.TimeRange timeRange, long position) throws IOException
         {
             assert timeRange == null || columnNames == null; // at most one may be non-null
 
@@ -597,7 +594,7 @@
             bufOut.write(file_, dataSize);
         }
 
-        private void readColumns(String key, DataOutputBuffer bufOut, String columnFamilyName, List<String> cNames)
+        private void readColumns(String key, DataOutputBuffer bufOut, String columnFamilyName, SortedSet<String> cNames)
                 throws IOException
         {
             int dataSize = file_.readInt();
@@ -655,9 +652,6 @@
                 dataSize -= 4;
 
                 // TODO: this is name sorted - but eventually this should be sorted by the same criteria as the col index
-                /* sort the required list of columns */
-                cNames = new ArrayList<String>(cNames);
-                Collections.sort(cNames);
                 /* get the various column ranges we have to read */
                 List<IndexHelper.ColumnRange> columnRanges = IndexHelper.getMultiColumnRangesFromNameIndex(cNames, columnIndexList, dataSize, totalNumCols);
 

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/test/TestRunner.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/test/TestRunner.java?rev=793053&r1=793052&r2=793053&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/test/TestRunner.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/test/TestRunner.java Fri Jul 10 17:49:01 2009
@@ -17,10 +17,7 @@
  */
 package org.apache.cassandra.test;
 
-import java.util.Collection;
-import java.util.Random;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
 
 import org.apache.cassandra.db.ColumnFamily;
 import org.apache.cassandra.db.IColumn;
@@ -84,7 +81,7 @@
         System.out.println(row);
         */
         
-        List<String> list = new ArrayList<String>();
+        TreeSet<String> list = new TreeSet<String>();
         list.add("SuperColumn-0");
         list.add("SuperColumn-189");
         list.add("SuperColumn-23");

Modified: incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java?rev=793053&r1=793052&r2=793053&view=diff
==============================================================================
--- incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java (original)
+++ incubator/cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java Fri Jul 10 17:49:01 2009
@@ -30,6 +30,8 @@
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertEquals;
 
+import org.apache.cassandra.db.filter.NamesQueryFilter;
+
 public class RemoveSuperColumnTest
 {
     @Test
@@ -125,11 +127,7 @@
         List<ColumnFamily> families;
         ColumnFamily resolved;
 
-        families = store.getColumnFamilies("key1", "Super2:SC1", new NamesFilter(Arrays.asList("Column2")));
-        resolved = ColumnFamilyStore.removeDeleted(ColumnFamily.resolve(families));
-        validateNewDataFamily(resolved);
-
-        resolved = store.getColumnFamily("key1", "Super2:SC1:Column2", new IdentityFilter());
+        resolved = store.getColumnFamily(new NamesQueryFilter("key1", "Super2:SC1", "Column2"));
         validateNewDataFamily(resolved);
     }
 



Mime
View raw message