HBASE-8947 Thrift 2 : Replace "bool writeToWAL" with "TDurability durability" (Hamed Madani) - REAPPLY after REVERT

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1507205 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Lars George 2013-07-26 07:32:19 +00:00
parent 260b8b644d
commit 350b3aca0c
6 changed files with 495 additions and 321 deletions

View File

@ -167,7 +167,9 @@ public class ThriftUtilities {
out = new Put(in.getRow());
}
out.setDurability(in.isWriteToWal() ? Durability.SYNC_WAL : Durability.SKIP_WAL);
if (in.isSetDurability()) {
out.setDurability(durabilityFromThrift(in.getDurability()));
}
for (TColumnValue columnValue : in.getColumnValues()) {
if (columnValue.isSetTimestamp()) {
@ -250,7 +252,10 @@ public class ThriftUtilities {
addAttributes(out,in.getAttributes());
}
out.setDurability(in.isWriteToWal() ? Durability.SYNC_WAL : Durability.SKIP_WAL);
if (in.isSetDurability()) {
out.setDurability(durabilityFromThrift(in.getDurability()));
}
return out;
}
@ -383,7 +388,10 @@ public class ThriftUtilities {
addAttributes(out,in.getAttributes());
}
out.setDurability(in.isWriteToWal() ? Durability.SYNC_WAL : Durability.SKIP_WAL);
if (in.isSetDurability()) {
out.setDurability(durabilityFromThrift(in.getDurability()));
}
return out;
}
@ -401,4 +409,14 @@ 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,6 +52,9 @@ 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");
@ -60,8 +63,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 {
@ -77,8 +80,12 @@ 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 {
@ -90,8 +97,12 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
* @see TDeleteType
*/
DELETE_TYPE((short)4, "deleteType"),
WRITE_TO_WAL((short)5, "writeToWal"),
ATTRIBUTES((short)6, "attributes");
ATTRIBUTES((short)6, "attributes"),
/**
*
* @see TDurability
*/
DURABILITY((short)7, "durability");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@ -114,10 +125,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;
}
@ -159,9 +170,8 @@ 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.WRITE_TO_WAL,_Fields.ATTRIBUTES};
private _Fields optionals[] = {_Fields.COLUMNS,_Fields.TIMESTAMP,_Fields.DELETE_TYPE,_Fields.ATTRIBUTES,_Fields.DURABILITY};
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);
@ -174,12 +184,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);
}
@ -187,8 +197,6 @@ 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(
@ -218,7 +226,6 @@ 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()) {
@ -236,6 +243,9 @@ 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() {
@ -250,9 +260,8 @@ 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() {
@ -383,29 +392,6 @@ 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();
}
@ -441,6 +427,38 @@ 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:
@ -475,14 +493,6 @@ 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();
@ -491,6 +501,14 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
}
break;
case DURABILITY:
if (value == null) {
unsetDurability();
} else {
setDurability((TDurability)value);
}
break;
}
}
@ -508,12 +526,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();
}
@ -533,10 +551,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();
}
@ -590,15 +608,6 @@ 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) {
@ -608,6 +617,15 @@ 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;
}
@ -664,16 +682,6 @@ 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;
@ -684,6 +692,16 @@ 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;
}
@ -737,12 +755,6 @@ 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:");
@ -753,6 +765,16 @@ 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();
}
@ -816,7 +838,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; // required
TColumn _elem46; // optional
_elem46 = new TColumn();
_elem46.read(iprot);
struct.columns.add(_elem46);
@ -844,14 +866,6 @@ 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) {
{
@ -872,6 +886,14 @@ 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);
}
@ -918,11 +940,6 @@ 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);
@ -938,6 +955,13 @@ 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();
}
@ -966,10 +990,10 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
if (struct.isSetDeleteType()) {
optionals.set(2);
}
if (struct.isSetWriteToWal()) {
if (struct.isSetAttributes()) {
optionals.set(3);
}
if (struct.isSetAttributes()) {
if (struct.isSetDurability()) {
optionals.set(4);
}
oprot.writeBitSet(optionals, 5);
@ -988,9 +1012,6 @@ 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());
@ -1001,6 +1022,9 @@ public class TDelete implements org.apache.thrift.TBase<TDelete, TDelete._Fields
}
}
}
if (struct.isSetDurability()) {
oprot.writeI32(struct.durability.getValue());
}
}
@Override
@ -1015,7 +1039,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; // required
TColumn _elem57; // optional
_elem57 = new TColumn();
_elem57.read(iprot);
struct.columns.add(_elem57);
@ -1032,10 +1056,6 @@ 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);
@ -1050,6 +1070,10 @@ 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,16 +33,17 @@ import org.slf4j.LoggerFactory;
/**
* Used to perform Increment operations for a single row.
*
* You can specify if this Increment should be written
* to the write-ahead Log (WAL) or not. It defaults to true.
* 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.
*/
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 {
@ -52,15 +53,23 @@ 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"),
WRITE_TO_WAL((short)3, "writeToWal"),
ATTRIBUTES((short)4, "attributes");
ATTRIBUTES((short)4, "attributes"),
/**
*
* @see TDurability
*/
DURABILITY((short)5, "durability");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@ -79,10 +88,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;
}
@ -123,9 +132,7 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
// isset id assignments
private static final int __WRITETOWAL_ISSET_ID = 0;
private byte __isset_bitfield = 0;
private _Fields optionals[] = {_Fields.WRITE_TO_WAL,_Fields.ATTRIBUTES};
private _Fields optionals[] = {_Fields.ATTRIBUTES,_Fields.DURABILITY};
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);
@ -134,19 +141,17 @@ 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(
@ -162,7 +167,6 @@ 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);
;
@ -174,7 +178,6 @@ 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()) {
@ -192,6 +195,9 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
this.attributes = __this__attributes;
}
if (other.isSetDurability()) {
this.durability = other.durability;
}
}
public TIncrement deepCopy() {
@ -202,9 +208,8 @@ 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() {
@ -280,29 +285,6 @@ 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();
}
@ -338,6 +320,38 @@ 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:
@ -356,14 +370,6 @@ 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();
@ -372,6 +378,14 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
break;
case DURABILITY:
if (value == null) {
unsetDurability();
} else {
setDurability((TDurability)value);
}
break;
}
}
@ -383,12 +397,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();
}
@ -404,10 +418,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();
}
@ -443,15 +457,6 @@ 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) {
@ -461,6 +466,15 @@ 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;
}
@ -497,16 +511,6 @@ 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;
@ -517,6 +521,16 @@ 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;
}
@ -552,12 +566,6 @@ 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:");
@ -568,6 +576,16 @@ 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();
}
@ -593,8 +611,6 @@ 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);
@ -634,7 +650,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; // required
TColumnIncrement _elem64; // optional
_elem64 = new TColumnIncrement();
_elem64.read(iprot);
struct.columns.add(_elem64);
@ -646,14 +662,6 @@ 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) {
{
@ -674,6 +682,14 @@ 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);
}
@ -706,11 +722,6 @@ 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);
@ -726,6 +737,13 @@ 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();
}
@ -752,16 +770,13 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
}
BitSet optionals = new BitSet();
if (struct.isSetWriteToWal()) {
if (struct.isSetAttributes()) {
optionals.set(0);
}
if (struct.isSetAttributes()) {
if (struct.isSetDurability()) {
optionals.set(1);
}
oprot.writeBitSet(optionals, 2);
if (struct.isSetWriteToWal()) {
oprot.writeBool(struct.writeToWal);
}
if (struct.isSetAttributes()) {
{
oprot.writeI32(struct.attributes.size());
@ -772,6 +787,9 @@ public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncremen
}
}
}
if (struct.isSetDurability()) {
oprot.writeI32(struct.durability.getValue());
}
}
@Override
@ -784,7 +802,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; // required
TColumnIncrement _elem75; // optional
_elem75 = new TColumnIncrement();
_elem75.read(iprot);
struct.columns.add(_elem75);
@ -793,10 +811,6 @@ 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);
@ -811,6 +825,10 @@ 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,8 +38,9 @@ import org.slf4j.LoggerFactory;
* don't have one. If you don't provide a default timestamp
* the current time is inserted.
*
* You can also specify if this Put should be written
* to the write-ahead Log (WAL) or not. It defaults to true.
* 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.
*/
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");
@ -47,8 +48,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 {
@ -59,16 +60,24 @@ 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"),
WRITE_TO_WAL((short)4, "writeToWal"),
ATTRIBUTES((short)5, "attributes");
ATTRIBUTES((short)5, "attributes"),
/**
*
* @see TDurability
*/
DURABILITY((short)6, "durability");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
@ -89,10 +98,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;
}
@ -134,9 +143,8 @@ 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.WRITE_TO_WAL,_Fields.ATTRIBUTES};
private _Fields optionals[] = {_Fields.TIMESTAMP,_Fields.ATTRIBUTES,_Fields.DURABILITY};
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);
@ -147,19 +155,17 @@ 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(
@ -188,7 +194,6 @@ 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()) {
@ -206,6 +211,9 @@ 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() {
@ -218,9 +226,8 @@ 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() {
@ -319,29 +326,6 @@ 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();
}
@ -377,6 +361,38 @@ 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:
@ -403,14 +419,6 @@ 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();
@ -419,6 +427,14 @@ 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;
}
}
@ -433,12 +449,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();
}
@ -456,10 +472,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();
}
@ -504,15 +520,6 @@ 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) {
@ -522,6 +529,15 @@ 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;
}
@ -568,16 +584,6 @@ 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;
@ -588,6 +594,16 @@ 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;
}
@ -629,12 +645,6 @@ 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:");
@ -645,6 +655,16 @@ 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();
}
@ -711,7 +731,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; // required
TColumnValue _elem28; // optional
_elem28 = new TColumnValue();
_elem28.read(iprot);
struct.columnValues.add(_elem28);
@ -731,14 +751,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 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) {
{
@ -759,6 +771,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 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);
}
@ -796,11 +816,6 @@ 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);
@ -816,6 +831,13 @@ 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();
}
@ -845,19 +867,16 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
if (struct.isSetTimestamp()) {
optionals.set(0);
}
if (struct.isSetWriteToWal()) {
if (struct.isSetAttributes()) {
optionals.set(1);
}
if (struct.isSetAttributes()) {
if (struct.isSetDurability()) {
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());
@ -868,6 +887,9 @@ public class TPut implements org.apache.thrift.TBase<TPut, TPut._Fields>, java.i
}
}
}
if (struct.isSetDurability()) {
oprot.writeI32(struct.durability.getValue());
}
}
@Override
@ -880,7 +902,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; // required
TColumnValue _elem39; // optional
_elem39 = new TColumnValue();
_elem39.read(iprot);
struct.columnValues.add(_elem39);
@ -893,10 +915,6 @@ 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);
@ -911,6 +929,10 @@ 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,6 +77,21 @@ 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.
*
@ -110,15 +125,16 @@ struct TGet {
* don't have one. If you don't provide a default timestamp
* the current time is inserted.
*
* You can also specify if this Put should be written
* to the write-ahead Log (WAL) or not. It defaults to true.
* 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.
*/
struct TPut {
1: required binary row,
2: required list<TColumnValue> columnValues
3: optional i64 timestamp,
4: optional bool writeToWal = 1,
5: optional map<binary, binary> attributes
5: optional map<binary, binary> attributes,
6: optional TDurability durability
}
/**
@ -143,27 +159,32 @@ 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,
5: optional bool writeToWal = 1,
6: optional map<binary, binary> attributes
6: optional map<binary, binary> attributes,
7: optional TDurability durability
}
/**
* Used to perform Increment operations for a single row.
*
* You can specify if this Increment should be written
* to the write-ahead Log (WAL) or not. It defaults to true.
* 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.
*/
struct TIncrement {
1: required binary row,
2: required list<TColumnIncrement> columns,
3: optional bool writeToWal = 1,
4: optional map<binary, binary> attributes
4: optional map<binary, binary> attributes,
5: optional TDurability durability
}
/**

View File

@ -32,6 +32,7 @@ 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;
@ -50,6 +51,7 @@ 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;
@ -864,5 +866,74 @@ 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);
}
}