HBASE-8947 Thrift 2 : Replace "bool writeToWAL" with "TDurability durability"

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1507099 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael Stack 2013-07-25 19:28:39 +00:00
parent 58df19c185
commit afd3480511
6 changed files with 321 additions and 495 deletions

View File

@ -167,9 +167,7 @@ public class ThriftUtilities {
out = new Put(in.getRow());
}
if (in.isSetDurability()) {
out.setDurability(durabilityFromThrift(in.getDurability()));
}
out.setDurability(in.isWriteToWal() ? Durability.SYNC_WAL : Durability.SKIP_WAL);
for (TColumnValue columnValue : in.getColumnValues()) {
if (columnValue.isSetTimestamp()) {
@ -252,10 +250,7 @@ public class ThriftUtilities {
addAttributes(out,in.getAttributes());
}
if (in.isSetDurability()) {
out.setDurability(durabilityFromThrift(in.getDurability()));
}
out.setDurability(in.isWriteToWal() ? Durability.SYNC_WAL : Durability.SKIP_WAL);
return out;
}
@ -388,10 +383,7 @@ public class ThriftUtilities {
addAttributes(out,in.getAttributes());
}
if (in.isSetDurability()) {
out.setDurability(durabilityFromThrift(in.getDurability()));
}
out.setDurability(in.isWriteToWal() ? Durability.SYNC_WAL : Durability.SKIP_WAL);
return out;
}
@ -409,14 +401,4 @@ public class ThriftUtilities {
op.setAttribute(name, value);
}
}
private static Durability durabilityFromThrift(TDurability tDurability) {
switch (tDurability.getValue()) {
case 1: return Durability.SKIP_WAL;
case 2: return Durability.ASYNC_WAL;
case 3: return Durability.SYNC_WAL;
case 4: return Durability.FSYNC_WAL;
default: return null;
}
}
}

View File

