View Javadoc

1   /**
2    * Autogenerated by Thrift Compiler (0.8.0)
3    *
4    * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
5    *  @generated
6    */
7   package org.apache.hadoop.hbase.thrift2.generated;
8   
9   import org.apache.thrift.scheme.IScheme;
10  import org.apache.thrift.scheme.SchemeFactory;
11  import org.apache.thrift.scheme.StandardScheme;
12  
13  import org.apache.thrift.scheme.TupleScheme;
14  import org.apache.thrift.protocol.TTupleProtocol;
15  import java.util.List;
16  import java.util.ArrayList;
17  import java.util.Map;
18  import java.util.HashMap;
19  import java.util.EnumMap;
20  import java.util.Set;
21  import java.util.HashSet;
22  import java.util.EnumSet;
23  import java.util.Collections;
24  import java.util.BitSet;
25  import java.nio.ByteBuffer;
26  import java.util.Arrays;
27  import org.slf4j.Logger;
28  import org.slf4j.LoggerFactory;
29  
30  /**
31   * Represents a single cell and the amount to increment it by
32   */
33  public class TColumnIncrement implements org.apache.thrift.TBase<TColumnIncrement, TColumnIncrement._Fields>, java.io.Serializable, Cloneable {
34    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TColumnIncrement");
35  
36    private static final org.apache.thrift.protocol.TField FAMILY_FIELD_DESC = new org.apache.thrift.protocol.TField("family", org.apache.thrift.protocol.TType.STRING, (short)1);
37    private static final org.apache.thrift.protocol.TField QUALIFIER_FIELD_DESC = new org.apache.thrift.protocol.TField("qualifier", org.apache.thrift.protocol.TType.STRING, (short)2);
38    private static final org.apache.thrift.protocol.TField AMOUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("amount", org.apache.thrift.protocol.TType.I64, (short)3);
39  
40    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
41    static {
42      schemes.put(StandardScheme.class, new TColumnIncrementStandardSchemeFactory());
43      schemes.put(TupleScheme.class, new TColumnIncrementTupleSchemeFactory());
44    }
45  
46    public ByteBuffer family; // required
47    public ByteBuffer qualifier; // required
48    public long amount; // optional
49  
50    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
51    public enum _Fields implements org.apache.thrift.TFieldIdEnum {
52      FAMILY((short)1, "family"),
53      QUALIFIER((short)2, "qualifier"),
54      AMOUNT((short)3, "amount");
55  
56      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
57  
58      static {
59        for (_Fields field : EnumSet.allOf(_Fields.class)) {
60          byName.put(field.getFieldName(), field);
61        }
62      }
63  
64      /**
65       * Find the _Fields constant that matches fieldId, or null if its not found.
66       */
67      public static _Fields findByThriftId(int fieldId) {
68        switch(fieldId) {
69          case 1: // FAMILY
70            return FAMILY;
71          case 2: // QUALIFIER
72            return QUALIFIER;
73          case 3: // AMOUNT
74            return AMOUNT;
75          default:
76            return null;
77        }
78      }
79  
80      /**
81       * Find the _Fields constant that matches fieldId, throwing an exception
82       * if it is not found.
83       */
84      public static _Fields findByThriftIdOrThrow(int fieldId) {
85        _Fields fields = findByThriftId(fieldId);
86        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
87        return fields;
88      }
89  
90      /**
91       * Find the _Fields constant that matches name, or null if its not found.
92       */
93      public static _Fields findByName(String name) {
94        return byName.get(name);
95      }
96  
97      private final short _thriftId;
98      private final String _fieldName;
99  
100     _Fields(short thriftId, String fieldName) {
101       _thriftId = thriftId;
102       _fieldName = fieldName;
103     }
104 
105     public short getThriftFieldId() {
106       return _thriftId;
107     }
108 
109     public String getFieldName() {
110       return _fieldName;
111     }
112   }
113 
114   // isset id assignments
115   private static final int __AMOUNT_ISSET_ID = 0;
116   private BitSet __isset_bit_vector = new BitSet(1);
117   private _Fields optionals[] = {_Fields.AMOUNT};
118   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
119   static {
120     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
121     tmpMap.put(_Fields.FAMILY, new org.apache.thrift.meta_data.FieldMetaData("family", org.apache.thrift.TFieldRequirementType.REQUIRED, 
122         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
123     tmpMap.put(_Fields.QUALIFIER, new org.apache.thrift.meta_data.FieldMetaData("qualifier", org.apache.thrift.TFieldRequirementType.REQUIRED, 
124         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , true)));
125     tmpMap.put(_Fields.AMOUNT, new org.apache.thrift.meta_data.FieldMetaData("amount", org.apache.thrift.TFieldRequirementType.OPTIONAL, 
126         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
127     metaDataMap = Collections.unmodifiableMap(tmpMap);
128     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TColumnIncrement.class, metaDataMap);
129   }
130 
131   public TColumnIncrement() {
132     this.amount = 1L;
133 
134   }
135 
136   public TColumnIncrement(
137     ByteBuffer family,
138     ByteBuffer qualifier)
139   {
140     this();
141     this.family = family;
142     this.qualifier = qualifier;
143   }
144 
145   /**
146    * Performs a deep copy on <i>other</i>.
147    */
148   public TColumnIncrement(TColumnIncrement other) {
149     __isset_bit_vector.clear();
150     __isset_bit_vector.or(other.__isset_bit_vector);
151     if (other.isSetFamily()) {
152       this.family = org.apache.thrift.TBaseHelper.copyBinary(other.family);
153 ;
154     }
155     if (other.isSetQualifier()) {
156       this.qualifier = org.apache.thrift.TBaseHelper.copyBinary(other.qualifier);
157 ;
158     }
159     this.amount = other.amount;
160   }
161 
162   public TColumnIncrement deepCopy() {
163     return new TColumnIncrement(this);
164   }
165 
166   @Override
167   public void clear() {
168     this.family = null;
169     this.qualifier = null;
170     this.amount = 1L;
171 
172   }
173 
174   public byte[] getFamily() {
175     setFamily(org.apache.thrift.TBaseHelper.rightSize(family));
176     return family == null ? null : family.array();
177   }
178 
179   public ByteBuffer bufferForFamily() {
180     return family;
181   }
182 
183   public TColumnIncrement setFamily(byte[] family) {
184     setFamily(family == null ? (ByteBuffer)null : ByteBuffer.wrap(family));
185     return this;
186   }
187 
188   public TColumnIncrement setFamily(ByteBuffer family) {
189     this.family = family;
190     return this;
191   }
192 
193   public void unsetFamily() {
194     this.family = null;
195   }
196 
197   /** Returns true if field family is set (has been assigned a value) and false otherwise */
198   public boolean isSetFamily() {
199     return this.family != null;
200   }
201 
202   public void setFamilyIsSet(boolean value) {
203     if (!value) {
204       this.family = null;
205     }
206   }
207 
208   public byte[] getQualifier() {
209     setQualifier(org.apache.thrift.TBaseHelper.rightSize(qualifier));
210     return qualifier == null ? null : qualifier.array();
211   }
212 
213   public ByteBuffer bufferForQualifier() {
214     return qualifier;
215   }
216 
217   public TColumnIncrement setQualifier(byte[] qualifier) {
218     setQualifier(qualifier == null ? (ByteBuffer)null : ByteBuffer.wrap(qualifier));
219     return this;
220   }
221 
222   public TColumnIncrement setQualifier(ByteBuffer qualifier) {
223     this.qualifier = qualifier;
224     return this;
225   }
226 
227   public void unsetQualifier() {
228     this.qualifier = null;
229   }
230 
231   /** Returns true if field qualifier is set (has been assigned a value) and false otherwise */
232   public boolean isSetQualifier() {
233     return this.qualifier != null;
234   }
235 
236   public void setQualifierIsSet(boolean value) {
237     if (!value) {
238       this.qualifier = null;
239     }
240   }
241 
242   public long getAmount() {
243     return this.amount;
244   }
245 
246   public TColumnIncrement setAmount(long amount) {
247     this.amount = amount;
248     setAmountIsSet(true);
249     return this;
250   }
251 
252   public void unsetAmount() {
253     __isset_bit_vector.clear(__AMOUNT_ISSET_ID);
254   }
255 
256   /** Returns true if field amount is set (has been assigned a value) and false otherwise */
257   public boolean isSetAmount() {
258     return __isset_bit_vector.get(__AMOUNT_ISSET_ID);
259   }
260 
261   public void setAmountIsSet(boolean value) {
262     __isset_bit_vector.set(__AMOUNT_ISSET_ID, value);
263   }
264 
265   public void setFieldValue(_Fields field, Object value) {
266     switch (field) {
267     case FAMILY:
268       if (value == null) {
269         unsetFamily();
270       } else {
271         setFamily((ByteBuffer)value);
272       }
273       break;
274 
275     case QUALIFIER:
276       if (value == null) {
277         unsetQualifier();
278       } else {
279         setQualifier((ByteBuffer)value);
280       }
281       break;
282 
283     case AMOUNT:
284       if (value == null) {
285         unsetAmount();
286       } else {
287         setAmount((Long)value);
288       }
289       break;
290 
291     }
292   }
293 
294   public Object getFieldValue(_Fields field) {
295     switch (field) {
296     case FAMILY:
297       return getFamily();
298 
299     case QUALIFIER:
300       return getQualifier();
301 
302     case AMOUNT:
303       return Long.valueOf(getAmount());
304 
305     }
306     throw new IllegalStateException();
307   }
308 
309   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
310   public boolean isSet(_Fields field) {
311     if (field == null) {
312       throw new IllegalArgumentException();
313     }
314 
315     switch (field) {
316     case FAMILY:
317       return isSetFamily();
318     case QUALIFIER:
319       return isSetQualifier();
320     case AMOUNT:
321       return isSetAmount();
322     }
323     throw new IllegalStateException();
324   }
325 
326   @Override
327   public boolean equals(Object that) {
328     if (that == null)
329       return false;
330     if (that instanceof TColumnIncrement)
331       return this.equals((TColumnIncrement)that);
332     return false;
333   }
334 
335   public boolean equals(TColumnIncrement that) {
336     if (that == null)
337       return false;
338 
339     boolean this_present_family = true && this.isSetFamily();
340     boolean that_present_family = true && that.isSetFamily();
341     if (this_present_family || that_present_family) {
342       if (!(this_present_family && that_present_family))
343         return false;
344       if (!this.family.equals(that.family))
345         return false;
346     }
347 
348     boolean this_present_qualifier = true && this.isSetQualifier();
349     boolean that_present_qualifier = true && that.isSetQualifier();
350     if (this_present_qualifier || that_present_qualifier) {
351       if (!(this_present_qualifier && that_present_qualifier))
352         return false;
353       if (!this.qualifier.equals(that.qualifier))
354         return false;
355     }
356 
357     boolean this_present_amount = true && this.isSetAmount();
358     boolean that_present_amount = true && that.isSetAmount();
359     if (this_present_amount || that_present_amount) {
360       if (!(this_present_amount && that_present_amount))
361         return false;
362       if (this.amount != that.amount)
363         return false;
364     }
365 
366     return true;
367   }
368 
369   @Override
370   public int hashCode() {
371     return 0;
372   }
373 
374   public int compareTo(TColumnIncrement other) {
375     if (!getClass().equals(other.getClass())) {
376       return getClass().getName().compareTo(other.getClass().getName());
377     }
378 
379     int lastComparison = 0;
380     TColumnIncrement typedOther = (TColumnIncrement)other;
381 
382     lastComparison = Boolean.valueOf(isSetFamily()).compareTo(typedOther.isSetFamily());
383     if (lastComparison != 0) {
384       return lastComparison;
385     }
386     if (isSetFamily()) {
387       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.family, typedOther.family);
388       if (lastComparison != 0) {
389         return lastComparison;
390       }
391     }
392     lastComparison = Boolean.valueOf(isSetQualifier()).compareTo(typedOther.isSetQualifier());
393     if (lastComparison != 0) {
394       return lastComparison;
395     }
396     if (isSetQualifier()) {
397       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.qualifier, typedOther.qualifier);
398       if (lastComparison != 0) {
399         return lastComparison;
400       }
401     }
402     lastComparison = Boolean.valueOf(isSetAmount()).compareTo(typedOther.isSetAmount());
403     if (lastComparison != 0) {
404       return lastComparison;
405     }
406     if (isSetAmount()) {
407       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.amount, typedOther.amount);
408       if (lastComparison != 0) {
409         return lastComparison;
410       }
411     }
412     return 0;
413   }
414 
415   public _Fields fieldForId(int fieldId) {
416     return _Fields.findByThriftId(fieldId);
417   }
418 
419   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
420     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
421   }
422 
423   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
424     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
425   }
426 
427   @Override
428   public String toString() {
429     StringBuilder sb = new StringBuilder("TColumnIncrement(");
430     boolean first = true;
431 
432     sb.append("family:");
433     if (this.family == null) {
434       sb.append("null");
435     } else {
436       org.apache.thrift.TBaseHelper.toString(this.family, sb);
437     }
438     first = false;
439     if (!first) sb.append(", ");
440     sb.append("qualifier:");
441     if (this.qualifier == null) {
442       sb.append("null");
443     } else {
444       org.apache.thrift.TBaseHelper.toString(this.qualifier, sb);
445     }
446     first = false;
447     if (isSetAmount()) {
448       if (!first) sb.append(", ");
449       sb.append("amount:");
450       sb.append(this.amount);
451       first = false;
452     }
453     sb.append(")");
454     return sb.toString();
455   }
456 
457   public void validate() throws org.apache.thrift.TException {
458     // check for required fields
459     if (family == null) {
460       throw new org.apache.thrift.protocol.TProtocolException("Required field 'family' was not present! Struct: " + toString());
461     }
462     if (qualifier == null) {
463       throw new org.apache.thrift.protocol.TProtocolException("Required field 'qualifier' was not present! Struct: " + toString());
464     }
465   }
466 
467   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
468     try {
469       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
470     } catch (org.apache.thrift.TException te) {
471       throw new java.io.IOException(te);
472     }
473   }
474 
475   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
476     try {
477       // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
478       __isset_bit_vector = new BitSet(1);
479       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
480     } catch (org.apache.thrift.TException te) {
481       throw new java.io.IOException(te);
482     }
483   }
484 
485   private static class TColumnIncrementStandardSchemeFactory implements SchemeFactory {
486     public TColumnIncrementStandardScheme getScheme() {
487       return new TColumnIncrementStandardScheme();
488     }
489   }
490 
491   private static class TColumnIncrementStandardScheme extends StandardScheme<TColumnIncrement> {
492 
493     public void read(org.apache.thrift.protocol.TProtocol iprot, TColumnIncrement struct) throws org.apache.thrift.TException {
494       org.apache.thrift.protocol.TField schemeField;
495       iprot.readStructBegin();
496       while (true)
497       {
498         schemeField = iprot.readFieldBegin();
499         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
500           break;
501         }
502         switch (schemeField.id) {
503           case 1: // FAMILY
504             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
505               struct.family = iprot.readBinary();
506               struct.setFamilyIsSet(true);
507             } else { 
508               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
509             }
510             break;
511           case 2: // QUALIFIER
512             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
513               struct.qualifier = iprot.readBinary();
514               struct.setQualifierIsSet(true);
515             } else { 
516               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
517             }
518             break;
519           case 3: // AMOUNT
520             if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
521               struct.amount = iprot.readI64();
522               struct.setAmountIsSet(true);
523             } else { 
524               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
525             }
526             break;
527           default:
528             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
529         }
530         iprot.readFieldEnd();
531       }
532       iprot.readStructEnd();
533 
534       // check for required fields of primitive type, which can't be checked in the validate method
535       struct.validate();
536     }
537 
538     public void write(org.apache.thrift.protocol.TProtocol oprot, TColumnIncrement struct) throws org.apache.thrift.TException {
539       struct.validate();
540 
541       oprot.writeStructBegin(STRUCT_DESC);
542       if (struct.family != null) {
543         oprot.writeFieldBegin(FAMILY_FIELD_DESC);
544         oprot.writeBinary(struct.family);
545         oprot.writeFieldEnd();
546       }
547       if (struct.qualifier != null) {
548         oprot.writeFieldBegin(QUALIFIER_FIELD_DESC);
549         oprot.writeBinary(struct.qualifier);
550         oprot.writeFieldEnd();
551       }
552       if (struct.isSetAmount()) {
553         oprot.writeFieldBegin(AMOUNT_FIELD_DESC);
554         oprot.writeI64(struct.amount);
555         oprot.writeFieldEnd();
556       }
557       oprot.writeFieldStop();
558       oprot.writeStructEnd();
559     }
560 
561   }
562 
563   private static class TColumnIncrementTupleSchemeFactory implements SchemeFactory {
564     public TColumnIncrementTupleScheme getScheme() {
565       return new TColumnIncrementTupleScheme();
566     }
567   }
568 
569   private static class TColumnIncrementTupleScheme extends TupleScheme<TColumnIncrement> {
570 
571     @Override
572     public void write(org.apache.thrift.protocol.TProtocol prot, TColumnIncrement struct) throws org.apache.thrift.TException {
573       TTupleProtocol oprot = (TTupleProtocol) prot;
574       oprot.writeBinary(struct.family);
575       oprot.writeBinary(struct.qualifier);
576       BitSet optionals = new BitSet();
577       if (struct.isSetAmount()) {
578         optionals.set(0);
579       }
580       oprot.writeBitSet(optionals, 1);
581       if (struct.isSetAmount()) {
582         oprot.writeI64(struct.amount);
583       }
584     }
585 
586     @Override
587     public void read(org.apache.thrift.protocol.TProtocol prot, TColumnIncrement struct) throws org.apache.thrift.TException {
588       TTupleProtocol iprot = (TTupleProtocol) prot;
589       struct.family = iprot.readBinary();
590       struct.setFamilyIsSet(true);
591       struct.qualifier = iprot.readBinary();
592       struct.setQualifierIsSet(true);
593       BitSet incoming = iprot.readBitSet(1);
594       if (incoming.get(0)) {
595         struct.amount = iprot.readI64();
596         struct.setAmountIsSet(true);
597       }
598     }
599   }
600 
601 }
602