cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdusba...@apache.org
Subject svn commit: r934154 [1/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
Author: gdusbabek
Date: Wed Apr 14 19:53:06 2010
New Revision: 934154

URL: http://svn.apache.org/viewvc?rev=934154&view=rev
Log:
byte for decorateKey and getToken in IPartitioner. Patch by Stu Hood, reviewed by Gary Dusbabek. CASSANDRA-767

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java
    cassandra/trunk/src/java/org/apache/cassandra/client/RingCache.java
    cassandra/trunk/src/java/org/apache/cassandra/db/BinaryMemtable.java
    cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
    cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java
    cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java
    cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java
    cassandra/trunk/src/java/org/apache/cassandra/db/ReadCommand.java
    cassandra/trunk/src/java/org/apache/cassandra/db/Row.java
    cassandra/trunk/src/java/org/apache/cassandra/db/RowIteratorFactory.java
    cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java
    cassandra/trunk/src/java/org/apache/cassandra/db/RowMutationVerbHandler.java
    cassandra/trunk/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java
    cassandra/trunk/src/java/org/apache/cassandra/db/SliceFromReadCommand.java
    cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java
    cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
    cassandra/trunk/src/java/org/apache/cassandra/db/WriteResponse.java
    cassandra/trunk/src/java/org/apache/cassandra/db/filter/IFilter.java
    cassandra/trunk/src/java/org/apache/cassandra/db/filter/IdentityQueryFilter.java
    cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
    cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java
    cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java
    cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
    cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
    cassandra/trunk/src/java/org/apache/cassandra/db/migration/Migration.java
    cassandra/trunk/src/java/org/apache/cassandra/dht/CollatingOrderPreservingPartitioner.java
    cassandra/trunk/src/java/org/apache/cassandra/dht/IPartitioner.java
    cassandra/trunk/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java
    cassandra/trunk/src/java/org/apache/cassandra/dht/RandomPartitioner.java
    cassandra/trunk/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java
    cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableTracker.java
    cassandra/trunk/src/java/org/apache/cassandra/service/RangeSliceResponseResolver.java
    cassandra/trunk/src/java/org/apache/cassandra/service/ReadResponseResolver.java
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
    cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java
    cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java
    cassandra/trunk/src/java/org/apache/cassandra/thrift/ThriftValidation.java
    cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java
    cassandra/trunk/src/java/org/apache/cassandra/tools/SSTableExport.java
    cassandra/trunk/src/java/org/apache/cassandra/tools/SSTableImport.java
    cassandra/trunk/src/java/org/apache/cassandra/utils/FBUtilities.java
    cassandra/trunk/test/unit/org/apache/cassandra/Util.java
    cassandra/trunk/test/unit/org/apache/cassandra/client/TestRingCache.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/ColumnFamilyStoreTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/CommitLogTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/CompactionsPurgeTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/CompactionsTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/DefsTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/MultitableTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/NameSortTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/OneCompactionTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/ReadMessageTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/RecoveryManager2Test.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/RecoveryManagerTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush1Test.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnFamilyWithFlush2Test.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveColumnTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSubColumnTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/RemoveSuperColumnTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/SystemTableTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/TableTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/db/TimeSortTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/dht/PartitionerTestCase.java
    cassandra/trunk/test/unit/org/apache/cassandra/io/StreamingTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/LegacySSTableTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableReaderTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/io/sstable/SSTableUtils.java
    cassandra/trunk/test/unit/org/apache/cassandra/locator/RackUnawareStrategyTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/service/AntiEntropyServiceTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableExportTest.java
    cassandra/trunk/test/unit/org/apache/cassandra/tools/SSTableImportTest.java

Modified: cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java Wed Apr 14 19:53:06 2010
@@ -45,6 +45,7 @@ import org.apache.cassandra.db.SliceByNa
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.db.marshal.MarshalException;
 import org.apache.cassandra.service.StorageProxy;
+import static org.apache.cassandra.utils.FBUtilities.UTF8;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import static org.apache.cassandra.avro.AvroRecordFactory.*;
@@ -87,7 +88,8 @@ public class CassandraServer implements 
         for (String key: keys)
         {
             AvroValidation.validateKey(key);
-            commands.add(new SliceByNamesReadCommand(keyspace, key, path, nameAsList));
+            // FIXME: string key
+            commands.add(new SliceByNamesReadCommand(keyspace, key.getBytes(UTF8), path, nameAsList));
         }
         
         Map<String, ColumnOrSuperColumn> columnFamiliesMap = new HashMap<String, ColumnOrSuperColumn>();
@@ -120,7 +122,8 @@ public class CassandraServer implements 
                 }
 
             }
-            columnFamiliesMap.put(command.key, columnorsupercolumn);
+            // FIXME: assuming string keys
+            columnFamiliesMap.put(new String(command.key, UTF8), columnorsupercolumn);
         }
 
         return columnFamiliesMap;
@@ -129,10 +132,10 @@ public class CassandraServer implements 
     private Map<String, Collection<IColumn>> multigetColumns(List<ReadCommand> commands, ConsistencyLevel level)
     throws InvalidRequestException, UnavailableException, TimedOutException
     {
-        Map<String, ColumnFamily> cfamilies = readColumnFamily(commands, level);
+        Map<byte[], ColumnFamily> cfamilies = readColumnFamily(commands, level);
         Map<String, Collection<IColumn>> columnFamiliesMap = new HashMap<String, Collection<IColumn>>();
         
-        for (ReadCommand command: commands)
+        for (ReadCommand command : commands)
         {
             ColumnFamily cfamily = cfamilies.get(command.key);
             if (cfamily == null)
@@ -154,18 +157,19 @@ public class CassandraServer implements 
 
             if (columns != null && columns.size() != 0)
             {
-                columnFamiliesMap.put(command.key, columns);
+                // FIXME: assuming string keys
+                columnFamiliesMap.put(new String(command.key, UTF8), columns);
             }
         }
         
         return columnFamiliesMap;
     }
     
