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 TI16Column implements org.apache.thrift.TBase<TI16Column, TI16Column._Fields>, java.io.Serializable, Cloneable {
0035 private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TI16Column");
0036
0037 private static final org.apache.thrift.protocol.TField VALUES_FIELD_DESC = new org.apache.thrift.protocol.TField("values", org.apache.thrift.protocol.TType.LIST, (short)1);
0038 private static final org.apache.thrift.protocol.TField NULLS_FIELD_DESC = new org.apache.thrift.protocol.TField("nulls", org.apache.thrift.protocol.TType.STRING, (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 TI16ColumnStandardSchemeFactory());
0043 schemes.put(TupleScheme.class, new TI16ColumnTupleSchemeFactory());
0044 }
0045
0046 private List<Short> values;
0047 private ByteBuffer nulls;
0048
0049
0050 public enum _Fields implements org.apache.thrift.TFieldIdEnum {
0051 VALUES((short)1, "values"),
0052 NULLS((short)2, "nulls");
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 VALUES;
0069 case 2:
0070 return NULLS;
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 public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
0112 static {
0113 Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
0114 tmpMap.put(_Fields.VALUES, new org.apache.thrift.meta_data.FieldMetaData("values", org.apache.thrift.TFieldRequirementType.REQUIRED,
0115 new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
0116 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I16))));
0117 tmpMap.put(_Fields.NULLS, new org.apache.thrift.meta_data.FieldMetaData("nulls", org.apache.thrift.TFieldRequirementType.REQUIRED,
0118 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
0119 metaDataMap = Collections.unmodifiableMap(tmpMap);
0120 org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TI16Column.class, metaDataMap);
0121 }
0122
0123 public TI16Column() {
0124 }
0125
0126 public TI16Column(
0127 List<Short> values,
0128 ByteBuffer nulls)
0129 {
0130 this();
0131 this.values = values;
0132 this.nulls = nulls;
0133 }
0134
0135
0136
0137
0138 public TI16Column(TI16Column other) {
0139 if (other.isSetValues()) {
0140 List<Short> __this__values = new ArrayList<Short>();
0141 for (Short other_element : other.values) {
0142 __this__values.add(other_element);
0143 }
0144 this.values = __this__values;
0145 }
0146 if (other.isSetNulls()) {
0147 this.nulls = org.apache.thrift.TBaseHelper.copyBinary(other.nulls);
0148 ;
0149 }
0150 }
0151
0152 public TI16Column deepCopy() {
0153 return new TI16Column(this);
0154 }
0155
0156 @Override
0157 public void clear() {
0158 this.values = null;
0159 this.nulls = null;
0160 }
0161
0162 public int getValuesSize() {
0163 return (this.values == null) ? 0 : this.values.size();
0164 }
0165
0166 public java.util.Iterator<Short> getValuesIterator() {
0167 return (this.values == null) ? null : this.values.iterator();
0168 }
0169
0170 public void addToValues(short elem) {
0171 if (this.values == null) {
0172 this.values = new ArrayList<Short>();
0173 }
0174 this.values.add(elem);
0175 }
0176
0177 public List<Short> getValues() {
0178 return this.values;
0179 }
0180
0181 public void setValues(List<Short> values) {
0182 this.values = values;
0183 }
0184
0185 public void unsetValues() {
0186 this.values = null;
0187 }
0188
0189
0190 public boolean isSetValues() {
0191 return this.values != null;
0192 }
0193
0194 public void setValuesIsSet(boolean value) {
0195 if (!value) {
0196 this.values = null;
0197 }
0198 }
0199
0200 public byte[] getNulls() {
0201 setNulls(org.apache.thrift.TBaseHelper.rightSize(nulls));
0202 return nulls == null ? null : nulls.array();
0203 }
0204
0205 public ByteBuffer bufferForNulls() {
0206 return nulls;
0207 }
0208
0209 public void setNulls(byte[] nulls) {
0210 setNulls(nulls == null ? (ByteBuffer)null : ByteBuffer.wrap(nulls));
0211 }
0212
0213 public void setNulls(ByteBuffer nulls) {
0214 this.nulls = nulls;
0215 }
0216
0217 public void unsetNulls() {
0218 this.nulls = null;
0219 }
0220
0221
0222 public boolean isSetNulls() {
0223 return this.nulls != null;
0224 }
0225
0226 public void setNullsIsSet(boolean value) {
0227 if (!value) {
0228 this.nulls = null;
0229 }
0230 }
0231
0232 public void setFieldValue(_Fields field, Object value) {
0233 switch (field) {
0234 case VALUES:
0235 if (value == null) {
0236 unsetValues();
0237 } else {
0238 setValues((List<Short>)value);
0239 }
0240 break;
0241
0242 case NULLS:
0243 if (value == null) {
0244 unsetNulls();
0245 } else {
0246 setNulls((ByteBuffer)value);
0247 }
0248 break;
0249
0250 }
0251 }
0252
0253 public Object getFieldValue(_Fields field) {
0254 switch (field) {
0255 case VALUES:
0256 return getValues();
0257
0258 case NULLS:
0259 return getNulls();
0260
0261 }
0262 throw new IllegalStateException();
0263 }
0264
0265
0266 public boolean isSet(_Fields field) {
0267 if (field == null) {
0268 throw new IllegalArgumentException();
0269 }
0270
0271 switch (field) {
0272 case VALUES:
0273 return isSetValues();
0274 case NULLS:
0275 return isSetNulls();
0276 }
0277 throw new IllegalStateException();
0278 }
0279
0280 @Override
0281 public boolean equals(Object that) {
0282 if (that == null)
0283 return false;
0284 if (that instanceof TI16Column)
0285 return this.equals((TI16Column)that);
0286 return false;
0287 }
0288
0289 public boolean equals(TI16Column that) {
0290 if (that == null)
0291 return false;
0292
0293 boolean this_present_values = true && this.isSetValues();
0294 boolean that_present_values = true && that.isSetValues();
0295 if (this_present_values || that_present_values) {
0296 if (!(this_present_values && that_present_values))
0297 return false;
0298 if (!this.values.equals(that.values))
0299 return false;
0300 }
0301
0302 boolean this_present_nulls = true && this.isSetNulls();
0303 boolean that_present_nulls = true && that.isSetNulls();
0304 if (this_present_nulls || that_present_nulls) {
0305 if (!(this_present_nulls && that_present_nulls))
0306 return false;
0307 if (!this.nulls.equals(that.nulls))
0308 return false;
0309 }
0310
0311 return true;
0312 }
0313
0314 @Override
0315 public int hashCode() {
0316 HashCodeBuilder builder = new HashCodeBuilder();
0317
0318 boolean present_values = true && (isSetValues());
0319 builder.append(present_values);
0320 if (present_values)
0321 builder.append(values);
0322
0323 boolean present_nulls = true && (isSetNulls());
0324 builder.append(present_nulls);
0325 if (present_nulls)
0326 builder.append(nulls);
0327
0328 return builder.toHashCode();
0329 }
0330
0331 public int compareTo(TI16Column other) {
0332 if (!getClass().equals(other.getClass())) {
0333 return getClass().getName().compareTo(other.getClass().getName());
0334 }
0335
0336 int lastComparison = 0;
0337 TI16Column typedOther = (TI16Column)other;
0338
0339 lastComparison = Boolean.valueOf(isSetValues()).compareTo(typedOther.isSetValues());
0340 if (lastComparison != 0) {
0341 return lastComparison;
0342 }
0343 if (isSetValues()) {
0344 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.values, typedOther.values);
0345 if (lastComparison != 0) {
0346 return lastComparison;
0347 }
0348 }
0349 lastComparison = Boolean.valueOf(isSetNulls()).compareTo(typedOther.isSetNulls());
0350 if (lastComparison != 0) {
0351 return lastComparison;
0352 }
0353 if (isSetNulls()) {
0354 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.nulls, typedOther.nulls);
0355 if (lastComparison != 0) {
0356 return lastComparison;
0357 }
0358 }
0359 return 0;
0360 }
0361
0362 public _Fields fieldForId(int fieldId) {
0363 return _Fields.findByThriftId(fieldId);
0364 }
0365
0366 public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
0367 schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
0368 }
0369
0370 public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
0371 schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
0372 }
0373
0374 @Override
0375 public String toString() {
0376 StringBuilder sb = new StringBuilder("TI16Column(");
0377 boolean first = true;
0378
0379 sb.append("values:");
0380 if (this.values == null) {
0381 sb.append("null");
0382 } else {
0383 sb.append(this.values);
0384 }
0385 first = false;
0386 if (!first) sb.append(", ");
0387 sb.append("nulls:");
0388 if (this.nulls == null) {
0389 sb.append("null");
0390 } else {
0391 org.apache.thrift.TBaseHelper.toString(this.nulls, sb);
0392 }
0393 first = false;
0394 sb.append(")");
0395 return sb.toString();
0396 }
0397
0398 public void validate() throws org.apache.thrift.TException {
0399
0400 if (!isSetValues()) {
0401 throw new org.apache.thrift.protocol.TProtocolException("Required field 'values' is unset! Struct:" + toString());
0402 }
0403
0404 if (!isSetNulls()) {
0405 throw new org.apache.thrift.protocol.TProtocolException("Required field 'nulls' is unset! Struct:" + toString());
0406 }
0407
0408
0409 }
0410
0411 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
0412 try {
0413 write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
0414 } catch (org.apache.thrift.TException te) {
0415 throw new java.io.IOException(te);
0416 }
0417 }
0418
0419 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
0420 try {
0421 read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
0422 } catch (org.apache.thrift.TException te) {
0423 throw new java.io.IOException(te);
0424 }
0425 }
0426
0427 private static class TI16ColumnStandardSchemeFactory implements SchemeFactory {
0428 public TI16ColumnStandardScheme getScheme() {
0429 return new TI16ColumnStandardScheme();
0430 }
0431 }
0432
0433 private static class TI16ColumnStandardScheme extends StandardScheme<TI16Column> {
0434
0435 public void read(org.apache.thrift.protocol.TProtocol iprot, TI16Column struct) throws org.apache.thrift.TException {
0436 org.apache.thrift.protocol.TField schemeField;
0437 iprot.readStructBegin();
0438 while (true)
0439 {
0440 schemeField = iprot.readFieldBegin();
0441 if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
0442 break;
0443 }
0444 switch (schemeField.id) {
0445 case 1:
0446 if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
0447 {
0448 org.apache.thrift.protocol.TList _list70 = iprot.readListBegin();
0449 struct.values = new ArrayList<Short>(_list70.size);
0450 for (int _i71 = 0; _i71 < _list70.size; ++_i71)
0451 {
0452 short _elem72;
0453 _elem72 = iprot.readI16();
0454 struct.values.add(_elem72);
0455 }
0456 iprot.readListEnd();
0457 }
0458 struct.setValuesIsSet(true);
0459 } else {
0460 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0461 }
0462 break;
0463 case 2:
0464 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
0465 struct.nulls = iprot.readBinary();
0466 struct.setNullsIsSet(true);
0467 } else {
0468 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0469 }
0470 break;
0471 default:
0472 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0473 }
0474 iprot.readFieldEnd();
0475 }
0476 iprot.readStructEnd();
0477 struct.validate();
0478 }
0479
0480 public void write(org.apache.thrift.protocol.TProtocol oprot, TI16Column struct) throws org.apache.thrift.TException {
0481 struct.validate();
0482
0483 oprot.writeStructBegin(STRUCT_DESC);
0484 if (struct.values != null) {
0485 oprot.writeFieldBegin(VALUES_FIELD_DESC);
0486 {
0487 oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I16, struct.values.size()));
0488 for (short _iter73 : struct.values)
0489 {
0490 oprot.writeI16(_iter73);
0491 }
0492 oprot.writeListEnd();
0493 }
0494 oprot.writeFieldEnd();
0495 }
0496 if (struct.nulls != null) {
0497 oprot.writeFieldBegin(NULLS_FIELD_DESC);
0498 oprot.writeBinary(struct.nulls);
0499 oprot.writeFieldEnd();
0500 }
0501 oprot.writeFieldStop();
0502 oprot.writeStructEnd();
0503 }
0504
0505 }
0506
0507 private static class TI16ColumnTupleSchemeFactory implements SchemeFactory {
0508 public TI16ColumnTupleScheme getScheme() {
0509 return new TI16ColumnTupleScheme();
0510 }
0511 }
0512
0513 private static class TI16ColumnTupleScheme extends TupleScheme<TI16Column> {
0514
0515 @Override
0516 public void write(org.apache.thrift.protocol.TProtocol prot, TI16Column struct) throws org.apache.thrift.TException {
0517 TTupleProtocol oprot = (TTupleProtocol) prot;
0518 {
0519 oprot.writeI32(struct.values.size());
0520 for (short _iter74 : struct.values)
0521 {
0522 oprot.writeI16(_iter74);
0523 }
0524 }
0525 oprot.writeBinary(struct.nulls);
0526 }
0527
0528 @Override
0529 public void read(org.apache.thrift.protocol.TProtocol prot, TI16Column struct) throws org.apache.thrift.TException {
0530 TTupleProtocol iprot = (TTupleProtocol) prot;
0531 {
0532 org.apache.thrift.protocol.TList _list75 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I16, iprot.readI32());
0533 struct.values = new ArrayList<Short>(_list75.size);
0534 for (int _i76 = 0; _i76 < _list75.size; ++_i76)
0535 {
0536 short _elem77;
0537 _elem77 = iprot.readI16();
0538 struct.values.add(_elem77);
0539 }
0540 }
0541 struct.setValuesIsSet(true);
0542 struct.nulls = iprot.readBinary();
0543 struct.setNullsIsSet(true);
0544 }
0545 }
0546
0547 }
0548