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 TRow implements org.apache.thrift.TBase<TRow, TRow._Fields>, java.io.Serializable, Cloneable {
0035 private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TRow");
0036
0037 private static final org.apache.thrift.protocol.TField COL_VALS_FIELD_DESC = new org.apache.thrift.protocol.TField("colVals", org.apache.thrift.protocol.TType.LIST, (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 TRowStandardSchemeFactory());
0042 schemes.put(TupleScheme.class, new TRowTupleSchemeFactory());
0043 }
0044
0045 private List<TColumnValue> colVals;
0046
0047
0048 public enum _Fields implements org.apache.thrift.TFieldIdEnum {
0049 COL_VALS((short)1, "colVals");
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 COL_VALS;
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 public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
0107 static {
0108 Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
0109 tmpMap.put(_Fields.COL_VALS, new org.apache.thrift.meta_data.FieldMetaData("colVals", org.apache.thrift.TFieldRequirementType.REQUIRED,
0110 new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
0111 new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TColumnValue.class))));
0112 metaDataMap = Collections.unmodifiableMap(tmpMap);
0113 org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TRow.class, metaDataMap);
0114 }
0115
0116 public TRow() {
0117 }
0118
0119 public TRow(
0120 List<TColumnValue> colVals)
0121 {
0122 this();
0123 this.colVals = colVals;
0124 }
0125
0126
0127
0128
0129 public TRow(TRow other) {
0130 if (other.isSetColVals()) {
0131 List<TColumnValue> __this__colVals = new ArrayList<TColumnValue>();
0132 for (TColumnValue other_element : other.colVals) {
0133 __this__colVals.add(new TColumnValue(other_element));
0134 }
0135 this.colVals = __this__colVals;
0136 }
0137 }
0138
0139 public TRow deepCopy() {
0140 return new TRow(this);
0141 }
0142
0143 @Override
0144 public void clear() {
0145 this.colVals = null;
0146 }
0147
0148 public int getColValsSize() {
0149 return (this.colVals == null) ? 0 : this.colVals.size();
0150 }
0151
0152 public java.util.Iterator<TColumnValue> getColValsIterator() {
0153 return (this.colVals == null) ? null : this.colVals.iterator();
0154 }
0155
0156 public void addToColVals(TColumnValue elem) {
0157 if (this.colVals == null) {
0158 this.colVals = new ArrayList<TColumnValue>();
0159 }
0160 this.colVals.add(elem);
0161 }
0162
0163 public List<TColumnValue> getColVals() {
0164 return this.colVals;
0165 }
0166
0167 public void setColVals(List<TColumnValue> colVals) {
0168 this.colVals = colVals;
0169 }
0170
0171 public void unsetColVals() {
0172 this.colVals = null;
0173 }
0174
0175
0176 public boolean isSetColVals() {
0177 return this.colVals != null;
0178 }
0179
0180 public void setColValsIsSet(boolean value) {
0181 if (!value) {
0182 this.colVals = null;
0183 }
0184 }
0185
0186 public void setFieldValue(_Fields field, Object value) {
0187 switch (field) {
0188 case COL_VALS:
0189 if (value == null) {
0190 unsetColVals();
0191 } else {
0192 setColVals((List<TColumnValue>)value);
0193 }
0194 break;
0195
0196 }
0197 }
0198
0199 public Object getFieldValue(_Fields field) {
0200 switch (field) {
0201 case COL_VALS:
0202 return getColVals();
0203
0204 }
0205 throw new IllegalStateException();
0206 }
0207
0208
0209 public boolean isSet(_Fields field) {
0210 if (field == null) {
0211 throw new IllegalArgumentException();
0212 }
0213
0214 switch (field) {
0215 case COL_VALS:
0216 return isSetColVals();
0217 }
0218 throw new IllegalStateException();
0219 }
0220
0221 @Override
0222 public boolean equals(Object that) {
0223 if (that == null)
0224 return false;
0225 if (that instanceof TRow)
0226 return this.equals((TRow)that);
0227 return false;
0228 }
0229
0230 public boolean equals(TRow that) {
0231 if (that == null)
0232 return false;
0233
0234 boolean this_present_colVals = true && this.isSetColVals();
0235 boolean that_present_colVals = true && that.isSetColVals();
0236 if (this_present_colVals || that_present_colVals) {
0237 if (!(this_present_colVals && that_present_colVals))
0238 return false;
0239 if (!this.colVals.equals(that.colVals))
0240 return false;
0241 }
0242
0243 return true;
0244 }
0245
0246 @Override
0247 public int hashCode() {
0248 HashCodeBuilder builder = new HashCodeBuilder();
0249
0250 boolean present_colVals = true && (isSetColVals());
0251 builder.append(present_colVals);
0252 if (present_colVals)
0253 builder.append(colVals);
0254
0255 return builder.toHashCode();
0256 }
0257
0258 public int compareTo(TRow other) {
0259 if (!getClass().equals(other.getClass())) {
0260 return getClass().getName().compareTo(other.getClass().getName());
0261 }
0262
0263 int lastComparison = 0;
0264 TRow typedOther = (TRow)other;
0265
0266 lastComparison = Boolean.valueOf(isSetColVals()).compareTo(typedOther.isSetColVals());
0267 if (lastComparison != 0) {
0268 return lastComparison;
0269 }
0270 if (isSetColVals()) {
0271 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.colVals, typedOther.colVals);
0272 if (lastComparison != 0) {
0273 return lastComparison;
0274 }
0275 }
0276 return 0;
0277 }
0278
0279 public _Fields fieldForId(int fieldId) {
0280 return _Fields.findByThriftId(fieldId);
0281 }
0282
0283 public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
0284 schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
0285 }
0286
0287 public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
0288 schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
0289 }
0290
0291 @Override
0292 public String toString() {
0293 StringBuilder sb = new StringBuilder("TRow(");
0294 boolean first = true;
0295
0296 sb.append("colVals:");
0297 if (this.colVals == null) {
0298 sb.append("null");
0299 } else {
0300 sb.append(this.colVals);
0301 }
0302 first = false;
0303 sb.append(")");
0304 return sb.toString();
0305 }
0306
0307 public void validate() throws org.apache.thrift.TException {
0308
0309 if (!isSetColVals()) {
0310 throw new org.apache.thrift.protocol.TProtocolException("Required field 'colVals' is unset! Struct:" + toString());
0311 }
0312
0313
0314 }
0315
0316 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
0317 try {
0318 write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
0319 } catch (org.apache.thrift.TException te) {
0320 throw new java.io.IOException(te);
0321 }
0322 }
0323
0324 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
0325 try {
0326 read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
0327 } catch (org.apache.thrift.TException te) {
0328 throw new java.io.IOException(te);
0329 }
0330 }
0331
0332 private static class TRowStandardSchemeFactory implements SchemeFactory {
0333 public TRowStandardScheme getScheme() {
0334 return new TRowStandardScheme();
0335 }
0336 }
0337
0338 private static class TRowStandardScheme extends StandardScheme<TRow> {
0339
0340 public void read(org.apache.thrift.protocol.TProtocol iprot, TRow struct) throws org.apache.thrift.TException {
0341 org.apache.thrift.protocol.TField schemeField;
0342 iprot.readStructBegin();
0343 while (true)
0344 {
0345 schemeField = iprot.readFieldBegin();
0346 if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
0347 break;
0348 }
0349 switch (schemeField.id) {
0350 case 1:
0351 if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
0352 {
0353 org.apache.thrift.protocol.TList _list46 = iprot.readListBegin();
0354 struct.colVals = new ArrayList<TColumnValue>(_list46.size);
0355 for (int _i47 = 0; _i47 < _list46.size; ++_i47)
0356 {
0357 TColumnValue _elem48;
0358 _elem48 = new TColumnValue();
0359 _elem48.read(iprot);
0360 struct.colVals.add(_elem48);
0361 }
0362 iprot.readListEnd();
0363 }
0364 struct.setColValsIsSet(true);
0365 } else {
0366 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0367 }
0368 break;
0369 default:
0370 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0371 }
0372 iprot.readFieldEnd();
0373 }
0374 iprot.readStructEnd();
0375 struct.validate();
0376 }
0377
0378 public void write(org.apache.thrift.protocol.TProtocol oprot, TRow struct) throws org.apache.thrift.TException {
0379 struct.validate();
0380
0381 oprot.writeStructBegin(STRUCT_DESC);
0382 if (struct.colVals != null) {
0383 oprot.writeFieldBegin(COL_VALS_FIELD_DESC);
0384 {
0385 oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.colVals.size()));
0386 for (TColumnValue _iter49 : struct.colVals)
0387 {
0388 _iter49.write(oprot);
0389 }
0390 oprot.writeListEnd();
0391 }
0392 oprot.writeFieldEnd();
0393 }
0394 oprot.writeFieldStop();
0395 oprot.writeStructEnd();
0396 }
0397
0398 }
0399
0400 private static class TRowTupleSchemeFactory implements SchemeFactory {
0401 public TRowTupleScheme getScheme() {
0402 return new TRowTupleScheme();
0403 }
0404 }
0405
0406 private static class TRowTupleScheme extends TupleScheme<TRow> {
0407
0408 @Override
0409 public void write(org.apache.thrift.protocol.TProtocol prot, TRow struct) throws org.apache.thrift.TException {
0410 TTupleProtocol oprot = (TTupleProtocol) prot;
0411 {
0412 oprot.writeI32(struct.colVals.size());
0413 for (TColumnValue _iter50 : struct.colVals)
0414 {
0415 _iter50.write(oprot);
0416 }
0417 }
0418 }
0419
0420 @Override
0421 public void read(org.apache.thrift.protocol.TProtocol prot, TRow struct) throws org.apache.thrift.TException {
0422 TTupleProtocol iprot = (TTupleProtocol) prot;
0423 {
0424 org.apache.thrift.protocol.TList _list51 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
0425 struct.colVals = new ArrayList<TColumnValue>(_list51.size);
0426 for (int _i52 = 0; _i52 < _list51.size; ++_i52)
0427 {
0428 TColumnValue _elem53;
0429 _elem53 = new TColumnValue();
0430 _elem53.read(iprot);
0431 struct.colVals.add(_elem53);
0432 }
0433 }
0434 struct.setColValsIsSet(true);
0435 }
0436 }
0437
0438 }
0439