1
2
3
4
5
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
35
36
37
38
39 public class TCell implements org.apache.thrift.TBase<TCell, TCell._Fields>, java.io.Serializable, Cloneable {
40 private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TCell");
41
42 private static final org.apache.thrift.protocol.TField VALUE_FIELD_DESC = new org.apache.thrift.protocol.TField("value", org.apache.thrift.protocol.TType.STRING, (short)1);
43 private static final org.apache.thrift.protocol.TField TIMESTAMP_FIELD_DESC = new org.apache.thrift.protocol.TField("timestamp", org.apache.thrift.protocol.TType.I64, (short)2);
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 TCellStandardSchemeFactory());
48 schemes.put(TupleScheme.class, new TCellTupleSchemeFactory());
49 }
50
51 public ByteBuffer value;
52 public long timestamp;
53
54
55 public enum _Fields implements org.apache.thrift.TFieldIdEnum {
56 VALUE((short)1, "value"),
57 TIMESTAMP((short)2, "timestamp");
58
59 private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
60
61 static {
62 for (_Fields field : EnumSet.allOf(_Fields.class)) {
63 byName.put(field.getFieldName(), field);
64 }
65 }
66
67
68
69
70 public static _Fields findByThriftId(int fieldId) {
71 switch(fieldId) {
72 case 1:
73 return VALUE;
74 case 2:
75 return TIMESTAMP;
76 default:
77 return null;
78 }
79 }
80
81
82
83
84
85 public static _Fields findByThriftIdOrThrow(int fieldId) {
86 _Fields fields = findByThriftId(fieldId);
87 if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
88 return fields;
89 }
90
91
92
93
94 public static _Fields findByName(String name) {
95 return byName.get(name);
96 }
97
98 private final short _thriftId;
99 private final String _fieldName;
100
101 _Fields(short thriftId, String fieldName) {
102 _thriftId = thriftId;
103 _fieldName = fieldName;
104 }
105
106 public short getThriftFieldId() {
107 return _thriftId;
108 }
109
110 public String getFieldName() {
111 return _fieldName;
112 }
113 }
114
115
116 private static final int __TIMESTAMP_ISSET_ID = 0;
117 private byte __isset_bitfield = 0;
118 public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
119 static {
120 Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
121 tmpMap.put(_Fields.VALUE, new org.apache.thrift.meta_data.FieldMetaData("value", org.apache.thrift.TFieldRequirementType.DEFAULT,
122 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , "Bytes")));
123 tmpMap.put(_Fields.TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("timestamp", org.apache.thrift.TFieldRequirementType.DEFAULT,
124 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
125 metaDataMap = Collections.unmodifiableMap(tmpMap);
126 org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TCell.class, metaDataMap);
127 }
128
129 public TCell() {
130 }
131
132 public TCell(
133 ByteBuffer value,
134 long timestamp)
135 {
136 this();
137 this.value = value;
138 this.timestamp = timestamp;
139 setTimestampIsSet(true);
140 }
141
142
143
144
145 public TCell(TCell other) {
146 __isset_bitfield = other.__isset_bitfield;
147 if (other.isSetValue()) {
148 this.value = other.value;
149 }
150 this.timestamp = other.timestamp;
151 }
152
153 public TCell deepCopy() {
154 return new TCell(this);
155 }
156
157 @Override
158 public void clear() {
159 this.value = null;
160 setTimestampIsSet(false);
161 this.timestamp = 0;
162 }
163
164 public byte[] getValue() {
165 setValue(org.apache.thrift.TBaseHelper.rightSize(value));
166 return value == null ? null : value.array();
167 }
168
169 public ByteBuffer bufferForValue() {
170 return value;
171 }
172
173 public TCell setValue(byte[] value) {
174 setValue(value == null ? (ByteBuffer)null : ByteBuffer.wrap(value));
175 return this;
176 }
177
178 public TCell setValue(ByteBuffer value) {
179 this.value = value;
180 return this;
181 }
182
183 public void unsetValue() {
184 this.value = null;
185 }
186
187
188 public boolean isSetValue() {
189 return this.value != null;
190 }
191
192 public void setValueIsSet(boolean value) {
193 if (!value) {
194 this.value = null;
195 }
196 }
197
198 public long getTimestamp() {
199 return this.timestamp;
200 }
201
202 public TCell setTimestamp(long timestamp) {
203 this.timestamp = timestamp;
204 setTimestampIsSet(true);
205 return this;
206 }
207
208 public void unsetTimestamp() {
209 __isset_bitfield = EncodingUtils.clearBit(__isset_bitfield, __TIMESTAMP_ISSET_ID);
210 }
211
212
213 public boolean isSetTimestamp() {
214 return EncodingUtils.testBit(__isset_bitfield, __TIMESTAMP_ISSET_ID);
215 }
216
217 public void setTimestampIsSet(boolean value) {
218 __isset_bitfield = EncodingUtils.setBit(__isset_bitfield, __TIMESTAMP_ISSET_ID, value);
219 }
220
221 public void setFieldValue(_Fields field, Object value) {
222 switch (field) {
223 case VALUE:
224 if (value == null) {
225 unsetValue();
226 } else {
227 setValue((ByteBuffer)value);
228 }
229 break;
230
231 case TIMESTAMP:
232 if (value == null) {
233 unsetTimestamp();
234 } else {
235 setTimestamp((Long)value);
236 }
237 break;
238
239 }
240 }
241
242 public Object getFieldValue(_Fields field) {
243 switch (field) {
244 case VALUE:
245 return getValue();
246
247 case TIMESTAMP:
248 return Long.valueOf(getTimestamp());
249
250 }
251 throw new IllegalStateException();
252 }
253
254
255 public boolean isSet(_Fields field) {
256 if (field == null) {
257 throw new IllegalArgumentException();
258 }
259
260 switch (field) {
261 case VALUE:
262 return isSetValue();
263 case TIMESTAMP:
264 return isSetTimestamp();
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 TCell)
274 return this.equals((TCell)that);
275 return false;
276 }
277
278 public boolean equals(TCell that) {
279 if (that == null)
280 return false;
281
282 boolean this_present_value = true && this.isSetValue();
283 boolean that_present_value = true && that.isSetValue();
284 if (this_present_value || that_present_value) {
285 if (!(this_present_value && that_present_value))
286 return false;
287 if (!this.value.equals(that.value))
288 return false;
289 }
290
291 boolean this_present_timestamp = true;
292 boolean that_present_timestamp = true;
293 if (this_present_timestamp || that_present_timestamp) {
294 if (!(this_present_timestamp && that_present_timestamp))
295 return false;
296 if (this.timestamp != that.timestamp)
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(TCell other) {
309 if (!getClass().equals(other.getClass())) {
310 return getClass().getName().compareTo(other.getClass().getName());
311 }
312
313 int lastComparison = 0;
314 TCell typedOther = (TCell)other;
315
316 lastComparison = Boolean.valueOf(isSetValue()).compareTo(typedOther.isSetValue());
317 if (lastComparison != 0) {
318 return lastComparison;
319 }
320 if (isSetValue()) {
321 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.value, typedOther.value);
322 if (lastComparison != 0) {
323 return lastComparison;
324 }
325 }
326 lastComparison = Boolean.valueOf(isSetTimestamp()).compareTo(typedOther.isSetTimestamp());
327 if (lastComparison != 0) {
328 return lastComparison;
329 }
330 if (isSetTimestamp()) {
331 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.timestamp, typedOther.timestamp);
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("TCell(");
354 boolean first = true;
355
356 sb.append("value:");
357 if (this.value == null) {
358 sb.append("null");
359 } else {
360 sb.append(this.value);
361 }
362 first = false;
363 if (!first) sb.append(", ");
364 sb.append("timestamp:");
365 sb.append(this.timestamp);
366 first = false;
367 sb.append(")");
368 return sb.toString();
369 }
370
371 public void validate() throws org.apache.thrift.TException {
372
373
374 }
375
376 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
377 try {
378 write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
379 } catch (org.apache.thrift.TException te) {
380 throw new java.io.IOException(te);
381 }
382 }
383
384 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
385 try {
386
387 __isset_bitfield = 0;
388 read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
389 } catch (org.apache.thrift.TException te) {
390 throw new java.io.IOException(te);
391 }
392 }
393
394 private static class TCellStandardSchemeFactory implements SchemeFactory {
395 public TCellStandardScheme getScheme() {
396 return new TCellStandardScheme();
397 }
398 }
399
400 private static class TCellStandardScheme extends StandardScheme<TCell> {
401
402 public void read(org.apache.thrift.protocol.TProtocol iprot, TCell struct) throws org.apache.thrift.TException {
403 org.apache.thrift.protocol.TField schemeField;
404 iprot.readStructBegin();
405 while (true)
406 {
407 schemeField = iprot.readFieldBegin();
408 if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
409 break;
410 }
411 switch (schemeField.id) {
412 case 1:
413 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
414 struct.value = iprot.readBinary();
415 struct.setValueIsSet(true);
416 } else {
417 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
418 }
419 break;
420 case 2:
421 if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
422 struct.timestamp = iprot.readI64();
423 struct.setTimestampIsSet(true);
424 } else {
425 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
426 }
427 break;
428 default:
429 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
430 }
431 iprot.readFieldEnd();
432 }
433 iprot.readStructEnd();
434
435
436 struct.validate();
437 }
438
439 public void write(org.apache.thrift.protocol.TProtocol oprot, TCell struct) throws org.apache.thrift.TException {
440 struct.validate();
441
442 oprot.writeStructBegin(STRUCT_DESC);
443 if (struct.value != null) {
444 oprot.writeFieldBegin(VALUE_FIELD_DESC);
445 oprot.writeBinary(struct.value);
446 oprot.writeFieldEnd();
447 }
448 oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
449 oprot.writeI64(struct.timestamp);
450 oprot.writeFieldEnd();
451 oprot.writeFieldStop();
452 oprot.writeStructEnd();
453 }
454
455 }
456
457 private static class TCellTupleSchemeFactory implements SchemeFactory {
458 public TCellTupleScheme getScheme() {
459 return new TCellTupleScheme();
460 }
461 }
462
463 private static class TCellTupleScheme extends TupleScheme<TCell> {
464
465 @Override
466 public void write(org.apache.thrift.protocol.TProtocol prot, TCell struct) throws org.apache.thrift.TException {
467 TTupleProtocol oprot = (TTupleProtocol) prot;
468 BitSet optionals = new BitSet();
469 if (struct.isSetValue()) {
470 optionals.set(0);
471 }
472 if (struct.isSetTimestamp()) {
473 optionals.set(1);
474 }
475 oprot.writeBitSet(optionals, 2);
476 if (struct.isSetValue()) {
477 oprot.writeBinary(struct.value);
478 }
479 if (struct.isSetTimestamp()) {
480 oprot.writeI64(struct.timestamp);
481 }
482 }
483
484 @Override
485 public void read(org.apache.thrift.protocol.TProtocol prot, TCell struct) throws org.apache.thrift.TException {
486 TTupleProtocol iprot = (TTupleProtocol) prot;
487 BitSet incoming = iprot.readBitSet(2);
488 if (incoming.get(0)) {
489 struct.value = iprot.readBinary();
490 struct.setValueIsSet(true);
491 }
492 if (incoming.get(1)) {
493 struct.timestamp = iprot.readI64();
494 struct.setTimestampIsSet(true);
495 }
496 }
497 }
498
499 }
500