cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1199369 - in /cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra: SchemaLoader.java db/ColumnFamilyStoreTest.java
Date Tue, 08 Nov 2011 18:01:30 GMT
Author: jbellis
Date: Tue Nov  8 18:01:30 2011
New Revision: 1199369

URL: http://svn.apache.org/viewvc?rev=1199369&view=rev
Log:
add test for CASSANDRA-3467 (which was fixed by #3446)
patch by Rick Branson; reviewed by jbellis for CASSANDRA-3467

Modified:
    cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/SchemaLoader.java
    cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java

Modified: cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/SchemaLoader.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/SchemaLoader.java?rev=1199369&r1=1199368&r2=1199369&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/SchemaLoader.java (original)
+++ cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/SchemaLoader.java Tue
Nov  8 18:01:30 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/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java?rev=1199369&r1=1199368&r2=1199369&view=diff
==============================================================================
--- cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
(original)
+++ cassandra/branches/cassandra-1.0/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
Tue Nov  8 18:01:30 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;
@@ -682,7 +683,7 @@ public class ColumnFamilyStoreTest exten
     }
     
     @Test
-    public void testSuperSliceByNamesCommandOn() throws Throwable
+    public void testSuperSliceByNamesCommand() throws Throwable
     {
         String tableName = "Keyspace1";
         String cfName= "Super4";
@@ -704,4 +705,36 @@ public class ColumnFamilyStoreTest exten
         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());
+    }
 }



Mime
View raw message