cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r938500 - in /cassandra/trunk/src/java/org/apache/cassandra: avro/CassandraServer.java thrift/CassandraServer.java
Date Tue, 27 Apr 2010 15:14:07 GMT
Author: jbellis
Date: Tue Apr 27 15:14:07 2010
New Revision: 938500

URL: http://svn.apache.org/viewvc?rev=938500&view=rev
Log:
use DecorateKey instead of byte[] in maps where object identity is insufficient to determine
equality
patch by Vijay Parthasarathy; reviewed by jbellis for CASSANDRA-1020

Modified:
    cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java
    cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.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=938500&r1=938499&r2=938500&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/avro/CassandraServer.java Tue Apr 27 15:14:07
2010
@@ -36,16 +36,14 @@ import org.apache.avro.generic.GenericDa
 import org.apache.avro.ipc.AvroRemoteException;
 import org.apache.avro.util.Utf8;
 import org.apache.cassandra.config.DatabaseDescriptor;
-import org.apache.cassandra.db.ColumnFamily;
-import org.apache.cassandra.db.IColumn;
-import org.apache.cassandra.db.ReadCommand;
-import org.apache.cassandra.db.Row;
-import org.apache.cassandra.db.RowMutation;
-import org.apache.cassandra.db.SliceByNamesReadCommand;
+import org.apache.cassandra.db.*;
 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.apache.cassandra.service.StorageService;
+import org.apache.cassandra.utils.Bytes;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import static org.apache.cassandra.avro.AvroRecordFactory.*;
@@ -132,12 +130,12 @@ public class CassandraServer implements 
     private Map<String, Collection<IColumn>> multigetColumns(List<ReadCommand>
commands, ConsistencyLevel level)
     throws InvalidRequestException, UnavailableException, TimedOutException
     {
-        Map<byte[], ColumnFamily> cfamilies = readColumnFamily(commands, level);
+        Map<DecoratedKey, ColumnFamily> cfamilies = readColumnFamily(commands, level);
         Map<String, Collection<IColumn>> columnFamiliesMap = new HashMap<String,
Collection<IColumn>>();
         
         for (ReadCommand command : commands)
         {
-            ColumnFamily cfamily = cfamilies.get(command.key);
+            ColumnFamily cfamily = cfamilies.get(StorageService.getPartitioner().decorateKey(command.key));
             if (cfamily == null)
                 continue;
 
@@ -165,11 +163,11 @@ public class CassandraServer implements 
         return columnFamiliesMap;
     }
     
-    protected Map<byte[], ColumnFamily> readColumnFamily(List<ReadCommand> commands,
ConsistencyLevel consistency)
+    protected Map<DecoratedKey, 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<byte[], ColumnFamily> columnFamilyKeyMap = new HashMap<byte[],ColumnFamily>();
+        Map<DecoratedKey, ColumnFamily> columnFamilyKeyMap = new HashMap<DecoratedKey,
ColumnFamily>();
         
         if (consistency == ConsistencyLevel.ZERO)
             throw newInvalidRequestException("Consistency level zero may not be applied to
read operations");
@@ -199,7 +197,7 @@ public class CassandraServer implements 
 
         for (Row row: rows)
         {
-            columnFamilyKeyMap.put(row.key.key, row.cf);
+            columnFamilyKeyMap.put(row.key, row.cf);
         }
         
         return columnFamilyKeyMap;

Modified: cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java?rev=938500&r1=938499&r2=938500&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/thrift/CassandraServer.java Tue Apr 27 15:14:07
2010
@@ -84,11 +84,11 @@ public class CassandraServer implements 
         storageService = StorageService.instance;
     }
     
-    protected Map<byte[], ColumnFamily> readColumnFamily(List<ReadCommand> commands,
ConsistencyLevel consistency_level)
+    protected Map<DecoratedKey, ColumnFamily> readColumnFamily(List<ReadCommand>
commands, ConsistencyLevel consistency_level)
     throws InvalidRequestException, UnavailableException, TimedOutException
     {
         // TODO - Support multiple column families per row, right now row only contains 1
column family
-        Map<byte[], ColumnFamily> columnFamilyKeyMap = new HashMap<byte[],ColumnFamily>();
+        Map<DecoratedKey, ColumnFamily> columnFamilyKeyMap = new HashMap<DecoratedKey,
ColumnFamily>();
 
         if (consistency_level == ConsistencyLevel.ZERO)
         {
@@ -119,7 +119,7 @@ public class CassandraServer implements 
 
         for (Row row: rows)
         {
-            columnFamilyKeyMap.put(row.key.key, row.cf);
+            columnFamilyKeyMap.put(row.key, row.cf);
         }
         return columnFamilyKeyMap;
     }
@@ -197,11 +197,11 @@ public class CassandraServer implements 
     private Map<byte[], List<ColumnOrSuperColumn>> getSlice(List<ReadCommand>
commands, ConsistencyLevel consistency_level)
     throws InvalidRequestException, UnavailableException, TimedOutException
     {
-        Map<byte[], ColumnFamily> columnFamilies = readColumnFamily(commands, consistency_level);
+        Map<DecoratedKey, ColumnFamily> columnFamilies = readColumnFamily(commands,
consistency_level);
         Map<byte[], List<ColumnOrSuperColumn>> columnFamiliesMap = new HashMap<byte[],
List<ColumnOrSuperColumn>>();
         for (ReadCommand command: commands)
         {
-            ColumnFamily cf = columnFamilies.get(command.key);
+            ColumnFamily cf = columnFamilies.get(StorageService.getPartitioner().decorateKey(command.key));
             boolean reverseOrder = command instanceof SliceFromReadCommand && ((SliceFromReadCommand)command).reversed;
             List<ColumnOrSuperColumn> thriftifiedColumns = thriftifyColumnFamily(cf,
command.queryPath.superColumnName != null, reverseOrder);
             columnFamiliesMap.put(command.key, thriftifiedColumns);
@@ -321,12 +321,12 @@ public class CassandraServer implements 
         }
 
         Map<byte[], ColumnOrSuperColumn> columnFamiliesMap = new HashMap<byte[],
ColumnOrSuperColumn>();
-        Map<byte[], ColumnFamily> cfamilies = readColumnFamily(commands, consistency_level);
+        Map<DecoratedKey, ColumnFamily> cfamilies = readColumnFamily(commands, consistency_level);
 
 
         for (ReadCommand command: commands)
         {
-            ColumnFamily cf = cfamilies.get(command.key);
+            ColumnFamily cf = cfamilies.get(StorageService.getPartitioner().decorateKey(command.key));
             if (cf == null)
             {
                 columnFamiliesMap.put(command.key, new ColumnOrSuperColumn());



Mime
View raw message