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