-    protected Map<String, ColumnFamily> readColumnFamily(List<ReadCommand> commands, ConsistencyLevel consistency)
+    protected Map<byte[], ColumnFamily> readColumnFamily(List<ReadCommand> commands, ConsistencyLevel consistency)
     throws InvalidRequestException, UnavailableException, TimedOutException
     {
         // TODO - Support multiple column families per row, right now row only contains 1 column family
-        Map<String, ColumnFamily> columnFamilyKeyMap = new HashMap<String,ColumnFamily>();
+        Map<byte[], ColumnFamily> columnFamilyKeyMap = new HashMap<byte[],ColumnFamily>();
         
         if (consistency == ConsistencyLevel.ZERO)
             throw newInvalidRequestException("Consistency level zero may not be applied to read operations");
@@ -195,7 +199,7 @@ public class CassandraServer implements 
 
         for (Row row: rows)
         {
-            columnFamilyKeyMap.put(row.key, row.cf);
+            columnFamilyKeyMap.put(row.key.key, row.cf);
         }
         
         return columnFamilyKeyMap;
@@ -238,7 +242,7 @@ public class CassandraServer implements 
         AvroValidation.validateKey(keyspace_string);
         AvroValidation.validateColumnPath(keyspace_string, cp);
 
-        RowMutation rm = new RowMutation(keyspace_string, key.toString());
+        RowMutation rm = new RowMutation(keyspace_string, key.getBytes());
         try
         {
             rm.add(new QueryPath(column_family, super_column, column), value.array(), timestamp);
@@ -282,10 +286,10 @@ public class CassandraServer implements 
         if (logger.isDebugEnabled())
             logger.debug("batch_insert");
 
-        String keyString = key.toString();
+        byte[] keyBytes = key.getBytes();
         String keyspaceString = keyspace.toString();
 
-        AvroValidation.validateKey(keyString);
+        AvroValidation.validateKey(key.toString());
 
         for (Utf8 cfName : cfmap.keySet())
         {
@@ -293,14 +297,14 @@ public class CassandraServer implements 
                 AvroValidation.validateColumnOrSuperColumn(keyspaceString, cfName.toString(), cosc);
         }
 
-        doInsert(consistency, getRowMutation(keyspaceString, keyString, cfmap));
+        doInsert(consistency, getRowMutation(keyspaceString, keyBytes, cfmap));
         return null;
     }
 
     // FIXME: This is copypasta from o.a.c.db.RowMutation, (RowMutation.getRowMutation uses Thrift types directly).
-    private static RowMutation getRowMutation(String keyspace, String key, Map<Utf8, GenericArray<ColumnOrSuperColumn>> cfmap)
+    private static RowMutation getRowMutation(String keyspace, byte[] key, Map<Utf8, GenericArray<ColumnOrSuperColumn>> cfmap)
     {
-        RowMutation rm = new RowMutation(keyspace, key.trim());
+        RowMutation rm = new RowMutation(keyspace, key);
         for (Map.Entry<Utf8, GenericArray<ColumnOrSuperColumn>> entry : cfmap.entrySet())
         {
             String cfName = entry.getKey().toString();
@@ -379,7 +383,8 @@ public class CassandraServer implements 
     // FIXME: This is copypasta from o.a.c.db.RowMutation, (RowMutation.getRowMutation uses Thrift types directly).
     private static RowMutation getRowMutationFromMutations(String keyspace, String key, Map<Utf8, GenericArray<Mutation>> cfMap)
     {
-        RowMutation rm = new RowMutation(keyspace, key.trim());
+        // FIXME: string key
+        RowMutation rm = new RowMutation(keyspace, key.trim().getBytes(UTF8));
         
         for (Map.Entry<Utf8, GenericArray<Mutation>> entry : cfMap.entrySet())
         {

Modified: cassandra/trunk/src/java/org/apache/cassandra/client/RingCache.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/client/RingCache.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/client/RingCache.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/client/RingCache.java Wed Apr 14 19:53:06 2010
@@ -109,7 +109,7 @@ public class RingCache
         }
     }
 
-    public List<InetAddress> getEndPoint(String key)
+    public List<InetAddress> getEndPoint(byte[] key)
     {
         if (tokenMetadata == null)
             throw new RuntimeException("Must refresh endpoints before looking up a key.");

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/BinaryMemtable.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/BinaryMemtable.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/BinaryMemtable.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/BinaryMemtable.java Wed Apr 14 19:53:06 2010
@@ -68,7 +68,7 @@ public class BinaryMemtable implements I
      * the memtable. This version will respect the threshold and flush
      * the memtable to disk when the size exceeds the threshold.
     */
-    void put(String key, byte[] buffer)
+    void put(DecoratedKey key, byte[] buffer)
     {
         if (isThresholdViolated())
         {
@@ -102,10 +102,10 @@ public class BinaryMemtable implements I
         return columnFamilies.isEmpty();
     }
 
-    private void resolve(String key, byte[] buffer)
+    private void resolve(DecoratedKey key, byte[] buffer)
     {
-        columnFamilies.put(partitioner.decorateKey(key), buffer);
-        currentSize.addAndGet(buffer.length + key.length());
+        columnFamilies.put(key, buffer);
+        currentSize.addAndGet(buffer.length + key.key.length);
     }
 
     private List<DecoratedKey> getSortedKeys()

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ColumnFamilyStore.java Wed Apr 14 19:53:06 2010
@@ -382,7 +382,7 @@ public class ColumnFamilyStore implement
         }
     }
 
-    void switchBinaryMemtable(String key, byte[] buffer)
+    void switchBinaryMemtable(DecoratedKey key, byte[] buffer)
     {
         binaryMemtable_.set(new BinaryMemtable(this));
         binaryMemtable_.get().put(key, buffer);
@@ -424,7 +424,7 @@ public class ColumnFamilyStore implement
      * param @ key - key for update/insert
      * param @ columnFamily - columnFamily changes
      */
-    Memtable apply(String key, ColumnFamily columnFamily)
+    Memtable apply(DecoratedKey key, ColumnFamily columnFamily)
     {
         long start = System.nanoTime();
 
@@ -440,7 +440,7 @@ public class ColumnFamilyStore implement
      * needs to be used. param @ key - key for update/insert param @
      * columnFamily - columnFamily changes
      */
-    void applyBinary(String key, byte[] buffer)
+    void applyBinary(DecoratedKey key, byte[] buffer)
     {
         long start = System.nanoTime();
         binaryMemtable_.get().put(key, buffer);
@@ -686,12 +686,12 @@ public class ColumnFamilyStore implement
         return writeStats_.getRecentLatencyMicros();
     }
 
-    public ColumnFamily getColumnFamily(String key, QueryPath path, byte[] start, byte[] finish, List<byte[]> bitmasks, boolean reversed, int limit)
+    public ColumnFamily getColumnFamily(DecoratedKey key, QueryPath path, byte[] start, byte[] finish, List<byte[]> bitmasks, boolean reversed, int limit)
     {
         return getColumnFamily(QueryFilter.getSliceFilter(key, path, start, finish, bitmasks, reversed, limit));
     }
 
-    public ColumnFamily getColumnFamily(String key, QueryPath path, byte[] start, byte[] finish, boolean reversed, int limit)
+    public ColumnFamily getColumnFamily(DecoratedKey key, QueryPath path, byte[] start, byte[] finish, boolean reversed, int limit)
     {
         return getColumnFamily(QueryFilter.getSliceFilter(key, path, start, finish, null, reversed, limit));
     }
@@ -701,7 +701,7 @@ public class ColumnFamilyStore implement
         return getColumnFamily(filter, CompactionManager.getDefaultGCBefore());
     }
 
-    private ColumnFamily cacheRow(String key)
+    private ColumnFamily cacheRow(DecoratedKey key)
     {
         ColumnFamily cached;
         if ((cached = ssTables_.getRowCache().get(key)) == null)
@@ -867,8 +867,7 @@ public class ColumnFamilyStore implement
             while(iterator.hasNext())
             {
                 Row current = iterator.next();
-            	// TODO store decoratedkey in row?
-                DecoratedKey key = partitioner.decorateKey(current.key);
+                DecoratedKey key = current.key;
 
                 if (!stopAt.isEmpty() && stopAt.compareTo(key) < 0)
                     return true;
@@ -1010,12 +1009,12 @@ public class ColumnFamilyStore implement
     }
 
     /** raw cached row -- does not fetch the row if it is not present.  not counted in cache statistics.  */
-    public ColumnFamily getRawCachedRow(String key)
+    public ColumnFamily getRawCachedRow(DecoratedKey key)
     {
         return ssTables_.getRowCache().getCapacity() == 0 ? null : ssTables_.getRowCache().getInternal(key);
     }
 
-    void invalidateCachedRow(String key)
+    void invalidateCachedRow(DecoratedKey key)
     {
         ssTables_.getRowCache().remove(key);
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/DefsTable.java Wed Apr 14 19:53:06 2010
@@ -25,6 +25,9 @@ import org.apache.cassandra.db.filter.Qu
 import org.apache.cassandra.db.filter.QueryPath;
 import org.apache.cassandra.db.filter.SliceQueryFilter;
 import org.apache.cassandra.db.migration.Migration;
+import org.apache.cassandra.io.util.FileUtils;
+import org.apache.cassandra.service.StorageService;
+import org.apache.cassandra.utils.FBUtilities;
 import org.apache.cassandra.utils.UUIDGen;
 
 import java.io.ByteArrayInputStream;
@@ -42,7 +45,7 @@ public class DefsTable
     /** dumps current keyspace definitions to storage */
     public static synchronized void dumpToStorage(UUID version) throws IOException
     {
-        String versionKey = version.toString();
+        byte[] versionKey = Migration.toBytes(version);
         long now = System.currentTimeMillis();
         RowMutation rm = new RowMutation(Table.DEFINITIONS, versionKey);
         for (String tableName : DatabaseDescriptor.getNonSystemTables())
@@ -53,16 +56,17 @@ public class DefsTable
         rm.apply();
         
         rm = new RowMutation(Table.DEFINITIONS, Migration.LAST_MIGRATION_KEY);
-        rm.add(new QueryPath(Migration.SCHEMA_CF, null, Migration.LAST_MIGRATION_KEY.getBytes()), UUIDGen.decompose(version), now);
+        rm.add(new QueryPath(Migration.SCHEMA_CF, null, Migration.LAST_MIGRATION_KEY), UUIDGen.decompose(version), now);
         rm.apply();
     }
 
     /** loads a version of keyspace definitions from storage */
     public static synchronized Collection<KSMetaData> loadFromStorage(UUID version) throws IOException
     {
+        DecoratedKey vkey = StorageService.getPartitioner().decorateKey(Migration.toBytes(version));
         Table defs = Table.open(Table.DEFINITIONS);
         ColumnFamilyStore cfStore = defs.getColumnFamilyStore(Migration.SCHEMA_CF);
-        QueryFilter filter = QueryFilter.getSliceFilter(version.toString(), new QueryPath(Migration.SCHEMA_CF), "".getBytes(), "".getBytes(), null, false, 1024);
+        QueryFilter filter = QueryFilter.getSliceFilter(vkey, new QueryPath(Migration.SCHEMA_CF), "".getBytes(), "".getBytes(), null, false, 1024);
         ColumnFamily cf = cfStore.getColumnFamily(filter);
         Collection<KSMetaData> tables = new ArrayList<KSMetaData>();
         for (IColumn col : cf.getSortedColumns())
@@ -90,5 +94,4 @@ public class DefsTable
         }
         return found;
     }
-    
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/HintedHandOffManager.java Wed Apr 14 19:53:06 2010
@@ -42,6 +42,8 @@ import org.apache.cassandra.net.Messagin
 import org.apache.cassandra.service.*;
 import org.apache.cassandra.thrift.InvalidRequestException;
 import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.utils.FBUtilities;
+import static org.apache.cassandra.utils.FBUtilities.UTF8;
 import org.apache.cassandra.utils.WrappedRunnable;
 
 
@@ -102,7 +104,7 @@ public class HintedHandOffManager
         }, "Hint delivery").start();
     }
 
-    private static boolean sendMessage(InetAddress endPoint, String tableName, String key) throws IOException
+    private static boolean sendMessage(InetAddress endPoint, String tableName, byte[] key) throws IOException
     {
         if (!Gossiper.instance.isKnownEndpoint(endPoint))
         {
@@ -116,9 +118,10 @@ public class HintedHandOffManager
 
         Table table = Table.open(tableName);
         RowMutation rm = new RowMutation(tableName, key);
+        DecoratedKey dkey = StorageService.getPartitioner().decorateKey(key);
         for (ColumnFamilyStore cfstore : table.getColumnFamilyStores())
         {
-            ColumnFamily cf = cfstore.getColumnFamily(QueryFilter.getIdentityFilter(key, new QueryPath(cfstore.getColumnFamilyName())));
+            ColumnFamily cf = cfstore.getColumnFamily(QueryFilter.getIdentityFilter(dkey, new QueryPath(cfstore.getColumnFamilyName())));
             if (cf != null)
                 rm.add(cf);
         }
@@ -139,14 +142,14 @@ public class HintedHandOffManager
 
     private static void deleteEndPoint(byte[] endpointAddress, String tableName, byte[] key, long timestamp) throws IOException
     {
-        RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, tableName);
+        RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, tableName.getBytes(UTF8));
         rm.delete(new QueryPath(HINTS_CF, key, endpointAddress), timestamp);
         rm.apply();
     }
 
     private static void deleteHintKey(String tableName, byte[] key) throws IOException
     {
-        RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, tableName);
+        RowMutation rm = new RowMutation(Table.SYSTEM_TABLE, tableName.getBytes(UTF8));
         rm.delete(new QueryPath(HINTS_CF, key, null), System.currentTimeMillis());
         rm.apply();
     }
@@ -167,10 +170,11 @@ public class HintedHandOffManager
         ColumnFamilyStore hintStore = Table.open(Table.SYSTEM_TABLE).getColumnFamilyStore(HINTS_CF);
         for (String tableName : DatabaseDescriptor.getTables())
         {
+            DecoratedKey tableNameKey = StorageService.getPartitioner().decorateKey(tableName.getBytes(UTF8));
             byte[] startColumn = ArrayUtils.EMPTY_BYTE_ARRAY;
             while (true)
             {
-                QueryFilter filter = QueryFilter.getSliceFilter(tableName, new QueryPath(HINTS_CF), startColumn, ArrayUtils.EMPTY_BYTE_ARRAY, null, false, PAGE_SIZE);
+                QueryFilter filter = QueryFilter.getSliceFilter(tableNameKey, new QueryPath(HINTS_CF), startColumn, ArrayUtils.EMPTY_BYTE_ARRAY, null, false, PAGE_SIZE);
                 ColumnFamily hintColumnFamily = ColumnFamilyStore.removeDeleted(hintStore.getColumnFamily(filter), Integer.MAX_VALUE);
                 if (pagingFinished(hintColumnFamily, startColumn))
                     break;
@@ -179,11 +183,11 @@ public class HintedHandOffManager
                 for (IColumn keyColumn : keys)
                 {
                     Collection<IColumn> endpoints = keyColumn.getSubColumns();
-                    String keyStr = new String(keyColumn.name(), "UTF-8");
+                    byte[] keyBytes = keyColumn.name();
                     int deleted = 0;
                     for (IColumn endpoint : endpoints)
                     {
-                        if (sendMessage(InetAddress.getByAddress(endpoint.name()), tableName, keyStr))
+                        if (sendMessage(InetAddress.getByAddress(endpoint.name()), tableName, keyBytes))
                         {
                             deleteEndPoint(endpoint.name(), tableName, keyColumn.name(), System.currentTimeMillis());
                             deleted++;
@@ -231,10 +235,11 @@ public class HintedHandOffManager
         ColumnFamilyStore hintStore = Table.open(Table.SYSTEM_TABLE).getColumnFamilyStore(HINTS_CF);
         for (String tableName : DatabaseDescriptor.getTables())
         {
+            DecoratedKey tableNameKey = StorageService.getPartitioner().decorateKey(tableName.getBytes(UTF8));
             byte[] startColumn = ArrayUtils.EMPTY_BYTE_ARRAY;
             while (true)
             {
-                QueryFilter filter = QueryFilter.getSliceFilter(tableName, new QueryPath(HINTS_CF), startColumn, ArrayUtils.EMPTY_BYTE_ARRAY, null, false, PAGE_SIZE);
+                QueryFilter filter = QueryFilter.getSliceFilter(tableNameKey, new QueryPath(HINTS_CF), startColumn, ArrayUtils.EMPTY_BYTE_ARRAY, null, false, PAGE_SIZE);
                 ColumnFamily hintColumnFamily = ColumnFamilyStore.removeDeleted(hintStore.getColumnFamily(filter), Integer.MAX_VALUE);
                 if (pagingFinished(hintColumnFamily, startColumn))
                     break;
@@ -242,11 +247,11 @@ public class HintedHandOffManager
 
                 for (IColumn keyColumn : keys)
                 {
-                    String keyStr = new String(keyColumn.name(), "UTF-8");
+                    byte[] keyBytes = keyColumn.name();
                     Collection<IColumn> endpoints = keyColumn.getSubColumns();
                     for (IColumn hintEndPoint : endpoints)
                     {
-                        if (Arrays.equals(hintEndPoint.name(), targetEPBytes) && sendMessage(endPoint, tableName, keyStr))
+                        if (Arrays.equals(hintEndPoint.name(), targetEPBytes) && sendMessage(endPoint, tableName, keyBytes))
                         {
                             if (endpoints.size() == 1)
                                 deleteHintKey(tableName, keyColumn.name());
@@ -268,6 +273,7 @@ public class HintedHandOffManager
     /** called when a keyspace is dropped or rename. newTable==null in the case of a drop. */
     public static void renameHints(String oldTable, String newTable) throws IOException
     {
+        DecoratedKey oldTableKey = StorageService.getPartitioner().decorateKey(oldTable.getBytes(UTF8));
         // we're basically going to fetch, drop and add the scf for the old and new table. we need to do it piecemeal 
         // though since there could be GB of data.
         ColumnFamilyStore hintStore = Table.open(Table.SYSTEM_TABLE).getColumnFamilyStore(HINTS_CF);
@@ -275,17 +281,17 @@ public class HintedHandOffManager
         long now = System.currentTimeMillis();
         while (true)
         {
-            QueryFilter filter = QueryFilter.getSliceFilter(oldTable, new QueryPath(HINTS_CF), startCol, ArrayUtils.EMPTY_BYTE_ARRAY, null, false, PAGE_SIZE);
+            QueryFilter filter = QueryFilter.getSliceFilter(oldTableKey, new QueryPath(HINTS_CF), startCol, ArrayUtils.EMPTY_BYTE_ARRAY, null, false, PAGE_SIZE);
             ColumnFamily cf = ColumnFamilyStore.removeDeleted(hintStore.getColumnFamily(filter), Integer.MAX_VALUE);
             if (pagingFinished(cf, startCol))
                 break;
             if (newTable != null)
             {
-                RowMutation insert = new RowMutation(Table.SYSTEM_TABLE, newTable);
+                RowMutation insert = new RowMutation(Table.SYSTEM_TABLE, newTable.getBytes(UTF8));
                 insert.add(cf);
                 insert.apply();
             }
-            RowMutation drop = new RowMutation(Table.SYSTEM_TABLE, oldTable);
+            RowMutation drop = new RowMutation(Table.SYSTEM_TABLE, oldTableKey.key);
             for (byte[] key : cf.getColumnNames())
             {
                 drop.delete(new QueryPath(HINTS_CF, key), now);

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Memtable.java Wed Apr 14 19:53:06 2010
@@ -111,19 +111,18 @@ public class Memtable implements Compara
      * (CFS handles locking to avoid submitting an op
      *  to a flushing memtable.  Any other way is unsafe.)
     */
-    void put(String key, ColumnFamily columnFamily)
+    void put(DecoratedKey key, ColumnFamily columnFamily)
     {
         assert !isFrozen; // not 100% foolproof but hell, it's an assert
         resolve(key, columnFamily);
     }
 
-    private void resolve(String key, ColumnFamily cf)
+    private void resolve(DecoratedKey key, ColumnFamily cf)
     {
         currentThroughput.addAndGet(cf.size());
         currentOperations.addAndGet(cf.getColumnCount());
 
-        DecoratedKey decoratedKey = partitioner.decorateKey(key);
-        ColumnFamily oldCf = columnFamilies.putIfAbsent(decoratedKey, cf);
+        ColumnFamily oldCf = columnFamilies.putIfAbsent(key, cf);
         if (oldCf == null)
             return;
 
@@ -299,9 +298,9 @@ public class Memtable implements Compara
         };
     }
 
-    public ColumnFamily getColumnFamily(String key)
+    public ColumnFamily getColumnFamily(DecoratedKey key)
     {
-        return columnFamilies.get(partitioner.decorateKey(key));
+        return columnFamilies.get(key);
     }
 
     void clearUnsafe()

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/ReadCommand.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/ReadCommand.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/ReadCommand.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/ReadCommand.java Wed Apr 14 19:53:06 2010
@@ -59,11 +59,11 @@ public abstract class ReadCommand
 
     public final QueryPath queryPath;
     public final String table;
-    public final String key;
+    public final byte[] key;
     private boolean isDigestQuery = false;    
     protected final byte commandType;
 
-    protected ReadCommand(String table, String key, QueryPath queryPath, byte cmdType)
+    protected ReadCommand(String table, byte[] key, QueryPath queryPath, byte cmdType)
     {
         this.table = table;
         this.key = key;

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Row.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Row.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Row.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Row.java Wed Apr 14 19:53:06 2010
@@ -29,6 +29,8 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import org.apache.cassandra.io.ICompactSerializer;
+import org.apache.cassandra.service.StorageService;
+import org.apache.cassandra.utils.FBUtilities;
 
 public class Row
 {
@@ -40,10 +42,10 @@ public class Row
         return serializer;
     }
 
-    public final String key;
+    public final DecoratedKey key;
     public final ColumnFamily cf;
 
-    public Row(String key, ColumnFamily cf)
+    public Row(DecoratedKey key, ColumnFamily cf)
     {
         assert key != null;
         // cf may be null, indicating no data
@@ -55,7 +57,7 @@ public class Row
     public String toString()
     {
         return "Row(" +
-               "key='" + key + '\'' +
+               "key=" + key +
                ", cf=" + cf +
                ')';
     }
@@ -65,12 +67,13 @@ class RowSerializer implements ICompactS
 {
     public void serialize(Row row, DataOutputStream dos) throws IOException
     {
-        dos.writeUTF(row.key);
+        FBUtilities.writeShortByteArray(row.key.key, dos);
         ColumnFamily.serializer().serialize(row.cf, dos);
     }
 
     public Row deserialize(DataInputStream dis) throws IOException
     {
-        return new Row(dis.readUTF(), ColumnFamily.serializer().deserialize(dis));
+        return new Row(StorageService.getPartitioner().decorateKey(FBUtilities.readShortByteArray(dis)),
+                       ColumnFamily.serializer().deserialize(dis));
     }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/RowIteratorFactory.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/RowIteratorFactory.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/RowIteratorFactory.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/RowIteratorFactory.java Wed Apr 14 19:53:06 2010
@@ -133,8 +133,7 @@ public class RowIteratorFactory
                 Comparator<IColumn> colComparator = QueryFilter.getColumnComparator(comparator);
                 Iterator<IColumn> colCollated = IteratorUtils.collatedIterator(colComparator, colIters);
 
-                // FIXME: string keys
-                ColumnFamily returnCF = current.getColumnFamily(new String(key.key));
+                ColumnFamily returnCF = current.getColumnFamily(key);
                 // TODO this is a little subtle: the Memtable ColumnIterator has to be a shallow clone of the source CF,
                 // with deletion times set correctly, so we can use it as the "base" CF to add query results to.
                 // (for sstable ColumnIterators we do not care if it is a shallow clone or not.)
@@ -150,8 +149,7 @@ public class RowIteratorFactory
                     returnCF = null;
                 }
 
-                // FIXME: string keys
-                Row rv = new Row(new String(key.key), returnCF);
+                Row rv = new Row(key, returnCF);
                 colIters.clear();
                 key = null;
                 return rv;

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/RowMutation.java Wed Apr 14 19:53:06 2010
@@ -61,10 +61,10 @@ public class RowMutation
     }
 
     private String table_;
-    private String key_;
+    private byte[] key_;
     protected Map<String, ColumnFamily> modifications_ = new HashMap<String, ColumnFamily>();
 
-    public RowMutation(String table, String key)
+    public RowMutation(String table, byte[] key)
     {
         table_ = table;
         key_ = key;
@@ -73,11 +73,11 @@ public class RowMutation
     public RowMutation(String table, Row row)
     {
         table_ = table;
-        key_ = row.key;
+        key_ = row.key.key;
         add(row.cf);
     }
 
-    protected RowMutation(String table, String key, Map<String, ColumnFamily> modifications)
+    protected RowMutation(String table, byte[] key, Map<String, ColumnFamily> modifications)
     {
         table_ = table;
         key_ = key;
@@ -89,7 +89,7 @@ public class RowMutation
         return table_;
     }
 
-    public String key()
+    public byte[] key()
     {
         return key_;
     }
@@ -104,9 +104,9 @@ public class RowMutation
         return modifications_.values();
     }
 
-    void addHints(String key, byte[] host) throws IOException
+    void addHints(byte[] key, byte[] host) throws IOException
     {
-        QueryPath path = new QueryPath(HintedHandOffManager.HINTS_CF, key.getBytes("UTF-8"), host);
+        QueryPath path = new QueryPath(HintedHandOffManager.HINTS_CF, key, host);
         add(path, ArrayUtils.EMPTY_BYTE_ARRAY, System.currentTimeMillis());
     }
 
@@ -222,9 +222,9 @@ public class RowMutation
         return new Message(FBUtilities.getLocalAddress(), StageManager.MUTATION_STAGE, verb, bos.toByteArray());
     }
 
-    public static RowMutation getRowMutationFromMutations(String keyspace, String key, Map<String, List<Mutation>> cfmap)
+    public static RowMutation getRowMutationFromMutations(String keyspace, byte[] key, Map<String, List<Mutation>> cfmap)
     {
-        RowMutation rm = new RowMutation(keyspace, key.trim());
+        RowMutation rm = new RowMutation(keyspace, key);
         for (Map.Entry<String, List<Mutation>> entry : cfmap.entrySet())
         {
             String cfName = entry.getKey();
@@ -243,9 +243,9 @@ public class RowMutation
         return rm;
     }
     
-    public static RowMutation getRowMutation(String table, String key, Map<String, List<ColumnOrSuperColumn>> cfmap)
+    public static RowMutation getRowMutation(String table, byte[] key, Map<String, List<ColumnOrSuperColumn>> cfmap)
     {
-        RowMutation rm = new RowMutation(table, key.trim());
+        RowMutation rm = new RowMutation(table, key);
         for (Map.Entry<String, List<ColumnOrSuperColumn>> entry : cfmap.entrySet())
         {
             String cfName = entry.getKey();
@@ -280,7 +280,7 @@ public class RowMutation
     {
         return "RowMutation(" +
                "table='" + table_ + '\'' +
-               ", key='" + key_ + '\'' +
+               ", key='" + FBUtilities.bytesToHex(key_) + '\'' +
                ", modifications=[" + StringUtils.join(modifications_.values(), ", ") + "]" +
                ')';
     }
@@ -327,15 +327,10 @@ class RowMutationSerializer implements I
         dos.writeInt(size);
         if (size > 0)
         {
-            Set<String> keys = map.keySet();
-            for (String key : keys)
+            for (Map.Entry<String,ColumnFamily> entry : map.entrySet())
             {
-                dos.writeUTF(key);
-                ColumnFamily cf = map.get(key);
-                if (cf != null)
-                {
-                    ColumnFamily.serializer().serialize(cf, dos);
-                }
+                dos.writeUTF(entry.getKey());
+                ColumnFamily.serializer().serialize(entry.getValue(), dos);
             }
         }
     }
@@ -343,7 +338,7 @@ class RowMutationSerializer implements I
     public void serialize(RowMutation rm, DataOutputStream dos) throws IOException
     {
         dos.writeUTF(rm.getTable());
-        dos.writeUTF(rm.key());
+        FBUtilities.writeShortByteArray(rm.key(), dos);
 
         /* serialize the modifications_ in the mutation */
         freezeTheMaps(rm.modifications_, dos);
@@ -365,10 +360,8 @@ class RowMutationSerializer implements I
     public RowMutation deserialize(DataInputStream dis) throws IOException
     {
         String table = dis.readUTF();
-        String key = dis.readUTF();
+        byte[] key = FBUtilities.readShortByteArray(dis);
         Map<String, ColumnFamily> modifications = defreezeTheMaps(dis);
         return new RowMutation(table, key, modifications);
     }
-
-  
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/RowMutationVerbHandler.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/RowMutationVerbHandler.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/RowMutationVerbHandler.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/RowMutationVerbHandler.java Wed Apr 14 19:53:06 2010
@@ -60,7 +60,7 @@ public class RowMutationVerbHandler impl
                     InetAddress hint = InetAddress.getByAddress(addressBytes);
                     if (logger_.isDebugEnabled())
                         logger_.debug("Adding hint for " + hint);
-                    RowMutation hintedMutation = new RowMutation(Table.SYSTEM_TABLE, rm.getTable());
+                    RowMutation hintedMutation = new RowMutation(Table.SYSTEM_TABLE, rm.getTable().getBytes(FBUtilities.UTF8));
                     hintedMutation.addHints(rm.key(), addressBytes);
                     hintedMutation.apply();
                 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/SliceByNamesReadCommand.java Wed Apr 14 19:53:06 2010
@@ -23,20 +23,21 @@ import java.io.IOException;
 import java.util.*;
 
 import org.apache.cassandra.db.filter.QueryFilter;
+import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.thrift.ColumnParent;
 import org.apache.cassandra.utils.FBUtilities;
-import org.apache.cassandra.db.filter.QueryPath;
 
 public class SliceByNamesReadCommand extends ReadCommand
 {
     public final SortedSet<byte[]> columnNames;
 
-    public SliceByNamesReadCommand(String table, String key, ColumnParent column_parent, Collection<byte[]> columnNames)
+    public SliceByNamesReadCommand(String table, byte[] key, ColumnParent column_parent, Collection<byte[]> columnNames)
     {
         this(table, key, new QueryPath(column_parent), columnNames);
     }
 
-    public SliceByNamesReadCommand(String table, String key, QueryPath path, Collection<byte[]> columnNames)
+    public SliceByNamesReadCommand(String table, byte[] key, QueryPath path, Collection<byte[]> columnNames)
     {
         super(table, key, path, CMD_TYPE_GET_SLICE_BY_NAMES);
         this.columnNames = new TreeSet<byte[]>(getComparator());
@@ -53,8 +54,9 @@ public class SliceByNamesReadCommand ext
     
     @Override
     public Row getRow(Table table) throws IOException
-    {        
-        return table.getRow(QueryFilter.getNamesFilter(key, queryPath, columnNames));
+    {
+        DecoratedKey dk = StorageService.getPartitioner().decorateKey(key);
+        return table.getRow(QueryFilter.getNamesFilter(dk, queryPath, columnNames));
     }
 
     @Override
@@ -62,7 +64,7 @@ public class SliceByNamesReadCommand ext
     {
         return "SliceByNamesReadCommand(" +
                "table='" + table + '\'' +
-               ", key='" + key + '\'' +
+               ", key=" + FBUtilities.bytesToHex(key) +
                ", columnParent='" + queryPath + '\'' +
                ", columns=[" + getComparator().getString(columnNames) + "]" +
                ')';
@@ -78,7 +80,7 @@ class SliceByNamesReadCommandSerializer 
         SliceByNamesReadCommand realRM = (SliceByNamesReadCommand)rm;
         dos.writeBoolean(realRM.isDigestQuery());
         dos.writeUTF(realRM.table);
-        dos.writeUTF(realRM.key);
+        FBUtilities.writeShortByteArray(realRM.key, dos);
         realRM.queryPath.serialize(dos);
         dos.writeInt(realRM.columnNames.size());
         if (realRM.columnNames.size() > 0)
@@ -95,7 +97,7 @@ class SliceByNamesReadCommandSerializer 
     {
         boolean isDigest = dis.readBoolean();
         String table = dis.readUTF();
-        String key = dis.readUTF();
+        byte[] key = FBUtilities.readShortByteArray(dis);
         QueryPath columnParent = QueryPath.deserialize(dis);
 
         int size = dis.readInt();

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/SliceFromReadCommand.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/SliceFromReadCommand.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/SliceFromReadCommand.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/SliceFromReadCommand.java Wed Apr 14 19:53:06 2010
@@ -24,6 +24,7 @@ import java.util.List;
 
 import org.apache.cassandra.db.filter.QueryFilter;
 import org.apache.cassandra.db.filter.QueryPath;
+import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.thrift.ColumnParent;
 import org.apache.cassandra.utils.ByteArrayListSerializer;
 import org.apache.cassandra.utils.FBUtilities;
@@ -35,17 +36,17 @@ public class SliceFromReadCommand extend
     public final int count;
     public final List<byte[]> bitmasks;
 
-    public SliceFromReadCommand(String table, String key, ColumnParent column_parent, byte[] start, byte[] finish, boolean reversed, int count)
+    public SliceFromReadCommand(String table, byte[] key, ColumnParent column_parent, byte[] start, byte[] finish, boolean reversed, int count)
     {
         this(table, key, new QueryPath(column_parent), start, finish, null, reversed, count);
     }
 
-    public SliceFromReadCommand(String table, String key, QueryPath path, byte[] start, byte[] finish, boolean reversed, int count)
+    public SliceFromReadCommand(String table, byte[] key, QueryPath path, byte[] start, byte[] finish, boolean reversed, int count)
     {
         this(table, key, path, start, finish, null, reversed, count);
     }
 
-    public SliceFromReadCommand(String table, String key, QueryPath path, byte[] start, byte[] finish, List<byte[]> bitmasks, boolean reversed, int count)
+    public SliceFromReadCommand(String table, byte[] key, QueryPath path, byte[] start, byte[] finish, List<byte[]> bitmasks, boolean reversed, int count)
     {
         super(table, key, path, CMD_TYPE_GET_SLICE);
         this.start = start;
@@ -66,7 +67,8 @@ public class SliceFromReadCommand extend
     @Override
     public Row getRow(Table table) throws IOException
     {
-        return table.getRow(QueryFilter.getSliceFilter(key, queryPath, start, finish, bitmasks, reversed, count));
+        DecoratedKey dk = StorageService.getPartitioner().decorateKey(key);
+        return table.getRow(QueryFilter.getSliceFilter(dk, queryPath, start, finish, bitmasks, reversed, count));
     }
 
     @Override
@@ -76,7 +78,7 @@ public class SliceFromReadCommand extend
 
         return "SliceFromReadCommand(" +
                "table='" + table + '\'' +
-               ", key='" + key + '\'' +
+               ", key='" + FBUtilities.bytesToHex(key) + '\'' +
                ", column_parent='" + queryPath + '\'' +
                ", start='" + getComparator().getString(start) + '\'' +
                ", finish='" + getComparator().getString(finish) + '\'' +
@@ -115,7 +117,7 @@ class SliceFromReadCommandSerializer ext
         SliceFromReadCommand realRM = (SliceFromReadCommand)rm;
         dos.writeBoolean(realRM.isDigestQuery());
         dos.writeUTF(realRM.table);
-        dos.writeUTF(realRM.key);
+        FBUtilities.writeShortByteArray(realRM.key, dos);
         realRM.queryPath.serialize(dos);
         FBUtilities.writeShortByteArray(realRM.start, dos);
         FBUtilities.writeShortByteArray(realRM.finish, dos);
@@ -129,7 +131,7 @@ class SliceFromReadCommandSerializer ext
     {
         boolean isDigest = dis.readBoolean();
         SliceFromReadCommand rm = new SliceFromReadCommand(dis.readUTF(),
-                                                           dis.readUTF(),
+                                                           FBUtilities.readShortByteArray(dis),
                                                            QueryPath.deserialize(dis),
                                                            FBUtilities.readShortByteArray(dis),
                                                            FBUtilities.readShortByteArray(dis),

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/SystemTable.java Wed Apr 14 19:53:06 2010
@@ -24,6 +24,7 @@ import java.io.IOError;
 
 import org.apache.cassandra.config.CFMetaData;
 import org.apache.cassandra.utils.FBUtilities;
+import static org.apache.cassandra.utils.FBUtilities.UTF8;
 
 import org.apache.commons.lang.ArrayUtils;
 import org.slf4j.Logger;
@@ -46,25 +47,18 @@ public class SystemTable
 {
     private static Logger logger = LoggerFactory.getLogger(SystemTable.class);
     public static final String STATUS_CF = "LocationInfo"; // keep the old CF string for backwards-compatibility
-    private static final String LOCATION_KEY = "L";
-    private static final String BOOTSTRAP_KEY = "Bootstrap";
-    private static final String GRAVEYARD_KEY = "Graveyard";
-    private static final byte[] BOOTSTRAP = utf8("B");
-    private static final byte[] TOKEN = utf8("Token");
-    private static final byte[] GENERATION = utf8("Generation");
-    private static final byte[] CLUSTERNAME = utf8("ClusterName");
+    private static final byte[] LOCATION_KEY = "L".getBytes(UTF8);
+    private static final byte[] BOOTSTRAP_KEY = "Bootstrap".getBytes(UTF8);
+    private static final byte[] GRAVEYARD_KEY = "Graveyard".getBytes(UTF8);
+    private static final byte[] BOOTSTRAP = "B".getBytes(UTF8);
+    private static final byte[] TOKEN = "Token".getBytes(UTF8);
+    private static final byte[] GENERATION = "Generation".getBytes(UTF8);
+    private static final byte[] CLUSTERNAME = "ClusterName".getBytes(UTF8);
     private static StorageMetadata metadata;
 
-    private static byte[] utf8(String str)
+    private static DecoratedKey decorate(byte[] key)
     {
-        try
-        {
-            return str.getBytes("UTF-8");
-        }
-        catch (UnsupportedEncodingException e)
-        {
-            throw new RuntimeException(e);
-        }
+        return StorageService.getPartitioner().decorateKey(key);
     }
 
     /**
@@ -123,15 +117,15 @@ public class SystemTable
             return metadata;
 
         /* Read the system table to retrieve the storage ID and the generation */
+        IPartitioner p = StorageService.getPartitioner();
         Table table = Table.open(Table.SYSTEM_TABLE);
         SortedSet<byte[]> columns = new TreeSet<byte[]>(new BytesType());
         columns.add(TOKEN);
         columns.add(GENERATION);
         columns.add(CLUSTERNAME);
-        QueryFilter filter = QueryFilter.getNamesFilter(LOCATION_KEY, new QueryPath(STATUS_CF), columns);
+        QueryFilter filter = QueryFilter.getNamesFilter(decorate(LOCATION_KEY), new QueryPath(STATUS_CF), columns);
         ColumnFamily cf = table.getColumnFamilyStore(STATUS_CF).getColumnFamily(filter);
 
-        IPartitioner p = StorageService.getPartitioner();
         if (cf == null)
         {
             Token token;
@@ -199,9 +193,10 @@ public class SystemTable
 
     public static boolean isBootstrapped()
     {
-        Table table = null;
-        table = Table.open(Table.SYSTEM_TABLE);
-        QueryFilter filter = QueryFilter.getNamesFilter(BOOTSTRAP_KEY, new QueryPath(STATUS_CF), BOOTSTRAP);
+        Table table = Table.open(Table.SYSTEM_TABLE);
+        QueryFilter filter = QueryFilter.getNamesFilter(decorate(BOOTSTRAP_KEY),
+                                                        new QueryPath(STATUS_CF),
+                                                        BOOTSTRAP);
         ColumnFamily cf = table.getColumnFamilyStore(STATUS_CF).getColumnFamily(filter);
         return cf != null && cf.getColumn(BOOTSTRAP).value()[0] == 1;
     }
@@ -225,7 +220,7 @@ public class SystemTable
     public static ColumnFamily getDroppedCFs() throws IOException
     {
         ColumnFamilyStore cfs = Table.open(Table.SYSTEM_TABLE).getColumnFamilyStore(SystemTable.STATUS_CF);
-        return cfs.getColumnFamily(QueryFilter.getSliceFilter(SystemTable.GRAVEYARD_KEY, new QueryPath(STATUS_CF), "".getBytes(), "".getBytes(), null, false, 100));
+        return cfs.getColumnFamily(QueryFilter.getSliceFilter(decorate(GRAVEYARD_KEY), new QueryPath(STATUS_CF), "".getBytes(), "".getBytes(), null, false, 100));
     }
     
     public static void deleteDroppedCfMarkers(Collection<IColumn> cols) throws IOException

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Wed Apr 14 19:53:06 2010
@@ -343,6 +343,7 @@ public class Table 
                 }
             }
         
+            DecoratedKey key = StorageService.getPartitioner().decorateKey(mutation.key());
             for (ColumnFamily columnFamily : mutation.getColumnFamilies())
             {
                 Memtable memtableToFlush;
@@ -353,10 +354,10 @@ public class Table 
                 }
                 else
                 {
-                    if ((memtableToFlush=cfs.apply(mutation.key(), columnFamily)) != null)
+                    if ((memtableToFlush=cfs.apply(key, columnFamily)) != null)
                         memtablesToFlush.put(cfs, memtableToFlush);
     
-                    ColumnFamily cachedRow = cfs.getRawCachedRow(mutation.key());
+                    ColumnFamily cachedRow = cfs.getRawCachedRow(key);
                     if (cachedRow != null)
                         cachedRow.addAll(columnFamily);
                 }
@@ -387,8 +388,7 @@ public class Table 
     // for binary load path.  skips commitlog.
     void load(RowMutation rowMutation) throws IOException
     {
-        String key = rowMutation.key();
-                
+        DecoratedKey key = StorageService.getPartitioner().decorateKey(rowMutation.key());
         for (ColumnFamily columnFamily : rowMutation.getColumnFamilies())
         {
             Collection<IColumn> columns = columnFamily.getSortedColumns();

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/WriteResponse.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/WriteResponse.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/WriteResponse.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/WriteResponse.java Wed Apr 14 19:53:06 2010
@@ -51,10 +51,10 @@ public class WriteResponse 
     }
 
 	private final String table_;
-	private final String key_;
+	private final byte[] key_;
 	private final boolean status_;
 
-	public WriteResponse(String table, String key, boolean bVal) {
+	public WriteResponse(String table, byte[] key, boolean bVal) {
 		table_ = table;
 		key_ = key;
 		status_ = bVal;
@@ -65,7 +65,7 @@ public class WriteResponse 
 		return table_;
 	}
 
-	public String key()
+	public byte[] key()
 	{
 		return key_;
 	}
@@ -80,14 +80,14 @@ public class WriteResponse 
         public void serialize(WriteResponse wm, DataOutputStream dos) throws IOException
         {
             dos.writeUTF(wm.table());
-            dos.writeUTF(wm.key());
+            FBUtilities.writeShortByteArray(wm.key(), dos);
             dos.writeBoolean(wm.isSuccess());
         }
 
         public WriteResponse deserialize(DataInputStream dis) throws IOException
         {
             String table = dis.readUTF();
-            String key = dis.readUTF();
+            byte[] key = FBUtilities.readShortByteArray(dis);
             boolean status = dis.readBoolean();
             return new WriteResponse(table, key, status);
         }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/filter/IFilter.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/filter/IFilter.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/filter/IFilter.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/filter/IFilter.java Wed Apr 14 19:53:06 2010
@@ -57,7 +57,7 @@ interface IFilter
      * returns an iterator that returns columns from the given SSTable
      * matching the Filter criteria in sorted order.
      */
-    public abstract IColumnIterator getSSTableColumnIterator(SSTableReader sstable, String key);
+    public abstract IColumnIterator getSSTableColumnIterator(SSTableReader sstable, DecoratedKey key);
 
     /**
      * collects columns from reducedColumns into returnCF.  Termination is determined

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/filter/IdentityQueryFilter.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/filter/IdentityQueryFilter.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/filter/IdentityQueryFilter.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/filter/IdentityQueryFilter.java Wed Apr 14 19:53:06 2010
@@ -23,6 +23,7 @@ package org.apache.cassandra.db.filter;
 
 import org.apache.commons.lang.ArrayUtils;
 
+import org.apache.cassandra.db.DecoratedKey;
 import org.apache.cassandra.db.SuperColumn;
 
 class IdentityQueryFilter extends SliceQueryFilter

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/filter/NamesQueryFilter.java Wed Apr 14 19:53:06 2010
@@ -61,7 +61,7 @@ public class NamesQueryFilter implements
         return Memtable.getNamesIterator(key, cf, this);
     }
 
-    public IColumnIterator getSSTableColumnIterator(SSTableReader sstable, String key)
+    public IColumnIterator getSSTableColumnIterator(SSTableReader sstable, DecoratedKey key)
     {
         return new SSTableNamesIterator(sstable, key, columns);
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/filter/QueryFilter.java Wed Apr 14 19:53:06 2010
@@ -32,12 +32,12 @@ import org.apache.cassandra.db.marshal.A
 
 public class QueryFilter
 {
-    public final String key;
+    public final DecoratedKey key;
     public final QueryPath path;
     private final IFilter filter;
     private final IFilter superFilter;
 
-    protected QueryFilter(String key, QueryPath path, IFilter filter)
+    protected QueryFilter(DecoratedKey key, QueryPath path, IFilter filter)
     {
         this.key = key;
         this.path = path;
@@ -50,7 +50,7 @@ public class QueryFilter
         ColumnFamily cf = memtable.getColumnFamily(key);
         if (cf == null)
             return null;
-        return getMemtableColumnIterator(cf, StorageService.getPartitioner().decorateKey(key), comparator);
+        return getMemtableColumnIterator(cf, key, comparator);
     }
 
     public IColumnIterator getMemtableColumnIterator(ColumnFamily cf, DecoratedKey key, AbstractType comparator)
@@ -153,7 +153,7 @@ public class QueryFilter
      * @param reversed true to start with the largest column (as determined by configured sort order) instead of smallest
      * @param limit maximum number of non-deleted columns to return
      */
-    public static QueryFilter getSliceFilter(String key, QueryPath path, byte[] start, byte[] finish, List<byte[]> bitmasks, boolean reversed, int limit)
+    public static QueryFilter getSliceFilter(DecoratedKey key, QueryPath path, byte[] start, byte[] finish, List<byte[]> bitmasks, boolean reversed, int limit)
     {
         return new QueryFilter(key, path, new SliceQueryFilter(start, finish, bitmasks, reversed, limit));
     }
@@ -162,7 +162,7 @@ public class QueryFilter
      * return a QueryFilter object that includes every column in the row.
      * This is dangerous on large rows; avoid except for test code.
      */
-    public static QueryFilter getIdentityFilter(String key, QueryPath path)
+    public static QueryFilter getIdentityFilter(DecoratedKey key, QueryPath path)
     {
         return new QueryFilter(key, path, new IdentityQueryFilter());
     }
@@ -173,7 +173,7 @@ public class QueryFilter
      * @param path path to the level to slice at (CF or SuperColumn)
      * @param columns the column names to restrict the results to
      */
-    public static QueryFilter getNamesFilter(String key, QueryPath path, SortedSet<byte[]> columns)
+    public static QueryFilter getNamesFilter(DecoratedKey key, QueryPath path, SortedSet<byte[]> columns)
     {
         return new QueryFilter(key, path, new NamesQueryFilter(columns));
     }
@@ -181,7 +181,7 @@ public class QueryFilter
     /**
      * convenience method for creating a name filter matching a single column
      */
-    public static QueryFilter getNamesFilter(String key, QueryPath path, byte[] column)
+    public static QueryFilter getNamesFilter(DecoratedKey key, QueryPath path, byte[] column)
     {
         return new QueryFilter(key, path, new NamesQueryFilter(column));
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableNamesIterator.java Wed Apr 14 19:53:06 2010
@@ -46,11 +46,11 @@ public class SSTableNamesIterator extend
     private ColumnFamily cf;
     private Iterator<IColumn> iter;
     public final SortedSet<byte[]> columns;
-    private DecoratedKey decoratedKey;
+    public final DecoratedKey decoratedKey;
     
-    public SSTableNamesIterator(SSTableReader ssTable, String key, SortedSet<byte[]> columnNames)
+    public SSTableNamesIterator(SSTableReader ssTable, DecoratedKey key, SortedSet<byte[]> columnNames)
     {
-        this (ssTable, null, ssTable.getPartitioner().decorateKey(key), columnNames);
+        this (ssTable, null, key, columnNames);
     }
 
     public SSTableNamesIterator(SSTableReader ssTable, FileDataInput file, DecoratedKey key, SortedSet<byte[]> columnNames)

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/filter/SSTableSliceIterator.java Wed Apr 14 19:53:06 2010
@@ -52,9 +52,9 @@ class SSTableSliceIterator extends Abstr
     private boolean closeFileWhenDone = false;
     private DecoratedKey decoratedKey;
     
-    public SSTableSliceIterator(SSTableReader ssTable, String key, byte[] startColumn, byte[] finishColumn, Predicate<IColumn> predicate, boolean reversed)
+    public SSTableSliceIterator(SSTableReader ssTable, DecoratedKey key, byte[] startColumn, byte[] finishColumn, Predicate<IColumn> predicate, boolean reversed)
     {
-        this(ssTable, null, ssTable.getPartitioner().decorateKey(key), startColumn, finishColumn, predicate, reversed); 
+        this(ssTable, null, key, startColumn, finishColumn, predicate, reversed); 
     }
     
     public SSTableSliceIterator(SSTableReader ssTable, FileDataInput file, DecoratedKey key, byte[] startColumn, byte[] finishColumn, Predicate<IColumn> predicate, boolean reversed) 

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/filter/SliceQueryFilter.java Wed Apr 14 19:53:06 2010
@@ -63,7 +63,7 @@ public class SliceQueryFilter implements
         return Memtable.getSliceIterator(key, cf, this, comparator);
     }
 
-    public IColumnIterator getSSTableColumnIterator(SSTableReader sstable, String key)
+    public IColumnIterator getSSTableColumnIterator(SSTableReader sstable, DecoratedKey key)
     {
         return new SSTableSliceIterator(sstable, key, start, finish, getPredicate(), reversed);
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/db/migration/Migration.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/db/migration/Migration.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/db/migration/Migration.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/db/migration/Migration.java Wed Apr 14 19:53:06 2010
@@ -23,6 +23,7 @@ import org.apache.cassandra.config.KSMet
 import org.apache.cassandra.db.ColumnFamily;
 import org.apache.cassandra.db.ColumnFamilyStore;
 import org.apache.cassandra.db.CompactionManager;
+import org.apache.cassandra.db.DecoratedKey;
 import org.apache.cassandra.db.IColumn;
 import org.apache.cassandra.db.RowMutation;
 import org.apache.cassandra.db.Table;
@@ -34,7 +35,9 @@ import org.apache.cassandra.gms.Applicat
 import org.apache.cassandra.gms.Gossiper;
 import org.apache.cassandra.io.ICompactSerializer;
 import org.apache.cassandra.service.MigrationManager;
+import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.UUIDGen;
+import static org.apache.cassandra.utils.FBUtilities.UTF8;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -75,8 +78,8 @@ public abstract class Migration
     
     public static final String MIGRATIONS_CF = "Migrations";
     public static final String SCHEMA_CF = "Schema";
-    public static final String MIGRATIONS_KEY = "Migrations Key";
-    public static final String LAST_MIGRATION_KEY = "Last Migration";
+    public static final byte[] MIGRATIONS_KEY = "Migrations Key".getBytes(UTF8);
+    public static final byte[] LAST_MIGRATION_KEY = "Last Migration".getBytes(UTF8);
     
     protected RowMutation rm;
     protected final UUID newVersion;
@@ -108,7 +111,7 @@ public abstract class Migration
         // note that we storing this in the system table, which is not replicated, instead of the definitions table, which is.
         logger.debug("Applying migration " + newVersion.toString());
         migration = new RowMutation(Table.DEFINITIONS, LAST_MIGRATION_KEY);
-        migration.add(new QueryPath(SCHEMA_CF, null, LAST_MIGRATION_KEY.getBytes()), UUIDGen.decompose(newVersion), now);
+        migration.add(new QueryPath(SCHEMA_CF, null, LAST_MIGRATION_KEY), UUIDGen.decompose(newVersion), now);
         migration.apply();
         
         // flush changes out of memtables so we don't need to rely on the commit log.
@@ -141,14 +144,15 @@ public abstract class Migration
     
     public static UUID getLastMigrationId()
     {
+        DecoratedKey dkey = StorageService.getPartitioner().decorateKey(LAST_MIGRATION_KEY);
         Table defs = Table.open(Table.DEFINITIONS);
         ColumnFamilyStore cfStore = defs.getColumnFamilyStore(SCHEMA_CF);
-        QueryFilter filter = QueryFilter.getNamesFilter(LAST_MIGRATION_KEY, new QueryPath(SCHEMA_CF), LAST_MIGRATION_KEY.getBytes());
+        QueryFilter filter = QueryFilter.getNamesFilter(dkey, new QueryPath(SCHEMA_CF), LAST_MIGRATION_KEY);
         ColumnFamily cf = cfStore.getColumnFamily(filter);
         if (cf == null || cf.getColumnNames().size() == 0)
             return null;
         else
-            return UUIDGen.makeType1UUID(cf.getColumn(LAST_MIGRATION_KEY.getBytes()).value());
+            return UUIDGen.makeType1UUID(cf.getColumn(LAST_MIGRATION_KEY).value());
     }
     
     /** keep in mind that applyLive might happen on another machine */
@@ -171,11 +175,11 @@ public abstract class Migration
     {
         return newVersion;
     }
-    
+
     static RowMutation makeDefinitionMutation(KSMetaData add, KSMetaData remove, UUID versionId) throws IOException
     {
         final long now = System.currentTimeMillis();
-        RowMutation rm = new RowMutation(Table.DEFINITIONS, versionId.toString());
+        RowMutation rm = new RowMutation(Table.DEFINITIONS, toBytes(versionId));
         if (remove != null)
             rm.delete(new QueryPath(SCHEMA_CF, null, remove.name.getBytes()), System.currentTimeMillis());
         if (add != null)
@@ -226,11 +230,16 @@ public abstract class Migration
     /** load serialized migrations. */
     public static Collection<IColumn> getLocalMigrations(UUID start, UUID end)
     {
+        DecoratedKey dkey = StorageService.getPartitioner().decorateKey(MIGRATIONS_KEY);
         Table defs = Table.open(Table.DEFINITIONS);
         ColumnFamilyStore cfStore = defs.getColumnFamilyStore(Migration.MIGRATIONS_CF);
-        QueryFilter filter = QueryFilter.getSliceFilter(Migration.MIGRATIONS_KEY, new QueryPath(MIGRATIONS_CF), UUIDGen.decompose(start), UUIDGen.decompose(end), null, false, 1000);
+        QueryFilter filter = QueryFilter.getSliceFilter(dkey, new QueryPath(MIGRATIONS_CF), UUIDGen.decompose(start), UUIDGen.decompose(end), null, false, 1000);
         ColumnFamily cf = cfStore.getColumnFamily(filter);
         return cf.getSortedColumns();
     }
     
+    public static byte[] toBytes(UUID version)
+    {
+        return version.toString().getBytes(UTF8);
+    }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/dht/CollatingOrderPreservingPartitioner.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/dht/CollatingOrderPreservingPartitioner.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/dht/CollatingOrderPreservingPartitioner.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/dht/CollatingOrderPreservingPartitioner.java Wed Apr 14 19:53:06 2010
@@ -39,15 +39,14 @@ public class CollatingOrderPreservingPar
     
     public static final BigInteger BYTE_MASK = new BigInteger("255");
 
-    public DecoratedKey<BytesToken> decorateKey(String key)
+    public DecoratedKey<BytesToken> decorateKey(byte[] key)
     {
         return new DecoratedKey<BytesToken>(getToken(key), key);
     }
     
-    public DecoratedKey<BytesToken> convertFromDiskFormat(byte[] fromdisk)
+    public DecoratedKey<BytesToken> convertFromDiskFormat(byte[] key)
     {
-        String key = new String(fromdisk, FBUtilities.UTF8);
-        return new DecoratedKey<BytesToken>(getToken(key), fromdisk);
+        return new DecoratedKey<BytesToken>(getToken(key), key);
     }
 
     public byte[] convertToDiskFormat(DecoratedKey<BytesToken> key)
@@ -147,10 +146,11 @@ public class CollatingOrderPreservingPar
         return true;
     }
 
-    public BytesToken getToken(String key)
+    public BytesToken getToken(byte[] key)
     {
-        if (key.isEmpty())
+        if (key.length == 0)
             return MINIMUM;
-        return new BytesToken(collator.getCollationKey(key).toByteArray());
+        String skey = new String(key, FBUtilities.UTF8);
+        return new BytesToken(collator.getCollationKey(skey).toByteArray());
     }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/dht/IPartitioner.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/dht/IPartitioner.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/dht/IPartitioner.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/dht/IPartitioner.java Wed Apr 14 19:53:06 2010
@@ -46,7 +46,7 @@ public interface IPartitioner<T extends 
      * @return decorated version of key
      */
     @Deprecated
-    public DecoratedKey<T> decorateKey(String key);
+    public DecoratedKey<T> decorateKey(byte[] key);
 
     /**
      * Calculate a Token representing the approximate "middle" of the given
@@ -67,7 +67,7 @@ public interface IPartitioner<T extends 
      * for that, use TokenFactory.fromString.)
      */
     @Deprecated
-    public T getToken(String key);
+    public T getToken(byte[] key);
 
     /**
      * @return a randomly generated token

Modified: cassandra/trunk/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/dht/OrderPreservingPartitioner.java Wed Apr 14 19:53:06 2010
@@ -35,15 +35,14 @@ public class OrderPreservingPartitioner 
 
     public static final BigInteger CHAR_MASK = new BigInteger("65535");
 
-    public DecoratedKey<StringToken> decorateKey(String key)
+    public DecoratedKey<StringToken> decorateKey(byte[] key)
     {
-        return new DecoratedKey<StringToken>(new StringToken(key), key);
+        return new DecoratedKey<StringToken>(getToken(key), key);
     }
     
-    public DecoratedKey<StringToken> convertFromDiskFormat(byte[] fromdisk)
+    public DecoratedKey<StringToken> convertFromDiskFormat(byte[] key)
     {
-        String key = new String(fromdisk, FBUtilities.UTF8);
-        return new DecoratedKey<StringToken>(new StringToken(key), fromdisk);
+        return new DecoratedKey<StringToken>(getToken(key), key);
     }
 
     public byte[] convertToDiskFormat(DecoratedKey<StringToken> key)
@@ -162,8 +161,8 @@ public class OrderPreservingPartitioner 
         return true;
     }
 
-    public StringToken getToken(String key)
+    public StringToken getToken(byte[] key)
     {
-        return new StringToken(key);
+        return new StringToken(new String(key, FBUtilities.UTF8));
     }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/dht/RandomPartitioner.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/dht/RandomPartitioner.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/dht/RandomPartitioner.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/dht/RandomPartitioner.java Wed Apr 14 19:53:06 2010
@@ -40,7 +40,7 @@ public class RandomPartitioner implement
 
     private static final byte DELIMITER_BYTE = ":".getBytes()[0];
 
-    public DecoratedKey<BigIntegerToken> decorateKey(String key)
+    public DecoratedKey<BigIntegerToken> decorateKey(byte[] key)
     {
         return new DecoratedKey<BigIntegerToken>(getToken(key), key);
     }
@@ -94,8 +94,7 @@ public class RandomPartitioner implement
 
     public BigIntegerToken getRandomToken()
     {
-        String guid = GuidGenerator.guid();
-        BigInteger token = FBUtilities.hash(guid);
+        BigInteger token = FBUtilities.md5hash(GuidGenerator.guid().getBytes());
         if ( token.signum() == -1 )
             token = token.multiply(BigInteger.valueOf(-1L));
         return new BigIntegerToken(token);
@@ -133,10 +132,10 @@ public class RandomPartitioner implement
         return false;
     }
 
-    public BigIntegerToken getToken(String key)
+    public BigIntegerToken getToken(byte[] key)
     {
-        if (key.isEmpty())
+        if (key.length == 0)
             return MINIMUM;
-        return new BigIntegerToken(FBUtilities.hash(key));
+        return new BigIntegerToken(FBUtilities.md5hash(key));
     }
 }

Modified: cassandra/trunk/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java Wed Apr 14 19:53:06 2010
@@ -36,6 +36,7 @@ import org.apache.cassandra.dht.IPartiti
 import org.apache.cassandra.thrift.*;
 import org.apache.cassandra.thrift.Column;
 import org.apache.cassandra.thrift.SuperColumn;
+import static org.apache.cassandra.utils.FBUtilities.UTF8;
 import org.apache.cassandra.utils.Pair;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.mapreduce.InputSplit;
@@ -158,7 +159,9 @@ public class ColumnFamilyRecordReader ex
                 // prepare for the next slice to be read
                 KeySlice lastRow = rows.get(rows.size() - 1);
                 IPartitioner p = DatabaseDescriptor.getPartitioner();
-                startToken = p.getTokenFactory().toString(p.getToken(lastRow.getKey()));
+                // FIXME: thrift strings
+                byte[] rowkey = lastRow.getKey().getBytes(UTF8);
+                startToken = p.getTokenFactory().toString(p.getToken(rowkey));
             }
             catch (Exception e)
             {

Modified: cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableTracker.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableTracker.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableTracker.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/io/sstable/SSTableTracker.java Wed Apr 14 19:53:06 2010
@@ -44,7 +44,7 @@ public class SSTableTracker implements I
     private final String cfname;
 
     private final JMXInstrumentedCache<Pair<SSTable.Descriptor,DecoratedKey>,SSTable.PositionSize> keyCache;
-    private final JMXInstrumentedCache<String, ColumnFamily> rowCache;
+    private final JMXInstrumentedCache<DecoratedKey, ColumnFamily> rowCache;
 
     public SSTableTracker(String ksname, String cfname)
     {
@@ -52,7 +52,7 @@ public class SSTableTracker implements I
         this.cfname = cfname;
         sstables = Collections.emptySet();
         keyCache = new JMXInstrumentedCache<Pair<SSTable.Descriptor,DecoratedKey>,SSTable.PositionSize>(ksname, cfname + "KeyCache", 0);
-        rowCache = new JMXInstrumentedCache<String, ColumnFamily>(ksname, cfname + "RowCache", 0);
+        rowCache = new JMXInstrumentedCache<DecoratedKey, ColumnFamily>(ksname, cfname + "RowCache", 0);
     }
 
     public synchronized void replace(Collection<SSTableReader> oldSSTables, Iterable<SSTableReader> replacements)
@@ -139,7 +139,7 @@ public class SSTableTracker implements I
         sstables = Collections.emptySet();
     }
 
-    public JMXInstrumentedCache<String, ColumnFamily> getRowCache()
+    public JMXInstrumentedCache<DecoratedKey, ColumnFamily> getRowCache()
     {
         return rowCache;
     }

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/RangeSliceResponseResolver.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/RangeSliceResponseResolver.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/RangeSliceResponseResolver.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/RangeSliceResponseResolver.java Wed Apr 14 19:53:06 2010
@@ -29,6 +29,7 @@ import org.apache.commons.collections.it
 
 import com.google.common.collect.AbstractIterator;
 import org.apache.cassandra.db.ColumnFamily;
+import org.apache.cassandra.db.DecoratedKey;
 import org.apache.cassandra.db.RangeSliceReply;
 import org.apache.cassandra.db.Row;
 import org.apache.cassandra.net.Message;
@@ -75,7 +76,7 @@ public class RangeSliceResponseResolver 
         {
             List<ColumnFamily> versions = new ArrayList<ColumnFamily>(sources.size());
             List<InetAddress> versionSources = new ArrayList<InetAddress>(sources.size());
-            String key;
+            DecoratedKey key;
 
             @Override
             protected boolean isEqual(Pair<Row, InetAddress> o1, Pair<Row, InetAddress> o2)

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/ReadResponseResolver.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/ReadResponseResolver.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/ReadResponseResolver.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/ReadResponseResolver.java Wed Apr 14 19:53:06 2010
@@ -26,11 +26,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
 
-import org.apache.cassandra.db.ColumnFamily;
-import org.apache.cassandra.db.ReadResponse;
-import org.apache.cassandra.db.Row;
-import org.apache.cassandra.db.RowMutation;
-import org.apache.cassandra.db.RowMutationMessage;
+import org.apache.cassandra.db.*;
 import java.net.InetAddress;
 import org.apache.cassandra.net.Message;
 import org.apache.cassandra.utils.FBUtilities;
@@ -70,7 +66,7 @@ public class ReadResponseResolver implem
         long startTime = System.currentTimeMillis();
 		List<ColumnFamily> versions = new ArrayList<ColumnFamily>();
 		List<InetAddress> endPoints = new ArrayList<InetAddress>();
-		String key = null;
+		DecoratedKey key = null;
 		byte[] digest = new byte[0];
 		boolean isDigestQuery = false;
         
@@ -124,7 +120,7 @@ public class ReadResponseResolver implem
      * For each row version, compare with resolved (the superset of all row versions);
      * if it is missing anything, send a mutation to the endpoint it come from.
      */
-    public static void maybeScheduleRepairs(ColumnFamily resolved, String table, String key, List<ColumnFamily> versions, List<InetAddress> endPoints)
+    public static void maybeScheduleRepairs(ColumnFamily resolved, String table, DecoratedKey key, List<ColumnFamily> versions, List<InetAddress> endPoints)
     {
         for (int i = 0; i < versions.size(); i++)
         {
@@ -133,7 +129,7 @@ public class ReadResponseResolver implem
                 continue;
 
             // create and send the row mutation message based on the diff
-            RowMutation rowMutation = new RowMutation(table, key);
+            RowMutation rowMutation = new RowMutation(table, key.key);
             rowMutation.add(diffCf);
             RowMutationMessage rowMutationMessage = new RowMutationMessage(rowMutation);
             ReadRepairManager.instance.schedule(endPoints.get(i), rowMutationMessage);

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageProxy.java Wed Apr 14 19:53:06 2010
@@ -82,15 +82,6 @@ public class StorageProxy implements Sto
         }
     }
 
-    private static final Comparator<String> keyComparator = new Comparator<String>()
-    {
-        public int compare(String o1, String o2)
-        {
-            IPartitioner<?> p = StorageService.getPartitioner();
-            return p.decorateKey(o1).compareTo(p.decorateKey(o2));
-        }
-    };
-
     /**
      * Use this method to have these RowMutations applied
      * across all replicas. This method will take care

Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=934154&r1=934153&r2=934154&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Wed Apr 14 19:53:06 2010
@@ -1170,7 +1170,7 @@ public class StorageService implements I
      * @param key - key for which we need to find the endpoint return value -
      * the endpoint responsible for this key
      */
-    public List<InetAddress> getNaturalEndpoints(String table, String key)
+    public List<InetAddress> getNaturalEndpoints(String table, byte[] key)
     {
         return getNaturalEndpoints(table, partitioner_.getToken(key));
     }
@@ -1194,7 +1194,7 @@ public class StorageService implements I
      * @param key - key for which we need to find the endpoint return value -
      * the endpoint responsible for this key
      */
-    public List<InetAddress> getLiveNaturalEndpoints(String table, String key)
+    public List<InetAddress> getLiveNaturalEndpoints(String table, byte[] key)
     {
         return getLiveNaturalEndpoints(table, partitioner_.getToken(key));
     }
@@ -1216,7 +1216,7 @@ public class StorageService implements I
     /**
      * This function finds the closest live endpoint that contains a given key.
      */
-    public InetAddress findSuitableEndPoint(String table, String key) throws IOException, UnavailableException
+    public InetAddress findSuitableEndPoint(String table, byte[] key) throws IOException, UnavailableException
     {
         List<InetAddress> endpoints = getNaturalEndpoints(table, key);
         DatabaseDescriptor.getEndPointSnitch(table).sortByProximity(FBUtilities.getLocalAddress(), endpoints);



Mime
View raw message