/**
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package com.yahoo.ycsb.db.tpcc.helper.rows;
import org.apache.thrift.scheme.IScheme;
import org.apache.thrift.scheme.SchemeFactory;
import org.apache.thrift.scheme.StandardScheme;
import org.apache.thrift.scheme.TupleScheme;
import org.apache.thrift.protocol.TTupleProtocol;
import org.apache.thrift.protocol.TProtocolException;
import org.apache.thrift.EncodingUtils;
import org.apache.thrift.TException;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.EnumMap;
import java.util.Set;
import java.util.HashSet;
import java.util.EnumSet;
import java.util.Collections;
import java.util.BitSet;
import java.nio.ByteBuffer;
import java.util.Arrays;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ItemRow implements org.apache.thrift.TBase<ItemRow, ItemRow._Fields>, java.io.Serializable, Cloneable {
private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("ItemRow");
private static final org.apache.thrift.protocol.TField I_IM_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("i_im_id", org.apache.thrift.protocol.TType.I32, (short)1);
private static final org.apache.thrift.protocol.TField I_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("i_name", org.apache.thrift.protocol.TType.STRING, (short)2);
private static final org.apache.thrift.protocol.TField I_PRICE_FIELD_DESC = new org.apache.thrift.protocol.TField("i_price", org.apache.thrift.protocol.TType.DOUBLE, (short)3);
private static final org.apache.thrift.protocol.TField I_DATA_FIELD_DESC = new org.apache.thrift.protocol.TField("i_data", org.apache.thrift.protocol.TType.STRING, (short)4);
private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
static {
schemes.put(StandardScheme.class, new ItemRowStandardSchemeFactory());
schemes.put(TupleScheme.class, new ItemRowTupleSchemeFactory());
}
public int i_im_id; // required
public String i_name; // required
public double i_price; // required
public String i_data; // required
/** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
public enum _Fields implements org.apache.thrift.TFieldIdEnum {
I_IM_ID((short)1, "i_im_id"),
I_NAME((short)2, "i_name"),
I_PRICE((short)3, "i_price"),
I_DATA((short)4, "i_data");
private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
static {
for (_Fields field : EnumSet.allOf(_Fields.class)) {
byName.put(field.getFieldName(), field);
}
}
/**
* Find the _Fields constant that matches fieldId, or null if its not found.
*/
public static _Fields findByThriftId(int fieldId) {
switch(fieldId) {
case 1: // I_IM_ID
return I_IM_ID;
case 2: // I_NAME
return I_NAME;
case 3: // I_PRICE
return I_PRICE;
case 4: // I_DATA
return I_DATA;
default:
return null;
}
}
/**
* Find the _Fields constant that matches fieldId, throwing an exception
* if it is not found.
*/
public static _Fields findByThriftIdOrThrow(int fieldId) {
_Fields fields = findByThriftId(fieldId);
if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
return fields;
}
/**
* Find the _Fields constant that matches name, or null if its not found.
*/
public static _Fields findByName(String name) {
return byName.get(name);
}
private final short _thriftId;
private final String _fieldName;
_Fields(short thriftId, String fieldName) {
_thriftId = thriftId;
_fieldName = fieldName;
}
public short getThriftFieldId() {
return _thriftId;
}
public String getFieldName() {
return _fieldName;
}
}
// isset id assignments
private static final int __I_IM_ID_ISSET_ID = 0;
private static final int __I_PRICE_ISSET_ID = 1;
private byte __isset_bitfield = 0;
public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
static {
Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
tmpMap.put(_Fields.I_IM_ID, new org.apache.thrift.meta_data.FieldMetaData("i_im_id", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
tmpMap.put(_Fields.I_NAME, new org.apache.thrift.meta_data.FieldMetaData("i_name", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
tmpMap.put(_Fields.I_PRICE, new org.apache.thrift.meta_data.FieldMetaData("i_price", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.DOUBLE)));
tmpMap.put(_Fields.I_DATA, new org.apache.thrift.meta_data.FieldMetaData("i_data", org.apache.thrift.TFieldRequirementType.DEFAULT,
new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
metaDataMap = Collections.unmodifiableMap(tmpMap);
org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(ItemRow.class, metaDataMap);
}
public ItemRow() {
}
public ItemRow(
int i_im_id,
String i_name,
double i_price,
String i_data)
{
this();
this.i_im_id = i_im_id;
setI_im_idIsSet(true);
this.i_name = i_name;
this.i_price = i_price;
setI_priceIsSet(true);
this.i_data = i_data;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public ItemRow(ItemRow other) {
__isset_bitfield = other.__isset_bitfield;
this.i_im_id = other.i_im_id;
if (other.isSetI_name()) {
this.i_name = other.i_name;
}
this.i_price = other.i_price;
if (other.isSetI_data()) {
this.i_data = other.i_data;
}
}
public ItemRow deepCopy() {
return new ItemRow(this);
}
@Override
public void clear() {
setI_im_idIsSet(false);
this.i_im_id = 0;
this.i_name = null;
setI_priceIsSet(false);
this.i_price = 0.0;
this.i_data = null;
}
public int getI_im_id() {
return this.i_im_id;
}
public ItemRow setI_im_id(int i_im_id) {
this.i_im_id = i_im_id;
setI_im_idIsSet(true);
return this;
}
public void unsetI_im_id() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __I_IM_ID_ISSET_ID);
}
/** Returns true if field i_im_id is set (has been assigned a value) and false otherwise */
public boolean isSetI_im_id() {
return EncodingUtils.testBit(__isset_bitfield, __I_IM_ID_ISSET_ID);
}
public void setI_im_idIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __I_IM_ID_ISSET_ID, value);
}
public String getI_name() {
return this.i_name;
}
public ItemRow setI_name(String i_name) {
this.i_name = i_name;
return this;
}
public void unsetI_name() {
this.i_name = null;
}
/** Returns true if field i_name is set (has been assigned a value) and false otherwise */
public boolean isSetI_name() {
return this.i_name != null;
}
public void setI_nameIsSet(boolean value) {
if (!value) {
this.i_name = null;
}
}
public double getI_price() {
return this.i_price;
}
public ItemRow setI_price(double i_price) {
this.i_price = i_price;
setI_priceIsSet(true);
return this;
}
public void unsetI_price() {
__isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __I_PRICE_ISSET_ID);
}
/** Returns true if field i_price is set (has been assigned a value) and false otherwise */
public boolean isSetI_price() {
return EncodingUtils.testBit(__isset_bitfield, __I_PRICE_ISSET_ID);
}
public void setI_priceIsSet(boolean value) {
__isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __I_PRICE_ISSET_ID, value);
}
public String getI_data() {
return this.i_data;
}
public ItemRow setI_data(String i_data) {
this.i_data = i_data;
return this;
}
public void unsetI_data() {
this.i_data = null;
}
/** Returns true if field i_data is set (has been assigned a value) and false otherwise */
public boolean isSetI_data() {
return this.i_data != null;
}
public void setI_dataIsSet(boolean value) {
if (!value) {
this.i_data = null;
}
}
public void setFieldValue(_Fields field, Object value) {
switch (field) {
case I_IM_ID:
if (value == null) {
unsetI_im_id();
} else {
setI_im_id((Integer)value);
}
break;
case I_NAME:
if (value == null) {
unsetI_name();
} else {
setI_name((String)value);
}
break;
case I_PRICE:
if (value == null) {
unsetI_price();
} else {
setI_price((Double)value);
}
break;
case I_DATA:
if (value == null) {
unsetI_data();
} else {
setI_data((String)value);
}
break;
}
}
public Object getFieldValue(_Fields field) {
switch (field) {
case I_IM_ID:
return Integer.valueOf(getI_im_id());
case I_NAME:
return getI_name();
case I_PRICE:
return Double.valueOf(getI_price());
case I_DATA:
return getI_data();
}
throw new IllegalStateException();
}
/** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
public boolean isSet(_Fields field) {
if (field == null) {
throw new IllegalArgumentException();
}
switch (field) {
case I_IM_ID:
return isSetI_im_id();
case I_NAME:
return isSetI_name();
case I_PRICE:
return isSetI_price();
case I_DATA:
return isSetI_data();
}
throw new IllegalStateException();
}
@Override
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof ItemRow)
return this.equals((ItemRow)that);
return false;
}
public boolean equals(ItemRow that) {
if (that == null)
return false;
boolean this_present_i_im_id = true;
boolean that_present_i_im_id = true;
if (this_present_i_im_id || that_present_i_im_id) {
if (!(this_present_i_im_id && that_present_i_im_id))
return false;
if (this.i_im_id != that.i_im_id)
return false;
}
boolean this_present_i_name = true && this.isSetI_name();
boolean that_present_i_name = true && that.isSetI_name();
if (this_present_i_name || that_present_i_name) {
if (!(this_present_i_name && that_present_i_name))
return false;
if (!this.i_name.equals(that.i_name))
return false;
}
boolean this_present_i_price = true;
boolean that_present_i_price = true;
if (this_present_i_price || that_present_i_price) {
if (!(this_present_i_price && that_present_i_price))
return false;
if (this.i_price != that.i_price)
return false;
}
boolean this_present_i_data = true && this.isSetI_data();
boolean that_present_i_data = true && that.isSetI_data();
if (this_present_i_data || that_present_i_data) {
if (!(this_present_i_data && that_present_i_data))
return false;
if (!this.i_data.equals(that.i_data))
return false;
}
return true;
}
@Override
public int hashCode() {
return 0;
}
public int compareTo(ItemRow other) {
if (!getClass().equals(other.getClass())) {
return getClass().getName().compareTo(other.getClass().getName());
}
int lastComparison = 0;
ItemRow typedOther = (ItemRow)other;
lastComparison = Boolean.valueOf(isSetI_im_id()).compareTo(typedOther.isSetI_im_id());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetI_im_id()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.i_im_id, typedOther.i_im_id);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetI_name()).compareTo(typedOther.isSetI_name());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetI_name()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.i_name, typedOther.i_name);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetI_price()).compareTo(typedOther.isSetI_price());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetI_price()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.i_price, typedOther.i_price);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = Boolean.valueOf(isSetI_data()).compareTo(typedOther.isSetI_data());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetI_data()) {
lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.i_data, typedOther.i_data);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public _Fields fieldForId(int fieldId) {
return _Fields.findByThriftId(fieldId);
}
public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
}
public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("ItemRow(");
boolean first = true;
sb.append("i_im_id:");
sb.append(this.i_im_id);
first = false;
if (!first) sb.append(", ");
sb.append("i_name:");
if (this.i_name == null) {
sb.append("null");
} else {
sb.append(this.i_name);
}
first = false;
if (!first) sb.append(", ");
sb.append("i_price:");
sb.append(this.i_price);
first = false;
if (!first) sb.append(", ");
sb.append("i_data:");
if (this.i_data == null) {
sb.append("null");
} else {
sb.append(this.i_data);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws org.apache.thrift.TException {
// check for required fields
// check for sub-struct validity
}
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
try {
write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
} catch (org.apache.thrift.TException te) {
throw new java.io.IOException(te);
}
}
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
try {
// 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);
}
}
private static class ItemRowStandardSchemeFactory implements SchemeFactory {
public ItemRowStandardScheme getScheme() {
return new ItemRowStandardScheme();
}
}
private static class ItemRowStandardScheme extends StandardScheme<ItemRow> {
public void read(org.apache.thrift.protocol.TProtocol iprot, ItemRow struct) throws org.apache.thrift.TException {
org.apache.thrift.protocol.TField schemeField;
iprot.readStructBegin();
while (true)
{
schemeField = iprot.readFieldBegin();
if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
break;
}
switch (schemeField.id) {
case 1: // I_IM_ID
if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
struct.i_im_id = iprot.readI32();
struct.setI_im_idIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 2: // I_NAME
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.i_name = iprot.readString();
struct.setI_nameIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 3: // I_PRICE
if (schemeField.type == org.apache.thrift.protocol.TType.DOUBLE) {
struct.i_price = iprot.readDouble();
struct.setI_priceIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
case 4: // I_DATA
if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
struct.i_data = iprot.readString();
struct.setI_dataIsSet(true);
} else {
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
break;
default:
org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
// check for required fields of primitive type, which can't be checked in the validate method
struct.validate();
}
public void write(org.apache.thrift.protocol.TProtocol oprot, ItemRow struct) throws org.apache.thrift.TException {
struct.validate();
oprot.writeStructBegin(STRUCT_DESC);
oprot.writeFieldBegin(I_IM_ID_FIELD_DESC);
oprot.writeI32(struct.i_im_id);
oprot.writeFieldEnd();
if (struct.i_name != null) {
oprot.writeFieldBegin(I_NAME_FIELD_DESC);
oprot.writeString(struct.i_name);
oprot.writeFieldEnd();
}
oprot.writeFieldBegin(I_PRICE_FIELD_DESC);
oprot.writeDouble(struct.i_price);
oprot.writeFieldEnd();
if (struct.i_data != null) {
oprot.writeFieldBegin(I_DATA_FIELD_DESC);
oprot.writeString(struct.i_data);
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
}
private static class ItemRowTupleSchemeFactory implements SchemeFactory {
public ItemRowTupleScheme getScheme() {
return new ItemRowTupleScheme();
}
}
private static class ItemRowTupleScheme extends TupleScheme<ItemRow> {
@Override
public void write(org.apache.thrift.protocol.TProtocol prot, ItemRow struct) throws org.apache.thrift.TException {
TTupleProtocol oprot = (TTupleProtocol) prot;
BitSet optionals = new BitSet();
if (struct.isSetI_im_id()) {
optionals.set(0);
}
if (struct.isSetI_name()) {
optionals.set(1);
}
if (struct.isSetI_price()) {
optionals.set(2);
}
if (struct.isSetI_data()) {
optionals.set(3);
}
oprot.writeBitSet(optionals, 4);
if (struct.isSetI_im_id()) {
oprot.writeI32(struct.i_im_id);
}
if (struct.isSetI_name()) {
oprot.writeString(struct.i_name);
}
if (struct.isSetI_price()) {
oprot.writeDouble(struct.i_price);
}
if (struct.isSetI_data()) {
oprot.writeString(struct.i_data);
}
}
@Override
public void read(org.apache.thrift.protocol.TProtocol prot, ItemRow struct) throws org.apache.thrift.TException {
TTupleProtocol iprot = (TTupleProtocol) prot;
BitSet incoming = iprot.readBitSet(4);
if (incoming.get(0)) {
struct.i_im_id = iprot.readI32();
struct.setI_im_idIsSet(true);
}
if (incoming.get(1)) {
struct.i_name = iprot.readString();
struct.setI_nameIsSet(true);
}
if (incoming.get(2)) {
struct.i_price = iprot.readDouble();
struct.setI_priceIsSet(true);
}
if (incoming.get(3)) {
struct.i_data = iprot.readString();
struct.setI_dataIsSet(true);
}
}
}
}