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 TMapTypeEntry implements org.apache.thrift.TBase<TMapTypeEntry, TMapTypeEntry._Fields>, java.io.Serializable, Cloneable {
0035 private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TMapTypeEntry");
0036
0037 private static final org.apache.thrift.protocol.TField KEY_TYPE_PTR_FIELD_DESC = new org.apache.thrift.protocol.TField("keyTypePtr", org.apache.thrift.protocol.TType.I32, (short)1);
0038 private static final org.apache.thrift.protocol.TField VALUE_TYPE_PTR_FIELD_DESC = new org.apache.thrift.protocol.TField("valueTypePtr", org.apache.thrift.protocol.TType.I32, (short)2);
0039
0040 private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
0041 static {
0042 schemes.put(StandardScheme.class, new TMapTypeEntryStandardSchemeFactory());
0043 schemes.put(TupleScheme.class, new TMapTypeEntryTupleSchemeFactory());
0044 }
0045
0046 private int keyTypePtr;
0047 private int valueTypePtr;
0048
0049
0050 public enum _Fields implements org.apache.thrift.TFieldIdEnum {
0051 KEY_TYPE_PTR((short)1, "keyTypePtr"),
0052 VALUE_TYPE_PTR((short)2, "valueTypePtr");
0053
0054 private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
0055
0056 static {
0057 for (_Fields field : EnumSet.allOf(_Fields.class)) {
0058 byName.put(field.getFieldName(), field);
0059 }
0060 }
0061
0062
0063
0064
0065 public static _Fields findByThriftId(int fieldId) {
0066 switch(fieldId) {
0067 case 1:
0068 return KEY_TYPE_PTR;
0069 case 2:
0070 return VALUE_TYPE_PTR;
0071 default:
0072 return null;
0073 }
0074 }
0075
0076
0077
0078
0079
0080 public static _Fields findByThriftIdOrThrow(int fieldId) {
0081 _Fields fields = findByThriftId(fieldId);
0082 if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
0083 return fields;
0084 }
0085
0086
0087
0088
0089 public static _Fields findByName(String name) {
0090 return byName.get(name);
0091 }
0092
0093 private final short _thriftId;
0094 private final String _fieldName;
0095
0096 _Fields(short thriftId, String fieldName) {
0097 _thriftId = thriftId;
0098 _fieldName = fieldName;
0099 }
0100
0101 public short getThriftFieldId() {
0102 return _thriftId;
0103 }
0104
0105 public String getFieldName() {
0106 return _fieldName;
0107 }
0108 }
0109
0110
0111 private static final int __KEYTYPEPTR_ISSET_ID = 0;
0112 private static final int __VALUETYPEPTR_ISSET_ID = 1;
0113 private byte __isset_bitfield = 0;
0114 public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
0115 static {
0116 Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
0117 tmpMap.put(_Fields.KEY_TYPE_PTR, new org.apache.thrift.meta_data.FieldMetaData("keyTypePtr", org.apache.thrift.TFieldRequirementType.REQUIRED,
0118 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32 , "TTypeEntryPtr")));
0119 tmpMap.put(_Fields.VALUE_TYPE_PTR, new org.apache.thrift.meta_data.FieldMetaData("valueTypePtr", org.apache.thrift.TFieldRequirementType.REQUIRED,
0120 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32 , "TTypeEntryPtr")));
0121 metaDataMap = Collections.unmodifiableMap(tmpMap);
0122 org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TMapTypeEntry.class, metaDataMap);
0123 }
0124
0125 public TMapTypeEntry() {
0126 }
0127
0128 public TMapTypeEntry(
0129 int keyTypePtr,
0130 int valueTypePtr)
0131 {
0132 this();
0133 this.keyTypePtr = keyTypePtr;
0134 setKeyTypePtrIsSet(true);
0135 this.valueTypePtr = valueTypePtr;
0136 setValueTypePtrIsSet(true);
0137 }
0138
0139
0140
0141
0142 public TMapTypeEntry(TMapTypeEntry other) {
0143 __isset_bitfield = other.__isset_bitfield;
0144 this.keyTypePtr = other.keyTypePtr;
0145 this.valueTypePtr = other.valueTypePtr;
0146 }
0147
0148 public TMapTypeEntry deepCopy() {
0149 return new TMapTypeEntry(this);
0150 }
0151
0152 @Override
0153 public void clear() {
0154 setKeyTypePtrIsSet(false);
0155 this.keyTypePtr = 0;
0156 setValueTypePtrIsSet(false);
0157 this.valueTypePtr = 0;
0158 }
0159
0160 public int getKeyTypePtr() {
0161 return this.keyTypePtr;
0162 }
0163
0164 public void setKeyTypePtr(int keyTypePtr) {
0165 this.keyTypePtr = keyTypePtr;
0166 setKeyTypePtrIsSet(true);
0167 }
0168
0169 public void unsetKeyTypePtr() {
0170 __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __KEYTYPEPTR_ISSET_ID);
0171 }
0172
0173
0174 public boolean isSetKeyTypePtr() {
0175 return EncodingUtils.testBit(__isset_bitfield, __KEYTYPEPTR_ISSET_ID);
0176 }
0177
0178 public void setKeyTypePtrIsSet(boolean value) {
0179 __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __KEYTYPEPTR_ISSET_ID, value);
0180 }
0181
0182 public int getValueTypePtr() {
0183 return this.valueTypePtr;
0184 }
0185
0186 public void setValueTypePtr(int valueTypePtr) {
0187 this.valueTypePtr = valueTypePtr;
0188 setValueTypePtrIsSet(true);
0189 }
0190
0191 public void unsetValueTypePtr() {
0192 __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __VALUETYPEPTR_ISSET_ID);
0193 }
0194
0195
0196 public boolean isSetValueTypePtr() {
0197 return EncodingUtils.testBit(__isset_bitfield, __VALUETYPEPTR_ISSET_ID);
0198 }
0199
0200 public void setValueTypePtrIsSet(boolean value) {
0201 __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __VALUETYPEPTR_ISSET_ID, value);
0202 }
0203
0204 public void setFieldValue(_Fields field, Object value) {
0205 switch (field) {
0206 case KEY_TYPE_PTR:
0207 if (value == null) {
0208 unsetKeyTypePtr();
0209 } else {
0210 setKeyTypePtr((Integer)value);
0211 }
0212 break;
0213
0214 case VALUE_TYPE_PTR:
0215 if (value == null) {
0216 unsetValueTypePtr();
0217 } else {
0218 setValueTypePtr((Integer)value);
0219 }
0220 break;
0221
0222 }
0223 }
0224
0225 public Object getFieldValue(_Fields field) {
0226 switch (field) {
0227 case KEY_TYPE_PTR:
0228 return Integer.valueOf(getKeyTypePtr());
0229
0230 case VALUE_TYPE_PTR:
0231 return Integer.valueOf(getValueTypePtr());
0232
0233 }
0234 throw new IllegalStateException();
0235 }
0236
0237
0238 public boolean isSet(_Fields field) {
0239 if (field == null) {
0240 throw new IllegalArgumentException();
0241 }
0242
0243 switch (field) {
0244 case KEY_TYPE_PTR:
0245 return isSetKeyTypePtr();
0246 case VALUE_TYPE_PTR:
0247 return isSetValueTypePtr();
0248 }
0249 throw new IllegalStateException();
0250 }
0251
0252 @Override
0253 public boolean equals(Object that) {
0254 if (that == null)
0255 return false;
0256 if (that instanceof TMapTypeEntry)
0257 return this.equals((TMapTypeEntry)that);
0258 return false;
0259 }
0260
0261 public boolean equals(TMapTypeEntry that) {
0262 if (that == null)
0263 return false;
0264
0265 boolean this_present_keyTypePtr = true;
0266 boolean that_present_keyTypePtr = true;
0267 if (this_present_keyTypePtr || that_present_keyTypePtr) {
0268 if (!(this_present_keyTypePtr && that_present_keyTypePtr))
0269 return false;
0270 if (this.keyTypePtr != that.keyTypePtr)
0271 return false;
0272 }
0273
0274 boolean this_present_valueTypePtr = true;
0275 boolean that_present_valueTypePtr = true;
0276 if (this_present_valueTypePtr || that_present_valueTypePtr) {
0277 if (!(this_present_valueTypePtr && that_present_valueTypePtr))
0278 return false;
0279 if (this.valueTypePtr != that.valueTypePtr)
0280 return false;
0281 }
0282
0283 return true;
0284 }
0285
0286 @Override
0287 public int hashCode() {
0288 HashCodeBuilder builder = new HashCodeBuilder();
0289
0290 boolean present_keyTypePtr = true;
0291 builder.append(present_keyTypePtr);
0292 if (present_keyTypePtr)
0293 builder.append(keyTypePtr);
0294
0295 boolean present_valueTypePtr = true;
0296 builder.append(present_valueTypePtr);
0297 if (present_valueTypePtr)
0298 builder.append(valueTypePtr);
0299
0300 return builder.toHashCode();
0301 }
0302
0303 public int compareTo(TMapTypeEntry other) {
0304 if (!getClass().equals(other.getClass())) {
0305 return getClass().getName().compareTo(other.getClass().getName());
0306 }
0307
0308 int lastComparison = 0;
0309 TMapTypeEntry typedOther = (TMapTypeEntry)other;
0310
0311 lastComparison = Boolean.valueOf(isSetKeyTypePtr()).compareTo(typedOther.isSetKeyTypePtr());
0312 if (lastComparison != 0) {
0313 return lastComparison;
0314 }
0315 if (isSetKeyTypePtr()) {
0316 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.keyTypePtr, typedOther.keyTypePtr);
0317 if (lastComparison != 0) {
0318 return lastComparison;
0319 }
0320 }
0321 lastComparison = Boolean.valueOf(isSetValueTypePtr()).compareTo(typedOther.isSetValueTypePtr());
0322 if (lastComparison != 0) {
0323 return lastComparison;
0324 }
0325 if (isSetValueTypePtr()) {
0326 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.valueTypePtr, typedOther.valueTypePtr);
0327 if (lastComparison != 0) {
0328 return lastComparison;
0329 }
0330 }
0331 return 0;
0332 }
0333
0334 public _Fields fieldForId(int fieldId) {
0335 return _Fields.findByThriftId(fieldId);
0336 }
0337
0338 public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
0339 schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
0340 }
0341
0342 public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
0343 schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
0344 }
0345
0346 @Override
0347 public String toString() {
0348 StringBuilder sb = new StringBuilder("TMapTypeEntry(");
0349 boolean first = true;
0350
0351 sb.append("keyTypePtr:");
0352 sb.append(this.keyTypePtr);
0353 first = false;
0354 if (!first) sb.append(", ");
0355 sb.append("valueTypePtr:");
0356 sb.append(this.valueTypePtr);
0357 first = false;
0358 sb.append(")");
0359 return sb.toString();
0360 }
0361
0362 public void validate() throws org.apache.thrift.TException {
0363
0364 if (!isSetKeyTypePtr()) {
0365 throw new org.apache.thrift.protocol.TProtocolException("Required field 'keyTypePtr' is unset! Struct:" + toString());
0366 }
0367
0368 if (!isSetValueTypePtr()) {
0369 throw new org.apache.thrift.protocol.TProtocolException("Required field 'valueTypePtr' is unset! Struct:" + toString());
0370 }
0371
0372
0373 }
0374
0375 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
0376 try {
0377 write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
0378 } catch (org.apache.thrift.TException te) {
0379 throw new java.io.IOException(te);
0380 }
0381 }
0382
0383 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
0384 try {
0385
0386 __isset_bitfield = 0;
0387 read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
0388 } catch (org.apache.thrift.TException te) {
0389 throw new java.io.IOException(te);
0390 }
0391 }
0392
0393 private static class TMapTypeEntryStandardSchemeFactory implements SchemeFactory {
0394 public TMapTypeEntryStandardScheme getScheme() {
0395 return new TMapTypeEntryStandardScheme();
0396 }
0397 }
0398
0399 private static class TMapTypeEntryStandardScheme extends StandardScheme<TMapTypeEntry> {
0400
0401 public void read(org.apache.thrift.protocol.TProtocol iprot, TMapTypeEntry struct) throws org.apache.thrift.TException {
0402 org.apache.thrift.protocol.TField schemeField;
0403 iprot.readStructBegin();
0404 while (true)
0405 {
0406 schemeField = iprot.readFieldBegin();
0407 if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
0408 break;
0409 }
0410 switch (schemeField.id) {
0411 case 1:
0412 if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
0413 struct.keyTypePtr = iprot.readI32();
0414 struct.setKeyTypePtrIsSet(true);
0415 } else {
0416 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0417 }
0418 break;
0419 case 2:
0420 if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
0421 struct.valueTypePtr = iprot.readI32();
0422 struct.setValueTypePtrIsSet(true);
0423 } else {
0424 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0425 }
0426 break;
0427 default:
0428 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0429 }
0430 iprot.readFieldEnd();
0431 }
0432 iprot.readStructEnd();
0433 struct.validate();
0434 }
0435
0436 public void write(org.apache.thrift.protocol.TProtocol oprot, TMapTypeEntry struct) throws org.apache.thrift.TException {
0437 struct.validate();
0438
0439 oprot.writeStructBegin(STRUCT_DESC);
0440 oprot.writeFieldBegin(KEY_TYPE_PTR_FIELD_DESC);
0441 oprot.writeI32(struct.keyTypePtr);
0442 oprot.writeFieldEnd();
0443 oprot.writeFieldBegin(VALUE_TYPE_PTR_FIELD_DESC);
0444 oprot.writeI32(struct.valueTypePtr);
0445 oprot.writeFieldEnd();
0446 oprot.writeFieldStop();
0447 oprot.writeStructEnd();
0448 }
0449
0450 }
0451
0452 private static class TMapTypeEntryTupleSchemeFactory implements SchemeFactory {
0453 public TMapTypeEntryTupleScheme getScheme() {
0454 return new TMapTypeEntryTupleScheme();
0455 }
0456 }
0457
0458 private static class TMapTypeEntryTupleScheme extends TupleScheme<TMapTypeEntry> {
0459
0460 @Override
0461 public void write(org.apache.thrift.protocol.TProtocol prot, TMapTypeEntry struct) throws org.apache.thrift.TException {
0462 TTupleProtocol oprot = (TTupleProtocol) prot;
0463 oprot.writeI32(struct.keyTypePtr);
0464 oprot.writeI32(struct.valueTypePtr);
0465 }
0466
0467 @Override
0468 public void read(org.apache.thrift.protocol.TProtocol prot, TMapTypeEntry struct) throws org.apache.thrift.TException {
0469 TTupleProtocol iprot = (TTupleProtocol) prot;
0470 struct.keyTypePtr = iprot.readI32();
0471 struct.setKeyTypePtrIsSet(true);
0472 struct.valueTypePtr = iprot.readI32();
0473 struct.setValueTypePtrIsSet(true);
0474 }
0475 }
0476
0477 }
0478