0001
0002
0003
0004
0005
0006
0007 package org.apache.hive.service.cli.thrift;
0008
0009 import org.apache.commons.lang.builder.HashCodeBuilder;
0010 import org.apache.thrift.scheme.IScheme;
0011 import org.apache.thrift.scheme.SchemeFactory;
0012 import org.apache.thrift.scheme.StandardScheme;
0013
0014 import org.apache.thrift.scheme.TupleScheme;
0015 import org.apache.thrift.protocol.TTupleProtocol;
0016 import org.apache.thrift.protocol.TProtocolException;
0017 import org.apache.thrift.EncodingUtils;
0018 import org.apache.thrift.TException;
0019 import java.util.List;
0020 import java.util.ArrayList;
0021 import java.util.Map;
0022 import java.util.HashMap;
0023 import java.util.EnumMap;
0024 import java.util.Set;
0025 import java.util.HashSet;
0026 import java.util.EnumSet;
0027 import java.util.Collections;
0028 import java.util.BitSet;
0029 import java.nio.ByteBuffer;
0030 import java.util.Arrays;
0031 import org.slf4j.Logger;
0032 import org.slf4j.LoggerFactory;
0033
0034 public class TI64Value implements org.apache.thrift.TBase<TI64Value, TI64Value._Fields>, java.io.Serializable, Cloneable {
0035 private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TI64Value");
0036
0037 private static final org.apache.thrift.protocol.TField VALUE_FIELD_DESC = new org.apache.thrift.protocol.TField("value", org.apache.thrift.protocol.TType.I64, (short)1);
0038
0039 private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
0040 static {
0041 schemes.put(StandardScheme.class, new TI64ValueStandardSchemeFactory());
0042 schemes.put(TupleScheme.class, new TI64ValueTupleSchemeFactory());
0043 }
0044
0045 private long value;
0046
0047
0048 public enum _Fields implements org.apache.thrift.TFieldIdEnum {
0049 VALUE((short)1, "value");
0050
0051 private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
0052
0053 static {
0054 for (_Fields field : EnumSet.allOf(_Fields.class)) {
0055 byName.put(field.getFieldName(), field);
0056 }
0057 }
0058
0059
0060
0061
0062 public static _Fields findByThriftId(int fieldId) {
0063 switch(fieldId) {
0064 case 1:
0065 return VALUE;
0066 default:
0067 return null;
0068 }
0069 }
0070
0071
0072
0073
0074
0075 public static _Fields findByThriftIdOrThrow(int fieldId) {
0076 _Fields fields = findByThriftId(fieldId);
0077 if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
0078 return fields;
0079 }
0080
0081
0082
0083
0084 public static _Fields findByName(String name) {
0085 return byName.get(name);
0086 }
0087
0088 private final short _thriftId;
0089 private final String _fieldName;
0090
0091 _Fields(short thriftId, String fieldName) {
0092 _thriftId = thriftId;
0093 _fieldName = fieldName;
0094 }
0095
0096 public short getThriftFieldId() {
0097 return _thriftId;
0098 }
0099
0100 public String getFieldName() {
0101 return _fieldName;
0102 }
0103 }
0104
0105
0106 private static final int __VALUE_ISSET_ID = 0;
0107 private byte __isset_bitfield = 0;
0108 private _Fields optionals[] = {_Fields.VALUE};
0109 public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
0110 static {
0111 Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
0112 tmpMap.put(_Fields.VALUE, new org.apache.thrift.meta_data.FieldMetaData("value", org.apache.thrift.TFieldRequirementType.OPTIONAL,
0113 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
0114 metaDataMap = Collections.unmodifiableMap(tmpMap);
0115 org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TI64Value.class, metaDataMap);
0116 }
0117
0118 public TI64Value() {
0119 }
0120
0121
0122
0123
0124 public TI64Value(TI64Value other) {
0125 __isset_bitfield = other.__isset_bitfield;
0126 this.value = other.value;
0127 }
0128
0129 public TI64Value deepCopy() {
0130 return new TI64Value(this);
0131 }
0132
0133 @Override
0134 public void clear() {
0135 setValueIsSet(false);
0136 this.value = 0;
0137 }
0138
0139 public long getValue() {
0140 return this.value;
0141 }
0142
0143 public void setValue(long value) {
0144 this.value = value;
0145 setValueIsSet(true);
0146 }
0147
0148 public void unsetValue() {
0149 __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __VALUE_ISSET_ID);
0150 }
0151
0152
0153 public boolean isSetValue() {
0154 return EncodingUtils.testBit(__isset_bitfield, __VALUE_ISSET_ID);
0155 }
0156
0157 public void setValueIsSet(boolean value) {
0158 __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __VALUE_ISSET_ID, value);
0159 }
0160
0161 public void setFieldValue(_Fields field, Object value) {
0162 switch (field) {
0163 case VALUE:
0164 if (value == null) {
0165 unsetValue();
0166 } else {
0167 setValue((Long)value);
0168 }
0169 break;
0170
0171 }
0172 }
0173
0174 public Object getFieldValue(_Fields field) {
0175 switch (field) {
0176 case VALUE:
0177 return Long.valueOf(getValue());
0178
0179 }
0180 throw new IllegalStateException();
0181 }
0182
0183
0184 public boolean isSet(_Fields field) {
0185 if (field == null) {
0186 throw new IllegalArgumentException();
0187 }
0188
0189 switch (field) {
0190 case VALUE:
0191 return isSetValue();
0192 }
0193 throw new IllegalStateException();
0194 }
0195
0196 @Override
0197 public boolean equals(Object that) {
0198 if (that == null)
0199 return false;
0200 if (that instanceof TI64Value)
0201 return this.equals((TI64Value)that);
0202 return false;
0203 }
0204
0205 public boolean equals(TI64Value that) {
0206 if (that == null)
0207 return false;
0208
0209 boolean this_present_value = true && this.isSetValue();
0210 boolean that_present_value = true && that.isSetValue();
0211 if (this_present_value || that_present_value) {
0212 if (!(this_present_value && that_present_value))
0213 return false;
0214 if (this.value != that.value)
0215 return false;
0216 }
0217
0218 return true;
0219 }
0220
0221 @Override
0222 public int hashCode() {
0223 HashCodeBuilder builder = new HashCodeBuilder();
0224
0225 boolean present_value = true && (isSetValue());
0226 builder.append(present_value);
0227 if (present_value)
0228 builder.append(value);
0229
0230 return builder.toHashCode();
0231 }
0232
0233 public int compareTo(TI64Value other) {
0234 if (!getClass().equals(other.getClass())) {
0235 return getClass().getName().compareTo(other.getClass().getName());
0236 }
0237
0238 int lastComparison = 0;
0239 TI64Value typedOther = (TI64Value)other;
0240
0241 lastComparison = Boolean.valueOf(isSetValue()).compareTo(typedOther.isSetValue());
0242 if (lastComparison != 0) {
0243 return lastComparison;
0244 }
0245 if (isSetValue()) {
0246 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.value, typedOther.value);
0247 if (lastComparison != 0) {
0248 return lastComparison;
0249 }
0250 }
0251 return 0;
0252 }
0253
0254 public _Fields fieldForId(int fieldId) {
0255 return _Fields.findByThriftId(fieldId);
0256 }
0257
0258 public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
0259 schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
0260 }
0261
0262 public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
0263 schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
0264 }
0265
0266 @Override
0267 public String toString() {
0268 StringBuilder sb = new StringBuilder("TI64Value(");
0269 boolean first = true;
0270
0271 if (isSetValue()) {
0272 sb.append("value:");
0273 sb.append(this.value);
0274 first = false;
0275 }
0276 sb.append(")");
0277 return sb.toString();
0278 }
0279
0280 public void validate() throws org.apache.thrift.TException {
0281
0282
0283 }
0284
0285 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
0286 try {
0287 write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
0288 } catch (org.apache.thrift.TException te) {
0289 throw new java.io.IOException(te);
0290 }
0291 }
0292
0293 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
0294 try {
0295
0296 __isset_bitfield = 0;
0297 read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
0298 } catch (org.apache.thrift.TException te) {
0299 throw new java.io.IOException(te);
0300 }
0301 }
0302
0303 private static class TI64ValueStandardSchemeFactory implements SchemeFactory {
0304 public TI64ValueStandardScheme getScheme() {
0305 return new TI64ValueStandardScheme();
0306 }
0307 }
0308
0309 private static class TI64ValueStandardScheme extends StandardScheme<TI64Value> {
0310
0311 public void read(org.apache.thrift.protocol.TProtocol iprot, TI64Value struct) throws org.apache.thrift.TException {
0312 org.apache.thrift.protocol.TField schemeField;
0313 iprot.readStructBegin();
0314 while (true)
0315 {
0316 schemeField = iprot.readFieldBegin();
0317 if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
0318 break;
0319 }
0320 switch (schemeField.id) {
0321 case 1:
0322 if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
0323 struct.value = iprot.readI64();
0324 struct.setValueIsSet(true);
0325 } else {
0326 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0327 }
0328 break;
0329 default:
0330 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0331 }
0332 iprot.readFieldEnd();
0333 }
0334 iprot.readStructEnd();
0335 struct.validate();
0336 }
0337
0338 public void write(org.apache.thrift.protocol.TProtocol oprot, TI64Value struct) throws org.apache.thrift.TException {
0339 struct.validate();
0340
0341 oprot.writeStructBegin(STRUCT_DESC);
0342 if (struct.isSetValue()) {
0343 oprot.writeFieldBegin(VALUE_FIELD_DESC);
0344 oprot.writeI64(struct.value);
0345 oprot.writeFieldEnd();
0346 }
0347 oprot.writeFieldStop();
0348 oprot.writeStructEnd();
0349 }
0350
0351 }
0352
0353 private static class TI64ValueTupleSchemeFactory implements SchemeFactory {
0354 public TI64ValueTupleScheme getScheme() {
0355 return new TI64ValueTupleScheme();
0356 }
0357 }
0358
0359 private static class TI64ValueTupleScheme extends TupleScheme<TI64Value> {
0360
0361 @Override
0362 public void write(org.apache.thrift.protocol.TProtocol prot, TI64Value struct) throws org.apache.thrift.TException {
0363 TTupleProtocol oprot = (TTupleProtocol) prot;
0364 BitSet optionals = new BitSet();
0365 if (struct.isSetValue()) {
0366 optionals.set(0);
0367 }
0368 oprot.writeBitSet(optionals, 1);
0369 if (struct.isSetValue()) {
0370 oprot.writeI64(struct.value);
0371 }
0372 }
0373
0374 @Override
0375 public void read(org.apache.thrift.protocol.TProtocol prot, TI64Value struct) throws org.apache.thrift.TException {
0376 TTupleProtocol iprot = (TTupleProtocol) prot;
0377 BitSet incoming = iprot.readBitSet(1);
0378 if (incoming.get(0)) {
0379 struct.value = iprot.readI64();
0380 struct.setValueIsSet(true);
0381 }
0382 }
0383 }
0384
0385 }
0386