From f3a4e1736b2fedb84abc27c23ae1f299fde3def6 Mon Sep 17 00:00:00 2001 From: Gary Dusbabek Date: Wed, 14 Apr 2010 19:53:23 +0000 Subject: [PATCH] convert thrift to byte keys. Patch by Stu Hood, reviewed by Gary Dusbabek. CASSANDRA-767 git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@934155 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop/pig/CassandraStorage.java | 2 +- contrib/word_count/src/WordCount.java | 4 +- interface/cassandra.thrift | 38 +- .../apache/cassandra/thrift/Cassandra.java | 445 ++++++++++-------- .../apache/cassandra/thrift/Constants.java | 2 +- .../org/apache/cassandra/thrift/KeyRange.java | 48 +- .../org/apache/cassandra/thrift/KeySlice.java | 26 +- .../org/apache/cassandra/cli/CliClient.java | 10 +- .../hadoop/ColumnFamilyInputFormat.java | 4 +- .../hadoop/ColumnFamilyRecordReader.java | 15 +- .../cassandra/thrift/CassandraServer.java | 76 ++- .../cassandra/thrift/ThriftValidation.java | 19 +- .../cassandra/client/TestRingCache.java | 8 +- .../service/EmbeddedCassandraServiceTest.java | 2 +- 14 files changed, 378 insertions(+), 321 deletions(-) diff --git a/contrib/pig/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java b/contrib/pig/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java index 371ca18ad3..47a8a7ce6c 100644 --- a/contrib/pig/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java +++ b/contrib/pig/src/java/org/apache/cassandra/hadoop/pig/CassandraStorage.java @@ -60,7 +60,7 @@ public class CassandraStorage extends LoadFunc // load the next pair if (!reader.nextKeyValue()) return null; - String key = (String)reader.getCurrentKey(); + byte[] key = (byte[])reader.getCurrentKey(); SortedMap cf = (SortedMap)reader.getCurrentValue(); assert key != null && cf != null; diff --git a/contrib/word_count/src/WordCount.java b/contrib/word_count/src/WordCount.java index b7ae36690d..c850e04d07 100644 --- a/contrib/word_count/src/WordCount.java +++ b/contrib/word_count/src/WordCount.java @@ -63,13 +63,13 @@ public class WordCount extends Configured implements Tool System.exit(0); } - public static class TokenizerMapper extends Mapper, Text, IntWritable> + public static class TokenizerMapper extends Mapper, Text, IntWritable> { private final static IntWritable one = new IntWritable(1); private Text word = new Text(); private String columnName; - public void map(String key, SortedMap columns, Context context) throws IOException, InterruptedException + public void map(byte[] key, SortedMap columns, Context context) throws IOException, InterruptedException { IColumn column = columns.get(columnName.getBytes()); if (column == null) diff --git a/interface/cassandra.thrift b/interface/cassandra.thrift index b1f9592962..2ad7d24c5d 100644 --- a/interface/cassandra.thrift +++ b/interface/cassandra.thrift @@ -46,7 +46,7 @@ namespace rb CassandraThrift # for every edit that doesn't result in a change to major/minor. # # See the Semantic Versioning Specification (SemVer) http://semver.org. -const string VERSION = "3.0.0" +const string VERSION = "4.0.0" # # data structures @@ -240,8 +240,8 @@ one-element range, but a range from tokenY to tokenY is the full ring. */ struct KeyRange { - 1: optional string start_key, - 2: optional string end_key, + 1: optional binary start_key, + 2: optional binary end_key, 3: optional string start_token, 4: optional string end_token, 5: required i32 count=100 @@ -255,7 +255,7 @@ struct KeyRange { a SlicePredicate. */ struct KeySlice { - 1: required string key, + 1: required binary key, 2: required list columns, } @@ -334,7 +334,7 @@ service Cassandra { the only method that can throw an exception under non-failure conditions.) */ ColumnOrSuperColumn get(1:required string keyspace, - 2:required string key, + 2:required binary key, 3:required ColumnPath column_path, 4:required ConsistencyLevel consistency_level=ONE) throws (1:InvalidRequestException ire, 2:NotFoundException nfe, 3:UnavailableException ue, 4:TimedOutException te), @@ -344,20 +344,20 @@ service Cassandra { pair) specified by the given SlicePredicate. If no matching values are found, an empty list is returned. */ list get_slice(1:required string keyspace, - 2:required string key, + 2:required binary key, 3:required ColumnParent column_parent, 4:required SlicePredicate predicate, 5:required ConsistencyLevel consistency_level=ONE) throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te), /** - Perform a get for column_path in parallel on the given list keys. The return value maps keys to the + Perform a get for column_path in parallel on the given list keys. The return value maps keys to the ColumnOrSuperColumn found. If no value corresponding to a key is present, the key will still be in the map, but both the column and super_column references of the ColumnOrSuperColumn object it maps to will be null. @deprecated; use multiget_slice */ - map multiget(1:required string keyspace, - 2:required list keys, + map multiget(1:required string keyspace, + 2:required list keys, 3:required ColumnPath column_path, 4:required ConsistencyLevel consistency_level=ONE) throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te), @@ -365,8 +365,8 @@ service Cassandra { /** Performs a get_slice for column_parent and predicate for the given keys in parallel. */ - map> multiget_slice(1:required string keyspace, - 2:required list keys, + map> multiget_slice(1:required string keyspace, + 2:required list keys, 3:required ColumnParent column_parent, 4:required SlicePredicate predicate, 5:required ConsistencyLevel consistency_level=ONE) @@ -376,7 +376,7 @@ service Cassandra { returns the number of columns for a particular key and ColumnFamily or SuperColumn. */ i32 get_count(1:required string keyspace, - 2:required string key, + 2:required binary key, 3:required ColumnParent column_parent, 4:required ConsistencyLevel consistency_level=ONE) throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te), @@ -388,8 +388,8 @@ service Cassandra { list get_range_slice(1:required string keyspace, 2:required ColumnParent column_parent, 3:required SlicePredicate predicate, - 4:required string start_key="", - 5:required string finish_key="", + 4:required binary start_key, + 5:required binary finish_key, 6:required i32 row_count=100, 7:required ConsistencyLevel consistency_level=ONE) throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te), @@ -412,7 +412,7 @@ service Cassandra { values -- it can only contain sub-Columns. */ void insert(1:required string keyspace, - 2:required string key, + 2:required binary key, 3:required ColumnPath column_path, 4:required binary value, 5:required i64 timestamp, @@ -426,7 +426,7 @@ service Cassandra { @deprecated; use batch_mutate instead */ void batch_insert(1:required string keyspace, - 2:required string key, + 2:required binary key, 3:required map> cfmap, 4:required ConsistencyLevel consistency_level=ONE) throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te), @@ -437,7 +437,7 @@ service Cassandra { row by just specifying the ColumnFamily, or you can remove a SuperColumn or a single Column by specifying those levels too. */ void remove(1:required string keyspace, - 2:required string key, + 2:required binary key, 3:required ColumnPath column_path, 4:required i64 timestamp, 5:ConsistencyLevel consistency_level=ONE) @@ -449,7 +449,7 @@ service Cassandra { mutation_map maps key to column family to a list of Mutation objects to take place at that scope. **/ void batch_mutate(1:required string keyspace, - 2:required map>> mutation_map, + 2:required map>> mutation_map, 3:required ConsistencyLevel consistency_level=ONE) throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te), @@ -485,7 +485,7 @@ service Cassandra { returns list of token strings such that first subrange is (list[0], list[1]], next is (list[1], list[2]], etc. */ list describe_splits(1:required string start_token, - 2:required string end_token, + 2:required string end_token, 3:required i32 keys_per_split), void system_add_column_family(1:required CfDef cf_def) diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java index b3bc9aea61..50b2e59c25 100644 --- a/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java +++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java @@ -59,7 +59,7 @@ public class Cassandra { * @param column_path * @param consistency_level */ - public ColumnOrSuperColumn get(String keyspace, String key, ColumnPath column_path, ConsistencyLevel consistency_level) throws InvalidRequestException, NotFoundException, UnavailableException, TimedOutException, TException; + public ColumnOrSuperColumn get(String keyspace, byte[] key, ColumnPath column_path, ConsistencyLevel consistency_level) throws InvalidRequestException, NotFoundException, UnavailableException, TimedOutException, TException; /** * Get the group of columns contained by column_parent (either a ColumnFamily name or a ColumnFamily/SuperColumn name @@ -71,10 +71,10 @@ public class Cassandra { * @param predicate * @param consistency_level */ - public List get_slice(String keyspace, String key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; + public List get_slice(String keyspace, byte[] key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; /** - * Perform a get for column_path in parallel on the given list keys. The return value maps keys to the + * Perform a get for column_path in parallel on the given list keys. The return value maps keys to the * ColumnOrSuperColumn found. If no value corresponding to a key is present, the key will still be in the map, but both * the column and super_column references of the ColumnOrSuperColumn object it maps to will be null. * @deprecated; use multiget_slice @@ -84,7 +84,7 @@ public class Cassandra { * @param column_path * @param consistency_level */ - public Map multiget(String keyspace, List keys, ColumnPath column_path, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; + public Map multiget(String keyspace, List keys, ColumnPath column_path, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; /** * Performs a get_slice for column_parent and predicate for the given keys in parallel. @@ -95,7 +95,7 @@ public class Cassandra { * @param predicate * @param consistency_level */ - public Map> multiget_slice(String keyspace, List keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; + public Map> multiget_slice(String keyspace, List keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; /** * returns the number of columns for a particular key and ColumnFamily or SuperColumn. @@ -105,7 +105,7 @@ public class Cassandra { * @param column_parent * @param consistency_level */ - public int get_count(String keyspace, String key, ColumnParent column_parent, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; + public int get_count(String keyspace, byte[] key, ColumnParent column_parent, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; /** * returns a subset of columns for a range of keys. @@ -119,7 +119,7 @@ public class Cassandra { * @param row_count * @param consistency_level */ - public List get_range_slice(String keyspace, ColumnParent column_parent, SlicePredicate predicate, String start_key, String finish_key, int row_count, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; + public List get_range_slice(String keyspace, ColumnParent column_parent, SlicePredicate predicate, byte[] start_key, byte[] finish_key, int row_count, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; /** * returns a subset of columns for a range of keys. @@ -144,7 +144,7 @@ public class Cassandra { * @param timestamp * @param consistency_level */ - public void insert(String keyspace, String key, ColumnPath column_path, byte[] value, long timestamp, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; + public void insert(String keyspace, byte[] key, ColumnPath column_path, byte[] value, long timestamp, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; /** * Insert Columns or SuperColumns across different Column Families for the same row key. batch_mutation is a @@ -157,7 +157,7 @@ public class Cassandra { * @param cfmap * @param consistency_level */ - public void batch_insert(String keyspace, String key, Map> cfmap, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; + public void batch_insert(String keyspace, byte[] key, Map> cfmap, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; /** * Remove data from the row specified by key at the granularity specified by column_path, and the given timestamp. Note @@ -170,7 +170,7 @@ public class Cassandra { * @param timestamp * @param consistency_level */ - public void remove(String keyspace, String key, ColumnPath column_path, long timestamp, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; + public void remove(String keyspace, byte[] key, ColumnPath column_path, long timestamp, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; /** * Mutate many columns or super columns for many row keys. See also: Mutation. @@ -182,7 +182,7 @@ public class Cassandra { * @param mutation_map * @param consistency_level */ - public void batch_mutate(String keyspace, Map>> mutation_map, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; + public void batch_mutate(String keyspace, Map>> mutation_map, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException; /** * list the defined keyspaces in this cluster @@ -314,13 +314,13 @@ public class Cassandra { throw new TApplicationException(TApplicationException.MISSING_RESULT, "login failed: unknown result"); } - public ColumnOrSuperColumn get(String keyspace, String key, ColumnPath column_path, ConsistencyLevel consistency_level) throws InvalidRequestException, NotFoundException, UnavailableException, TimedOutException, TException + public ColumnOrSuperColumn get(String keyspace, byte[] key, ColumnPath column_path, ConsistencyLevel consistency_level) throws InvalidRequestException, NotFoundException, UnavailableException, TimedOutException, TException { send_get(keyspace, key, column_path, consistency_level); return recv_get(); } - public void send_get(String keyspace, String key, ColumnPath column_path, ConsistencyLevel consistency_level) throws TException + public void send_get(String keyspace, byte[] key, ColumnPath column_path, ConsistencyLevel consistency_level) throws TException { oprot_.writeMessageBegin(new TMessage("get", TMessageType.CALL, seqid_)); get_args args = new get_args(); @@ -362,13 +362,13 @@ public class Cassandra { throw new TApplicationException(TApplicationException.MISSING_RESULT, "get failed: unknown result"); } - public List get_slice(String keyspace, String key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException + public List get_slice(String keyspace, byte[] key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { send_get_slice(keyspace, key, column_parent, predicate, consistency_level); return recv_get_slice(); } - public void send_get_slice(String keyspace, String key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws TException + public void send_get_slice(String keyspace, byte[] key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws TException { oprot_.writeMessageBegin(new TMessage("get_slice", TMessageType.CALL, seqid_)); get_slice_args args = new get_slice_args(); @@ -408,13 +408,13 @@ public class Cassandra { throw new TApplicationException(TApplicationException.MISSING_RESULT, "get_slice failed: unknown result"); } - public Map multiget(String keyspace, List keys, ColumnPath column_path, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException + public Map multiget(String keyspace, List keys, ColumnPath column_path, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { send_multiget(keyspace, keys, column_path, consistency_level); return recv_multiget(); } - public void send_multiget(String keyspace, List keys, ColumnPath column_path, ConsistencyLevel consistency_level) throws TException + public void send_multiget(String keyspace, List keys, ColumnPath column_path, ConsistencyLevel consistency_level) throws TException { oprot_.writeMessageBegin(new TMessage("multiget", TMessageType.CALL, seqid_)); multiget_args args = new multiget_args(); @@ -427,7 +427,7 @@ public class Cassandra { oprot_.getTransport().flush(); } - public Map recv_multiget() throws InvalidRequestException, UnavailableException, TimedOutException, TException + public Map recv_multiget() throws InvalidRequestException, UnavailableException, TimedOutException, TException { TMessage msg = iprot_.readMessageBegin(); if (msg.type == TMessageType.EXCEPTION) { @@ -453,13 +453,13 @@ public class Cassandra { throw new TApplicationException(TApplicationException.MISSING_RESULT, "multiget failed: unknown result"); } - public Map> multiget_slice(String keyspace, List keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException + public Map> multiget_slice(String keyspace, List keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { send_multiget_slice(keyspace, keys, column_parent, predicate, consistency_level); return recv_multiget_slice(); } - public void send_multiget_slice(String keyspace, List keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws TException + public void send_multiget_slice(String keyspace, List keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws TException { oprot_.writeMessageBegin(new TMessage("multiget_slice", TMessageType.CALL, seqid_)); multiget_slice_args args = new multiget_slice_args(); @@ -473,7 +473,7 @@ public class Cassandra { oprot_.getTransport().flush(); } - public Map> recv_multiget_slice() throws InvalidRequestException, UnavailableException, TimedOutException, TException + public Map> recv_multiget_slice() throws InvalidRequestException, UnavailableException, TimedOutException, TException { TMessage msg = iprot_.readMessageBegin(); if (msg.type == TMessageType.EXCEPTION) { @@ -499,13 +499,13 @@ public class Cassandra { throw new TApplicationException(TApplicationException.MISSING_RESULT, "multiget_slice failed: unknown result"); } - public int get_count(String keyspace, String key, ColumnParent column_parent, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException + public int get_count(String keyspace, byte[] key, ColumnParent column_parent, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { send_get_count(keyspace, key, column_parent, consistency_level); return recv_get_count(); } - public void send_get_count(String keyspace, String key, ColumnParent column_parent, ConsistencyLevel consistency_level) throws TException + public void send_get_count(String keyspace, byte[] key, ColumnParent column_parent, ConsistencyLevel consistency_level) throws TException { oprot_.writeMessageBegin(new TMessage("get_count", TMessageType.CALL, seqid_)); get_count_args args = new get_count_args(); @@ -544,13 +544,13 @@ public class Cassandra { throw new TApplicationException(TApplicationException.MISSING_RESULT, "get_count failed: unknown result"); } - public List get_range_slice(String keyspace, ColumnParent column_parent, SlicePredicate predicate, String start_key, String finish_key, int row_count, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException + public List get_range_slice(String keyspace, ColumnParent column_parent, SlicePredicate predicate, byte[] start_key, byte[] finish_key, int row_count, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { send_get_range_slice(keyspace, column_parent, predicate, start_key, finish_key, row_count, consistency_level); return recv_get_range_slice(); } - public void send_get_range_slice(String keyspace, ColumnParent column_parent, SlicePredicate predicate, String start_key, String finish_key, int row_count, ConsistencyLevel consistency_level) throws TException + public void send_get_range_slice(String keyspace, ColumnParent column_parent, SlicePredicate predicate, byte[] start_key, byte[] finish_key, int row_count, ConsistencyLevel consistency_level) throws TException { oprot_.writeMessageBegin(new TMessage("get_range_slice", TMessageType.CALL, seqid_)); get_range_slice_args args = new get_range_slice_args(); @@ -638,13 +638,13 @@ public class Cassandra { throw new TApplicationException(TApplicationException.MISSING_RESULT, "get_range_slices failed: unknown result"); } - public void insert(String keyspace, String key, ColumnPath column_path, byte[] value, long timestamp, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException + public void insert(String keyspace, byte[] key, ColumnPath column_path, byte[] value, long timestamp, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { send_insert(keyspace, key, column_path, value, timestamp, consistency_level); recv_insert(); } - public void send_insert(String keyspace, String key, ColumnPath column_path, byte[] value, long timestamp, ConsistencyLevel consistency_level) throws TException + public void send_insert(String keyspace, byte[] key, ColumnPath column_path, byte[] value, long timestamp, ConsistencyLevel consistency_level) throws TException { oprot_.writeMessageBegin(new TMessage("insert", TMessageType.CALL, seqid_)); insert_args args = new insert_args(); @@ -682,13 +682,13 @@ public class Cassandra { return; } - public void batch_insert(String keyspace, String key, Map> cfmap, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException + public void batch_insert(String keyspace, byte[] key, Map> cfmap, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { send_batch_insert(keyspace, key, cfmap, consistency_level); recv_batch_insert(); } - public void send_batch_insert(String keyspace, String key, Map> cfmap, ConsistencyLevel consistency_level) throws TException + public void send_batch_insert(String keyspace, byte[] key, Map> cfmap, ConsistencyLevel consistency_level) throws TException { oprot_.writeMessageBegin(new TMessage("batch_insert", TMessageType.CALL, seqid_)); batch_insert_args args = new batch_insert_args(); @@ -724,13 +724,13 @@ public class Cassandra { return; } - public void remove(String keyspace, String key, ColumnPath column_path, long timestamp, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException + public void remove(String keyspace, byte[] key, ColumnPath column_path, long timestamp, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { send_remove(keyspace, key, column_path, timestamp, consistency_level); recv_remove(); } - public void send_remove(String keyspace, String key, ColumnPath column_path, long timestamp, ConsistencyLevel consistency_level) throws TException + public void send_remove(String keyspace, byte[] key, ColumnPath column_path, long timestamp, ConsistencyLevel consistency_level) throws TException { oprot_.writeMessageBegin(new TMessage("remove", TMessageType.CALL, seqid_)); remove_args args = new remove_args(); @@ -767,13 +767,13 @@ public class Cassandra { return; } - public void batch_mutate(String keyspace, Map>> mutation_map, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException + public void batch_mutate(String keyspace, Map>> mutation_map, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, TException { send_batch_mutate(keyspace, mutation_map, consistency_level); recv_batch_mutate(); } - public void send_batch_mutate(String keyspace, Map>> mutation_map, ConsistencyLevel consistency_level) throws TException + public void send_batch_mutate(String keyspace, Map>> mutation_map, ConsistencyLevel consistency_level) throws TException { oprot_.writeMessageBegin(new TMessage("batch_mutate", TMessageType.CALL, seqid_)); batch_mutate_args args = new batch_mutate_args(); @@ -2989,7 +2989,7 @@ public class Cassandra { private static final TField CONSISTENCY_LEVEL_FIELD_DESC = new TField("consistency_level", TType.I32, (short)4); public String keyspace; - public String key; + public byte[] key; public ColumnPath column_path; /** * @@ -3083,7 +3083,7 @@ public class Cassandra { public get_args( String keyspace, - String key, + byte[] key, ColumnPath column_path, ConsistencyLevel consistency_level) { @@ -3102,7 +3102,8 @@ public class Cassandra { this.keyspace = other.keyspace; } if (other.isSetKey()) { - this.key = other.key; + this.key = new byte[other.key.length]; + System.arraycopy(other.key, 0, key, 0, other.key.length); } if (other.isSetColumn_path()) { this.column_path = new ColumnPath(other.column_path); @@ -3145,11 +3146,11 @@ public class Cassandra { } } - public String getKey() { + public byte[] getKey() { return this.key; } - public get_args setKey(String key) { + public get_args setKey(byte[] key) { this.key = key; return this; } @@ -3239,7 +3240,7 @@ public class Cassandra { if (value == null) { unsetKey(); } else { - setKey((String)value); + setKey((byte[])value); } break; @@ -3334,7 +3335,7 @@ public class Cassandra { if (this_present_key || that_present_key) { if (!(this_present_key && that_present_key)) return false; - if (!this.key.equals(that.key)) + if (!java.util.Arrays.equals(this.key, that.key)) return false; } @@ -3430,7 +3431,7 @@ public class Cassandra { break; case 2: // KEY if (field.type == TType.STRING) { - this.key = iprot.readString(); + this.key = iprot.readBinary(); } else { TProtocolUtil.skip(iprot, field.type); } @@ -3472,7 +3473,7 @@ public class Cassandra { } if (this.key != null) { oprot.writeFieldBegin(KEY_FIELD_DESC); - oprot.writeString(this.key); + oprot.writeBinary(this.key); oprot.writeFieldEnd(); } if (this.column_path != null) { @@ -3506,7 +3507,12 @@ public class Cassandra { if (this.key == null) { sb.append("null"); } else { - sb.append(this.key); + int __key_size = Math.min(this.key.length, 128); + for (int i = 0; i < __key_size; i++) { + if (i != 0) sb.append(" "); + sb.append(Integer.toHexString(this.key[i]).length() > 1 ? Integer.toHexString(this.key[i]).substring(Integer.toHexString(this.key[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.key[i]).toUpperCase()); + } + if (this.key.length > 128) sb.append(" ..."); } first = false; if (!first) sb.append(", "); @@ -4178,7 +4184,7 @@ public class Cassandra { private static final TField CONSISTENCY_LEVEL_FIELD_DESC = new TField("consistency_level", TType.I32, (short)5); public String keyspace; - public String key; + public byte[] key; public ColumnParent column_parent; public SlicePredicate predicate; /** @@ -4276,7 +4282,7 @@ public class Cassandra { public get_slice_args( String keyspace, - String key, + byte[] key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) @@ -4297,7 +4303,8 @@ public class Cassandra { this.keyspace = other.keyspace; } if (other.isSetKey()) { - this.key = other.key; + this.key = new byte[other.key.length]; + System.arraycopy(other.key, 0, key, 0, other.key.length); } if (other.isSetColumn_parent()) { this.column_parent = new ColumnParent(other.column_parent); @@ -4343,11 +4350,11 @@ public class Cassandra { } } - public String getKey() { + public byte[] getKey() { return this.key; } - public get_slice_args setKey(String key) { + public get_slice_args setKey(byte[] key) { this.key = key; return this; } @@ -4461,7 +4468,7 @@ public class Cassandra { if (value == null) { unsetKey(); } else { - setKey((String)value); + setKey((byte[])value); } break; @@ -4569,7 +4576,7 @@ public class Cassandra { if (this_present_key || that_present_key) { if (!(this_present_key && that_present_key)) return false; - if (!this.key.equals(that.key)) + if (!java.util.Arrays.equals(this.key, that.key)) return false; } @@ -4683,7 +4690,7 @@ public class Cassandra { break; case 2: // KEY if (field.type == TType.STRING) { - this.key = iprot.readString(); + this.key = iprot.readBinary(); } else { TProtocolUtil.skip(iprot, field.type); } @@ -4733,7 +4740,7 @@ public class Cassandra { } if (this.key != null) { oprot.writeFieldBegin(KEY_FIELD_DESC); - oprot.writeString(this.key); + oprot.writeBinary(this.key); oprot.writeFieldEnd(); } if (this.column_parent != null) { @@ -4772,7 +4779,12 @@ public class Cassandra { if (this.key == null) { sb.append("null"); } else { - sb.append(this.key); + int __key_size = Math.min(this.key.length, 128); + for (int i = 0; i < __key_size; i++) { + if (i != 0) sb.append(" "); + sb.append(Integer.toHexString(this.key[i]).length() > 1 ? Integer.toHexString(this.key[i]).substring(Integer.toHexString(this.key[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.key[i]).toUpperCase()); + } + if (this.key.length > 128) sb.append(" ..."); } first = false; if (!first) sb.append(", "); @@ -5406,7 +5418,7 @@ public class Cassandra { private static final TField CONSISTENCY_LEVEL_FIELD_DESC = new TField("consistency_level", TType.I32, (short)4); public String keyspace; - public List keys; + public List keys; public ColumnPath column_path; /** * @@ -5501,7 +5513,7 @@ public class Cassandra { public multiget_args( String keyspace, - List keys, + List keys, ColumnPath column_path, ConsistencyLevel consistency_level) { @@ -5520,9 +5532,11 @@ public class Cassandra { this.keyspace = other.keyspace; } if (other.isSetKeys()) { - List __this__keys = new ArrayList(); - for (String other_element : other.keys) { - __this__keys.add(other_element); + List __this__keys = new ArrayList(); + for (byte[] other_element : other.keys) { + byte[] temp_binary_element = new byte[other_element.length]; + System.arraycopy(other_element, 0, temp_binary_element, 0, other_element.length); + __this__keys.add(temp_binary_element); } this.keys = __this__keys; } @@ -5571,22 +5585,22 @@ public class Cassandra { return (this.keys == null) ? 0 : this.keys.size(); } - public java.util.Iterator getKeysIterator() { + public java.util.Iterator getKeysIterator() { return (this.keys == null) ? null : this.keys.iterator(); } - public void addToKeys(String elem) { + public void addToKeys(byte[] elem) { if (this.keys == null) { - this.keys = new ArrayList(); + this.keys = new ArrayList(); } this.keys.add(elem); } - public List getKeys() { + public List getKeys() { return this.keys; } - public multiget_args setKeys(List keys) { + public multiget_args setKeys(List keys) { this.keys = keys; return this; } @@ -5676,7 +5690,7 @@ public class Cassandra { if (value == null) { unsetKeys(); } else { - setKeys((List)value); + setKeys((List)value); } break; @@ -5869,11 +5883,11 @@ public class Cassandra { if (field.type == TType.LIST) { { TList _list33 = iprot.readListBegin(); - this.keys = new ArrayList(_list33.size); + this.keys = new ArrayList(_list33.size); for (int _i34 = 0; _i34 < _list33.size; ++_i34) { - String _elem35; - _elem35 = iprot.readString(); + byte[] _elem35; + _elem35 = iprot.readBinary(); this.keys.add(_elem35); } iprot.readListEnd(); @@ -5921,9 +5935,9 @@ public class Cassandra { oprot.writeFieldBegin(KEYS_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRING, this.keys.size())); - for (String _iter36 : this.keys) + for (byte[] _iter36 : this.keys) { - oprot.writeString(_iter36); + oprot.writeBinary(_iter36); } oprot.writeListEnd(); } @@ -6009,7 +6023,7 @@ public class Cassandra { private static final TField UE_FIELD_DESC = new TField("ue", TType.STRUCT, (short)2); private static final TField TE_FIELD_DESC = new TField("te", TType.STRUCT, (short)3); - public Map success; + public Map success; public InvalidRequestException ire; public UnavailableException ue; public TimedOutException te; @@ -6095,7 +6109,7 @@ public class Cassandra { } public multiget_result( - Map success, + Map success, InvalidRequestException ire, UnavailableException ue, TimedOutException te) @@ -6112,13 +6126,14 @@ public class Cassandra { */ public multiget_result(multiget_result other) { if (other.isSetSuccess()) { - Map __this__success = new HashMap(); - for (Map.Entry other_element : other.success.entrySet()) { + Map __this__success = new HashMap(); + for (Map.Entry other_element : other.success.entrySet()) { - String other_element_key = other_element.getKey(); + byte[] other_element_key = other_element.getKey(); ColumnOrSuperColumn other_element_value = other_element.getValue(); - String __this__success_copy_key = other_element_key; + byte[] __this__success_copy_key = new byte[other_element_key.length]; + System.arraycopy(other_element_key, 0, __this__success_copy_key, 0, other_element_key.length); ColumnOrSuperColumn __this__success_copy_value = new ColumnOrSuperColumn(other_element_value); @@ -6150,18 +6165,18 @@ public class Cassandra { return (this.success == null) ? 0 : this.success.size(); } - public void putToSuccess(String key, ColumnOrSuperColumn val) { + public void putToSuccess(byte[] key, ColumnOrSuperColumn val) { if (this.success == null) { - this.success = new HashMap(); + this.success = new HashMap(); } this.success.put(key, val); } - public Map getSuccess() { + public Map getSuccess() { return this.success; } - public multiget_result setSuccess(Map success) { + public multiget_result setSuccess(Map success) { this.success = success; return this; } @@ -6259,7 +6274,7 @@ public class Cassandra { if (value == null) { unsetSuccess(); } else { - setSuccess((Map)value); + setSuccess((Map)value); } break; @@ -6406,12 +6421,12 @@ public class Cassandra { if (field.type == TType.MAP) { { TMap _map37 = iprot.readMapBegin(); - this.success = new HashMap(2*_map37.size); + this.success = new HashMap(2*_map37.size); for (int _i38 = 0; _i38 < _map37.size; ++_i38) { - String _key39; + byte[] _key39; ColumnOrSuperColumn _val40; - _key39 = iprot.readString(); + _key39 = iprot.readBinary(); _val40 = new ColumnOrSuperColumn(); _val40.read(iprot); this.success.put(_key39, _val40); @@ -6464,9 +6479,9 @@ public class Cassandra { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeMapBegin(new TMap(TType.STRING, TType.STRUCT, this.success.size())); - for (Map.Entry _iter41 : this.success.entrySet()) + for (Map.Entry _iter41 : this.success.entrySet()) { - oprot.writeString(_iter41.getKey()); + oprot.writeBinary(_iter41.getKey()); _iter41.getValue().write(oprot); } oprot.writeMapEnd(); @@ -6545,7 +6560,7 @@ public class Cassandra { private static final TField CONSISTENCY_LEVEL_FIELD_DESC = new TField("consistency_level", TType.I32, (short)5); public String keyspace; - public List keys; + public List keys; public ColumnParent column_parent; public SlicePredicate predicate; /** @@ -6644,7 +6659,7 @@ public class Cassandra { public multiget_slice_args( String keyspace, - List keys, + List keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) @@ -6665,9 +6680,11 @@ public class Cassandra { this.keyspace = other.keyspace; } if (other.isSetKeys()) { - List __this__keys = new ArrayList(); - for (String other_element : other.keys) { - __this__keys.add(other_element); + List __this__keys = new ArrayList(); + for (byte[] other_element : other.keys) { + byte[] temp_binary_element = new byte[other_element.length]; + System.arraycopy(other_element, 0, temp_binary_element, 0, other_element.length); + __this__keys.add(temp_binary_element); } this.keys = __this__keys; } @@ -6719,22 +6736,22 @@ public class Cassandra { return (this.keys == null) ? 0 : this.keys.size(); } - public java.util.Iterator getKeysIterator() { + public java.util.Iterator getKeysIterator() { return (this.keys == null) ? null : this.keys.iterator(); } - public void addToKeys(String elem) { + public void addToKeys(byte[] elem) { if (this.keys == null) { - this.keys = new ArrayList(); + this.keys = new ArrayList(); } this.keys.add(elem); } - public List getKeys() { + public List getKeys() { return this.keys; } - public multiget_slice_args setKeys(List keys) { + public multiget_slice_args setKeys(List keys) { this.keys = keys; return this; } @@ -6848,7 +6865,7 @@ public class Cassandra { if (value == null) { unsetKeys(); } else { - setKeys((List)value); + setKeys((List)value); } break; @@ -7072,11 +7089,11 @@ public class Cassandra { if (field.type == TType.LIST) { { TList _list42 = iprot.readListBegin(); - this.keys = new ArrayList(_list42.size); + this.keys = new ArrayList(_list42.size); for (int _i43 = 0; _i43 < _list42.size; ++_i43) { - String _elem44; - _elem44 = iprot.readString(); + byte[] _elem44; + _elem44 = iprot.readBinary(); this.keys.add(_elem44); } iprot.readListEnd(); @@ -7132,9 +7149,9 @@ public class Cassandra { oprot.writeFieldBegin(KEYS_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRING, this.keys.size())); - for (String _iter45 : this.keys) + for (byte[] _iter45 : this.keys) { - oprot.writeString(_iter45); + oprot.writeBinary(_iter45); } oprot.writeListEnd(); } @@ -7236,7 +7253,7 @@ public class Cassandra { private static final TField UE_FIELD_DESC = new TField("ue", TType.STRUCT, (short)2); private static final TField TE_FIELD_DESC = new TField("te", TType.STRUCT, (short)3); - public Map> success; + public Map> success; public InvalidRequestException ire; public UnavailableException ue; public TimedOutException te; @@ -7323,7 +7340,7 @@ public class Cassandra { } public multiget_slice_result( - Map> success, + Map> success, InvalidRequestException ire, UnavailableException ue, TimedOutException te) @@ -7340,13 +7357,14 @@ public class Cassandra { */ public multiget_slice_result(multiget_slice_result other) { if (other.isSetSuccess()) { - Map> __this__success = new HashMap>(); - for (Map.Entry> other_element : other.success.entrySet()) { + Map> __this__success = new HashMap>(); + for (Map.Entry> other_element : other.success.entrySet()) { - String other_element_key = other_element.getKey(); + byte[] other_element_key = other_element.getKey(); List other_element_value = other_element.getValue(); - String __this__success_copy_key = other_element_key; + byte[] __this__success_copy_key = new byte[other_element_key.length]; + System.arraycopy(other_element_key, 0, __this__success_copy_key, 0, other_element_key.length); List __this__success_copy_value = new ArrayList(); for (ColumnOrSuperColumn other_element_value_element : other_element_value) { @@ -7381,18 +7399,18 @@ public class Cassandra { return (this.success == null) ? 0 : this.success.size(); } - public void putToSuccess(String key, List val) { + public void putToSuccess(byte[] key, List val) { if (this.success == null) { - this.success = new HashMap>(); + this.success = new HashMap>(); } this.success.put(key, val); } - public Map> getSuccess() { + public Map> getSuccess() { return this.success; } - public multiget_slice_result setSuccess(Map> success) { + public multiget_slice_result setSuccess(Map> success) { this.success = success; return this; } @@ -7490,7 +7508,7 @@ public class Cassandra { if (value == null) { unsetSuccess(); } else { - setSuccess((Map>)value); + setSuccess((Map>)value); } break; @@ -7637,12 +7655,12 @@ public class Cassandra { if (field.type == TType.MAP) { { TMap _map46 = iprot.readMapBegin(); - this.success = new HashMap>(2*_map46.size); + this.success = new HashMap>(2*_map46.size); for (int _i47 = 0; _i47 < _map46.size; ++_i47) { - String _key48; + byte[] _key48; List _val49; - _key48 = iprot.readString(); + _key48 = iprot.readBinary(); { TList _list50 = iprot.readListBegin(); _val49 = new ArrayList(_list50.size); @@ -7705,9 +7723,9 @@ public class Cassandra { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeMapBegin(new TMap(TType.STRING, TType.LIST, this.success.size())); - for (Map.Entry> _iter53 : this.success.entrySet()) + for (Map.Entry> _iter53 : this.success.entrySet()) { - oprot.writeString(_iter53.getKey()); + oprot.writeBinary(_iter53.getKey()); { oprot.writeListBegin(new TList(TType.STRUCT, _iter53.getValue().size())); for (ColumnOrSuperColumn _iter54 : _iter53.getValue()) @@ -7792,7 +7810,7 @@ public class Cassandra { private static final TField CONSISTENCY_LEVEL_FIELD_DESC = new TField("consistency_level", TType.I32, (short)4); public String keyspace; - public String key; + public byte[] key; public ColumnParent column_parent; /** * @@ -7886,7 +7904,7 @@ public class Cassandra { public get_count_args( String keyspace, - String key, + byte[] key, ColumnParent column_parent, ConsistencyLevel consistency_level) { @@ -7905,7 +7923,8 @@ public class Cassandra { this.keyspace = other.keyspace; } if (other.isSetKey()) { - this.key = other.key; + this.key = new byte[other.key.length]; + System.arraycopy(other.key, 0, key, 0, other.key.length); } if (other.isSetColumn_parent()) { this.column_parent = new ColumnParent(other.column_parent); @@ -7948,11 +7967,11 @@ public class Cassandra { } } - public String getKey() { + public byte[] getKey() { return this.key; } - public get_count_args setKey(String key) { + public get_count_args setKey(byte[] key) { this.key = key; return this; } @@ -8042,7 +8061,7 @@ public class Cassandra { if (value == null) { unsetKey(); } else { - setKey((String)value); + setKey((byte[])value); } break; @@ -8137,7 +8156,7 @@ public class Cassandra { if (this_present_key || that_present_key) { if (!(this_present_key && that_present_key)) return false; - if (!this.key.equals(that.key)) + if (!java.util.Arrays.equals(this.key, that.key)) return false; } @@ -8233,7 +8252,7 @@ public class Cassandra { break; case 2: // KEY if (field.type == TType.STRING) { - this.key = iprot.readString(); + this.key = iprot.readBinary(); } else { TProtocolUtil.skip(iprot, field.type); } @@ -8275,7 +8294,7 @@ public class Cassandra { } if (this.key != null) { oprot.writeFieldBegin(KEY_FIELD_DESC); - oprot.writeString(this.key); + oprot.writeBinary(this.key); oprot.writeFieldEnd(); } if (this.column_parent != null) { @@ -8309,7 +8328,12 @@ public class Cassandra { if (this.key == null) { sb.append("null"); } else { - sb.append(this.key); + int __key_size = Math.min(this.key.length, 128); + for (int i = 0; i < __key_size; i++) { + if (i != 0) sb.append(" "); + sb.append(Integer.toHexString(this.key[i]).length() > 1 ? Integer.toHexString(this.key[i]).substring(Integer.toHexString(this.key[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.key[i]).toUpperCase()); + } + if (this.key.length > 128) sb.append(" ..."); } first = false; if (!first) sb.append(", "); @@ -8898,8 +8922,8 @@ public class Cassandra { public String keyspace; public ColumnParent column_parent; public SlicePredicate predicate; - public String start_key; - public String finish_key; + public byte[] start_key; + public byte[] finish_key; public int row_count; /** * @@ -8998,10 +9022,6 @@ public class Cassandra { } public get_range_slice_args() { - this.start_key = ""; - - this.finish_key = ""; - this.row_count = 100; this.consistency_level = ConsistencyLevel.ONE; @@ -9012,8 +9032,8 @@ public class Cassandra { String keyspace, ColumnParent column_parent, SlicePredicate predicate, - String start_key, - String finish_key, + byte[] start_key, + byte[] finish_key, int row_count, ConsistencyLevel consistency_level) { @@ -9044,10 +9064,12 @@ public class Cassandra { this.predicate = new SlicePredicate(other.predicate); } if (other.isSetStart_key()) { - this.start_key = other.start_key; + this.start_key = new byte[other.start_key.length]; + System.arraycopy(other.start_key, 0, start_key, 0, other.start_key.length); } if (other.isSetFinish_key()) { - this.finish_key = other.finish_key; + this.finish_key = new byte[other.finish_key.length]; + System.arraycopy(other.finish_key, 0, finish_key, 0, other.finish_key.length); } this.row_count = other.row_count; if (other.isSetConsistency_level()) { @@ -9136,11 +9158,11 @@ public class Cassandra { } } - public String getStart_key() { + public byte[] getStart_key() { return this.start_key; } - public get_range_slice_args setStart_key(String start_key) { + public get_range_slice_args setStart_key(byte[] start_key) { this.start_key = start_key; return this; } @@ -9160,11 +9182,11 @@ public class Cassandra { } } - public String getFinish_key() { + public byte[] getFinish_key() { return this.finish_key; } - public get_range_slice_args setFinish_key(String finish_key) { + public get_range_slice_args setFinish_key(byte[] finish_key) { this.finish_key = finish_key; return this; } @@ -9269,7 +9291,7 @@ public class Cassandra { if (value == null) { unsetStart_key(); } else { - setStart_key((String)value); + setStart_key((byte[])value); } break; @@ -9277,7 +9299,7 @@ public class Cassandra { if (value == null) { unsetFinish_key(); } else { - setFinish_key((String)value); + setFinish_key((byte[])value); } break; @@ -9405,7 +9427,7 @@ public class Cassandra { if (this_present_start_key || that_present_start_key) { if (!(this_present_start_key && that_present_start_key)) return false; - if (!this.start_key.equals(that.start_key)) + if (!java.util.Arrays.equals(this.start_key, that.start_key)) return false; } @@ -9414,7 +9436,7 @@ public class Cassandra { if (this_present_finish_key || that_present_finish_key) { if (!(this_present_finish_key && that_present_finish_key)) return false; - if (!this.finish_key.equals(that.finish_key)) + if (!java.util.Arrays.equals(this.finish_key, that.finish_key)) return false; } @@ -9553,14 +9575,14 @@ public class Cassandra { break; case 4: // START_KEY if (field.type == TType.STRING) { - this.start_key = iprot.readString(); + this.start_key = iprot.readBinary(); } else { TProtocolUtil.skip(iprot, field.type); } break; case 5: // FINISH_KEY if (field.type == TType.STRING) { - this.finish_key = iprot.readString(); + this.finish_key = iprot.readBinary(); } else { TProtocolUtil.skip(iprot, field.type); } @@ -9615,12 +9637,12 @@ public class Cassandra { } if (this.start_key != null) { oprot.writeFieldBegin(START_KEY_FIELD_DESC); - oprot.writeString(this.start_key); + oprot.writeBinary(this.start_key); oprot.writeFieldEnd(); } if (this.finish_key != null) { oprot.writeFieldBegin(FINISH_KEY_FIELD_DESC); - oprot.writeString(this.finish_key); + oprot.writeBinary(this.finish_key); oprot.writeFieldEnd(); } oprot.writeFieldBegin(ROW_COUNT_FIELD_DESC); @@ -9668,7 +9690,12 @@ public class Cassandra { if (this.start_key == null) { sb.append("null"); } else { - sb.append(this.start_key); + int __start_key_size = Math.min(this.start_key.length, 128); + for (int i = 0; i < __start_key_size; i++) { + if (i != 0) sb.append(" "); + sb.append(Integer.toHexString(this.start_key[i]).length() > 1 ? Integer.toHexString(this.start_key[i]).substring(Integer.toHexString(this.start_key[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.start_key[i]).toUpperCase()); + } + if (this.start_key.length > 128) sb.append(" ..."); } first = false; if (!first) sb.append(", "); @@ -9676,7 +9703,12 @@ public class Cassandra { if (this.finish_key == null) { sb.append("null"); } else { - sb.append(this.finish_key); + int __finish_key_size = Math.min(this.finish_key.length, 128); + for (int i = 0; i < __finish_key_size; i++) { + if (i != 0) sb.append(" "); + sb.append(Integer.toHexString(this.finish_key[i]).length() > 1 ? Integer.toHexString(this.finish_key[i]).substring(Integer.toHexString(this.finish_key[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.finish_key[i]).toUpperCase()); + } + if (this.finish_key.length > 128) sb.append(" ..."); } first = false; if (!first) sb.append(", "); @@ -11534,7 +11566,7 @@ public class Cassandra { private static final TField CONSISTENCY_LEVEL_FIELD_DESC = new TField("consistency_level", TType.I32, (short)6); public String keyspace; - public String key; + public byte[] key; public ColumnPath column_path; public byte[] value; public long timestamp; @@ -11638,7 +11670,7 @@ public class Cassandra { public insert_args( String keyspace, - String key, + byte[] key, ColumnPath column_path, byte[] value, long timestamp, @@ -11664,7 +11696,8 @@ public class Cassandra { this.keyspace = other.keyspace; } if (other.isSetKey()) { - this.key = other.key; + this.key = new byte[other.key.length]; + System.arraycopy(other.key, 0, key, 0, other.key.length); } if (other.isSetColumn_path()) { this.column_path = new ColumnPath(other.column_path); @@ -11712,11 +11745,11 @@ public class Cassandra { } } - public String getKey() { + public byte[] getKey() { return this.key; } - public insert_args setKey(String key) { + public insert_args setKey(byte[] key) { this.key = key; return this; } @@ -11853,7 +11886,7 @@ public class Cassandra { if (value == null) { unsetKey(); } else { - setKey((String)value); + setKey((byte[])value); } break; @@ -11974,7 +12007,7 @@ public class Cassandra { if (this_present_key || that_present_key) { if (!(this_present_key && that_present_key)) return false; - if (!this.key.equals(that.key)) + if (!java.util.Arrays.equals(this.key, that.key)) return false; } @@ -12106,7 +12139,7 @@ public class Cassandra { break; case 2: // KEY if (field.type == TType.STRING) { - this.key = iprot.readString(); + this.key = iprot.readBinary(); } else { TProtocolUtil.skip(iprot, field.type); } @@ -12166,7 +12199,7 @@ public class Cassandra { } if (this.key != null) { oprot.writeFieldBegin(KEY_FIELD_DESC); - oprot.writeString(this.key); + oprot.writeBinary(this.key); oprot.writeFieldEnd(); } if (this.column_path != null) { @@ -12208,7 +12241,12 @@ public class Cassandra { if (this.key == null) { sb.append("null"); } else { - sb.append(this.key); + int __key_size = Math.min(this.key.length, 128); + for (int i = 0; i < __key_size; i++) { + if (i != 0) sb.append(" "); + sb.append(Integer.toHexString(this.key[i]).length() > 1 ? Integer.toHexString(this.key[i]).substring(Integer.toHexString(this.key[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.key[i]).toUpperCase()); + } + if (this.key.length > 128) sb.append(" ..."); } first = false; if (!first) sb.append(", "); @@ -12730,7 +12768,7 @@ public class Cassandra { private static final TField CONSISTENCY_LEVEL_FIELD_DESC = new TField("consistency_level", TType.I32, (short)4); public String keyspace; - public String key; + public byte[] key; public Map> cfmap; /** * @@ -12827,7 +12865,7 @@ public class Cassandra { public batch_insert_args( String keyspace, - String key, + byte[] key, Map> cfmap, ConsistencyLevel consistency_level) { @@ -12846,7 +12884,8 @@ public class Cassandra { this.keyspace = other.keyspace; } if (other.isSetKey()) { - this.key = other.key; + this.key = new byte[other.key.length]; + System.arraycopy(other.key, 0, key, 0, other.key.length); } if (other.isSetCfmap()) { Map> __this__cfmap = new HashMap>(); @@ -12904,11 +12943,11 @@ public class Cassandra { } } - public String getKey() { + public byte[] getKey() { return this.key; } - public batch_insert_args setKey(String key) { + public batch_insert_args setKey(byte[] key) { this.key = key; return this; } @@ -13009,7 +13048,7 @@ public class Cassandra { if (value == null) { unsetKey(); } else { - setKey((String)value); + setKey((byte[])value); } break; @@ -13104,7 +13143,7 @@ public class Cassandra { if (this_present_key || that_present_key) { if (!(this_present_key && that_present_key)) return false; - if (!this.key.equals(that.key)) + if (!java.util.Arrays.equals(this.key, that.key)) return false; } @@ -13153,7 +13192,7 @@ public class Cassandra { break; case 2: // KEY if (field.type == TType.STRING) { - this.key = iprot.readString(); + this.key = iprot.readBinary(); } else { TProtocolUtil.skip(iprot, field.type); } @@ -13217,7 +13256,7 @@ public class Cassandra { } if (this.key != null) { oprot.writeFieldBegin(KEY_FIELD_DESC); - oprot.writeString(this.key); + oprot.writeBinary(this.key); oprot.writeFieldEnd(); } if (this.cfmap != null) { @@ -13266,7 +13305,12 @@ public class Cassandra { if (this.key == null) { sb.append("null"); } else { - sb.append(this.key); + int __key_size = Math.min(this.key.length, 128); + for (int i = 0; i < __key_size; i++) { + if (i != 0) sb.append(" "); + sb.append(Integer.toHexString(this.key[i]).length() > 1 ? Integer.toHexString(this.key[i]).substring(Integer.toHexString(this.key[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.key[i]).toUpperCase()); + } + if (this.key.length > 128) sb.append(" ..."); } first = false; if (!first) sb.append(", "); @@ -13768,7 +13812,7 @@ public class Cassandra { private static final TField CONSISTENCY_LEVEL_FIELD_DESC = new TField("consistency_level", TType.I32, (short)5); public String keyspace; - public String key; + public byte[] key; public ColumnPath column_path; public long timestamp; /** @@ -13868,7 +13912,7 @@ public class Cassandra { public remove_args( String keyspace, - String key, + byte[] key, ColumnPath column_path, long timestamp, ConsistencyLevel consistency_level) @@ -13892,7 +13936,8 @@ public class Cassandra { this.keyspace = other.keyspace; } if (other.isSetKey()) { - this.key = other.key; + this.key = new byte[other.key.length]; + System.arraycopy(other.key, 0, key, 0, other.key.length); } if (other.isSetColumn_path()) { this.column_path = new ColumnPath(other.column_path); @@ -13936,11 +13981,11 @@ public class Cassandra { } } - public String getKey() { + public byte[] getKey() { return this.key; } - public remove_args setKey(String key) { + public remove_args setKey(byte[] key) { this.key = key; return this; } @@ -14053,7 +14098,7 @@ public class Cassandra { if (value == null) { unsetKey(); } else { - setKey((String)value); + setKey((byte[])value); } break; @@ -14161,7 +14206,7 @@ public class Cassandra { if (this_present_key || that_present_key) { if (!(this_present_key && that_present_key)) return false; - if (!this.key.equals(that.key)) + if (!java.util.Arrays.equals(this.key, that.key)) return false; } @@ -14275,7 +14320,7 @@ public class Cassandra { break; case 2: // KEY if (field.type == TType.STRING) { - this.key = iprot.readString(); + this.key = iprot.readBinary(); } else { TProtocolUtil.skip(iprot, field.type); } @@ -14328,7 +14373,7 @@ public class Cassandra { } if (this.key != null) { oprot.writeFieldBegin(KEY_FIELD_DESC); - oprot.writeString(this.key); + oprot.writeBinary(this.key); oprot.writeFieldEnd(); } if (this.column_path != null) { @@ -14365,7 +14410,12 @@ public class Cassandra { if (this.key == null) { sb.append("null"); } else { - sb.append(this.key); + int __key_size = Math.min(this.key.length, 128); + for (int i = 0; i < __key_size; i++) { + if (i != 0) sb.append(" "); + sb.append(Integer.toHexString(this.key[i]).length() > 1 ? Integer.toHexString(this.key[i]).substring(Integer.toHexString(this.key[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.key[i]).toUpperCase()); + } + if (this.key.length > 128) sb.append(" ..."); } first = false; if (!first) sb.append(", "); @@ -14867,7 +14917,7 @@ public class Cassandra { private static final TField CONSISTENCY_LEVEL_FIELD_DESC = new TField("consistency_level", TType.I32, (short)3); public String keyspace; - public Map>> mutation_map; + public Map>> mutation_map; /** * * @see ConsistencyLevel @@ -14962,7 +15012,7 @@ public class Cassandra { public batch_mutate_args( String keyspace, - Map>> mutation_map, + Map>> mutation_map, ConsistencyLevel consistency_level) { this(); @@ -14979,13 +15029,14 @@ public class Cassandra { this.keyspace = other.keyspace; } if (other.isSetMutation_map()) { - Map>> __this__mutation_map = new HashMap>>(); - for (Map.Entry>> other_element : other.mutation_map.entrySet()) { + Map>> __this__mutation_map = new HashMap>>(); + for (Map.Entry>> other_element : other.mutation_map.entrySet()) { - String other_element_key = other_element.getKey(); + byte[] other_element_key = other_element.getKey(); Map> other_element_value = other_element.getValue(); - String __this__mutation_map_copy_key = other_element_key; + byte[] __this__mutation_map_copy_key = new byte[other_element_key.length]; + System.arraycopy(other_element_key, 0, __this__mutation_map_copy_key, 0, other_element_key.length); Map> __this__mutation_map_copy_value = new HashMap>(); for (Map.Entry> other_element_value_element : other_element_value.entrySet()) { @@ -15049,18 +15100,18 @@ public class Cassandra { return (this.mutation_map == null) ? 0 : this.mutation_map.size(); } - public void putToMutation_map(String key, Map> val) { + public void putToMutation_map(byte[] key, Map> val) { if (this.mutation_map == null) { - this.mutation_map = new HashMap>>(); + this.mutation_map = new HashMap>>(); } this.mutation_map.put(key, val); } - public Map>> getMutation_map() { + public Map>> getMutation_map() { return this.mutation_map; } - public batch_mutate_args setMutation_map(Map>> mutation_map) { + public batch_mutate_args setMutation_map(Map>> mutation_map) { this.mutation_map = mutation_map; return this; } @@ -15126,7 +15177,7 @@ public class Cassandra { if (value == null) { unsetMutation_map(); } else { - setMutation_map((Map>>)value); + setMutation_map((Map>>)value); } break; @@ -15250,12 +15301,12 @@ public class Cassandra { if (field.type == TType.MAP) { { TMap _map72 = iprot.readMapBegin(); - this.mutation_map = new HashMap>>(2*_map72.size); + this.mutation_map = new HashMap>>(2*_map72.size); for (int _i73 = 0; _i73 < _map72.size; ++_i73) { - String _key74; + byte[] _key74; Map> _val75; - _key74 = iprot.readString(); + _key74 = iprot.readBinary(); { TMap _map76 = iprot.readMapBegin(); _val75 = new HashMap>(2*_map76.size); @@ -15319,9 +15370,9 @@ public class Cassandra { oprot.writeFieldBegin(MUTATION_MAP_FIELD_DESC); { oprot.writeMapBegin(new TMap(TType.STRING, TType.MAP, this.mutation_map.size())); - for (Map.Entry>> _iter83 : this.mutation_map.entrySet()) + for (Map.Entry>> _iter83 : this.mutation_map.entrySet()) { - oprot.writeString(_iter83.getKey()); + oprot.writeBinary(_iter83.getKey()); { oprot.writeMapBegin(new TMap(TType.STRING, TType.LIST, _iter83.getValue().size())); for (Map.Entry> _iter84 : _iter83.getValue().entrySet()) diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java index fe11fb50a9..90f129d10c 100644 --- a/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java +++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java @@ -42,6 +42,6 @@ import org.slf4j.LoggerFactory; public class Constants { - public static final String VERSION = "3.0.0"; + public static final String VERSION = "4.0.0"; } diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/KeyRange.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/KeyRange.java index b125991f55..6d514e2354 100644 --- a/interface/thrift/gen-java/org/apache/cassandra/thrift/KeyRange.java +++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/KeyRange.java @@ -61,8 +61,8 @@ public class KeyRange implements TBase, java.io.Serializable, private static final TField END_TOKEN_FIELD_DESC = new TField("end_token", TType.STRING, (short)4); private static final TField COUNT_FIELD_DESC = new TField("count", TType.I32, (short)5); - public String start_key; - public String end_key; + public byte[] start_key; + public byte[] end_key; public String start_token; public String end_token; public int count; @@ -167,10 +167,12 @@ public class KeyRange implements TBase, java.io.Serializable, __isset_bit_vector.clear(); __isset_bit_vector.or(other.__isset_bit_vector); if (other.isSetStart_key()) { - this.start_key = other.start_key; + this.start_key = new byte[other.start_key.length]; + System.arraycopy(other.start_key, 0, start_key, 0, other.start_key.length); } if (other.isSetEnd_key()) { - this.end_key = other.end_key; + this.end_key = new byte[other.end_key.length]; + System.arraycopy(other.end_key, 0, end_key, 0, other.end_key.length); } if (other.isSetStart_token()) { this.start_token = other.start_token; @@ -190,11 +192,11 @@ public class KeyRange implements TBase, java.io.Serializable, return new KeyRange(this); } - public String getStart_key() { + public byte[] getStart_key() { return this.start_key; } - public KeyRange setStart_key(String start_key) { + public KeyRange setStart_key(byte[] start_key) { this.start_key = start_key; return this; } @@ -214,11 +216,11 @@ public class KeyRange implements TBase, java.io.Serializable, } } - public String getEnd_key() { + public byte[] getEnd_key() { return this.end_key; } - public KeyRange setEnd_key(String end_key) { + public KeyRange setEnd_key(byte[] end_key) { this.end_key = end_key; return this; } @@ -315,7 +317,7 @@ public class KeyRange implements TBase, java.io.Serializable, if (value == null) { unsetStart_key(); } else { - setStart_key((String)value); + setStart_key((byte[])value); } break; @@ -323,7 +325,7 @@ public class KeyRange implements TBase, java.io.Serializable, if (value == null) { unsetEnd_key(); } else { - setEnd_key((String)value); + setEnd_key((byte[])value); } break; @@ -422,7 +424,7 @@ public class KeyRange implements TBase, java.io.Serializable, if (this_present_start_key || that_present_start_key) { if (!(this_present_start_key && that_present_start_key)) return false; - if (!this.start_key.equals(that.start_key)) + if (!java.util.Arrays.equals(this.start_key, that.start_key)) return false; } @@ -431,7 +433,7 @@ public class KeyRange implements TBase, java.io.Serializable, if (this_present_end_key || that_present_end_key) { if (!(this_present_end_key && that_present_end_key)) return false; - if (!this.end_key.equals(that.end_key)) + if (!java.util.Arrays.equals(this.end_key, that.end_key)) return false; } @@ -538,14 +540,14 @@ public class KeyRange implements TBase, java.io.Serializable, switch (field.id) { case 1: // START_KEY if (field.type == TType.STRING) { - this.start_key = iprot.readString(); + this.start_key = iprot.readBinary(); } else { TProtocolUtil.skip(iprot, field.type); } break; case 2: // END_KEY if (field.type == TType.STRING) { - this.end_key = iprot.readString(); + this.end_key = iprot.readBinary(); } else { TProtocolUtil.skip(iprot, field.type); } @@ -593,14 +595,14 @@ public class KeyRange implements TBase, java.io.Serializable, if (this.start_key != null) { if (isSetStart_key()) { oprot.writeFieldBegin(START_KEY_FIELD_DESC); - oprot.writeString(this.start_key); + oprot.writeBinary(this.start_key); oprot.writeFieldEnd(); } } if (this.end_key != null) { if (isSetEnd_key()) { oprot.writeFieldBegin(END_KEY_FIELD_DESC); - oprot.writeString(this.end_key); + oprot.writeBinary(this.end_key); oprot.writeFieldEnd(); } } @@ -635,7 +637,12 @@ public class KeyRange implements TBase, java.io.Serializable, if (this.start_key == null) { sb.append("null"); } else { - sb.append(this.start_key); + int __start_key_size = Math.min(this.start_key.length, 128); + for (int i = 0; i < __start_key_size; i++) { + if (i != 0) sb.append(" "); + sb.append(Integer.toHexString(this.start_key[i]).length() > 1 ? Integer.toHexString(this.start_key[i]).substring(Integer.toHexString(this.start_key[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.start_key[i]).toUpperCase()); + } + if (this.start_key.length > 128) sb.append(" ..."); } first = false; } @@ -645,7 +652,12 @@ public class KeyRange implements TBase, java.io.Serializable, if (this.end_key == null) { sb.append("null"); } else { - sb.append(this.end_key); + int __end_key_size = Math.min(this.end_key.length, 128); + for (int i = 0; i < __end_key_size; i++) { + if (i != 0) sb.append(" "); + sb.append(Integer.toHexString(this.end_key[i]).length() > 1 ? Integer.toHexString(this.end_key[i]).substring(Integer.toHexString(this.end_key[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.end_key[i]).toUpperCase()); + } + if (this.end_key.length > 128) sb.append(" ..."); } first = false; } diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/KeySlice.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/KeySlice.java index 7b671ce16e..774c2213e6 100644 --- a/interface/thrift/gen-java/org/apache/cassandra/thrift/KeySlice.java +++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/KeySlice.java @@ -57,7 +57,7 @@ public class KeySlice implements TBase, java.io.Serializable, private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)1); private static final TField COLUMNS_FIELD_DESC = new TField("columns", TType.LIST, (short)2); - public String key; + public byte[] key; public List columns; /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ @@ -134,7 +134,7 @@ public class KeySlice implements TBase, java.io.Serializable, } public KeySlice( - String key, + byte[] key, List columns) { this(); @@ -147,7 +147,8 @@ public class KeySlice implements TBase, java.io.Serializable, */ public KeySlice(KeySlice other) { if (other.isSetKey()) { - this.key = other.key; + this.key = new byte[other.key.length]; + System.arraycopy(other.key, 0, key, 0, other.key.length); } if (other.isSetColumns()) { List __this__columns = new ArrayList(); @@ -167,11 +168,11 @@ public class KeySlice implements TBase, java.io.Serializable, return new KeySlice(this); } - public String getKey() { + public byte[] getKey() { return this.key; } - public KeySlice setKey(String key) { + public KeySlice setKey(byte[] key) { this.key = key; return this; } @@ -236,7 +237,7 @@ public class KeySlice implements TBase, java.io.Serializable, if (value == null) { unsetKey(); } else { - setKey((String)value); + setKey((byte[])value); } break; @@ -304,7 +305,7 @@ public class KeySlice implements TBase, java.io.Serializable, if (this_present_key || that_present_key) { if (!(this_present_key && that_present_key)) return false; - if (!this.key.equals(that.key)) + if (!java.util.Arrays.equals(this.key, that.key)) return false; } @@ -366,7 +367,7 @@ public class KeySlice implements TBase, java.io.Serializable, switch (field.id) { case 1: // KEY if (field.type == TType.STRING) { - this.key = iprot.readString(); + this.key = iprot.readBinary(); } else { TProtocolUtil.skip(iprot, field.type); } @@ -406,7 +407,7 @@ public class KeySlice implements TBase, java.io.Serializable, oprot.writeStructBegin(STRUCT_DESC); if (this.key != null) { oprot.writeFieldBegin(KEY_FIELD_DESC); - oprot.writeString(this.key); + oprot.writeBinary(this.key); oprot.writeFieldEnd(); } if (this.columns != null) { @@ -434,7 +435,12 @@ public class KeySlice implements TBase, java.io.Serializable, if (this.key == null) { sb.append("null"); } else { - sb.append(this.key); + int __key_size = Math.min(this.key.length, 128); + for (int i = 0; i < __key_size; i++) { + if (i != 0) sb.append(" "); + sb.append(Integer.toHexString(this.key[i]).length() > 1 ? Integer.toHexString(this.key[i]).substring(Integer.toHexString(this.key[i]).length() - 2).toUpperCase() : "0" + Integer.toHexString(this.key[i]).toUpperCase()); + } + if (this.key.length > 128) sb.append(" ..."); } first = false; if (!first) sb.append(", "); diff --git a/src/java/org/apache/cassandra/cli/CliClient.java b/src/java/org/apache/cassandra/cli/CliClient.java index 1f1f9fb0cb..15b9f6a9f6 100644 --- a/src/java/org/apache/cassandra/cli/CliClient.java +++ b/src/java/org/apache/cassandra/cli/CliClient.java @@ -166,7 +166,7 @@ public class CliClient colParent = new ColumnParent(columnFamily).setSuper_column(CliCompiler.getColumn(columnFamilySpec, 0).getBytes("UTF-8")); } - int count = thriftClient_.get_count(tableName, key, colParent, ConsistencyLevel.ONE); + int count = thriftClient_.get_count(tableName, key.getBytes(), colParent, ConsistencyLevel.ONE); css_.out.printf("%d columns\n", count); } @@ -227,7 +227,7 @@ public class CliClient columnName = CliCompiler.getColumn(columnFamilySpec, 1).getBytes("UTF-8"); } - thriftClient_.remove(tableName, key, new ColumnPath(columnFamily).setSuper_column(superColumnName).setColumn(columnName), + thriftClient_.remove(tableName, key.getBytes(), new ColumnPath(columnFamily).setSuper_column(superColumnName).setColumn(columnName), timestampMicros(), ConsistencyLevel.ONE); css_.out.println(String.format("%s removed.", (columnSpecCnt == 0) ? "row" : "column")); } @@ -243,7 +243,7 @@ public class CliClient throws InvalidRequestException, UnavailableException, TimedOutException, TException, UnsupportedEncodingException, IllegalAccessException, NotFoundException, InstantiationException, ClassNotFoundException { SliceRange range = new SliceRange(ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, 1000000); - List columns = thriftClient_.get_slice(keyspace, key, + List columns = thriftClient_.get_slice(keyspace, key.getBytes(), new ColumnParent(columnFamily).setSuper_column(superColumnName), new SlicePredicate().setColumn_names(null).setSlice_range(range), ConsistencyLevel.ONE); int size = columns.size(); @@ -363,7 +363,7 @@ public class CliClient // Perform a get(), print out the results. ColumnPath path = new ColumnPath(columnFamily).setSuper_column(superColumnName).setColumn(columnName); - Column column = thriftClient_.get(tableName, key, path, ConsistencyLevel.ONE).column; + Column column = thriftClient_.get(tableName, key.getBytes(), path, ConsistencyLevel.ONE).column; css_.out.printf("=> (column=%s, value=%s, timestamp=%d)\n", formatColumnName(tableName, columnFamily, column), new String(column.value, "UTF-8"), column.timestamp); } @@ -411,7 +411,7 @@ public class CliClient } // do the insert - thriftClient_.insert(tableName, key, new ColumnPath(columnFamily).setSuper_column(superColumnName).setColumn(columnName), + thriftClient_.insert(tableName, key.getBytes(), new ColumnPath(columnFamily).setSuper_column(superColumnName).setColumn(columnName), value.getBytes(), timestampMicros(), ConsistencyLevel.ONE); css_.out.println("Value inserted."); diff --git a/src/java/org/apache/cassandra/hadoop/ColumnFamilyInputFormat.java b/src/java/org/apache/cassandra/hadoop/ColumnFamilyInputFormat.java index f9eb561f67..db4e010165 100644 --- a/src/java/org/apache/cassandra/hadoop/ColumnFamilyInputFormat.java +++ b/src/java/org/apache/cassandra/hadoop/ColumnFamilyInputFormat.java @@ -60,7 +60,7 @@ import org.apache.thrift.transport.TTransportException; * * The default split size is 64k rows. */ -public class ColumnFamilyInputFormat extends InputFormat> +public class ColumnFamilyInputFormat extends InputFormat> { private static final Logger logger = LoggerFactory.getLogger(StorageService.class); @@ -218,7 +218,7 @@ public class ColumnFamilyInputFormat extends InputFormat> createRecordReader(InputSplit inputSplit, TaskAttemptContext taskAttemptContext) throws IOException, InterruptedException + public RecordReader> createRecordReader(InputSplit inputSplit, TaskAttemptContext taskAttemptContext) throws IOException, InterruptedException { return new ColumnFamilyRecordReader(); } diff --git a/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java b/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java index c1b33e5028..6e82216a72 100644 --- a/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java +++ b/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java @@ -46,11 +46,11 @@ import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransportException; -public class ColumnFamilyRecordReader extends RecordReader> +public class ColumnFamilyRecordReader extends RecordReader> { private ColumnFamilySplit split; private RowIterator iter; - private Pair> currentRow; + private Pair> currentRow; private SlicePredicate predicate; private int totalRowCount; // total number of rows to fetch private int batchRowCount; // fetch this many per batch @@ -59,7 +59,7 @@ public class ColumnFamilyRecordReader extends RecordReader>> + private class RowIterator extends AbstractIterator>> { private List rows; @@ -159,8 +159,7 @@ public class ColumnFamilyRecordReader extends RecordReader> computeNext() + protected Pair> computeNext() { maybeInit(); if (rows == null) @@ -227,7 +226,7 @@ public class ColumnFamilyRecordReader extends RecordReader>(ks.key, map); + return new Pair>(ks.key, map); } } diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java b/src/java/org/apache/cassandra/thrift/CassandraServer.java index 2c891355d4..fbd3dcdb12 100644 --- a/src/java/org/apache/cassandra/thrift/CassandraServer.java +++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java @@ -186,18 +186,17 @@ public class CassandraServer implements Cassandra.Iface return thriftSuperColumns; } - private Map> getSlice(List commands, ConsistencyLevel consistency_level) + private Map> getSlice(List commands, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException { Map columnFamilies = readColumnFamily(commands, consistency_level); - Map> columnFamiliesMap = new HashMap>(); + Map> columnFamiliesMap = new HashMap>(); for (ReadCommand command: commands) { ColumnFamily cf = columnFamilies.get(command.key); boolean reverseOrder = command instanceof SliceFromReadCommand && ((SliceFromReadCommand)command).reversed; List thriftifiedColumns = thriftifyColumnFamily(cf, command.queryPath.superColumnName != null, reverseOrder); - // FIXME: string keys - columnFamiliesMap.put(new String(command.key, UTF8), thriftifiedColumns); + columnFamiliesMap.put(command.key, thriftifiedColumns); } return columnFamiliesMap; @@ -222,7 +221,7 @@ public class CassandraServer implements Cassandra.Iface return thriftifyColumns(cf.getSortedColumns(), reverseOrder); } - public List get_slice(String keyspace, String key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) + public List get_slice(String keyspace, byte[] key, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException { if (logger.isDebugEnabled()) @@ -232,7 +231,7 @@ public class CassandraServer implements Cassandra.Iface return multigetSliceInternal(keyspace, Arrays.asList(key), column_parent, predicate, consistency_level).get(key); } - public Map> multiget_slice(String keyspace, List keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) + public Map> multiget_slice(String keyspace, List keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException { if (logger.isDebugEnabled()) @@ -243,7 +242,7 @@ public class CassandraServer implements Cassandra.Iface return multigetSliceInternal(keyspace, keys, column_parent, predicate, consistency_level); } - private Map> multigetSliceInternal(String keyspace, List keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) + private Map> multigetSliceInternal(String keyspace, List keys, ColumnParent column_parent, SlicePredicate predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException { ThriftValidation.validateColumnParent(keyspace, column_parent); @@ -252,28 +251,26 @@ public class CassandraServer implements Cassandra.Iface List commands = new ArrayList(); if (predicate.column_names != null) { - for (String key: keys) + for (byte[] key: keys) { ThriftValidation.validateKey(key); - // FIXME: string keys - commands.add(new SliceByNamesReadCommand(keyspace, key.getBytes(UTF8), column_parent, predicate.column_names)); + commands.add(new SliceByNamesReadCommand(keyspace, key, column_parent, predicate.column_names)); } } else { SliceRange range = predicate.slice_range; - for (String key: keys) + for (byte[] key: keys) { ThriftValidation.validateKey(key); - // FIXME: string keys - commands.add(new SliceFromReadCommand(keyspace, key.getBytes(UTF8), column_parent, range.start, range.finish, range.reversed, range.count)); + commands.add(new SliceFromReadCommand(keyspace, key, column_parent, range.start, range.finish, range.reversed, range.count)); } } return getSlice(commands, consistency_level); } - public ColumnOrSuperColumn get(String table, String key, ColumnPath column_path, ConsistencyLevel consistency_level) + public ColumnOrSuperColumn get(String table, byte[] key, ColumnPath column_path, ConsistencyLevel consistency_level) throws InvalidRequestException, NotFoundException, UnavailableException, TimedOutException { if (logger.isDebugEnabled()) @@ -290,7 +287,7 @@ public class CassandraServer implements Cassandra.Iface } /** always returns a ColumnOrSuperColumn for each key, even if there is no data for it */ - public Map multiget(String table, List keys, ColumnPath column_path, ConsistencyLevel consistency_level) + public Map multiget(String table, List keys, ColumnPath column_path, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException { if (logger.isDebugEnabled()) @@ -301,7 +298,7 @@ public class CassandraServer implements Cassandra.Iface return multigetInternal(table, keys, column_path, consistency_level); } - private Map multigetInternal(String table, List keys, ColumnPath column_path, ConsistencyLevel consistency_level) + private Map multigetInternal(String table, List keys, ColumnPath column_path, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException { ThriftValidation.validateColumnPath(table, column_path); @@ -309,37 +306,34 @@ public class CassandraServer implements Cassandra.Iface QueryPath path = new QueryPath(column_path.column_family, column_path.column == null ? null : column_path.super_column); List nameAsList = Arrays.asList(column_path.column == null ? column_path.super_column : column_path.column); List commands = new ArrayList(); - for (String key: keys) + for (byte[] key: keys) { ThriftValidation.validateKey(key); - // FIXME: string keys - commands.add(new SliceByNamesReadCommand(table, key.getBytes(UTF8), path, nameAsList)); + commands.add(new SliceByNamesReadCommand(table, key, path, nameAsList)); } - Map columnFamiliesMap = new HashMap(); + Map columnFamiliesMap = new HashMap(); Map cfamilies = readColumnFamily(commands, consistency_level); for (ReadCommand command: commands) { ColumnFamily cf = cfamilies.get(command.key); - // FIXME: string keys - String skey = new String(command.key, UTF8); if (cf == null) { - columnFamiliesMap.put(skey, new ColumnOrSuperColumn()); + columnFamiliesMap.put(command.key, new ColumnOrSuperColumn()); } else { List tcolumns = thriftifyColumnFamily(cf, command.queryPath.superColumnName != null, false); - columnFamiliesMap.put(skey, tcolumns.size() > 0 ? tcolumns.iterator().next() : new ColumnOrSuperColumn()); + columnFamiliesMap.put(command.key, tcolumns.size() > 0 ? tcolumns.iterator().next() : new ColumnOrSuperColumn()); } } return columnFamiliesMap; } - public int get_count(String table, String key, ColumnParent column_parent, ConsistencyLevel consistency_level) + public int get_count(String table, byte[] key, ColumnParent column_parent, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException { if (logger.isDebugEnabled()) @@ -352,7 +346,7 @@ public class CassandraServer implements Cassandra.Iface return get_slice(table, key, column_parent, predicate, consistency_level).size(); } - public void insert(String table, String key, ColumnPath column_path, byte[] value, long timestamp, ConsistencyLevel consistency_level) + public void insert(String table, byte[] key, ColumnPath column_path, byte[] value, long timestamp, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException { if (logger.isDebugEnabled()) @@ -363,8 +357,7 @@ public class CassandraServer implements Cassandra.Iface ThriftValidation.validateKey(key); ThriftValidation.validateColumnPath(table, column_path); - // FIXME: string keys - RowMutation rm = new RowMutation(table, key.getBytes(UTF8)); + RowMutation rm = new RowMutation(table, key); try { rm.add(new QueryPath(column_path), value, timestamp); @@ -376,7 +369,7 @@ public class CassandraServer implements Cassandra.Iface doInsert(consistency_level, rm); } - public void batch_insert(String keyspace, String key, Map> cfmap, ConsistencyLevel consistency_level) + public void batch_insert(String keyspace, byte[] key, Map> cfmap, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException { if (logger.isDebugEnabled()) @@ -394,11 +387,10 @@ public class CassandraServer implements Cassandra.Iface } } - // FIXME: string keys - doInsert(consistency_level, RowMutation.getRowMutation(keyspace, key.getBytes(UTF8), cfmap)); + doInsert(consistency_level, RowMutation.getRowMutation(keyspace, key, cfmap)); } - public void batch_mutate(String keyspace, Map>> mutation_map, ConsistencyLevel consistency_level) + public void batch_mutate(String keyspace, Map>> mutation_map, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException { if (logger.isDebugEnabled()) @@ -425,9 +417,9 @@ public class CassandraServer implements Cassandra.Iface checkLoginAuthorized(needed); List rowMutations = new ArrayList(); - for (Map.Entry>> mutationEntry: mutation_map.entrySet()) + for (Map.Entry>> mutationEntry: mutation_map.entrySet()) { - String key = mutationEntry.getKey(); + byte[] key = mutationEntry.getKey(); ThriftValidation.validateKey(key); Map> columnFamilyToMutations = mutationEntry.getValue(); @@ -440,8 +432,7 @@ public class CassandraServer implements Cassandra.Iface ThriftValidation.validateMutation(keyspace, cfName, mutation); } } - // FIXME: string keys - rowMutations.add(RowMutation.getRowMutationFromMutations(keyspace, key.getBytes(UTF8), columnFamilyToMutations)); + rowMutations.add(RowMutation.getRowMutationFromMutations(keyspace, key, columnFamilyToMutations)); } if (consistency_level == ConsistencyLevel.ZERO) { @@ -460,7 +451,7 @@ public class CassandraServer implements Cassandra.Iface } } - public void remove(String table, String key, ColumnPath column_path, long timestamp, ConsistencyLevel consistency_level) + public void remove(String table, byte[] key, ColumnPath column_path, long timestamp, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException { if (logger.isDebugEnabled()) @@ -471,8 +462,7 @@ public class CassandraServer implements Cassandra.Iface ThriftValidation.validateKey(key); ThriftValidation.validateColumnPathOrParent(table, column_path); - // FIXME: string keys - RowMutation rm = new RowMutation(table, key.getBytes(UTF8)); + RowMutation rm = new RowMutation(table, key); rm.delete(new QueryPath(column_path), timestamp); doInsert(consistency_level, rm); @@ -523,7 +513,7 @@ public class CassandraServer implements Cassandra.Iface return columnFamiliesMap; } - public List get_range_slice(String keyspace, ColumnParent column_parent, SlicePredicate predicate, String start_key, String finish_key, int maxRows, ConsistencyLevel consistency_level) + public List get_range_slice(String keyspace, ColumnParent column_parent, SlicePredicate predicate, byte[] start_key, byte[] finish_key, int maxRows, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TException, TimedOutException { if (logger.isDebugEnabled()) @@ -565,8 +555,7 @@ public class CassandraServer implements Cassandra.Iface } else { - // FIXME: string keys - bounds = new Bounds(p.getToken(range.start_key.getBytes(UTF8)), p.getToken(range.end_key.getBytes(UTF8))); + bounds = new Bounds(p.getToken(range.start_key), p.getToken(range.end_key)); } rows = StorageProxy.getRangeSlice(new RangeSliceCommand(keyspace, column_parent, predicate, bounds, range.count), consistency_level); assert rows != null; @@ -585,8 +574,7 @@ public class CassandraServer implements Cassandra.Iface for (Row row : rows) { List thriftifiedColumns = thriftifyColumnFamily(row.cf, column_parent.super_column != null, reversed); - // FIXME: string keys - keySlices.add(new KeySlice(new String(row.key.key, UTF8), thriftifiedColumns)); + keySlices.add(new KeySlice(row.key.key, thriftifiedColumns)); } return keySlices; diff --git a/src/java/org/apache/cassandra/thrift/ThriftValidation.java b/src/java/org/apache/cassandra/thrift/ThriftValidation.java index 6ac961d23e..80e610a87b 100644 --- a/src/java/org/apache/cassandra/thrift/ThriftValidation.java +++ b/src/java/org/apache/cassandra/thrift/ThriftValidation.java @@ -38,16 +38,18 @@ import org.apache.cassandra.utils.FBUtilities; public class ThriftValidation { - static void validateKey(String key) throws InvalidRequestException + static void validateKey(byte[] key) throws InvalidRequestException { - if (key.isEmpty()) + if (key == null || key.length == 0) { throw new InvalidRequestException("Key may not be empty"); } - // check that writeUTF will be able to handle it -- encoded length must fit in 2 bytes - int utflen = FBUtilities.encodedUTF8Length(key); - if (utflen > 65535) - throw new InvalidRequestException("Encoded key length of " + utflen + " is longer than maximum of 65535"); + // check that key can be handled by FBUtilities.writeShortByteArray + if (key.length > FBUtilities.MAX_UNSIGNED_SHORT) + { + throw new InvalidRequestException("Key length of " + key.length + + " is longer than maximum of " + FBUtilities.MAX_UNSIGNED_SHORT); + } } private static void validateTable(String tablename) throws KeyspaceNotDefinedException @@ -303,9 +305,8 @@ public class ThriftValidation if (range.start_key != null) { IPartitioner p = StorageService.getPartitioner(); - // FIXME: string keys - Token startToken = p.getToken(range.start_key.getBytes(FBUtilities.UTF8)); - Token endToken = p.getToken(range.end_key.getBytes(FBUtilities.UTF8)); + Token startToken = p.getToken(range.start_key); + Token endToken = p.getToken(range.end_key); if (startToken.compareTo(endToken) > 0 && !endToken.equals(p.getMinimumToken())) { if (p instanceof RandomPartitioner) diff --git a/test/unit/org/apache/cassandra/client/TestRingCache.java b/test/unit/org/apache/cassandra/client/TestRingCache.java index e338dea5c2..e9953c5f21 100644 --- a/test/unit/org/apache/cassandra/client/TestRingCache.java +++ b/test/unit/org/apache/cassandra/client/TestRingCache.java @@ -87,20 +87,20 @@ public class TestRingCache for (int nRows = minRow; nRows < maxRow; nRows++) { - String row = rowPrefix + nRows; + byte[] row = (rowPrefix + nRows).getBytes(); ColumnPath col = new ColumnPath("Standard1").setSuper_column(null).setColumn("col1".getBytes()); - List endPoints = tester.ringCache.getEndPoint(row.getBytes()); + List endPoints = tester.ringCache.getEndPoint(row); String hosts=""; for (int i = 0; i < endPoints.size(); i++) hosts = hosts + ((i > 0) ? "," : "") + endPoints.get(i); - System.out.println("hosts with key " + row + " : " + hosts + "; choose " + endPoints.get(0)); + System.out.println("hosts with key " + new String(row) + " : " + hosts + "; choose " + endPoints.get(0)); // now, read the row back directly from the host owning the row locally tester.setup(endPoints.get(0).getHostAddress(), DatabaseDescriptor.getRpcPort()); tester.thriftClient.insert(keyspace, row, col, "val1".getBytes(), 1, ConsistencyLevel.ONE); Column column = tester.thriftClient.get(keyspace, row, col, ConsistencyLevel.ONE).column; - System.out.println("read row " + row + " " + new String(column.name) + ":" + new String(column.value) + ":" + column.timestamp); + System.out.println("read row " + new String(row) + " " + new String(column.name) + ":" + new String(column.value) + ":" + column.timestamp); } System.exit(1); diff --git a/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java b/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java index a3b6300552..3afc8b68b4 100644 --- a/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java +++ b/test/unit/org/apache/cassandra/service/EmbeddedCassandraServiceTest.java @@ -89,7 +89,7 @@ public class EmbeddedCassandraServiceTest { Cassandra.Client client = getClient(); - String key_user_id = "1"; + byte[] key_user_id = "1".getBytes(); long timestamp = System.currentTimeMillis(); ColumnPath cp = new ColumnPath("Standard1");