cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1199375 - in /cassandra/trunk: ./ contrib/ interface/thrift/gen-java/org/apache/cassandra/thrift/ src/java/org/apache/cassandra/db/ test/unit/org/apache/cassandra/ test/unit/org/apache/cassandra/db/
Date Tue, 08 Nov 2011 18:22:37 GMT
Author: jbellis
Date: Tue Nov  8 18:22:36 2011
New Revision: 1199375

URL: http://svn.apache.org/viewvc?rev=1199375&view=rev
Log:
merge from 1.0

Modified:
    cassandra/trunk/   (props changed)
    cassandra/trunk/CHANGES.txt
    cassandra/trunk/contrib/   (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java 
 (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java   (props
changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
  (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
  (props changed)
    cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
  (props changed)
    cassandra/trunk/src/java/org/apache/cassandra/db/CollationController.java
    cassandra/trunk/src/java/org/apache/cassandra/db/Column.java
    cassandra/trunk/src/java/org/apache/cassandra/db/IColumn.java
    cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java
    cassandra/trunk/src/java/org/apache/cassandra/db/TreeMapBackedSortedColumns.java
    cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java

Propchange: cassandra/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov  8 18:22:36 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8:1090934-1125013,1125019-1198724,1198726-1199259,1199284
 /cassandra/branches/cassandra-0.8.0:1125021-1130369
 /cassandra/branches/cassandra-0.8.1:1101014-1125018
-/cassandra/branches/cassandra-1.0:1167085-1199271,1199287,1199361
+/cassandra/branches/cassandra-1.0:1167085-1199374
 /cassandra/branches/cassandra-1.0.0:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/tags/cassandra-0.7.0-rc3:1051699-1053689
 /cassandra/tags/cassandra-0.8.0-rc1:1102511-1125020

Modified: cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/cassandra/trunk/CHANGES.txt?rev=1199375&r1=1199374&r2=1199375&view=diff
==============================================================================
--- cassandra/trunk/CHANGES.txt (original)
+++ cassandra/trunk/CHANGES.txt Tue Nov  8 18:22:36 2011
@@ -10,6 +10,8 @@
  * fix invalidate-related test failures (CASSANDRA-3437)
  * add next-gen cqlsh to bin/
  * (CQL) fix handling of rows with no columns (CASSANDRA-3424, 3473)
+ * fix querying supercolumns by name returning only a subset of
+   subcolumns or old subcolumn versions (CASSANDRA-3446)
 Merged from 0.8:
  * Make counter shard merging thread safe (CASSANDRA-3178)
  * fix updating CF row_cache_provider (CASSANDRA-3414)
@@ -20,6 +22,7 @@ Merged from 0.8:
  * Revert CASSANDRA-2855
  * Fix bug preventing the use of efficient cross-DC writes (CASSANDRA-3472)
 
+
 1.0.2
  * "defragment" rows for name-based queries under STCS (CASSANDRA-2503)
  * Add timing information to cassandra-cli GET/SET/LIST queries (CASSANDRA-3326)

Propchange: cassandra/trunk/contrib/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov  8 18:22:36 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/contrib:1090934-1125013,1125019-1198724,1198726-1199259,1199284
 /cassandra/branches/cassandra-0.8.0/contrib:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/contrib:1101014-1125018
-/cassandra/branches/cassandra-1.0/contrib:1167085-1199271,1199287,1199361
+/cassandra/branches/cassandra-1.0/contrib:1167085-1199374
 /cassandra/branches/cassandra-1.0.0/contrib:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/tags/cassandra-0.7.0-rc3/contrib:1051699-1053689
 /cassandra/tags/cassandra-0.8.0-rc1/contrib:1102511-1125020

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov  8 18:22:36 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1090934-1125013,1125019-1198724,1198726-1199259,1199284
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1167085-1199271,1199287,1199361
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1167085-1199374
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1051699-1053689
 /cassandra/tags/cassandra-0.8.0-rc1/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1102511-1125020

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov  8 18:22:36 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1090934-1125013,1125019-1198724,1198726-1199259,1199284
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1167085-1199271,1199287,1199361
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1167085-1199374
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1051699-1053689
 /cassandra/tags/cassandra-0.8.0-rc1/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1102511-1125020

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov  8 18:22:36 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1090934-1125013,1125019-1198724,1198726-1199259,1199284
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1167085-1199271,1199287,1199361
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1167085-1199374
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1051699-1053689
 /cassandra/tags/cassandra-0.8.0-rc1/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1102511-1125020

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov  8 18:22:36 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1090934-1125013,1125019-1198724,1198726-1199259,1199284
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1167085-1199271,1199287,1199361
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1167085-1199374
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1051699-1053689
 /cassandra/tags/cassandra-0.8.0-rc1/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1102511-1125020

Propchange: cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Nov  8 18:22:36 2011
@@ -4,7 +4,7 @@
 /cassandra/branches/cassandra-0.8/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1090934-1125013,1125019-1198724,1198726-1199259,1199284
 /cassandra/branches/cassandra-0.8.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1125021-1130369
 /cassandra/branches/cassandra-0.8.1/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1101014-1125018
-/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1167085-1199271,1199287,1199361
+/cassandra/branches/cassandra-1.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1167085-1199374
 /cassandra/branches/cassandra-1.0.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1167104-1167229,1167232-1181093,1181741,1181816,1181820,1182951,1183243
 /cassandra/tags/cassandra-0.7.0-rc3/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1051699-1053689
 /cassandra/tags/cassandra-0.8.0-rc1/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1102511-1125020

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/CollationController.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/CollationController.java?rev=1199375&r1=1199374&r2=1199375&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/CollationController.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/CollationController.java Tue Nov  8 18:22:36
2011
@@ -59,7 +59,9 @@ public class CollationController
 
     public ColumnFamily getTopLevelColumns()
     {
-        return filter.filter instanceof NamesQueryFilter && cfs.metadata.getDefaultValidator()
!= CounterColumnType.instance
+        return filter.filter instanceof NamesQueryFilter
+               && (cfs.metadata.cfType == ColumnFamilyType.Standard || filter.path.superColumnName
!= null)
+               && cfs.metadata.getDefaultValidator() != CounterColumnType.instance
                ? collectTimeOrderedData()
                : collectAllData();
     }
@@ -95,8 +97,7 @@ public class CollationController
 
             // avoid changing the filter columns of the original filter
             // (reduceNameFilter removes columns that are known to be irrelevant)
-            TreeSet<ByteBuffer> filterColumns = new TreeSet<ByteBuffer>(cfs.metadata.comparator);
-            filterColumns.addAll(((NamesQueryFilter) filter.filter).columns);
+            TreeSet<ByteBuffer> filterColumns = new TreeSet<ByteBuffer>(((NamesQueryFilter)
filter.filter).columns);
             QueryFilter reducedFilter = new QueryFilter(filter.key, filter.path, new NamesQueryFilter(filterColumns));
 
             /* add the SSTables on disk */
@@ -181,9 +182,9 @@ public class CollationController
      */
     private void reduceNameFilter(QueryFilter filter, ColumnFamily returnCF, long sstableTimestamp)
     {
-        AbstractColumnContainer container = filter.path.superColumnName != null
-                                          ? (SuperColumn) returnCF.getColumn(filter.path.superColumnName)
-                                          : returnCF;
+        AbstractColumnContainer container = filter.path.superColumnName == null
+                                          ? returnCF
+                                          : (SuperColumn) returnCF.getColumn(filter.path.superColumnName);
         if (container == null)
             return;
 
@@ -191,7 +192,7 @@ public class CollationController
         {
             ByteBuffer filterColumn = iterator.next();
             IColumn column = container.getColumn(filterColumn);
-            if (column != null && column.minTimestamp() > sstableTimestamp)
+            if (column != null && column.timestamp() > sstableTimestamp)
                 iterator.remove();
         }
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Column.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Column.java?rev=1199375&r1=1199374&r2=1199375&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Column.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Column.java Tue Nov  8 18:22:36 2011
@@ -104,11 +104,6 @@ public class Column implements IColumn
         return timestamp;
     }
 
-    public long minTimestamp()
-    {
-        return timestamp;
-    }
-
     public boolean isMarkedForDelete()
     {
         return false;

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/IColumn.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/IColumn.java?rev=1199375&r1=1199374&r2=1199375&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/IColumn.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/IColumn.java Tue Nov  8 18:22:36 2011
@@ -81,10 +81,4 @@ public interface IColumn
      * For a super column, this is the max column timestamp of the sub columns.
      */
     public long maxTimestamp();
-
-    /**
-     * For a standard column, this is the same as timestamp().
-     * For a super column, this is the min column timestamp of the sub columns.
-     */
-    public long minTimestamp();
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java?rev=1199375&r1=1199374&r2=1199375&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/SuperColumn.java Tue Nov  8 18:22:36
2011
@@ -138,14 +138,6 @@ public class SuperColumn extends Abstrac
         return maxTimestamp;
     }
 
-    public long minTimestamp()
-    {
-        long minTimestamp = getMarkedForDeleteAt();
-        for (IColumn subColumn : getSubColumns())
-            minTimestamp = Math.min(minTimestamp, subColumn.maxTimestamp());
-        return minTimestamp;
-    }
-
     public long mostRecentLiveChangeAt()
     {
         long max = Long.MIN_VALUE;

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/TreeMapBackedSortedColumns.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/TreeMapBackedSortedColumns.java?rev=1199375&r1=1199374&r2=1199375&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/TreeMapBackedSortedColumns.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/TreeMapBackedSortedColumns.java Tue Nov
 8 18:22:36 2011
@@ -84,13 +84,21 @@ public class TreeMapBackedSortedColumns 
     public void addColumn(IColumn column, Allocator allocator)
     {
         ByteBuffer name = column.name();
+        // this is a slightly unusual way to structure this; a more natural way is shown
in ThreadSafeSortedColumns,
+        // but TreeMap lacks putAbsent.  Rather than split it into a "get, then put" check,
we do it as follows,
+        // which saves the extra "get" in the no-conflict case [for both normal and super
columns],
+        // in exchange for a re-put in the SuperColumn case.
         IColumn oldColumn = put(name, column);
         if (oldColumn != null)
         {
             if (oldColumn instanceof SuperColumn)
             {
                 assert column instanceof SuperColumn;
+                // since oldColumn is where we've been accumulating results, it's usually
going to be faster to
+                // add the new one to the old, then place old back in the Map, rather than
copy the old contents
+                // into the new Map entry.
                 ((SuperColumn) oldColumn).putColumn((SuperColumn)column, allocator);
+                put(name,  oldColumn);
             }
             else
             {

Modified: cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java?rev=1199375&r1=1199374&r2=1199375&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/SchemaLoader.java Tue Nov  8 18:22:36 2011
@@ -133,6 +133,7 @@ public class SchemaLoader
                                            superCFMD(ks1, "Super3", LongType.instance),
                                            superCFMD(ks1, "Super4", UTF8Type.instance),
                                            superCFMD(ks1, "Super5", bytes),
+                                           superCFMD(ks1, "Super6", LexicalUUIDType.instance,
UTF8Type.instance),
                                            indexCFMD(ks1, "Indexed1", true),
                                            indexCFMD(ks1, "Indexed2", false),
                                            new CFMetaData(ks1,
@@ -271,7 +272,11 @@ public class SchemaLoader
     }
     private static CFMetaData superCFMD(String ksName, String cfName, AbstractType subcc)
     {
-        return new CFMetaData(ksName, cfName, ColumnFamilyType.Super, BytesType.instance,
subcc).keyCacheSize(0);
+        return superCFMD(ksName, cfName, BytesType.instance, subcc).keyCacheSize(0);
+    }
+    private static CFMetaData superCFMD(String ksName, String cfName, AbstractType cc, AbstractType
subcc)
+    {
+        return new CFMetaData(ksName, cfName, ColumnFamilyType.Super, cc, subcc).keyCacheSize(0);
     }
     private static CFMetaData indexCFMD(String ksName, String cfName, final Boolean withIdxType)
throws ConfigurationException
     {

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=1199375&r1=1199374&r2=1199375&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java Tue Nov 
8 18:22:36 2011
@@ -35,6 +35,7 @@ import org.apache.cassandra.db.columnite
 import org.apache.cassandra.db.filter.*;
 import org.apache.cassandra.db.index.SecondaryIndex;
 import org.apache.cassandra.db.marshal.LongType;
+import org.apache.cassandra.db.marshal.LexicalUUIDType;
 import org.apache.cassandra.dht.IPartitioner;
 import org.apache.cassandra.dht.Range;
 import org.apache.cassandra.io.sstable.Component;
@@ -51,6 +52,7 @@ import static junit.framework.Assert.ass
 import static junit.framework.Assert.assertTrue;
 import static org.apache.cassandra.Util.column;
 import static org.apache.cassandra.Util.getBytes;
+import static org.apache.cassandra.db.TableTest.assertColumns;
 import static org.junit.Assert.assertNull;
 
 import org.junit.Test;
@@ -575,14 +577,14 @@ public class ColumnFamilyStoreTest exten
     {
         RowMutation rm = new RowMutation(cfs.table.name, key.key);
         ColumnFamily cf = ColumnFamily.create(cfs.table.name, cfs.getColumnFamilyName());
-        SuperColumn sc = new SuperColumn(scfName, LongType.instance);
+        SuperColumn sc = new SuperColumn(scfName, cfs.metadata.subcolumnComparator);
         for (Column col : cols)
             sc.addColumn(col);
         cf.addColumn(sc);
         rm.add(cf);
         rm.apply();
     }
-    
+
     private static void putColsStandard(ColumnFamilyStore cfs, DecoratedKey key, Column...
cols) throws Throwable
     {
         RowMutation rm = new RowMutation(cfs.table.name, key.key);
@@ -679,4 +681,60 @@ public class ColumnFamilyStoreTest exten
                 assertTrue("can not find backedup file:" + desc.filenameFor(c), new File(desc.filenameFor(c)).exists());
         }
     }
+    
+    @Test
+    public void testSuperSliceByNamesCommand() throws Throwable
+    {
+        String tableName = "Keyspace1";
+        String cfName= "Super4";
+        ByteBuffer superColName = ByteBufferUtil.bytes("HerpDerp");
+        DecoratedKey key = Util.dk("multiget-slice-resurrection");
+        Table table = Table.open(tableName);
+        ColumnFamilyStore cfs = table.getColumnFamilyStore(cfName);
+
+        // Initially create a SC with 1 subcolumn
+        putColsSuper(cfs, key, superColName, new Column(ByteBufferUtil.bytes("c1"), ByteBufferUtil.bytes("a"),
1));
+        cfs.forceBlockingFlush();
+
+        // Add another column
+        putColsSuper(cfs, key, superColName, new Column(ByteBufferUtil.bytes("c2"), ByteBufferUtil.bytes("b"),
2));
+
+        // Test fetching the supercolumn by name
+        SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(tableName, key.key, new
QueryPath(cfName), Collections.singletonList(superColName));
+        ColumnFamily cf = cmd.getRow(table).cf;
+        SuperColumn superColumn = (SuperColumn) cf.getColumn(superColName);
+        assertColumns(superColumn, "c1", "c2");
+    }
+    
+    // CASSANDRA-3467.  the key here is that supercolumn and subcolumn comparators are different
+    @Test
+    public void testSliceByNamesCommandOnUUIDTypeSCF() throws Throwable
+    {
+        String tableName = "Keyspace1";
+        String cfName = "Super6";
+        ByteBuffer superColName = LexicalUUIDType.instance.fromString("a4ed3562-0e8e-4b41-bdfd-c45a2774682d");
+        Table table = Table.open(tableName);
+        ColumnFamilyStore cfs = table.getColumnFamilyStore(cfName);
+        DecoratedKey key = Util.dk("slice-get-uuid-type");
+
+        // Insert a row with one supercolumn and multiple subcolumns
+        putColsSuper(cfs, key, superColName, new Column(ByteBufferUtil.bytes("a"), ByteBufferUtil.bytes("A"),
1),
+                                             new Column(ByteBufferUtil.bytes("b"), ByteBufferUtil.bytes("B"),
1));
+
+        // Get the entire supercolumn like normal 
+        IColumn columnGet = cfs.getColumnFamily(QueryFilter.getIdentityFilter(key, new QueryPath(cfName,
superColName))).getColumn(superColName);
+        assertEquals(ByteBufferUtil.bytes("A"), columnGet.getSubColumn(ByteBufferUtil.bytes("a")).value());
+        assertEquals(ByteBufferUtil.bytes("B"), columnGet.getSubColumn(ByteBufferUtil.bytes("b")).value());
+
+        // Now do the SliceByNamesCommand on the supercolumn, passing both subcolumns in
as columns to get 
+        ArrayList<ByteBuffer> sliceColNames = new ArrayList<ByteBuffer>();
+        sliceColNames.add(ByteBufferUtil.bytes("a"));
+        sliceColNames.add(ByteBufferUtil.bytes("b"));
+        SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(tableName, key.key, new
QueryPath(cfName, superColName), sliceColNames);
+        IColumn columnSliced = cmd.getRow(table).cf.getColumn(superColName);
+
+        // Make sure the slice returns the same as the straight get 
+        assertEquals(ByteBufferUtil.bytes("A"), columnSliced.getSubColumn(ByteBufferUtil.bytes("a")).value());
+        assertEquals(ByteBufferUtil.bytes("B"), columnSliced.getSubColumn(ByteBufferUtil.bytes("b")).value());
+    }
 }

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java?rev=1199375&r1=1199374&r2=1199375&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyTest.java Tue Nov  8 18:22:36
2011
@@ -30,13 +30,15 @@ import org.junit.Test;
 import org.apache.cassandra.io.util.DataOutputBuffer;
 import org.apache.cassandra.db.filter.QueryPath;
 import static org.apache.cassandra.Util.column;
+import static org.junit.Assert.assertEquals;
+
 import org.apache.cassandra.utils.ByteBufferUtil;
 import org.apache.cassandra.utils.HeapAllocator;
 
 
 public class ColumnFamilyTest extends SchemaLoader
 {
-    // TODO test SuperColumns
+    // TODO test SuperColumns more
 
     @Test
     public void testSingleColumn() throws IOException
@@ -146,4 +148,34 @@ public class ColumnFamilyTest extends Sc
         cf_result.addColumn(QueryPath.column(ByteBufferUtil.bytes("col3")), ByteBufferUtil.bytes("z"),
2);
         assert cf_result.getColumn(ByteBufferUtil.bytes("col3")).value().equals(ByteBufferUtil.bytes("z"));
     }
+
+    private void testSuperColumnResolution(ISortedColumns.Factory factory)
+    {
+        ColumnFamilyStore cfs = Table.open("Keyspace1").getColumnFamilyStore("Super1");
+        ColumnFamily cf = ColumnFamily.create(cfs.metadata, factory);
+        ByteBuffer superColumnName = ByteBufferUtil.bytes("sc");
+        ByteBuffer subColumnName = ByteBufferUtil.bytes(1L);
+
+        Column first = new Column(subColumnName, ByteBufferUtil.bytes("one"), 1L);
+        Column second = new Column(subColumnName, ByteBufferUtil.bytes("two"), 2L);
+
+        cf.addColumn(superColumnName, first);
+
+        // resolve older + new
+        cf.addColumn(superColumnName, second);
+        assertEquals(second, cf.getColumn(superColumnName).getSubColumn(subColumnName));
+
+        // resolve new + older
+        cf.addColumn(superColumnName, first);
+        assertEquals(second, cf.getColumn(superColumnName).getSubColumn(subColumnName));
+    }
+
+    @Test
+    public void testSuperColumnResolution()
+    {
+        testSuperColumnResolution(TreeMapBackedSortedColumns.factory());
+        testSuperColumnResolution(ThreadSafeSortedColumns.factory());
+        // array-sorted does allow conflict resolution IF it is the last column.  Bit of
an edge case.
+        testSuperColumnResolution(ArrayBackedSortedColumns.factory());
+    }
 }

Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java?rev=1199375&r1=1199374&r2=1199375&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java Tue Nov  8 18:22:36 2011
@@ -542,17 +542,10 @@ public class TableTest extends CleanupHe
 
         String[] columnNames1 = names.toArray(new String[0]);
         String[] la = L.toArray(new String[columns.size()]);
-        StringBuffer lasb = new StringBuffer();
-        for (String l: la)
-        {
-            lasb.append(l);
-            lasb.append(", ");
-        }
 
         assert Arrays.equals(la, columnNames1)
-                : String.format("Columns [%s(as string: %s)])] is not expected [%s]",
+                : String.format("Columns [%s])] is not expected [%s]",
                                 ((container == null) ? "" : container.getComparator().getColumnsString(columns)),
-                                lasb.toString(),
                                 StringUtils.join(columnNames1, ","));
     }
 
@@ -573,6 +566,4 @@ public class TableTest extends CleanupHe
         assertEquals(0, ByteBufferUtil.compareUnsigned(column.value(), ByteBufferUtil.bytes(value)));
         assertEquals(timestamp, column.timestamp());
     }
-
-
 }



Mime
View raw message