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 TColumnDesc implements org.apache.thrift.TBase<TColumnDesc, TColumnDesc._Fields>, java.io.Serializable, Cloneable {
0035 private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TColumnDesc");
0036
0037 private static final org.apache.thrift.protocol.TField COLUMN_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("columnName", org.apache.thrift.protocol.TType.STRING, (short)1);
0038 private static final org.apache.thrift.protocol.TField TYPE_DESC_FIELD_DESC = new org.apache.thrift.protocol.TField("typeDesc", org.apache.thrift.protocol.TType.STRUCT, (short)2);
0039 private static final org.apache.thrift.protocol.TField POSITION_FIELD_DESC = new org.apache.thrift.protocol.TField("position", org.apache.thrift.protocol.TType.I32, (short)3);
0040 private static final org.apache.thrift.protocol.TField COMMENT_FIELD_DESC = new org.apache.thrift.protocol.TField("comment", org.apache.thrift.protocol.TType.STRING, (short)4);
0041
0042 private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
0043 static {
0044 schemes.put(StandardScheme.class, new TColumnDescStandardSchemeFactory());
0045 schemes.put(TupleScheme.class, new TColumnDescTupleSchemeFactory());
0046 }
0047
0048 private String columnName;
0049 private TTypeDesc typeDesc;
0050 private int position;
0051 private String comment;
0052
0053
0054 public enum _Fields implements org.apache.thrift.TFieldIdEnum {
0055 COLUMN_NAME((short)1, "columnName"),
0056 TYPE_DESC((short)2, "typeDesc"),
0057 POSITION((short)3, "position"),
0058 COMMENT((short)4, "comment");
0059
0060 private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
0061
0062 static {
0063 for (_Fields field : EnumSet.allOf(_Fields.class)) {
0064 byName.put(field.getFieldName(), field);
0065 }
0066 }
0067
0068
0069
0070
0071 public static _Fields findByThriftId(int fieldId) {
0072 switch(fieldId) {
0073 case 1:
0074 return COLUMN_NAME;
0075 case 2:
0076 return TYPE_DESC;
0077 case 3:
0078 return POSITION;
0079 case 4:
0080 return COMMENT;
0081 default:
0082 return null;
0083 }
0084 }
0085
0086
0087
0088
0089
0090 public static _Fields findByThriftIdOrThrow(int fieldId) {
0091 _Fields fields = findByThriftId(fieldId);
0092 if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
0093 return fields;
0094 }
0095
0096
0097
0098
0099 public static _Fields findByName(String name) {
0100 return byName.get(name);
0101 }
0102
0103 private final short _thriftId;
0104 private final String _fieldName;
0105
0106 _Fields(short thriftId, String fieldName) {
0107 _thriftId = thriftId;
0108 _fieldName = fieldName;
0109 }
0110
0111 public short getThriftFieldId() {
0112 return _thriftId;
0113 }
0114
0115 public String getFieldName() {
0116 return _fieldName;
0117 }
0118 }
0119
0120
0121 private static final int __POSITION_ISSET_ID = 0;
0122 private byte __isset_bitfield = 0;
0123 private _Fields optionals[] = {_Fields.COMMENT};
0124 public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
0125 static {
0126 Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
0127 tmpMap.put(_Fields.COLUMN_NAME, new org.apache.thrift.meta_data.FieldMetaData("columnName", org.apache.thrift.TFieldRequirementType.REQUIRED,
0128 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
0129 tmpMap.put(_Fields.TYPE_DESC, new org.apache.thrift.meta_data.FieldMetaData("typeDesc", org.apache.thrift.TFieldRequirementType.REQUIRED,
0130 new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TTypeDesc.class)));
0131 tmpMap.put(_Fields.POSITION, new org.apache.thrift.meta_data.FieldMetaData("position", org.apache.thrift.TFieldRequirementType.REQUIRED,
0132 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)));
0133 tmpMap.put(_Fields.COMMENT, new org.apache.thrift.meta_data.FieldMetaData("comment", org.apache.thrift.TFieldRequirementType.OPTIONAL,
0134 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING)));
0135 metaDataMap = Collections.unmodifiableMap(tmpMap);
0136 org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TColumnDesc.class, metaDataMap);
0137 }
0138
0139 public TColumnDesc() {
0140 }
0141
0142 public TColumnDesc(
0143 String columnName,
0144 TTypeDesc typeDesc,
0145 int position)
0146 {
0147 this();
0148 this.columnName = columnName;
0149 this.typeDesc = typeDesc;
0150 this.position = position;
0151 setPositionIsSet(true);
0152 }
0153
0154
0155
0156
0157 public TColumnDesc(TColumnDesc other) {
0158 __isset_bitfield = other.__isset_bitfield;
0159 if (other.isSetColumnName()) {
0160 this.columnName = other.columnName;
0161 }
0162 if (other.isSetTypeDesc()) {
0163 this.typeDesc = new TTypeDesc(other.typeDesc);
0164 }
0165 this.position = other.position;
0166 if (other.isSetComment()) {
0167 this.comment = other.comment;
0168 }
0169 }
0170
0171 public TColumnDesc deepCopy() {
0172 return new TColumnDesc(this);
0173 }
0174
0175 @Override
0176 public void clear() {
0177 this.columnName = null;
0178 this.typeDesc = null;
0179 setPositionIsSet(false);
0180 this.position = 0;
0181 this.comment = null;
0182 }
0183
0184 public String getColumnName() {
0185 return this.columnName;
0186 }
0187
0188 public void setColumnName(String columnName) {
0189 this.columnName = columnName;
0190 }
0191
0192 public void unsetColumnName() {
0193 this.columnName = null;
0194 }
0195
0196
0197 public boolean isSetColumnName() {
0198 return this.columnName != null;
0199 }
0200
0201 public void setColumnNameIsSet(boolean value) {
0202 if (!value) {
0203 this.columnName = null;
0204 }
0205 }
0206
0207 public TTypeDesc getTypeDesc() {
0208 return this.typeDesc;
0209 }
0210
0211 public void setTypeDesc(TTypeDesc typeDesc) {
0212 this.typeDesc = typeDesc;
0213 }
0214
0215 public void unsetTypeDesc() {
0216 this.typeDesc = null;
0217 }
0218
0219
0220 public boolean isSetTypeDesc() {
0221 return this.typeDesc != null;
0222 }
0223
0224 public void setTypeDescIsSet(boolean value) {
0225 if (!value) {
0226 this.typeDesc = null;
0227 }
0228 }
0229
0230 public int getPosition() {
0231 return this.position;
0232 }
0233
0234 public void setPosition(int position) {
0235 this.position = position;
0236 setPositionIsSet(true);
0237 }
0238
0239 public void unsetPosition() {
0240 __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __POSITION_ISSET_ID);
0241 }
0242
0243
0244 public boolean isSetPosition() {
0245 return EncodingUtils.testBit(__isset_bitfield, __POSITION_ISSET_ID);
0246 }
0247
0248 public void setPositionIsSet(boolean value) {
0249 __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __POSITION_ISSET_ID, value);
0250 }
0251
0252 public String getComment() {
0253 return this.comment;
0254 }
0255
0256 public void setComment(String comment) {
0257 this.comment = comment;
0258 }
0259
0260 public void unsetComment() {
0261 this.comment = null;
0262 }
0263
0264
0265 public boolean isSetComment() {
0266 return this.comment != null;
0267 }
0268
0269 public void setCommentIsSet(boolean value) {
0270 if (!value) {
0271 this.comment = null;
0272 }
0273 }
0274
0275 public void setFieldValue(_Fields field, Object value) {
0276 switch (field) {
0277 case COLUMN_NAME:
0278 if (value == null) {
0279 unsetColumnName();
0280 } else {
0281 setColumnName((String)value);
0282 }
0283 break;
0284
0285 case TYPE_DESC:
0286 if (value == null) {
0287 unsetTypeDesc();
0288 } else {
0289 setTypeDesc((TTypeDesc)value);
0290 }
0291 break;
0292
0293 case POSITION:
0294 if (value == null) {
0295 unsetPosition();
0296 } else {
0297 setPosition((Integer)value);
0298 }
0299 break;
0300
0301 case COMMENT:
0302 if (value == null) {
0303 unsetComment();
0304 } else {
0305 setComment((String)value);
0306 }
0307 break;
0308
0309 }
0310 }
0311
0312 public Object getFieldValue(_Fields field) {
0313 switch (field) {
0314 case COLUMN_NAME:
0315 return getColumnName();
0316
0317 case TYPE_DESC:
0318 return getTypeDesc();
0319
0320 case POSITION:
0321 return Integer.valueOf(getPosition());
0322
0323 case COMMENT:
0324 return getComment();
0325
0326 }
0327 throw new IllegalStateException();
0328 }
0329
0330
0331 public boolean isSet(_Fields field) {
0332 if (field == null) {
0333 throw new IllegalArgumentException();
0334 }
0335
0336 switch (field) {
0337 case COLUMN_NAME:
0338 return isSetColumnName();
0339 case TYPE_DESC:
0340 return isSetTypeDesc();
0341 case POSITION:
0342 return isSetPosition();
0343 case COMMENT:
0344 return isSetComment();
0345 }
0346 throw new IllegalStateException();
0347 }
0348
0349 @Override
0350 public boolean equals(Object that) {
0351 if (that == null)
0352 return false;
0353 if (that instanceof TColumnDesc)
0354 return this.equals((TColumnDesc)that);
0355 return false;
0356 }
0357
0358 public boolean equals(TColumnDesc that) {
0359 if (that == null)
0360 return false;
0361
0362 boolean this_present_columnName = true && this.isSetColumnName();
0363 boolean that_present_columnName = true && that.isSetColumnName();
0364 if (this_present_columnName || that_present_columnName) {
0365 if (!(this_present_columnName && that_present_columnName))
0366 return false;
0367 if (!this.columnName.equals(that.columnName))
0368 return false;
0369 }
0370
0371 boolean this_present_typeDesc = true && this.isSetTypeDesc();
0372 boolean that_present_typeDesc = true && that.isSetTypeDesc();
0373 if (this_present_typeDesc || that_present_typeDesc) {
0374 if (!(this_present_typeDesc && that_present_typeDesc))
0375 return false;
0376 if (!this.typeDesc.equals(that.typeDesc))
0377 return false;
0378 }
0379
0380 boolean this_present_position = true;
0381 boolean that_present_position = true;
0382 if (this_present_position || that_present_position) {
0383 if (!(this_present_position && that_present_position))
0384 return false;
0385 if (this.position != that.position)
0386 return false;
0387 }
0388
0389 boolean this_present_comment = true && this.isSetComment();
0390 boolean that_present_comment = true && that.isSetComment();
0391 if (this_present_comment || that_present_comment) {
0392 if (!(this_present_comment && that_present_comment))
0393 return false;
0394 if (!this.comment.equals(that.comment))
0395 return false;
0396 }
0397
0398 return true;
0399 }
0400
0401 @Override
0402 public int hashCode() {
0403 HashCodeBuilder builder = new HashCodeBuilder();
0404
0405 boolean present_columnName = true && (isSetColumnName());
0406 builder.append(present_columnName);
0407 if (present_columnName)
0408 builder.append(columnName);
0409
0410 boolean present_typeDesc = true && (isSetTypeDesc());
0411 builder.append(present_typeDesc);
0412 if (present_typeDesc)
0413 builder.append(typeDesc);
0414
0415 boolean present_position = true;
0416 builder.append(present_position);
0417 if (present_position)
0418 builder.append(position);
0419
0420 boolean present_comment = true && (isSetComment());
0421 builder.append(present_comment);
0422 if (present_comment)
0423 builder.append(comment);
0424
0425 return builder.toHashCode();
0426 }
0427
0428 public int compareTo(TColumnDesc other) {
0429 if (!getClass().equals(other.getClass())) {
0430 return getClass().getName().compareTo(other.getClass().getName());
0431 }
0432
0433 int lastComparison = 0;
0434 TColumnDesc typedOther = (TColumnDesc)other;
0435
0436 lastComparison = Boolean.valueOf(isSetColumnName()).compareTo(typedOther.isSetColumnName());
0437 if (lastComparison != 0) {
0438 return lastComparison;
0439 }
0440 if (isSetColumnName()) {
0441 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.columnName, typedOther.columnName);
0442 if (lastComparison != 0) {
0443 return lastComparison;
0444 }
0445 }
0446 lastComparison = Boolean.valueOf(isSetTypeDesc()).compareTo(typedOther.isSetTypeDesc());
0447 if (lastComparison != 0) {
0448 return lastComparison;
0449 }
0450 if (isSetTypeDesc()) {
0451 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.typeDesc, typedOther.typeDesc);
0452 if (lastComparison != 0) {
0453 return lastComparison;
0454 }
0455 }
0456 lastComparison = Boolean.valueOf(isSetPosition()).compareTo(typedOther.isSetPosition());
0457 if (lastComparison != 0) {
0458 return lastComparison;
0459 }
0460 if (isSetPosition()) {
0461 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.position, typedOther.position);
0462 if (lastComparison != 0) {
0463 return lastComparison;
0464 }
0465 }
0466 lastComparison = Boolean.valueOf(isSetComment()).compareTo(typedOther.isSetComment());
0467 if (lastComparison != 0) {
0468 return lastComparison;
0469 }
0470 if (isSetComment()) {
0471 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.comment, typedOther.comment);
0472 if (lastComparison != 0) {
0473 return lastComparison;
0474 }
0475 }
0476 return 0;
0477 }
0478
0479 public _Fields fieldForId(int fieldId) {
0480 return _Fields.findByThriftId(fieldId);
0481 }
0482
0483 public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
0484 schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
0485 }
0486
0487 public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
0488 schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
0489 }
0490
0491 @Override
0492 public String toString() {
0493 StringBuilder sb = new StringBuilder("TColumnDesc(");
0494 boolean first = true;
0495
0496 sb.append("columnName:");
0497 if (this.columnName == null) {
0498 sb.append("null");
0499 } else {
0500 sb.append(this.columnName);
0501 }
0502 first = false;
0503 if (!first) sb.append(", ");
0504 sb.append("typeDesc:");
0505 if (this.typeDesc == null) {
0506 sb.append("null");
0507 } else {
0508 sb.append(this.typeDesc);
0509 }
0510 first = false;
0511 if (!first) sb.append(", ");
0512 sb.append("position:");
0513 sb.append(this.position);
0514 first = false;
0515 if (isSetComment()) {
0516 if (!first) sb.append(", ");
0517 sb.append("comment:");
0518 if (this.comment == null) {
0519 sb.append("null");
0520 } else {
0521 sb.append(this.comment);
0522 }
0523 first = false;
0524 }
0525 sb.append(")");
0526 return sb.toString();
0527 }
0528
0529 public void validate() throws org.apache.thrift.TException {
0530
0531 if (!isSetColumnName()) {
0532 throw new org.apache.thrift.protocol.TProtocolException("Required field 'columnName' is unset! Struct:" + toString());
0533 }
0534
0535 if (!isSetTypeDesc()) {
0536 throw new org.apache.thrift.protocol.TProtocolException("Required field 'typeDesc' is unset! Struct:" + toString());
0537 }
0538
0539 if (!isSetPosition()) {
0540 throw new org.apache.thrift.protocol.TProtocolException("Required field 'position' is unset! Struct:" + toString());
0541 }
0542
0543
0544 if (typeDesc != null) {
0545 typeDesc.validate();
0546 }
0547 }
0548
0549 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
0550 try {
0551 write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
0552 } catch (org.apache.thrift.TException te) {
0553 throw new java.io.IOException(te);
0554 }
0555 }
0556
0557 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
0558 try {
0559
0560 __isset_bitfield = 0;
0561 read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
0562 } catch (org.apache.thrift.TException te) {
0563 throw new java.io.IOException(te);
0564 }
0565 }
0566
0567 private static class TColumnDescStandardSchemeFactory implements SchemeFactory {
0568 public TColumnDescStandardScheme getScheme() {
0569 return new TColumnDescStandardScheme();
0570 }
0571 }
0572
0573 private static class TColumnDescStandardScheme extends StandardScheme<TColumnDesc> {
0574
0575 public void read(org.apache.thrift.protocol.TProtocol iprot, TColumnDesc struct) throws org.apache.thrift.TException {
0576 org.apache.thrift.protocol.TField schemeField;
0577 iprot.readStructBegin();
0578 while (true)
0579 {
0580 schemeField = iprot.readFieldBegin();
0581 if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
0582 break;
0583 }
0584 switch (schemeField.id) {
0585 case 1:
0586 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
0587 struct.columnName = iprot.readString();
0588 struct.setColumnNameIsSet(true);
0589 } else {
0590 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0591 }
0592 break;
0593 case 2:
0594 if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
0595 struct.typeDesc = new TTypeDesc();
0596 struct.typeDesc.read(iprot);
0597 struct.setTypeDescIsSet(true);
0598 } else {
0599 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0600 }
0601 break;
0602 case 3:
0603 if (schemeField.type == org.apache.thrift.protocol.TType.I32) {
0604 struct.position = iprot.readI32();
0605 struct.setPositionIsSet(true);
0606 } else {
0607 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0608 }
0609 break;
0610 case 4:
0611 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
0612 struct.comment = iprot.readString();
0613 struct.setCommentIsSet(true);
0614 } else {
0615 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0616 }
0617 break;
0618 default:
0619 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0620 }
0621 iprot.readFieldEnd();
0622 }
0623 iprot.readStructEnd();
0624 struct.validate();
0625 }
0626
0627 public void write(org.apache.thrift.protocol.TProtocol oprot, TColumnDesc struct) throws org.apache.thrift.TException {
0628 struct.validate();
0629
0630 oprot.writeStructBegin(STRUCT_DESC);
0631 if (struct.columnName != null) {
0632 oprot.writeFieldBegin(COLUMN_NAME_FIELD_DESC);
0633 oprot.writeString(struct.columnName);
0634 oprot.writeFieldEnd();
0635 }
0636 if (struct.typeDesc != null) {
0637 oprot.writeFieldBegin(TYPE_DESC_FIELD_DESC);
0638 struct.typeDesc.write(oprot);
0639 oprot.writeFieldEnd();
0640 }
0641 oprot.writeFieldBegin(POSITION_FIELD_DESC);
0642 oprot.writeI32(struct.position);
0643 oprot.writeFieldEnd();
0644 if (struct.comment != null) {
0645 if (struct.isSetComment()) {
0646 oprot.writeFieldBegin(COMMENT_FIELD_DESC);
0647 oprot.writeString(struct.comment);
0648 oprot.writeFieldEnd();
0649 }
0650 }
0651 oprot.writeFieldStop();
0652 oprot.writeStructEnd();
0653 }
0654
0655 }
0656
0657 private static class TColumnDescTupleSchemeFactory implements SchemeFactory {
0658 public TColumnDescTupleScheme getScheme() {
0659 return new TColumnDescTupleScheme();
0660 }
0661 }
0662
0663 private static class TColumnDescTupleScheme extends TupleScheme<TColumnDesc> {
0664
0665 @Override
0666 public void write(org.apache.thrift.protocol.TProtocol prot, TColumnDesc struct) throws org.apache.thrift.TException {
0667 TTupleProtocol oprot = (TTupleProtocol) prot;
0668 oprot.writeString(struct.columnName);
0669 struct.typeDesc.write(oprot);
0670 oprot.writeI32(struct.position);
0671 BitSet optionals = new BitSet();
0672 if (struct.isSetComment()) {
0673 optionals.set(0);
0674 }
0675 oprot.writeBitSet(optionals, 1);
0676 if (struct.isSetComment()) {
0677 oprot.writeString(struct.comment);
0678 }
0679 }
0680
0681 @Override
0682 public void read(org.apache.thrift.protocol.TProtocol prot, TColumnDesc struct) throws org.apache.thrift.TException {
0683 TTupleProtocol iprot = (TTupleProtocol) prot;
0684 struct.columnName = iprot.readString();
0685 struct.setColumnNameIsSet(true);
0686 struct.typeDesc = new TTypeDesc();
0687 struct.typeDesc.read(iprot);
0688 struct.setTypeDescIsSet(true);
0689 struct.position = iprot.readI32();
0690 struct.setPositionIsSet(true);
0691 BitSet incoming = iprot.readBitSet(1);
0692 if (incoming.get(0)) {
0693 struct.comment = iprot.readString();
0694 struct.setCommentIsSet(true);
0695 }
0696 }
0697 }
0698
0699 }
0700