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