Backport MultiSliceRequest

Patch by Ed Capriolo; Reviewed by tjake for CASSANDRA-7027
This commit is contained in:
Jake Luciani 2014-05-27 11:27:17 -04:00
parent 4a295b6bee
commit 7f63b1f958
9 changed files with 3765 additions and 639 deletions

View File

@ -25,6 +25,7 @@
* Fix broken paging state with prepared statement (CASSANDRA-7120)
* Fix IllegalArgumentException in CqlStorage (CASSANDRA-7287)
* Allow nulls/non-existant fields in UDT (CASSANDRA-7206)
* Backport Thrift MultiSliceRequest (CASSANDRA-7027)
Merged from 2.0:
* Copy compaction options to make sure they are reloaded (CASSANDRA-7290)
* Add option to do more aggressive tombstone compactions (CASSANDRA-6563)

View File

@ -117,7 +117,6 @@ struct ColumnOrSuperColumn {
4: optional CounterSuperColumn counter_super_column
}
#
# Exceptions
# (note that internal server errors will raise a TApplicationException, courtesy of Thrift)
@ -571,6 +570,35 @@ struct CfSplit {
3: required i64 row_count
}
/** The ColumnSlice is used to select a set of columns from inside a row.
* If start or finish are unspecified they will default to the start-of
* end-of value.
* @param start. The start of the ColumnSlice inclusive
* @param finish. The end of the ColumnSlice inclusive
*/
struct ColumnSlice {
1: optional binary start,
2: optional binary finish
}
/**
* Used to perform multiple slices on a single row key in one rpc operation
* @param key. The row key to be multi sliced
* @param column_parent. The column family (super columns are unsupported)
* @param column_slices. 0 to many ColumnSlice objects each will be used to select columns
* @param reversed. Direction of slice
* @param count. Maximum number of columns
* @param consistency_level. Level to perform the operation at
*/
struct MultiSliceRequest {
1: optional binary key,
2: optional ColumnParent column_parent,
3: optional list<ColumnSlice> column_slices,
4: optional bool reversed=false,
5: optional i32 count=1000,
6: optional ConsistencyLevel consistency_level=ConsistencyLevel.ONE
}
service Cassandra {
# auth methods
void login(1: required AuthenticationRequest auth_request) throws (1:AuthenticationException authnx, 2:AuthorizationException authzx),
@ -749,6 +777,11 @@ service Cassandra {
void truncate(1:required string cfname)
throws (1: InvalidRequestException ire, 2: UnavailableException ue, 3: TimedOutException te),
/**
* Select multiple slices of a key in a single RPC operation
*/
list<ColumnOrSuperColumn> get_multi_slice(1:required MultiSliceRequest request)
throws (1:InvalidRequestException ire, 2:UnavailableException ue, 3:TimedOutException te),
// Meta-APIs -- APIs to get information about the node or cluster,

View File

@ -78,7 +78,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
private static final org.apache.thrift.protocol.TField BLOOM_FILTER_FP_CHANCE_FIELD_DESC = new org.apache.thrift.protocol.TField("bloom_filter_fp_chance", org.apache.thrift.protocol.TType.DOUBLE, (short)33);
private static final org.apache.thrift.protocol.TField CACHING_FIELD_DESC = new org.apache.thrift.protocol.TField("caching", org.apache.thrift.protocol.TType.STRING, (short)34);
private static final org.apache.thrift.protocol.TField DCLOCAL_READ_REPAIR_CHANCE_FIELD_DESC = new org.apache.thrift.protocol.TField("dclocal_read_repair_chance", org.apache.thrift.protocol.TType.DOUBLE, (short)37);
private static final org.apache.thrift.protocol.TField POPULATE_IO_CACHE_ON_FLUSH_FIELD_DESC = new org.apache.thrift.protocol.TField("populate_io_cache_on_flush", org.apache.thrift.protocol.TType.BOOL, (short)38);
private static final org.apache.thrift.protocol.TField MEMTABLE_FLUSH_PERIOD_IN_MS_FIELD_DESC = new org.apache.thrift.protocol.TField("memtable_flush_period_in_ms", org.apache.thrift.protocol.TType.I32, (short)39);
private static final org.apache.thrift.protocol.TField DEFAULT_TIME_TO_LIVE_FIELD_DESC = new org.apache.thrift.protocol.TField("default_time_to_live", org.apache.thrift.protocol.TType.I32, (short)40);
private static final org.apache.thrift.protocol.TField SPECULATIVE_RETRY_FIELD_DESC = new org.apache.thrift.protocol.TField("speculative_retry", org.apache.thrift.protocol.TType.STRING, (short)42);
@ -97,6 +96,7 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
private static final org.apache.thrift.protocol.TField MERGE_SHARDS_CHANCE_FIELD_DESC = new org.apache.thrift.protocol.TField("merge_shards_chance", org.apache.thrift.protocol.TType.DOUBLE, (short)25);
private static final org.apache.thrift.protocol.TField ROW_CACHE_PROVIDER_FIELD_DESC = new org.apache.thrift.protocol.TField("row_cache_provider", org.apache.thrift.protocol.TType.STRING, (short)27);
private static final org.apache.thrift.protocol.TField ROW_CACHE_KEYS_TO_SAVE_FIELD_DESC = new org.apache.thrift.protocol.TField("row_cache_keys_to_save", org.apache.thrift.protocol.TType.I32, (short)31);
private static final org.apache.thrift.protocol.TField POPULATE_IO_CACHE_ON_FLUSH_FIELD_DESC = new org.apache.thrift.protocol.TField("populate_io_cache_on_flush", org.apache.thrift.protocol.TType.BOOL, (short)38);
private static final org.apache.thrift.protocol.TField INDEX_INTERVAL_FIELD_DESC = new org.apache.thrift.protocol.TField("index_interval", org.apache.thrift.protocol.TType.I32, (short)41);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
@ -126,7 +126,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
public double bloom_filter_fp_chance; // optional
public String caching; // optional
public double dclocal_read_repair_chance; // optional
public boolean populate_io_cache_on_flush; // optional
public int memtable_flush_period_in_ms; // optional
public int default_time_to_live; // optional
public String speculative_retry; // optional
@ -178,6 +177,10 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
* @deprecated
*/
public int row_cache_keys_to_save; // optional
/**
* @deprecated
*/
public boolean populate_io_cache_on_flush; // optional
/**
* @deprecated
*/
@ -206,7 +209,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
BLOOM_FILTER_FP_CHANCE((short)33, "bloom_filter_fp_chance"),
CACHING((short)34, "caching"),
DCLOCAL_READ_REPAIR_CHANCE((short)37, "dclocal_read_repair_chance"),
POPULATE_IO_CACHE_ON_FLUSH((short)38, "populate_io_cache_on_flush"),
MEMTABLE_FLUSH_PERIOD_IN_MS((short)39, "memtable_flush_period_in_ms"),
DEFAULT_TIME_TO_LIVE((short)40, "default_time_to_live"),
SPECULATIVE_RETRY((short)42, "speculative_retry"),
@ -258,6 +260,10 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
* @deprecated
*/
ROW_CACHE_KEYS_TO_SAVE((short)31, "row_cache_keys_to_save"),
/**
* @deprecated
*/
POPULATE_IO_CACHE_ON_FLUSH((short)38, "populate_io_cache_on_flush"),
/**
* @deprecated
*/
@ -318,8 +324,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
return CACHING;
case 37: // DCLOCAL_READ_REPAIR_CHANCE
return DCLOCAL_READ_REPAIR_CHANCE;
case 38: // POPULATE_IO_CACHE_ON_FLUSH
return POPULATE_IO_CACHE_ON_FLUSH;
case 39: // MEMTABLE_FLUSH_PERIOD_IN_MS
return MEMTABLE_FLUSH_PERIOD_IN_MS;
case 40: // DEFAULT_TIME_TO_LIVE
@ -356,6 +360,8 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
return ROW_CACHE_PROVIDER;
case 31: // ROW_CACHE_KEYS_TO_SAVE
return ROW_CACHE_KEYS_TO_SAVE;
case 38: // POPULATE_IO_CACHE_ON_FLUSH
return POPULATE_IO_CACHE_ON_FLUSH;
case 41: // INDEX_INTERVAL
return INDEX_INTERVAL;
default:
@ -405,24 +411,24 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
private static final int __MAX_COMPACTION_THRESHOLD_ISSET_ID = 4;
private static final int __BLOOM_FILTER_FP_CHANCE_ISSET_ID = 5;
private static final int __DCLOCAL_READ_REPAIR_CHANCE_ISSET_ID = 6;
private static final int __POPULATE_IO_CACHE_ON_FLUSH_ISSET_ID = 7;
private static final int __MEMTABLE_FLUSH_PERIOD_IN_MS_ISSET_ID = 8;
private static final int __DEFAULT_TIME_TO_LIVE_ISSET_ID = 9;
private static final int __MIN_INDEX_INTERVAL_ISSET_ID = 10;
private static final int __MAX_INDEX_INTERVAL_ISSET_ID = 11;
private static final int __ROW_CACHE_SIZE_ISSET_ID = 12;
private static final int __KEY_CACHE_SIZE_ISSET_ID = 13;
private static final int __ROW_CACHE_SAVE_PERIOD_IN_SECONDS_ISSET_ID = 14;
private static final int __KEY_CACHE_SAVE_PERIOD_IN_SECONDS_ISSET_ID = 15;
private static final int __MEMTABLE_FLUSH_AFTER_MINS_ISSET_ID = 16;
private static final int __MEMTABLE_THROUGHPUT_IN_MB_ISSET_ID = 17;
private static final int __MEMTABLE_OPERATIONS_IN_MILLIONS_ISSET_ID = 18;
private static final int __REPLICATE_ON_WRITE_ISSET_ID = 19;
private static final int __MERGE_SHARDS_CHANCE_ISSET_ID = 20;
private static final int __ROW_CACHE_KEYS_TO_SAVE_ISSET_ID = 21;
private static final int __MEMTABLE_FLUSH_PERIOD_IN_MS_ISSET_ID = 7;
private static final int __DEFAULT_TIME_TO_LIVE_ISSET_ID = 8;
private static final int __MIN_INDEX_INTERVAL_ISSET_ID = 9;
private static final int __MAX_INDEX_INTERVAL_ISSET_ID = 10;
private static final int __ROW_CACHE_SIZE_ISSET_ID = 11;
private static final int __KEY_CACHE_SIZE_ISSET_ID = 12;
private static final int __ROW_CACHE_SAVE_PERIOD_IN_SECONDS_ISSET_ID = 13;
private static final int __KEY_CACHE_SAVE_PERIOD_IN_SECONDS_ISSET_ID = 14;
private static final int __MEMTABLE_FLUSH_AFTER_MINS_ISSET_ID = 15;
private static final int __MEMTABLE_THROUGHPUT_IN_MB_ISSET_ID = 16;
private static final int __MEMTABLE_OPERATIONS_IN_MILLIONS_ISSET_ID = 17;
private static final int __REPLICATE_ON_WRITE_ISSET_ID = 18;
private static final int __MERGE_SHARDS_CHANCE_ISSET_ID = 19;
private static final int __ROW_CACHE_KEYS_TO_SAVE_ISSET_ID = 20;
private static final int __POPULATE_IO_CACHE_ON_FLUSH_ISSET_ID = 21;
private static final int __INDEX_INTERVAL_ISSET_ID = 22;
private int __isset_bitfield = 0;
private _Fields optionals[] = {_Fields.COLUMN_TYPE,_Fields.COMPARATOR_TYPE,_Fields.SUBCOMPARATOR_TYPE,_Fields.COMMENT,_Fields.READ_REPAIR_CHANCE,_Fields.COLUMN_METADATA,_Fields.GC_GRACE_SECONDS,_Fields.DEFAULT_VALIDATION_CLASS,_Fields.ID,_Fields.MIN_COMPACTION_THRESHOLD,_Fields.MAX_COMPACTION_THRESHOLD,_Fields.KEY_VALIDATION_CLASS,_Fields.KEY_ALIAS,_Fields.COMPACTION_STRATEGY,_Fields.COMPACTION_STRATEGY_OPTIONS,_Fields.COMPRESSION_OPTIONS,_Fields.BLOOM_FILTER_FP_CHANCE,_Fields.CACHING,_Fields.DCLOCAL_READ_REPAIR_CHANCE,_Fields.POPULATE_IO_CACHE_ON_FLUSH,_Fields.MEMTABLE_FLUSH_PERIOD_IN_MS,_Fields.DEFAULT_TIME_TO_LIVE,_Fields.SPECULATIVE_RETRY,_Fields.TRIGGERS,_Fields.CELLS_PER_ROW_TO_CACHE,_Fields.MIN_INDEX_INTERVAL,_Fields.MAX_INDEX_INTERVAL,_Fields.ROW_CACHE_SIZE,_Fields.KEY_CACHE_SIZE,_Fields.ROW_CACHE_SAVE_PERIOD_IN_SECONDS,_Fields.KEY_CACHE_SAVE_PERIOD_IN_SECONDS,_Fields.MEMTABLE_FLUSH_AFTER_MINS,_Fields.MEMTABLE_THROUGHPUT_IN_MB,_Fields.MEMTABLE_OPERATIONS_IN_MILLIONS,_Fields.REPLICATE_ON_WRITE,_Fields.MERGE_SHARDS_CHANCE,_Fields.ROW_CACHE_PROVIDER,_Fields.ROW_CACHE_KEYS_TO_SAVE,_Fields.INDEX_INTERVAL};
private _Fields optionals[] = {_Fields.COLUMN_TYPE,_Fields.COMPARATOR_TYPE,_Fields.SUBCOMPARATOR_TYPE,_Fields.COMMENT,_Fields.READ_REPAIR_CHANCE,_Fields.COLUMN_METADATA,_Fields.GC_GRACE_SECONDS,_Fields.DEFAULT_VALIDATION_CLASS,_Fields.ID,_Fields.MIN_COMPACTION_THRESHOLD,_Fields.MAX_COMPACTION_THRESHOLD,_Fields.KEY_VALIDATION_CLASS,_Fields.KEY_ALIAS,_Fields.COMPACTION_STRATEGY,_Fields.COMPACTION_STRATEGY_OPTIONS,_Fields.COMPRESSION_OPTIONS,_Fields.BLOOM_FILTER_FP_CHANCE,_Fields.CACHING,_Fields.DCLOCAL_READ_REPAIR_CHANCE,_Fields.MEMTABLE_FLUSH_PERIOD_IN_MS,_Fields.DEFAULT_TIME_TO_LIVE,_Fields.SPECULATIVE_RETRY,_Fields.TRIGGERS,_Fields.CELLS_PER_ROW_TO_CACHE,_Fields.MIN_INDEX_INTERVAL,_Fields.MAX_INDEX_INTERVAL,_Fields.ROW_CACHE_SIZE,_Fields.KEY_CACHE_SIZE,_Fields.ROW_CACHE_SAVE_PERIOD_IN_SECONDS,_Fields.KEY_CACHE_SAVE_PERIOD_IN_SECONDS,_Fields.MEMTABLE_FLUSH_AFTER_MINS,_Fields.MEMTABLE_THROUGHPUT_IN_MB,_Fields.MEMTABLE_OPERATIONS_IN_MILLIONS,_Fields.REPLICATE_ON_WRITE,_Fields.MERGE_SHARDS_CHANCE,_Fields.ROW_CACHE_PROVIDER,_Fields.ROW_CACHE_KEYS_TO_SAVE,_Fields.POPULATE_IO_CACHE_ON_FLUSH,_Fields.INDEX_INTERVAL};
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);
@ -473,8 +479,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.DCLOCAL_READ_REPAIR_CHANCE, new org.apache.thrift.meta_data.FieldMetaData("dclocal_read_repair_chance", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
tmpMap.put(_Fields.POPULATE_IO_CACHE_ON_FLUSH, new org.apache.thrift.meta_data.FieldMetaData("populate_io_cache_on_flush", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.MEMTABLE_FLUSH_PERIOD_IN_MS, new org.apache.thrift.meta_data.FieldMetaData("memtable_flush_period_in_ms", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.DEFAULT_TIME_TO_LIVE, new org.apache.thrift.meta_data.FieldMetaData("default_time_to_live", org.apache.thrift.TFieldRequirementType.OPTIONAL,
@ -512,6 +516,8 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.ROW_CACHE_KEYS_TO_SAVE, new org.apache.thrift.meta_data.FieldMetaData("row_cache_keys_to_save", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.POPULATE_IO_CACHE_ON_FLUSH, new org.apache.thrift.meta_data.FieldMetaData("populate_io_cache_on_flush", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.INDEX_INTERVAL, new org.apache.thrift.meta_data.FieldMetaData("index_interval", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
@ -603,7 +609,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
this.caching = other.caching;
}
this.dclocal_read_repair_chance = other.dclocal_read_repair_chance;
this.populate_io_cache_on_flush = other.populate_io_cache_on_flush;
this.memtable_flush_period_in_ms = other.memtable_flush_period_in_ms;
this.default_time_to_live = other.default_time_to_live;
if (other.isSetSpeculative_retry()) {
@ -634,6 +639,7 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
this.row_cache_provider = other.row_cache_provider;
}
this.row_cache_keys_to_save = other.row_cache_keys_to_save;
this.populate_io_cache_on_flush = other.populate_io_cache_on_flush;
this.index_interval = other.index_interval;
}
@ -674,8 +680,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
this.dclocal_read_repair_chance = 0;
setPopulate_io_cache_on_flushIsSet(false);
this.populate_io_cache_on_flush = false;
setMemtable_flush_period_in_msIsSet(false);
this.memtable_flush_period_in_ms = 0;
setDefault_time_to_liveIsSet(false);
@ -710,6 +714,8 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
this.row_cache_provider = null;
setRow_cache_keys_to_saveIsSet(false);
this.row_cache_keys_to_save = 0;
setPopulate_io_cache_on_flushIsSet(false);
this.populate_io_cache_on_flush = false;
setIndex_intervalIsSet(false);
this.index_interval = 0;
}
@ -1258,29 +1264,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __DCLOCAL_READ_REPAIR_CHANCE_ISSET_ID, value);
}
public boolean isPopulate_io_cache_on_flush() {
return this.populate_io_cache_on_flush;
}
public CfDef setPopulate_io_cache_on_flush(boolean populate_io_cache_on_flush) {
this.populate_io_cache_on_flush = populate_io_cache_on_flush;
setPopulate_io_cache_on_flushIsSet(true);
return this;
}
public void unsetPopulate_io_cache_on_flush() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __POPULATE_IO_CACHE_ON_FLUSH_ISSET_ID);
}
/** Returns true if field populate_io_cache_on_flush is set (has been assigned a value) and false otherwise */
public boolean isSetPopulate_io_cache_on_flush() {
return EncodingUtils.testBit(__isset_bitfield, __POPULATE_IO_CACHE_ON_FLUSH_ISSET_ID);
}
public void setPopulate_io_cache_on_flushIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __POPULATE_IO_CACHE_ON_FLUSH_ISSET_ID, value);
}
public int getMemtable_flush_period_in_ms() {
return this.memtable_flush_period_in_ms;
}
@ -1780,6 +1763,35 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __ROW_CACHE_KEYS_TO_SAVE_ISSET_ID, value);
}
/**
* @deprecated
*/
public boolean isPopulate_io_cache_on_flush() {
return this.populate_io_cache_on_flush;
}
/**
* @deprecated
*/
public CfDef setPopulate_io_cache_on_flush(boolean populate_io_cache_on_flush) {
this.populate_io_cache_on_flush = populate_io_cache_on_flush;
setPopulate_io_cache_on_flushIsSet(true);
return this;
}
public void unsetPopulate_io_cache_on_flush() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __POPULATE_IO_CACHE_ON_FLUSH_ISSET_ID);
}
/** Returns true if field populate_io_cache_on_flush is set (has been assigned a value) and false otherwise */
public boolean isSetPopulate_io_cache_on_flush() {
return EncodingUtils.testBit(__isset_bitfield, __POPULATE_IO_CACHE_ON_FLUSH_ISSET_ID);
}
public void setPopulate_io_cache_on_flushIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __POPULATE_IO_CACHE_ON_FLUSH_ISSET_ID, value);
}
/**
* @deprecated
*/
@ -1979,14 +1991,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
}
break;
case POPULATE_IO_CACHE_ON_FLUSH:
if (value == null) {
unsetPopulate_io_cache_on_flush();
} else {
setPopulate_io_cache_on_flush((Boolean)value);
}
break;
case MEMTABLE_FLUSH_PERIOD_IN_MS:
if (value == null) {
unsetMemtable_flush_period_in_ms();
@ -2131,6 +2135,14 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
}
break;
case POPULATE_IO_CACHE_ON_FLUSH:
if (value == null) {
unsetPopulate_io_cache_on_flush();
} else {
setPopulate_io_cache_on_flush((Boolean)value);
}
break;
case INDEX_INTERVAL:
if (value == null) {
unsetIndex_interval();
@ -2207,9 +2219,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
case DCLOCAL_READ_REPAIR_CHANCE:
return Double.valueOf(getDclocal_read_repair_chance());
case POPULATE_IO_CACHE_ON_FLUSH:
return Boolean.valueOf(isPopulate_io_cache_on_flush());
case MEMTABLE_FLUSH_PERIOD_IN_MS:
return Integer.valueOf(getMemtable_flush_period_in_ms());
@ -2264,6 +2273,9 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
case ROW_CACHE_KEYS_TO_SAVE:
return Integer.valueOf(getRow_cache_keys_to_save());
case POPULATE_IO_CACHE_ON_FLUSH:
return Boolean.valueOf(isPopulate_io_cache_on_flush());
case INDEX_INTERVAL:
return Integer.valueOf(getIndex_interval());
@ -2320,8 +2332,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
return isSetCaching();
case DCLOCAL_READ_REPAIR_CHANCE:
return isSetDclocal_read_repair_chance();
case POPULATE_IO_CACHE_ON_FLUSH:
return isSetPopulate_io_cache_on_flush();
case MEMTABLE_FLUSH_PERIOD_IN_MS:
return isSetMemtable_flush_period_in_ms();
case DEFAULT_TIME_TO_LIVE:
@ -2358,6 +2368,8 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
return isSetRow_cache_provider();
case ROW_CACHE_KEYS_TO_SAVE:
return isSetRow_cache_keys_to_save();
case POPULATE_IO_CACHE_ON_FLUSH:
return isSetPopulate_io_cache_on_flush();
case INDEX_INTERVAL:
return isSetIndex_interval();
}
@ -2566,15 +2578,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
return false;
}
boolean this_present_populate_io_cache_on_flush = true && this.isSetPopulate_io_cache_on_flush();
boolean that_present_populate_io_cache_on_flush = true && that.isSetPopulate_io_cache_on_flush();
if (this_present_populate_io_cache_on_flush || that_present_populate_io_cache_on_flush) {
if (!(this_present_populate_io_cache_on_flush && that_present_populate_io_cache_on_flush))
return false;
if (this.populate_io_cache_on_flush != that.populate_io_cache_on_flush)
return false;
}
boolean this_present_memtable_flush_period_in_ms = true && this.isSetMemtable_flush_period_in_ms();
boolean that_present_memtable_flush_period_in_ms = true && that.isSetMemtable_flush_period_in_ms();
if (this_present_memtable_flush_period_in_ms || that_present_memtable_flush_period_in_ms) {
@ -2737,6 +2740,15 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
return false;
}
boolean this_present_populate_io_cache_on_flush = true && this.isSetPopulate_io_cache_on_flush();
boolean that_present_populate_io_cache_on_flush = true && that.isSetPopulate_io_cache_on_flush();
if (this_present_populate_io_cache_on_flush || that_present_populate_io_cache_on_flush) {
if (!(this_present_populate_io_cache_on_flush && that_present_populate_io_cache_on_flush))
return false;
if (this.populate_io_cache_on_flush != that.populate_io_cache_on_flush)
return false;
}
boolean this_present_index_interval = true && this.isSetIndex_interval();
boolean that_present_index_interval = true && that.isSetIndex_interval();
if (this_present_index_interval || that_present_index_interval) {
@ -2858,11 +2870,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
if (present_dclocal_read_repair_chance)
builder.append(dclocal_read_repair_chance);
boolean present_populate_io_cache_on_flush = true && (isSetPopulate_io_cache_on_flush());
builder.append(present_populate_io_cache_on_flush);
if (present_populate_io_cache_on_flush)
builder.append(populate_io_cache_on_flush);
boolean present_memtable_flush_period_in_ms = true && (isSetMemtable_flush_period_in_ms());
builder.append(present_memtable_flush_period_in_ms);
if (present_memtable_flush_period_in_ms)
@ -2953,6 +2960,11 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
if (present_row_cache_keys_to_save)
builder.append(row_cache_keys_to_save);
boolean present_populate_io_cache_on_flush = true && (isSetPopulate_io_cache_on_flush());
builder.append(present_populate_io_cache_on_flush);
if (present_populate_io_cache_on_flush)
builder.append(populate_io_cache_on_flush);
boolean present_index_interval = true && (isSetIndex_interval());
builder.append(present_index_interval);
if (present_index_interval)
@ -3179,16 +3191,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetPopulate_io_cache_on_flush()).compareTo(other.isSetPopulate_io_cache_on_flush());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetPopulate_io_cache_on_flush()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.populate_io_cache_on_flush, other.populate_io_cache_on_flush);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetMemtable_flush_period_in_ms()).compareTo(other.isSetMemtable_flush_period_in_ms());
if (lastComparison != 0) {
return lastComparison;
@ -3369,6 +3371,16 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetPopulate_io_cache_on_flush()).compareTo(other.isSetPopulate_io_cache_on_flush());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetPopulate_io_cache_on_flush()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.populate_io_cache_on_flush, other.populate_io_cache_on_flush);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetIndex_interval()).compareTo(other.isSetIndex_interval());
if (lastComparison != 0) {
return lastComparison;
@ -3576,12 +3588,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
sb.append(this.dclocal_read_repair_chance);
first = false;
}
if (isSetPopulate_io_cache_on_flush()) {
if (!first) sb.append(", ");
sb.append("populate_io_cache_on_flush:");
sb.append(this.populate_io_cache_on_flush);
first = false;
}
if (isSetMemtable_flush_period_in_ms()) {
if (!first) sb.append(", ");
sb.append("memtable_flush_period_in_ms:");
@ -3706,6 +3712,12 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
sb.append(this.row_cache_keys_to_save);
first = false;
}
if (isSetPopulate_io_cache_on_flush()) {
if (!first) sb.append(", ");
sb.append("populate_io_cache_on_flush:");
sb.append(this.populate_io_cache_on_flush);
first = false;
}
if (isSetIndex_interval()) {
if (!first) sb.append(", ");
sb.append("index_interval:");
@ -3966,14 +3978,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 38: // POPULATE_IO_CACHE_ON_FLUSH
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.populate_io_cache_on_flush = iprot.readBool();
struct.setPopulate_io_cache_on_flushIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 39: // MEMTABLE_FLUSH_PERIOD_IN_MS
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.memtable_flush_period_in_ms = iprot.readI32();
@ -4129,6 +4133,14 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 38: // POPULATE_IO_CACHE_ON_FLUSH
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.populate_io_cache_on_flush = iprot.readBool();
struct.setPopulate_io_cache_on_flushIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 41: // INDEX_INTERVAL
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.index_interval = iprot.readI32();
@ -4496,61 +4508,61 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
if (struct.isSetDclocal_read_repair_chance()) {
optionals.set(18);
}
if (struct.isSetPopulate_io_cache_on_flush()) {
if (struct.isSetMemtable_flush_period_in_ms()) {
optionals.set(19);
}
if (struct.isSetMemtable_flush_period_in_ms()) {
if (struct.isSetDefault_time_to_live()) {
optionals.set(20);
}
if (struct.isSetDefault_time_to_live()) {
if (struct.isSetSpeculative_retry()) {
optionals.set(21);
}
if (struct.isSetSpeculative_retry()) {
if (struct.isSetTriggers()) {
optionals.set(22);
}
if (struct.isSetTriggers()) {
if (struct.isSetCells_per_row_to_cache()) {
optionals.set(23);
}
if (struct.isSetCells_per_row_to_cache()) {
if (struct.isSetMin_index_interval()) {
optionals.set(24);
}
if (struct.isSetMin_index_interval()) {
if (struct.isSetMax_index_interval()) {
optionals.set(25);
}
if (struct.isSetMax_index_interval()) {
if (struct.isSetRow_cache_size()) {
optionals.set(26);
}
if (struct.isSetRow_cache_size()) {
if (struct.isSetKey_cache_size()) {
optionals.set(27);
}
if (struct.isSetKey_cache_size()) {
if (struct.isSetRow_cache_save_period_in_seconds()) {
optionals.set(28);
}
if (struct.isSetRow_cache_save_period_in_seconds()) {
if (struct.isSetKey_cache_save_period_in_seconds()) {
optionals.set(29);
}
if (struct.isSetKey_cache_save_period_in_seconds()) {
if (struct.isSetMemtable_flush_after_mins()) {
optionals.set(30);
}
if (struct.isSetMemtable_flush_after_mins()) {
if (struct.isSetMemtable_throughput_in_mb()) {
optionals.set(31);
}
if (struct.isSetMemtable_throughput_in_mb()) {
if (struct.isSetMemtable_operations_in_millions()) {
optionals.set(32);
}
if (struct.isSetMemtable_operations_in_millions()) {
if (struct.isSetReplicate_on_write()) {
optionals.set(33);
}
if (struct.isSetReplicate_on_write()) {
if (struct.isSetMerge_shards_chance()) {
optionals.set(34);
}
if (struct.isSetMerge_shards_chance()) {
if (struct.isSetRow_cache_provider()) {
optionals.set(35);
}
if (struct.isSetRow_cache_provider()) {
if (struct.isSetRow_cache_keys_to_save()) {
optionals.set(36);
}
if (struct.isSetRow_cache_keys_to_save()) {
if (struct.isSetPopulate_io_cache_on_flush()) {
optionals.set(37);
}
if (struct.isSetIndex_interval()) {
@ -4634,9 +4646,6 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
if (struct.isSetDclocal_read_repair_chance()) {
oprot.writeDouble(struct.dclocal_read_repair_chance);
}
if (struct.isSetPopulate_io_cache_on_flush()) {
oprot.writeBool(struct.populate_io_cache_on_flush);
}
if (struct.isSetMemtable_flush_period_in_ms()) {
oprot.writeI32(struct.memtable_flush_period_in_ms);
}
@ -4697,6 +4706,9 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
if (struct.isSetRow_cache_keys_to_save()) {
oprot.writeI32(struct.row_cache_keys_to_save);
}
if (struct.isSetPopulate_io_cache_on_flush()) {
oprot.writeBool(struct.populate_io_cache_on_flush);
}
if (struct.isSetIndex_interval()) {
oprot.writeI32(struct.index_interval);
}
@ -4819,22 +4831,18 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
struct.setDclocal_read_repair_chanceIsSet(true);
}
if (incoming.get(19)) {
struct.populate_io_cache_on_flush = iprot.readBool();
struct.setPopulate_io_cache_on_flushIsSet(true);
}
if (incoming.get(20)) {
struct.memtable_flush_period_in_ms = iprot.readI32();
struct.setMemtable_flush_period_in_msIsSet(true);
}
if (incoming.get(21)) {
if (incoming.get(20)) {
struct.default_time_to_live = iprot.readI32();
struct.setDefault_time_to_liveIsSet(true);
}
if (incoming.get(22)) {
if (incoming.get(21)) {
struct.speculative_retry = iprot.readString();
struct.setSpeculative_retryIsSet(true);
}
if (incoming.get(23)) {
if (incoming.get(22)) {
{
org.apache.thrift.protocol.TList _list143 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
struct.triggers = new ArrayList<TriggerDef>(_list143.size);
@ -4848,62 +4856,66 @@ public class CfDef implements org.apache.thrift.TBase<CfDef, CfDef._Fields>, jav
}
struct.setTriggersIsSet(true);
}
if (incoming.get(24)) {
if (incoming.get(23)) {
struct.cells_per_row_to_cache = iprot.readString();
struct.setCells_per_row_to_cacheIsSet(true);
}
if (incoming.get(25)) {
if (incoming.get(24)) {
struct.min_index_interval = iprot.readI32();
struct.setMin_index_intervalIsSet(true);
}
if (incoming.get(26)) {
if (incoming.get(25)) {
struct.max_index_interval = iprot.readI32();
struct.setMax_index_intervalIsSet(true);
}
if (incoming.get(27)) {
if (incoming.get(26)) {
struct.row_cache_size = iprot.readDouble();
struct.setRow_cache_sizeIsSet(true);
}
if (incoming.get(28)) {
if (incoming.get(27)) {
struct.key_cache_size = iprot.readDouble();
struct.setKey_cache_sizeIsSet(true);
}
if (incoming.get(29)) {
if (incoming.get(28)) {
struct.row_cache_save_period_in_seconds = iprot.readI32();
struct.setRow_cache_save_period_in_secondsIsSet(true);
}
if (incoming.get(30)) {
if (incoming.get(29)) {
struct.key_cache_save_period_in_seconds = iprot.readI32();
struct.setKey_cache_save_period_in_secondsIsSet(true);
}
if (incoming.get(31)) {
if (incoming.get(30)) {
struct.memtable_flush_after_mins = iprot.readI32();
struct.setMemtable_flush_after_minsIsSet(true);
}
if (incoming.get(32)) {
if (incoming.get(31)) {
struct.memtable_throughput_in_mb = iprot.readI32();
struct.setMemtable_throughput_in_mbIsSet(true);
}
if (incoming.get(33)) {
if (incoming.get(32)) {
struct.memtable_operations_in_millions = iprot.readDouble();
struct.setMemtable_operations_in_millionsIsSet(true);
}
if (incoming.get(34)) {
if (incoming.get(33)) {
struct.replicate_on_write = iprot.readBool();
struct.setReplicate_on_writeIsSet(true);
}
if (incoming.get(35)) {
if (incoming.get(34)) {
struct.merge_shards_chance = iprot.readDouble();
struct.setMerge_shards_chanceIsSet(true);
}
if (incoming.get(36)) {
if (incoming.get(35)) {
struct.row_cache_provider = iprot.readString();
struct.setRow_cache_providerIsSet(true);
}
if (incoming.get(37)) {
if (incoming.get(36)) {
struct.row_cache_keys_to_save = iprot.readI32();
struct.setRow_cache_keys_to_saveIsSet(true);
}
if (incoming.get(37)) {
struct.populate_io_cache_on_flush = iprot.readBool();
struct.setPopulate_io_cache_on_flushIsSet(true);
}
if (incoming.get(38)) {
struct.index_interval = iprot.readI32();
struct.setIndex_intervalIsSet(true);

View File

@ -0,0 +1,551 @@
/**
* Autogenerated by Thrift Compiler (0.9.1)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package org.apache.cassandra.thrift;
/*
*
* 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.
*
*/
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import org.apache.thrift.async.AsyncMethodCallback;
import org.apache.thrift.server.AbstractNonblockingServer.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The ColumnSlice is used to select a set of columns from inside a row.
* If start or finish are unspecified they will default to the start-of
* end-of value.
* @param start. The start of the ColumnSlice inclusive
* @param finish. The end of the ColumnSlice inclusive
*/
public class ColumnSlice implements org.apache.thrift.TBase<ColumnSlice, ColumnSlice._Fields>, java.io.Serializable, Cloneable, Comparable<ColumnSlice> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ColumnSlice");
private static final org.apache.thrift.protocol.TField START_FIELD_DESC = new org.apache.thrift.protocol.TField("start", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField FINISH_FIELD_DESC = new org.apache.thrift.protocol.TField("finish", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new ColumnSliceStandardSchemeFactory());
schemes.put(TupleScheme.class, new ColumnSliceTupleSchemeFactory());
}
public ByteBuffer start; // optional
public ByteBuffer finish; // optional
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
START((short)1, "start"),
FINISH((short)2, "finish");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
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: // START
return START;
case 2: // FINISH
return FINISH;
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
private _Fields optionals[] = {_Fields.START,_Fields.FINISH};
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.START, new org.apache.thrift.meta_data.FieldMetaData("start", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
tmpMap.put(_Fields.FINISH, new org.apache.thrift.meta_data.FieldMetaData("finish", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ColumnSlice.class, metaDataMap);
}
public ColumnSlice() {
}
/**
* Performs a deep copy on <i>other</i>.
*/
public ColumnSlice(ColumnSlice other) {
if (other.isSetStart()) {
this.start = org.apache.thrift.TBaseHelper.copyBinary(other.start);
;
}
if (other.isSetFinish()) {
this.finish = org.apache.thrift.TBaseHelper.copyBinary(other.finish);
;
}
}
public ColumnSlice deepCopy() {
return new ColumnSlice(this);
}
@Override
public void clear() {
this.start = null;
this.finish = null;
}
public byte[] getStart() {
setStart(org.apache.thrift.TBaseHelper.rightSize(start));
return start == null ? null : start.array();
}
public ByteBuffer bufferForStart() {
return start;
}
public ColumnSlice setStart(byte[] start) {
setStart(start == null ? (ByteBuffer)null : ByteBuffer.wrap(start));
return this;
}
public ColumnSlice setStart(ByteBuffer start) {
this.start = start;
return this;
}
public void unsetStart() {
this.start = null;
}
/** Returns true if field start is set (has been assigned a value) and false otherwise */
public boolean isSetStart() {
return this.start != null;
}
public void setStartIsSet(boolean value) {
if (!value) {
this.start = null;
}
}
public byte[] getFinish() {
setFinish(org.apache.thrift.TBaseHelper.rightSize(finish));
return finish == null ? null : finish.array();
}
public ByteBuffer bufferForFinish() {
return finish;
}
public ColumnSlice setFinish(byte[] finish) {
setFinish(finish == null ? (ByteBuffer)null : ByteBuffer.wrap(finish));
return this;
}
public ColumnSlice setFinish(ByteBuffer finish) {
this.finish = finish;
return this;
}
public void unsetFinish() {
this.finish = null;
}
/** Returns true if field finish is set (has been assigned a value) and false otherwise */
public boolean isSetFinish() {
return this.finish != null;
}
public void setFinishIsSet(boolean value) {
if (!value) {
this.finish = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case START:
if (value == null) {
unsetStart();
} else {
setStart((ByteBuffer)value);
}
break;
case FINISH:
if (value == null) {
unsetFinish();
} else {
setFinish((ByteBuffer)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case START:
return getStart();
case FINISH:
return getFinish();
}
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 START:
return isSetStart();
case FINISH:
return isSetFinish();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof ColumnSlice)
return this.equals((ColumnSlice)that);
return false;
}
public boolean equals(ColumnSlice that) {
if (that == null)
return false;
boolean this_present_start = true && this.isSetStart();
boolean that_present_start = true && that.isSetStart();
if (this_present_start || that_present_start) {
if (!(this_present_start && that_present_start))
return false;
if (!this.start.equals(that.start))
return false;
}
boolean this_present_finish = true && this.isSetFinish();
boolean that_present_finish = true && that.isSetFinish();
if (this_present_finish || that_present_finish) {
if (!(this_present_finish && that_present_finish))
return false;
if (!this.finish.equals(that.finish))
return false;
}
return true;
}
@Override
public int hashCode() {
HashCodeBuilder builder = new HashCodeBuilder();
boolean present_start = true && (isSetStart());
builder.append(present_start);
if (present_start)
builder.append(start);
boolean present_finish = true && (isSetFinish());
builder.append(present_finish);
if (present_finish)
builder.append(finish);
return builder.toHashCode();
}
@Override
public int compareTo(ColumnSlice other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
lastComparison = Boolean.valueOf(isSetStart()).compareTo(other.isSetStart());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStart()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.start, other.start);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetFinish()).compareTo(other.isSetFinish());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetFinish()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.finish, other.finish);
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 {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("ColumnSlice(");
boolean first = true;
if (isSetStart()) {
sb.append("start:");
if (this.start == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.start, sb);
}
first = false;
}
if (isSetFinish()) {
if (!first) sb.append(", ");
sb.append("finish:");
if (this.finish == null) {
sb.append("null");
} else {
org.apache.thrift.TBaseHelper.toString(this.finish, sb);
}
first = false;
}
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
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);
}
}
private static class ColumnSliceStandardSchemeFactory implements SchemeFactory {
public ColumnSliceStandardScheme getScheme() {
return new ColumnSliceStandardScheme();
}
}
private static class ColumnSliceStandardScheme extends StandardScheme<ColumnSlice> {
public void read(org.apache.thrift.protocol.TProtocol iprot, ColumnSlice struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // START
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.start = iprot.readBinary();
struct.setStartIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // FINISH
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.finish = iprot.readBinary();
struct.setFinishIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, ColumnSlice struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
if (struct.start != null) {
if (struct.isSetStart()) {
oprot.writeFieldBegin(START_FIELD_DESC);
oprot.writeBinary(struct.start);
oprot.writeFieldEnd();
}
}
if (struct.finish != null) {
if (struct.isSetFinish()) {
oprot.writeFieldBegin(FINISH_FIELD_DESC);
oprot.writeBinary(struct.finish);
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class ColumnSliceTupleSchemeFactory implements SchemeFactory {
public ColumnSliceTupleScheme getScheme() {
return new ColumnSliceTupleScheme();
}
}
private static class ColumnSliceTupleScheme extends TupleScheme<ColumnSlice> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, ColumnSlice struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
BitSet optionals = new BitSet();
if (struct.isSetStart()) {
optionals.set(0);
}
if (struct.isSetFinish()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetStart()) {
oprot.writeBinary(struct.start);
}
if (struct.isSetFinish()) {
oprot.writeBinary(struct.finish);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, ColumnSlice struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.start = iprot.readBinary();
struct.setStartIsSet(true);
}
if (incoming.get(1)) {
struct.finish = iprot.readBinary();
struct.setFinishIsSet(true);
}
}
}
}

View File

@ -55,7 +55,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Row returned from a CQL query
* Row returned from a CQL query.
*
* This struct is used for both CQL2 and CQL3 queries. For CQL2, the partition key
* is special-cased and is always returned. For CQL3, it is not special cased;
* it will be included in the columns list if it was included in the SELECT and
* the key field is always null.
*/
public class CqlRow implements org.apache.thrift.TBase<CqlRow, CqlRow._Fields>, java.io.Serializable, Cloneable, Comparable<CqlRow> {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("CqlRow");

File diff suppressed because it is too large Load Diff

View File

@ -2036,6 +2036,74 @@ public class CassandraServer implements Cassandra.Iface
}
}
@Override
public List<ColumnOrSuperColumn> get_multi_slice(MultiSliceRequest request)
throws InvalidRequestException, UnavailableException, TimedOutException
{
if (startSessionIfRequested())
{
Map<String, String> traceParameters = ImmutableMap.of("key", ByteBufferUtil.bytesToHex(request.key),
"column_parent", request.column_parent.toString(),
"consistency_level", request.consistency_level.name(),
"count", String.valueOf(request.count),
"column_slices", request.column_slices.toString());
Tracing.instance.begin("get_multi_slice", traceParameters);
}
else
{
logger.debug("get_multi_slice");
}
try
{
ClientState cState = state();
String keyspace = cState.getKeyspace();
state().hasColumnFamilyAccess(keyspace, request.getColumn_parent().column_family, Permission.SELECT);
CFMetaData metadata = ThriftValidation.validateColumnFamily(keyspace, request.getColumn_parent().column_family);
if (metadata.cfType == ColumnFamilyType.Super)
throw new org.apache.cassandra.exceptions.InvalidRequestException("get_multi_slice does not support super columns");
ThriftValidation.validateColumnParent(metadata, request.getColumn_parent());
org.apache.cassandra.db.ConsistencyLevel consistencyLevel = ThriftConversion.fromThrift(request.getConsistency_level());
consistencyLevel.validateForRead(keyspace);
List<ReadCommand> commands = new ArrayList<>(1);
ColumnSlice [] slices = new ColumnSlice[request.getColumn_slices().size()];
for (int i = 0 ; i < request.getColumn_slices().size() ; i++)
{
fixOptionalSliceParameters(request.getColumn_slices().get(i));
Composite start = metadata.comparator.fromByteBuffer(request.getColumn_slices().get(i).start);
Composite finish = metadata.comparator.fromByteBuffer(request.getColumn_slices().get(i).finish);
int compare = metadata.comparator.compare(start, finish);
if (!request.reversed && compare > 0)
throw new InvalidRequestException(String.format("Column slice at index %d had start greater than finish", i));
else if (request.reversed && compare < 0)
throw new InvalidRequestException(String.format("Reversed column slice at index %d had start less than finish", i));
slices[i] = new ColumnSlice(start, finish);
}
SliceQueryFilter filter = new SliceQueryFilter(slices, request.reversed, request.count);
ThriftValidation.validateKey(metadata, request.key);
commands.add(ReadCommand.create(keyspace, request.key, request.column_parent.getColumn_family(), System.currentTimeMillis(), filter));
return getSlice(commands, request.column_parent.isSetSuper_column(), consistencyLevel).entrySet().iterator().next().getValue();
}
catch (RequestValidationException e)
{
throw ThriftConversion.toThrift(e);
}
finally
{
Tracing.instance.stopSession();
}
}
/**
* Set the to start-of end-of value of "" for start and finish.
* @param columnSlice
*/
private static void fixOptionalSliceParameters(org.apache.cassandra.thrift.ColumnSlice columnSlice) {
if (!columnSlice.isSetStart())
columnSlice.setStart(new byte[0]);
if (!columnSlice.isSetFinish())
columnSlice.setFinish(new byte[0]);
}
public CqlResult execute_prepared_cql_query(int itemId, List<ByteBuffer> bindVariables)
throws InvalidRequestException, UnavailableException, TimedOutException, SchemaDisagreementException, TException
{

View File

@ -0,0 +1,149 @@
package org.apache.cassandra.thrift;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import junit.framework.Assert;
import org.apache.cassandra.SchemaLoader;
import org.apache.cassandra.config.Schema;
import org.apache.cassandra.service.EmbeddedCassandraService;
import org.apache.cassandra.utils.ByteBufferUtil;
import org.apache.thrift.TException;
import org.junit.BeforeClass;
import org.junit.Test;
public class MultiSliceTest extends SchemaLoader
{
private static CassandraServer server;
@BeforeClass
public static void setup() throws IOException, TException
{
Schema.instance.clear(); // Schema are now written on disk and will be reloaded
new EmbeddedCassandraService().start();
ThriftSessionManager.instance.setCurrentSocket(new InetSocketAddress(9160));
server = new CassandraServer();
server.set_keyspace("Keyspace1");
}
private static MultiSliceRequest makeMultiSliceRequest(ByteBuffer key)
{
ColumnParent cp = new ColumnParent("Standard1");
MultiSliceRequest req = new MultiSliceRequest();
req.setKey(key);
req.setCount(1000);
req.reversed = false;
req.setColumn_parent(cp);
return req;
}
@Test
public void test_multi_slice_optional_column_slice() throws TException
{
ColumnParent cp = new ColumnParent("Standard1");
ByteBuffer key = ByteBuffer.wrap("multi_slice".getBytes());
List<String> expected = new ArrayList<String>();
for (char a = 'a'; a <= 'z'; a++)
expected.add(a + "");
addTheAlphabetToRow(key, cp);
MultiSliceRequest req = makeMultiSliceRequest(key);
req.setColumn_slices(new ArrayList<ColumnSlice>());
req.getColumn_slices().add(new ColumnSlice());
List<ColumnOrSuperColumn> list = server.get_multi_slice(req);
assertColumnNameMatches(expected, list);
}
@Test
public void test_multi_slice() throws TException
{
ColumnParent cp = new ColumnParent("Standard1");
ByteBuffer key = ByteBuffer.wrap("multi_slice_two_slice".getBytes());
addTheAlphabetToRow(key, cp);
MultiSliceRequest req = makeMultiSliceRequest(key);
req.setColumn_slices(Arrays.asList(columnSliceFrom("a", "e"), columnSliceFrom("i", "n")));
assertColumnNameMatches(Arrays.asList("a", "b", "c", "d", "e", "i", "j", "k" , "l", "m" , "n"), server.get_multi_slice(req));
}
@Test
public void test_with_overlap() throws TException
{
ColumnParent cp = new ColumnParent("Standard1");
ByteBuffer key = ByteBuffer.wrap("overlap".getBytes());
addTheAlphabetToRow(key, cp);
MultiSliceRequest req = makeMultiSliceRequest(key);
req.setColumn_slices(Arrays.asList(columnSliceFrom("a", "e"), columnSliceFrom("d", "g")));
assertColumnNameMatches(Arrays.asList("a", "b", "c", "d", "e", "f", "g"), server.get_multi_slice(req));
}
@Test
public void test_with_overlap_reversed() throws TException
{
ColumnParent cp = new ColumnParent("Standard1");
ByteBuffer key = ByteBuffer.wrap("overlap_reversed".getBytes());
addTheAlphabetToRow(key, cp);
MultiSliceRequest req = makeMultiSliceRequest(key);
req.reversed = true;
req.setColumn_slices(Arrays.asList(columnSliceFrom("e", "a"), columnSliceFrom("g", "d")));
assertColumnNameMatches(Arrays.asList("g", "f", "e", "d", "c", "b", "a"), server.get_multi_slice(req));
}
@Test(expected=InvalidRequestException.class)
public void test_that_column_slice_is_proper() throws TException
{
ByteBuffer key = ByteBuffer.wrap("overlap".getBytes());
MultiSliceRequest req = makeMultiSliceRequest(key);
req.reversed = true;
req.setColumn_slices(Arrays.asList(columnSliceFrom("a", "e"), columnSliceFrom("g", "d")));
assertColumnNameMatches(Arrays.asList("a", "b", "c", "d", "e", "f", "g"), server.get_multi_slice(req));
}
@Test
public void test_with_overlap_reversed_with_count() throws TException
{
ColumnParent cp = new ColumnParent("Standard1");
ByteBuffer key = ByteBuffer.wrap("overlap_reversed_count".getBytes());
addTheAlphabetToRow(key, cp);
MultiSliceRequest req = makeMultiSliceRequest(key);
req.setCount(6);
req.reversed = true;
req.setColumn_slices(Arrays.asList(columnSliceFrom("e", "a"), columnSliceFrom("g", "d")));
assertColumnNameMatches(Arrays.asList("g", "e", "d", "c", "b", "a"), server.get_multi_slice(req));
}
private static void addTheAlphabetToRow(ByteBuffer key, ColumnParent parent)
throws InvalidRequestException, UnavailableException, TimedOutException
{
for (char a = 'a'; a <= 'z'; a++) {
Column c1 = new Column();
c1.setName(ByteBufferUtil.bytes(String.valueOf(a)));
c1.setValue(new byte [0]);
c1.setTimestamp(System.nanoTime());
server.insert(key, parent, c1, ConsistencyLevel.ONE);
}
}
private static void assertColumnNameMatches(List<String> expected , List<ColumnOrSuperColumn> actual)
{
Assert.assertEquals(actual+" "+expected +" did not have same number of elements", actual.size(), expected.size());
for (int i = 0 ; i< expected.size() ; i++)
{
Assert.assertEquals(actual.get(i) +" did not equal "+ expected.get(i),
new String(actual.get(i).getColumn().getName()), expected.get(i));
}
}
private ColumnSlice columnSliceFrom(String startInclusive, String endInclusive)
{
ColumnSlice cs = new ColumnSlice();
cs.setStart(ByteBufferUtil.bytes(startInclusive));
cs.setFinish(ByteBufferUtil.bytes(endInclusive));
return cs;
}
}