cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdusba...@apache.org
Subject svn commit: r934154 [3/3] - in /cassandra/trunk: src/java/org/apache/cassandra/avro/ src/java/org/apache/cassandra/client/ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/db/filter/ src/java/org/apache/cassandra/db/migration/ src/java/o...
Date Wed, 14 Apr 2010 19:53:07 GMT
Modified: cassandra/trunk/test/unit/org/apache/cassandra/db/TimeSortTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/db/TimeSortTest.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/db/TimeSortTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/db/TimeSortTest.java Wed Apr 14 19:53:06
2010
@@ -28,6 +28,7 @@ import static org.junit.Assert.assertEqu
 
 import org.apache.cassandra.CleanupHelper;
 import static org.apache.cassandra.Util.getBytes;
+import org.apache.cassandra.Util;
 
 import org.apache.cassandra.db.filter.QueryFilter;
 import org.apache.cassandra.db.filter.QueryPath;
@@ -42,17 +43,18 @@ public class TimeSortTest extends Cleanu
         Table table = Table.open("Keyspace1");
         ColumnFamilyStore cfStore = table.getColumnFamilyStore("StandardLong1");
         RowMutation rm;
+        DecoratedKey key = Util.dk("key0");
 
-        rm = new RowMutation("Keyspace1", "key0");
+        rm = new RowMutation("Keyspace1", key.key);
         rm.add(new QueryPath("StandardLong1", null, getBytes(100)), "a".getBytes(), 100);
         rm.apply();
         cfStore.forceBlockingFlush();
 
-        rm = new RowMutation("Keyspace1", "key0");
+        rm = new RowMutation("Keyspace1", key.key);
         rm.add(new QueryPath("StandardLong1", null, getBytes(0)), "b".getBytes(), 0);
         rm.apply();
 
-        ColumnFamily cf = cfStore.getColumnFamily("key0", new QueryPath("StandardLong1"),
getBytes(10), ArrayUtils.EMPTY_BYTE_ARRAY, false, 1000);
+        ColumnFamily cf = cfStore.getColumnFamily(key, new QueryPath("StandardLong1"), getBytes(10),
ArrayUtils.EMPTY_BYTE_ARRAY, false, 1000);
         Collection<IColumn> columns = cf.getSortedColumns();
         assert columns.size() == 1;
     }
