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 InitialMultiScan implements org.apache.thrift.TBase<InitialMultiScan, InitialMultiScan._Fields>, java.io.Serializable, Cloneable {
50    private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("InitialMultiScan");
51  
52    private static final org.apache.thrift.protocol.TField SCAN_ID_FIELD_DESC = new org.apache.thrift.protocol.TField("scanID", org.apache.thrift.protocol.TType.I64, (short)1);
53    private static final org.apache.thrift.protocol.TField RESULT_FIELD_DESC = new org.apache.thrift.protocol.TField("result", org.apache.thrift.protocol.TType.STRUCT, (short)2);
54  
55    private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
56    static {
57      schemes.put(StandardScheme.class, new InitialMultiScanStandardSchemeFactory());
58      schemes.put(TupleScheme.class, new InitialMultiScanTupleSchemeFactory());
59    }
60  
61    public long scanID; // required
62    public MultiScanResult result; // required
63  
64    /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */
65    @SuppressWarnings("all") public enum _Fields implements org.apache.thrift.TFieldIdEnum {
66      SCAN_ID((short)1, "scanID"),
67      RESULT((short)2, "result");
68  
69      private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
70  
71      static {
72        for (_Fields field : EnumSet.allOf(_Fields.class)) {
73          byName.put(field.getFieldName(), field);
74        }
75      }
76  
77      /**
78       * Find the _Fields constant that matches fieldId, or null if its not found.
79       */
80      public static _Fields findByThriftId(int fieldId) {
81        switch(fieldId) {
82          case 1: // SCAN_ID
83            return SCAN_ID;
84          case 2: // RESULT
85            return RESULT;
86          default:
87            return null;
88        }
89      }
90  
91      /**
92       * Find the _Fields constant that matches fieldId, throwing an exception
93       * if it is not found.
94       */
95      public static _Fields findByThriftIdOrThrow(int fieldId) {
96        _Fields fields = findByThriftId(fieldId);
97        if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
98        return fields;
99      }
100 
101     /**
102      * Find the _Fields constant that matches name, or null if its not found.
103      */
104     public static _Fields findByName(String name) {
105       return byName.get(name);
106     }
107 
108     private final short _thriftId;
109     private final String _fieldName;
110 
111     _Fields(short thriftId, String fieldName) {
112       _thriftId = thriftId;
113       _fieldName = fieldName;
114     }
115 
116     public short getThriftFieldId() {
117       return _thriftId;
118     }
119 
120     public String getFieldName() {
121       return _fieldName;
122     }
123   }
124 
125   // isset id assignments
126   private static final int __SCANID_ISSET_ID = 0;
127   private byte __isset_bitfield = 0;
128   public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
129   static {
130     Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
131     tmpMap.put(_Fields.SCAN_ID, new org.apache.thrift.meta_data.FieldMetaData("scanID", org.apache.thrift.TFieldRequirementType.DEFAULT, 
132         new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64        , "ScanID")));
133     tmpMap.put(_Fields.RESULT, new org.apache.thrift.meta_data.FieldMetaData("result", org.apache.thrift.TFieldRequirementType.DEFAULT, 
134         new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, MultiScanResult.class)));
135     metaDataMap = Collections.unmodifiableMap(tmpMap);
136     org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(InitialMultiScan.class, metaDataMap);
137   }
138 
139   public InitialMultiScan() {
140   }
141 
142   public InitialMultiScan(
143     long scanID,
144     MultiScanResult result)
145   {
146     this();
147     this.scanID = scanID;
148     setScanIDIsSet(true);
149     this.result = result;
150   }
151 
152   /**
153    * Performs a deep copy on <i>other</i>.
154    */
155   public InitialMultiScan(InitialMultiScan other) {
156     __isset_bitfield = other.__isset_bitfield;
157     this.scanID = other.scanID;
158     if (other.isSetResult()) {
159       this.result = new MultiScanResult(other.result);
160     }
161   }
162 
163   public InitialMultiScan deepCopy() {
164     return new InitialMultiScan(this);
165   }
166 
167   @Override
168   public void clear() {
169     setScanIDIsSet(false);
170     this.scanID = 0;
171     this.result = null;
172   }
173 
174   public long getScanID() {
175     return this.scanID;
176   }
177 
178   public InitialMultiScan setScanID(long scanID) {
179     this.scanID = scanID;
180     setScanIDIsSet(true);
181     return this;
182   }
183 
184   public void unsetScanID() {
185     __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __SCANID_ISSET_ID);
186   }
187 
188   /** Returns true if field scanID is set (has been assigned a value) and false otherwise */
189   public boolean isSetScanID() {
190     return EncodingUtils.testBit(__isset_bitfield, __SCANID_ISSET_ID);
191   }
192 
193   public void setScanIDIsSet(boolean value) {
194     __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __SCANID_ISSET_ID, value);
195   }
196 
197   public MultiScanResult getResult() {
198     return this.result;
199   }
200 
201   public InitialMultiScan setResult(MultiScanResult result) {
202     this.result = result;
203     return this;
204   }
205 
206   public void unsetResult() {
207     this.result = null;
208   }
209 
210   /** Returns true if field result is set (has been assigned a value) and false otherwise */
211   public boolean isSetResult() {
212     return this.result != null;
213   }
214 
215   public void setResultIsSet(boolean value) {
216     if (!value) {
217       this.result = null;
218     }
219   }
220 
221   public void setFieldValue(_Fields field, Object value) {
222     switch (field) {
223     case SCAN_ID:
224       if (value == null) {
225         unsetScanID();
226       } else {
227         setScanID((Long)value);
228       }
229       break;
230 
231     case RESULT:
232       if (value == null) {
233         unsetResult();
234       } else {
235         setResult((MultiScanResult)value);
236       }
237       break;
238 
239     }
240   }
241 
242   public Object getFieldValue(_Fields field) {
243     switch (field) {
244     case SCAN_ID:
245       return Long.valueOf(getScanID());
246 
247     case RESULT:
248       return getResult();
249 
250     }
251     throw new IllegalStateException();
252   }
253 
254   /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */
255   public boolean isSet(_Fields field) {
256     if (field == null) {
257       throw new IllegalArgumentException();
258     }
259 
260     switch (field) {
261     case SCAN_ID:
262       return isSetScanID();
263     case RESULT:
264       return isSetResult();
265     }
266     throw new IllegalStateException();
267   }
268 
269   @Override
270   public boolean equals(Object that) {
271     if (that == null)
272       return false;
273     if (that instanceof InitialMultiScan)
274       return this.equals((InitialMultiScan)that);
275     return false;
276   }
277 
278   public boolean equals(InitialMultiScan that) {
279     if (that == null)
280       return false;
281 
282     boolean this_present_scanID = true;
283     boolean that_present_scanID = true;
284     if (this_present_scanID || that_present_scanID) {
285       if (!(this_present_scanID && that_present_scanID))
286         return false;
287       if (this.scanID != that.scanID)
288         return false;
289     }
290 
291     boolean this_present_result = true && this.isSetResult();
292     boolean that_present_result = true && that.isSetResult();
293     if (this_present_result || that_present_result) {
294       if (!(this_present_result && that_present_result))
295         return false;
296       if (!this.result.equals(that.result))
297         return false;
298     }
299 
300     return true;
301   }
302 
303   @Override
304   public int hashCode() {
305     return 0;
306   }
307 
308   public int compareTo(InitialMultiScan other) {
309     if (!getClass().equals(other.getClass())) {
310       return getClass().getName().compareTo(other.getClass().getName());
311     }
312 
313     int lastComparison = 0;
314     InitialMultiScan typedOther = (InitialMultiScan)other;
315 
316     lastComparison = Boolean.valueOf(isSetScanID()).compareTo(typedOther.isSetScanID());
317     if (lastComparison != 0) {
318       return lastComparison;
319     }
320     if (isSetScanID()) {
321       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.scanID, typedOther.scanID);
322       if (lastComparison != 0) {
323         return lastComparison;
324       }
325     }
326     lastComparison = Boolean.valueOf(isSetResult()).compareTo(typedOther.isSetResult());
327     if (lastComparison != 0) {
328       return lastComparison;
329     }
330     if (isSetResult()) {
331       lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.result, typedOther.result);
332       if (lastComparison != 0) {
333         return lastComparison;
334       }
335     }
336     return 0;
337   }
338 
339   public _Fields fieldForId(int fieldId) {
340     return _Fields.findByThriftId(fieldId);
341   }
342 
343   public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
344     schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
345   }
346 
347   public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
348     schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
349   }
350 
351   @Override
352   public String toString() {
353     StringBuilder sb = new StringBuilder("InitialMultiScan(");
354     boolean first = true;
355 
356     sb.append("scanID:");
357     sb.append(this.scanID);
358     first = false;
359     if (!first) sb.append(", ");
360     sb.append("result:");
361     if (this.result == null) {
362       sb.append("null");
363     } else {
364       sb.append(this.result);
365     }
366     first = false;
367     sb.append(")");
368     return sb.toString();
369   }
370 
371   public void validate() throws org.apache.thrift.TException {
372     // check for required fields
373     // check for sub-struct validity
374     if (result != null) {
375       result.validate();
376     }
377   }
378 
379   private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
380     try {
381       write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
382     } catch (org.apache.thrift.TException te) {
383       throw new java.io.IOException(te);
384     }
385   }
386 
387   private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
388     try {
389       // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor.
390       __isset_bitfield = 0;
391       read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
392     } catch (org.apache.thrift.TException te) {
393       throw new java.io.IOException(te);
394     }
395   }
396 
397   private static class InitialMultiScanStandardSchemeFactory implements SchemeFactory {
398     public InitialMultiScanStandardScheme getScheme() {
399       return new InitialMultiScanStandardScheme();
400     }
401   }
402 
403   private static class InitialMultiScanStandardScheme extends StandardScheme<InitialMultiScan> {
404 
405     public void read(org.apache.thrift.protocol.TProtocol iprot, InitialMultiScan struct) throws org.apache.thrift.TException {
406       org.apache.thrift.protocol.TField schemeField;
407       iprot.readStructBegin();
408       while (true)
409       {
410         schemeField = iprot.readFieldBegin();
411         if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { 
412           break;
413         }
414         switch (schemeField.id) {
415           case 1: // SCAN_ID
416             if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
417               struct.scanID = iprot.readI64();
418               struct.setScanIDIsSet(true);
419             } else { 
420               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
421             }
422             break;
423           case 2: // RESULT
424             if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) {
425               struct.result = new MultiScanResult();
426               struct.result.read(iprot);
427               struct.setResultIsSet(true);
428             } else { 
429               org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
430             }
431             break;
432           default:
433             org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
434         }
435         iprot.readFieldEnd();
436       }
437       iprot.readStructEnd();
438 
439       // check for required fields of primitive type, which can't be checked in the validate method
440       struct.validate();
441     }
442 
443     public void write(org.apache.thrift.protocol.TProtocol oprot, InitialMultiScan struct) throws org.apache.thrift.TException {
444       struct.validate();
445 
446       oprot.writeStructBegin(STRUCT_DESC);
447       oprot.writeFieldBegin(SCAN_ID_FIELD_DESC);
448       oprot.writeI64(struct.scanID);
449       oprot.writeFieldEnd();
450       if (struct.result != null) {
451         oprot.writeFieldBegin(RESULT_FIELD_DESC);
452         struct.result.write(oprot);
453         oprot.writeFieldEnd();
454       }
455       oprot.writeFieldStop();
456       oprot.writeStructEnd();
457     }
458 
459   }
460 
461   private static class InitialMultiScanTupleSchemeFactory implements SchemeFactory {
462     public InitialMultiScanTupleScheme getScheme() {
463       return new InitialMultiScanTupleScheme();
464     }
465   }
466 
467   private static class InitialMultiScanTupleScheme extends TupleScheme<InitialMultiScan> {
468 
469     @Override
470     public void write(org.apache.thrift.protocol.TProtocol prot, InitialMultiScan struct) throws org.apache.thrift.TException {
471       TTupleProtocol oprot = (TTupleProtocol) prot;
472       BitSet optionals = new BitSet();
473       if (struct.isSetScanID()) {
474         optionals.set(0);
475       }
476       if (struct.isSetResult()) {
477         optionals.set(1);
478       }
479       oprot.writeBitSet(optionals, 2);
480       if (struct.isSetScanID()) {
481         oprot.writeI64(struct.scanID);
482       }
483       if (struct.isSetResult()) {
484         struct.result.write(oprot);
485       }
486     }
487 
488     @Override
489     public void read(org.apache.thrift.protocol.TProtocol prot, InitialMultiScan struct) throws org.apache.thrift.TException {
490       TTupleProtocol iprot = (TTupleProtocol) prot;
491       BitSet incoming = iprot.readBitSet(2);
492       if (incoming.get(0)) {
493         struct.scanID = iprot.readI64();
494         struct.setScanIDIsSet(true);
495       }
496       if (incoming.get(1)) {
497         struct.result = new MultiScanResult();
498         struct.result.read(iprot);
499         struct.setResultIsSet(true);
500       }
501     }
502   }
503 
504 }
505