View Javadoc

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