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