@@ -65,7 +67,7 @@ public class TimeSortTest extends Cleanu
 
         for (int i = 900; i < 1000; ++i)
         {
-            RowMutation rm = new RowMutation("Keyspace1", Integer.toString(i));
+            RowMutation rm = new RowMutation("Keyspace1", Integer.toString(i).getBytes());
             for (int j = 0; j < 8; ++j)
             {
                 rm.add(new QueryPath("StandardLong1", null, getBytes(j * 2)), "a".getBytes(),
j * 2);
@@ -79,15 +81,15 @@ public class TimeSortTest extends Cleanu
         validateTimeSort(table);
 
         // interleave some new data to test memtable + sstable
-        String key = "900";
-        RowMutation rm = new RowMutation("Keyspace1", key);
+        DecoratedKey key = Util.dk("900");
+        RowMutation rm = new RowMutation("Keyspace1", key.key);
         for (int j = 0; j < 4; ++j)
         {
             rm.add(new QueryPath("StandardLong1", null, getBytes(j * 2 + 1)), "b".getBytes(),
j * 2 + 1);
         }
         rm.apply();
         // and some overwrites
-        rm = new RowMutation("Keyspace1", key);
+        rm = new RowMutation("Keyspace1", key.key);
         rm.add(new QueryPath("StandardLong1", null, getBytes(0)), "c".getBytes(), 100);
         rm.add(new QueryPath("StandardLong1", null, getBytes(10)), "c".getBytes(), 100);
         rm.apply();
@@ -106,7 +108,7 @@ public class TimeSortTest extends Cleanu
         TreeSet<byte[]> columnNames = new TreeSet<byte[]>(new LongType());
         columnNames.add(getBytes(10));
         columnNames.add(getBytes(0));
-        cf = cfStore.getColumnFamily(QueryFilter.getNamesFilter("900", new QueryPath("StandardLong1"),
columnNames));
+        cf = cfStore.getColumnFamily(QueryFilter.getNamesFilter(Util.dk("900"), new QueryPath("StandardLong1"),
columnNames));
         assert "c".equals(new String(cf.getColumn(getBytes(0)).value()));
         assert "c".equals(new String(cf.getColumn(getBytes(10)).value()));
     }
@@ -115,7 +117,7 @@ public class TimeSortTest extends Cleanu
     {
         for (int i = 900; i < 1000; ++i)
         {
-            String key = Integer.toString(i);
+            DecoratedKey key = Util.dk(Integer.toString(i));
             for (int j = 0; j < 8; j += 3)
             {
                 ColumnFamily cf = table.getColumnFamilyStore("StandardLong1").getColumnFamily(key,
new QueryPath("StandardLong1"), getBytes(j * 2), ArrayUtils.EMPTY_BYTE_ARRAY, false, 1000);

Modified: cassandra/trunk/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java Wed Apr 14
19:53:06 2010
@@ -40,7 +40,7 @@ public abstract class PartitionerTestCas
 
     public T tok(String string)
     {
-        return partitioner.getToken(string);
+        return partitioner.getToken(string.getBytes());
     }
 
     /**
@@ -97,7 +97,7 @@ public abstract class PartitionerTestCas
     @Test
     public void testDiskFormat()
     {
-        String key = "key";
+        byte[] key = "key".getBytes();
         DecoratedKey<T> decKey = partitioner.decorateKey(key);
         DecoratedKey<T> result = partitioner.convertFromDiskFormat(partitioner.convertToDiskFormat(decKey));
         assertEquals(decKey, result);

Modified: cassandra/trunk/test/unit/org/apache/cassandra/io/StreamingTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/io/StreamingTest.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/io/StreamingTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/io/StreamingTest.java Wed Apr 14 19:53:06
2010
@@ -57,6 +57,6 @@ public class StreamingTest extends Clean
         ColumnFamilyStore cfstore = Table.open(tablename).getColumnFamilyStore(cfname);
         RangeSliceReply rr = Util.getRangeSlice(cfstore);
         assert rr.rows.size() == 1;
-        assert rr.rows.get(0).key.equals("key");
+        assert Arrays.equals(rr.rows.get(0).key.key, "key".getBytes());
     }
 }

Modified: cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java Wed Apr
14 19:53:06 2010
@@ -30,6 +30,7 @@ import static org.junit.Assert.*;
 import org.apache.cassandra.CleanupHelper;
 import org.apache.cassandra.io.util.BufferedRandomAccessFile;
 import org.apache.cassandra.db.DecoratedKey;
+import org.apache.cassandra.utils.FBUtilities;
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
@@ -44,7 +45,7 @@ public class LegacySSTableTest extends C
     public static final String KSNAME = "Keyspace1";
     public static final String CFNAME = "Standard1";
 
-    public static SortedMap<String, byte[]> TEST_DATA;
+    public static Map<byte[], byte[]> TEST_DATA;
     public static File LEGACY_SSTABLE_ROOT;
 
     @BeforeClass
@@ -55,10 +56,10 @@ public class LegacySSTableTest extends C
         LEGACY_SSTABLE_ROOT = new File(scp);
         assert LEGACY_SSTABLE_ROOT.isDirectory();
 
-        TEST_DATA = new TreeMap<String,byte[]>();
-        for ( int i = 100; i < 1000; ++i )
+        TEST_DATA = new HashMap<byte[],byte[]>();
+        for (int i = 100; i < 1000; ++i)
         {
-            TEST_DATA.put(Integer.toString(i), ("Avinash Lakshman is a good man: " + i).getBytes());
+            TEST_DATA.put(Integer.toString(i).getBytes(), ("Avinash Lakshman is a good man:
" + i).getBytes());
         }
     }
 
@@ -100,14 +101,14 @@ public class LegacySSTableTest extends C
     {
         SSTableReader reader = SSTableReader.open(getDescriptor("b"));
 
-        List<String> keys = new ArrayList<String>(TEST_DATA.keySet());
+        List<byte[]> keys = new ArrayList<byte[]>(TEST_DATA.keySet());
         Collections.shuffle(keys);
         BufferedRandomAccessFile file = new BufferedRandomAccessFile(reader.getFilename(),
"r");
-        for (String key : keys)
+        for (byte[] key : keys)
         {
             // confirm that the bloom filter does not reject any keys
             file.seek(reader.getPosition(reader.partitioner.decorateKey(key)).position);
-            assert key.equals(file.readUTF());
+            assert Arrays.equals(key, FBUtilities.readShortByteArray(file));
         }
     }
 }

Modified: cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java Wed Apr
14 19:53:06 2010
@@ -15,6 +15,7 @@ import org.apache.cassandra.io.util.File
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.FBUtilities;
 
+import org.apache.cassandra.Util;
 
 public class SSTableReaderTest extends CleanupHelper
 {
@@ -30,7 +31,7 @@ public class SSTableReaderTest extends C
         CompactionManager.instance.disableAutoCompaction();
         for (int j = 0; j < 100; j += 2)
         {
-            String key = String.valueOf(j);
+            byte[] key = String.valueOf(j).getBytes();
             RowMutation rm = new RowMutation("Keyspace1", key);
             rm.add(new QueryPath("Standard1", null, "0".getBytes()), new byte[0], j);
             rm.apply();
@@ -42,8 +43,7 @@ public class SSTableReaderTest extends C
         SSTableReader sstable = store.getSSTables().iterator().next();
         for (int j = 0; j < 100; j += 2)
         {
-            String key = String.valueOf(j);
-            DecoratedKey dk = StorageService.getPartitioner().decorateKey(key);
+            DecoratedKey dk = Util.dk(String.valueOf(j));
             FileDataInput file = sstable.getFileDataInput(dk, DatabaseDescriptor.getIndexedReadBufferSizeInKB()
* 1024);
             DecoratedKey keyInDisk = sstable.getPartitioner().convertFromDiskFormat(FBUtilities.readShortByteArray(file));
             assert keyInDisk.equals(dk) : String.format("%s != %s in %s", keyInDisk, dk,
file.getPath());
@@ -52,8 +52,7 @@ public class SSTableReaderTest extends C
         // check no false positives
         for (int j = 1; j < 110; j += 2)
         {
-            String key = String.valueOf(j);
-            DecoratedKey dk = StorageService.getPartitioner().decorateKey(key);
+            DecoratedKey dk = Util.dk(String.valueOf(j));
             assert sstable.getPosition(dk) == null;
         }
     }

Modified: cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableTest.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableTest.java Wed Apr 14
19:53:06 2010
@@ -29,6 +29,7 @@ import static org.junit.Assert.*;
 import org.apache.cassandra.CleanupHelper;
 import org.apache.cassandra.io.util.BufferedRandomAccessFile;
 import org.apache.cassandra.db.DecoratedKey;
+import org.apache.cassandra.utils.FBUtilities;
 
 import com.google.common.base.Predicate;
 import com.google.common.base.Predicates;
@@ -38,11 +39,11 @@ public class SSTableTest extends Cleanup
     @Test
     public void testSingleWrite() throws IOException {
         // write test data
-        String key = Integer.toString(1);
+        byte[] key = Integer.toString(1).getBytes();
         byte[] bytes = new byte[1024];
         new Random().nextBytes(bytes);
 
-        TreeMap<String, byte[]> map = new TreeMap<String,byte[]>();
+        Map<byte[], byte[]> map = new HashMap<byte[],byte[]>();
         map.put(key, bytes);
         SSTableReader ssTable = SSTableUtils.writeRawSSTable("Keyspace1", "Standard1", map);
 
@@ -52,11 +53,11 @@ public class SSTableTest extends Cleanup
         verifySingle(ssTable, bytes, key);
     }
 
-    private void verifySingle(SSTableReader sstable, byte[] bytes, String key) throws IOException
+    private void verifySingle(SSTableReader sstable, byte[] bytes, byte[] key) throws IOException
     {
         BufferedRandomAccessFile file = new BufferedRandomAccessFile(sstable.getFilename(),
"r");
         file.seek(sstable.getPosition(sstable.partitioner.decorateKey(key)).position);
-        assert key.equals(file.readUTF());
+        assert Arrays.equals(key, FBUtilities.readShortByteArray(file));
         int size = file.readInt();
         byte[] bytes2 = new byte[size];
         file.readFully(bytes2);
@@ -65,10 +66,10 @@ public class SSTableTest extends Cleanup
 
     @Test
     public void testManyWrites() throws IOException {
-        TreeMap<String, byte[]> map = new TreeMap<String,byte[]>();
-        for ( int i = 100; i < 1000; ++i )
+        Map<byte[], byte[]> map = new HashMap<byte[],byte[]>();
+        for (int i = 100; i < 1000; ++i)
         {
-            map.put(Integer.toString(i), ("Avinash Lakshman is a good man: " + i).getBytes());
+            map.put(Integer.toString(i).getBytes(), ("Avinash Lakshman is a good man: " +
i).getBytes());
         }
 
         // write
@@ -80,15 +81,15 @@ public class SSTableTest extends Cleanup
         verifyMany(ssTable, map);
     }
 
-    private void verifyMany(SSTableReader sstable, TreeMap<String, byte[]> map) throws
IOException
+    private void verifyMany(SSTableReader sstable, Map<byte[], byte[]> map) throws
IOException
     {
-        List<String> keys = new ArrayList<String>(map.keySet());
+        List<byte[]> keys = new ArrayList<byte[]>(map.keySet());
         Collections.shuffle(keys);
         BufferedRandomAccessFile file = new BufferedRandomAccessFile(sstable.getFilename(),
"r");
-        for (String key : keys)
+        for (byte[] key : keys)
         {
             file.seek(sstable.getPosition(sstable.partitioner.decorateKey(key)).position);
-            assert key.equals(file.readUTF());
+            assert Arrays.equals(key, FBUtilities.readShortByteArray(file));
             int size = file.readInt();
             byte[] bytes2 = new byte[size];
             file.readFully(bytes2);

Modified: cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java Wed Apr 14
19:53:06 2010
@@ -22,16 +22,10 @@ package org.apache.cassandra.io.sstable;
 import java.io.File;
 import java.io.IOException;
 
-import java.util.Map;
-import java.util.SortedMap;
-import java.util.Set;
-import java.util.TreeMap;
+import java.util.*;
 
 import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.db.Column;
-import org.apache.cassandra.db.IColumn;
-import org.apache.cassandra.db.ColumnFamily;
-import org.apache.cassandra.db.Table;
+import org.apache.cassandra.db.*;
 import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.io.util.DataOutputBuffer;
 
@@ -68,7 +62,7 @@ public class SSTableUtils
 
     public static SSTableReader writeSSTable(Set<String> keys) throws IOException
     {
-        TreeMap<String, ColumnFamily> map = new TreeMap<String, ColumnFamily>();
+        Map<String, ColumnFamily> map = new HashMap<String, ColumnFamily>();
         for (String key : keys)
         {
             ColumnFamily cf = ColumnFamily.create(TABLENAME, CFNAME);
@@ -78,24 +72,24 @@ public class SSTableUtils
         return writeSSTable(map);
     }
 
-    public static SSTableReader writeSSTable(SortedMap<String, ColumnFamily> entries)
throws IOException
+    public static SSTableReader writeSSTable(Map<String, ColumnFamily> entries) throws
IOException
     {
-        TreeMap<String, byte[]> map = new TreeMap<String, byte[]>();
+        Map<byte[], byte[]> map = new HashMap<byte[], byte[]>();
         for (Map.Entry<String, ColumnFamily> entry : entries.entrySet())
         {
             DataOutputBuffer buffer = new DataOutputBuffer();
             ColumnFamily.serializer().serializeWithIndexes(entry.getValue(), buffer);
-            map.put(entry.getKey(), buffer.getData());
+            map.put(entry.getKey().getBytes(), buffer.getData());
         }
         return writeRawSSTable(TABLENAME, CFNAME, map);
     }
 
-    public static SSTableReader writeRawSSTable(String tablename, String cfname, SortedMap<String,
byte[]> entries) throws IOException
+    public static SSTableReader writeRawSSTable(String tablename, String cfname, Map<byte[],
byte[]> entries) throws IOException
     {
         return writeRawSSTable(null, tablename, cfname, entries);
     }
 
-    public static SSTableReader writeRawSSTable(File datafile, String tablename, String cfname,
SortedMap<String, byte[]> entries) throws IOException
+    public static SSTableReader writeRawSSTable(File datafile, String tablename, String cfname,
Map<byte[], byte[]> entries) throws IOException
     {
         boolean temporary = false;
         if (datafile == null)
@@ -104,9 +98,11 @@ public class SSTableUtils
             temporary = true;
         }
         SSTableWriter writer = new SSTableWriter(datafile.getAbsolutePath(), entries.size(),
StorageService.getPartitioner());
-        for (Map.Entry<String, byte[]> entry : entries.entrySet())
-            writer.append(writer.partitioner.decorateKey(entry.getKey()),
-                          entry.getValue());
+        SortedMap<DecoratedKey, byte[]> sortedEntries = new TreeMap<DecoratedKey,
byte[]>();
+        for (Map.Entry<byte[], byte[]> entry : entries.entrySet())
+            sortedEntries.put(writer.partitioner.decorateKey(entry.getKey()), entry.getValue());
+        for (Map.Entry<DecoratedKey, byte[]> entry : sortedEntries.entrySet())
+            writer.append(entry.getKey(), entry.getValue());
         if (temporary)
         {
             new File(writer.indexFilename()).deleteOnExit();

Modified: cassandra/trunk/test/unit/org/apache/cassandra/locator/RackUnawareStrategyTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/locator/RackUnawareStrategyTest.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/locator/RackUnawareStrategyTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/locator/RackUnawareStrategyTest.java Wed
Apr 14 19:53:06 2010
@@ -86,7 +86,7 @@ public class RackUnawareStrategyTest ext
         List<Token> keyTokens = new ArrayList<Token>();
         for (int i = 0; i < 5; i++) {
             endPointTokens.add(new StringToken(String.valueOf((char)('a' + i * 2))));
-            keyTokens.add(partitioner.getToken(String.valueOf((char)('a' + i * 2 + 1))));
+            keyTokens.add(partitioner.getToken(String.valueOf((char)('a' + i * 2 + 1)).getBytes()));
         }
         for (String table : DatabaseDescriptor.getNonSystemTables())
             testGetEndpoints(tmd, strategy, endPointTokens.toArray(new Token[0]), keyTokens.toArray(new
Token[0]), table);

Modified: cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java Wed
Apr 14 19:53:06 2010
@@ -107,7 +107,7 @@ public class AntiEntropyServiceTest exte
         // write
         List<RowMutation> rms = new LinkedList<RowMutation>();
         RowMutation rm;
-        rm = new RowMutation(tablename, "key1");
+        rm = new RowMutation(tablename, "key1".getBytes());
         rm.add(new QueryPath(cfname, null, "Column1".getBytes()), "asdf".getBytes(), 0);
         rms.add(rm);
         Util.writeColumnFamily(rms);
@@ -165,7 +165,7 @@ public class AntiEntropyServiceTest exte
     {
         // populate column family
         List<RowMutation> rms = new LinkedList<RowMutation>();
-        RowMutation rm = new RowMutation(tablename, "key");
+        RowMutation rm = new RowMutation(tablename, "key".getBytes());
         rm.add(new QueryPath(cfname, null, "Column1".getBytes()), "asdf".getBytes(), 0);
         rms.add(rm);
         // with two SSTables

Modified: cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java Wed Apr 14
19:53:06 2010
@@ -38,6 +38,8 @@ import static org.apache.cassandra.io.ss
 import static org.apache.cassandra.utils.FBUtilities.hexToBytes;
 import static org.junit.Assert.assertTrue;
 
+import org.apache.cassandra.Util;
+
 import org.json.simple.JSONArray;
 import org.json.simple.JSONObject;
 import org.json.simple.JSONValue;
@@ -58,14 +60,14 @@ public class SSTableExportTest extends S
         // Add rowA
         cfamily.addColumn(new QueryPath("Standard1", null, "colA".getBytes()), "valA".getBytes(),
1, false);
         ColumnFamily.serializer().serializeWithIndexes(cfamily, dob);
-        writer.append(partitioner.decorateKey("rowA"), dob);
+        writer.append(Util.dk("rowA"), dob);
         dob.reset();
         cfamily.clear();
         
         // Add rowB
         cfamily.addColumn(new QueryPath("Standard1", null, "colB".getBytes()), "valB".getBytes(),
1, false);
         ColumnFamily.serializer().serializeWithIndexes(cfamily, dob);
-        writer.append(partitioner.decorateKey("rowB"), dob);
+        writer.append(Util.dk("rowB"), dob);
         dob.reset();
         cfamily.clear();
      
@@ -82,6 +84,7 @@ public class SSTableExportTest extends S
         String output = new String(buf);
 
         String sep = System.getProperty("line.separator");
+        // FIXME: string keys
         assert output.equals("rowA" + sep + "rowB" + sep) : output;
     }
 
@@ -96,21 +99,21 @@ public class SSTableExportTest extends S
         // Add rowA
         cfamily.addColumn(new QueryPath("Standard1", null, "colA".getBytes()), "valA".getBytes(),
1, false);
         ColumnFamily.serializer().serializeWithIndexes(cfamily, dob);
-        writer.append(partitioner.decorateKey("rowA"), dob);
+        writer.append(Util.dk("rowA"), dob);
         dob.reset();
         cfamily.clear();
         
         // Add rowB
         cfamily.addColumn(new QueryPath("Standard1", null, "colB".getBytes()), "valB".getBytes(),
1, false);
         ColumnFamily.serializer().serializeWithIndexes(cfamily, dob);
-        writer.append(partitioner.decorateKey("rowB"), dob);
+        writer.append(Util.dk("rowB"), dob);
         dob.reset();
         cfamily.clear();
 
         // Add rowExclude
         cfamily.addColumn(new QueryPath("Standard1", null, "colX".getBytes()), "valX".getBytes(),
1, false);
         ColumnFamily.serializer().serializeWithIndexes(cfamily, dob);
-        writer.append(partitioner.decorateKey("rowExclude"), dob);
+        writer.append(Util.dk("rowExclude"), dob);
         dob.reset();
         cfamily.clear();
 
@@ -122,6 +125,7 @@ public class SSTableExportTest extends S
         
         JSONObject json = (JSONObject)JSONValue.parse(new FileReader(tempJson));
         
+        // FIXME: string keys
         JSONArray rowA = (JSONArray)json.get("rowA");
         JSONArray colA = (JSONArray)rowA.get(0);
         assert Arrays.equals(hexToBytes((String)colA.get(1)), "valA".getBytes());
@@ -146,21 +150,21 @@ public class SSTableExportTest extends S
         // Add rowA
         cfamily.addColumn(new QueryPath("Super4", "superA".getBytes(), "colA".getBytes()),
"valA".getBytes(), 1, false);
         ColumnFamily.serializer().serializeWithIndexes(cfamily, dob);
-        writer.append(partitioner.decorateKey("rowA"), dob);
+        writer.append(Util.dk("rowA"), dob);
         dob.reset();
         cfamily.clear();
         
         // Add rowB
         cfamily.addColumn(new QueryPath("Super4", "superB".getBytes(), "colB".getBytes()),
"valB".getBytes(), 1, false);
         ColumnFamily.serializer().serializeWithIndexes(cfamily, dob);
-        writer.append(partitioner.decorateKey("rowB"), dob);
+        writer.append(Util.dk("rowB"), dob);
         dob.reset();
         cfamily.clear();
 
         // Add rowExclude
         cfamily.addColumn(new QueryPath("Super4", "superX".getBytes(), "colX".getBytes()),
"valX".getBytes(), 1, false);
         ColumnFamily.serializer().serializeWithIndexes(cfamily, dob);
-        writer.append(partitioner.decorateKey("rowExclude"), dob);
+        writer.append(Util.dk("rowExclude"), dob);
         dob.reset();
         cfamily.clear();
 
@@ -194,14 +198,14 @@ public class SSTableExportTest extends S
         // Add rowA
         cfamily.addColumn(new QueryPath("Standard1", null, "name".getBytes()), "val".getBytes(),
1, false);
         ColumnFamily.serializer().serializeWithIndexes(cfamily, dob);
-        writer.append(partitioner.decorateKey("rowA"), dob);
+        writer.append(Util.dk("rowA"), dob);
         dob.reset();
         cfamily.clear();
 
         // Add rowExclude
         cfamily.addColumn(new QueryPath("Standard1", null, "name".getBytes()), "val".getBytes(),
1, false);
         ColumnFamily.serializer().serializeWithIndexes(cfamily, dob);
-        writer.append(partitioner.decorateKey("rowExclude"), dob);
+        writer.append(Util.dk("rowExclude"), dob);
         dob.reset();
         cfamily.clear();
 
@@ -216,15 +220,13 @@ public class SSTableExportTest extends S
         SSTableImport.importJson(tempJson.getPath(), "Keyspace1", "Standard1", tempSS2.getPath());
       
         
         reader = SSTableReader.open(tempSS2.getPath(), DatabaseDescriptor.getPartitioner());
-        QueryFilter qf = QueryFilter.getNamesFilter("rowA", new QueryPath("Standard1", null,
null), "name".getBytes());
+        QueryFilter qf = QueryFilter.getNamesFilter(Util.dk("rowA"), new QueryPath("Standard1",
null, null), "name".getBytes());
         ColumnFamily cf = qf.getSSTableColumnIterator(reader).getColumnFamily();
         assertTrue(cf != null);
         assertTrue(Arrays.equals(cf.getColumn("name".getBytes()).value(), hexToBytes("76616c")));
 
-        qf = QueryFilter.getNamesFilter("rowExclude", new QueryPath("Standard1", null, null),
"name".getBytes());
+        qf = QueryFilter.getNamesFilter(Util.dk("rowExclude"), new QueryPath("Standard1",
null, null), "name".getBytes());
         cf = qf.getSSTableColumnIterator(reader).getColumnFamily();
         assert cf == null;
-
     }
-    
 }

Modified: cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableImportTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableImportTest.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableImportTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableImportTest.java Wed Apr 14
19:53:06 2010
@@ -32,6 +32,9 @@ import org.apache.cassandra.db.filter.Qu
 import org.apache.cassandra.io.sstable.SSTableReader;
 import static org.apache.cassandra.utils.FBUtilities.hexToBytes;
 import static org.apache.cassandra.io.sstable.SSTableUtils.tempSSTableFile;
+
+import org.apache.cassandra.Util;
+
 import org.json.simple.parser.ParseException;
 import org.junit.Test;
 
@@ -47,7 +50,7 @@ public class SSTableImportTest extends S
 
         // Verify results
         SSTableReader reader = SSTableReader.open(tempSS.getPath(), DatabaseDescriptor.getPartitioner());
-        QueryFilter qf = QueryFilter.getNamesFilter("rowA", new QueryPath("Standard1", null,
null), "colAA".getBytes());
+        QueryFilter qf = QueryFilter.getNamesFilter(Util.dk("rowA"), new QueryPath("Standard1",
null, null), "colAA".getBytes());
         ColumnFamily cf = qf.getSSTableColumnIterator(reader).getColumnFamily();
         assert Arrays.equals(cf.getColumn("colAA".getBytes()).value(), hexToBytes("76616c4141"));
     }
@@ -61,7 +64,7 @@ public class SSTableImportTest extends S
         
         // Verify results
         SSTableReader reader = SSTableReader.open(tempSS.getPath(), DatabaseDescriptor.getPartitioner());
-        QueryFilter qf = QueryFilter.getNamesFilter("rowA", new QueryPath("Super4", null,
null), "superA".getBytes());
+        QueryFilter qf = QueryFilter.getNamesFilter(Util.dk("rowA"), new QueryPath("Super4",
null, null), "superA".getBytes());
         ColumnFamily cf = qf.getSSTableColumnIterator(reader).getColumnFamily();
         IColumn superCol = cf.getColumn("superA".getBytes());
         assert Arrays.equals(superCol.getSubColumn("colAA".getBytes()).value(), hexToBytes("76616c75654141"));



Mime
View raw message