diff --git a/build.xml b/build.xml index b0a0d86a35..4eac9213b2 100644 --- a/build.xml +++ b/build.xml @@ -94,26 +94,6 @@ - - - - - - - Building Grammar ${build.src}/org/apache/cassandra/cql/compiler/parse/Cql.g .... - - - - - - - Generating Thrift Java code from ${basedir}/interface/cassandra.thrift .... @@ -134,7 +114,7 @@ - + diff --git a/interface/cassandra.thrift b/interface/cassandra.thrift index 4be685cb25..609129344a 100644 --- a/interface/cassandra.thrift +++ b/interface/cassandra.thrift @@ -169,8 +169,5 @@ service Cassandra { // describe specified keyspace map> describe_keyspace(1:string keyspace) throws (1: NotFoundException nfe), - - // execute a CQL query - CqlResult execute_query(1:string query) } diff --git a/interface/gen-java/org/apache/cassandra/service/BatchMutation.java b/interface/gen-java/org/apache/cassandra/service/BatchMutation.java index e6fdc91424..ac97c7690c 100644 --- a/interface/gen-java/org/apache/cassandra/service/BatchMutation.java +++ b/interface/gen-java/org/apache/cassandra/service/BatchMutation.java @@ -76,8 +76,9 @@ public class BatchMutation implements TBase, java.io.Serializable, Cloneable { return this.key; } - public void setKey(String key) { + public BatchMutation setKey(String key) { this.key = key; + return this; } public void unsetKey() { @@ -95,23 +96,13 @@ public class BatchMutation implements TBase, java.io.Serializable, Cloneable { } } - public int getCfmapSize() { - return (this.cfmap == null) ? 0 : this.cfmap.size(); - } - - public void putToCfmap(String key, List val) { - if (this.cfmap == null) { - this.cfmap = new HashMap>(); - } - this.cfmap.put(key, val); - } - public Map> getCfmap() { return this.cfmap; } - public void setCfmap(Map> cfmap) { + public BatchMutation setCfmap(Map> cfmap) { this.cfmap = cfmap; + return this; } public void unsetCfmap() { diff --git a/interface/gen-java/org/apache/cassandra/service/BatchMutationSuper.java b/interface/gen-java/org/apache/cassandra/service/BatchMutationSuper.java index 9a2f23a4aa..14dd9630fd 100644 --- a/interface/gen-java/org/apache/cassandra/service/BatchMutationSuper.java +++ b/interface/gen-java/org/apache/cassandra/service/BatchMutationSuper.java @@ -76,8 +76,9 @@ public class BatchMutationSuper implements TBase, java.io.Serializable, Cloneabl return this.key; } - public void setKey(String key) { + public BatchMutationSuper setKey(String key) { this.key = key; + return this; } public void unsetKey() { @@ -95,23 +96,13 @@ public class BatchMutationSuper implements TBase, java.io.Serializable, Cloneabl } } - public int getCfmapSize() { - return (this.cfmap == null) ? 0 : this.cfmap.size(); - } - - public void putToCfmap(String key, List val) { - if (this.cfmap == null) { - this.cfmap = new HashMap>(); - } - this.cfmap.put(key, val); - } - public Map> getCfmap() { return this.cfmap; } - public void setCfmap(Map> cfmap) { + public BatchMutationSuper setCfmap(Map> cfmap) { this.cfmap = cfmap; + return this; } public void unsetCfmap() { diff --git a/interface/gen-java/org/apache/cassandra/service/Cassandra.java b/interface/gen-java/org/apache/cassandra/service/Cassandra.java index d45d6ac0a6..f459fc82b8 100644 --- a/interface/gen-java/org/apache/cassandra/service/Cassandra.java +++ b/interface/gen-java/org/apache/cassandra/service/Cassandra.java @@ -32,7 +32,7 @@ public class Cassandra { public void batch_insert(String keyspace, BatchMutation batch_mutation, int consistency_level) throws InvalidRequestException, UnavailableException, TException; - public void remove(String keyspace, String key, ColumnPath column_path_or_parent, long timestamp, int consistency_level) throws InvalidRequestException, UnavailableException, TException; + public void remove(String keyspace, String key, ColumnPath column_path, long timestamp, int consistency_level) throws InvalidRequestException, UnavailableException, TException; public void batch_insert_super_column(String keyspace, BatchMutationSuper batch_mutation_super, int consistency_level) throws InvalidRequestException, UnavailableException, TException; @@ -44,8 +44,6 @@ public class Cassandra { public Map> describe_keyspace(String keyspace) throws NotFoundException, TException; - public CqlResult execute_query(String query) throws TException; - } public static class Client implements Iface { @@ -278,19 +276,19 @@ public class Cassandra { return; } - public void remove(String keyspace, String key, ColumnPath column_path_or_parent, long timestamp, int consistency_level) throws InvalidRequestException, UnavailableException, TException + public void remove(String keyspace, String key, ColumnPath column_path, long timestamp, int consistency_level) throws InvalidRequestException, UnavailableException, TException { - send_remove(keyspace, key, column_path_or_parent, timestamp, consistency_level); + send_remove(keyspace, key, column_path, timestamp, consistency_level); recv_remove(); } - public void send_remove(String keyspace, String key, ColumnPath column_path_or_parent, long timestamp, int consistency_level) throws TException + public void send_remove(String keyspace, String key, ColumnPath column_path, long timestamp, int consistency_level) throws TException { oprot_.writeMessageBegin(new TMessage("remove", TMessageType.CALL, seqid_)); remove_args args = new remove_args(); args.keyspace = keyspace; args.key = key; - args.column_path_or_parent = column_path_or_parent; + args.column_path = column_path; args.timestamp = timestamp; args.consistency_level = consistency_level; args.write(oprot_); @@ -498,39 +496,6 @@ public class Cassandra { throw new TApplicationException(TApplicationException.MISSING_RESULT, "describe_keyspace failed: unknown result"); } - public CqlResult execute_query(String query) throws TException - { - send_execute_query(query); - return recv_execute_query(); - } - - public void send_execute_query(String query) throws TException - { - oprot_.writeMessageBegin(new TMessage("execute_query", TMessageType.CALL, seqid_)); - execute_query_args args = new execute_query_args(); - args.query = query; - args.write(oprot_); - oprot_.writeMessageEnd(); - oprot_.getTransport().flush(); - } - - public CqlResult recv_execute_query() throws TException - { - TMessage msg = iprot_.readMessageBegin(); - if (msg.type == TMessageType.EXCEPTION) { - TApplicationException x = TApplicationException.read(iprot_); - iprot_.readMessageEnd(); - throw x; - } - execute_query_result result = new execute_query_result(); - result.read(iprot_); - iprot_.readMessageEnd(); - if (result.isSetSuccess()) { - return result.success; - } - throw new TApplicationException(TApplicationException.MISSING_RESULT, "execute_query failed: unknown result"); - } - } public static class Processor implements TProcessor { private static final Logger LOGGER = Logger.getLogger(Processor.class.getName()); @@ -548,7 +513,6 @@ public class Cassandra { processMap_.put("get_string_property", new get_string_property()); processMap_.put("get_string_list_property", new get_string_list_property()); processMap_.put("describe_keyspace", new describe_keyspace()); - processMap_.put("execute_query", new execute_query()); } protected static interface ProcessFunction { @@ -733,7 +697,7 @@ public class Cassandra { iprot.readMessageEnd(); remove_result result = new remove_result(); try { - iface_.remove(args.keyspace, args.key, args.column_path_or_parent, args.timestamp, args.consistency_level); + iface_.remove(args.keyspace, args.key, args.column_path, args.timestamp, args.consistency_level); } catch (InvalidRequestException ire) { result.ire = ire; } catch (UnavailableException ue) { @@ -873,22 +837,6 @@ public class Cassandra { } - private class execute_query implements ProcessFunction { - public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException - { - execute_query_args args = new execute_query_args(); - args.read(iprot); - iprot.readMessageEnd(); - execute_query_result result = new execute_query_result(); - result.success = iface_.execute_query(args.query); - oprot.writeMessageBegin(new TMessage("execute_query", TMessageType.REPLY, seqid)); - result.write(oprot); - oprot.writeMessageEnd(); - oprot.getTransport().flush(); - } - - } - } public static class get_slice_args implements TBase, java.io.Serializable, Cloneable { @@ -907,6 +855,10 @@ public class Cassandra { public static final int COLUMN_PARENT = 3; public SlicePredicate predicate; public static final int PREDICATE = 4; + /** + * + * @see ConsistencyLevel + */ public int consistency_level; public static final int CONSISTENCY_LEVEL = 5; @@ -982,8 +934,9 @@ public class Cassandra { return this.keyspace; } - public void setKeyspace(String keyspace) { + public get_slice_args setKeyspace(String keyspace) { this.keyspace = keyspace; + return this; } public void unsetKeyspace() { @@ -1005,8 +958,9 @@ public class Cassandra { return this.key; } - public void setKey(String key) { + public get_slice_args setKey(String key) { this.key = key; + return this; } public void unsetKey() { @@ -1028,8 +982,9 @@ public class Cassandra { return this.column_parent; } - public void setColumn_parent(ColumnParent column_parent) { + public get_slice_args setColumn_parent(ColumnParent column_parent) { this.column_parent = column_parent; + return this; } public void unsetColumn_parent() { @@ -1051,8 +1006,9 @@ public class Cassandra { return this.predicate; } - public void setPredicate(SlicePredicate predicate) { + public get_slice_args setPredicate(SlicePredicate predicate) { this.predicate = predicate; + return this; } public void unsetPredicate() { @@ -1070,13 +1026,22 @@ public class Cassandra { } } + /** + * + * @see ConsistencyLevel + */ public int getConsistency_level() { return this.consistency_level; } - public void setConsistency_level(int consistency_level) { + /** + * + * @see ConsistencyLevel + */ + public get_slice_args setConsistency_level(int consistency_level) { this.consistency_level = consistency_level; this.__isset.consistency_level = true; + return this; } public void unsetConsistency_level() { @@ -1469,27 +1434,13 @@ public class Cassandra { return new get_slice_result(this); } - public int getSuccessSize() { - return (this.success == null) ? 0 : this.success.size(); - } - - public java.util.Iterator getSuccessIterator() { - return (this.success == null) ? null : this.success.iterator(); - } - - public void addToSuccess(ColumnOrSuperColumn elem) { - if (this.success == null) { - this.success = new ArrayList(); - } - this.success.add(elem); - } - public List getSuccess() { return this.success; } - public void setSuccess(List success) { + public get_slice_result setSuccess(List success) { this.success = success; + return this; } public void unsetSuccess() { @@ -1511,8 +1462,9 @@ public class Cassandra { return this.ire; } - public void setIre(InvalidRequestException ire) { + public get_slice_result setIre(InvalidRequestException ire) { this.ire = ire; + return this; } public void unsetIre() { @@ -1534,8 +1486,9 @@ public class Cassandra { return this.nfe; } - public void setNfe(NotFoundException nfe) { + public get_slice_result setNfe(NotFoundException nfe) { this.nfe = nfe; + return this; } public void unsetNfe() { @@ -1798,6 +1751,10 @@ public class Cassandra { public static final int KEY = 2; public ColumnPath column_path; public static final int COLUMN_PATH = 3; + /** + * + * @see ConsistencyLevel + */ public int consistency_level; public static final int CONSISTENCY_LEVEL = 4; @@ -1866,8 +1823,9 @@ public class Cassandra { return this.keyspace; } - public void setKeyspace(String keyspace) { + public get_args setKeyspace(String keyspace) { this.keyspace = keyspace; + return this; } public void unsetKeyspace() { @@ -1889,8 +1847,9 @@ public class Cassandra { return this.key; } - public void setKey(String key) { + public get_args setKey(String key) { this.key = key; + return this; } public void unsetKey() { @@ -1912,8 +1871,9 @@ public class Cassandra { return this.column_path; } - public void setColumn_path(ColumnPath column_path) { + public get_args setColumn_path(ColumnPath column_path) { this.column_path = column_path; + return this; } public void unsetColumn_path() { @@ -1931,13 +1891,22 @@ public class Cassandra { } } + /** + * + * @see ConsistencyLevel + */ public int getConsistency_level() { return this.consistency_level; } - public void setConsistency_level(int consistency_level) { + /** + * + * @see ConsistencyLevel + */ + public get_args setConsistency_level(int consistency_level) { this.consistency_level = consistency_level; this.__isset.consistency_level = true; + return this; } public void unsetConsistency_level() { @@ -2286,8 +2255,9 @@ public class Cassandra { return this.success; } - public void setSuccess(ColumnOrSuperColumn success) { + public get_result setSuccess(ColumnOrSuperColumn success) { this.success = success; + return this; } public void unsetSuccess() { @@ -2309,8 +2279,9 @@ public class Cassandra { return this.ire; } - public void setIre(InvalidRequestException ire) { + public get_result setIre(InvalidRequestException ire) { this.ire = ire; + return this; } public void unsetIre() { @@ -2332,8 +2303,9 @@ public class Cassandra { return this.nfe; } - public void setNfe(NotFoundException nfe) { + public get_result setNfe(NotFoundException nfe) { this.nfe = nfe; + return this; } public void unsetNfe() { @@ -2580,6 +2552,10 @@ public class Cassandra { public static final int KEY = 2; public ColumnParent column_parent; public static final int COLUMN_PARENT = 3; + /** + * + * @see ConsistencyLevel + */ public int consistency_level; public static final int CONSISTENCY_LEVEL = 5; @@ -2648,8 +2624,9 @@ public class Cassandra { return this.keyspace; } - public void setKeyspace(String keyspace) { + public get_count_args setKeyspace(String keyspace) { this.keyspace = keyspace; + return this; } public void unsetKeyspace() { @@ -2671,8 +2648,9 @@ public class Cassandra { return this.key; } - public void setKey(String key) { + public get_count_args setKey(String key) { this.key = key; + return this; } public void unsetKey() { @@ -2694,8 +2672,9 @@ public class Cassandra { return this.column_parent; } - public void setColumn_parent(ColumnParent column_parent) { + public get_count_args setColumn_parent(ColumnParent column_parent) { this.column_parent = column_parent; + return this; } public void unsetColumn_parent() { @@ -2713,13 +2692,22 @@ public class Cassandra { } } + /** + * + * @see ConsistencyLevel + */ public int getConsistency_level() { return this.consistency_level; } - public void setConsistency_level(int consistency_level) { + /** + * + * @see ConsistencyLevel + */ + public get_count_args setConsistency_level(int consistency_level) { this.consistency_level = consistency_level; this.__isset.consistency_level = true; + return this; } public void unsetConsistency_level() { @@ -3059,9 +3047,10 @@ public class Cassandra { return this.success; } - public void setSuccess(int success) { + public get_count_result setSuccess(int success) { this.success = success; this.__isset.success = true; + return this; } public void unsetSuccess() { @@ -3081,8 +3070,9 @@ public class Cassandra { return this.ire; } - public void setIre(InvalidRequestException ire) { + public get_count_result setIre(InvalidRequestException ire) { this.ire = ire; + return this; } public void unsetIre() { @@ -3289,6 +3279,10 @@ public class Cassandra { public static final int VALUE = 4; public long timestamp; public static final int TIMESTAMP = 5; + /** + * + * @see ConsistencyLevel + */ public int consistency_level; public static final int CONSISTENCY_LEVEL = 6; @@ -3373,8 +3367,9 @@ public class Cassandra { return this.keyspace; } - public void setKeyspace(String keyspace) { + public insert_args setKeyspace(String keyspace) { this.keyspace = keyspace; + return this; } public void unsetKeyspace() { @@ -3396,8 +3391,9 @@ public class Cassandra { return this.key; } - public void setKey(String key) { + public insert_args setKey(String key) { this.key = key; + return this; } public void unsetKey() { @@ -3419,8 +3415,9 @@ public class Cassandra { return this.column_path; } - public void setColumn_path(ColumnPath column_path) { + public insert_args setColumn_path(ColumnPath column_path) { this.column_path = column_path; + return this; } public void unsetColumn_path() { @@ -3442,8 +3439,9 @@ public class Cassandra { return this.value; } - public void setValue(byte[] value) { + public insert_args setValue(byte[] value) { this.value = value; + return this; } public void unsetValue() { @@ -3465,9 +3463,10 @@ public class Cassandra { return this.timestamp; } - public void setTimestamp(long timestamp) { + public insert_args setTimestamp(long timestamp) { this.timestamp = timestamp; this.__isset.timestamp = true; + return this; } public void unsetTimestamp() { @@ -3483,13 +3482,22 @@ public class Cassandra { this.__isset.timestamp = value; } + /** + * + * @see ConsistencyLevel + */ public int getConsistency_level() { return this.consistency_level; } - public void setConsistency_level(int consistency_level) { + /** + * + * @see ConsistencyLevel + */ + public insert_args setConsistency_level(int consistency_level) { this.consistency_level = consistency_level; this.__isset.consistency_level = true; + return this; } public void unsetConsistency_level() { @@ -3912,8 +3920,9 @@ public class Cassandra { return this.ire; } - public void setIre(InvalidRequestException ire) { + public insert_result setIre(InvalidRequestException ire) { this.ire = ire; + return this; } public void unsetIre() { @@ -3935,8 +3944,9 @@ public class Cassandra { return this.ue; } - public void setUe(UnavailableException ue) { + public insert_result setUe(UnavailableException ue) { this.ue = ue; + return this; } public void unsetUe() { @@ -4138,6 +4148,10 @@ public class Cassandra { public static final int KEYSPACE = 1; public BatchMutation batch_mutation; public static final int BATCH_MUTATION = 2; + /** + * + * @see ConsistencyLevel + */ public int consistency_level; public static final int CONSISTENCY_LEVEL = 3; @@ -4199,8 +4213,9 @@ public class Cassandra { return this.keyspace; } - public void setKeyspace(String keyspace) { + public batch_insert_args setKeyspace(String keyspace) { this.keyspace = keyspace; + return this; } public void unsetKeyspace() { @@ -4222,8 +4237,9 @@ public class Cassandra { return this.batch_mutation; } - public void setBatch_mutation(BatchMutation batch_mutation) { + public batch_insert_args setBatch_mutation(BatchMutation batch_mutation) { this.batch_mutation = batch_mutation; + return this; } public void unsetBatch_mutation() { @@ -4241,13 +4257,22 @@ public class Cassandra { } } + /** + * + * @see ConsistencyLevel + */ public int getConsistency_level() { return this.consistency_level; } - public void setConsistency_level(int consistency_level) { + /** + * + * @see ConsistencyLevel + */ + public batch_insert_args setConsistency_level(int consistency_level) { this.consistency_level = consistency_level; this.__isset.consistency_level = true; + return this; } public void unsetConsistency_level() { @@ -4544,8 +4569,9 @@ public class Cassandra { return this.ire; } - public void setIre(InvalidRequestException ire) { + public batch_insert_result setIre(InvalidRequestException ire) { this.ire = ire; + return this; } public void unsetIre() { @@ -4567,8 +4593,9 @@ public class Cassandra { return this.ue; } - public void setUe(UnavailableException ue) { + public batch_insert_result setUe(UnavailableException ue) { this.ue = ue; + return this; } public void unsetUe() { @@ -4764,7 +4791,7 @@ public class Cassandra { private static final TStruct STRUCT_DESC = new TStruct("remove_args"); private static final TField KEYSPACE_FIELD_DESC = new TField("keyspace", TType.STRING, (short)1); private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)2); - private static final TField COLUMN_PATH_OR_PARENT_FIELD_DESC = new TField("column_path_or_parent", TType.STRUCT, (short)3); + private static final TField COLUMN_PATH_FIELD_DESC = new TField("column_path", TType.STRUCT, (short)3); private static final TField TIMESTAMP_FIELD_DESC = new TField("timestamp", TType.I64, (short)4); private static final TField CONSISTENCY_LEVEL_FIELD_DESC = new TField("consistency_level", TType.I32, (short)5); @@ -4772,10 +4799,14 @@ public class Cassandra { public static final int KEYSPACE = 1; public String key; public static final int KEY = 2; - public ColumnPath column_path_or_parent; - public static final int COLUMN_PATH_OR_PARENT = 3; + public ColumnPath column_path; + public static final int COLUMN_PATH = 3; public long timestamp; public static final int TIMESTAMP = 4; + /** + * + * @see ConsistencyLevel + */ public int consistency_level; public static final int CONSISTENCY_LEVEL = 5; @@ -4790,7 +4821,7 @@ public class Cassandra { new FieldValueMetaData(TType.STRING))); put(KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.STRING))); - put(COLUMN_PATH_OR_PARENT, new FieldMetaData("column_path_or_parent", TFieldRequirementType.DEFAULT, + put(COLUMN_PATH, new FieldMetaData("column_path", TFieldRequirementType.DEFAULT, new StructMetaData(TType.STRUCT, ColumnPath.class))); put(TIMESTAMP, new FieldMetaData("timestamp", TFieldRequirementType.DEFAULT, new FieldValueMetaData(TType.I64))); @@ -4810,14 +4841,14 @@ public class Cassandra { public remove_args( String keyspace, String key, - ColumnPath column_path_or_parent, + ColumnPath column_path, long timestamp, int consistency_level) { this(); this.keyspace = keyspace; this.key = key; - this.column_path_or_parent = column_path_or_parent; + this.column_path = column_path; this.timestamp = timestamp; this.__isset.timestamp = true; this.consistency_level = consistency_level; @@ -4834,8 +4865,8 @@ public class Cassandra { if (other.isSetKey()) { this.key = other.key; } - if (other.isSetColumn_path_or_parent()) { - this.column_path_or_parent = new ColumnPath(other.column_path_or_parent); + if (other.isSetColumn_path()) { + this.column_path = new ColumnPath(other.column_path); } __isset.timestamp = other.__isset.timestamp; this.timestamp = other.timestamp; @@ -4852,8 +4883,9 @@ public class Cassandra { return this.keyspace; } - public void setKeyspace(String keyspace) { + public remove_args setKeyspace(String keyspace) { this.keyspace = keyspace; + return this; } public void unsetKeyspace() { @@ -4875,8 +4907,9 @@ public class Cassandra { return this.key; } - public void setKey(String key) { + public remove_args setKey(String key) { this.key = key; + return this; } public void unsetKey() { @@ -4894,26 +4927,27 @@ public class Cassandra { } } - public ColumnPath getColumn_path_or_parent() { - return this.column_path_or_parent; + public ColumnPath getColumn_path() { + return this.column_path; } - public void setColumn_path_or_parent(ColumnPath column_path_or_parent) { - this.column_path_or_parent = column_path_or_parent; + public remove_args setColumn_path(ColumnPath column_path) { + this.column_path = column_path; + return this; } - public void unsetColumn_path_or_parent() { - this.column_path_or_parent = null; + public void unsetColumn_path() { + this.column_path = null; } - // Returns true if field column_path_or_parent is set (has been asigned a value) and false otherwise - public boolean isSetColumn_path_or_parent() { - return this.column_path_or_parent != null; + // Returns true if field column_path is set (has been asigned a value) and false otherwise + public boolean isSetColumn_path() { + return this.column_path != null; } - public void setColumn_path_or_parentIsSet(boolean value) { + public void setColumn_pathIsSet(boolean value) { if (!value) { - this.column_path_or_parent = null; + this.column_path = null; } } @@ -4921,9 +4955,10 @@ public class Cassandra { return this.timestamp; } - public void setTimestamp(long timestamp) { + public remove_args setTimestamp(long timestamp) { this.timestamp = timestamp; this.__isset.timestamp = true; + return this; } public void unsetTimestamp() { @@ -4939,13 +4974,22 @@ public class Cassandra { this.__isset.timestamp = value; } + /** + * + * @see ConsistencyLevel + */ public int getConsistency_level() { return this.consistency_level; } - public void setConsistency_level(int consistency_level) { + /** + * + * @see ConsistencyLevel + */ + public remove_args setConsistency_level(int consistency_level) { this.consistency_level = consistency_level; this.__isset.consistency_level = true; + return this; } public void unsetConsistency_level() { @@ -4979,11 +5023,11 @@ public class Cassandra { } break; - case COLUMN_PATH_OR_PARENT: + case COLUMN_PATH: if (value == null) { - unsetColumn_path_or_parent(); + unsetColumn_path(); } else { - setColumn_path_or_parent((ColumnPath)value); + setColumn_path((ColumnPath)value); } break; @@ -5016,8 +5060,8 @@ public class Cassandra { case KEY: return getKey(); - case COLUMN_PATH_OR_PARENT: - return getColumn_path_or_parent(); + case COLUMN_PATH: + return getColumn_path(); case TIMESTAMP: return new Long(getTimestamp()); @@ -5037,8 +5081,8 @@ public class Cassandra { return isSetKeyspace(); case KEY: return isSetKey(); - case COLUMN_PATH_OR_PARENT: - return isSetColumn_path_or_parent(); + case COLUMN_PATH: + return isSetColumn_path(); case TIMESTAMP: return isSetTimestamp(); case CONSISTENCY_LEVEL: @@ -5079,12 +5123,12 @@ public class Cassandra { return false; } - boolean this_present_column_path_or_parent = true && this.isSetColumn_path_or_parent(); - boolean that_present_column_path_or_parent = true && that.isSetColumn_path_or_parent(); - if (this_present_column_path_or_parent || that_present_column_path_or_parent) { - if (!(this_present_column_path_or_parent && that_present_column_path_or_parent)) + boolean this_present_column_path = true && this.isSetColumn_path(); + boolean that_present_column_path = true && that.isSetColumn_path(); + if (this_present_column_path || that_present_column_path) { + if (!(this_present_column_path && that_present_column_path)) return false; - if (!this.column_path_or_parent.equals(that.column_path_or_parent)) + if (!this.column_path.equals(that.column_path)) return false; } @@ -5139,10 +5183,10 @@ public class Cassandra { TProtocolUtil.skip(iprot, field.type); } break; - case COLUMN_PATH_OR_PARENT: + case COLUMN_PATH: if (field.type == TType.STRUCT) { - this.column_path_or_parent = new ColumnPath(); - this.column_path_or_parent.read(iprot); + this.column_path = new ColumnPath(); + this.column_path.read(iprot); } else { TProtocolUtil.skip(iprot, field.type); } @@ -5190,9 +5234,9 @@ public class Cassandra { oprot.writeString(this.key); oprot.writeFieldEnd(); } - if (this.column_path_or_parent != null) { - oprot.writeFieldBegin(COLUMN_PATH_OR_PARENT_FIELD_DESC); - this.column_path_or_parent.write(oprot); + if (this.column_path != null) { + oprot.writeFieldBegin(COLUMN_PATH_FIELD_DESC); + this.column_path.write(oprot); oprot.writeFieldEnd(); } oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC); @@ -5226,11 +5270,11 @@ public class Cassandra { } first = false; if (!first) sb.append(", "); - sb.append("column_path_or_parent:"); - if (this.column_path_or_parent == null) { + sb.append("column_path:"); + if (this.column_path == null) { sb.append("null"); } else { - sb.append(this.column_path_or_parent); + sb.append(this.column_path); } first = false; if (!first) sb.append(", "); @@ -5321,8 +5365,9 @@ public class Cassandra { return this.ire; } - public void setIre(InvalidRequestException ire) { + public remove_result setIre(InvalidRequestException ire) { this.ire = ire; + return this; } public void unsetIre() { @@ -5344,8 +5389,9 @@ public class Cassandra { return this.ue; } - public void setUe(UnavailableException ue) { + public remove_result setUe(UnavailableException ue) { this.ue = ue; + return this; } public void unsetUe() { @@ -5547,6 +5593,10 @@ public class Cassandra { public static final int KEYSPACE = 1; public BatchMutationSuper batch_mutation_super; public static final int BATCH_MUTATION_SUPER = 2; + /** + * + * @see ConsistencyLevel + */ public int consistency_level; public static final int CONSISTENCY_LEVEL = 3; @@ -5608,8 +5658,9 @@ public class Cassandra { return this.keyspace; } - public void setKeyspace(String keyspace) { + public batch_insert_super_column_args setKeyspace(String keyspace) { this.keyspace = keyspace; + return this; } public void unsetKeyspace() { @@ -5631,8 +5682,9 @@ public class Cassandra { return this.batch_mutation_super; } - public void setBatch_mutation_super(BatchMutationSuper batch_mutation_super) { + public batch_insert_super_column_args setBatch_mutation_super(BatchMutationSuper batch_mutation_super) { this.batch_mutation_super = batch_mutation_super; + return this; } public void unsetBatch_mutation_super() { @@ -5650,13 +5702,22 @@ public class Cassandra { } } + /** + * + * @see ConsistencyLevel + */ public int getConsistency_level() { return this.consistency_level; } - public void setConsistency_level(int consistency_level) { + /** + * + * @see ConsistencyLevel + */ + public batch_insert_super_column_args setConsistency_level(int consistency_level) { this.consistency_level = consistency_level; this.__isset.consistency_level = true; + return this; } public void unsetConsistency_level() { @@ -5953,8 +6014,9 @@ public class Cassandra { return this.ire; } - public void setIre(InvalidRequestException ire) { + public batch_insert_super_column_result setIre(InvalidRequestException ire) { this.ire = ire; + return this; } public void unsetIre() { @@ -5976,8 +6038,9 @@ public class Cassandra { return this.ue; } - public void setUe(UnavailableException ue) { + public batch_insert_super_column_result setUe(UnavailableException ue) { this.ue = ue; + return this; } public void unsetUe() { @@ -6264,8 +6327,9 @@ public class Cassandra { return this.keyspace; } - public void setKeyspace(String keyspace) { + public get_key_range_args setKeyspace(String keyspace) { this.keyspace = keyspace; + return this; } public void unsetKeyspace() { @@ -6287,8 +6351,9 @@ public class Cassandra { return this.column_family; } - public void setColumn_family(String column_family) { + public get_key_range_args setColumn_family(String column_family) { this.column_family = column_family; + return this; } public void unsetColumn_family() { @@ -6310,8 +6375,9 @@ public class Cassandra { return this.start; } - public void setStart(String start) { + public get_key_range_args setStart(String start) { this.start = start; + return this; } public void unsetStart() { @@ -6333,8 +6399,9 @@ public class Cassandra { return this.finish; } - public void setFinish(String finish) { + public get_key_range_args setFinish(String finish) { this.finish = finish; + return this; } public void unsetFinish() { @@ -6356,9 +6423,10 @@ public class Cassandra { return this.count; } - public void setCount(int count) { + public get_key_range_args setCount(int count) { this.count = count; this.__isset.count = true; + return this; } public void unsetCount() { @@ -6728,27 +6796,13 @@ public class Cassandra { return new get_key_range_result(this); } - public int getSuccessSize() { - return (this.success == null) ? 0 : this.success.size(); - } - - public java.util.Iterator getSuccessIterator() { - return (this.success == null) ? null : this.success.iterator(); - } - - public void addToSuccess(String elem) { - if (this.success == null) { - this.success = new ArrayList(); - } - this.success.add(elem); - } - public List getSuccess() { return this.success; } - public void setSuccess(List success) { + public get_key_range_result setSuccess(List success) { this.success = success; + return this; } public void unsetSuccess() { @@ -6770,8 +6824,9 @@ public class Cassandra { return this.ire; } - public void setIre(InvalidRequestException ire) { + public get_key_range_result setIre(InvalidRequestException ire) { this.ire = ire; + return this; } public void unsetIre() { @@ -7026,8 +7081,9 @@ public class Cassandra { return this.property; } - public void setProperty(String property) { + public get_string_property_args setProperty(String property) { this.property = property; + return this; } public void unsetProperty() { @@ -7225,8 +7281,9 @@ public class Cassandra { return this.success; } - public void setSuccess(String success) { + public get_string_property_result setSuccess(String success) { this.success = success; + return this; } public void unsetSuccess() { @@ -7423,8 +7480,9 @@ public class Cassandra { return this.property; } - public void setProperty(String property) { + public get_string_list_property_args setProperty(String property) { this.property = property; + return this; } public void unsetProperty() { @@ -7623,27 +7681,13 @@ public class Cassandra { return new get_string_list_property_result(this); } - public int getSuccessSize() { - return (this.success == null) ? 0 : this.success.size(); - } - - public java.util.Iterator getSuccessIterator() { - return (this.success == null) ? null : this.success.iterator(); - } - - public void addToSuccess(String elem) { - if (this.success == null) { - this.success = new ArrayList(); - } - this.success.add(elem); - } - public List getSuccess() { return this.success; } - public void setSuccess(List success) { + public get_string_list_property_result setSuccess(List success) { this.success = success; + return this; } public void unsetSuccess() { @@ -7856,8 +7900,9 @@ public class Cassandra { return this.keyspace; } - public void setKeyspace(String keyspace) { + public describe_keyspace_args setKeyspace(String keyspace) { this.keyspace = keyspace; + return this; } public void unsetKeyspace() { @@ -8088,23 +8133,13 @@ public class Cassandra { return new describe_keyspace_result(this); } - public int getSuccessSize() { - return (this.success == null) ? 0 : this.success.size(); - } - - public void putToSuccess(String key, Map val) { - if (this.success == null) { - this.success = new HashMap>(); - } - this.success.put(key, val); - } - public Map> getSuccess() { return this.success; } - public void setSuccess(Map> success) { + public describe_keyspace_result setSuccess(Map> success) { this.success = success; + return this; } public void unsetSuccess() { @@ -8126,8 +8161,9 @@ public class Cassandra { return this.nfe; } - public void setNfe(NotFoundException nfe) { + public describe_keyspace_result setNfe(NotFoundException nfe) { this.nfe = nfe; + return this; } public void unsetNfe() { @@ -8356,402 +8392,4 @@ public class Cassandra { } - public static class execute_query_args implements TBase, java.io.Serializable, Cloneable { - private static final TStruct STRUCT_DESC = new TStruct("execute_query_args"); - private static final TField QUERY_FIELD_DESC = new TField("query", TType.STRING, (short)1); - - public String query; - public static final int QUERY = 1; - - private final Isset __isset = new Isset(); - private static final class Isset implements java.io.Serializable { - } - - public static final Map metaDataMap = Collections.unmodifiableMap(new HashMap() {{ - put(QUERY, new FieldMetaData("query", TFieldRequirementType.DEFAULT, - new FieldValueMetaData(TType.STRING))); - }}); - - static { - FieldMetaData.addStructMetaDataMap(execute_query_args.class, metaDataMap); - } - - public execute_query_args() { - } - - public execute_query_args( - String query) - { - this(); - this.query = query; - } - - /** - * Performs a deep copy on other. - */ - public execute_query_args(execute_query_args other) { - if (other.isSetQuery()) { - this.query = other.query; - } - } - - @Override - public execute_query_args clone() { - return new execute_query_args(this); - } - - public String getQuery() { - return this.query; - } - - public void setQuery(String query) { - this.query = query; - } - - public void unsetQuery() { - this.query = null; - } - - // Returns true if field query is set (has been asigned a value) and false otherwise - public boolean isSetQuery() { - return this.query != null; - } - - public void setQueryIsSet(boolean value) { - if (!value) { - this.query = null; - } - } - - public void setFieldValue(int fieldID, Object value) { - switch (fieldID) { - case QUERY: - if (value == null) { - unsetQuery(); - } else { - setQuery((String)value); - } - break; - - default: - throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); - } - } - - public Object getFieldValue(int fieldID) { - switch (fieldID) { - case QUERY: - return getQuery(); - - default: - throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); - } - } - - // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise - public boolean isSet(int fieldID) { - switch (fieldID) { - case QUERY: - return isSetQuery(); - default: - throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); - } - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof execute_query_args) - return this.equals((execute_query_args)that); - return false; - } - - public boolean equals(execute_query_args that) { - if (that == null) - return false; - - boolean this_present_query = true && this.isSetQuery(); - boolean that_present_query = true && that.isSetQuery(); - if (this_present_query || that_present_query) { - if (!(this_present_query && that_present_query)) - return false; - if (!this.query.equals(that.query)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - public void read(TProtocol iprot) throws TException { - TField field; - iprot.readStructBegin(); - while (true) - { - field = iprot.readFieldBegin(); - if (field.type == TType.STOP) { - break; - } - switch (field.id) - { - case QUERY: - if (field.type == TType.STRING) { - this.query = iprot.readString(); - } else { - TProtocolUtil.skip(iprot, field.type); - } - break; - default: - TProtocolUtil.skip(iprot, field.type); - break; - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - - // check for required fields of primitive type, which can't be checked in the validate method - validate(); - } - - public void write(TProtocol oprot) throws TException { - validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (this.query != null) { - oprot.writeFieldBegin(QUERY_FIELD_DESC); - oprot.writeString(this.query); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("execute_query_args("); - boolean first = true; - - sb.append("query:"); - if (this.query == null) { - sb.append("null"); - } else { - sb.append(this.query); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws TException { - // check for required fields - // check that fields of type enum have valid values - } - - } - - public static class execute_query_result implements TBase, java.io.Serializable, Cloneable { - private static final TStruct STRUCT_DESC = new TStruct("execute_query_result"); - private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.STRUCT, (short)0); - - public CqlResult success; - public static final int SUCCESS = 0; - - private final Isset __isset = new Isset(); - private static final class Isset implements java.io.Serializable { - } - - public static final Map metaDataMap = Collections.unmodifiableMap(new HashMap() {{ - put(SUCCESS, new FieldMetaData("success", TFieldRequirementType.DEFAULT, - new StructMetaData(TType.STRUCT, CqlResult.class))); - }}); - - static { - FieldMetaData.addStructMetaDataMap(execute_query_result.class, metaDataMap); - } - - public execute_query_result() { - } - - public execute_query_result( - CqlResult success) - { - this(); - this.success = success; - } - - /** - * Performs a deep copy on other. - */ - public execute_query_result(execute_query_result other) { - if (other.isSetSuccess()) { - this.success = new CqlResult(other.success); - } - } - - @Override - public execute_query_result clone() { - return new execute_query_result(this); - } - - public CqlResult getSuccess() { - return this.success; - } - - public void setSuccess(CqlResult success) { - this.success = success; - } - - public void unsetSuccess() { - this.success = null; - } - - // Returns true if field success is set (has been asigned a value) and false otherwise - public boolean isSetSuccess() { - return this.success != null; - } - - public void setSuccessIsSet(boolean value) { - if (!value) { - this.success = null; - } - } - - public void setFieldValue(int fieldID, Object value) { - switch (fieldID) { - case SUCCESS: - if (value == null) { - unsetSuccess(); - } else { - setSuccess((CqlResult)value); - } - break; - - default: - throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); - } - } - - public Object getFieldValue(int fieldID) { - switch (fieldID) { - case SUCCESS: - return getSuccess(); - - default: - throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); - } - } - - // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise - public boolean isSet(int fieldID) { - switch (fieldID) { - case SUCCESS: - return isSetSuccess(); - default: - throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); - } - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof execute_query_result) - return this.equals((execute_query_result)that); - return false; - } - - public boolean equals(execute_query_result that) { - if (that == null) - return false; - - boolean this_present_success = true && this.isSetSuccess(); - boolean that_present_success = true && that.isSetSuccess(); - if (this_present_success || that_present_success) { - if (!(this_present_success && that_present_success)) - return false; - if (!this.success.equals(that.success)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - return 0; - } - - public void read(TProtocol iprot) throws TException { - TField field; - iprot.readStructBegin(); - while (true) - { - field = iprot.readFieldBegin(); - if (field.type == TType.STOP) { - break; - } - switch (field.id) - { - case SUCCESS: - if (field.type == TType.STRUCT) { - this.success = new CqlResult(); - this.success.read(iprot); - } else { - TProtocolUtil.skip(iprot, field.type); - } - break; - default: - TProtocolUtil.skip(iprot, field.type); - break; - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - - // check for required fields of primitive type, which can't be checked in the validate method - validate(); - } - - public void write(TProtocol oprot) throws TException { - oprot.writeStructBegin(STRUCT_DESC); - - if (this.isSetSuccess()) { - oprot.writeFieldBegin(SUCCESS_FIELD_DESC); - this.success.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("execute_query_result("); - boolean first = true; - - sb.append("success:"); - if (this.success == null) { - sb.append("null"); - } else { - sb.append(this.success); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws TException { - // check for required fields - // check that fields of type enum have valid values - } - - } - } diff --git a/interface/gen-java/org/apache/cassandra/service/Column.java b/interface/gen-java/org/apache/cassandra/service/Column.java index 5443ab6da7..b10e24522b 100644 --- a/interface/gen-java/org/apache/cassandra/service/Column.java +++ b/interface/gen-java/org/apache/cassandra/service/Column.java @@ -89,8 +89,9 @@ public class Column implements TBase, java.io.Serializable, Cloneable { return this.name; } - public void setName(byte[] name) { + public Column setName(byte[] name) { this.name = name; + return this; } public void unsetName() { @@ -112,8 +113,9 @@ public class Column implements TBase, java.io.Serializable, Cloneable { return this.value; } - public void setValue(byte[] value) { + public Column setValue(byte[] value) { this.value = value; + return this; } public void unsetValue() { @@ -135,9 +137,10 @@ public class Column implements TBase, java.io.Serializable, Cloneable { return this.timestamp; } - public void setTimestamp(long timestamp) { + public Column setTimestamp(long timestamp) { this.timestamp = timestamp; this.__isset.timestamp = true; + return this; } public void unsetTimestamp() { diff --git a/interface/gen-java/org/apache/cassandra/service/ColumnOrSuperColumn.java b/interface/gen-java/org/apache/cassandra/service/ColumnOrSuperColumn.java index 7d091c7df3..5af36ad1fb 100644 --- a/interface/gen-java/org/apache/cassandra/service/ColumnOrSuperColumn.java +++ b/interface/gen-java/org/apache/cassandra/service/ColumnOrSuperColumn.java @@ -76,8 +76,9 @@ public class ColumnOrSuperColumn implements TBase, java.io.Serializable, Cloneab return this.column; } - public void setColumn(Column column) { + public ColumnOrSuperColumn setColumn(Column column) { this.column = column; + return this; } public void unsetColumn() { @@ -99,8 +100,9 @@ public class ColumnOrSuperColumn implements TBase, java.io.Serializable, Cloneab return this.super_column; } - public void setSuper_column(SuperColumn super_column) { + public ColumnOrSuperColumn setSuper_column(SuperColumn super_column) { this.super_column = super_column; + return this; } public void unsetSuper_column() { @@ -250,14 +252,18 @@ public class ColumnOrSuperColumn implements TBase, java.io.Serializable, Cloneab oprot.writeStructBegin(STRUCT_DESC); if (this.column != null) { - oprot.writeFieldBegin(COLUMN_FIELD_DESC); - this.column.write(oprot); - oprot.writeFieldEnd(); + if (isSetColumn()) { + oprot.writeFieldBegin(COLUMN_FIELD_DESC); + this.column.write(oprot); + oprot.writeFieldEnd(); + } } if (this.super_column != null) { - oprot.writeFieldBegin(SUPER_COLUMN_FIELD_DESC); - this.super_column.write(oprot); - oprot.writeFieldEnd(); + if (isSetSuper_column()) { + oprot.writeFieldBegin(SUPER_COLUMN_FIELD_DESC); + this.super_column.write(oprot); + oprot.writeFieldEnd(); + } } oprot.writeFieldStop(); oprot.writeStructEnd(); diff --git a/interface/gen-java/org/apache/cassandra/service/ColumnParent.java b/interface/gen-java/org/apache/cassandra/service/ColumnParent.java index 65ce1a5e4a..f1d3410db6 100644 --- a/interface/gen-java/org/apache/cassandra/service/ColumnParent.java +++ b/interface/gen-java/org/apache/cassandra/service/ColumnParent.java @@ -77,8 +77,9 @@ public class ColumnParent implements TBase, java.io.Serializable, Cloneable { return this.column_family; } - public void setColumn_family(String column_family) { + public ColumnParent setColumn_family(String column_family) { this.column_family = column_family; + return this; } public void unsetColumn_family() { @@ -100,8 +101,9 @@ public class ColumnParent implements TBase, java.io.Serializable, Cloneable { return this.super_column; } - public void setSuper_column(byte[] super_column) { + public ColumnParent setSuper_column(byte[] super_column) { this.super_column = super_column; + return this; } public void unsetSuper_column() { @@ -254,9 +256,11 @@ public class ColumnParent implements TBase, java.io.Serializable, Cloneable { oprot.writeFieldEnd(); } if (this.super_column != null) { - oprot.writeFieldBegin(SUPER_COLUMN_FIELD_DESC); - oprot.writeBinary(this.super_column); - oprot.writeFieldEnd(); + if (isSetSuper_column()) { + oprot.writeFieldBegin(SUPER_COLUMN_FIELD_DESC); + oprot.writeBinary(this.super_column); + oprot.writeFieldEnd(); + } } oprot.writeFieldStop(); oprot.writeStructEnd(); diff --git a/interface/gen-java/org/apache/cassandra/service/ColumnPath.java b/interface/gen-java/org/apache/cassandra/service/ColumnPath.java index be712ef838..4aafea58f3 100644 --- a/interface/gen-java/org/apache/cassandra/service/ColumnPath.java +++ b/interface/gen-java/org/apache/cassandra/service/ColumnPath.java @@ -88,8 +88,9 @@ public class ColumnPath implements TBase, java.io.Serializable, Cloneable { return this.column_family; } - public void setColumn_family(String column_family) { + public ColumnPath setColumn_family(String column_family) { this.column_family = column_family; + return this; } public void unsetColumn_family() { @@ -111,8 +112,9 @@ public class ColumnPath implements TBase, java.io.Serializable, Cloneable { return this.super_column; } - public void setSuper_column(byte[] super_column) { + public ColumnPath setSuper_column(byte[] super_column) { this.super_column = super_column; + return this; } public void unsetSuper_column() { @@ -134,8 +136,9 @@ public class ColumnPath implements TBase, java.io.Serializable, Cloneable { return this.column; } - public void setColumn(byte[] column) { + public ColumnPath setColumn(byte[] column) { this.column = column; + return this; } public void unsetColumn() { @@ -317,14 +320,18 @@ public class ColumnPath implements TBase, java.io.Serializable, Cloneable { oprot.writeFieldEnd(); } if (this.super_column != null) { - oprot.writeFieldBegin(SUPER_COLUMN_FIELD_DESC); - oprot.writeBinary(this.super_column); - oprot.writeFieldEnd(); + if (isSetSuper_column()) { + oprot.writeFieldBegin(SUPER_COLUMN_FIELD_DESC); + oprot.writeBinary(this.super_column); + oprot.writeFieldEnd(); + } } if (this.column != null) { - oprot.writeFieldBegin(COLUMN_FIELD_DESC); - oprot.writeBinary(this.column); - oprot.writeFieldEnd(); + if (isSetColumn()) { + oprot.writeFieldBegin(COLUMN_FIELD_DESC); + oprot.writeBinary(this.column); + oprot.writeFieldEnd(); + } } oprot.writeFieldStop(); oprot.writeStructEnd(); diff --git a/interface/gen-java/org/apache/cassandra/service/ConsistencyLevel.java b/interface/gen-java/org/apache/cassandra/service/ConsistencyLevel.java index 0ce14bd32f..04323d8bd1 100644 --- a/interface/gen-java/org/apache/cassandra/service/ConsistencyLevel.java +++ b/interface/gen-java/org/apache/cassandra/service/ConsistencyLevel.java @@ -19,7 +19,12 @@ public class ConsistencyLevel { public static final int QUORUM = 2; public static final int ALL = 3; - public static final IntRangeSet VALID_VALUES = new IntRangeSet(ZERO, ONE, QUORUM, ALL); + public static final IntRangeSet VALID_VALUES = new IntRangeSet( + ZERO, + ONE, + QUORUM, + ALL ); + public static final Map VALUES_TO_NAMES = new HashMap() {{ put(ZERO, "ZERO"); put(ONE, "ONE"); diff --git a/interface/gen-java/org/apache/cassandra/service/CqlResult.java b/interface/gen-java/org/apache/cassandra/service/CqlResult.java index 4ae562ea75..9004fe2ba5 100644 --- a/interface/gen-java/org/apache/cassandra/service/CqlResult.java +++ b/interface/gen-java/org/apache/cassandra/service/CqlResult.java @@ -87,9 +87,10 @@ public class CqlResult implements TBase, java.io.Serializable, Cloneable { return this.error_code; } - public void setError_code(int error_code) { + public CqlResult setError_code(int error_code) { this.error_code = error_code; this.__isset.error_code = true; + return this; } public void unsetError_code() { @@ -109,8 +110,9 @@ public class CqlResult implements TBase, java.io.Serializable, Cloneable { return this.error_txt; } - public void setError_txt(String error_txt) { + public CqlResult setError_txt(String error_txt) { this.error_txt = error_txt; + return this; } public void unsetError_txt() { @@ -128,27 +130,13 @@ public class CqlResult implements TBase, java.io.Serializable, Cloneable { } } - public int getResult_setSize() { - return (this.result_set == null) ? 0 : this.result_set.size(); - } - - public java.util.Iterator> getResult_setIterator() { - return (this.result_set == null) ? null : this.result_set.iterator(); - } - - public void addToResult_set(Map elem) { - if (this.result_set == null) { - this.result_set = new ArrayList>(); - } - this.result_set.add(elem); - } - public List> getResult_set() { return this.result_set; } - public void setResult_set(List> result_set) { + public CqlResult setResult_set(List> result_set) { this.result_set = result_set; + return this; } public void unsetResult_set() { diff --git a/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java b/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java index 524bc0c4fc..84aed87c43 100644 --- a/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java +++ b/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java @@ -66,8 +66,9 @@ public class InvalidRequestException extends Exception implements TBase, java.io return this.why; } - public void setWhy(String why) { + public InvalidRequestException setWhy(String why) { this.why = why; + return this; } public void unsetWhy() { diff --git a/interface/gen-java/org/apache/cassandra/service/SlicePredicate.java b/interface/gen-java/org/apache/cassandra/service/SlicePredicate.java index 31a6b46c54..70e6101fbd 100644 --- a/interface/gen-java/org/apache/cassandra/service/SlicePredicate.java +++ b/interface/gen-java/org/apache/cassandra/service/SlicePredicate.java @@ -79,27 +79,13 @@ public class SlicePredicate implements TBase, java.io.Serializable, Cloneable { return new SlicePredicate(this); } - public int getColumn_namesSize() { - return (this.column_names == null) ? 0 : this.column_names.size(); - } - - public java.util.Iterator getColumn_namesIterator() { - return (this.column_names == null) ? null : this.column_names.iterator(); - } - - public void addToColumn_names(byte[] elem) { - if (this.column_names == null) { - this.column_names = new ArrayList(); - } - this.column_names.add(elem); - } - public List getColumn_names() { return this.column_names; } - public void setColumn_names(List column_names) { + public SlicePredicate setColumn_names(List column_names) { this.column_names = column_names; + return this; } public void unsetColumn_names() { @@ -121,8 +107,9 @@ public class SlicePredicate implements TBase, java.io.Serializable, Cloneable { return this.slice_range; } - public void setSlice_range(SliceRange slice_range) { + public SlicePredicate setSlice_range(SliceRange slice_range) { this.slice_range = slice_range; + return this; } public void unsetSlice_range() { @@ -281,20 +268,24 @@ public class SlicePredicate implements TBase, java.io.Serializable, Cloneable { oprot.writeStructBegin(STRUCT_DESC); if (this.column_names != null) { - oprot.writeFieldBegin(COLUMN_NAMES_FIELD_DESC); - { - oprot.writeListBegin(new TList(TType.STRING, this.column_names.size())); - for (byte[] _iter34 : this.column_names) { - oprot.writeBinary(_iter34); + if (isSetColumn_names()) { + oprot.writeFieldBegin(COLUMN_NAMES_FIELD_DESC); + { + oprot.writeListBegin(new TList(TType.STRING, this.column_names.size())); + for (byte[] _iter34 : this.column_names) { + oprot.writeBinary(_iter34); + } + oprot.writeListEnd(); } - oprot.writeListEnd(); + oprot.writeFieldEnd(); } - oprot.writeFieldEnd(); } if (this.slice_range != null) { - oprot.writeFieldBegin(SLICE_RANGE_FIELD_DESC); - this.slice_range.write(oprot); - oprot.writeFieldEnd(); + if (isSetSlice_range()) { + oprot.writeFieldBegin(SLICE_RANGE_FIELD_DESC); + this.slice_range.write(oprot); + oprot.writeFieldEnd(); + } } oprot.writeFieldStop(); oprot.writeStructEnd(); diff --git a/interface/gen-java/org/apache/cassandra/service/SliceRange.java b/interface/gen-java/org/apache/cassandra/service/SliceRange.java index c9bd6e845b..49e7476eda 100644 --- a/interface/gen-java/org/apache/cassandra/service/SliceRange.java +++ b/interface/gen-java/org/apache/cassandra/service/SliceRange.java @@ -104,8 +104,9 @@ public class SliceRange implements TBase, java.io.Serializable, Cloneable { return this.start; } - public void setStart(byte[] start) { + public SliceRange setStart(byte[] start) { this.start = start; + return this; } public void unsetStart() { @@ -127,8 +128,9 @@ public class SliceRange implements TBase, java.io.Serializable, Cloneable { return this.finish; } - public void setFinish(byte[] finish) { + public SliceRange setFinish(byte[] finish) { this.finish = finish; + return this; } public void unsetFinish() { @@ -150,9 +152,10 @@ public class SliceRange implements TBase, java.io.Serializable, Cloneable { return this.is_ascending; } - public void setIs_ascending(boolean is_ascending) { + public SliceRange setIs_ascending(boolean is_ascending) { this.is_ascending = is_ascending; this.__isset.is_ascending = true; + return this; } public void unsetIs_ascending() { @@ -172,9 +175,10 @@ public class SliceRange implements TBase, java.io.Serializable, Cloneable { return this.count; } - public void setCount(int count) { + public SliceRange setCount(int count) { this.count = count; this.__isset.count = true; + return this; } public void unsetCount() { diff --git a/interface/gen-java/org/apache/cassandra/service/SuperColumn.java b/interface/gen-java/org/apache/cassandra/service/SuperColumn.java index 8863723851..3fa2831c91 100644 --- a/interface/gen-java/org/apache/cassandra/service/SuperColumn.java +++ b/interface/gen-java/org/apache/cassandra/service/SuperColumn.java @@ -82,8 +82,9 @@ public class SuperColumn implements TBase, java.io.Serializable, Cloneable { return this.name; } - public void setName(byte[] name) { + public SuperColumn setName(byte[] name) { this.name = name; + return this; } public void unsetName() { @@ -101,27 +102,13 @@ public class SuperColumn implements TBase, java.io.Serializable, Cloneable { } } - public int getColumnsSize() { - return (this.columns == null) ? 0 : this.columns.size(); - } - - public java.util.Iterator getColumnsIterator() { - return (this.columns == null) ? null : this.columns.iterator(); - } - - public void addToColumns(Column elem) { - if (this.columns == null) { - this.columns = new ArrayList(); - } - this.columns.add(elem); - } - public List getColumns() { return this.columns; } - public void setColumns(List columns) { + public SuperColumn setColumns(List columns) { this.columns = columns; + return this; } public void unsetColumns() { diff --git a/src/java/org/apache/cassandra/cli/CliClient.java b/src/java/org/apache/cassandra/cli/CliClient.java index e345aef312..250e991c01 100644 --- a/src/java/org/apache/cassandra/cli/CliClient.java +++ b/src/java/org/apache/cassandra/cli/CliClient.java @@ -146,8 +146,7 @@ public class CliClient } catch (UnsupportedEncodingException e) { - css_.out.printf("Cannot display results (UTF-8 not supported)."); - break; + throw new RuntimeException(e); } } css_.out.println("Returned " + size + " rows."); @@ -161,14 +160,16 @@ public class CliClient try { cosc = thriftClient_.get(tableName, key, new ColumnPath(columnFamily, null, columnName.getBytes("UTF-8")), ConsistencyLevel.ONE); + Column column = cosc.column; + css_.out.printf("==> (name=%s, value=%s; timestamp=%d)\n", + new String(column.name, "UTF-8"), + new String(column.value, "UTF-8"), + column.timestamp); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } - Column column = cosc.column; - css_.out.printf("==> (name=%s, value=%s; timestamp=%d)\n", - column.name, column.value, column.timestamp); } } diff --git a/src/java/org/apache/cassandra/cql/common/BindOperand.java b/src/java/org/apache/cassandra/cql/common/BindOperand.java deleted file mode 100644 index 53d2f8e895..0000000000 --- a/src/java/org/apache/cassandra/cql/common/BindOperand.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -import org.apache.cassandra.cql.execution.RuntimeErrorMsg; - -/** - * BindOperand: - * Represents a bind variable in the CQL statement. Lives - * in the shared execution plan. - */ -public class BindOperand implements OperandDef -{ - int bindIndex_; // bind position - - public BindOperand(int bindIndex) - { - bindIndex_ = bindIndex; - } - - public Object get() - { - // TODO: Once bind variables are supported, the get() will extract - // the value of the bind at position "bindIndex_" from the execution - // context. - throw new RuntimeException(RuntimeErrorMsg.IMPLEMENTATION_RESTRICTION - .getMsg("bind params not yet supported")); - } - - public String explain() - { - return "Bind #: " + bindIndex_; - } - -}; \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/common/CExpr.java b/src/java/org/apache/cassandra/cql/common/CExpr.java deleted file mode 100644 index fe78a2f356..0000000000 --- a/src/java/org/apache/cassandra/cql/common/CExpr.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -//Note: This class is CQL related work in progress. -public class CExpr -{ - public static interface Expr - { - CType getType(); - String toString(); - }; -} - diff --git a/src/java/org/apache/cassandra/cql/common/CType.java b/src/java/org/apache/cassandra/cql/common/CType.java deleted file mode 100644 index 04de09abe7..0000000000 --- a/src/java/org/apache/cassandra/cql/common/CType.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.cassandra.cql.common; - -import java.util.ArrayList; - -//Note: This class is CQL related work in progress. -public class CType -{ - public static interface Type - { - String toString(); - }; - - public static class IntegerType implements Type - { - public String toString() { return "Integer"; }; - } - - public static class StringType implements Type - { - public String toString() { return "String"; }; - } - - public static class RowType implements Type - { - ArrayList types_; - public RowType(ArrayList types) - { - types_ = types; - } - - public String toString() - { - StringBuilder sb = new StringBuilder("<"); - for (int idx = types_.size(); idx > 0; idx--) - { - sb.append(types_.toString()); - if (idx != 1) - { - sb.append(", "); - } - } - sb.append(">"); - return sb.toString(); - } - } - - public static class ArrayType - { - Type elementType_; - public ArrayType(Type elementType) - { - elementType_ = elementType; - } - - public String toString() - { - return "Array(" + elementType_.toString() + ")"; - } - } -} diff --git a/src/java/org/apache/cassandra/cql/common/ColumnMapExpr.java b/src/java/org/apache/cassandra/cql/common/ColumnMapExpr.java deleted file mode 100644 index 1981c9ed69..0000000000 --- a/src/java/org/apache/cassandra/cql/common/ColumnMapExpr.java +++ /dev/null @@ -1,25 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -import java.util.ArrayList; - -public class ColumnMapExpr extends ArrayList> -{ - private static final long serialVersionUID = 1L; -}; \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/common/ColumnRangeQueryRSD.java b/src/java/org/apache/cassandra/cql/common/ColumnRangeQueryRSD.java deleted file mode 100644 index 0da8c050ae..0000000000 --- a/src/java/org/apache/cassandra/cql/common/ColumnRangeQueryRSD.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.List; -import java.io.UnsupportedEncodingException; - -import org.apache.cassandra.config.CFMetaData; -import org.apache.cassandra.cql.execution.RuntimeErrorMsg; -import org.apache.cassandra.db.*; -import org.apache.cassandra.db.filter.QueryPath; -import org.apache.cassandra.service.ConsistencyLevel; -import org.apache.cassandra.service.StorageProxy; -import org.apache.cassandra.service.StorageService; -import org.apache.cassandra.utils.LogUtil; -import org.apache.log4j.Logger; -import org.apache.commons.lang.ArrayUtils; - -/** - * A Row Source Defintion (RSD) for doing a range query on a column map - * (in Standard or Super Column Family). - */ -public class ColumnRangeQueryRSD extends RowSourceDef -{ - private final static Logger logger_ = Logger.getLogger(ColumnRangeQueryRSD.class); - private CFMetaData cfMetaData_; - private OperandDef rowKey_; - private OperandDef superColumnKey_; - private int limit_; - - /** - * Set up a range query on column map in a simple column family. - * The column map in a simple column family is identified by the rowKey. - * - * Note: "limit" of -1 is the equivalent of no limit. - * "offset" specifies the number of rows to skip. An offset of 0 implies from the first row. - */ - public ColumnRangeQueryRSD(CFMetaData cfMetaData, OperandDef rowKey, int limit) - { - cfMetaData_ = cfMetaData; - rowKey_ = rowKey; - superColumnKey_ = null; - limit_ = limit; - } - - /** - * Setup a range query on a column map in a super column family. - * The column map in a super column family is identified by the rowKey & superColumnKey. - * - * Note: "limit" of -1 is the equivalent of no limit. - * "offset" specifies the number of rows to skip. An offset of 0 implies the first row. - */ - public ColumnRangeQueryRSD(CFMetaData cfMetaData, ConstantOperand rowKey, ConstantOperand superColumnKey, int limit) - { - cfMetaData_ = cfMetaData; - rowKey_ = rowKey; - superColumnKey_ = superColumnKey; - limit_ = limit; - } - - public List> getRows() throws UnsupportedEncodingException - { - QueryPath path; - String superColumnKey = null; - - if (superColumnKey_ != null) - { - superColumnKey = (String)(superColumnKey_.get()); - path = new QueryPath(cfMetaData_.cfName, superColumnKey.getBytes("UTF-8")); - } - else - { - path = new QueryPath(cfMetaData_.cfName); - } - - Row row = null; - try - { - String key = (String)(rowKey_.get()); - ReadCommand readCommand = new SliceFromReadCommand(cfMetaData_.tableName, key, path, ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, limit_); - row = StorageProxy.readProtocol(readCommand, ConsistencyLevel.ONE); - } - catch (Exception e) - { - logger_.error(LogUtil.throwableToString(e)); - throw new RuntimeException(RuntimeErrorMsg.GENERIC_ERROR.getMsg()); - } - - List> rows = new LinkedList>(); - if (row != null) - { - ColumnFamily cfamily = row.getColumnFamily(cfMetaData_.cfName); - if (cfamily != null) - { - Collection columns = null; - if (superColumnKey_ != null) - { - // this is the super column case - IColumn column = cfamily.getColumn(superColumnKey.getBytes("UTF-8")); - if (column != null) - columns = column.getSubColumns(); - } - else - { - columns = cfamily.getSortedColumns(); - } - - if (columns != null && columns.size() > 0) - { - for (IColumn column : columns) - { - Map result = new HashMap(); - - result.put(cfMetaData_.n_columnKey, new String(column.name(), "UTF-8")); - result.put(cfMetaData_.n_columnValue, new String(column.value())); - result.put(cfMetaData_.n_columnTimestamp, Long.toString(column.timestamp())); - - rows.add(result); - } - } - } - } - return rows; - } - - public String explainPlan() - { - return String.format("%s Column Family: Column Range Query: \n" + - " Table Name: %s\n" + - " Column Family: %s\n" + - " RowKey: %s\n" + - "%s" + - " Limit: %d\n" + - " Order By: %s", - cfMetaData_.columnType, - cfMetaData_.tableName, - cfMetaData_.cfName, - rowKey_.explain(), - (superColumnKey_ == null) ? "" : " SuperColumnKey: " + superColumnKey_.explain() + "\n", - limit_, - cfMetaData_.comparator); - } -} \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/common/ConstantOperand.java b/src/java/org/apache/cassandra/cql/common/ConstantOperand.java deleted file mode 100644 index a521f4c5ec..0000000000 --- a/src/java/org/apache/cassandra/cql/common/ConstantOperand.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -/** - * ConstantOperand: - * Represents a literal/constant operand in the CQL statement. - * Lives as part of the shared execution plan. - */ -public class ConstantOperand implements OperandDef -{ - Object value_; - public ConstantOperand(Object value) - { - value_ = value; - } - - public Object get() - { - return value_; - } - - public String explain() - { - return "Constant: '" + value_ + "'"; - } -}; \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/common/CqlResult.java b/src/java/org/apache/cassandra/cql/common/CqlResult.java deleted file mode 100644 index 2908e86ed0..0000000000 --- a/src/java/org/apache/cassandra/cql/common/CqlResult.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.cassandra.cql.common; - -import java.util.List; -import java.util.Map; - -public class CqlResult -{ - public int errorCode; // 0 - success - public String errorTxt; - public List> resultSet; - - public CqlResult(List> rows) - { - resultSet = rows; - errorTxt = null; - errorCode = 0; // success - } - -}; diff --git a/src/java/org/apache/cassandra/cql/common/DMLPlan.java b/src/java/org/apache/cassandra/cql/common/DMLPlan.java deleted file mode 100644 index e364798cea..0000000000 --- a/src/java/org/apache/cassandra/cql/common/DMLPlan.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -/** - * This class represents the execution plan for DML (data manipulation language) - * CQL statements. - */ -public abstract class DMLPlan extends Plan {}; \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/common/ExplainPlan.java b/src/java/org/apache/cassandra/cql/common/ExplainPlan.java deleted file mode 100644 index 4ea4ef1b3f..0000000000 --- a/src/java/org/apache/cassandra/cql/common/ExplainPlan.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -import java.util.*; -import org.apache.log4j.Logger; - -/** - * The "Plan" for the EXPLAIN PLAN statement itself! - * - * It is nothing but a simple wrapper around the "Plan" for the statement - * on which an EXPLAIN PLAN has been requested. - */ -public class ExplainPlan extends Plan -{ - private final static Logger logger_ = Logger.getLogger(ExplainPlan.class); - - // the execution plan for the statement on which an - // EXPLAIN PLAN was requested. - private Plan plan_ = null; - - /** - * Construct an ExplainPlan instance for the statement whose - * "plan" has been passed in. - */ - public ExplainPlan(Plan plan) - { - plan_ = plan; - } - - public CqlResult execute() - { - String planText = plan_.explainPlan(); - - List> rows = new LinkedList>(); - Map row = new HashMap(); - row.put("PLAN", planText); - rows.add(row); - - return new CqlResult(rows); - } - - public String explainPlan() - { - // We never expect this method to get invoked for ExplainPlan instances - // (i.e. those that correspond to the EXPLAIN PLAN statement). - logger_.error("explainPlan() invoked on an ExplainPlan instance"); - return null; - } -} \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/common/OperandDef.java b/src/java/org/apache/cassandra/cql/common/OperandDef.java deleted file mode 100644 index 31ccb83638..0000000000 --- a/src/java/org/apache/cassandra/cql/common/OperandDef.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -/** - * OperandDef: - * - * The abstract definition of an operand (i.e. data item) in - * CQL compiler/runtime. Examples, include a Constant operand - * or a Bind operand. This is the part of an operand definition - * that lives in the share-able execution plan. - */ -public abstract interface OperandDef -{ - public abstract Object get(); - public abstract String explain(); -}; \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/common/Pair.java b/src/java/org/apache/cassandra/cql/common/Pair.java deleted file mode 100644 index 59523bbdad..0000000000 --- a/src/java/org/apache/cassandra/cql/common/Pair.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -/* Would have expected java.util.* to have this class! - * Code cut-paste from wikipedia. - */ - -/** - * Generic for representing a "typed" 2-tuple. - */ -public class Pair -{ - public Pair(T f, S s) - { - first = f; - second = s; - } - - public T getFirst() - { - return first; - } - - public S getSecond() - { - return second; - } - - public String toString() - { - return "(" + first.toString() + ", " + second.toString() + ")"; - } - - private T first; - private S second; -} diff --git a/src/java/org/apache/cassandra/cql/common/Plan.java b/src/java/org/apache/cassandra/cql/common/Plan.java deleted file mode 100644 index a846f04cef..0000000000 --- a/src/java/org/apache/cassandra/cql/common/Plan.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -import java.io.UnsupportedEncodingException; - -/** - * Abstract class representing the shared execution plan for a CQL - * statement (query or DML operation). - * - */ -public abstract class Plan -{ - public abstract CqlResult execute() throws UnsupportedEncodingException; - public abstract String explainPlan(); -} diff --git a/src/java/org/apache/cassandra/cql/common/QueryPlan.java b/src/java/org/apache/cassandra/cql/common/QueryPlan.java deleted file mode 100644 index df399c0af0..0000000000 --- a/src/java/org/apache/cassandra/cql/common/QueryPlan.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -import java.io.UnsupportedEncodingException; - -import org.apache.log4j.Logger; - -/** - * This class represents the execution plan for Query (data retrieval) statement. - */ -public class QueryPlan extends Plan -{ - private final static Logger logger_ = Logger.getLogger(QueryPlan.class); - - public RowSourceDef root; // the root of the row source tree - - public QueryPlan(RowSourceDef rwsDef) - { - root = rwsDef; - } - - public CqlResult execute() - { - if (root != null) - { - try - { - return new CqlResult(root.getRows()); - } - catch (UnsupportedEncodingException e) - { - throw new RuntimeException(e); - } - } - else - logger_.error("No rowsource to execute"); - return null; - } - - public String explainPlan() - { - return root.explainPlan(); - } - -} diff --git a/src/java/org/apache/cassandra/cql/common/RowSourceDef.java b/src/java/org/apache/cassandra/cql/common/RowSourceDef.java deleted file mode 100644 index 4235986d3d..0000000000 --- a/src/java/org/apache/cassandra/cql/common/RowSourceDef.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -import java.util.List; -import java.util.Map; -import java.io.UnsupportedEncodingException; - -/** - * The abstract notion of a row source definition. A row source - * is literally just anything that returns rows back. - * - * The concrete implementations of row source might be things like a - * column family row source, a "super column family" row source, - * a table row source, etc. - * - * Note: Instances of sub-classes of this class are part of the "shared" - * execution plan of CQL. And hence they should not contain any mutable - * (i.e. session specific) execution state. Mutable state, such a bind - * variable values (corresponding to say a rowKey or a column Key) are - * note part of the RowSourceDef tree. - * - * [Eventually the notion of a "mutable" portion of the RowSource (RowSourceMut) - * will be introduced to hold session-specific execution state of the RowSource. - * For example, this would be needed when implementing iterator style rowsources - * that yields rows back one at a time as opposed to returning them in one - * shot.] - */ -public abstract class RowSourceDef -{ - public abstract List> getRows() throws UnsupportedEncodingException; - public abstract String explainPlan(); -} \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/common/SetColumnMap.java b/src/java/org/apache/cassandra/cql/common/SetColumnMap.java deleted file mode 100644 index 90b0b2ecf0..0000000000 --- a/src/java/org/apache/cassandra/cql/common/SetColumnMap.java +++ /dev/null @@ -1,133 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -import org.apache.cassandra.config.CFMetaData; -import org.apache.cassandra.cql.execution.RuntimeErrorMsg; -import org.apache.cassandra.db.RowMutation; -import org.apache.cassandra.service.StorageProxy; -import org.apache.cassandra.utils.LogUtil; -import org.apache.log4j.Logger; -import org.apache.cassandra.cql.execution.*; -import org.apache.cassandra.db.*; -import org.apache.cassandra.db.filter.QueryPath; -import org.apache.cassandra.service.*; - -/** - * Execution plan for batch setting a set of columns in a Simple/Super column family. - * SET table.standard_cf[] = ; - * SET table.super_cf[][] = ; - */ -public class SetColumnMap extends DMLPlan -{ - private final static Logger logger_ = Logger.getLogger(SetUniqueKey.class); - private CFMetaData cfMetaData_; - private OperandDef rowKey_; - private OperandDef superColumnKey_; - private ColumnMapExpr columnMapExpr_; - - /** - * construct an execution plan node to set the column map for a Standard Column Family. - * - * SET table.standard_cf[] = ; - */ - public SetColumnMap(CFMetaData cfMetaData, OperandDef rowKey, ColumnMapExpr columnMapExpr) - { - cfMetaData_ = cfMetaData; - rowKey_ = rowKey; - superColumnKey_ = null; - columnMapExpr_ = columnMapExpr; - } - - /** - * Construct an execution plan node to set the column map for a Super Column Family - * - * SET table.super_cf[][] = ; - */ - public SetColumnMap(CFMetaData cfMetaData, OperandDef rowKey, OperandDef superColumnKey, ColumnMapExpr columnMapExpr) - { - cfMetaData_ = cfMetaData; - rowKey_ = rowKey; - superColumnKey_ = superColumnKey; - columnMapExpr_ = columnMapExpr; - } - - public CqlResult execute() - { - try - { - RowMutation rm = new RowMutation(cfMetaData_.tableName, (String)(rowKey_.get())); - long time = System.currentTimeMillis(); - - for (Pair entry : columnMapExpr_) - { - OperandDef columnKey = entry.getFirst(); - OperandDef value = entry.getSecond(); - - QueryPath path; - if (superColumnKey_ != null) - { - String superColumnKey = (String)(superColumnKey_.get()); - path = new QueryPath(cfMetaData_.cfName, superColumnKey.getBytes("UTF-8"), ((String)columnKey.get()).getBytes("UTF-8")); - } - else - { - path = new QueryPath(cfMetaData_.cfName, null, ((String)columnKey.get()).getBytes("UTF-8")); - } - - rm.add(path, ((String)value.get()).getBytes(), time); - } - StorageProxy.insert(rm); - } - catch (Exception e) - { - logger_.error(LogUtil.throwableToString(e)); - throw new RuntimeException(RuntimeErrorMsg.GENERIC_ERROR.getMsg()); - } - return null; - } - - public String explainPlan() - { - StringBuilder sb = new StringBuilder(); - - String prefix = - String.format("%s Column Family: Batch SET a set of columns: \n" + - " Table Name: %s\n" + - " Column Famly: %s\n" + - " RowKey: %s\n" + - "%s", - cfMetaData_.columnType, - cfMetaData_.tableName, - cfMetaData_.cfName, - rowKey_.explain(), - (superColumnKey_ == null) ? "" : " SuperColumnKey: " + superColumnKey_.explain() + "\n"); - - for (Pair entry : columnMapExpr_) - { - OperandDef columnKey = entry.getFirst(); - OperandDef value = entry.getSecond(); - sb.append(String.format(" ColumnKey: %s\n" + - " Value: %s\n", - columnKey.explain(), value.explain())); - } - - return prefix + sb.toString(); - } -} \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/common/SetSuperColumnMap.java b/src/java/org/apache/cassandra/cql/common/SetSuperColumnMap.java deleted file mode 100644 index 7c29f9b75d..0000000000 --- a/src/java/org/apache/cassandra/cql/common/SetSuperColumnMap.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -import org.apache.cassandra.config.CFMetaData; -import org.apache.cassandra.cql.execution.RuntimeErrorMsg; -import org.apache.cassandra.db.RowMutation; -import org.apache.cassandra.db.filter.QueryPath; -import org.apache.cassandra.service.StorageProxy; -import org.apache.cassandra.utils.LogUtil; -import org.apache.log4j.Logger; -import org.apache.cassandra.cql.execution.*; - -/** - * Execution plan for batch setting a set of super columns in a Super column family. - * SET table.super_cf[] = ; - */ -public class SetSuperColumnMap extends DMLPlan -{ - private final static Logger logger_ = Logger.getLogger(SetUniqueKey.class); - private CFMetaData cfMetaData_; - private OperandDef rowKey_; - private SuperColumnMapExpr superColumnMapExpr_; - - /** - * construct an execution plan node to batch set a bunch of super columns in a - * super column family. - * - * SET table.super_cf[] = ; - */ - public SetSuperColumnMap(CFMetaData cfMetaData, OperandDef rowKey, SuperColumnMapExpr superColumnMapExpr) - { - cfMetaData_ = cfMetaData; - rowKey_ = rowKey; - superColumnMapExpr_ = superColumnMapExpr; - } - - public CqlResult execute() - { - try - { - RowMutation rm = new RowMutation(cfMetaData_.tableName, (String)(rowKey_.get())); - long time = System.currentTimeMillis(); - - for (Pair superColumn : superColumnMapExpr_) - { - OperandDef superColumnKey = superColumn.getFirst(); - ColumnMapExpr columnMapExpr = superColumn.getSecond(); - - for (Pair entry : columnMapExpr) - { - OperandDef columnKey = entry.getFirst(); - OperandDef value = entry.getSecond(); - QueryPath path = new QueryPath(cfMetaData_.cfName, ((String)(superColumnKey.get())).getBytes("UTF-8"), ((String)(columnKey.get())).getBytes("UTF-8")); - rm.add(path, ((String)value.get()).getBytes(), time); - } - } - StorageProxy.insert(rm); - } - catch (Exception e) - { - logger_.error(LogUtil.throwableToString(e)); - throw new RuntimeException(RuntimeErrorMsg.GENERIC_ERROR.getMsg()); - } - return null; - - } - - public String explainPlan() - { - StringBuilder sb = new StringBuilder(); - - String prefix = - String.format("%s Column Family: Batch SET a set of Super Columns: \n" + - " Table Name: %s\n" + - " Column Famly: %s\n" + - " RowKey: %s\n", - cfMetaData_.columnType, - cfMetaData_.tableName, - cfMetaData_.cfName, - rowKey_.explain()); - - for (Pair superColumn : superColumnMapExpr_) - { - OperandDef superColumnKey = superColumn.getFirst(); - ColumnMapExpr columnMapExpr = superColumn.getSecond(); - - for (Pair entry : columnMapExpr) - { - OperandDef columnKey = entry.getFirst(); - OperandDef value = entry.getSecond(); - sb.append(String.format(" SuperColumnKey: %s\n" + - " ColumnKey: %s\n" + - " Value: %s\n", - superColumnKey.explain(), - columnKey.explain(), - value.explain())); - } - } - - return prefix + sb.toString(); - } -} \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/common/SetUniqueKey.java b/src/java/org/apache/cassandra/cql/common/SetUniqueKey.java deleted file mode 100644 index dafd32b57c..0000000000 --- a/src/java/org/apache/cassandra/cql/common/SetUniqueKey.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -import java.io.UnsupportedEncodingException; - -import org.apache.cassandra.config.CFMetaData; -import org.apache.cassandra.cql.execution.RuntimeErrorMsg; -import org.apache.cassandra.db.RowMutation; -import org.apache.cassandra.db.filter.QueryPath; -import org.apache.cassandra.service.StorageProxy; -import org.apache.cassandra.utils.LogUtil; -import org.apache.log4j.Logger; - - -/** - * Execution plan for setting a specific column in a Simple/Super column family. - * SET table.standard_cf[][] = ; - * SET table.super_cf[][][] = ; - */ -public class SetUniqueKey extends DMLPlan -{ - private final static Logger logger_ = Logger.getLogger(SetUniqueKey.class); - private CFMetaData cfMetaData_; - private OperandDef rowKey_; - private OperandDef superColumnKey_; - private OperandDef columnKey_; - private OperandDef value_; - - /** - * Construct an execution plan for setting a column in a simple column family - * - * SET table.standard_cf[][] = ; - */ - public SetUniqueKey(CFMetaData cfMetaData, OperandDef rowKey, OperandDef columnKey, OperandDef value) - { - cfMetaData_ = cfMetaData; - rowKey_ = rowKey; - columnKey_ = columnKey; - superColumnKey_ = null; - value_ = value; - } - - /** - * Construct execution plan for setting a column in a super column family. - * - * SET table.super_cf[][][] = ; - */ - public SetUniqueKey(CFMetaData cfMetaData, OperandDef rowKey, OperandDef superColumnKey, OperandDef columnKey, OperandDef value) - { - cfMetaData_ = cfMetaData; - rowKey_ = rowKey; - superColumnKey_ = superColumnKey; - columnKey_ = columnKey; - value_ = value; - } - - public CqlResult execute() throws UnsupportedEncodingException - { - String columnKey = (String)(columnKey_.get()); - QueryPath path; - - if (superColumnKey_ != null) - { - String superColumnKey = (String)(superColumnKey_.get()); - path = new QueryPath(cfMetaData_.cfName, superColumnKey.getBytes("UTF-8"), columnKey.getBytes("UTF-8")); - } - else - { - path = new QueryPath(cfMetaData_.cfName, null, columnKey.getBytes("UTF-8")); - } - - try - { - RowMutation rm = new RowMutation(cfMetaData_.tableName, (String)(rowKey_.get())); - rm.add(path, ((String)value_.get()).getBytes(), System.currentTimeMillis()); - StorageProxy.insert(rm); - } - catch (Exception e) - { - logger_.error(LogUtil.throwableToString(e)); - throw new RuntimeException(RuntimeErrorMsg.GENERIC_ERROR.getMsg()); - } - return null; - } - - public String explainPlan() - { - return - String.format("%s Column Family: Unique Key SET: \n" + - " Table Name: %s\n" + - " Column Famly: %s\n" + - " RowKey: %s\n" + - "%s" + - " ColumnKey: %s\n" + - " Value: %s\n", - cfMetaData_.columnType, - cfMetaData_.tableName, - cfMetaData_.cfName, - rowKey_.explain(), - (superColumnKey_ == null) ? "" : " SuperColumnKey: " + superColumnKey_.explain() + "\n", - columnKey_.explain(), - value_.explain()); - } -} \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/common/SuperColumnMapExpr.java b/src/java/org/apache/cassandra/cql/common/SuperColumnMapExpr.java deleted file mode 100644 index b3427eca90..0000000000 --- a/src/java/org/apache/cassandra/cql/common/SuperColumnMapExpr.java +++ /dev/null @@ -1,25 +0,0 @@ -/* Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -import java.util.ArrayList; - -public class SuperColumnMapExpr extends ArrayList> -{ - private static final long serialVersionUID = 1L; -}; \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/common/SuperColumnRangeQueryRSD.java b/src/java/org/apache/cassandra/cql/common/SuperColumnRangeQueryRSD.java deleted file mode 100644 index b053cb4b6b..0000000000 --- a/src/java/org/apache/cassandra/cql/common/SuperColumnRangeQueryRSD.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.List; -import java.io.UnsupportedEncodingException; - -import org.apache.cassandra.config.CFMetaData; -import org.apache.cassandra.cql.execution.RuntimeErrorMsg; -import org.apache.cassandra.db.*; -import org.apache.cassandra.db.filter.QueryPath; -import org.apache.cassandra.service.ConsistencyLevel; -import org.apache.cassandra.service.StorageProxy; -import org.apache.cassandra.service.StorageService; -import org.apache.cassandra.utils.LogUtil; -import org.apache.log4j.Logger; -import org.apache.commons.lang.ArrayUtils; - -/** - * A Row Source Definition (RSD) for doing a super column range query on a Super Column Family. - */ -public class SuperColumnRangeQueryRSD extends RowSourceDef -{ - private final static Logger logger_ = Logger.getLogger(SuperColumnRangeQueryRSD.class); - private CFMetaData cfMetaData_; - private OperandDef rowKey_; - private int limit_; - - /** - * Set up a range query on super column map in a super column family. - * The super column map is identified by the rowKey. - * - * Note: "limit" of -1 is the equivalent of no limit. - * "offset" specifies the number of rows to skip. - * An offset of 0 implies from the first row. - */ - public SuperColumnRangeQueryRSD(CFMetaData cfMetaData, OperandDef rowKey, int limit) - { - cfMetaData_ = cfMetaData; - rowKey_ = rowKey; - limit_ = limit; - } - - public List> getRows() throws UnsupportedEncodingException - { - Row row = null; - try - { - String key = (String)(rowKey_.get()); - ReadCommand readCommand = new SliceFromReadCommand(cfMetaData_.tableName, key, new QueryPath(cfMetaData_.cfName), ArrayUtils.EMPTY_BYTE_ARRAY, ArrayUtils.EMPTY_BYTE_ARRAY, true, limit_); - row = StorageProxy.readProtocol(readCommand, ConsistencyLevel.ONE); - } - catch (Exception e) - { - logger_.error(LogUtil.throwableToString(e)); - throw new RuntimeException(RuntimeErrorMsg.GENERIC_ERROR.getMsg()); - } - - List> rows = new LinkedList>(); - if (row != null) - { - ColumnFamily cfamily = row.getColumnFamily(cfMetaData_.cfName); - if (cfamily != null) - { - Collection columns = cfamily.getSortedColumns(); - if (columns != null && columns.size() > 0) - { - for (IColumn column : columns) - { - Collection subColumns = column.getSubColumns(); - for( IColumn subColumn : subColumns ) - { - Map result = new HashMap(); - result.put(cfMetaData_.n_superColumnKey, new String(column.name(), "UTF-8")); - result.put(cfMetaData_.n_columnKey, new String(subColumn.name(), "UTF-8")); - result.put(cfMetaData_.n_columnValue, new String(subColumn.value())); - result.put(cfMetaData_.n_columnTimestamp, Long.toString(subColumn.timestamp())); - rows.add(result); - } - } - } - } - } - return rows; - } - - public String explainPlan() - { - return String.format("%s Column Family: Super Column Range Query: \n" + - " Table Name: %s\n" + - " Column Family: %s\n" + - " RowKey: %s\n" + - " Limit: %d\n" + - " Order By: %s", - cfMetaData_.columnType, - cfMetaData_.tableName, - cfMetaData_.cfName, - rowKey_.explain(), - limit_, - cfMetaData_.comparator); - } -} \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/common/UniqueKeyQueryRSD.java b/src/java/org/apache/cassandra/cql/common/UniqueKeyQueryRSD.java deleted file mode 100644 index f1b3cdd673..0000000000 --- a/src/java/org/apache/cassandra/cql/common/UniqueKeyQueryRSD.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -import java.util.*; -import java.io.UnsupportedEncodingException; - -import org.apache.cassandra.config.CFMetaData; -import org.apache.cassandra.cql.execution.RuntimeErrorMsg; -import org.apache.cassandra.db.*; -import org.apache.cassandra.db.filter.QueryPath; -import org.apache.cassandra.service.ConsistencyLevel; -import org.apache.cassandra.service.StorageProxy; -import org.apache.cassandra.service.StorageService; -import org.apache.cassandra.utils.LogUtil; -import org.apache.log4j.Logger; - -/** - * A Row Source Defintion (RSD) for looking up a unique column within a column family. - */ -public class UniqueKeyQueryRSD extends RowSourceDef -{ - private final static Logger logger_ = Logger.getLogger(UniqueKeyQueryRSD.class); - private CFMetaData cfMetaData_; - private OperandDef rowKey_; - private OperandDef superColumnKey_; - private OperandDef columnKey_; - - // super column family - public UniqueKeyQueryRSD(CFMetaData cfMetaData, OperandDef rowKey, OperandDef superColumnKey, OperandDef columnKey) - { - cfMetaData_ = cfMetaData; - rowKey_ = rowKey; - superColumnKey_ = superColumnKey; - columnKey_ = columnKey; - } - - // simple column family - public UniqueKeyQueryRSD(CFMetaData cfMetaData, OperandDef rowKey, OperandDef columnKey) - { - cfMetaData_ = cfMetaData; - rowKey_ = rowKey; - columnKey_ = columnKey; - superColumnKey_ = null; - } - - // specific column lookup - public List> getRows() throws UnsupportedEncodingException - { - String columnKey = (String)(columnKey_.get()); - QueryPath path = null; - String superColumnKey = null; - - if (superColumnKey_ != null) - { - superColumnKey = (String)(superColumnKey_.get()); - path = new QueryPath(cfMetaData_.cfName, superColumnKey.getBytes("UTF-8")); - } - else - { - path = new QueryPath(cfMetaData_.cfName); - } - - Row row = null; - try - { - String key = (String)(rowKey_.get()); - ReadCommand readCommand = new SliceByNamesReadCommand(cfMetaData_.tableName, key, path, Arrays.asList(columnKey.getBytes("UTF-8"))); - row = StorageProxy.readProtocol(readCommand, ConsistencyLevel.ONE); - } - catch (Exception e) - { - logger_.error(LogUtil.throwableToString(e)); - throw new RuntimeException(RuntimeErrorMsg.GENERIC_ERROR.getMsg()); - } - - if (row != null) - { - ColumnFamily cfamily = row.getColumnFamily(cfMetaData_.cfName); - if (cfamily != null) - { - Collection columns = null; - if (superColumnKey_ != null) - { - // this is the super column case - IColumn column = cfamily.getColumn(superColumnKey.getBytes("UTF-8")); - if (column != null) - columns = column.getSubColumns(); - } - else - { - columns = cfamily.getSortedColumns(); - } - - if (columns != null && columns.size() > 0) - { - if (columns.size() > 1) - { - // We are looking up by a rowKey & columnKey. There should - // be at most one column that matches. If we find more than - // one, then it is an internal error. - throw new RuntimeException(RuntimeErrorMsg.INTERNAL_ERROR.getMsg("Too many columns found for: " + columnKey)); - } - for (IColumn column : columns) - { - List> rows = new LinkedList>(); - - Map result = new HashMap(); - result.put(cfMetaData_.n_columnKey, new String(column.name(), "UTF-8")); - result.put(cfMetaData_.n_columnValue, new String(column.value())); - result.put(cfMetaData_.n_columnTimestamp, Long.toString(column.timestamp())); - - rows.add(result); - - // at this point, due to the prior checks, we are guaranteed that - // there is only one item in "columns". - return rows; - } - return null; - } - } - } - throw new RuntimeException(RuntimeErrorMsg.NO_DATA_FOUND.getMsg()); - } - - public String explainPlan() - { - return String.format("%s Column Family: Unique Key Query: \n" + - " Table Name: %s\n" + - " Column Famly: %s\n" + - " RowKey: %s\n" + - "%s" + - " ColumnKey: %s", - cfMetaData_.columnType, - cfMetaData_.tableName, - cfMetaData_.cfName, - rowKey_.explain(), - (superColumnKey_ == null) ? "" : " SuperColumnKey: " + superColumnKey_.explain() + "\n", - columnKey_.explain()); - } -} \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/common/Utils.java b/src/java/org/apache/cassandra/cql/common/Utils.java deleted file mode 100644 index e030d84e68..0000000000 --- a/src/java/org/apache/cassandra/cql/common/Utils.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.common; - -public class Utils -{ - /* - * Strips leading and trailing "'" characters, and handles - * and escaped characters such as \n, \r, etc. - * [Shameless clone from hive.] - */ - public static String unescapeSQLString(String b) - { - assert(b.charAt(0) == '\''); - assert(b.charAt(b.length()-1) == '\''); - StringBuilder sb = new StringBuilder(b.length()); - - for (int i=1; i+1 errors; - - public CqlParserX(TokenStream input) - { - super(input); - errors = new ArrayList(); - } - - protected void mismatch(IntStream input, int ttype, BitSet follow) throws RecognitionException - { - throw new MismatchedTokenException(ttype, input); - } - - public Object recoverFromMismatchedSet(IntStream input, - RecognitionException re, - BitSet follow) throws RecognitionException - { - throw re; - } - - public void displayRecognitionError(String[] tokenNames, - RecognitionException e) - { - errors.add(new ParseError(this, e, tokenNames)); - } - - public ArrayList getErrors() - { - return errors; - } - } - - // Compile a CQL query - public Plan compileQuery(String query) throws ParseException, SemanticException - { - CommonTree queryTree = null; - CqlLexer lexer = null; - CqlParserX parser = null; - CommonTokenStream tokens = null; - - ANTLRStringStream input = new ANTLRNoCaseStringStream(query); - - lexer = new CqlLexer(input); - tokens = new CommonTokenStream(lexer); - parser = new CqlParserX(tokens); - - // built AST - try - { - queryTree = (CommonTree)(parser.root().getTree()); - } - catch (RecognitionException e) - { - throw new ParseException(parser.getErrors()); - } - catch (RewriteEmptyStreamException e) - { - throw new ParseException(parser.getErrors()); - } - - if (!parser.getErrors().isEmpty()) - { - throw new ParseException(parser.getErrors()); - } - - if (!parser.errors.isEmpty()) - { - throw new ParseException("parser error"); - } - - // Semantic analysis and code-gen. - // Eventually, I anticipate, I'll be forking these off into two separate phases. - return SemanticPhase.doSemanticAnalysis(queryTree); - } -} diff --git a/src/java/org/apache/cassandra/cql/compiler/parse/Cql.g b/src/java/org/apache/cassandra/cql/compiler/parse/Cql.g deleted file mode 100644 index 59ab1f83e5..0000000000 --- a/src/java/org/apache/cassandra/cql/compiler/parse/Cql.g +++ /dev/null @@ -1,308 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// ANTLR Grammar Definition for Cassandra Query Language (CQL) -// -// CQL is a query language tailored for Cassandra's multi-level (or -// nested-table like) data model where values stored for each key -// can be: -// -// * a simple column map (a 1-level nested table). This is the case -// for a simple column family. -// -// or, -// -// * a supercolumn column map, which in turn contains a column map -// per super column (i.e. a 2-level nested table). This is the case -// for a super column family. -// -// For the common case of key-based data retrieval or storage, CQL -// provides array like get/set syntax, such as: -// -// SET user.profile['99']['name'] = 'joe'; -// SET user.profile['99']['age'] = '27'; -// GET user.profile['99']['name']; -// GET user.profile['99']; -// -// When additional constraints need to be applied to data being retrieved -// (such as imposing row limits, retrieving counts, retrieving data for -// a subset of super columns or columns and son on) CQL falls back to more -// traditional SQL-like syntax. -// -// *Note*: The SQL syntax supported by CQL doesn't support the full -// relational algebra. For example, it doesn't have any support for -// joins. It also imposes restrictions on the types of filters and ORDER -// BY clauses it supports-- generally only those queries that can be -// efficiently answered based on data layout are supported. Suppose a column -// family has been configured to store columns in time sorted fashion, -// CQL will not support 'ORDER BY column_name' for such a column family. -// - - -// -// NOTE: The grammar is in a very rudimentary/prototypish shape right now. -// Will undergo fairly big restructuring in the next checkin. -// - -grammar Cql; - -options { - output=AST; - ASTLabelType=CommonTree; - backtrack=true; -} - -// -// AST Nodes. We use a A_ prefix convention for these AST node names. -// -tokens { - - // Top-level AST nodes - // These typically correspond to various top-level CQL statements. - A_DELETE; - A_GET; - A_SELECT; - A_SET; - A_EXPLAIN_PLAN; - - // Internal AST nodes - A_COLUMN_ACCESS; - A_COLUMN_MAP_ENTRY; - A_COLUMN_MAP_VALUE; - A_FROM; - A_KEY_IN_LIST; - A_KEY_EXACT_MATCH; - A_LIMIT; - A_OFFSET; - A_ORDER_BY; - A_SUPERCOLUMN_MAP_ENTRY; - A_SUPERCOLUMN_MAP_VALUE; - A_SELECT_CLAUSE; - A_WHERE; -} - -@parser::header { - package org.apache.cassandra.cql.compiler.parse; - } - -@lexer::header { - package org.apache.cassandra.cql.compiler.parse; - } - -// -// Parser Section -// - -// the root node -root - : stmt SEMICOLON? EOF -> stmt - | K_EXPLAIN K_PLAN stmt SEMICOLON? EOF -> ^(A_EXPLAIN_PLAN stmt) - ; - -stmt - : deleteStmt - | getStmt - | selectStmt - | setStmt - ; - -getStmt - : K_GET columnSpec -> ^(A_GET columnSpec) - ; - -setStmt - : K_SET columnSpec '=' valueExpr -> ^(A_SET columnSpec valueExpr) - ; - -selectStmt - : selectClause - fromClause? - whereClause? - limitClause? -> ^(A_SELECT selectClause fromClause? whereClause? limitClause?) - ; - -selectClause - : K_SELECT selectList -> ^(A_SELECT_CLAUSE selectList) - ; - -selectList - : selectListItem (',' selectListItem)* - ; - -selectListItem - : columnExpression - | '(' selectStmt ')' -> ^(A_SELECT selectStmt) - ; - -columnExpression - : columnOrSuperColumnName columnExpressionRest; - -columnExpressionRest - : /* empty */ - | '[' stringVal ']' columnExpressionRest - ; - -tableExpression - : tableName '.' columnFamilyName '[' stringVal ']'; - -fromClause - : K_FROM tableExpression -> ^(A_FROM tableExpression) - ; - -whereClause - : K_WHERE keyInClause -> ^(A_WHERE keyInClause) - | K_WHERE keyExactMatch -> ^(A_WHERE keyExactMatch) - ; - -keyInClause - : columnOrSuperColumnName K_IN '(' a+=stringVal (',' a+=stringVal)* ')' - -> ^(A_KEY_IN_LIST columnOrSuperColumnName $a+) - ; - -keyExactMatch - : columnOrSuperColumnName '=' stringVal - -> ^(A_KEY_EXACT_MATCH columnOrSuperColumnName stringVal) - ; - -limitClause - : K_LIMIT IntegerLiteral -> ^(A_LIMIT IntegerLiteral); - -deleteStmt - : K_DELETE columnSpec -> ^(A_DELETE columnSpec) - ; - -columnSpec - : tableName '.' columnFamilyName '[' rowKey ']' - ( '[' a+=columnOrSuperColumnKey ']' - ('[' a+=columnOrSuperColumnKey ']')? - )? - -> ^(A_COLUMN_ACCESS tableName columnFamilyName rowKey ($a+)?) - ; - -tableName: Identifier; - -columnFamilyName: Identifier; - -valueExpr - : cellValue - | columnMapValue - | superColumnMapValue - ; - -cellValue - : stringVal; - -columnMapValue - : LEFT_BRACE columnMapEntry (COMMA columnMapEntry)* RIGHT_BRACE - -> ^(A_COLUMN_MAP_VALUE columnMapEntry+) - ; - -superColumnMapValue - : LEFT_BRACE superColumnMapEntry (COMMA superColumnMapEntry)* RIGHT_BRACE - -> ^(A_SUPERCOLUMN_MAP_VALUE superColumnMapEntry+) - ; - -columnMapEntry - : columnKey ASSOC cellValue -> ^(A_COLUMN_MAP_ENTRY columnKey cellValue) - ; - -superColumnMapEntry - : superColumnKey ASSOC columnMapValue -> ^(A_SUPERCOLUMN_MAP_ENTRY superColumnKey columnMapValue) - ; - -columnOrSuperColumnName: Identifier; - -rowKey: stringVal; -columnOrSuperColumnKey: stringVal; -columnKey: stringVal; -superColumnKey: stringVal; - -// String Values can either be query params (aka bind variables) -// or string literals. -stringVal - : '?' // bind variable - | StringLiteral // - ; - -// -// Lexer Section -// - -// Keywords (in alphabetical order for convenience) -K_BY: 'BY'; -K_DELETE: 'DELETE'; -K_EXPLAIN: 'EXPLAIN'; -K_FROM: 'FROM'; -K_GET: 'GET'; -K_IN: 'IN'; -K_LIMIT: 'LIMIT'; -K_OFFSET: 'OFFSET'; -K_ORDER: 'ORDER'; -K_PLAN: 'PLAN'; -K_SELECT: 'SELECT'; -K_SET: 'SET'; -K_WHERE: 'WHERE'; - -// private syntactic rules -fragment -Letter - : 'a'..'z' - | 'A'..'Z' - ; - -fragment -Digit - : '0'..'9' - ; - -// syntactic Elements -Identifier - : Letter ( Letter | Digit | '_')* - ; - -// -// Literals -// - -// strings: escape single quote ' by repeating it '' (SQL style) -StringLiteral - : '\'' (~'\'')* '\'' ( '\'' (~'\'')* '\'' )* - ; - -// integer literals -IntegerLiteral - : Digit+ - ; - -// -// miscellaneous syntactic elements -// -WS - : (' '|'\r'|'\t'|'\n') {skip();} // whitepace - ; - -COMMENT - : '--' (~('\n'|'\r'))* { $channel=HIDDEN; } - | '/*' (options {greedy=false;} : .)* '*/' { $channel=HIDDEN; } - ; - -ASSOC: '=>'; -COMMA: ','; -LEFT_BRACE: '{'; -RIGHT_BRACE: '}'; -SEMICOLON: ';'; diff --git a/src/java/org/apache/cassandra/cql/compiler/parse/ParseError.java b/src/java/org/apache/cassandra/cql/compiler/parse/ParseError.java deleted file mode 100644 index d5baa642f6..0000000000 --- a/src/java/org/apache/cassandra/cql/compiler/parse/ParseError.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.compiler.parse; - -import org.antlr.runtime.*; - -public class ParseError { - private BaseRecognizer br; - private RecognitionException re; - private String[] tokenNames; - - public ParseError(BaseRecognizer br, RecognitionException re, String[] tokenNames) { - this.br = br; - this.re = re; - this.tokenNames = tokenNames; - } - - public BaseRecognizer getBaseRecognizer() { - return br; - } - - public RecognitionException getRecognitionException() { - return re; - } - - public String[] getTokenNames() { - return tokenNames; - } - - public String getMessage() { - return br.getErrorHeader(re) + " " + br.getErrorMessage(re, tokenNames); - } - -} diff --git a/src/java/org/apache/cassandra/cql/compiler/parse/ParseException.java b/src/java/org/apache/cassandra/cql/compiler/parse/ParseException.java deleted file mode 100644 index d89ce28d01..0000000000 --- a/src/java/org/apache/cassandra/cql/compiler/parse/ParseException.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.compiler.parse; - -/** - * Exception from the CQL Parser - */ - -import java.util.ArrayList; - -public class ParseException extends Exception { - - private static final long serialVersionUID = 1L; - ArrayList errors = null; - - public ParseException(ArrayList errors) - { - super(); - this.errors = errors; - } - - public ParseException(String message) - { - super(message); - } - - public String getMessage() { - - if (errors == null) - return super.getMessage(); - - StringBuilder sb = new StringBuilder(); - for(ParseError err: errors) { - sb.append(err.getMessage()); - sb.append("\n"); - } - - return sb.toString(); - } - -} diff --git a/src/java/org/apache/cassandra/cql/compiler/sem/SemanticException.java b/src/java/org/apache/cassandra/cql/compiler/sem/SemanticException.java deleted file mode 100644 index 72a17f6474..0000000000 --- a/src/java/org/apache/cassandra/cql/compiler/sem/SemanticException.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.compiler.sem; - - -/** - * Exception from the CQL SemanticAnalyzer - */ - -public class SemanticException extends Exception -{ - private static final long serialVersionUID = 1L; - - public SemanticException() - { - super(); - } - - public SemanticException(String message) - { - super(message); - } - - public SemanticException(Throwable cause) - { - super(cause); - } - - public SemanticException(String message, Throwable cause) - { - super(message, cause); - } -} diff --git a/src/java/org/apache/cassandra/cql/compiler/sem/SemanticPhase.java b/src/java/org/apache/cassandra/cql/compiler/sem/SemanticPhase.java deleted file mode 100644 index dc9479f05b..0000000000 --- a/src/java/org/apache/cassandra/cql/compiler/sem/SemanticPhase.java +++ /dev/null @@ -1,343 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.cassandra.cql.compiler.sem; - -import java.util.Map; - -import org.antlr.runtime.tree.CommonTree; - -import org.apache.cassandra.cql.common.*; -import org.apache.cassandra.cql.compiler.common.*; -import org.apache.cassandra.cql.compiler.parse.*; - -import org.apache.cassandra.config.CFMetaData; -import org.apache.cassandra.config.DatabaseDescriptor; -import org.apache.cassandra.cql.common.ColumnMapExpr; -import org.apache.cassandra.cql.common.ColumnRangeQueryRSD; -import org.apache.cassandra.cql.common.ConstantOperand; -import org.apache.cassandra.cql.common.ExplainPlan; -import org.apache.cassandra.cql.common.OperandDef; -import org.apache.cassandra.cql.common.Pair; -import org.apache.cassandra.cql.common.Plan; -import org.apache.cassandra.cql.common.QueryPlan; -import org.apache.cassandra.cql.common.RowSourceDef; -import org.apache.cassandra.cql.common.SetColumnMap; -import org.apache.cassandra.cql.common.SetSuperColumnMap; -import org.apache.cassandra.cql.common.SetUniqueKey; -import org.apache.cassandra.cql.common.SuperColumnMapExpr; -import org.apache.cassandra.cql.common.SuperColumnRangeQueryRSD; -import org.apache.cassandra.cql.common.UniqueKeyQueryRSD; -import org.apache.cassandra.cql.common.Utils; -import org.apache.cassandra.cql.compiler.common.CompilerErrorMsg; -import org.apache.cassandra.cql.compiler.parse.CqlParser; -import org.apache.log4j.Logger; - -// -// Note: This class is CQL related work in progress. -// -// Currently, this phase combines both semantic analysis and code-gen. -// I expect that as my ideas get refined/cleared up, I'll be drawing -// a more clear distinction between semantic analysis phase and code-gen. -// -public class SemanticPhase -{ - private final static Logger logger_ = Logger.getLogger(SemanticPhase.class); - - // Current code-gen also happens in this phase! - public static Plan doSemanticAnalysis(CommonTree ast) throws SemanticException - { - Plan plan = null; - - if (logger_.isDebugEnabled()) - logger_.debug("AST: " + ast.toStringTree()); - - switch (ast.getType()) - { - case CqlParser.A_GET: - plan = compileGet(ast); - break; - case CqlParser.A_SET: - plan = compileSet(ast); - break; - case CqlParser.A_DELETE: - compileDelete(ast); - break; - case CqlParser.A_SELECT: - compileSelect(ast); - break; - case CqlParser.A_EXPLAIN_PLAN: - // Case: EXPLAN PLAN - // first, generate a plan for - // and then, wrapper it with a special ExplainPlan plan - // whose execution will result in an explain plan rather - // than a normal execution of the statement. - plan = doSemanticAnalysis((CommonTree)(ast.getChild(0))); - plan = new ExplainPlan(plan); - break; - default: - // Unhandled AST node. Raise an internal error. - throw new SemanticException(CompilerErrorMsg.INTERNAL_ERROR.getMsg(ast, "Unknown Node Type: " + ast.getType())); - } - return plan; - } - - /** - * Given a CommonTree AST node of type, A_COLUMN_ACCESS related functions, do semantic - * checking to ensure table name, column family name, and number of key dimensions - * specified are all valid. - */ - private static CFMetaData getColumnFamilyInfo(CommonTree ast) throws SemanticException - { - assert(ast.getType() == CqlParser.A_COLUMN_ACCESS); - - CommonTree columnFamilyNode = (CommonTree)(ast.getChild(1)); - CommonTree tableNode = (CommonTree)(ast.getChild(0)); - - String columnFamily = columnFamilyNode.getText(); - String table = tableNode.getText(); - - Map columnFamilies = DatabaseDescriptor.getTableMetaData(table); - if (columnFamilies == null) - { - throw new SemanticException(CompilerErrorMsg.INVALID_TABLE.getMsg(ast, table)); - } - - CFMetaData cfMetaData = columnFamilies.get(columnFamily); - if (cfMetaData == null) - { - throw new SemanticException(CompilerErrorMsg.INVALID_COLUMN_FAMILY.getMsg(ast, columnFamily, table)); - } - - // Once you have drilled down to a row using a rowKey, a super column - // map can be indexed only 2 further levels deep; and a column map may - // be indexed up to 1 level deep. - int dimensions = numColumnDimensions(ast); - if (("Super".equals(cfMetaData.columnType) && (dimensions > 2)) || - ("Standard".equals(cfMetaData.columnType) && dimensions > 1)) - { - throw new SemanticException(CompilerErrorMsg.TOO_MANY_DIMENSIONS.getMsg(ast, cfMetaData.columnType)); - } - - return cfMetaData; - } - - private static String getRowKey(CommonTree ast) - { - assert(ast.getType() == CqlParser.A_COLUMN_ACCESS); - return Utils.unescapeSQLString(ast.getChild(2).getText()); - } - - private static int numColumnDimensions(CommonTree ast) - { - // Skip over table name, column family and rowKey - return ast.getChildCount() - 3; - } - - // Returns the pos'th (0-based index) column specifier in the astNode - private static String getColumn(CommonTree ast, int pos) - { - // Skip over table name, column family and rowKey - return Utils.unescapeSQLString(ast.getChild(pos + 3).getText()); - } - - // Compile a GET statement - private static Plan compileGet(CommonTree ast) throws SemanticException - { - int childCount = ast.getChildCount(); - assert(childCount == 1); - - CommonTree columnFamilySpec = (CommonTree)ast.getChild(0); - assert(columnFamilySpec.getType() == CqlParser.A_COLUMN_ACCESS); - - CFMetaData cfMetaData = getColumnFamilyInfo(columnFamilySpec); - ConstantOperand rowKey = new ConstantOperand(getRowKey(columnFamilySpec)); - int dimensionCnt = numColumnDimensions(columnFamilySpec); - - RowSourceDef rwsDef; - if ("Super".equals(cfMetaData.columnType)) - { - if (dimensionCnt > 2) - { - // We don't expect this case to arise, since Cql.g grammar disallows this. - // therefore, raise this case as an "internal error". - throw new SemanticException(CompilerErrorMsg.INTERNAL_ERROR.getMsg(columnFamilySpec)); - } - - if (dimensionCnt == 2) - { - // Case: table.super_cf[][][] - ConstantOperand superColumnKey = new ConstantOperand(getColumn(columnFamilySpec, 0)); - ConstantOperand columnKey = new ConstantOperand(getColumn(columnFamilySpec, 1)); - rwsDef = new UniqueKeyQueryRSD(cfMetaData, rowKey, superColumnKey, columnKey); - } - else if (dimensionCnt == 1) - { - // Case: table.super_cf[][] - ConstantOperand superColumnKey = new ConstantOperand(getColumn(columnFamilySpec, 0)); - rwsDef = new ColumnRangeQueryRSD(cfMetaData, rowKey, superColumnKey, Integer.MAX_VALUE); - } - else - { - // Case: table.super_cf[] - rwsDef = new SuperColumnRangeQueryRSD(cfMetaData, rowKey, Integer.MAX_VALUE); - } - } - else // Standard Column Family - { - if (dimensionCnt == 1) - { - // Case: table.standard_cf[][] - ConstantOperand columnKey = new ConstantOperand(getColumn(columnFamilySpec, 0)); - rwsDef = new UniqueKeyQueryRSD(cfMetaData, rowKey, columnKey); - } - else - { - // Case: table.standard_cf[] - logger_.assertLog((dimensionCnt == 0), "invalid dimensionCnt: " + dimensionCnt); - rwsDef = new ColumnRangeQueryRSD(cfMetaData, rowKey, Integer.MAX_VALUE); - } - } - return new QueryPlan(rwsDef); - } - - private static OperandDef getSimpleExpr(CommonTree ast) throws SemanticException - { - int type = ast.getType(); - - // for now, the only simple expressions support are of string type - if (type != CqlParser.StringLiteral) - { - throw new SemanticException(CompilerErrorMsg.INVALID_TYPE.getMsg(ast)); - } - return new ConstantOperand(Utils.unescapeSQLString(ast.getText())); - } - - private static ColumnMapExpr getColumnMapExpr(CommonTree ast) throws SemanticException - { - int type = ast.getType(); - if (type != CqlParser.A_COLUMN_MAP_VALUE) - { - throw new SemanticException(CompilerErrorMsg.INVALID_TYPE.getMsg(ast)); - } - - int size = ast.getChildCount(); - ColumnMapExpr result = new ColumnMapExpr(); - for (int idx = 0; idx < size; idx++) - { - CommonTree entryNode = (CommonTree)(ast.getChild(idx)); - OperandDef columnKey = getSimpleExpr((CommonTree)(entryNode.getChild(0))); - OperandDef columnValue = getSimpleExpr((CommonTree)(entryNode.getChild(1))); - - Pair entry = new Pair(columnKey, columnValue); - result.add(entry); - } - return result; - } - - private static SuperColumnMapExpr getSuperColumnMapExpr(CommonTree ast) throws SemanticException - { - int type = ast.getType(); - if (type != CqlParser.A_SUPERCOLUMN_MAP_VALUE) - { - throw new SemanticException(CompilerErrorMsg.INVALID_TYPE.getMsg(ast)); - } - int size = ast.getChildCount(); - SuperColumnMapExpr result = new SuperColumnMapExpr(); - for (int idx = 0; idx < size; idx++) - { - CommonTree entryNode = (CommonTree)(ast.getChild(idx)); - OperandDef superColumnKey = getSimpleExpr((CommonTree)(entryNode.getChild(0))); - ColumnMapExpr columnMapExpr = getColumnMapExpr((CommonTree)(entryNode.getChild(1))); - - Pair entry = new Pair(superColumnKey, columnMapExpr); - result.add(entry); - } - return result; - } - - // compile a SET statement - private static Plan compileSet(CommonTree ast) throws SemanticException - { - int childCount = ast.getChildCount(); - assert(childCount == 2); - - CommonTree columnFamilySpec = (CommonTree)ast.getChild(0); - assert(columnFamilySpec.getType() == CqlParser.A_COLUMN_ACCESS); - - CFMetaData cfMetaData = getColumnFamilyInfo(columnFamilySpec); - ConstantOperand rowKey = new ConstantOperand(getRowKey(columnFamilySpec)); - int dimensionCnt = numColumnDimensions(columnFamilySpec); - - CommonTree valueNode = (CommonTree)(ast.getChild(1)); - - Plan plan = null; - if ("Super".equals(cfMetaData.columnType)) - { - if (dimensionCnt == 2) - { - // Case: set table.super_cf['key']['supercolumn']['column'] = 'value' - OperandDef value = getSimpleExpr(valueNode); - ConstantOperand superColumnKey = new ConstantOperand(getColumn(columnFamilySpec, 0)); - ConstantOperand columnKey = new ConstantOperand(getColumn(columnFamilySpec, 1)); - plan = new SetUniqueKey(cfMetaData, rowKey, superColumnKey, columnKey, value); - } - else if (dimensionCnt == 1) - { - // Case: set table.super_cf['key']['supercolumn'] = ; - ColumnMapExpr columnMapExpr = getColumnMapExpr(valueNode); - ConstantOperand superColumnKey = new ConstantOperand(getColumn(columnFamilySpec, 0)); - plan = new SetColumnMap(cfMetaData, rowKey, superColumnKey, columnMapExpr); - } - else - { - // Case: set table.super_cf['key'] = ; - logger_.assertLog(dimensionCnt == 0, "invalid dimensionCnt: " + dimensionCnt); - SuperColumnMapExpr superColumnMapExpr = getSuperColumnMapExpr(valueNode); - plan = new SetSuperColumnMap(cfMetaData, rowKey, superColumnMapExpr); - } - } - else // Standard column family - { - if (dimensionCnt == 1) - { - // Case: set table.standard_cf['key']['column'] = 'value' - OperandDef value = getSimpleExpr(valueNode); - ConstantOperand columnKey = new ConstantOperand(getColumn(columnFamilySpec, 0)); - plan = new SetUniqueKey(cfMetaData, rowKey, columnKey, value); - } - else - { - // Case: set table.standard_cf['key'] = ; - logger_.assertLog(dimensionCnt == 0, "invalid dimensionCnt: " + dimensionCnt); - ColumnMapExpr columnMapExpr = getColumnMapExpr(valueNode); - plan = new SetColumnMap(cfMetaData, rowKey, columnMapExpr); - } - } - return plan; - } - - private static void compileSelect(CommonTree ast) throws SemanticException - { - // stub; tbd. - } - private static void compileDelete(CommonTree ast) throws SemanticException - { - // stub; tbd. - } -} \ No newline at end of file diff --git a/src/java/org/apache/cassandra/cql/driver/CqlDriver.java b/src/java/org/apache/cassandra/cql/driver/CqlDriver.java deleted file mode 100644 index 63c0c20785..0000000000 --- a/src/java/org/apache/cassandra/cql/driver/CqlDriver.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.cassandra.cql.driver; - -import org.apache.cassandra.cql.common.CqlResult; -import org.apache.cassandra.cql.common.Plan; -import org.apache.cassandra.cql.compiler.common.CqlCompiler; -import org.apache.cassandra.cql.compiler.parse.ParseException; -import org.apache.cassandra.cql.compiler.sem.SemanticException; -import org.apache.cassandra.utils.LogUtil; -import org.apache.log4j.Logger; - -// Server side driver class for CQL -public class CqlDriver -{ - private final static Logger logger_ = Logger.getLogger(CqlDriver.class); - - // Execute a CQL Statement - public static CqlResult executeQuery(String query) - { - CqlCompiler compiler = new CqlCompiler(); - - try - { - if (logger_.isDebugEnabled()) - logger_.debug("Compiling CQL query ..."); - Plan plan = compiler.compileQuery(query); - if (plan != null) - { - if (logger_.isDebugEnabled()) - logger_.debug("Executing CQL query ..."); - return plan.execute(); - } - } - catch (Exception e) - { - CqlResult result = new CqlResult(null); - result.errorTxt = e.getMessage(); - - Class excpClass = e.getClass(); - if ((excpClass != SemanticException.class) - && (excpClass != ParseException.class) - && (excpClass != RuntimeException.class)) - { - result.errorTxt = "CQL Internal Error: " + result.errorTxt; - result.errorCode = 1; // failure - logger_.error(LogUtil.throwableToString(e)); - } - - return result; - } - - return null; - } -} diff --git a/src/java/org/apache/cassandra/cql/execution/RuntimeErrorMsg.java b/src/java/org/apache/cassandra/cql/execution/RuntimeErrorMsg.java deleted file mode 100644 index 8e066dc6e5..0000000000 --- a/src/java/org/apache/cassandra/cql/execution/RuntimeErrorMsg.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.cassandra.cql.execution; - -/** - * List of error messages thrown by CQL's Execution Layer - **/ -public enum RuntimeErrorMsg -{ - // Error messages with String.format() style format specifiers - GENERIC_ERROR("CQL Execution Error"), - INTERNAL_ERROR("CQL Internal Error: %s"), - IMPLEMENTATION_RESTRICTION("Implementation Restriction: %s"), - NO_DATA_FOUND("No data found") - ; - - private String mesg; - RuntimeErrorMsg(String mesg) - { - this.mesg = mesg; - } - - // Returns the formatted error message. - public String getMsg(Object... args) - { - // note: mesg itself might contain other format specifiers... - return String.format(mesg, args); - } -} diff --git a/src/java/org/apache/cassandra/service/CassandraServer.java b/src/java/org/apache/cassandra/service/CassandraServer.java index b41f9ecdac..6db09daaec 100644 --- a/src/java/org/apache/cassandra/service/CassandraServer.java +++ b/src/java/org/apache/cassandra/service/CassandraServer.java @@ -30,8 +30,6 @@ import org.apache.commons.lang.ArrayUtils; import org.apache.cassandra.config.CFMetaData; import org.apache.cassandra.config.DatabaseDescriptor; -import org.apache.cassandra.cql.common.CqlResult; -import org.apache.cassandra.cql.driver.CqlDriver; import org.apache.cassandra.db.*; import org.apache.cassandra.db.marshal.MarshalException; import org.apache.cassandra.db.filter.QueryPath; @@ -471,22 +469,6 @@ public class CassandraServer implements Cassandra.Iface return columnFamiliesMap; } - public org.apache.cassandra.service.CqlResult execute_query(String query) throws TException - { - org.apache.cassandra.service.CqlResult result = new org.apache.cassandra.service.CqlResult(); - - CqlResult cqlResult = CqlDriver.executeQuery(query); - - // convert CQL result type to Thrift specific return type - if (cqlResult != null) - { - result.error_txt = cqlResult.errorTxt; - result.result_set = cqlResult.resultSet; - result.error_code = cqlResult.errorCode; - } - return result; - } - public List get_key_range(String tablename, String columnFamily, String startWith, String stopAt, int maxResults) throws InvalidRequestException, TException { if (logger.isDebugEnabled())