Back to home page

OSCL-LXR

 
 

    


0001 /**
0002  * Autogenerated by Thrift Compiler (0.9.0)
0003  *
0004  * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
0005  *  @generated
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 TGetSchemasReq implements org.apache.thrift.TBase<TGetSchemasReq, TGetSchemasReq._Fields>, java.io.Serializable, Cloneable {
0035   private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TGetSchemasReq");
0036 
0037   private static final org.apache.thrift.protocol.TField SESSION_HANDLE_FIELD_DESC = new org.apache.thrift.protocol.TField("sessionHandle", org.apache.thrift.protocol.TType.STRUCT, (short)1);
0038   private static final org.apache.thrift.protocol.TField CATALOG_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("catalogName", org.apache.thrift.protocol.TType.STRING, (short)2);
0039   private static final org.apache.thrift.protocol.TField SCHEMA_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("schemaName", org.apache.thrift.protocol.TType.STRING, (short)3);
0040 
0041   private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
0042   static {
0043     schemes.put(StandardScheme.class, new TGetSchemasReqStandardSchemeFactory());
0044     schemes.put(TupleScheme.class, new TGetSchemasReqTupleSchemeFactory());
0045   }
0046 
0047   private TSessionHandle sessionHandle; // required
0048   private String catalogName; // optional
0049   private String schemaName; // optional
0050 
0051   /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
0052   public enum _Fields implements org.apache.thrift.TFieldIdEnum {
0053     SESSION_HANDLE((short)1, "sessionHandle"),
0054     CATALOG_NAME((short)2, "catalogName"),
0055     SCHEMA_NAME((short)3, "schemaName");
0056 
0057     private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
0058 
0059     static {
0060       for (_Fields field : EnumSet.allOf(_Fields.class)) {
0061         byName.put(field.getFieldName(), field);
0062       }
0063     }
0064 
0065     /**
0066      * Find the _Fields constant that matches fieldId, or null if its not found.
0067      */
0068     public static _Fields findByThriftId(int fieldId) {
0069       switch(fieldId) {
0070         case 1: // SESSION_HANDLE
0071           return SESSION_HANDLE;
0072         case 2: // CATALOG_NAME
0073           return CATALOG_NAME;
0074         case 3: // SCHEMA_NAME
0075           return SCHEMA_NAME;
0076         default:
0077           return null;
0078       }
0079     }
0080 
0081     /**
0082      * Find the _Fields constant that matches fieldId, throwing an exception
0083      * if it is not found.
0084      */
0085     public static _Fields findByThriftIdOrThrow(int fieldId) {
0086       _Fields fields = findByThriftId(fieldId);
0087       if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
0088       return fields;
0089     }
0090 
0091     /**
0092      * Find the _Fields constant that matches name, or null if its not found.
0093      */
0094     public static _Fields findByName(String name) {
0095       return byName.get(name);
0096     }
0097 
0098     private final short _thriftId;
0099     private final String _fieldName;
0100 
0101     _Fields(short thriftId, String fieldName) {
0102       _thriftId = thriftId;
0103       _fieldName = fieldName;
0104     }
0105 
0106     public short getThriftFieldId() {
0107       return _thriftId;
0108     }
0109 
0110     public String getFieldName() {
0111       return _fieldName;
0112     }
0113   }
0114 
0115   // isset id assignments
0116   private _Fields optionals[] = {_Fields.CATALOG_NAME,_Fields.SCHEMA_NAME};
0117   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
0118   static {
0119     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
0120     tmpMap.put(_Fields.SESSION_HANDLE, new org.apache.thrift.meta_data.FieldMetaData("sessionHandle", org.apache.thrift.TFieldRequirementType.REQUIRED, 
0121         new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, TSessionHandle.class)));
0122     tmpMap.put(_Fields.CATALOG_NAME, new org.apache.thrift.meta_data.FieldMetaData("catalogName", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
0123         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , "TIdentifier")));
0124     tmpMap.put(_Fields.SCHEMA_NAME, new org.apache.thrift.meta_data.FieldMetaData("schemaName", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
0125         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , "TPatternOrIdentifier")));
0126     metaDataMap = Collections.unmodifiableMap(tmpMap);
0127     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TGetSchemasReq.class, metaDataMap);
0128   }
0129 
0130   public TGetSchemasReq() {
0131   }
0132 
0133   public TGetSchemasReq(
0134     TSessionHandle sessionHandle)
0135   {
0136     this();
0137     this.sessionHandle = sessionHandle;
0138   }
0139 
0140   /**
0141    * Performs a deep copy on <i>other</i>.
0142    */
0143   public TGetSchemasReq(TGetSchemasReq other) {
0144     if (other.isSetSessionHandle()) {
0145       this.sessionHandle = new TSessionHandle(other.sessionHandle);
0146     }
0147     if (other.isSetCatalogName()) {
0148       this.catalogName = other.catalogName;
0149     }
0150     if (other.isSetSchemaName()) {
0151       this.schemaName = other.schemaName;
0152     }
0153   }
0154 
0155   public TGetSchemasReq deepCopy() {
0156     return new TGetSchemasReq(this);
0157   }
0158 
0159   @Override
0160   public void clear() {
0161     this.sessionHandle = null;
0162     this.catalogName = null;
0163     this.schemaName = null;
0164   }
0165 
0166   public TSessionHandle getSessionHandle() {
0167     return this.sessionHandle;
0168   }
0169 
0170   public void setSessionHandle(TSessionHandle sessionHandle) {
0171     this.sessionHandle = sessionHandle;
0172   }
0173 
0174   public void unsetSessionHandle() {
0175     this.sessionHandle = null;
0176   }
0177 
0178   /** Returns true if field sessionHandle is set (has been assigned a value) and false otherwise */
0179   public boolean isSetSessionHandle() {
0180     return this.sessionHandle != null;
0181   }
0182 
0183   public void setSessionHandleIsSet(boolean value) {
0184     if (!value) {
0185       this.sessionHandle = null;
0186     }
0187   }
0188 
0189   public String getCatalogName() {
0190     return this.catalogName;
0191   }
0192 
0193   public void setCatalogName(String catalogName) {
0194     this.catalogName = catalogName;
0195   }
0196 
0197   public void unsetCatalogName() {
0198     this.catalogName = null;
0199   }
0200 
0201   /** Returns true if field catalogName is set (has been assigned a value) and false otherwise */
0202   public boolean isSetCatalogName() {
0203     return this.catalogName != null;
0204   }
0205 
0206   public void setCatalogNameIsSet(boolean value) {
0207     if (!value) {
0208       this.catalogName = null;
0209     }
0210   }
0211 
0212   public String getSchemaName() {
0213     return this.schemaName;
0214   }
0215 
0216   public void setSchemaName(String schemaName) {
0217     this.schemaName = schemaName;
0218   }
0219 
0220   public void unsetSchemaName() {
0221     this.schemaName = null;
0222   }
0223 
0224   /** Returns true if field schemaName is set (has been assigned a value) and false otherwise */
0225   public boolean isSetSchemaName() {
0226     return this.schemaName != null;
0227   }
0228 
0229   public void setSchemaNameIsSet(boolean value) {
0230     if (!value) {
0231       this.schemaName = null;
0232     }
0233   }
0234 
0235   public void setFieldValue(_Fields field, Object value) {
0236     switch (field) {
0237     case SESSION_HANDLE:
0238       if (value == null) {
0239         unsetSessionHandle();
0240       } else {
0241         setSessionHandle((TSessionHandle)value);
0242       }
0243       break;
0244 
0245     case CATALOG_NAME:
0246       if (value == null) {
0247         unsetCatalogName();
0248       } else {
0249         setCatalogName((String)value);
0250       }
0251       break;
0252 
0253     case SCHEMA_NAME:
0254       if (value == null) {
0255         unsetSchemaName();
0256       } else {
0257         setSchemaName((String)value);
0258       }
0259       break;
0260 
0261     }
0262   }
0263 
0264   public Object getFieldValue(_Fields field) {
0265     switch (field) {
0266     case SESSION_HANDLE:
0267       return getSessionHandle();
0268 
0269     case CATALOG_NAME:
0270       return getCatalogName();
0271 
0272     case SCHEMA_NAME:
0273       return getSchemaName();
0274 
0275     }
0276     throw new IllegalStateException();
0277   }
0278 
0279   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
0280   public boolean isSet(_Fields field) {
0281     if (field == null) {
0282       throw new IllegalArgumentException();
0283     }
0284 
0285     switch (field) {
0286     case SESSION_HANDLE:
0287       return isSetSessionHandle();
0288     case CATALOG_NAME:
0289       return isSetCatalogName();
0290     case SCHEMA_NAME:
0291       return isSetSchemaName();
0292     }
0293     throw new IllegalStateException();
0294   }
0295 
0296   @Override
0297   public boolean equals(Object that) {
0298     if (that == null)
0299       return false;
0300     if (that instanceof TGetSchemasReq)
0301       return this.equals((TGetSchemasReq)that);
0302     return false;
0303   }
0304 
0305   public boolean equals(TGetSchemasReq that) {
0306     if (that == null)
0307       return false;
0308 
0309     boolean this_present_sessionHandle = true && this.isSetSessionHandle();
0310     boolean that_present_sessionHandle = true && that.isSetSessionHandle();
0311     if (this_present_sessionHandle || that_present_sessionHandle) {
0312       if (!(this_present_sessionHandle && that_present_sessionHandle))
0313         return false;
0314       if (!this.sessionHandle.equals(that.sessionHandle))
0315         return false;
0316     }
0317 
0318     boolean this_present_catalogName = true && this.isSetCatalogName();
0319     boolean that_present_catalogName = true && that.isSetCatalogName();
0320     if (this_present_catalogName || that_present_catalogName) {
0321       if (!(this_present_catalogName && that_present_catalogName))
0322         return false;
0323       if (!this.catalogName.equals(that.catalogName))
0324         return false;
0325     }
0326 
0327     boolean this_present_schemaName = true && this.isSetSchemaName();
0328     boolean that_present_schemaName = true && that.isSetSchemaName();
0329     if (this_present_schemaName || that_present_schemaName) {
0330       if (!(this_present_schemaName && that_present_schemaName))
0331         return false;
0332       if (!this.schemaName.equals(that.schemaName))
0333         return false;
0334     }
0335 
0336     return true;
0337   }
0338 
0339   @Override
0340   public int hashCode() {
0341     HashCodeBuilder builder = new HashCodeBuilder();
0342 
0343     boolean present_sessionHandle = true && (isSetSessionHandle());
0344     builder.append(present_sessionHandle);
0345     if (present_sessionHandle)
0346       builder.append(sessionHandle);
0347 
0348     boolean present_catalogName = true && (isSetCatalogName());
0349     builder.append(present_catalogName);
0350     if (present_catalogName)
0351       builder.append(catalogName);
0352 
0353     boolean present_schemaName = true && (isSetSchemaName());
0354     builder.append(present_schemaName);
0355     if (present_schemaName)
0356       builder.append(schemaName);
0357 
0358     return builder.toHashCode();
0359   }
0360 
0361   public int compareTo(TGetSchemasReq other) {
0362     if (!getClass().equals(other.getClass())) {
0363       return getClass().getName().compareTo(other.getClass().getName());
0364     }
0365 
0366     int lastComparison = 0;
0367     TGetSchemasReq typedOther = (TGetSchemasReq)other;
0368 
0369     lastComparison = Boolean.valueOf(isSetSessionHandle()).compareTo(typedOther.isSetSessionHandle());
0370     if (lastComparison != 0) {
0371       return lastComparison;
0372     }
0373     if (isSetSessionHandle()) {
0374       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.sessionHandle, typedOther.sessionHandle);
0375       if (lastComparison != 0) {
0376         return lastComparison;
0377       }
0378     }
0379     lastComparison = Boolean.valueOf(isSetCatalogName()).compareTo(typedOther.isSetCatalogName());
0380     if (lastComparison != 0) {
0381       return lastComparison;
0382     }
0383     if (isSetCatalogName()) {
0384       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.catalogName, typedOther.catalogName);
0385       if (lastComparison != 0) {
0386         return lastComparison;
0387       }
0388     }
0389     lastComparison = Boolean.valueOf(isSetSchemaName()).compareTo(typedOther.isSetSchemaName());
0390     if (lastComparison != 0) {
0391       return lastComparison;
0392     }
0393     if (isSetSchemaName()) {
0394       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.schemaName, typedOther.schemaName);
0395       if (lastComparison != 0) {
0396         return lastComparison;
0397       }
0398     }
0399     return 0;
0400   }
0401 
0402   public _Fields fieldForId(int fieldId) {
0403     return _Fields.findByThriftId(fieldId);
0404   }
0405 
0406   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
0407     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
0408   }
0409 
0410   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
0411     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
0412   }
0413 
0414   @Override
0415   public String toString() {
0416     StringBuilder sb = new StringBuilder("TGetSchemasReq(");
0417     boolean first = true;
0418 
0419     sb.append("sessionHandle:");
0420     if (this.sessionHandle == null) {
0421       sb.append("null");
0422     } else {
0423       sb.append(this.sessionHandle);
0424     }
0425     first = false;
0426     if (isSetCatalogName()) {
0427       if (!first) sb.append(", ");
0428       sb.append("catalogName:");
0429       if (this.catalogName == null) {
0430         sb.append("null");
0431       } else {
0432         sb.append(this.catalogName);
0433       }
0434       first = false;
0435     }
0436     if (isSetSchemaName()) {
0437       if (!first) sb.append(", ");
0438       sb.append("schemaName:");
0439       if (this.schemaName == null) {
0440         sb.append("null");
0441       } else {
0442         sb.append(this.schemaName);
0443       }
0444       first = false;
0445     }
0446     sb.append(")");
0447     return sb.toString();
0448   }
0449 
0450   public void validate() throws org.apache.thrift.TException {
0451     // check for required fields
0452     if (!isSetSessionHandle()) {
0453       throw new org.apache.thrift.protocol.TProtocolException("Required field 'sessionHandle' is unset! Struct:" + toString());
0454     }
0455 
0456     // check for sub-struct validity
0457     if (sessionHandle != null) {
0458       sessionHandle.validate();
0459     }
0460   }
0461 
0462   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
0463     try {
0464       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
0465     } catch (org.apache.thrift.TException te) {
0466       throw new java.io.IOException(te);
0467     }
0468   }
0469 
0470   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
0471     try {
0472       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
0473     } catch (org.apache.thrift.TException te) {
0474       throw new java.io.IOException(te);
0475     }
0476   }
0477 
0478   private static class TGetSchemasReqStandardSchemeFactory implements SchemeFactory {
0479     public TGetSchemasReqStandardScheme getScheme() {
0480       return new TGetSchemasReqStandardScheme();
0481     }
0482   }
0483 
0484   private static class TGetSchemasReqStandardScheme extends StandardScheme<TGetSchemasReq> {
0485 
0486     public void read(org.apache.thrift.protocol.TProtocol iprot, TGetSchemasReq struct) throws org.apache.thrift.TException {
0487       org.apache.thrift.protocol.TField schemeField;
0488       iprot.readStructBegin();
0489       while (true)
0490       {
0491         schemeField = iprot.readFieldBegin();
0492         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
0493           break;
0494         }
0495         switch (schemeField.id) {
0496           case 1: // SESSION_HANDLE
0497             if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
0498               struct.sessionHandle = new TSessionHandle();
0499               struct.sessionHandle.read(iprot);
0500               struct.setSessionHandleIsSet(true);
0501             } else { 
0502               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0503             }
0504             break;
0505           case 2: // CATALOG_NAME
0506             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
0507               struct.catalogName = iprot.readString();
0508               struct.setCatalogNameIsSet(true);
0509             } else { 
0510               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0511             }
0512             break;
0513           case 3: // SCHEMA_NAME
0514             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
0515               struct.schemaName = iprot.readString();
0516               struct.setSchemaNameIsSet(true);
0517             } else { 
0518               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0519             }
0520             break;
0521           default:
0522             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
0523         }
0524         iprot.readFieldEnd();
0525       }
0526       iprot.readStructEnd();
0527       struct.validate();
0528     }
0529 
0530     public void write(org.apache.thrift.protocol.TProtocol oprot, TGetSchemasReq struct) throws org.apache.thrift.TException {
0531       struct.validate();
0532 
0533       oprot.writeStructBegin(STRUCT_DESC);
0534       if (struct.sessionHandle != null) {
0535         oprot.writeFieldBegin(SESSION_HANDLE_FIELD_DESC);
0536         struct.sessionHandle.write(oprot);
0537         oprot.writeFieldEnd();
0538       }
0539       if (struct.catalogName != null) {
0540         if (struct.isSetCatalogName()) {
0541           oprot.writeFieldBegin(CATALOG_NAME_FIELD_DESC);
0542           oprot.writeString(struct.catalogName);
0543           oprot.writeFieldEnd();
0544         }
0545       }
0546       if (struct.schemaName != null) {
0547         if (struct.isSetSchemaName()) {
0548           oprot.writeFieldBegin(SCHEMA_NAME_FIELD_DESC);
0549           oprot.writeString(struct.schemaName);
0550           oprot.writeFieldEnd();
0551         }
0552       }
0553       oprot.writeFieldStop();
0554       oprot.writeStructEnd();
0555     }
0556 
0557   }
0558 
0559   private static class TGetSchemasReqTupleSchemeFactory implements SchemeFactory {
0560     public TGetSchemasReqTupleScheme getScheme() {
0561       return new TGetSchemasReqTupleScheme();
0562     }
0563   }
0564 
0565   private static class TGetSchemasReqTupleScheme extends TupleScheme<TGetSchemasReq> {
0566 
0567     @Override
0568     public void write(org.apache.thrift.protocol.TProtocol prot, TGetSchemasReq struct) throws org.apache.thrift.TException {
0569       TTupleProtocol oprot = (TTupleProtocol) prot;
0570       struct.sessionHandle.write(oprot);
0571       BitSet optionals = new BitSet();
0572       if (struct.isSetCatalogName()) {
0573         optionals.set(0);
0574       }
0575       if (struct.isSetSchemaName()) {
0576         optionals.set(1);
0577       }
0578       oprot.writeBitSet(optionals, 2);
0579       if (struct.isSetCatalogName()) {
0580         oprot.writeString(struct.catalogName);
0581       }
0582       if (struct.isSetSchemaName()) {
0583         oprot.writeString(struct.schemaName);
0584       }
0585     }
0586 
0587     @Override
0588     public void read(org.apache.thrift.protocol.TProtocol prot, TGetSchemasReq struct) throws org.apache.thrift.TException {
0589       TTupleProtocol iprot = (TTupleProtocol) prot;
0590       struct.sessionHandle = new TSessionHandle();
0591       struct.sessionHandle.read(iprot);
0592       struct.setSessionHandleIsSet(true);
0593       BitSet incoming = iprot.readBitSet(2);
0594       if (incoming.get(0)) {
0595         struct.catalogName = iprot.readString();
0596         struct.setCatalogNameIsSet(true);
0597       }
0598       if (incoming.get(1)) {
0599         struct.schemaName = iprot.readString();
0600         struct.setSchemaNameIsSet(true);
0601       }
0602     }
0603   }
0604 
0605 }
0606