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