diff --git a/interface/cassandra.thrift b/interface/cassandra.thrift index dc3c1bb7c7..598354c16a 100644 --- a/interface/cassandra.thrift +++ b/interface/cassandra.thrift @@ -134,9 +134,6 @@ service Cassandra { void remove(1:string table, 2:string key, 3:ColumnPathOrParent column_path_or_parent, 4:i64 timestamp, 5:i32 block_for=0) throws (1: InvalidRequestException ire, 2: UnavailableException ue), - list get_columns_since(1:string table, 2:string key, 3:ColumnParent column_parent, 4:i64 timeStamp) - throws (1: InvalidRequestException ire, 2: NotFoundException nfe), - list get_slice_super(1:string table, 2:string key, 3:string column_family, 4:string start, 5:string finish, 6:bool is_ascending, 7:i32 count=100) throws (1: InvalidRequestException ire), diff --git a/interface/gen-java/org/apache/cassandra/service/Cassandra.java b/interface/gen-java/org/apache/cassandra/service/Cassandra.java index 5296e3643d..36e4b5e953 100644 --- a/interface/gen-java/org/apache/cassandra/service/Cassandra.java +++ b/interface/gen-java/org/apache/cassandra/service/Cassandra.java @@ -36,8 +36,6 @@ public class Cassandra { public void remove(String table, String key, ColumnPathOrParent column_path_or_parent, long timestamp, int block_for) throws InvalidRequestException, UnavailableException, TException; - public List get_columns_since(String table, String key, ColumnParent column_parent, long timeStamp) throws InvalidRequestException, NotFoundException, TException; - public List get_slice_super(String table, String key, String column_family, String start, String finish, boolean is_ascending, int count) throws InvalidRequestException, TException; public List get_slice_super_by_names(String table, String key, String column_family, List super_column_names) throws InvalidRequestException, TException; @@ -370,48 +368,6 @@ public class Cassandra { return; } - public List get_columns_since(String table, String key, ColumnParent column_parent, long timeStamp) throws InvalidRequestException, NotFoundException, TException - { - send_get_columns_since(table, key, column_parent, timeStamp); - return recv_get_columns_since(); - } - - public void send_get_columns_since(String table, String key, ColumnParent column_parent, long timeStamp) throws TException - { - oprot_.writeMessageBegin(new TMessage("get_columns_since", TMessageType.CALL, seqid_)); - get_columns_since_args args = new get_columns_since_args(); - args.table = table; - args.key = key; - args.column_parent = column_parent; - args.timeStamp = timeStamp; - args.write(oprot_); - oprot_.writeMessageEnd(); - oprot_.getTransport().flush(); - } - - public List recv_get_columns_since() throws InvalidRequestException, NotFoundException, TException - { - TMessage msg = iprot_.readMessageBegin(); - if (msg.type == TMessageType.EXCEPTION) { - TApplicationException x = TApplicationException.read(iprot_); - iprot_.readMessageEnd(); - throw x; - } - get_columns_since_result result = new get_columns_since_result(); - result.read(iprot_); - iprot_.readMessageEnd(); - if (result.isSetSuccess()) { - return result.success; - } - if (result.ire != null) { - throw result.ire; - } - if (result.nfe != null) { - throw result.nfe; - } - throw new TApplicationException(TApplicationException.MISSING_RESULT, "get_columns_since failed: unknown result"); - } - public List get_slice_super(String table, String key, String column_family, String start, String finish, boolean is_ascending, int count) throws InvalidRequestException, TException { send_get_slice_super(table, key, column_family, start, finish, is_ascending, count); @@ -760,7 +716,6 @@ public class Cassandra { processMap_.put("insert", new insert()); processMap_.put("batch_insert", new batch_insert()); processMap_.put("remove", new remove()); - processMap_.put("get_columns_since", new get_columns_since()); processMap_.put("get_slice_super", new get_slice_super()); processMap_.put("get_slice_super_by_names", new get_slice_super_by_names()); processMap_.put("get_super_column", new get_super_column()); @@ -1006,36 +961,6 @@ public class Cassandra { } - private class get_columns_since implements ProcessFunction { - public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException - { - get_columns_since_args args = new get_columns_since_args(); - args.read(iprot); - iprot.readMessageEnd(); - get_columns_since_result result = new get_columns_since_result(); - try { - result.success = iface_.get_columns_since(args.table, args.key, args.column_parent, args.timeStamp); - } catch (InvalidRequestException ire) { - result.ire = ire; - } catch (NotFoundException nfe) { - result.nfe = nfe; - } catch (Throwable th) { - LOGGER.error("Internal error processing get_columns_since", th); - TApplicationException x = new TApplicationException(TApplicationException.INTERNAL_ERROR, "Internal error processing get_columns_since"); - oprot.writeMessageBegin(new TMessage("get_columns_since", TMessageType.EXCEPTION, seqid)); - x.write(oprot); - oprot.writeMessageEnd(); - oprot.getTransport().flush(); - return; - } - oprot.writeMessageBegin(new TMessage("get_columns_since", TMessageType.REPLY, seqid)); - result.write(oprot); - oprot.writeMessageEnd(); - oprot.getTransport().flush(); - } - - } - private class get_slice_super implements ProcessFunction { public void process(int seqid, TProtocol iprot, TProtocol oprot) throws TException { @@ -6684,811 +6609,6 @@ public class Cassandra { } - public static class get_columns_since_args implements TBase, java.io.Serializable, Cloneable { - private static final TStruct STRUCT_DESC = new TStruct("get_columns_since_args"); - private static final TField TABLE_FIELD_DESC = new TField("table", TType.STRING, (short)1); - private static final TField KEY_FIELD_DESC = new TField("key", TType.STRING, (short)2); - private static final TField COLUMN_PARENT_FIELD_DESC = new TField("column_parent", TType.STRUCT, (short)3); - private static final TField TIME_STAMP_FIELD_DESC = new TField("timeStamp", TType.I64, (short)4); - - public String table; - public static final int TABLE = 1; - public String key; - public static final int KEY = 2; - public ColumnParent column_parent; - public static final int COLUMN_PARENT = 3; - public long timeStamp; - public static final int TIMESTAMP = 4; - - private final Isset __isset = new Isset(); - private static final class Isset implements java.io.Serializable { - public boolean timeStamp = false; - } - - public static final Map metaDataMap = Collections.unmodifiableMap(new HashMap() {{ - put(TABLE, new FieldMetaData("table", TFieldRequirementType.DEFAULT, - new FieldValueMetaData(TType.STRING))); - put(KEY, new FieldMetaData("key", TFieldRequirementType.DEFAULT, - new FieldValueMetaData(TType.STRING))); - put(COLUMN_PARENT, new FieldMetaData("column_parent", TFieldRequirementType.DEFAULT, - new StructMetaData(TType.STRUCT, ColumnParent.class))); - put(TIMESTAMP, new FieldMetaData("timeStamp", TFieldRequirementType.DEFAULT, - new FieldValueMetaData(TType.I64))); - }}); - - static { - FieldMetaData.addStructMetaDataMap(get_columns_since_args.class, metaDataMap); - } - - public get_columns_since_args() { - } - - public get_columns_since_args( - String table, - String key, - ColumnParent column_parent, - long timeStamp) - { - this(); - this.table = table; - this.key = key; - this.column_parent = column_parent; - this.timeStamp = timeStamp; - this.__isset.timeStamp = true; - } - - /** - * Performs a deep copy on other. - */ - public get_columns_since_args(get_columns_since_args other) { - if (other.isSetTable()) { - this.table = other.table; - } - if (other.isSetKey()) { - this.key = other.key; - } - if (other.isSetColumn_parent()) { - this.column_parent = new ColumnParent(other.column_parent); - } - __isset.timeStamp = other.__isset.timeStamp; - this.timeStamp = other.timeStamp; - } - - @Override - public get_columns_since_args clone() { - return new get_columns_since_args(this); - } - - public String getTable() { - return this.table; - } - - public void setTable(String table) { - this.table = table; - } - - public void unsetTable() { - this.table = null; - } - - // Returns true if field table is set (has been asigned a value) and false otherwise - public boolean isSetTable() { - return this.table != null; - } - - public void setTableIsSet(boolean value) { - if (!value) { - this.table = null; - } - } - - public String getKey() { - return this.key; - } - - public void setKey(String key) { - this.key = key; - } - - public void unsetKey() { - this.key = null; - } - - // Returns true if field key is set (has been asigned a value) and false otherwise - public boolean isSetKey() { - return this.key != null; - } - - public void setKeyIsSet(boolean value) { - if (!value) { - this.key = null; - } - } - - public ColumnParent getColumn_parent() { - return this.column_parent; - } - - public void setColumn_parent(ColumnParent column_parent) { - this.column_parent = column_parent; - } - - public void unsetColumn_parent() { - this.column_parent = null; - } - - // Returns true if field column_parent is set (has been asigned a value) and false otherwise - public boolean isSetColumn_parent() { - return this.column_parent != null; - } - - public void setColumn_parentIsSet(boolean value) { - if (!value) { - this.column_parent = null; - } - } - - public long getTimeStamp() { - return this.timeStamp; - } - - public void setTimeStamp(long timeStamp) { - this.timeStamp = timeStamp; - this.__isset.timeStamp = true; - } - - public void unsetTimeStamp() { - this.__isset.timeStamp = false; - } - - // Returns true if field timeStamp is set (has been asigned a value) and false otherwise - public boolean isSetTimeStamp() { - return this.__isset.timeStamp; - } - - public void setTimeStampIsSet(boolean value) { - this.__isset.timeStamp = value; - } - - public void setFieldValue(int fieldID, Object value) { - switch (fieldID) { - case TABLE: - if (value == null) { - unsetTable(); - } else { - setTable((String)value); - } - break; - - case KEY: - if (value == null) { - unsetKey(); - } else { - setKey((String)value); - } - break; - - case COLUMN_PARENT: - if (value == null) { - unsetColumn_parent(); - } else { - setColumn_parent((ColumnParent)value); - } - break; - - case TIMESTAMP: - if (value == null) { - unsetTimeStamp(); - } else { - setTimeStamp((Long)value); - } - break; - - default: - throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); - } - } - - public Object getFieldValue(int fieldID) { - switch (fieldID) { - case TABLE: - return getTable(); - - case KEY: - return getKey(); - - case COLUMN_PARENT: - return getColumn_parent(); - - case TIMESTAMP: - return new Long(getTimeStamp()); - - 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 TABLE: - return isSetTable(); - case KEY: - return isSetKey(); - case COLUMN_PARENT: - return isSetColumn_parent(); - case TIMESTAMP: - return isSetTimeStamp(); - default: - throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); - } - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof get_columns_since_args) - return this.equals((get_columns_since_args)that); - return false; - } - - public boolean equals(get_columns_since_args that) { - if (that == null) - return false; - - boolean this_present_table = true && this.isSetTable(); - boolean that_present_table = true && that.isSetTable(); - if (this_present_table || that_present_table) { - if (!(this_present_table && that_present_table)) - return false; - if (!this.table.equals(that.table)) - return false; - } - - boolean this_present_key = true && this.isSetKey(); - boolean that_present_key = true && that.isSetKey(); - if (this_present_key || that_present_key) { - if (!(this_present_key && that_present_key)) - return false; - if (!this.key.equals(that.key)) - return false; - } - - boolean this_present_column_parent = true && this.isSetColumn_parent(); - boolean that_present_column_parent = true && that.isSetColumn_parent(); - if (this_present_column_parent || that_present_column_parent) { - if (!(this_present_column_parent && that_present_column_parent)) - return false; - if (!this.column_parent.equals(that.column_parent)) - return false; - } - - boolean this_present_timeStamp = true; - boolean that_present_timeStamp = true; - if (this_present_timeStamp || that_present_timeStamp) { - if (!(this_present_timeStamp && that_present_timeStamp)) - return false; - if (this.timeStamp != that.timeStamp) - 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 TABLE: - if (field.type == TType.STRING) { - this.table = iprot.readString(); - } else { - TProtocolUtil.skip(iprot, field.type); - } - break; - case KEY: - if (field.type == TType.STRING) { - this.key = iprot.readString(); - } else { - TProtocolUtil.skip(iprot, field.type); - } - break; - case COLUMN_PARENT: - if (field.type == TType.STRUCT) { - this.column_parent = new ColumnParent(); - this.column_parent.read(iprot); - } else { - TProtocolUtil.skip(iprot, field.type); - } - break; - case TIMESTAMP: - if (field.type == TType.I64) { - this.timeStamp = iprot.readI64(); - this.__isset.timeStamp = true; - } 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.table != null) { - oprot.writeFieldBegin(TABLE_FIELD_DESC); - oprot.writeString(this.table); - oprot.writeFieldEnd(); - } - if (this.key != null) { - oprot.writeFieldBegin(KEY_FIELD_DESC); - oprot.writeString(this.key); - oprot.writeFieldEnd(); - } - if (this.column_parent != null) { - oprot.writeFieldBegin(COLUMN_PARENT_FIELD_DESC); - this.column_parent.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldBegin(TIME_STAMP_FIELD_DESC); - oprot.writeI64(this.timeStamp); - oprot.writeFieldEnd(); - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("get_columns_since_args("); - boolean first = true; - - sb.append("table:"); - if (this.table == null) { - sb.append("null"); - } else { - sb.append(this.table); - } - first = false; - if (!first) sb.append(", "); - sb.append("key:"); - if (this.key == null) { - sb.append("null"); - } else { - sb.append(this.key); - } - first = false; - if (!first) sb.append(", "); - sb.append("column_parent:"); - if (this.column_parent == null) { - sb.append("null"); - } else { - sb.append(this.column_parent); - } - first = false; - if (!first) sb.append(", "); - sb.append("timeStamp:"); - sb.append(this.timeStamp); - 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 get_columns_since_result implements TBase, java.io.Serializable, Cloneable { - private static final TStruct STRUCT_DESC = new TStruct("get_columns_since_result"); - private static final TField SUCCESS_FIELD_DESC = new TField("success", TType.LIST, (short)0); - private static final TField IRE_FIELD_DESC = new TField("ire", TType.STRUCT, (short)1); - private static final TField NFE_FIELD_DESC = new TField("nfe", TType.STRUCT, (short)2); - - public List success; - public static final int SUCCESS = 0; - public InvalidRequestException ire; - public static final int IRE = 1; - public NotFoundException nfe; - public static final int NFE = 2; - - 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 ListMetaData(TType.LIST, - new StructMetaData(TType.STRUCT, Column.class)))); - put(IRE, new FieldMetaData("ire", TFieldRequirementType.DEFAULT, - new FieldValueMetaData(TType.STRUCT))); - put(NFE, new FieldMetaData("nfe", TFieldRequirementType.DEFAULT, - new FieldValueMetaData(TType.STRUCT))); - }}); - - static { - FieldMetaData.addStructMetaDataMap(get_columns_since_result.class, metaDataMap); - } - - public get_columns_since_result() { - } - - public get_columns_since_result( - List success, - InvalidRequestException ire, - NotFoundException nfe) - { - this(); - this.success = success; - this.ire = ire; - this.nfe = nfe; - } - - /** - * Performs a deep copy on other. - */ - public get_columns_since_result(get_columns_since_result other) { - if (other.isSetSuccess()) { - List __this__success = new ArrayList(); - for (Column other_element : other.success) { - __this__success.add(new Column(other_element)); - } - this.success = __this__success; - } - if (other.isSetIre()) { - this.ire = new InvalidRequestException(other.ire); - } - if (other.isSetNfe()) { - this.nfe = new NotFoundException(other.nfe); - } - } - - @Override - public get_columns_since_result clone() { - return new get_columns_since_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(Column elem) { - if (this.success == null) { - this.success = new ArrayList(); - } - this.success.add(elem); - } - - public List getSuccess() { - return this.success; - } - - public void setSuccess(List 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 InvalidRequestException getIre() { - return this.ire; - } - - public void setIre(InvalidRequestException ire) { - this.ire = ire; - } - - public void unsetIre() { - this.ire = null; - } - - // Returns true if field ire is set (has been asigned a value) and false otherwise - public boolean isSetIre() { - return this.ire != null; - } - - public void setIreIsSet(boolean value) { - if (!value) { - this.ire = null; - } - } - - public NotFoundException getNfe() { - return this.nfe; - } - - public void setNfe(NotFoundException nfe) { - this.nfe = nfe; - } - - public void unsetNfe() { - this.nfe = null; - } - - // Returns true if field nfe is set (has been asigned a value) and false otherwise - public boolean isSetNfe() { - return this.nfe != null; - } - - public void setNfeIsSet(boolean value) { - if (!value) { - this.nfe = null; - } - } - - public void setFieldValue(int fieldID, Object value) { - switch (fieldID) { - case SUCCESS: - if (value == null) { - unsetSuccess(); - } else { - setSuccess((List)value); - } - break; - - case IRE: - if (value == null) { - unsetIre(); - } else { - setIre((InvalidRequestException)value); - } - break; - - case NFE: - if (value == null) { - unsetNfe(); - } else { - setNfe((NotFoundException)value); - } - break; - - default: - throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); - } - } - - public Object getFieldValue(int fieldID) { - switch (fieldID) { - case SUCCESS: - return getSuccess(); - - case IRE: - return getIre(); - - case NFE: - return getNfe(); - - 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(); - case IRE: - return isSetIre(); - case NFE: - return isSetNfe(); - default: - throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!"); - } - } - - @Override - public boolean equals(Object that) { - if (that == null) - return false; - if (that instanceof get_columns_since_result) - return this.equals((get_columns_since_result)that); - return false; - } - - public boolean equals(get_columns_since_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; - } - - boolean this_present_ire = true && this.isSetIre(); - boolean that_present_ire = true && that.isSetIre(); - if (this_present_ire || that_present_ire) { - if (!(this_present_ire && that_present_ire)) - return false; - if (!this.ire.equals(that.ire)) - return false; - } - - boolean this_present_nfe = true && this.isSetNfe(); - boolean that_present_nfe = true && that.isSetNfe(); - if (this_present_nfe || that_present_nfe) { - if (!(this_present_nfe && that_present_nfe)) - return false; - if (!this.nfe.equals(that.nfe)) - 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.LIST) { - { - TList _list43 = iprot.readListBegin(); - this.success = new ArrayList(_list43.size); - for (int _i44 = 0; _i44 < _list43.size; ++_i44) - { - Column _elem45; - _elem45 = new Column(); - _elem45.read(iprot); - this.success.add(_elem45); - } - iprot.readListEnd(); - } - } else { - TProtocolUtil.skip(iprot, field.type); - } - break; - case IRE: - if (field.type == TType.STRUCT) { - this.ire = new InvalidRequestException(); - this.ire.read(iprot); - } else { - TProtocolUtil.skip(iprot, field.type); - } - break; - case NFE: - if (field.type == TType.STRUCT) { - this.nfe = new NotFoundException(); - this.nfe.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); - { - oprot.writeListBegin(new TList(TType.STRUCT, this.success.size())); - for (Column _iter46 : this.success) { - _iter46.write(oprot); - } - oprot.writeListEnd(); - } - oprot.writeFieldEnd(); - } else if (this.isSetIre()) { - oprot.writeFieldBegin(IRE_FIELD_DESC); - this.ire.write(oprot); - oprot.writeFieldEnd(); - } else if (this.isSetNfe()) { - oprot.writeFieldBegin(NFE_FIELD_DESC); - this.nfe.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("get_columns_since_result("); - boolean first = true; - - sb.append("success:"); - if (this.success == null) { - sb.append("null"); - } else { - sb.append(this.success); - } - first = false; - if (!first) sb.append(", "); - sb.append("ire:"); - if (this.ire == null) { - sb.append("null"); - } else { - sb.append(this.ire); - } - first = false; - if (!first) sb.append(", "); - sb.append("nfe:"); - if (this.nfe == null) { - sb.append("null"); - } else { - sb.append(this.nfe); - } - 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 get_slice_super_args implements TBase, java.io.Serializable, Cloneable { private static final TStruct STRUCT_DESC = new TStruct("get_slice_super_args"); private static final TField TABLE_FIELD_DESC = new TField("table", TType.STRING, (short)1); @@ -8351,14 +7471,14 @@ public class Cassandra { case SUCCESS: if (field.type == TType.LIST) { { - TList _list47 = iprot.readListBegin(); - this.success = new ArrayList(_list47.size); - for (int _i48 = 0; _i48 < _list47.size; ++_i48) + TList _list43 = iprot.readListBegin(); + this.success = new ArrayList(_list43.size); + for (int _i44 = 0; _i44 < _list43.size; ++_i44) { - SuperColumn _elem49; - _elem49 = new SuperColumn(); - _elem49.read(iprot); - this.success.add(_elem49); + SuperColumn _elem45; + _elem45 = new SuperColumn(); + _elem45.read(iprot); + this.success.add(_elem45); } iprot.readListEnd(); } @@ -8394,8 +7514,8 @@ public class Cassandra { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRUCT, this.success.size())); - for (SuperColumn _iter50 : this.success) { - _iter50.write(oprot); + for (SuperColumn _iter46 : this.success) { + _iter46.write(oprot); } oprot.writeListEnd(); } @@ -8792,13 +7912,13 @@ public class Cassandra { case SUPER_COLUMN_NAMES: if (field.type == TType.LIST) { { - TList _list51 = iprot.readListBegin(); - this.super_column_names = new ArrayList(_list51.size); - for (int _i52 = 0; _i52 < _list51.size; ++_i52) + TList _list47 = iprot.readListBegin(); + this.super_column_names = new ArrayList(_list47.size); + for (int _i48 = 0; _i48 < _list47.size; ++_i48) { - String _elem53; - _elem53 = iprot.readString(); - this.super_column_names.add(_elem53); + String _elem49; + _elem49 = iprot.readString(); + this.super_column_names.add(_elem49); } iprot.readListEnd(); } @@ -8842,8 +7962,8 @@ public class Cassandra { oprot.writeFieldBegin(SUPER_COLUMN_NAMES_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRING, this.super_column_names.size())); - for (String _iter54 : this.super_column_names) { - oprot.writeString(_iter54); + for (String _iter50 : this.super_column_names) { + oprot.writeString(_iter50); } oprot.writeListEnd(); } @@ -9121,14 +8241,14 @@ public class Cassandra { case SUCCESS: if (field.type == TType.LIST) { { - TList _list55 = iprot.readListBegin(); - this.success = new ArrayList(_list55.size); - for (int _i56 = 0; _i56 < _list55.size; ++_i56) + TList _list51 = iprot.readListBegin(); + this.success = new ArrayList(_list51.size); + for (int _i52 = 0; _i52 < _list51.size; ++_i52) { - SuperColumn _elem57; - _elem57 = new SuperColumn(); - _elem57.read(iprot); - this.success.add(_elem57); + SuperColumn _elem53; + _elem53 = new SuperColumn(); + _elem53.read(iprot); + this.success.add(_elem53); } iprot.readListEnd(); } @@ -9164,8 +8284,8 @@ public class Cassandra { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRUCT, this.success.size())); - for (SuperColumn _iter58 : this.success) { - _iter58.write(oprot); + for (SuperColumn _iter54 : this.success) { + _iter54.write(oprot); } oprot.writeListEnd(); } @@ -11251,13 +10371,13 @@ public class Cassandra { case SUCCESS: if (field.type == TType.LIST) { { - TList _list59 = iprot.readListBegin(); - this.success = new ArrayList(_list59.size); - for (int _i60 = 0; _i60 < _list59.size; ++_i60) + TList _list55 = iprot.readListBegin(); + this.success = new ArrayList(_list55.size); + for (int _i56 = 0; _i56 < _list55.size; ++_i56) { - String _elem61; - _elem61 = iprot.readString(); - this.success.add(_elem61); + String _elem57; + _elem57 = iprot.readString(); + this.success.add(_elem57); } iprot.readListEnd(); } @@ -11293,8 +10413,8 @@ public class Cassandra { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRING, this.success.size())); - for (String _iter62 : this.success) { - oprot.writeString(_iter62); + for (String _iter58 : this.success) { + oprot.writeString(_iter58); } oprot.writeListEnd(); } @@ -12101,13 +11221,13 @@ public class Cassandra { case SUCCESS: if (field.type == TType.LIST) { { - TList _list63 = iprot.readListBegin(); - this.success = new ArrayList(_list63.size); - for (int _i64 = 0; _i64 < _list63.size; ++_i64) + TList _list59 = iprot.readListBegin(); + this.success = new ArrayList(_list59.size); + for (int _i60 = 0; _i60 < _list59.size; ++_i60) { - String _elem65; - _elem65 = iprot.readString(); - this.success.add(_elem65); + String _elem61; + _elem61 = iprot.readString(); + this.success.add(_elem61); } iprot.readListEnd(); } @@ -12135,8 +11255,8 @@ public class Cassandra { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new TList(TType.STRING, this.success.size())); - for (String _iter66 : this.success) { - oprot.writeString(_iter66); + for (String _iter62 : this.success) { + oprot.writeString(_iter62); } oprot.writeListEnd(); } @@ -12607,27 +11727,27 @@ public class Cassandra { case SUCCESS: if (field.type == TType.MAP) { { - TMap _map67 = iprot.readMapBegin(); - this.success = new HashMap>(2*_map67.size); - for (int _i68 = 0; _i68 < _map67.size; ++_i68) + TMap _map63 = iprot.readMapBegin(); + this.success = new HashMap>(2*_map63.size); + for (int _i64 = 0; _i64 < _map63.size; ++_i64) { - String _key69; - Map _val70; - _key69 = iprot.readString(); + String _key65; + Map _val66; + _key65 = iprot.readString(); { - TMap _map71 = iprot.readMapBegin(); - _val70 = new HashMap(2*_map71.size); - for (int _i72 = 0; _i72 < _map71.size; ++_i72) + TMap _map67 = iprot.readMapBegin(); + _val66 = new HashMap(2*_map67.size); + for (int _i68 = 0; _i68 < _map67.size; ++_i68) { - String _key73; - String _val74; - _key73 = iprot.readString(); - _val74 = iprot.readString(); - _val70.put(_key73, _val74); + String _key69; + String _val70; + _key69 = iprot.readString(); + _val70 = iprot.readString(); + _val66.put(_key69, _val70); } iprot.readMapEnd(); } - this.success.put(_key69, _val70); + this.success.put(_key65, _val66); } iprot.readMapEnd(); } @@ -12663,13 +11783,13 @@ public class Cassandra { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeMapBegin(new TMap(TType.STRING, TType.MAP, this.success.size())); - for (Map.Entry> _iter75 : this.success.entrySet()) { - oprot.writeString(_iter75.getKey()); + for (Map.Entry> _iter71 : this.success.entrySet()) { + oprot.writeString(_iter71.getKey()); { - oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING, _iter75.getValue().size())); - for (Map.Entry _iter76 : _iter75.getValue().entrySet()) { - oprot.writeString(_iter76.getKey()); - oprot.writeString(_iter76.getValue()); + oprot.writeMapBegin(new TMap(TType.STRING, TType.STRING, _iter71.getValue().size())); + for (Map.Entry _iter72 : _iter71.getValue().entrySet()) { + oprot.writeString(_iter72.getKey()); + oprot.writeString(_iter72.getValue()); } oprot.writeMapEnd(); } diff --git a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java index 3db762e119..680955e0c2 100644 --- a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java +++ b/src/java/org/apache/cassandra/config/DatabaseDescriptor.java @@ -587,17 +587,6 @@ public class DatabaseDescriptor return cfMetaData.flushPeriodInMinutes; } - public static boolean isNameSortingEnabled(String tableName, String cfName) - { - assert tableName != null; - CFMetaData cfMetaData = getCFMetaData(tableName, cfName); - - if (cfMetaData == null) - return false; - - return "Name".equals(cfMetaData.indexProperty_); - } - public static boolean isTimeSortingEnabled(String tableName, String cfName) { assert tableName != null; @@ -773,15 +762,7 @@ public class DatabaseDescriptor public static ColumnComparatorFactory.ComparatorType getTypeInfo(String tableName, String cfName) { assert tableName != null; - CFMetaData cfMetadata = DatabaseDescriptor.getCFMetaData(tableName, cfName); - if ( cfMetadata.indexProperty_.equals("Name") ) - { - return ColumnComparatorFactory.ComparatorType.NAME; - } - else - { - return ColumnComparatorFactory.ComparatorType.TIMESTAMP; - } + return ColumnComparatorFactory.ComparatorType.NAME; } public static Map> getTableToColumnFamilyMap() diff --git a/src/java/org/apache/cassandra/db/ColumnComparatorFactory.java b/src/java/org/apache/cassandra/db/ColumnComparatorFactory.java index 5277f58fcc..4b8edf3646 100644 --- a/src/java/org/apache/cassandra/db/ColumnComparatorFactory.java +++ b/src/java/org/apache/cassandra/db/ColumnComparatorFactory.java @@ -31,18 +31,14 @@ public class ColumnComparatorFactory public static enum ComparatorType { NAME, - TIMESTAMP } public static final Comparator nameComparator_ = new ColumnNameComparator(); - public static final Comparator timestampComparator_ = new ColumnTimestampComparator(); public static Comparator getComparator(ComparatorType comparatorType) { - if (comparatorType == ComparatorType.NAME) - return nameComparator_; - assert comparatorType == ComparatorType.TIMESTAMP; - return timestampComparator_; + assert comparatorType == ComparatorType.NAME; + return nameComparator_; } public static Comparator getComparator(int comparatorTypeInt) @@ -67,36 +63,6 @@ abstract class AbstractColumnComparator implements Comparator, Serializ } } -class ColumnTimestampComparator extends AbstractColumnComparator -{ - ColumnTimestampComparator() - { - super(ColumnComparatorFactory.ComparatorType.TIMESTAMP); - } - - /* if the time-stamps are the same then sort by names */ - public int compare(IColumn column1, IColumn column2) - { - assert column1.getClass() == column2.getClass(); - /* inverse sort by time to get hte latest first */ - long result = column2.timestamp() - column1.timestamp(); - int finalResult = 0; - if (result == 0) - { - result = column1.name().compareTo(column2.name()); - } - if (result > 0) - { - finalResult = 1; - } - if (result < 0) - { - finalResult = -1; - } - return finalResult; - } -} - class ColumnNameComparator extends AbstractColumnComparator { ColumnNameComparator() diff --git a/src/java/org/apache/cassandra/db/ColumnFamily.java b/src/java/org/apache/cassandra/db/ColumnFamily.java index c351c158e9..e8b1eedaab 100644 --- a/src/java/org/apache/cassandra/db/ColumnFamily.java +++ b/src/java/org/apache/cassandra/db/ColumnFamily.java @@ -96,17 +96,8 @@ public final class ColumnFamily public static ColumnFamily create(String tableName, String cfName) { - Comparator comparator; String columnType = DatabaseDescriptor.getColumnFamilyType(tableName, cfName); - if (DatabaseDescriptor.isNameSortingEnabled(tableName, cfName)) - { - comparator = ColumnComparatorFactory.getComparator(ColumnComparatorFactory.ComparatorType.NAME); - } - /* if this columnfamily has simple columns, and no index on name sort by timestamp */ - else - { - comparator = ColumnComparatorFactory.getComparator(ColumnComparatorFactory.ComparatorType.TIMESTAMP); - } + Comparator comparator = ColumnComparatorFactory.getComparator(ColumnComparatorFactory.ComparatorType.NAME); return new ColumnFamily(cfName, columnType, comparator); } @@ -343,9 +334,7 @@ public final class ColumnFamily public ColumnComparatorFactory.ComparatorType getComparatorType() { - return getComparator() == ColumnComparatorFactory.nameComparator_ - ? ColumnComparatorFactory.ComparatorType.NAME - : ColumnComparatorFactory.ComparatorType.TIMESTAMP; + return ColumnComparatorFactory.ComparatorType.NAME; } int size() diff --git a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java index 7d22208b65..c59dbb9456 100644 --- a/src/java/org/apache/cassandra/db/ColumnFamilyStore.java +++ b/src/java/org/apache/cassandra/db/ColumnFamilyStore.java @@ -1416,11 +1416,6 @@ public final class ColumnFamilyStore implements ColumnFamilyStoreMBean return getColumnFamily(new SliceQueryFilter(key, path, start, finish, isAscending, limit)); } - public ColumnFamily getColumnFamily(String key, QueryPath columnParent, long since) throws IOException - { - return getColumnFamily(new TimeQueryFilter(key, columnParent, since)); - } - public ColumnFamily getColumnFamily(QueryFilter filter) throws IOException { return getColumnFamily(filter, getDefaultGCBefore()); diff --git a/src/java/org/apache/cassandra/db/ColumnsSinceReadCommand.java b/src/java/org/apache/cassandra/db/ColumnsSinceReadCommand.java deleted file mode 100644 index e523658e3f..0000000000 --- a/src/java/org/apache/cassandra/db/ColumnsSinceReadCommand.java +++ /dev/null @@ -1,104 +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.db; - -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import org.apache.cassandra.service.ColumnParent; -import org.apache.cassandra.db.filter.QueryPath; -import org.apache.cassandra.db.filter.QueryFilter; -import org.apache.cassandra.db.filter.TimeQueryFilter; - -public class ColumnsSinceReadCommand extends ReadCommand -{ - public final QueryPath columnParent; - public final long sinceTimestamp; - - public ColumnsSinceReadCommand(String table, String key, ColumnParent column_parent, long sinceTimestamp) - { - this(table, key, new QueryPath(column_parent), sinceTimestamp); - } - - public ColumnsSinceReadCommand(String table, String key, QueryPath columnParent, long sinceTimestamp) - { - super(table, key, CMD_TYPE_GET_COLUMNS_SINCE); - this.columnParent = columnParent; - this.sinceTimestamp = sinceTimestamp; - } - - @Override - public String getColumnFamilyName() - { - return columnParent.columnFamilyName; - } - - @Override - public ReadCommand copy() - { - ReadCommand readCommand = new ColumnsSinceReadCommand(table, key, columnParent, sinceTimestamp); - readCommand.setDigestQuery(isDigestQuery()); - return readCommand; - } - - @Override - public Row getRow(Table table) throws IOException - { - return table.getRow(new TimeQueryFilter(key, columnParent, sinceTimestamp)); - } - - @Override - public String toString() - { - return "ColumnsSinceReadCommand(" + - "table='" + table + '\'' + - ", key='" + key + '\'' + - ", columnParent='" + columnParent + '\'' + - ", sinceTimestamp='" + sinceTimestamp + '\'' + - ')'; - } -} - -class ColumnsSinceReadCommandSerializer extends ReadCommandSerializer -{ - @Override - public void serialize(ReadCommand rm, DataOutputStream dos) throws IOException - { - ColumnsSinceReadCommand realRM = (ColumnsSinceReadCommand)rm; - dos.writeBoolean(realRM.isDigestQuery()); - dos.writeUTF(realRM.table); - dos.writeUTF(realRM.key); - realRM.columnParent.serialize(dos); - dos.writeLong(realRM.sinceTimestamp); - } - - @Override - public ReadCommand deserialize(DataInputStream dis) throws IOException - { - boolean isDigest = dis.readBoolean(); - String table = dis.readUTF(); - String key = dis.readUTF(); - QueryPath columnParent = QueryPath.deserialize(dis); - long sinceTimestamp = dis.readLong(); - - ColumnsSinceReadCommand rm = new ColumnsSinceReadCommand(table, key, columnParent, sinceTimestamp); - rm.setDigestQuery(isDigest); - return rm; - } -} diff --git a/src/java/org/apache/cassandra/db/Memtable.java b/src/java/org/apache/cassandra/db/Memtable.java index 37a323727c..5359d0b71d 100644 --- a/src/java/org/apache/cassandra/db/Memtable.java +++ b/src/java/org/apache/cassandra/db/Memtable.java @@ -353,39 +353,7 @@ public class Memtable implements Comparable } }; } - - public ColumnIterator getTimeIterator(final TimeQueryFilter filter) - { - final ColumnFamily cf = columnFamilies_.get(filter.key); - final ColumnFamily columnFamily = cf == null ? ColumnFamily.create(table_, filter.getColumnFamilyName()) : cf.cloneMeShallow(); - - return new SimpleAbstractColumnIterator() - { - private Iterator iter = cf == null ? null : cf.getAllColumns().iterator(); - - public ColumnFamily getColumnFamily() - { - return columnFamily; - } - - protected IColumn computeNext() - { - if (iter == null) - { - return endOfData(); - } - while (iter.hasNext()) - { - IColumn column = iter.next(); - if (column.timestamp() < filter.since) - break; - return column; - } - return endOfData(); - } - }; - } - + void clearUnsafe() { columnFamilies_.clear(); diff --git a/src/java/org/apache/cassandra/db/ReadCommand.java b/src/java/org/apache/cassandra/db/ReadCommand.java index 43f7f797a7..6192e63e58 100644 --- a/src/java/org/apache/cassandra/db/ReadCommand.java +++ b/src/java/org/apache/cassandra/db/ReadCommand.java @@ -34,8 +34,7 @@ public abstract class ReadCommand { public static final String DO_REPAIR = "READ-REPAIR"; public static final byte CMD_TYPE_GET_SLICE_BY_NAMES = 1; - public static final byte CMD_TYPE_GET_COLUMNS_SINCE = 2; - public static final byte CMD_TYPE_GET_SLICE = 3; + public static final byte CMD_TYPE_GET_SLICE = 2; public static final String EMPTY_CF = ""; @@ -89,7 +88,6 @@ class ReadCommandSerializer implements ICompactSerializer static { CMD_SERIALIZER_MAP.put(ReadCommand.CMD_TYPE_GET_SLICE_BY_NAMES, new SliceByNamesReadCommandSerializer()); - CMD_SERIALIZER_MAP.put(ReadCommand.CMD_TYPE_GET_COLUMNS_SINCE, new ColumnsSinceReadCommandSerializer()); CMD_SERIALIZER_MAP.put(ReadCommand.CMD_TYPE_GET_SLICE, new SliceFromReadCommandSerializer()); } diff --git a/src/java/org/apache/cassandra/db/RowMutation.java b/src/java/org/apache/cassandra/db/RowMutation.java index 5d0200d84e..ffe89e2667 100644 --- a/src/java/org/apache/cassandra/db/RowMutation.java +++ b/src/java/org/apache/cassandra/db/RowMutation.java @@ -95,13 +95,6 @@ public class RowMutation implements Serializable modifications_ = modifications; } - /** trailing empty patch fragments ("" or "CF:") will be removed, - * so caller doesn't have to check for those */ - public static String[] getColumnAndColumnFamily(String cf) - { - return cf.split(":"); - } - public String table() { return table_; diff --git a/src/java/org/apache/cassandra/db/SuperColumn.java b/src/java/org/apache/cassandra/db/SuperColumn.java index 0212857543..b3d45893b9 100644 --- a/src/java/org/apache/cassandra/db/SuperColumn.java +++ b/src/java/org/apache/cassandra/db/SuperColumn.java @@ -24,7 +24,9 @@ import java.io.IOException; import java.io.Serializable; import java.util.Collection; import java.util.Set; +import java.util.Map; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.ConcurrentSkipListMap; import org.apache.commons.lang.ArrayUtils; import org.apache.commons.lang.StringUtils; @@ -41,7 +43,6 @@ public final class SuperColumn implements IColumn, Serializable { private static Logger logger_ = Logger.getLogger(SuperColumn.class); private static SuperColumnSerializer serializer_ = new SuperColumnSerializer(); - private final static String seperator_ = ":"; static SuperColumnSerializer serializer() { @@ -49,7 +50,7 @@ public final class SuperColumn implements IColumn, Serializable } private String name_; - private EfficientBidiMap columns_ = new EfficientBidiMap(ColumnComparatorFactory.getComparator(ColumnComparatorFactory.ComparatorType.TIMESTAMP)); + private ConcurrentSkipListMap columns_ = new ConcurrentSkipListMap(); private int localDeletionTime = Integer.MIN_VALUE; private long markedForDeleteAt = Long.MIN_VALUE; private AtomicInteger size_ = new AtomicInteger(0); @@ -82,7 +83,7 @@ public final class SuperColumn implements IColumn, Serializable public Collection getSubColumns() { - return columns_.getSortedColumns(); + return columns_.values(); } public IColumn getSubColumn(String columnName) @@ -277,12 +278,11 @@ public final class SuperColumn implements IColumn, Serializable public byte[] digest() { - Set columns = columns_.getSortedColumns(); byte[] xorHash = ArrayUtils.EMPTY_BYTE_ARRAY; if(name_ == null) return xorHash; xorHash = name_.getBytes(); - for(IColumn column : columns) + for(IColumn column : columns_.values()) { xorHash = FBUtilities.xor(xorHash, column.digest()); } diff --git a/src/java/org/apache/cassandra/db/Table.java b/src/java/org/apache/cassandra/db/Table.java index 023717efa1..161386ee3f 100644 --- a/src/java/org/apache/cassandra/db/Table.java +++ b/src/java/org/apache/cassandra/db/Table.java @@ -517,9 +517,7 @@ public class Table @Deprecated // single CFs could be larger than memory public ColumnFamily get(String key, String cfName) throws IOException { - assert !cfName.contains(":") : cfName; - String[] values = RowMutation.getColumnAndColumnFamily(cfName); - ColumnFamilyStore cfStore = columnFamilyStores_.get(values[0]); + ColumnFamilyStore cfStore = columnFamilyStores_.get(cfName); assert cfStore != null : "Column family " + cfName + " has not been defined"; return cfStore.getColumnFamily(new IdentityQueryFilter(key, new QueryPath(cfName))); } diff --git a/src/java/org/apache/cassandra/db/filter/SSTableTimeIterator.java b/src/java/org/apache/cassandra/db/filter/SSTableTimeIterator.java deleted file mode 100644 index 1ba5deba0f..0000000000 --- a/src/java/org/apache/cassandra/db/filter/SSTableTimeIterator.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.apache.cassandra.db.filter; - -import java.util.Iterator; -import java.io.IOException; - -import org.apache.cassandra.db.ColumnFamily; -import org.apache.cassandra.db.IColumn; -import org.apache.cassandra.io.SSTableReader; -import org.apache.cassandra.io.DataInputBuffer; -import org.apache.cassandra.io.IndexHelper; - -public class SSTableTimeIterator extends SimpleAbstractColumnIterator -{ - private ColumnFamily cf; - private Iterator iter; - public final long since; - - public SSTableTimeIterator(String filename, String key, String cfName, long since) throws IOException - { - this.since = since; - SSTableReader ssTable = SSTableReader.open(filename); - DataInputBuffer buffer = ssTable.next(key, cfName, null, new IndexHelper.TimeRange(since, Long.MAX_VALUE)); - if (buffer.getLength() > 0) - { - cf = ColumnFamily.serializer().deserialize(buffer); - iter = cf.getAllColumns().iterator(); - } - } - - public ColumnFamily getColumnFamily() - { - return cf; - } - - protected IColumn computeNext() - { - if (iter == null) - return endOfData(); - while (iter.hasNext()) - { - IColumn c = iter.next(); - if (c.timestamp() < since) - break; - return c; - } - return endOfData(); - } -} diff --git a/src/java/org/apache/cassandra/db/filter/TimeQueryFilter.java b/src/java/org/apache/cassandra/db/filter/TimeQueryFilter.java deleted file mode 100644 index 4c4dbe2909..0000000000 --- a/src/java/org/apache/cassandra/db/filter/TimeQueryFilter.java +++ /dev/null @@ -1,55 +0,0 @@ -package org.apache.cassandra.db.filter; - -import java.io.IOException; -import java.util.Comparator; - -import org.apache.cassandra.db.*; -import org.apache.cassandra.io.SSTableReader; -import org.apache.cassandra.utils.ReducingIterator; - -public class TimeQueryFilter extends QueryFilter -{ - public final long since; - - public TimeQueryFilter(String key, QueryPath columnParent, long since) - { - super(key, columnParent); - this.since = since; - } - - public ColumnIterator getMemColumnIterator(Memtable memtable) - { - return memtable.getTimeIterator(this); - } - - public ColumnIterator getSSTableColumnIterator(SSTableReader sstable) throws IOException - { - return new SSTableTimeIterator(sstable.getFilename(), key, getColumnFamilyName(), since); - } - - @Override - public Comparator getColumnComparator() - { - return ColumnComparatorFactory.timestampComparator_; - } - - public void collectColumns(ColumnFamily returnCF, ReducingIterator reducedColumns, int gcBefore) - { - for (IColumn column : reducedColumns) - { - if (!column.isMarkedForDelete() || column.getLocalDeletionTime() > gcBefore) - returnCF.addColumn(column); - } - } - - public void filterSuperColumn(SuperColumn superColumn) - { - for (IColumn column : superColumn.getSubColumns()) - { - if (column.timestamp() < since) - { - superColumn.remove(column.name()); - } - } - } -} diff --git a/src/java/org/apache/cassandra/io/IFileReader.java b/src/java/org/apache/cassandra/io/IFileReader.java index ee8cd977c4..1da11b2bcc 100644 --- a/src/java/org/apache/cassandra/io/IFileReader.java +++ b/src/java/org/apache/cassandra/io/IFileReader.java @@ -72,14 +72,8 @@ public interface IFileReader * @param columnFamilyName The name of the column family only without the ":" * @param columnNames - The list of columns in the cfName column family * that we want to return - * OR - * @param timeRange - time range we are interested in - * @param position - * @throws IOException - * @return number of bytes read. - * */ - public long next(String key, DataOutputBuffer bufOut, String columnFamilyName, SortedSet columnNames, IndexHelper.TimeRange timeRange, long position) throws IOException; + public long next(String key, DataOutputBuffer bufOut, String columnFamilyName, SortedSet columnNames, long position) throws IOException; /** * Close the file after reading. diff --git a/src/java/org/apache/cassandra/io/IndexHelper.java b/src/java/org/apache/cassandra/io/IndexHelper.java index 484554ca5b..70dca465d5 100644 --- a/src/java/org/apache/cassandra/io/IndexHelper.java +++ b/src/java/org/apache/cassandra/io/IndexHelper.java @@ -246,93 +246,7 @@ public class IndexHelper return columnRanges; } - - /** - * Returns the range in which a given column falls in the index. This - * is used when time range queries are in play. For instance if we are - * looking for columns in the range [t, t2] - * @param cIndexInfo the time we are interested in. - * @param columnIndexList the in-memory representation of the column index - * @param dataSize the total size of the data - * @param totalNumCols total number of columns - * @return an object describing a subrange in which the column is serialized - */ - static ColumnRange getColumnRangeFromTimeIndex(IndexHelper.TimeRange timeRange, List columnIndexList, int dataSize, int totalNumCols) - { - /* if column indexes were not present for this column family, the handle accordingly */ - if(columnIndexList.size() == 0) - { - return new ColumnRange(0, dataSize, totalNumCols); - } - - /* find the offset for the column */ - int size = columnIndexList.size(); - long start = 0; - long end = dataSize; - int numColumns = 0; - - /* - * Time indices are sorted in descending order. So - * we need to apply a reverse comparator for the - * binary search. - */ - Comparator comparator = Collections.reverseOrder(); - IndexHelper.ColumnIndexInfo rhs = IndexHelper.ColumnIndexFactory.instance(ColumnComparatorFactory.ComparatorType.TIMESTAMP); - rhs.set(timeRange.rhs()); - int index = Collections.binarySearch(columnIndexList, rhs, comparator); - if ( index < 0 ) - { - /* We are here which means that the requested column is not an index. */ - index = (++index)*(-1); - } - else - { - ++index; - } - - /* - * Calculate the starting offset from which we have to read. So - * we achieve this by performing the probe using the bigger timestamp - * and then scanning the column position chunks till we reach the - * lower timestamp in the time range. - */ - start = (index == 0) ? 0 : columnIndexList.get(index - 1).position(); - /* add the number of columns in the first chunk. */ - numColumns += (index ==0) ? columnIndexList.get(0).count() : columnIndexList.get(index - 1).count(); - if( index < size ) - { - int chunks = columnIndexList.size(); - /* Index info for the lower bound of the time range */ - IndexHelper.ColumnIndexInfo lhs = IndexHelper.ColumnIndexFactory.instance(ColumnComparatorFactory.ComparatorType.TIMESTAMP); - lhs.set(timeRange.lhs()); - int i = index + 1; - for ( ; i < chunks; ++i ) - { - IndexHelper.ColumnIndexInfo cIndexInfo2 = columnIndexList.get(i); - if ( cIndexInfo2.compareTo(lhs) < 0 ) - { - numColumns += cIndexInfo2.count(); - break; - } - numColumns += cIndexInfo2.count(); - } - - end = columnIndexList.get(i).position(); - } - else - { - end = dataSize; - int totalColsIndexed = 0; - for( IndexHelper.ColumnIndexInfo colPosInfo : columnIndexList ) - { - totalColsIndexed += colPosInfo.count(); - } - numColumns = totalNumCols - totalColsIndexed; - } - - return new ColumnRange(start, end, numColumns); - } - + public static class ColumnIndexFactory { public static ColumnIndexInfo instance(ColumnComparatorFactory.ComparatorType typeInfo) @@ -341,37 +255,8 @@ public class IndexHelper ? new ColumnNameIndexInfo() : new ColumnTimestampIndexInfo(); } } - - /** - * Encapsulates a time range. Queries use - * this abstraction for indicating start - * and end regions of a time filter. - * - * @author alakshman - * - */ - public static class TimeRange - { - private long lhs_; - private long rhs_; - - public TimeRange(long lhs, long rhs) - { - lhs_ = lhs; - rhs_ = rhs; - } - - public long lhs() - { - return lhs_; - } - - public long rhs() - { - return rhs_; - } - } - + + /** * A column range containing the start and end * offset of the appropriate column index chunk diff --git a/src/java/org/apache/cassandra/io/SSTableReader.java b/src/java/org/apache/cassandra/io/SSTableReader.java index 2f0d54bc89..9085ddf603 100644 --- a/src/java/org/apache/cassandra/io/SSTableReader.java +++ b/src/java/org/apache/cassandra/io/SSTableReader.java @@ -286,11 +286,6 @@ public class SSTableReader extends SSTable } public DataInputBuffer next(final String clientKey, String cfName, SortedSet columnNames) throws IOException - { - return next(clientKey, cfName, columnNames, null); - } - - public DataInputBuffer next(final String clientKey, String cfName, SortedSet columnNames, IndexHelper.TimeRange timeRange) throws IOException { IFileReader dataReader = null; try @@ -301,7 +296,7 @@ public class SSTableReader extends SSTable DataOutputBuffer bufOut = new DataOutputBuffer(); DataInputBuffer bufIn = new DataInputBuffer(); - long bytesRead = dataReader.next(decoratedKey, bufOut, cfName, columnNames, timeRange, position); + long bytesRead = dataReader.next(decoratedKey, bufOut, cfName, columnNames, position); if (bytesRead != -1L) { if (bufOut.getLength() > 0) diff --git a/src/java/org/apache/cassandra/io/SequenceFile.java b/src/java/org/apache/cassandra/io/SequenceFile.java index f4ec2db6db..2f30356adf 100644 --- a/src/java/org/apache/cassandra/io/SequenceFile.java +++ b/src/java/org/apache/cassandra/io/SequenceFile.java @@ -426,15 +426,8 @@ public class SequenceFile if (hasColumnIndexes) { String tableName = getTableName(); - if (DatabaseDescriptor.isNameSortingEnabled(tableName, cfName)) - { - /* read the index */ - totalBytesRead += IndexHelper.deserializeIndex(tableName, cfName, file_, columnIndexList); - } - else - { - totalBytesRead += IndexHelper.skipIndex(file_); - } + /* read the index */ + totalBytesRead += IndexHelper.deserializeIndex(tableName, cfName, file_, columnIndexList); } return totalBytesRead; } @@ -476,15 +469,10 @@ public class SequenceFile * @param bufOut DataOutputStream that needs to be filled. * @param columnFamilyName name of the columnFamily * @param columnNames columnNames we are interested in - * OR - * @param timeRange time range we are interested in - * @param position - * @return number of bytes that were read. - * @throws IOException */ - public long next(String key, DataOutputBuffer bufOut, String columnFamilyName, SortedSet columnNames, IndexHelper.TimeRange timeRange, long position) throws IOException + public long next(String key, DataOutputBuffer bufOut, String columnFamilyName, SortedSet columnNames, long position) throws IOException { - assert timeRange == null || columnNames == null; // at most one may be non-null + assert columnNames != null; long bytesRead = -1L; if (isEOF() || seekTo(position) < 0) @@ -510,11 +498,7 @@ public class SequenceFile */ if (keyInDisk.equals(key)) { - if (timeRange == null) { - readColumns(key, bufOut, columnFamilyName, columnNames); - } else { - readTimeRange(key, bufOut, columnFamilyName, timeRange); - } + readColumns(key, bufOut, columnFamilyName, columnNames); } else { @@ -530,70 +514,6 @@ public class SequenceFile return bytesRead; } - private void readTimeRange(String key, DataOutputBuffer bufOut, String columnFamilyName, IndexHelper.TimeRange timeRange) - throws IOException - { - int dataSize = file_.readInt(); - - /* write the key into buffer */ - bufOut.writeUTF(key); - - int bytesSkipped = IndexHelper.skipBloomFilter(file_); - /* - * read the correct number of bytes for the column family and - * write data into buffer. Subtract from dataSize the bloom - * filter size. - */ - dataSize -= bytesSkipped; - List columnIndexList = new ArrayList(); - /* Read the times indexes if present */ - int totalBytesRead = handleColumnTimeIndexes(columnFamilyName, columnIndexList); - dataSize -= totalBytesRead; - - /* read the column family name */ - String cfName = file_.readUTF(); - dataSize -= (utfPrefix_ + cfName.length()); - - String cfType = file_.readUTF(); - dataSize -= (utfPrefix_ + cfType.length()); - - int indexType = file_.readInt(); - dataSize -= 4; - - /* read local deletion time */ - int localDeletionTime = file_.readInt(); - dataSize -=4; - - /* read if this cf is marked for delete */ - long markedForDeleteAt = file_.readLong(); - dataSize -= 8; - - /* read the total number of columns */ - int totalNumCols = file_.readInt(); - dataSize -= 4; - - /* get the column range we have to read */ - IndexHelper.ColumnRange columnRange = IndexHelper.getColumnRangeFromTimeIndex(timeRange, columnIndexList, dataSize, totalNumCols); - - Coordinate coordinate = columnRange.coordinate(); - /* seek to the correct offset to the data, and calculate the data size */ - file_.skipBytes((int) coordinate.start_); - dataSize = (int) (coordinate.end_ - coordinate.start_); - - // returned data size - bufOut.writeInt(dataSize + utfPrefix_ * 2 + cfName.length() + cfType.length() + 4 + 4 + 8 + 4); - // echo back the CF data we read - bufOut.writeUTF(cfName); - bufOut.writeUTF(cfType); - bufOut.writeInt(indexType); - bufOut.writeInt(localDeletionTime); - bufOut.writeLong(markedForDeleteAt); - /* write number of columns */ - bufOut.writeInt(columnRange.count()); - /* now write the columns */ - bufOut.write(file_, dataSize); - } - private void readColumns(String key, DataOutputBuffer bufOut, String columnFamilyName, SortedSet cNames) throws IOException { diff --git a/src/java/org/apache/cassandra/service/CassandraServer.java b/src/java/org/apache/cassandra/service/CassandraServer.java index d3bc679a34..8d5e4c57d8 100644 --- a/src/java/org/apache/cassandra/service/CassandraServer.java +++ b/src/java/org/apache/cassandra/service/CassandraServer.java @@ -133,15 +133,6 @@ public class CassandraServer implements Cassandra.Iface return thriftifyColumns(cfamily.getAllColumns()); } - public List get_columns_since(String table, String key, ColumnParent column_parent, long timeStamp) - throws InvalidRequestException, NotFoundException - { - logger.debug("get_columns_since"); - ThriftValidation.validateColumnParent(table, column_parent); - return getSlice(new ColumnsSinceReadCommand(table, key, column_parent, timeStamp)); - } - - public List get_slice_by_names(String table, String key, ColumnParent column_parent, List column_names) throws InvalidRequestException, NotFoundException { @@ -221,15 +212,7 @@ public class CassandraServer implements Cassandra.Iface } ColumnFamily cfamily; - if (DatabaseDescriptor.isNameSortingEnabled(table, column_parent.column_family) - && column_parent.super_column == null) - { - cfamily = readColumnFamily(new SliceFromReadCommand(table, key, column_parent, "", "", true, Integer.MAX_VALUE)); - } - else - { - cfamily = readColumnFamily(new ColumnsSinceReadCommand(table, key, column_parent, Long.MIN_VALUE)); - } + cfamily = readColumnFamily(new SliceFromReadCommand(table, key, column_parent, "", "", true, Integer.MAX_VALUE)); if (cfamily == null) { return 0; diff --git a/test/unit/org/apache/cassandra/db/ReadMessageTest.java b/test/unit/org/apache/cassandra/db/ReadMessageTest.java index 169837abe2..5f1850f23d 100644 --- a/test/unit/org/apache/cassandra/db/ReadMessageTest.java +++ b/test/unit/org/apache/cassandra/db/ReadMessageTest.java @@ -46,10 +46,6 @@ public class ReadMessageTest rm2 = serializeAndDeserializeReadMessage(rm); assert rm2.toString().equals(rm.toString()); - rm = new ColumnsSinceReadCommand("Table1", "row1", new QueryPath("foo"), 1); - rm2 = serializeAndDeserializeReadMessage(rm); - assert rm2.toString().equals(rm.toString()); - rm = new SliceFromReadCommand("Table1", "row1", new QueryPath("foo"), "", "", true, 2); rm2 = serializeAndDeserializeReadMessage(rm); assert rm2.toString().equals(rm.toString()); diff --git a/test/unit/org/apache/cassandra/db/TimeSortTest.java b/test/unit/org/apache/cassandra/db/TimeSortTest.java deleted file mode 100644 index 21c0fb5e22..0000000000 --- a/test/unit/org/apache/cassandra/db/TimeSortTest.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.db; - -import java.io.IOException; -import java.util.concurrent.ExecutionException; -import java.util.SortedSet; -import java.util.Iterator; - -import org.apache.commons.lang.ArrayUtils; -import org.junit.Test; - -import org.apache.cassandra.CleanupHelper; -import org.apache.cassandra.db.filter.QueryPath; - -public class TimeSortTest extends CleanupHelper -{ - @Test - public void testMixedSources() throws IOException, ExecutionException, InterruptedException - { - Table table = Table.open("Table1"); - ColumnFamilyStore cfStore = table.getColumnFamilyStore("StandardByTime1"); - RowMutation rm; - - rm = new RowMutation("Table1", "key0"); - rm.add(new QueryPath("StandardByTime1", null, "C0"), "a".getBytes(), 100); - rm.apply(); - cfStore.forceBlockingFlush(); - - rm = new RowMutation("Table1", "key0"); - rm.add(new QueryPath("StandardByTime1", null, "C1"), "b".getBytes(), 0); - rm.apply(); - - ColumnFamily cf = cfStore.getColumnFamily("key0", new QueryPath("StandardByTime1"), 10); - SortedSet columns = cf.getAllColumns(); - assert columns.size() == 1; - } - - @Test - public void testTimeSort() throws IOException, ExecutionException, InterruptedException - { - Table table = Table.open("Table1"); - ColumnFamilyStore cfStore = table.getColumnFamilyStore("StandardByTime1"); - - for (int i = 900; i < 1000; ++i) - { - String key = Integer.toString(i); - RowMutation rm = new RowMutation("Table1", key); - for (int j = 0; j < 8; ++j) - { - byte[] bytes = j % 2 == 0 ? "a".getBytes() : "b".getBytes(); - rm.add(new QueryPath("StandardByTime1", null, "Column-" + j), bytes, j * 2); - } - rm.apply(); - } - - validateTimeSort(table); - - cfStore.forceBlockingFlush(); - validateTimeSort(table); - - // interleave some new data to test memtable + sstable - String key = "900"; - RowMutation rm = new RowMutation("Table1", key); - for (int j = 0; j < 4; ++j) - { - rm.add(new QueryPath("StandardByTime1", null, "Column+" + j), ArrayUtils.EMPTY_BYTE_ARRAY, j * 2 + 1); - } - rm.apply(); - // and some overwrites - rm = new RowMutation("Table1", key); - for (int j = 4; j < 8; ++j) - { - rm.add(new QueryPath("StandardByTime1", null, "Column-" + j), ArrayUtils.EMPTY_BYTE_ARRAY, j * 3); - } - rm.apply(); - // verify - ColumnFamily cf = cfStore.getColumnFamily(key, new QueryPath("StandardByTime1"), 0); - SortedSet columns = cf.getAllColumns(); - assert columns.size() == 12; - Iterator iter = columns.iterator(); - IColumn column; - for (int j = 7; j >= 4; j--) - { - column = iter.next(); - assert column.name().equals("Column-" + j); - assert column.timestamp() == j * 3; - assert column.value().length == 0; - } - for (int j = 3; j >= 0; j--) - { - column = iter.next(); - assert column.name().equals("Column+" + j); - column = iter.next(); - assert column.name().equals("Column-" + j); - } - } - - private void validateTimeSort(Table table) throws IOException - { - for (int i = 900; i < 1000; ++i) - { - String key = Integer.toString(i); - for (int j = 0; j < 8; j += 3) - { - ColumnFamily cf = table.getColumnFamilyStore("StandardByTime1").getColumnFamily(key, new QueryPath("StandardByTime1"), j * 2); - SortedSet columns = cf.getAllColumns(); - assert columns.size() == 8 - j; - int k = 7; - for (IColumn c : columns) - { - assert c.timestamp() == (k--) * 2; - } - } - } - } -}