@ -52,9 +52,6 @@ import org.slf4j.LoggerFactory;
* as if you had added a TColumn for every column family and this timestamp
* (i.e. all versions older than or equal in all column families will be deleted)
*
* You can specify how this Delete should be written to the write-ahead Log (WAL)
* by changing the durability. If you don't provide durability, it defaults to
* column family's default setting for durability.
*/
public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TDelete");
@ -63,8 +60,8 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
private static final org.apache.thrift.protocol.TField COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("columns", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final org.apache.thrift.protocol.TField TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("timestamp", org.apache.thrift.protocol.TType.I64, (short)3);
private static final org.apache.thrift.protocol.TField DELETE_TYPE_FIELD_DESC = new org.apache.thrift.protocol.TField("deleteType", org.apache.thrift.protocol.TType.I32, (short)4);
private static final org.apache.thrift.protocol.TField WRITE_TO_WAL_FIELD_DESC = new org.apache.thrift.protocol.TField("writeToWal", org.apache.thrift.protocol.TType.BOOL, (short)5);
private static final org.apache.thrift.protocol.TField ATTRIBUTES_FIELD_DESC = new org.apache.thrift.protocol.TField("attributes", org.apache.thrift.protocol.TType.MAP, (short)6);
private static final org.apache.thrift.protocol.TField DURABILITY_FIELD_DESC = new org.apache.thrift.protocol.TField("durability", org.apache.thrift.protocol.TType.I32, (short)7);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@ -80,12 +77,8 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
* @see TDeleteType
*/
public TDeleteType deleteType; // optional
public boolean writeToWal; // optional
public Map<ByteBuffer,ByteBuffer> attributes; // optional
/**
*
* @see TDurability
*/
public TDurability durability; // 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 {
@ -97,12 +90,8 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
* @see TDeleteType
*/
DELETE_TYPE((short)4, "deleteType"),
ATTRIBUTES((short)6, "attributes"),
/**
*
* @see TDurability
*/
DURABILITY((short)7, "durability");
WRITE_TO_WAL((short)5, "writeToWal"),
ATTRIBUTES((short)6, "attributes");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@ -125,10 +114,10 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
return TIMESTAMP;
case 4: // DELETE_TYPE
return DELETE_TYPE;
case 5: // WRITE_TO_WAL
return WRITE_TO_WAL;
case 6: // ATTRIBUTES
return ATTRIBUTES;
case 7: // DURABILITY
return DURABILITY;
default:
return null;
}
@ -170,8 +159,9 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
// isset id assignments
private static final int __TIMESTAMP_ISSET_ID = 0;
private static final int __WRITETOWAL_ISSET_ID = 1;
private byte __isset_bitfield = 0;
private _Fields optionals[] = {_Fields.COLUMNS,_Fields.TIMESTAMP,_Fields.DELETE_TYPE,_Fields.ATTRIBUTES,_Fields.DURABILITY};
private _Fields optionals[] = {_Fields.COLUMNS,_Fields.TIMESTAMP,_Fields.DELETE_TYPE,_Fields.WRITE_TO_WAL,_Fields.ATTRIBUTES};
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);
@ -184,12 +174,12 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
tmpMap.put(_Fields.DELETE_TYPE, new org.apache.thrift.meta_data.FieldMetaData("deleteType", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TDeleteType.class)));
tmpMap.put(_Fields.WRITE_TO_WAL, new org.apache.thrift.meta_data.FieldMetaData("writeToWal", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.ATTRIBUTES, new org.apache.thrift.meta_data.FieldMetaData("attributes", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true),
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))));
tmpMap.put(_Fields.DURABILITY, new org.apache.thrift.meta_data.FieldMetaData("durability", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TDurability.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TDelete.class, metaDataMap);
}
@ -197,6 +187,8 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
public TDelete() {
this.deleteType = org.apache.hadoop.hbase.thrift2.generated.TDeleteType.DELETE_COLUMNS;
this.writeToWal = true;
}
public TDelete(
@ -226,6 +218,7 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
if (other.isSetDeleteType()) {
this.deleteType = other.deleteType;
}
this.writeToWal = other.writeToWal;
if (other.isSetAttributes()) {
Map<ByteBuffer,ByteBuffer> __this__attributes = new HashMap<ByteBuffer,ByteBuffer>();
for (Map.Entry<ByteBuffer, ByteBuffer> other_element : other.attributes.entrySet()) {
@ -243,9 +236,6 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
}
this.attributes = __this__attributes;
}
if (other.isSetDurability()) {
this.durability = other.durability;
}
}
public TDelete deepCopy() {
@ -260,8 +250,9 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
this.timestamp = 0;
this.deleteType = org.apache.hadoop.hbase.thrift2.generated.TDeleteType.DELETE_COLUMNS;
this.writeToWal = true;
this.attributes = null;
this.durability = null;
}
public byte[] getRow() {
@ -392,6 +383,29 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
}
}
public boolean isWriteToWal() {
return this.writeToWal;
}
public TDelete setWriteToWal(boolean writeToWal) {
this.writeToWal = writeToWal;
setWriteToWalIsSet(true);
return this;
}
public void unsetWriteToWal() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __WRITETOWAL_ISSET_ID);
}
/** Returns true if field writeToWal is set (has been assigned a value) and false otherwise */
public boolean isSetWriteToWal() {
return EncodingUtils.testBit(__isset_bitfield, __WRITETOWAL_ISSET_ID);
}
public void setWriteToWalIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __WRITETOWAL_ISSET_ID, value);
}
public int getAttributesSize() {
return (this.attributes == null) ? 0 : this.attributes.size();
}
@ -427,38 +441,6 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
}
}
/**
*
* @see TDurability
*/
public TDurability getDurability() {
return this.durability;
}
/**
*
* @see TDurability
*/
public TDelete setDurability(TDurability durability) {
this.durability = durability;
return this;
}
public void unsetDurability() {
this.durability = null;
}
/** Returns true if field durability is set (has been assigned a value) and false otherwise */
public boolean isSetDurability() {
return this.durability != null;
}
public void setDurabilityIsSet(boolean value) {
if (!value) {
this.durability = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case ROW:
@ -493,6 +475,14 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
}
break;
case WRITE_TO_WAL:
if (value == null) {
unsetWriteToWal();
} else {
setWriteToWal((Boolean)value);
}
break;
case ATTRIBUTES:
if (value == null) {
unsetAttributes();
@ -501,14 +491,6 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
}
break;
case DURABILITY:
if (value == null) {
unsetDurability();
} else {
setDurability((TDurability)value);
}
break;
}
}
@ -526,12 +508,12 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
case DELETE_TYPE:
return getDeleteType();
case WRITE_TO_WAL:
return Boolean.valueOf(isWriteToWal());
case ATTRIBUTES:
return getAttributes();
case DURABILITY:
return getDurability();
}
throw new IllegalStateException();
}
@ -551,10 +533,10 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
return isSetTimestamp();
case DELETE_TYPE:
return isSetDeleteType();
case WRITE_TO_WAL:
return isSetWriteToWal();
case ATTRIBUTES:
return isSetAttributes();
case DURABILITY:
return isSetDurability();
}
throw new IllegalStateException();
}
@ -608,6 +590,15 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
return false;
}
boolean this_present_writeToWal = true && this.isSetWriteToWal();
boolean that_present_writeToWal = true && that.isSetWriteToWal();
if (this_present_writeToWal || that_present_writeToWal) {
if (!(this_present_writeToWal && that_present_writeToWal))
return false;
if (this.writeToWal != that.writeToWal)
return false;
}
boolean this_present_attributes = true && this.isSetAttributes();
boolean that_present_attributes = true && that.isSetAttributes();
if (this_present_attributes || that_present_attributes) {
@ -617,15 +608,6 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
return false;
}
boolean this_present_durability = true && this.isSetDurability();
boolean that_present_durability = true && that.isSetDurability();
if (this_present_durability || that_present_durability) {
if (!(this_present_durability && that_present_durability))
return false;
if (!this.durability.equals(that.durability))
return false;
}
return true;
}
@ -682,6 +664,16 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetWriteToWal()).compareTo(typedOther.isSetWriteToWal());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetWriteToWal()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.writeToWal, typedOther.writeToWal);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetAttributes()).compareTo(typedOther.isSetAttributes());
if (lastComparison != 0) {
return lastComparison;
@ -692,16 +684,6 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetDurability()).compareTo(typedOther.isSetDurability());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetDurability()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.durability, typedOther.durability);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
@ -755,6 +737,12 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
}
first = false;
}
if (isSetWriteToWal()) {
if (!first) sb.append(", ");
sb.append("writeToWal:");
sb.append(this.writeToWal);
first = false;
}
if (isSetAttributes()) {
if (!first) sb.append(", ");
sb.append("attributes:");
@ -765,16 +753,6 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
}
first = false;
}
if (isSetDurability()) {
if (!first) sb.append(", ");
sb.append("durability:");
if (this.durability == null) {
sb.append("null");
} else {
sb.append(this.durability);
}
first = false;
}
sb.append(")");
return sb.toString();
}
@ -838,7 +816,7 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
struct.columns = new ArrayList<TColumn>(_list44.size);
for (int _i45 = 0; _i45 < _list44.size; ++_i45)
{
TColumn _elem46; // optional
TColumn _elem46; // required
_elem46 = new TColumn();
_elem46.read(iprot);
struct.columns.add(_elem46);
@ -866,6 +844,14 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 5: // WRITE_TO_WAL
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.writeToWal = iprot.readBool();
struct.setWriteToWalIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 6: // ATTRIBUTES
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
@ -886,14 +872,6 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 7: // DURABILITY
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.durability = TDurability.findByValue(iprot.readI32());
struct.setDurabilityIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
@ -940,6 +918,11 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
oprot.writeFieldEnd();
}
}
if (struct.isSetWriteToWal()) {
oprot.writeFieldBegin(WRITE_TO_WAL_FIELD_DESC);
oprot.writeBool(struct.writeToWal);
oprot.writeFieldEnd();
}
if (struct.attributes != null) {
if (struct.isSetAttributes()) {
oprot.writeFieldBegin(ATTRIBUTES_FIELD_DESC);
@ -955,13 +938,6 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
oprot.writeFieldEnd();
}
}
if (struct.durability != null) {
if (struct.isSetDurability()) {
oprot.writeFieldBegin(DURABILITY_FIELD_DESC);
oprot.writeI32(struct.durability.getValue());
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@ -990,10 +966,10 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
if (struct.isSetDeleteType()) {
optionals.set(2);
}
if (struct.isSetAttributes()) {
if (struct.isSetWriteToWal()) {
optionals.set(3);
}
if (struct.isSetDurability()) {
if (struct.isSetAttributes()) {
optionals.set(4);
}
oprot.writeBitSet(optionals, 5);
@ -1012,6 +988,9 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
if (struct.isSetDeleteType()) {
oprot.writeI32(struct.deleteType.getValue());
}
if (struct.isSetWriteToWal()) {
oprot.writeBool(struct.writeToWal);
}
if (struct.isSetAttributes()) {
{
oprot.writeI32(struct.attributes.size());
@ -1022,9 +1001,6 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
}
}
}
if (struct.isSetDurability()) {
oprot.writeI32(struct.durability.getValue());
}
}
@Override
@ -1039,7 +1015,7 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
struct.columns = new ArrayList<TColumn>(_list55.size);
for (int _i56 = 0; _i56 < _list55.size; ++_i56)
{
TColumn _elem57; // optional
TColumn _elem57; // required
_elem57 = new TColumn();
_elem57.read(iprot);
struct.columns.add(_elem57);
@ -1056,6 +1032,10 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
struct.setDeleteTypeIsSet(true);
}
if (incoming.get(3)) {
struct.writeToWal = iprot.readBool();
struct.setWriteToWalIsSet(true);
}
if (incoming.get(4)) {
{
org.apache.thrift.protocol.TMap _map58 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.attributes = new HashMap<ByteBuffer,ByteBuffer>(2*_map58.size);
@ -1070,10 +1050,6 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
}
struct.setAttributesIsSet(true);
}
if (incoming.get(4)) {
struct.durability = TDurability.findByValue(iprot.readI32());
struct.setDurabilityIsSet(true);
}
}
}

