diff --git a/CHANGES.txt b/CHANGES.txt index 03d2e699a7..74ee0e9046 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -56,6 +56,7 @@ * Make CFMetaData conversions to/from thrift/native schema inverses (CASSANDRA_3559) * Add initial code for CQL 3.0-beta (CASSANDRA-3781) + * Add wide row support for ColumnFamilyInputFormat (CASSANDRA-3264) 1.0.8 diff --git a/examples/hadoop_word_count/bin/word_count_counters b/examples/hadoop_word_count/bin/word_count_counters old mode 100644 new mode 100755 diff --git a/examples/hadoop_word_count/src/WordCount.java b/examples/hadoop_word_count/src/WordCount.java index e1c70bbd60..d3cee0e72a 100644 --- a/examples/hadoop_word_count/src/WordCount.java +++ b/examples/hadoop_word_count/src/WordCount.java @@ -25,8 +25,6 @@ import org.apache.cassandra.hadoop.ColumnFamilyOutputFormat; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import static com.google.common.base.Charsets.UTF_8; - import org.apache.cassandra.db.IColumn; import org.apache.cassandra.hadoop.ColumnFamilyInputFormat; import org.apache.cassandra.hadoop.ConfigHelper; @@ -81,22 +79,28 @@ public class WordCount extends Configured implements Tool protected void setup(org.apache.hadoop.mapreduce.Mapper.Context context) throws IOException, InterruptedException { - sourceColumn = ByteBufferUtil.bytes(context.getConfiguration().get(CONF_COLUMN_NAME)); } public void map(ByteBuffer key, SortedMap columns, Context context) throws IOException, InterruptedException { - IColumn column = columns.get(sourceColumn); - if (column == null) - return; - String value = ByteBufferUtil.string(column.value()); - logger.debug("read " + key + ":" + value + " from " + context.getInputSplit()); - - StringTokenizer itr = new StringTokenizer(value); - while (itr.hasMoreTokens()) + for (IColumn column : columns.values()) { - word.set(itr.nextToken()); - context.write(word, one); + String name = ByteBufferUtil.string(column.name()); + String value = null; + + if (name.contains("int")) + value = String.valueOf(ByteBufferUtil.toInt(column.value())); + else + value = ByteBufferUtil.string(column.value()); + + System.err.println("read " + ByteBufferUtil.string(key) + ":" +name + ":" + value + " from " + context.getInputSplit()); + + StringTokenizer itr = new StringTokenizer(value); + while (itr.hasMoreTokens()) + { + word.set(itr.nextToken()); + context.write(word, one); + } } } } @@ -155,10 +159,12 @@ public class WordCount extends Configured implements Tool } logger.info("output reducer type: " + outputReducerType); + // use a smaller page size that doesn't divide the row count evenly to exercise the paging logic better + ConfigHelper.setRangeBatchSize(getConf(), 99); + for (int i = 0; i < WordCountSetup.TEST_COUNT; i++) { String columnName = "text" + i; - getConf().set(CONF_COLUMN_NAME, columnName); Job job = new Job(getConf(), "wordcount"); job.setJarByClass(WordCount.class); @@ -184,6 +190,7 @@ public class WordCount extends Configured implements Tool job.setOutputFormatClass(ColumnFamilyOutputFormat.class); ConfigHelper.setOutputColumnFamily(job.getConfiguration(), KEYSPACE, OUTPUT_COLUMN_FAMILY); + job.getConfiguration().set(CONF_COLUMN_NAME, "sum"); } job.setInputFormatClass(ColumnFamilyInputFormat.class); @@ -194,12 +201,19 @@ public class WordCount extends Configured implements Tool ConfigHelper.setInputColumnFamily(job.getConfiguration(), KEYSPACE, COLUMN_FAMILY); SlicePredicate predicate = new SlicePredicate().setColumn_names(Arrays.asList(ByteBufferUtil.bytes(columnName))); ConfigHelper.setInputSlicePredicate(job.getConfiguration(), predicate); + if (i == 4) { IndexExpression expr = new IndexExpression(ByteBufferUtil.bytes("int4"), IndexOperator.EQ, ByteBufferUtil.bytes(0)); ConfigHelper.setInputRange(job.getConfiguration(), Arrays.asList(expr)); } + if (i == 5) + { + // this will cause the predicate to be ignored in favor of scanning everything as a wide row + ConfigHelper.setInputColumnFamily(job.getConfiguration(), KEYSPACE, COLUMN_FAMILY, true); + } + ConfigHelper.setOutputInitialAddress(job.getConfiguration(), "localhost"); ConfigHelper.setOutputPartitioner(job.getConfiguration(), "RandomPartitioner"); diff --git a/examples/hadoop_word_count/src/WordCountSetup.java b/examples/hadoop_word_count/src/WordCountSetup.java index 66476aa3ff..e8711b2800 100644 --- a/examples/hadoop_word_count/src/WordCountSetup.java +++ b/examples/hadoop_word_count/src/WordCountSetup.java @@ -36,7 +36,7 @@ public class WordCountSetup { private static final Logger logger = LoggerFactory.getLogger(WordCountSetup.class); - public static final int TEST_COUNT = 5; + public static final int TEST_COUNT = 6; public static void main(String[] args) throws Exception { diff --git a/interface/cassandra.thrift b/interface/cassandra.thrift index 08b776edcb..211c4c805b 100644 --- a/interface/cassandra.thrift +++ b/interface/cassandra.thrift @@ -46,7 +46,7 @@ namespace rb CassandraThrift # for every edit that doesn't result in a change to major/minor. # # See the Semantic Versioning Specification (SemVer) http://semver.org. -const string VERSION = "19.26.0" +const string VERSION = "19.27.0" # @@ -535,6 +535,15 @@ service Cassandra { 4:required ConsistencyLevel consistency_level=ConsistencyLevel.ONE) throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te), + /** + returns a range of columns, wrapping to the next rows if necessary to collect max_results. + */ + list get_paged_slice(1:required string column_family, + 2:required KeyRange range, + 3:required binary start_column, + 4:required ConsistencyLevel consistency_level=ConsistencyLevel.ONE) + throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te), + /** Returns the subset of columns specified in SlicePredicate for the rows matching the IndexClause @Deprecated; use get_range_slices instead with range.row_filter specified diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java index ca1a8c042e..406429b863 100644 --- a/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java +++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java @@ -112,9 +112,19 @@ public class Cassandra { */ public List get_range_slices(ColumnParent column_parent, SlicePredicate predicate, KeyRange range, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, org.apache.thrift.TException; + /** + * returns a range of columns, wrapping to the next rows if necessary to collect max_results. + * + * @param column_family + * @param range + * @param start_column + * @param consistency_level + */ + public List get_paged_slice(String column_family, KeyRange range, ByteBuffer start_column, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, org.apache.thrift.TException; + /** * Returns the subset of columns specified in SlicePredicate for the rows matching the IndexClause - * @Deprecated; use get_range_slices instead with row_filter specified + * @Deprecated; use get_range_slices instead with range.row_filter specified * * @param column_parent * @param index_clause @@ -349,6 +359,8 @@ public class Cassandra { public void get_range_slices(ColumnParent column_parent, SlicePredicate predicate, KeyRange range, ConsistencyLevel consistency_level, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void get_paged_slice(String column_family, KeyRange range, ByteBuffer start_column, ConsistencyLevel consistency_level, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + public void get_indexed_slices(ColumnParent column_parent, IndexClause index_clause, SlicePredicate column_predicate, ConsistencyLevel consistency_level, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; public void insert(ByteBuffer key, ColumnParent column_parent, Column column, ConsistencyLevel consistency_level, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; @@ -684,6 +696,41 @@ public class Cassandra { throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "get_range_slices failed: unknown result"); } + public List get_paged_slice(String column_family, KeyRange range, ByteBuffer start_column, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, org.apache.thrift.TException + { + send_get_paged_slice(column_family, range, start_column, consistency_level); + return recv_get_paged_slice(); + } + + public void send_get_paged_slice(String column_family, KeyRange range, ByteBuffer start_column, ConsistencyLevel consistency_level) throws org.apache.thrift.TException + { + get_paged_slice_args args = new get_paged_slice_args(); + args.setColumn_family(column_family); + args.setRange(range); + args.setStart_column(start_column); + args.setConsistency_level(consistency_level); + sendBase("get_paged_slice", args); + } + + public List recv_get_paged_slice() throws InvalidRequestException, UnavailableException, TimedOutException, org.apache.thrift.TException + { + get_paged_slice_result result = new get_paged_slice_result(); + receiveBase(result, "get_paged_slice"); + if (result.isSetSuccess()) { + return result.success; + } + if (result.ire != null) { + throw result.ire; + } + if (result.ue != null) { + throw result.ue; + } + if (result.te != null) { + throw result.te; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "get_paged_slice failed: unknown result"); + } + public List get_indexed_slices(ColumnParent column_parent, IndexClause index_clause, SlicePredicate column_predicate, ConsistencyLevel consistency_level) throws InvalidRequestException, UnavailableException, TimedOutException, org.apache.thrift.TException { send_get_indexed_slices(column_parent, index_clause, column_predicate, consistency_level); @@ -1748,6 +1795,47 @@ public class Cassandra { } } + public void get_paged_slice(String column_family, KeyRange range, ByteBuffer start_column, ConsistencyLevel consistency_level, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + get_paged_slice_call method_call = new get_paged_slice_call(column_family, range, start_column, consistency_level, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class get_paged_slice_call extends org.apache.thrift.async.TAsyncMethodCall { + private String column_family; + private KeyRange range; + private ByteBuffer start_column; + private ConsistencyLevel consistency_level; + public get_paged_slice_call(String column_family, KeyRange range, ByteBuffer start_column, ConsistencyLevel consistency_level, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.column_family = column_family; + this.range = range; + this.start_column = start_column; + this.consistency_level = consistency_level; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("get_paged_slice", org.apache.thrift.protocol.TMessageType.CALL, 0)); + get_paged_slice_args args = new get_paged_slice_args(); + args.setColumn_family(column_family); + args.setRange(range); + args.setStart_column(start_column); + args.setConsistency_level(consistency_level); + args.write(prot); + prot.writeMessageEnd(); + } + + public List getResult() throws InvalidRequestException, UnavailableException, TimedOutException, org.apache.thrift.TException { + if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_get_paged_slice(); + } + } + public void get_indexed_slices(ColumnParent column_parent, IndexClause index_clause, SlicePredicate column_predicate, ConsistencyLevel consistency_level, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { checkReady(); get_indexed_slices_call method_call = new get_indexed_slices_call(column_parent, index_clause, column_predicate, consistency_level, resultHandler, this, ___protocolFactory, ___transport); @@ -2646,6 +2734,7 @@ public class Cassandra { processMap.put("multiget_slice", new multiget_slice()); processMap.put("multiget_count", new multiget_count()); processMap.put("get_range_slices", new get_range_slices()); + processMap.put("get_paged_slice", new get_paged_slice()); processMap.put("get_indexed_slices", new get_indexed_slices()); processMap.put("insert", new insert()); processMap.put("add", new add()); @@ -2864,6 +2953,30 @@ public class Cassandra { } } + private static class get_paged_slice extends org.apache.thrift.ProcessFunction { + public get_paged_slice() { + super("get_paged_slice"); + } + + protected get_paged_slice_args getEmptyArgsInstance() { + return new get_paged_slice_args(); + } + + protected get_paged_slice_result getResult(I iface, get_paged_slice_args args) throws org.apache.thrift.TException { + get_paged_slice_result result = new get_paged_slice_result(); + try { + result.success = iface.get_paged_slice(args.column_family, args.range, args.start_column, args.consistency_level); + } catch (InvalidRequestException ire) { + result.ire = ire; + } catch (UnavailableException ue) { + result.ue = ue; + } catch (TimedOutException te) { + result.te = te; + } + return result; + } + } + private static class get_indexed_slices extends org.apache.thrift.ProcessFunction { public get_indexed_slices() { super("get_indexed_slices"); @@ -8413,6 +8526,8 @@ public class Cassandra { private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bit_vector = new BitSet(1); read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); @@ -12264,6 +12379,1258 @@ public class Cassandra { } + public static class get_paged_slice_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("get_paged_slice_args"); + + private static final org.apache.thrift.protocol.TField COLUMN_FAMILY_FIELD_DESC = new org.apache.thrift.protocol.TField("column_family", org.apache.thrift.protocol.TType.STRING, (short)1); + private static final org.apache.thrift.protocol.TField RANGE_FIELD_DESC = new org.apache.thrift.protocol.TField("range", org.apache.thrift.protocol.TType.STRUCT, (short)2); + private static final org.apache.thrift.protocol.TField START_COLUMN_FIELD_DESC = new org.apache.thrift.protocol.TField("start_column", org.apache.thrift.protocol.TType.STRING, (short)3); + private static final org.apache.thrift.protocol.TField CONSISTENCY_LEVEL_FIELD_DESC = new org.apache.thrift.protocol.TField("consistency_level", org.apache.thrift.protocol.TType.I32, (short)4); + + public String column_family; // required + public KeyRange range; // required + public ByteBuffer start_column; // required + /** + * + * @see ConsistencyLevel + */ + public ConsistencyLevel consistency_level; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + COLUMN_FAMILY((short)1, "column_family"), + RANGE((short)2, "range"), + START_COLUMN((short)3, "start_column"), + /** + * + * @see ConsistencyLevel + */ + CONSISTENCY_LEVEL((short)4, "consistency_level"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // COLUMN_FAMILY + return COLUMN_FAMILY; + case 2: // RANGE + return RANGE; + case 3: // START_COLUMN + return START_COLUMN; + case 4: // CONSISTENCY_LEVEL + return CONSISTENCY_LEVEL; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.COLUMN_FAMILY, new org.apache.thrift.meta_data.FieldMetaData("column_family", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + tmpMap.put(_Fields.RANGE, new org.apache.thrift.meta_data.FieldMetaData("range", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, KeyRange.class))); + tmpMap.put(_Fields.START_COLUMN, new org.apache.thrift.meta_data.FieldMetaData("start_column", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))); + tmpMap.put(_Fields.CONSISTENCY_LEVEL, new org.apache.thrift.meta_data.FieldMetaData("consistency_level", org.apache.thrift.TFieldRequirementType.REQUIRED, + new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, ConsistencyLevel.class))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(get_paged_slice_args.class, metaDataMap); + } + + public get_paged_slice_args() { + this.consistency_level = org.apache.cassandra.thrift.ConsistencyLevel.ONE; + + } + + public get_paged_slice_args( + String column_family, + KeyRange range, + ByteBuffer start_column, + ConsistencyLevel consistency_level) + { + this(); + this.column_family = column_family; + this.range = range; + this.start_column = start_column; + this.consistency_level = consistency_level; + } + + /** + * Performs a deep copy on other. + */ + public get_paged_slice_args(get_paged_slice_args other) { + if (other.isSetColumn_family()) { + this.column_family = other.column_family; + } + if (other.isSetRange()) { + this.range = new KeyRange(other.range); + } + if (other.isSetStart_column()) { + this.start_column = org.apache.thrift.TBaseHelper.copyBinary(other.start_column); +; + } + if (other.isSetConsistency_level()) { + this.consistency_level = other.consistency_level; + } + } + + public get_paged_slice_args deepCopy() { + return new get_paged_slice_args(this); + } + + @Override + public void clear() { + this.column_family = null; + this.range = null; + this.start_column = null; + this.consistency_level = org.apache.cassandra.thrift.ConsistencyLevel.ONE; + + } + + public String getColumn_family() { + return this.column_family; + } + + public get_paged_slice_args setColumn_family(String column_family) { + this.column_family = column_family; + return this; + } + + public void unsetColumn_family() { + this.column_family = null; + } + + /** Returns true if field column_family is set (has been assigned a value) and false otherwise */ + public boolean isSetColumn_family() { + return this.column_family != null; + } + + public void setColumn_familyIsSet(boolean value) { + if (!value) { + this.column_family = null; + } + } + + public KeyRange getRange() { + return this.range; + } + + public get_paged_slice_args setRange(KeyRange range) { + this.range = range; + return this; + } + + public void unsetRange() { + this.range = null; + } + + /** Returns true if field range is set (has been assigned a value) and false otherwise */ + public boolean isSetRange() { + return this.range != null; + } + + public void setRangeIsSet(boolean value) { + if (!value) { + this.range = null; + } + } + + public byte[] getStart_column() { + setStart_column(org.apache.thrift.TBaseHelper.rightSize(start_column)); + return start_column == null ? null : start_column.array(); + } + + public ByteBuffer bufferForStart_column() { + return start_column; + } + + public get_paged_slice_args setStart_column(byte[] start_column) { + setStart_column(start_column == null ? (ByteBuffer)null : ByteBuffer.wrap(start_column)); + return this; + } + + public get_paged_slice_args setStart_column(ByteBuffer start_column) { + this.start_column = start_column; + return this; + } + + public void unsetStart_column() { + this.start_column = null; + } + + /** Returns true if field start_column is set (has been assigned a value) and false otherwise */ + public boolean isSetStart_column() { + return this.start_column != null; + } + + public void setStart_columnIsSet(boolean value) { + if (!value) { + this.start_column = null; + } + } + + /** + * + * @see ConsistencyLevel + */ + public ConsistencyLevel getConsistency_level() { + return this.consistency_level; + } + + /** + * + * @see ConsistencyLevel + */ + public get_paged_slice_args setConsistency_level(ConsistencyLevel consistency_level) { + this.consistency_level = consistency_level; + return this; + } + + public void unsetConsistency_level() { + this.consistency_level = null; + } + + /** Returns true if field consistency_level is set (has been assigned a value) and false otherwise */ + public boolean isSetConsistency_level() { + return this.consistency_level != null; + } + + public void setConsistency_levelIsSet(boolean value) { + if (!value) { + this.consistency_level = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case COLUMN_FAMILY: + if (value == null) { + unsetColumn_family(); + } else { + setColumn_family((String)value); + } + break; + + case RANGE: + if (value == null) { + unsetRange(); + } else { + setRange((KeyRange)value); + } + break; + + case START_COLUMN: + if (value == null) { + unsetStart_column(); + } else { + setStart_column((ByteBuffer)value); + } + break; + + case CONSISTENCY_LEVEL: + if (value == null) { + unsetConsistency_level(); + } else { + setConsistency_level((ConsistencyLevel)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case COLUMN_FAMILY: + return getColumn_family(); + + case RANGE: + return getRange(); + + case START_COLUMN: + return getStart_column(); + + case CONSISTENCY_LEVEL: + return getConsistency_level(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case COLUMN_FAMILY: + return isSetColumn_family(); + case RANGE: + return isSetRange(); + case START_COLUMN: + return isSetStart_column(); + case CONSISTENCY_LEVEL: + return isSetConsistency_level(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof get_paged_slice_args) + return this.equals((get_paged_slice_args)that); + return false; + } + + public boolean equals(get_paged_slice_args that) { + if (that == null) + return false; + + boolean this_present_column_family = true && this.isSetColumn_family(); + boolean that_present_column_family = true && that.isSetColumn_family(); + if (this_present_column_family || that_present_column_family) { + if (!(this_present_column_family && that_present_column_family)) + return false; + if (!this.column_family.equals(that.column_family)) + return false; + } + + boolean this_present_range = true && this.isSetRange(); + boolean that_present_range = true && that.isSetRange(); + if (this_present_range || that_present_range) { + if (!(this_present_range && that_present_range)) + return false; + if (!this.range.equals(that.range)) + return false; + } + + boolean this_present_start_column = true && this.isSetStart_column(); + boolean that_present_start_column = true && that.isSetStart_column(); + if (this_present_start_column || that_present_start_column) { + if (!(this_present_start_column && that_present_start_column)) + return false; + if (!this.start_column.equals(that.start_column)) + return false; + } + + boolean this_present_consistency_level = true && this.isSetConsistency_level(); + boolean that_present_consistency_level = true && that.isSetConsistency_level(); + if (this_present_consistency_level || that_present_consistency_level) { + if (!(this_present_consistency_level && that_present_consistency_level)) + return false; + if (!this.consistency_level.equals(that.consistency_level)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_column_family = true && (isSetColumn_family()); + builder.append(present_column_family); + if (present_column_family) + builder.append(column_family); + + boolean present_range = true && (isSetRange()); + builder.append(present_range); + if (present_range) + builder.append(range); + + boolean present_start_column = true && (isSetStart_column()); + builder.append(present_start_column); + if (present_start_column) + builder.append(start_column); + + boolean present_consistency_level = true && (isSetConsistency_level()); + builder.append(present_consistency_level); + if (present_consistency_level) + builder.append(consistency_level.getValue()); + + return builder.toHashCode(); + } + + public int compareTo(get_paged_slice_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + get_paged_slice_args typedOther = (get_paged_slice_args)other; + + lastComparison = Boolean.valueOf(isSetColumn_family()).compareTo(typedOther.isSetColumn_family()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetColumn_family()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.column_family, typedOther.column_family); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetRange()).compareTo(typedOther.isSetRange()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetRange()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.range, typedOther.range); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetStart_column()).compareTo(typedOther.isSetStart_column()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetStart_column()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.start_column, typedOther.start_column); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetConsistency_level()).compareTo(typedOther.isSetConsistency_level()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetConsistency_level()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.consistency_level, typedOther.consistency_level); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField field; + iprot.readStructBegin(); + while (true) + { + field = iprot.readFieldBegin(); + if (field.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (field.id) { + case 1: // COLUMN_FAMILY + if (field.type == org.apache.thrift.protocol.TType.STRING) { + this.column_family = iprot.readString(); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 2: // RANGE + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.range = new KeyRange(); + this.range.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 3: // START_COLUMN + if (field.type == org.apache.thrift.protocol.TType.STRING) { + this.start_column = iprot.readBinary(); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 4: // CONSISTENCY_LEVEL + if (field.type == org.apache.thrift.protocol.TType.I32) { + this.consistency_level = ConsistencyLevel.findByValue(iprot.readI32()); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (this.column_family != null) { + oprot.writeFieldBegin(COLUMN_FAMILY_FIELD_DESC); + oprot.writeString(this.column_family); + oprot.writeFieldEnd(); + } + if (this.range != null) { + oprot.writeFieldBegin(RANGE_FIELD_DESC); + this.range.write(oprot); + oprot.writeFieldEnd(); + } + if (this.start_column != null) { + oprot.writeFieldBegin(START_COLUMN_FIELD_DESC); + oprot.writeBinary(this.start_column); + oprot.writeFieldEnd(); + } + if (this.consistency_level != null) { + oprot.writeFieldBegin(CONSISTENCY_LEVEL_FIELD_DESC); + oprot.writeI32(this.consistency_level.getValue()); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("get_paged_slice_args("); + boolean first = true; + + sb.append("column_family:"); + if (this.column_family == null) { + sb.append("null"); + } else { + sb.append(this.column_family); + } + first = false; + if (!first) sb.append(", "); + sb.append("range:"); + if (this.range == null) { + sb.append("null"); + } else { + sb.append(this.range); + } + first = false; + if (!first) sb.append(", "); + sb.append("start_column:"); + if (this.start_column == null) { + sb.append("null"); + } else { + org.apache.thrift.TBaseHelper.toString(this.start_column, sb); + } + first = false; + if (!first) sb.append(", "); + sb.append("consistency_level:"); + if (this.consistency_level == null) { + sb.append("null"); + } else { + sb.append(this.consistency_level); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + if (column_family == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'column_family' was not present! Struct: " + toString()); + } + if (range == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'range' was not present! Struct: " + toString()); + } + if (start_column == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'start_column' was not present! Struct: " + toString()); + } + if (consistency_level == null) { + throw new org.apache.thrift.protocol.TProtocolException("Required field 'consistency_level' was not present! Struct: " + toString()); + } + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + } + + public static class get_paged_slice_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("get_paged_slice_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.LIST, (short)0); + private static final org.apache.thrift.protocol.TField IRE_FIELD_DESC = new org.apache.thrift.protocol.TField("ire", org.apache.thrift.protocol.TType.STRUCT, (short)1); + private static final org.apache.thrift.protocol.TField UE_FIELD_DESC = new org.apache.thrift.protocol.TField("ue", org.apache.thrift.protocol.TType.STRUCT, (short)2); + private static final org.apache.thrift.protocol.TField TE_FIELD_DESC = new org.apache.thrift.protocol.TField("te", org.apache.thrift.protocol.TType.STRUCT, (short)3); + + public List success; // required + public InvalidRequestException ire; // required + public UnavailableException ue; // required + public TimedOutException te; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"), + IRE((short)1, "ire"), + UE((short)2, "ue"), + TE((short)3, "te"); + + private static final Map byName = new HashMap(); + + static { + for (_Fields field : EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + case 1: // IRE + return IRE; + case 2: // UE + return UE; + case 3: // TE + return TE; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + + public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, KeySlice.class)))); + tmpMap.put(_Fields.IRE, new org.apache.thrift.meta_data.FieldMetaData("ire", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + tmpMap.put(_Fields.UE, new org.apache.thrift.meta_data.FieldMetaData("ue", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + tmpMap.put(_Fields.TE, new org.apache.thrift.meta_data.FieldMetaData("te", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRUCT))); + metaDataMap = Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(get_paged_slice_result.class, metaDataMap); + } + + public get_paged_slice_result() { + } + + public get_paged_slice_result( + List success, + InvalidRequestException ire, + UnavailableException ue, + TimedOutException te) + { + this(); + this.success = success; + this.ire = ire; + this.ue = ue; + this.te = te; + } + + /** + * Performs a deep copy on other. + */ + public get_paged_slice_result(get_paged_slice_result other) { + if (other.isSetSuccess()) { + List __this__success = new ArrayList(); + for (KeySlice other_element : other.success) { + __this__success.add(new KeySlice(other_element)); + } + this.success = __this__success; + } + if (other.isSetIre()) { + this.ire = new InvalidRequestException(other.ire); + } + if (other.isSetUe()) { + this.ue = new UnavailableException(other.ue); + } + if (other.isSetTe()) { + this.te = new TimedOutException(other.te); + } + } + + public get_paged_slice_result deepCopy() { + return new get_paged_slice_result(this); + } + + @Override + public void clear() { + this.success = null; + this.ire = null; + this.ue = null; + this.te = null; + } + + 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(KeySlice elem) { + if (this.success == null) { + this.success = new ArrayList(); + } + this.success.add(elem); + } + + public List getSuccess() { + return this.success; + } + + public get_paged_slice_result setSuccess(List success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned 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 get_paged_slice_result setIre(InvalidRequestException ire) { + this.ire = ire; + return this; + } + + public void unsetIre() { + this.ire = null; + } + + /** Returns true if field ire is set (has been assigned a value) and false otherwise */ + public boolean isSetIre() { + return this.ire != null; + } + + public void setIreIsSet(boolean value) { + if (!value) { + this.ire = null; + } + } + + public UnavailableException getUe() { + return this.ue; + } + + public get_paged_slice_result setUe(UnavailableException ue) { + this.ue = ue; + return this; + } + + public void unsetUe() { + this.ue = null; + } + + /** Returns true if field ue is set (has been assigned a value) and false otherwise */ + public boolean isSetUe() { + return this.ue != null; + } + + public void setUeIsSet(boolean value) { + if (!value) { + this.ue = null; + } + } + + public TimedOutException getTe() { + return this.te; + } + + public get_paged_slice_result setTe(TimedOutException te) { + this.te = te; + return this; + } + + public void unsetTe() { + this.te = null; + } + + /** Returns true if field te is set (has been assigned a value) and false otherwise */ + public boolean isSetTe() { + return this.te != null; + } + + public void setTeIsSet(boolean value) { + if (!value) { + this.te = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((List)value); + } + break; + + case IRE: + if (value == null) { + unsetIre(); + } else { + setIre((InvalidRequestException)value); + } + break; + + case UE: + if (value == null) { + unsetUe(); + } else { + setUe((UnavailableException)value); + } + break; + + case TE: + if (value == null) { + unsetTe(); + } else { + setTe((TimedOutException)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + case IRE: + return getIre(); + + case UE: + return getUe(); + + case TE: + return getTe(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + case IRE: + return isSetIre(); + case UE: + return isSetUe(); + case TE: + return isSetTe(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof get_paged_slice_result) + return this.equals((get_paged_slice_result)that); + return false; + } + + public boolean equals(get_paged_slice_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_ue = true && this.isSetUe(); + boolean that_present_ue = true && that.isSetUe(); + if (this_present_ue || that_present_ue) { + if (!(this_present_ue && that_present_ue)) + return false; + if (!this.ue.equals(that.ue)) + return false; + } + + boolean this_present_te = true && this.isSetTe(); + boolean that_present_te = true && that.isSetTe(); + if (this_present_te || that_present_te) { + if (!(this_present_te && that_present_te)) + return false; + if (!this.te.equals(that.te)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + HashCodeBuilder builder = new HashCodeBuilder(); + + boolean present_success = true && (isSetSuccess()); + builder.append(present_success); + if (present_success) + builder.append(success); + + boolean present_ire = true && (isSetIre()); + builder.append(present_ire); + if (present_ire) + builder.append(ire); + + boolean present_ue = true && (isSetUe()); + builder.append(present_ue); + if (present_ue) + builder.append(ue); + + boolean present_te = true && (isSetTe()); + builder.append(present_te); + if (present_te) + builder.append(te); + + return builder.toHashCode(); + } + + public int compareTo(get_paged_slice_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + get_paged_slice_result typedOther = (get_paged_slice_result)other; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(typedOther.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, typedOther.success); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetIre()).compareTo(typedOther.isSetIre()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetIre()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ire, typedOther.ire); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetUe()).compareTo(typedOther.isSetUe()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetUe()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ue, typedOther.ue); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetTe()).compareTo(typedOther.isSetTe()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetTe()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.te, typedOther.te); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField field; + iprot.readStructBegin(); + while (true) + { + field = iprot.readFieldBegin(); + if (field.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (field.id) { + case 0: // SUCCESS + if (field.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list121 = iprot.readListBegin(); + this.success = new ArrayList(_list121.size); + for (int _i122 = 0; _i122 < _list121.size; ++_i122) + { + KeySlice _elem123; // required + _elem123 = new KeySlice(); + _elem123.read(iprot); + this.success.add(_elem123); + } + iprot.readListEnd(); + } + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 1: // IRE + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.ire = new InvalidRequestException(); + this.ire.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 2: // UE + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.ue = new UnavailableException(); + this.ue.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + case 3: // TE + if (field.type == org.apache.thrift.protocol.TType.STRUCT) { + this.te = new TimedOutException(); + this.te.read(iprot); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, field.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + oprot.writeStructBegin(STRUCT_DESC); + + if (this.isSetSuccess()) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.success.size())); + for (KeySlice _iter124 : this.success) + { + _iter124.write(oprot); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } else if (this.isSetIre()) { + oprot.writeFieldBegin(IRE_FIELD_DESC); + this.ire.write(oprot); + oprot.writeFieldEnd(); + } else if (this.isSetUe()) { + oprot.writeFieldBegin(UE_FIELD_DESC); + this.ue.write(oprot); + oprot.writeFieldEnd(); + } else if (this.isSetTe()) { + oprot.writeFieldBegin(TE_FIELD_DESC); + this.te.write(oprot); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("get_paged_slice_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("ue:"); + if (this.ue == null) { + sb.append("null"); + } else { + sb.append(this.ue); + } + first = false; + if (!first) sb.append(", "); + sb.append("te:"); + if (this.te == null) { + sb.append("null"); + } else { + sb.append(this.te); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + } + public static class get_indexed_slices_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable { private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("get_indexed_slices_args"); @@ -13364,14 +14731,14 @@ public class Cassandra { case 0: // SUCCESS if (field.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list121 = iprot.readListBegin(); - this.success = new ArrayList(_list121.size); - for (int _i122 = 0; _i122 < _list121.size; ++_i122) + org.apache.thrift.protocol.TList _list125 = iprot.readListBegin(); + this.success = new ArrayList(_list125.size); + for (int _i126 = 0; _i126 < _list125.size; ++_i126) { - KeySlice _elem123; // required - _elem123 = new KeySlice(); - _elem123.read(iprot); - this.success.add(_elem123); + KeySlice _elem127; // required + _elem127 = new KeySlice(); + _elem127.read(iprot); + this.success.add(_elem127); } iprot.readListEnd(); } @@ -13421,9 +14788,9 @@ public class Cassandra { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.success.size())); - for (KeySlice _iter124 : this.success) + for (KeySlice _iter128 : this.success) { - _iter124.write(oprot); + _iter128.write(oprot); } oprot.writeListEnd(); } @@ -16368,6 +17735,8 @@ public class Cassandra { private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bit_vector = new BitSet(1); read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); @@ -18266,38 +19635,38 @@ public class Cassandra { case 1: // MUTATION_MAP if (field.type == org.apache.thrift.protocol.TType.MAP) { { - org.apache.thrift.protocol.TMap _map125 = iprot.readMapBegin(); - this.mutation_map = new HashMap>>(2*_map125.size); - for (int _i126 = 0; _i126 < _map125.size; ++_i126) + org.apache.thrift.protocol.TMap _map129 = iprot.readMapBegin(); + this.mutation_map = new HashMap>>(2*_map129.size); + for (int _i130 = 0; _i130 < _map129.size; ++_i130) { - ByteBuffer _key127; // required - Map> _val128; // required - _key127 = iprot.readBinary(); + ByteBuffer _key131; // required + Map> _val132; // required + _key131 = iprot.readBinary(); { - org.apache.thrift.protocol.TMap _map129 = iprot.readMapBegin(); - _val128 = new HashMap>(2*_map129.size); - for (int _i130 = 0; _i130 < _map129.size; ++_i130) + org.apache.thrift.protocol.TMap _map133 = iprot.readMapBegin(); + _val132 = new HashMap>(2*_map133.size); + for (int _i134 = 0; _i134 < _map133.size; ++_i134) { - String _key131; // required - List _val132; // required - _key131 = iprot.readString(); + String _key135; // required + List _val136; // required + _key135 = iprot.readString(); { - org.apache.thrift.protocol.TList _list133 = iprot.readListBegin(); - _val132 = new ArrayList(_list133.size); - for (int _i134 = 0; _i134 < _list133.size; ++_i134) + org.apache.thrift.protocol.TList _list137 = iprot.readListBegin(); + _val136 = new ArrayList(_list137.size); + for (int _i138 = 0; _i138 < _list137.size; ++_i138) { - Mutation _elem135; // required - _elem135 = new Mutation(); - _elem135.read(iprot); - _val132.add(_elem135); + Mutation _elem139; // required + _elem139 = new Mutation(); + _elem139.read(iprot); + _val136.add(_elem139); } iprot.readListEnd(); } - _val128.put(_key131, _val132); + _val132.put(_key135, _val136); } iprot.readMapEnd(); } - this.mutation_map.put(_key127, _val128); + this.mutation_map.put(_key131, _val132); } iprot.readMapEnd(); } @@ -18331,19 +19700,19 @@ public class Cassandra { oprot.writeFieldBegin(MUTATION_MAP_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.MAP, this.mutation_map.size())); - for (Map.Entry>> _iter136 : this.mutation_map.entrySet()) + for (Map.Entry>> _iter140 : this.mutation_map.entrySet()) { - oprot.writeBinary(_iter136.getKey()); + oprot.writeBinary(_iter140.getKey()); { - oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.LIST, _iter136.getValue().size())); - for (Map.Entry> _iter137 : _iter136.getValue().entrySet()) + oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.LIST, _iter140.getValue().size())); + for (Map.Entry> _iter141 : _iter140.getValue().entrySet()) { - oprot.writeString(_iter137.getKey()); + oprot.writeString(_iter141.getKey()); { - oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, _iter137.getValue().size())); - for (Mutation _iter138 : _iter137.getValue()) + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, _iter141.getValue().size())); + for (Mutation _iter142 : _iter141.getValue()) { - _iter138.write(oprot); + _iter142.write(oprot); } oprot.writeListEnd(); } @@ -20252,25 +21621,25 @@ public class Cassandra { case 0: // SUCCESS if (field.type == org.apache.thrift.protocol.TType.MAP) { { - org.apache.thrift.protocol.TMap _map139 = iprot.readMapBegin(); - this.success = new HashMap>(2*_map139.size); - for (int _i140 = 0; _i140 < _map139.size; ++_i140) + org.apache.thrift.protocol.TMap _map143 = iprot.readMapBegin(); + this.success = new HashMap>(2*_map143.size); + for (int _i144 = 0; _i144 < _map143.size; ++_i144) { - String _key141; // required - List _val142; // required - _key141 = iprot.readString(); + String _key145; // required + List _val146; // required + _key145 = iprot.readString(); { - org.apache.thrift.protocol.TList _list143 = iprot.readListBegin(); - _val142 = new ArrayList(_list143.size); - for (int _i144 = 0; _i144 < _list143.size; ++_i144) + org.apache.thrift.protocol.TList _list147 = iprot.readListBegin(); + _val146 = new ArrayList(_list147.size); + for (int _i148 = 0; _i148 < _list147.size; ++_i148) { - String _elem145; // required - _elem145 = iprot.readString(); - _val142.add(_elem145); + String _elem149; // required + _elem149 = iprot.readString(); + _val146.add(_elem149); } iprot.readListEnd(); } - this.success.put(_key141, _val142); + this.success.put(_key145, _val146); } iprot.readMapEnd(); } @@ -20304,14 +21673,14 @@ public class Cassandra { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeMapBegin(new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.LIST, this.success.size())); - for (Map.Entry> _iter146 : this.success.entrySet()) + for (Map.Entry> _iter150 : this.success.entrySet()) { - oprot.writeString(_iter146.getKey()); + oprot.writeString(_iter150.getKey()); { - oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, _iter146.getValue().size())); - for (String _iter147 : _iter146.getValue()) + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, _iter150.getValue().size())); + for (String _iter151 : _iter150.getValue()) { - oprot.writeString(_iter147); + oprot.writeString(_iter151); } oprot.writeListEnd(); } @@ -20910,14 +22279,14 @@ public class Cassandra { case 0: // SUCCESS if (field.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list148 = iprot.readListBegin(); - this.success = new ArrayList(_list148.size); - for (int _i149 = 0; _i149 < _list148.size; ++_i149) + org.apache.thrift.protocol.TList _list152 = iprot.readListBegin(); + this.success = new ArrayList(_list152.size); + for (int _i153 = 0; _i153 < _list152.size; ++_i153) { - KsDef _elem150; // required - _elem150 = new KsDef(); - _elem150.read(iprot); - this.success.add(_elem150); + KsDef _elem154; // required + _elem154 = new KsDef(); + _elem154.read(iprot); + this.success.add(_elem154); } iprot.readListEnd(); } @@ -20951,9 +22320,9 @@ public class Cassandra { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.success.size())); - for (KsDef _iter151 : this.success) + for (KsDef _iter155 : this.success) { - _iter151.write(oprot); + _iter155.write(oprot); } oprot.writeListEnd(); } @@ -22666,14 +24035,14 @@ public class Cassandra { case 0: // SUCCESS if (field.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list152 = iprot.readListBegin(); - this.success = new ArrayList(_list152.size); - for (int _i153 = 0; _i153 < _list152.size; ++_i153) + org.apache.thrift.protocol.TList _list156 = iprot.readListBegin(); + this.success = new ArrayList(_list156.size); + for (int _i157 = 0; _i157 < _list156.size; ++_i157) { - TokenRange _elem154; // required - _elem154 = new TokenRange(); - _elem154.read(iprot); - this.success.add(_elem154); + TokenRange _elem158; // required + _elem158 = new TokenRange(); + _elem158.read(iprot); + this.success.add(_elem158); } iprot.readListEnd(); } @@ -22707,9 +24076,9 @@ public class Cassandra { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, this.success.size())); - for (TokenRange _iter155 : this.success) + for (TokenRange _iter159 : this.success) { - _iter155.write(oprot); + _iter159.write(oprot); } oprot.writeListEnd(); } @@ -25171,8 +26540,6 @@ public class Cassandra { private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bit_vector = new BitSet(1); read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); } catch (org.apache.thrift.TException te) { throw new java.io.IOException(te); @@ -25513,13 +26880,13 @@ public class Cassandra { case 0: // SUCCESS if (field.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list156 = iprot.readListBegin(); - this.success = new ArrayList(_list156.size); - for (int _i157 = 0; _i157 < _list156.size; ++_i157) + org.apache.thrift.protocol.TList _list160 = iprot.readListBegin(); + this.success = new ArrayList(_list160.size); + for (int _i161 = 0; _i161 < _list160.size; ++_i161) { - String _elem158; // required - _elem158 = iprot.readString(); - this.success.add(_elem158); + String _elem162; // required + _elem162 = iprot.readString(); + this.success.add(_elem162); } iprot.readListEnd(); } @@ -25553,9 +26920,9 @@ public class Cassandra { oprot.writeFieldBegin(SUCCESS_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, this.success.size())); - for (String _iter159 : this.success) + for (String _iter163 : this.success) { - oprot.writeString(_iter159); + oprot.writeString(_iter163); } oprot.writeListEnd(); } @@ -32692,13 +34059,13 @@ public class Cassandra { case 2: // VALUES if (field.type == org.apache.thrift.protocol.TType.LIST) { { - org.apache.thrift.protocol.TList _list160 = iprot.readListBegin(); - this.values = new ArrayList(_list160.size); - for (int _i161 = 0; _i161 < _list160.size; ++_i161) + org.apache.thrift.protocol.TList _list164 = iprot.readListBegin(); + this.values = new ArrayList(_list164.size); + for (int _i165 = 0; _i165 < _list164.size; ++_i165) { - ByteBuffer _elem162; // required - _elem162 = iprot.readBinary(); - this.values.add(_elem162); + ByteBuffer _elem166; // required + _elem166 = iprot.readBinary(); + this.values.add(_elem166); } iprot.readListEnd(); } @@ -32731,9 +34098,9 @@ public class Cassandra { oprot.writeFieldBegin(VALUES_FIELD_DESC); { oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRING, this.values.size())); - for (ByteBuffer _iter163 : this.values) + for (ByteBuffer _iter167 : this.values) { - oprot.writeBinary(_iter163); + oprot.writeBinary(_iter167); } oprot.writeListEnd(); } diff --git a/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java b/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java index be4e5aad2d..8227239eb1 100644 --- a/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java +++ b/interface/thrift/gen-java/org/apache/cassandra/thrift/Constants.java @@ -44,6 +44,6 @@ import org.slf4j.LoggerFactory; public class Constants { - public static final String VERSION = "19.26.0"; + public static final String VERSION = "19.27.0"; } diff --git a/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java b/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java index 46b767a6aa..e315cede40 100644 --- a/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java +++ b/src/java/org/apache/cassandra/hadoop/ColumnFamilyRecordReader.java @@ -30,6 +30,9 @@ import java.nio.ByteBuffer; import java.util.*; import com.google.common.collect.AbstractIterator; +import com.google.common.collect.ImmutableSortedMap; +import com.google.common.collect.Iterables; +import org.apache.commons.lang.ArrayUtils; import org.apache.cassandra.auth.IAuthenticator; import org.apache.cassandra.config.ConfigurationException; @@ -41,7 +44,6 @@ import org.apache.cassandra.thrift.*; import org.apache.cassandra.utils.ByteBufferUtil; import org.apache.cassandra.utils.FBUtilities; import org.apache.cassandra.utils.Pair; -import org.apache.commons.lang.ArrayUtils; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.mapreduce.InputSplit; import org.apache.hadoop.mapreduce.RecordReader; @@ -61,7 +63,7 @@ public class ColumnFamilyRecordReader extends RecordReader filter; + private boolean widerows; public ColumnFamilyRecordReader() { @@ -103,6 +106,7 @@ public class ColumnFamilyRecordReader extends RecordReader>> + private abstract class RowIterator extends AbstractIterator>> { - private List rows; - private String startToken; - private int totalRead = 0; - private int i = 0; - private final AbstractType comparator; - private final AbstractType subComparator; - private final IPartitioner partitioner; + protected List rows; + protected KeySlice lastRow; + protected int totalRead = 0; + protected int i = 0; + protected final AbstractType comparator; + protected final AbstractType subComparator; + protected final IPartitioner partitioner; private RowIterator() { @@ -264,81 +269,6 @@ public class ColumnFamilyRecordReader extends RecordReader= rows.size()) - rows = null; - - if (rows != null) - return; - - if (startToken == null) - { - startToken = split.getStartToken(); - } - else if (startToken.equals(split.getEndToken())) - { - // reached end of the split - rows = null; - return; - } - - KeyRange keyRange = new KeyRange(batchRowCount) - .setStart_token(startToken) - .setEnd_token(split.getEndToken()) - .setRow_filter(filter); - try - { - rows = client.get_range_slices(new ColumnParent(cfName), - predicate, - keyRange, - consistencyLevel); - - // nothing new? reached the end - if (rows.isEmpty()) - { - rows = null; - return; - } - - // prepare for the next slice to be read - KeySlice lastRow = rows.get(rows.size() - 1); - ByteBuffer rowkey = lastRow.key; - startToken = partitioner.getTokenFactory().toString(partitioner.getToken(rowkey)); - - // remove ghosts when fetching all columns - if (isEmptyPredicate) - { - Iterator it = rows.iterator(); - - while(it.hasNext()) - { - KeySlice ks = it.next(); - - if (ks.getColumnsSize() == 0) - { - it.remove(); - } - } - - // all ghosts, spooky - if (rows.isEmpty()) - { - maybeInit(); - return; - } - } - - // reset to iterate through this new batch - i = 0; - } - catch (Exception e) - { - throw new RuntimeException(e); - } - } - /** * @return total number of rows read by this record reader */ @@ -347,24 +277,7 @@ public class ColumnFamilyRecordReader extends RecordReader> computeNext() - { - maybeInit(); - if (rows == null) - return endOfData(); - - totalRead++; - KeySlice ks = rows.get(i++); - SortedMap map = new TreeMap(comparator); - for (ColumnOrSuperColumn cosc : ks.columns) - { - IColumn column = unthriftify(cosc); - map.put(column.name(), column); - } - return new Pair>(ks.key, map); - } - - private IColumn unthriftify(ColumnOrSuperColumn cosc) + protected IColumn unthriftify(ColumnOrSuperColumn cosc) { if (cosc.counter_column != null) return unthriftifyCounter(cosc.counter_column); @@ -407,6 +320,178 @@ public class ColumnFamilyRecordReader extends RecordReader= rows.size()) + rows = null; + + if (rows != null) + return; + + String startToken; + if (lastRow == null) + { + startToken = split.getStartToken(); + } + else + { + startToken = partitioner.getTokenFactory().toString(partitioner.getToken(lastRow.key)); + if (startToken.equals(split.getEndToken())) + { + // reached end of the split + rows = null; + return; + } + } + + KeyRange keyRange = new KeyRange(batchSize) + .setStart_token(startToken) + .setEnd_token(split.getEndToken()) + .setRow_filter(filter); + try + { + rows = client.get_range_slices(new ColumnParent(cfName), predicate, keyRange, consistencyLevel); + + // nothing new? reached the end + if (rows.isEmpty()) + { + rows = null; + return; + } + + // prepare for the next slice to be read + lastRow = Iterables.getLast(rows); + + // remove ghosts when fetching all columns + if (isEmptyPredicate) + { + Iterator it = rows.iterator(); + while (it.hasNext()) + { + KeySlice ks = it.next(); + if (ks.getColumnsSize() == 0) + { + it.remove(); + } + } + + // all ghosts, spooky + if (rows.isEmpty()) + { + maybeInit(); + return; + } + } + + // reset to iterate through this new batch + i = 0; + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + protected Pair> computeNext() + { + maybeInit(); + if (rows == null) + return endOfData(); + + totalRead++; + KeySlice ks = rows.get(i++); + SortedMap map = new TreeMap(comparator); + for (ColumnOrSuperColumn cosc : ks.columns) + { + IColumn column = unthriftify(cosc); + map.put(column.name(), column); + } + return new Pair>(ks.key, map); + } + } + + private class WideRowIterator extends RowIterator + { + private Iterator wideColumns; + + private void maybeInit() + { + if (wideColumns != null && wideColumns.hasNext()) + return; + + // check if we need another batch + if (rows != null && ++i >= rows.size()) + rows = null; + + if (rows != null) + { + wideColumns = rows.get(i).columns.iterator(); + return; + } + + String startToken; + ByteBuffer startColumn; + if (lastRow == null) + { + startToken = split.getStartToken(); + startColumn = ByteBufferUtil.EMPTY_BYTE_BUFFER; + } + else + { + startToken = partitioner.getTokenFactory().toString(partitioner.getToken(lastRow.key)); + startColumn = Iterables.getLast(lastRow.columns).column.name; + } + + KeyRange keyRange = new KeyRange(batchSize) + .setStart_token(startToken) + .setEnd_token(split.getEndToken()) + .setRow_filter(filter); + try + { + rows = client.get_paged_slice(cfName, keyRange, startColumn, consistencyLevel); + + // nothing found? + if (rows == null || rows.isEmpty() || rows.get(0).columns.isEmpty()) + { + rows = null; + return; + } + + // nothing new? reached the end + if (lastRow != null && (rows.get(0).key.equals(lastRow.key) || rows.get(0).columns.get(0).column.equals(startColumn))) + { + rows = null; + return; + } + + // prepare for the next slice to be read + lastRow = Iterables.getLast(rows); + + // reset to iterate through this new batch + i = 0; + wideColumns = rows.get(i).columns.iterator(); + } + catch (Exception e) + { + throw new RuntimeException(e); + } + } + + protected Pair> computeNext() + { + maybeInit(); + if (rows == null) + return endOfData(); + + totalRead++; + ColumnOrSuperColumn cosc = wideColumns.next(); + ImmutableSortedMap map = ImmutableSortedMap.of(cosc.column.name, unthriftify(cosc)); + return Pair.>create(rows.get(i).key, map); + } + } // Because the old Hadoop API wants us to write to the key and value // and the new asks for them, we need to copy the output of the new API diff --git a/src/java/org/apache/cassandra/hadoop/ConfigHelper.java b/src/java/org/apache/cassandra/hadoop/ConfigHelper.java index 810ac809cd..c83fbc547d 100644 --- a/src/java/org/apache/cassandra/hadoop/ConfigHelper.java +++ b/src/java/org/apache/cassandra/hadoop/ConfigHelper.java @@ -19,10 +19,14 @@ package org.apache.cassandra.hadoop; * under the License. * */ + import java.io.IOException; import java.util.ArrayList; import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import org.apache.cassandra.config.ConfigurationException; import org.apache.cassandra.dht.IPartitioner; import org.apache.cassandra.thrift.*; @@ -37,8 +41,6 @@ import org.apache.thrift.transport.TFramedTransport; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; import org.apache.thrift.transport.TTransportException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; public class ConfigHelper @@ -56,6 +58,7 @@ public class ConfigHelper private static final String INPUT_PREDICATE_CONFIG = "cassandra.input.predicate"; private static final String INPUT_KEYRANGE_CONFIG = "cassandra.input.keyRange"; private static final String INPUT_SPLIT_SIZE_CONFIG = "cassandra.input.split.size"; + private static final String INPUT_WIDEROWS_CONFIG = "cassandra.input.widerows"; private static final int DEFAULT_SPLIT_SIZE = 64 * 1024; private static final String RANGE_BATCH_SIZE_CONFIG = "cassandra.range.batch.size"; private static final int DEFAULT_RANGE_BATCH_SIZE = 4096; @@ -71,13 +74,13 @@ public class ConfigHelper /** * Set the keyspace and column family for the input of this job. - * Comparator and Partitioner types will be read from storage-conf.xml. * * @param conf Job configuration you are about to run * @param keyspace * @param columnFamily + * @param widerows */ - public static void setInputColumnFamily(Configuration conf, String keyspace, String columnFamily) + public static void setInputColumnFamily(Configuration conf, String keyspace, String columnFamily, boolean widerows) { if (keyspace == null) { @@ -90,6 +93,19 @@ public class ConfigHelper conf.set(INPUT_KEYSPACE_CONFIG, keyspace); conf.set(INPUT_COLUMNFAMILY_CONFIG, columnFamily); + conf.set(INPUT_WIDEROWS_CONFIG, String.valueOf(widerows)); + } + + /** + * Set the keyspace and column family for the input of this job. + * + * @param conf Job configuration you are about to run + * @param keyspace + * @param columnFamily + */ + public static void setInputColumnFamily(Configuration conf, String keyspace, String columnFamily) + { + setInputColumnFamily(conf, keyspace, columnFamily, false); } /** @@ -175,7 +191,7 @@ public class ConfigHelper { return predicateFromString(conf.get(INPUT_PREDICATE_CONFIG)); } - + public static String getRawInputSlicePredicate(Configuration conf) { return conf.get(INPUT_PREDICATE_CONFIG); @@ -299,6 +315,11 @@ public class ConfigHelper { return conf.get(INPUT_COLUMNFAMILY_CONFIG); } + + public static boolean getInputIsWide(Configuration conf) + { + return Boolean.valueOf(conf.get(INPUT_WIDEROWS_CONFIG)); + } public static String getOutputColumnFamily(Configuration conf) { diff --git a/src/java/org/apache/cassandra/thrift/CassandraServer.java b/src/java/org/apache/cassandra/thrift/CassandraServer.java index b84c3ce4dc..8aacea146b 100644 --- a/src/java/org/apache/cassandra/thrift/CassandraServer.java +++ b/src/java/org/apache/cassandra/thrift/CassandraServer.java @@ -711,6 +711,61 @@ public class CassandraServer implements Cassandra.Iface return thriftifyKeySlices(rows, column_parent, predicate); } + public List get_paged_slice(String column_family, KeyRange range, ByteBuffer start_column, ConsistencyLevel consistency_level) + throws InvalidRequestException, UnavailableException, TimedOutException, TException + { + logger.debug("get_paged_slice"); + + String keyspace = state().getKeyspace(); + state().hasColumnFamilyAccess(column_family, Permission.READ); + + CFMetaData metadata = ThriftValidation.validateColumnFamily(keyspace, column_family); + ThriftValidation.validateKeyRange(metadata, null, range); + ThriftValidation.validateConsistencyLevel(keyspace, consistency_level, RequestType.READ); + + SlicePredicate predicate = new SlicePredicate().setSlice_range(new SliceRange(start_column, ByteBufferUtil.EMPTY_BYTE_BUFFER, false, -1)); + + IPartitioner p = StorageService.getPartitioner(); + AbstractBounds bounds; + if (range.start_key == null) + { + Token.TokenFactory tokenFactory = p.getTokenFactory(); + Token left = tokenFactory.fromString(range.start_token); + Token right = tokenFactory.fromString(range.end_token); + bounds = Range.makeRowRange(left, right, p); + } + else + { + bounds = new Bounds(RowPosition.forKey(range.start_key, p), RowPosition.forKey(range.end_key, p)); + } + + List rows; + try + { + schedule(DatabaseDescriptor.getRpcTimeout()); + try + { + rows = StorageProxy.getRangeSlice(new RangeSliceCommand(keyspace, column_family, null, predicate, bounds, range.row_filter, range.count, true), consistency_level); + } + finally + { + release(); + } + assert rows != null; + } + catch (TimeoutException e) + { + logger.debug("... timed out"); + throw new TimedOutException(); + } + catch (IOException e) + { + throw new RuntimeException(e); + } + + return thriftifyKeySlices(rows, new ColumnParent(column_family), predicate); + } + private List thriftifyKeySlices(List rows, ColumnParent column_parent, SlicePredicate predicate) { List keySlices = new ArrayList(rows.size());