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