View Javadoc

1   /**
2    * Autogenerated by Thrift Compiler (0.9.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.thrift.generated;
8   
9   import org.apache.commons.lang.builder.HashCodeBuilder;
10  import org.apache.thrift.scheme.IScheme;
11  import org.apache.thrift.scheme.SchemeFactory;
12  import org.apache.thrift.scheme.StandardScheme;
13  
14  import org.apache.thrift.scheme.TupleScheme;
15  import org.apache.thrift.protocol.TTupleProtocol;
16  import org.apache.thrift.protocol.TProtocolException;
17  import org.apache.thrift.EncodingUtils;
18  import org.apache.thrift.TException;
19  import java.util.List;
20  import java.util.ArrayList;
21  import java.util.Map;
22  import java.util.HashMap;
23  import java.util.EnumMap;
24  import java.util.Set;
25  import java.util.HashSet;
26  import java.util.EnumSet;
27  import java.util.Collections;
28  import java.util.BitSet;
29  import java.nio.ByteBuffer;
30  import java.util.Arrays;
31  import org.slf4j.Logger;
32  import org.slf4j.LoggerFactory;
33  
34  /**
35   * For increments that are not incrementColumnValue
36   * equivalents.
37   */
38  public class TIncrement implements org.apache.thrift.TBase<TIncrement, TIncrement._Fields>, java.io.Serializable, Cloneable {
39    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TIncrement");
40  
41    private static final org.apache.thrift.protocol.TField TABLE_FIELD_DESC = new org.apache.thrift.protocol.TField("table", org.apache.thrift.protocol.TType.STRING, (short)1);
42    private static final org.apache.thrift.protocol.TField ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("row", org.apache.thrift.protocol.TType.STRING, (short)2);
43    private static final org.apache.thrift.protocol.TField COLUMN_FIELD_DESC = new org.apache.thrift.protocol.TField("column", org.apache.thrift.protocol.TType.STRING, (short)3);
44    private static final org.apache.thrift.protocol.TField AMMOUNT_FIELD_DESC = new org.apache.thrift.protocol.TField("ammount", org.apache.thrift.protocol.TType.I64, (short)4);
45  
46    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
47    static {
48      schemes.put(StandardScheme.class, new TIncrementStandardSchemeFactory());
49      schemes.put(TupleScheme.class, new TIncrementTupleSchemeFactory());
50    }
51  
52    public ByteBuffer table; // required
53    public ByteBuffer row; // required
54    public ByteBuffer column; // required
55    public long ammount; // required
56  
57    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
58    public enum _Fields implements org.apache.thrift.TFieldIdEnum {
59      TABLE((short)1, "table"),
60      ROW((short)2, "row"),
61      COLUMN((short)3, "column"),
62      AMMOUNT((short)4, "ammount");
63  
64      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
65  
66      static {
67        for (_Fields field : EnumSet.allOf(_Fields.class)) {
68          byName.put(field.getFieldName(), field);
69        }
70      }
71  
72      /**
73       * Find the _Fields constant that matches fieldId, or null if its not found.
74       */
75      public static _Fields findByThriftId(int fieldId) {
76        switch(fieldId) {
77          case 1: // TABLE
78            return TABLE;
79          case 2: // ROW
80            return ROW;
81          case 3: // COLUMN
82            return COLUMN;
83          case 4: // AMMOUNT
84            return AMMOUNT;
85          default:
86            return null;
87        }
88      }
89  
90      /**
91       * Find the _Fields constant that matches fieldId, throwing an exception
92       * if it is not found.
93       */
94      public static _Fields findByThriftIdOrThrow(int fieldId) {
95        _Fields fields = findByThriftId(fieldId);
96        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
97        return fields;
98      }
99  
100     /**
101      * Find the _Fields constant that matches name, or null if its not found.
102      */
103     public static _Fields findByName(String name) {
104       return byName.get(name);
105     }
106 
107     private final short _thriftId;
108     private final String _fieldName;
109 
110     _Fields(short thriftId, String fieldName) {
111       _thriftId = thriftId;
112       _fieldName = fieldName;
113     }
114 
115     public short getThriftFieldId() {
116       return _thriftId;
117     }
118 
119     public String getFieldName() {
120       return _fieldName;
121     }
122   }
123 
124   // isset id assignments
125   private static final int __AMMOUNT_ISSET_ID = 0;
126   private byte __isset_bitfield = 0;
127   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
128   static {
129     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
130     tmpMap.put(_Fields.TABLE, new org.apache.thrift.meta_data.FieldMetaData("table", org.apache.thrift.TFieldRequirementType.DEFAULT, 
131         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , "Text")));
132     tmpMap.put(_Fields.ROW, new org.apache.thrift.meta_data.FieldMetaData("row", org.apache.thrift.TFieldRequirementType.DEFAULT, 
133         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , "Text")));
134     tmpMap.put(_Fields.COLUMN, new org.apache.thrift.meta_data.FieldMetaData("column", org.apache.thrift.TFieldRequirementType.DEFAULT, 
135         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING        , "Text")));
136     tmpMap.put(_Fields.AMMOUNT, new org.apache.thrift.meta_data.FieldMetaData("ammount", org.apache.thrift.TFieldRequirementType.DEFAULT, 
137         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
138     metaDataMap = Collections.unmodifiableMap(tmpMap);
139     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TIncrement.class, metaDataMap);
140   }
141 
142   public TIncrement() {
143   }
144 
145   public TIncrement(
146     ByteBuffer table,
147     ByteBuffer row,
148     ByteBuffer column,
149     long ammount)
150   {
151     this();
152     this.table = table;
153     this.row = row;
154     this.column = column;
155     this.ammount = ammount;
156     setAmmountIsSet(true);
157   }
158 
159   /**
160    * Performs a deep copy on <i>other</i>.
161    */
162   public TIncrement(TIncrement other) {
163     __isset_bitfield = other.__isset_bitfield;
164     if (other.isSetTable()) {
165       this.table = other.table;
166     }
167     if (other.isSetRow()) {
168       this.row = other.row;
169     }
170     if (other.isSetColumn()) {
171       this.column = other.column;
172     }
173     this.ammount = other.ammount;
174   }
175 
176   public TIncrement deepCopy() {
177     return new TIncrement(this);
178   }
179 
180   @Override
181   public void clear() {
182     this.table = null;
183     this.row = null;
184     this.column = null;
185     setAmmountIsSet(false);
186     this.ammount = 0;
187   }
188 
189   public byte[] getTable() {
190     setTable(org.apache.thrift.TBaseHelper.rightSize(table));
191     return table == null ? null : table.array();
192   }
193 
194   public ByteBuffer bufferForTable() {
195     return table;
196   }
197 
198   public TIncrement setTable(byte[] table) {
199     setTable(table == null ? (ByteBuffer)null : ByteBuffer.wrap(table));
200     return this;
201   }
202 
203   public TIncrement setTable(ByteBuffer table) {
204     this.table = table;
205     return this;
206   }
207 
208   public void unsetTable() {
209     this.table = null;
210   }
211 
212   /** Returns true if field table is set (has been assigned a value) and false otherwise */
213   public boolean isSetTable() {
214     return this.table != null;
215   }
216 
217   public void setTableIsSet(boolean value) {
218     if (!value) {
219       this.table = null;
220     }
221   }
222 
223   public byte[] getRow() {
224     setRow(org.apache.thrift.TBaseHelper.rightSize(row));
225     return row == null ? null : row.array();
226   }
227 
228   public ByteBuffer bufferForRow() {
229     return row;
230   }
231 
232   public TIncrement setRow(byte[] row) {
233     setRow(row == null ? (ByteBuffer)null : ByteBuffer.wrap(row));
234     return this;
235   }
236 
237   public TIncrement setRow(ByteBuffer row) {
238     this.row = row;
239     return this;
240   }
241 
242   public void unsetRow() {
243     this.row = null;
244   }
245 
246   /** Returns true if field row is set (has been assigned a value) and false otherwise */
247   public boolean isSetRow() {
248     return this.row != null;
249   }
250 
251   public void setRowIsSet(boolean value) {
252     if (!value) {
253       this.row = null;
254     }
255   }
256 
257   public byte[] getColumn() {
258     setColumn(org.apache.thrift.TBaseHelper.rightSize(column));
259     return column == null ? null : column.array();
260   }
261 
262   public ByteBuffer bufferForColumn() {
263     return column;
264   }
265 
266   public TIncrement setColumn(byte[] column) {
267     setColumn(column == null ? (ByteBuffer)null : ByteBuffer.wrap(column));
268     return this;
269   }
270 
271   public TIncrement setColumn(ByteBuffer column) {
272     this.column = column;
273     return this;
274   }
275 
276   public void unsetColumn() {
277     this.column = null;
278   }
279 
280   /** Returns true if field column is set (has been assigned a value) and false otherwise */
281   public boolean isSetColumn() {
282     return this.column != null;
283   }
284 
285   public void setColumnIsSet(boolean value) {
286     if (!value) {
287       this.column = null;
288     }
289   }
290 
291   public long getAmmount() {
292     return this.ammount;
293   }
294 
295   public TIncrement setAmmount(long ammount) {
296     this.ammount = ammount;
297     setAmmountIsSet(true);
298     return this;
299   }
300 
301   public void unsetAmmount() {
302     __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __AMMOUNT_ISSET_ID);
303   }
304 
305   /** Returns true if field ammount is set (has been assigned a value) and false otherwise */
306   public boolean isSetAmmount() {
307     return EncodingUtils.testBit(__isset_bitfield, __AMMOUNT_ISSET_ID);
308   }
309 
310   public void setAmmountIsSet(boolean value) {
311     __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __AMMOUNT_ISSET_ID, value);
312   }
313 
314   public void setFieldValue(_Fields field, Object value) {
315     switch (field) {
316     case TABLE:
317       if (value == null) {
318         unsetTable();
319       } else {
320         setTable((ByteBuffer)value);
321       }
322       break;
323 
324     case ROW:
325       if (value == null) {
326         unsetRow();
327       } else {
328         setRow((ByteBuffer)value);
329       }
330       break;
331 
332     case COLUMN:
333       if (value == null) {
334         unsetColumn();
335       } else {
336         setColumn((ByteBuffer)value);
337       }
338       break;
339 
340     case AMMOUNT:
341       if (value == null) {
342         unsetAmmount();
343       } else {
344         setAmmount((Long)value);
345       }
346       break;
347 
348     }
349   }
350 
351   public Object getFieldValue(_Fields field) {
352     switch (field) {
353     case TABLE:
354       return getTable();
355 
356     case ROW:
357       return getRow();
358 
359     case COLUMN:
360       return getColumn();
361 
362     case AMMOUNT:
363       return Long.valueOf(getAmmount());
364 
365     }
366     throw new IllegalStateException();
367   }
368 
369   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
370   public boolean isSet(_Fields field) {
371     if (field == null) {
372       throw new IllegalArgumentException();
373     }
374 
375     switch (field) {
376     case TABLE:
377       return isSetTable();
378     case ROW:
379       return isSetRow();
380     case COLUMN:
381       return isSetColumn();
382     case AMMOUNT:
383       return isSetAmmount();
384     }
385     throw new IllegalStateException();
386   }
387 
388   @Override
389   public boolean equals(Object that) {
390     if (that == null)
391       return false;
392     if (that instanceof TIncrement)
393       return this.equals((TIncrement)that);
394     return false;
395   }
396 
397   public boolean equals(TIncrement that) {
398     if (that == null)
399       return false;
400 
401     boolean this_present_table = true && this.isSetTable();
402     boolean that_present_table = true && that.isSetTable();
403     if (this_present_table || that_present_table) {
404       if (!(this_present_table && that_present_table))
405         return false;
406       if (!this.table.equals(that.table))
407         return false;
408     }
409 
410     boolean this_present_row = true && this.isSetRow();
411     boolean that_present_row = true && that.isSetRow();
412     if (this_present_row || that_present_row) {
413       if (!(this_present_row && that_present_row))
414         return false;
415       if (!this.row.equals(that.row))
416         return false;
417     }
418 
419     boolean this_present_column = true && this.isSetColumn();
420     boolean that_present_column = true && that.isSetColumn();
421     if (this_present_column || that_present_column) {
422       if (!(this_present_column && that_present_column))
423         return false;
424       if (!this.column.equals(that.column))
425         return false;
426     }
427 
428     boolean this_present_ammount = true;
429     boolean that_present_ammount = true;
430     if (this_present_ammount || that_present_ammount) {
431       if (!(this_present_ammount && that_present_ammount))
432         return false;
433       if (this.ammount != that.ammount)
434         return false;
435     }
436 
437     return true;
438   }
439 
440   @Override
441   public int hashCode() {
442     HashCodeBuilder builder = new HashCodeBuilder();
443 
444     boolean present_table = true && (isSetTable());
445     builder.append(present_table);
446     if (present_table)
447       builder.append(table);
448 
449     boolean present_row = true && (isSetRow());
450     builder.append(present_row);
451     if (present_row)
452       builder.append(row);
453 
454     boolean present_column = true && (isSetColumn());
455     builder.append(present_column);
456     if (present_column)
457       builder.append(column);
458 
459     boolean present_ammount = true;
460     builder.append(present_ammount);
461     if (present_ammount)
462       builder.append(ammount);
463 
464     return builder.toHashCode();
465   }
466 
467   public int compareTo(TIncrement other) {
468     if (!getClass().equals(other.getClass())) {
469       return getClass().getName().compareTo(other.getClass().getName());
470     }
471 
472     int lastComparison = 0;
473     TIncrement typedOther = (TIncrement)other;
474 
475     lastComparison = Boolean.valueOf(isSetTable()).compareTo(typedOther.isSetTable());
476     if (lastComparison != 0) {
477       return lastComparison;
478     }
479     if (isSetTable()) {
480       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.table, typedOther.table);
481       if (lastComparison != 0) {
482         return lastComparison;
483       }
484     }
485     lastComparison = Boolean.valueOf(isSetRow()).compareTo(typedOther.isSetRow());
486     if (lastComparison != 0) {
487       return lastComparison;
488     }
489     if (isSetRow()) {
490       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.row, typedOther.row);
491       if (lastComparison != 0) {
492         return lastComparison;
493       }
494     }
495     lastComparison = Boolean.valueOf(isSetColumn()).compareTo(typedOther.isSetColumn());
496     if (lastComparison != 0) {
497       return lastComparison;
498     }
499     if (isSetColumn()) {
500       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.column, typedOther.column);
501       if (lastComparison != 0) {
502         return lastComparison;
503       }
504     }
505     lastComparison = Boolean.valueOf(isSetAmmount()).compareTo(typedOther.isSetAmmount());
506     if (lastComparison != 0) {
507       return lastComparison;
508     }
509     if (isSetAmmount()) {
510       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.ammount, typedOther.ammount);
511       if (lastComparison != 0) {
512         return lastComparison;
513       }
514     }
515     return 0;
516   }
517 
518   public _Fields fieldForId(int fieldId) {
519     return _Fields.findByThriftId(fieldId);
520   }
521 
522   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
523     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
524   }
525 
526   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
527     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
528   }
529 
530   @Override
531   public String toString() {
532     StringBuilder sb = new StringBuilder("TIncrement(");
533     boolean first = true;
534 
535     sb.append("table:");
536     if (this.table == null) {
537       sb.append("null");
538     } else {
539       sb.append(this.table);
540     }
541     first = false;
542     if (!first) sb.append(", ");
543     sb.append("row:");
544     if (this.row == null) {
545       sb.append("null");
546     } else {
547       sb.append(this.row);
548     }
549     first = false;
550     if (!first) sb.append(", ");
551     sb.append("column:");
552     if (this.column == null) {
553       sb.append("null");
554     } else {
555       sb.append(this.column);
556     }
557     first = false;
558     if (!first) sb.append(", ");
559     sb.append("ammount:");
560     sb.append(this.ammount);
561     first = false;
562     sb.append(")");
563     return sb.toString();
564   }
565 
566   public void validate() throws org.apache.thrift.TException {
567     // check for required fields
568     // check for sub-struct validity
569   }
570 
571   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
572     try {
573       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
574     } catch (org.apache.thrift.TException te) {
575       throw new java.io.IOException(te);
576     }
577   }
578 
579   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
580     try {
581       // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
582       __isset_bitfield = 0;
583       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
584     } catch (org.apache.thrift.TException te) {
585       throw new java.io.IOException(te);
586     }
587   }
588 
589   private static class TIncrementStandardSchemeFactory implements SchemeFactory {
590     public TIncrementStandardScheme getScheme() {
591       return new TIncrementStandardScheme();
592     }
593   }
594 
595   private static class TIncrementStandardScheme extends StandardScheme<TIncrement> {
596 
597     public void read(org.apache.thrift.protocol.TProtocol iprot, TIncrement struct) throws org.apache.thrift.TException {
598       org.apache.thrift.protocol.TField schemeField;
599       iprot.readStructBegin();
600       while (true)
601       {
602         schemeField = iprot.readFieldBegin();
603         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
604           break;
605         }
606         switch (schemeField.id) {
607           case 1: // TABLE
608             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
609               struct.table = iprot.readBinary();
610               struct.setTableIsSet(true);
611             } else { 
612               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
613             }
614             break;
615           case 2: // ROW
616             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
617               struct.row = iprot.readBinary();
618               struct.setRowIsSet(true);
619             } else { 
620               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
621             }
622             break;
623           case 3: // COLUMN
624             if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
625               struct.column = iprot.readBinary();
626               struct.setColumnIsSet(true);
627             } else { 
628               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
629             }
630             break;
631           case 4: // AMMOUNT
632             if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
633               struct.ammount = iprot.readI64();
634               struct.setAmmountIsSet(true);
635             } else { 
636               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
637             }
638             break;
639           default:
640             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
641         }
642         iprot.readFieldEnd();
643       }
644       iprot.readStructEnd();
645 
646       // check for required fields of primitive type, which can't be checked in the validate method
647       struct.validate();
648     }
649 
650     public void write(org.apache.thrift.protocol.TProtocol oprot, TIncrement struct) throws org.apache.thrift.TException {
651       struct.validate();
652 
653       oprot.writeStructBegin(STRUCT_DESC);
654       if (struct.table != null) {
655         oprot.writeFieldBegin(TABLE_FIELD_DESC);
656         oprot.writeBinary(struct.table);
657         oprot.writeFieldEnd();
658       }
659       if (struct.row != null) {
660         oprot.writeFieldBegin(ROW_FIELD_DESC);
661         oprot.writeBinary(struct.row);
662         oprot.writeFieldEnd();
663       }
664       if (struct.column != null) {
665         oprot.writeFieldBegin(COLUMN_FIELD_DESC);
666         oprot.writeBinary(struct.column);
667         oprot.writeFieldEnd();
668       }
669       oprot.writeFieldBegin(AMMOUNT_FIELD_DESC);
670       oprot.writeI64(struct.ammount);
671       oprot.writeFieldEnd();
672       oprot.writeFieldStop();
673       oprot.writeStructEnd();
674     }
675 
676   }
677 
678   private static class TIncrementTupleSchemeFactory implements SchemeFactory {
679     public TIncrementTupleScheme getScheme() {
680       return new TIncrementTupleScheme();
681     }
682   }
683 
684   private static class TIncrementTupleScheme extends TupleScheme<TIncrement> {
685 
686     @Override
687     public void write(org.apache.thrift.protocol.TProtocol prot, TIncrement struct) throws org.apache.thrift.TException {
688       TTupleProtocol oprot = (TTupleProtocol) prot;
689       BitSet optionals = new BitSet();
690       if (struct.isSetTable()) {
691         optionals.set(0);
692       }
693       if (struct.isSetRow()) {
694         optionals.set(1);
695       }
696       if (struct.isSetColumn()) {
697         optionals.set(2);
698       }
699       if (struct.isSetAmmount()) {
700         optionals.set(3);
701       }
702       oprot.writeBitSet(optionals, 4);
703       if (struct.isSetTable()) {
704         oprot.writeBinary(struct.table);
705       }
706       if (struct.isSetRow()) {
707         oprot.writeBinary(struct.row);
708       }
709       if (struct.isSetColumn()) {
710         oprot.writeBinary(struct.column);
711       }
712       if (struct.isSetAmmount()) {
713         oprot.writeI64(struct.ammount);
714       }
715     }
716 
717     @Override
718     public void read(org.apache.thrift.protocol.TProtocol prot, TIncrement struct) throws org.apache.thrift.TException {
719       TTupleProtocol iprot = (TTupleProtocol) prot;
720       BitSet incoming = iprot.readBitSet(4);
721       if (incoming.get(0)) {
722         struct.table = iprot.readBinary();
723         struct.setTableIsSet(true);
724       }
725       if (incoming.get(1)) {
726         struct.row = iprot.readBinary();
727         struct.setRowIsSet(true);
728       }
729       if (incoming.get(2)) {
730         struct.column = iprot.readBinary();
731         struct.setColumnIsSet(true);
732       }
733       if (incoming.get(3)) {
734         struct.ammount = iprot.readI64();
735         struct.setAmmountIsSet(true);
736       }
737     }
738   }
739 
740 }
741