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