View File

@ -33,17 +33,16 @@ import org.slf4j.LoggerFactory;
/**
* Used to perform Increment operations for a single row.
*
* You can specify how this Increment should be written to the write-ahead Log (WAL)
* by changing the durability. If you don't provide durability, it defaults to
* column family's default setting for durability.
* You can specify if this Increment should be written
* to the write-ahead Log (WAL) or not. It defaults to true.
*/
public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncrement._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TIncrement");
private static final org.apache.thrift.protocol.TField ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("row", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField COLUMNS_FIELD_DESC = new org.apache.thrift.protocol.TField("columns", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final org.apache.thrift.protocol.TField WRITE_TO_WAL_FIELD_DESC = new org.apache.thrift.protocol.TField("writeToWal", org.apache.thrift.protocol.TType.BOOL, (short)3);
private static final org.apache.thrift.protocol.TField ATTRIBUTES_FIELD_DESC = new org.apache.thrift.protocol.TField("attributes", org.apache.thrift.protocol.TType.MAP, (short)4);
private static final org.apache.thrift.protocol.TField DURABILITY_FIELD_DESC = new org.apache.thrift.protocol.TField("durability", org.apache.thrift.protocol.TType.I32, (short)5);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@ -53,23 +52,15 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
public ByteBuffer row; // required
public List<TColumnIncrement> columns; // required
public boolean writeToWal; // optional
public Map<ByteBuffer,ByteBuffer> attributes; // optional
/**
*
* @see TDurability
*/
public TDurability durability; // 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 {
ROW((short)1, "row"),
COLUMNS((short)2, "columns"),
ATTRIBUTES((short)4, "attributes"),
/**
*
* @see TDurability
*/
DURABILITY((short)5, "durability");
WRITE_TO_WAL((short)3, "writeToWal"),
ATTRIBUTES((short)4, "attributes");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@ -88,10 +79,10 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
return ROW;
case 2: // COLUMNS
return COLUMNS;
case 3: // WRITE_TO_WAL
return WRITE_TO_WAL;
case 4: // ATTRIBUTES
return ATTRIBUTES;
case 5: // DURABILITY
return DURABILITY;
default:
return null;
}
@ -132,7 +123,9 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
// isset id assignments
private _Fields optionals[] = {_Fields.ATTRIBUTES,_Fields.DURABILITY};
private static final int __WRITETOWAL_ISSET_ID = 0;
private byte __isset_bitfield = 0;
private _Fields optionals[] = {_Fields.WRITE_TO_WAL,_Fields.ATTRIBUTES};
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);
@ -141,17 +134,19 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
tmpMap.put(_Fields.COLUMNS, new org.apache.thrift.meta_data.FieldMetaData("columns", org.apache.thrift.TFieldRequirementType.REQUIRED,
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, TColumnIncrement.class))));
tmpMap.put(_Fields.WRITE_TO_WAL, new org.apache.thrift.meta_data.FieldMetaData("writeToWal", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.ATTRIBUTES, new org.apache.thrift.meta_data.FieldMetaData("attributes", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true),
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))));
tmpMap.put(_Fields.DURABILITY, new org.apache.thrift.meta_data.FieldMetaData("durability", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TDurability.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TIncrement.class, metaDataMap);
}
public TIncrement() {
this.writeToWal = true;
}
public TIncrement(
@ -167,6 +162,7 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
* Performs a deep copy on <i>other</i>.
*/
public TIncrement(TIncrement other) {
__isset_bitfield = other.__isset_bitfield;
if (other.isSetRow()) {
this.row = org.apache.thrift.TBaseHelper.copyBinary(other.row);
;
@ -178,6 +174,7 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
this.columns = __this__columns;
}
this.writeToWal = other.writeToWal;
if (other.isSetAttributes()) {
Map<ByteBuffer,ByteBuffer> __this__attributes = new HashMap<ByteBuffer,ByteBuffer>();
for (Map.Entry<ByteBuffer, ByteBuffer> other_element : other.attributes.entrySet()) {
@ -195,9 +192,6 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
this.attributes = __this__attributes;
}
if (other.isSetDurability()) {
this.durability = other.durability;
}
}
public TIncrement deepCopy() {
@ -208,8 +202,9 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
public void clear() {
this.row = null;
this.columns = null;
this.writeToWal = true;
this.attributes = null;
this.durability = null;
}
public byte[] getRow() {
@ -285,6 +280,29 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
}
public boolean isWriteToWal() {
return this.writeToWal;
}
public TIncrement setWriteToWal(boolean writeToWal) {
this.writeToWal = writeToWal;
setWriteToWalIsSet(true);
return this;
}
public void unsetWriteToWal() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __WRITETOWAL_ISSET_ID);
}
/** Returns true if field writeToWal is set (has been assigned a value) and false otherwise */
public boolean isSetWriteToWal() {
return EncodingUtils.testBit(__isset_bitfield, __WRITETOWAL_ISSET_ID);
}
public void setWriteToWalIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __WRITETOWAL_ISSET_ID, value);
}
public int getAttributesSize() {
return (this.attributes == null) ? 0 : this.attributes.size();
}
@ -320,38 +338,6 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
}
/**
*
* @see TDurability
*/
public TDurability getDurability() {
return this.durability;
}
/**
*
* @see TDurability
*/
public TIncrement setDurability(TDurability durability) {
this.durability = durability;
return this;
}
public void unsetDurability() {
this.durability = null;
}
/** Returns true if field durability is set (has been assigned a value) and false otherwise */
public boolean isSetDurability() {
return this.durability != null;
}
public void setDurabilityIsSet(boolean value) {
if (!value) {
this.durability = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case ROW:
@ -370,6 +356,14 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
break;
case WRITE_TO_WAL:
if (value == null) {
unsetWriteToWal();
} else {
setWriteToWal((Boolean)value);
}
break;
case ATTRIBUTES:
if (value == null) {
unsetAttributes();
@ -378,14 +372,6 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
break;
case DURABILITY:
if (value == null) {
unsetDurability();
} else {
setDurability((TDurability)value);
}
break;
}
}
@ -397,12 +383,12 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
case COLUMNS:
return getColumns();
case WRITE_TO_WAL:
return Boolean.valueOf(isWriteToWal());
case ATTRIBUTES:
return getAttributes();
case DURABILITY:
return getDurability();
}
throw new IllegalStateException();
}
@ -418,10 +404,10 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
return isSetRow();
case COLUMNS:
return isSetColumns();
case WRITE_TO_WAL:
return isSetWriteToWal();
case ATTRIBUTES:
return isSetAttributes();
case DURABILITY:
return isSetDurability();
}
throw new IllegalStateException();
}
@ -457,6 +443,15 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
return false;
}
boolean this_present_writeToWal = true && this.isSetWriteToWal();
boolean that_present_writeToWal = true && that.isSetWriteToWal();
if (this_present_writeToWal || that_present_writeToWal) {
if (!(this_present_writeToWal && that_present_writeToWal))
return false;
if (this.writeToWal != that.writeToWal)
return false;
}
boolean this_present_attributes = true && this.isSetAttributes();
boolean that_present_attributes = true && that.isSetAttributes();
if (this_present_attributes || that_present_attributes) {
@ -466,15 +461,6 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
return false;
}
boolean this_present_durability = true && this.isSetDurability();
boolean that_present_durability = true && that.isSetDurability();
if (this_present_durability || that_present_durability) {
if (!(this_present_durability && that_present_durability))
return false;
if (!this.durability.equals(that.durability))
return false;
}
return true;
}
@ -511,6 +497,16 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetWriteToWal()).compareTo(typedOther.isSetWriteToWal());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetWriteToWal()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.writeToWal, typedOther.writeToWal);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetAttributes()).compareTo(typedOther.isSetAttributes());
if (lastComparison != 0) {
return lastComparison;
@ -521,16 +517,6 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetDurability()).compareTo(typedOther.isSetDurability());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetDurability()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.durability, typedOther.durability);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
@ -566,6 +552,12 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
sb.append(this.columns);
}
first = false;
if (isSetWriteToWal()) {
if (!first) sb.append(", ");
sb.append("writeToWal:");
sb.append(this.writeToWal);
first = false;
}
if (isSetAttributes()) {
if (!first) sb.append(", ");
sb.append("attributes:");
@ -576,16 +568,6 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
first = false;
}
if (isSetDurability()) {
if (!first) sb.append(", ");
sb.append("durability:");
if (this.durability == null) {
sb.append("null");
} else {
sb.append(this.durability);
}
first = false;
}
sb.append(")");
return sb.toString();
}
@ -611,6 +593,8 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
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_bitfield = 0;
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);
@ -650,7 +634,7 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
struct.columns = new ArrayList<TColumnIncrement>(_list62.size);
for (int _i63 = 0; _i63 < _list62.size; ++_i63)
{
TColumnIncrement _elem64; // optional
TColumnIncrement _elem64; // required
_elem64 = new TColumnIncrement();
_elem64.read(iprot);
struct.columns.add(_elem64);
@ -662,6 +646,14 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // WRITE_TO_WAL
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.writeToWal = iprot.readBool();
struct.setWriteToWalIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // ATTRIBUTES
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
@ -682,14 +674,6 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 5: // DURABILITY
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.durability = TDurability.findByValue(iprot.readI32());
struct.setDurabilityIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
@ -722,6 +706,11 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
oprot.writeFieldEnd();
}
if (struct.isSetWriteToWal()) {
oprot.writeFieldBegin(WRITE_TO_WAL_FIELD_DESC);
oprot.writeBool(struct.writeToWal);
oprot.writeFieldEnd();
}
if (struct.attributes != null) {
if (struct.isSetAttributes()) {
oprot.writeFieldBegin(ATTRIBUTES_FIELD_DESC);
@ -737,13 +726,6 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
oprot.writeFieldEnd();
}
}
if (struct.durability != null) {
if (struct.isSetDurability()) {
oprot.writeFieldBegin(DURABILITY_FIELD_DESC);
oprot.writeI32(struct.durability.getValue());
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@ -770,13 +752,16 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
}
BitSet optionals = new BitSet();
if (struct.isSetAttributes()) {
if (struct.isSetWriteToWal()) {
optionals.set(0);
}
if (struct.isSetDurability()) {
if (struct.isSetAttributes()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetWriteToWal()) {
oprot.writeBool(struct.writeToWal);
}
if (struct.isSetAttributes()) {
{
oprot.writeI32(struct.attributes.size());
@ -787,9 +772,6 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
}
}
if (struct.isSetDurability()) {
oprot.writeI32(struct.durability.getValue());
}
}
@Override
@ -802,7 +784,7 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
struct.columns = new ArrayList<TColumnIncrement>(_list73.size);
for (int _i74 = 0; _i74 < _list73.size; ++_i74)
{
TColumnIncrement _elem75; // optional
TColumnIncrement _elem75; // required
_elem75 = new TColumnIncrement();
_elem75.read(iprot);
struct.columns.add(_elem75);
@ -811,6 +793,10 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
struct.setColumnsIsSet(true);
BitSet incoming = iprot.readBitSet(2);
if (incoming.get(0)) {
struct.writeToWal = iprot.readBool();
struct.setWriteToWalIsSet(true);
}
if (incoming.get(1)) {
{
org.apache.thrift.protocol.TMap _map76 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.attributes = new HashMap<ByteBuffer,ByteBuffer>(2*_map76.size);
@ -825,10 +811,6 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
struct.setAttributesIsSet(true);
}
if (incoming.get(1)) {
struct.durability = TDurability.findByValue(iprot.readI32());
struct.setDurabilityIsSet(true);
}
}
}

View File

@ -38,9 +38,8 @@ import org.slf4j.LoggerFactory;
* don't have one. If you don't provide a default timestamp
* the current time is inserted.
*
* You can specify how this Put should be written to the write-ahead Log (WAL)
* by changing the durability. If you don't provide durability, it defaults to
* column family's default setting for durability.
* You can also specify if this Put should be written
* to the write-ahead Log (WAL) or not. It defaults to true.
*/
public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TPut");
@ -48,8 +47,8 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
private static final org.apache.thrift.protocol.TField ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("row", org.apache.thrift.protocol.TType.STRING, (short)1);
private static final org.apache.thrift.protocol.TField COLUMN_VALUES_FIELD_DESC = new org.apache.thrift.protocol.TField("columnValues", org.apache.thrift.protocol.TType.LIST, (short)2);
private static final org.apache.thrift.protocol.TField TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("timestamp", org.apache.thrift.protocol.TType.I64, (short)3);
private static final org.apache.thrift.protocol.TField WRITE_TO_WAL_FIELD_DESC = new org.apache.thrift.protocol.TField("writeToWal", org.apache.thrift.protocol.TType.BOOL, (short)4);
private static final org.apache.thrift.protocol.TField ATTRIBUTES_FIELD_DESC = new org.apache.thrift.protocol.TField("attributes", org.apache.thrift.protocol.TType.MAP, (short)5);
private static final org.apache.thrift.protocol.TField DURABILITY_FIELD_DESC = new org.apache.thrift.protocol.TField("durability", org.apache.thrift.protocol.TType.I32, (short)6);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
@ -60,24 +59,16 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
public ByteBuffer row; // required
public List<TColumnValue> columnValues; // required
public long timestamp; // optional
public boolean writeToWal; // optional
public Map<ByteBuffer,ByteBuffer> attributes; // optional
/**
*
* @see TDurability
*/
public TDurability durability; // 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 {
ROW((short)1, "row"),
COLUMN_VALUES((short)2, "columnValues"),
TIMESTAMP((short)3, "timestamp"),
ATTRIBUTES((short)5, "attributes"),
/**
*
* @see TDurability
*/
DURABILITY((short)6, "durability");
WRITE_TO_WAL((short)4, "writeToWal"),
ATTRIBUTES((short)5, "attributes");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@ -98,10 +89,10 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
return COLUMN_VALUES;
case 3: // TIMESTAMP
return TIMESTAMP;
case 4: // WRITE_TO_WAL
return WRITE_TO_WAL;
case 5: // ATTRIBUTES
return ATTRIBUTES;
case 6: // DURABILITY
return DURABILITY;
default:
return null;
}
@ -143,8 +134,9 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
// isset id assignments
private static final int __TIMESTAMP_ISSET_ID = 0;
private static final int __WRITETOWAL_ISSET_ID = 1;
private byte __isset_bitfield = 0;
private _Fields optionals[] = {_Fields.TIMESTAMP,_Fields.ATTRIBUTES,_Fields.DURABILITY};
private _Fields optionals[] = {_Fields.TIMESTAMP,_Fields.WRITE_TO_WAL,_Fields.ATTRIBUTES};
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);
@ -155,17 +147,19 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TColumnValue.class))));
tmpMap.put(_Fields.TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("timestamp", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
tmpMap.put(_Fields.WRITE_TO_WAL, new org.apache.thrift.meta_data.FieldMetaData("writeToWal", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.BOOL)));
tmpMap.put(_Fields.ATTRIBUTES, new org.apache.thrift.meta_data.FieldMetaData("attributes", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.MapMetaData(org.apache.thrift.protocol.TType.MAP,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true),
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true))));
tmpMap.put(_Fields.DURABILITY, new org.apache.thrift.meta_data.FieldMetaData("durability", org.apache.thrift.TFieldRequirementType.OPTIONAL,
new org.apache.thrift.meta_data.EnumMetaData(org.apache.thrift.protocol.TType.ENUM, TDurability.class)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TPut.class, metaDataMap);
}
public TPut() {
this.writeToWal = true;
}
public TPut(
@ -194,6 +188,7 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
this.columnValues = __this__columnValues;
}
this.timestamp = other.timestamp;
this.writeToWal = other.writeToWal;
if (other.isSetAttributes()) {
Map<ByteBuffer,ByteBuffer> __this__attributes = new HashMap<ByteBuffer,ByteBuffer>();
for (Map.Entry<ByteBuffer, ByteBuffer> other_element : other.attributes.entrySet()) {
@ -211,9 +206,6 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
}
this.attributes = __this__attributes;
}
if (other.isSetDurability()) {
this.durability = other.durability;
}
}
public TPut deepCopy() {
@ -226,8 +218,9 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
this.columnValues = null;
setTimestampIsSet(false);
this.timestamp = 0;
this.writeToWal = true;
this.attributes = null;
this.durability = null;
}
public byte[] getRow() {
@ -326,6 +319,29 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TIMESTAMP_ISSET_ID, value);
}
public boolean isWriteToWal() {
return this.writeToWal;
}
public TPut setWriteToWal(boolean writeToWal) {
this.writeToWal = writeToWal;
setWriteToWalIsSet(true);
return this;
}
public void unsetWriteToWal() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __WRITETOWAL_ISSET_ID);
}
/** Returns true if field writeToWal is set (has been assigned a value) and false otherwise */
public boolean isSetWriteToWal() {
return EncodingUtils.testBit(__isset_bitfield, __WRITETOWAL_ISSET_ID);
}
public void setWriteToWalIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __WRITETOWAL_ISSET_ID, value);
}
public int getAttributesSize() {
return (this.attributes == null) ? 0 : this.attributes.size();
}
@ -361,38 +377,6 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
}
}
/**
*
* @see TDurability
*/
public TDurability getDurability() {
return this.durability;
}
/**
*
* @see TDurability
*/
public TPut setDurability(TDurability durability) {
this.durability = durability;
return this;
}
public void unsetDurability() {
this.durability = null;
}
/** Returns true if field durability is set (has been assigned a value) and false otherwise */
public boolean isSetDurability() {
return this.durability != null;
}
public void setDurabilityIsSet(boolean value) {
if (!value) {
this.durability = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case ROW:
@ -419,6 +403,14 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
}
break;
case WRITE_TO_WAL:
if (value == null) {
unsetWriteToWal();
} else {
setWriteToWal((Boolean)value);
}
break;
case ATTRIBUTES:
if (value == null) {
unsetAttributes();
@ -427,14 +419,6 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
}
break;
case DURABILITY:
if (value == null) {
unsetDurability();
} else {
setDurability((TDurability)value);
}
break;
}
}
@ -449,12 +433,12 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
case TIMESTAMP:
return Long.valueOf(getTimestamp());
case WRITE_TO_WAL:
return Boolean.valueOf(isWriteToWal());
case ATTRIBUTES:
return getAttributes();
case DURABILITY:
return getDurability();
}
throw new IllegalStateException();
}
@ -472,10 +456,10 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
return isSetColumnValues();
case TIMESTAMP:
return isSetTimestamp();
case WRITE_TO_WAL:
return isSetWriteToWal();
case ATTRIBUTES:
return isSetAttributes();
case DURABILITY:
return isSetDurability();
}
throw new IllegalStateException();
}
@ -520,6 +504,15 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
return false;
}
boolean this_present_writeToWal = true && this.isSetWriteToWal();
boolean that_present_writeToWal = true && that.isSetWriteToWal();
if (this_present_writeToWal || that_present_writeToWal) {
if (!(this_present_writeToWal && that_present_writeToWal))
return false;
if (this.writeToWal != that.writeToWal)
return false;
}
boolean this_present_attributes = true && this.isSetAttributes();
boolean that_present_attributes = true && that.isSetAttributes();
if (this_present_attributes || that_present_attributes) {
@ -529,15 +522,6 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
return false;
}
boolean this_present_durability = true && this.isSetDurability();
boolean that_present_durability = true && that.isSetDurability();
if (this_present_durability || that_present_durability) {
if (!(this_present_durability && that_present_durability))
return false;
if (!this.durability.equals(that.durability))
return false;
}
return true;
}
@ -584,6 +568,16 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetWriteToWal()).compareTo(typedOther.isSetWriteToWal());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetWriteToWal()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.writeToWal, typedOther.writeToWal);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetAttributes()).compareTo(typedOther.isSetAttributes());
if (lastComparison != 0) {
return lastComparison;
@ -594,16 +588,6 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetDurability()).compareTo(typedOther.isSetDurability());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetDurability()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.durability, typedOther.durability);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
@ -645,6 +629,12 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
sb.append(this.timestamp);
first = false;
}
if (isSetWriteToWal()) {
if (!first) sb.append(", ");
sb.append("writeToWal:");
sb.append(this.writeToWal);
first = false;
}
if (isSetAttributes()) {
if (!first) sb.append(", ");
sb.append("attributes:");
@ -655,16 +645,6 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
}
first = false;
}
if (isSetDurability()) {
if (!first) sb.append(", ");
sb.append("durability:");
if (this.durability == null) {
sb.append("null");
} else {
sb.append(this.durability);
}
first = false;
}
sb.append(")");
return sb.toString();
}
@ -731,7 +711,7 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
struct.columnValues = new ArrayList<TColumnValue>(_list26.size);
for (int _i27 = 0; _i27 < _list26.size; ++_i27)
{
TColumnValue _elem28; // optional
TColumnValue _elem28; // required
_elem28 = new TColumnValue();
_elem28.read(iprot);
struct.columnValues.add(_elem28);
@ -751,6 +731,14 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // WRITE_TO_WAL
if (schemeField.type == org.apache.thrift.protocol.TType.BOOL) {
struct.writeToWal = iprot.readBool();
struct.setWriteToWalIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 5: // ATTRIBUTES
if (schemeField.type == org.apache.thrift.protocol.TType.MAP) {
{
@ -771,14 +759,6 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 6: // DURABILITY
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.durability = TDurability.findByValue(iprot.readI32());
struct.setDurabilityIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
@ -816,6 +796,11 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
oprot.writeI64(struct.timestamp);
oprot.writeFieldEnd();
}
if (struct.isSetWriteToWal()) {
oprot.writeFieldBegin(WRITE_TO_WAL_FIELD_DESC);
oprot.writeBool(struct.writeToWal);
oprot.writeFieldEnd();
}
if (struct.attributes != null) {
if (struct.isSetAttributes()) {
oprot.writeFieldBegin(ATTRIBUTES_FIELD_DESC);
@ -831,13 +816,6 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
oprot.writeFieldEnd();
}
}
if (struct.durability != null) {
if (struct.isSetDurability()) {
oprot.writeFieldBegin(DURABILITY_FIELD_DESC);
oprot.writeI32(struct.durability.getValue());
oprot.writeFieldEnd();
}
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
@ -867,16 +845,19 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
if (struct.isSetTimestamp()) {
optionals.set(0);
}
if (struct.isSetAttributes()) {
if (struct.isSetWriteToWal()) {
optionals.set(1);
}
if (struct.isSetDurability()) {
if (struct.isSetAttributes()) {
optionals.set(2);
}
oprot.writeBitSet(optionals, 3);
if (struct.isSetTimestamp()) {
oprot.writeI64(struct.timestamp);
}
if (struct.isSetWriteToWal()) {
oprot.writeBool(struct.writeToWal);
}
if (struct.isSetAttributes()) {
{
oprot.writeI32(struct.attributes.size());
@ -887,9 +868,6 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
}
}
}
if (struct.isSetDurability()) {
oprot.writeI32(struct.durability.getValue());
}
}
@Override
@ -902,7 +880,7 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
struct.columnValues = new ArrayList<TColumnValue>(_list37.size);
for (int _i38 = 0; _i38 < _list37.size; ++_i38)
{
TColumnValue _elem39; // optional
TColumnValue _elem39; // required
_elem39 = new TColumnValue();
_elem39.read(iprot);
struct.columnValues.add(_elem39);
@ -915,6 +893,10 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
struct.setTimestampIsSet(true);
}
if (incoming.get(1)) {
struct.writeToWal = iprot.readBool();
struct.setWriteToWalIsSet(true);
}
if (incoming.get(2)) {
{
org.apache.thrift.protocol.TMap _map40 = new org.apache.thrift.protocol.TMap(org.apache.thrift.protocol.TType.STRING, org.apache.thrift.protocol.TType.STRING, iprot.readI32());
struct.attributes = new HashMap<ByteBuffer,ByteBuffer>(2*_map40.size);
@ -929,10 +911,6 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
}
struct.setAttributesIsSet(true);
}
if (incoming.get(2)) {
struct.durability = TDurability.findByValue(iprot.readI32());
struct.setDurabilityIsSet(true);
}
}
}

View File

@ -77,21 +77,6 @@ enum TDeleteType {
DELETE_COLUMNS = 1
}
/**
* Specify Durability:
* - SKIP_WAL means do not write the Mutation to the WAL.
* - ASYNC_WAL means write the Mutation to the WAL asynchronously,
* - SYNC_WAL means write the Mutation to the WAL synchronously,
* - FSYNC_WAL means Write the Mutation to the WAL synchronously and force the entries to disk.
*/
enum TDurability {
SKIP_WAL = 1,
ASYNC_WAL = 2,
SYNC_WAL = 3,
FSYNC_WAL = 4
}
/**
* Used to perform Get operations on a single row.
*
@ -125,16 +110,15 @@ struct TGet {
* don't have one. If you don't provide a default timestamp
* the current time is inserted.
*
* You can specify how this Put should be written to the write-ahead Log (WAL)
* by changing the durability. If you don't provide durability, it defaults to
* column family's default setting for durability.
* You can also specify if this Put should be written
* to the write-ahead Log (WAL) or not. It defaults to true.
*/
struct TPut {
1: required binary row,
2: required list<TColumnValue> columnValues
3: optional i64 timestamp,
5: optional map<binary, binary> attributes,
6: optional TDurability durability
4: optional bool writeToWal = 1,
5: optional map<binary, binary> attributes
}
/**
@ -159,32 +143,27 @@ struct TPut {
* as if you had added a TColumn for every column family and this timestamp
* (i.e. all versions older than or equal in all column families will be deleted)
*
* You can specify how this Delete should be written to the write-ahead Log (WAL)
* by changing the durability. If you don't provide durability, it defaults to
* column family's default setting for durability.
*/
struct TDelete {
1: required binary row,
2: optional list<TColumn> columns,
3: optional i64 timestamp,
4: optional TDeleteType deleteType = 1,
6: optional map<binary, binary> attributes,
7: optional TDurability durability
5: optional bool writeToWal = 1,
6: optional map<binary, binary> attributes
}
/**
* Used to perform Increment operations for a single row.
*
* You can specify how this Increment should be written to the write-ahead Log (WAL)
* by changing the durability. If you don't provide durability, it defaults to
* column family's default setting for durability.
* You can specify if this Increment should be written
* to the write-ahead Log (WAL) or not. It defaults to true.
*/
struct TIncrement {
1: required binary row,
2: required list<TColumnIncrement> columns,
4: optional map<binary, binary> attributes,
5: optional TDurability durability
3: optional bool writeToWal = 1,
4: optional map<binary, binary> attributes
}
/**

View File

@ -32,7 +32,6 @@ import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.client.Increment;
import org.apache.hadoop.hbase.client.Delete;
import org.apache.hadoop.hbase.client.Durability;
import org.apache.hadoop.hbase.filter.ParseFilter;
import org.apache.hadoop.hbase.test.MetricsAssertHelper;
import org.apache.hadoop.hbase.thrift.ThriftMetrics;
@ -51,7 +50,6 @@ import org.apache.hadoop.hbase.thrift2.generated.TResult;
import org.apache.hadoop.hbase.thrift2.generated.TScan;
import org.apache.hadoop.hbase.thrift2.generated.TMutation;
import org.apache.hadoop.hbase.thrift2.generated.TRowMutations;
import org.apache.hadoop.hbase.thrift2.generated.TDurability;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.thrift.TException;
import org.junit.AfterClass;
@ -866,74 +864,5 @@ public class TestThriftHBaseServiceHandler {
expectedColumnValues.add(columnValueB);
assertTColumnValuesEqual(expectedColumnValues, returnedColumnValues);
}
/**
* Create TPut, TDelete , TIncrement objects, set durability then call ThriftUtility
* functions to get Put , Delete and Increment respectively. Use getDurability to make sure
* the returned objects have the appropriate durability setting.
*
* @throws Exception
*/
@Test
public void testDurability() throws Exception {
byte[] rowName = "testDurability".getBytes();
List<TColumnValue> columnValues = new ArrayList<TColumnValue>();
columnValues.add(new TColumnValue(wrap(familyAname), wrap(qualifierAname), wrap(valueAname)));
List<TColumnIncrement> incrementColumns = new ArrayList<TColumnIncrement>();
incrementColumns.add(new TColumnIncrement(wrap(familyAname), wrap(qualifierAname)));
TDelete tDelete = new TDelete(wrap(rowName));
tDelete.setDurability(TDurability.SKIP_WAL);
Delete delete = deleteFromThrift(tDelete);
assertEquals(delete.getDurability(), Durability.SKIP_WAL);
tDelete.setDurability(TDurability.ASYNC_WAL);
delete = deleteFromThrift(tDelete);
assertEquals(delete.getDurability(), Durability.ASYNC_WAL);
tDelete.setDurability(TDurability.SYNC_WAL);
delete = deleteFromThrift(tDelete);
assertEquals(delete.getDurability(), Durability.SYNC_WAL);
tDelete.setDurability(TDurability.FSYNC_WAL);
delete = deleteFromThrift(tDelete);
assertEquals(delete.getDurability(), Durability.FSYNC_WAL);
TPut tPut = new TPut(wrap(rowName), columnValues);
tPut.setDurability(TDurability.SKIP_WAL);
Put put = putFromThrift(tPut);
assertEquals(put.getDurability(), Durability.SKIP_WAL);
tPut.setDurability(TDurability.ASYNC_WAL);
put = putFromThrift(tPut);
assertEquals(put.getDurability(), Durability.ASYNC_WAL);
tPut.setDurability(TDurability.SYNC_WAL);
put = putFromThrift(tPut);
assertEquals(put.getDurability(), Durability.SYNC_WAL);
tPut.setDurability(TDurability.FSYNC_WAL);
put = putFromThrift(tPut);
assertEquals(put.getDurability(), Durability.FSYNC_WAL);
TIncrement tIncrement = new TIncrement(wrap(rowName), incrementColumns);
tIncrement.setDurability(TDurability.SKIP_WAL);
Increment increment = incrementFromThrift(tIncrement);
assertEquals(increment.getDurability(), Durability.SKIP_WAL);
tIncrement.setDurability(TDurability.ASYNC_WAL);
increment = incrementFromThrift(tIncrement);
assertEquals(increment.getDurability(), Durability.ASYNC_WAL);
tIncrement.setDurability(TDurability.SYNC_WAL);
increment = incrementFromThrift(tIncrement);
assertEquals(increment.getDurability(), Durability.SYNC_WAL);
tIncrement.setDurability(TDurability.FSYNC_WAL);
increment = incrementFromThrift(tIncrement);
assertEquals(increment.getDurability(), Durability.FSYNC_WAL);
}
}