1
2
3
4
5
6
7 package org.apache.hadoop.hbase.thrift2.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 java.util.List;
17 import java.util.ArrayList;
18 import java.util.Map;
19 import java.util.HashMap;
20 import java.util.EnumMap;
21 import java.util.Set;
22 import java.util.HashSet;
23 import java.util.EnumSet;
24 import java.util.Collections;
25 import java.util.BitSet;
26 import java.nio.ByteBuffer;
27 import java.util.Arrays;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
30
31
32
33
34 public class TColumnValue implements org.apache.thrift.TBase<TColumnValue, TColumnValue._Fields>, java.io.Serializable, Cloneable {
35 private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("TColumnValue");
36
37 private static final org.apache.thrift.protocol.TField FAMILY_FIELD_DESC = new org.apache.thrift.protocol.TField("family", org.apache.thrift.protocol.TType.STRING, (short)1);
38 private static final org.apache.thrift.protocol.TField QUALIFIER_FIELD_DESC = new org.apache.thrift.protocol.TField("qualifier", org.apache.thrift.protocol.TType.STRING, (short)2);
39 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)3);
40 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)4);
41
42 private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
43 static {
44 schemes.put(StandardScheme.class, new TColumnValueStandardSchemeFactory());
45 schemes.put(TupleScheme.class, new TColumnValueTupleSchemeFactory());
46 }
47
48 public ByteBuffer family;
49 public ByteBuffer qualifier;
50 public ByteBuffer value;
51 public long timestamp;
52
53
54 public enum _Fields implements org.apache.thrift.TFieldIdEnum {
55 FAMILY((short)1, "family"),
56 QUALIFIER((short)2, "qualifier"),
57 VALUE((short)3, "value"),
58 TIMESTAMP((short)4, "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 FAMILY;
75 case 2:
76 return QUALIFIER;
77 case 3:
78 return VALUE;
79 case 4:
80 return TIMESTAMP;
81 default:
82 return null;
83 }
84 }
85
86
87
88
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
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
121 private static final int __TIMESTAMP_ISSET_ID = 0;
122 private BitSet __isset_bit_vector = new BitSet(1);
123 private _Fields optionals[] = {_Fields.TIMESTAMP};
124 public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
125 static {
126 Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
127 tmpMap.put(_Fields.FAMILY, new org.apache.thrift.meta_data.FieldMetaData("family", org.apache.thrift.TFieldRequirementType.REQUIRED,
128 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
129 tmpMap.put(_Fields.QUALIFIER, new org.apache.thrift.meta_data.FieldMetaData("qualifier", org.apache.thrift.TFieldRequirementType.REQUIRED,
130 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
131 tmpMap.put(_Fields.VALUE, new org.apache.thrift.meta_data.FieldMetaData("value", org.apache.thrift.TFieldRequirementType.REQUIRED,
132 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , true)));
133 tmpMap.put(_Fields.TIMESTAMP, new org.apache.thrift.meta_data.FieldMetaData("timestamp", org.apache.thrift.TFieldRequirementType.OPTIONAL,
134 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I64)));
135 metaDataMap = Collections.unmodifiableMap(tmpMap);
136 org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(TColumnValue.class, metaDataMap);
137 }
138
139 public TColumnValue() {
140 }
141
142 public TColumnValue(
143 ByteBuffer family,
144 ByteBuffer qualifier,
145 ByteBuffer value)
146 {
147 this();
148 this.family = family;
149 this.qualifier = qualifier;
150 this.value = value;
151 }
152
153
154
155
156 public TColumnValue(TColumnValue other) {
157 __isset_bit_vector.clear();
158 __isset_bit_vector.or(other.__isset_bit_vector);
159 if (other.isSetFamily()) {
160 this.family = org.apache.thrift.TBaseHelper.copyBinary(other.family);
161 ;
162 }
163 if (other.isSetQualifier()) {
164 this.qualifier = org.apache.thrift.TBaseHelper.copyBinary(other.qualifier);
165 ;
166 }
167 if (other.isSetValue()) {
168 this.value = org.apache.thrift.TBaseHelper.copyBinary(other.value);
169 ;
170 }
171 this.timestamp = other.timestamp;
172 }
173
174 public TColumnValue deepCopy() {
175 return new TColumnValue(this);
176 }
177
178 @Override
179 public void clear() {
180 this.family = null;
181 this.qualifier = null;
182 this.value = null;
183 setTimestampIsSet(false);
184 this.timestamp = 0;
185 }
186
187 public byte[] getFamily() {
188 setFamily(org.apache.thrift.TBaseHelper.rightSize(family));
189 return family == null ? null : family.array();
190 }
191
192 public ByteBuffer bufferForFamily() {
193 return family;
194 }
195
196 public TColumnValue setFamily(byte[] family) {
197 setFamily(family == null ? (ByteBuffer)null : ByteBuffer.wrap(family));
198 return this;
199 }
200
201 public TColumnValue setFamily(ByteBuffer family) {
202 this.family = family;
203 return this;
204 }
205
206 public void unsetFamily() {
207 this.family = null;
208 }
209
210
211 public boolean isSetFamily() {
212 return this.family != null;
213 }
214
215 public void setFamilyIsSet(boolean value) {
216 if (!value) {
217 this.family = null;
218 }
219 }
220
221 public byte[] getQualifier() {
222 setQualifier(org.apache.thrift.TBaseHelper.rightSize(qualifier));
223 return qualifier == null ? null : qualifier.array();
224 }
225
226 public ByteBuffer bufferForQualifier() {
227 return qualifier;
228 }
229
230 public TColumnValue setQualifier(byte[] qualifier) {
231 setQualifier(qualifier == null ? (ByteBuffer)null : ByteBuffer.wrap(qualifier));
232 return this;
233 }
234
235 public TColumnValue setQualifier(ByteBuffer qualifier) {
236 this.qualifier = qualifier;
237 return this;
238 }
239
240 public void unsetQualifier() {
241 this.qualifier = null;
242 }
243
244
245 public boolean isSetQualifier() {
246 return this.qualifier != null;
247 }
248
249 public void setQualifierIsSet(boolean value) {
250 if (!value) {
251 this.qualifier = null;
252 }
253 }
254
255 public byte[] getValue() {
256 setValue(org.apache.thrift.TBaseHelper.rightSize(value));
257 return value == null ? null : value.array();
258 }
259
260 public ByteBuffer bufferForValue() {
261 return value;
262 }
263
264 public TColumnValue setValue(byte[] value) {
265 setValue(value == null ? (ByteBuffer)null : ByteBuffer.wrap(value));
266 return this;
267 }
268
269 public TColumnValue setValue(ByteBuffer value) {
270 this.value = value;
271 return this;
272 }
273
274 public void unsetValue() {
275 this.value = null;
276 }
277
278
279 public boolean isSetValue() {
280 return this.value != null;
281 }
282
283 public void setValueIsSet(boolean value) {
284 if (!value) {
285 this.value = null;
286 }
287 }
288
289 public long getTimestamp() {
290 return this.timestamp;
291 }
292
293 public TColumnValue setTimestamp(long timestamp) {
294 this.timestamp = timestamp;
295 setTimestampIsSet(true);
296 return this;
297 }
298
299 public void unsetTimestamp() {
300 __isset_bit_vector.clear(__TIMESTAMP_ISSET_ID);
301 }
302
303
304 public boolean isSetTimestamp() {
305 return __isset_bit_vector.get(__TIMESTAMP_ISSET_ID);
306 }
307
308 public void setTimestampIsSet(boolean value) {
309 __isset_bit_vector.set(__TIMESTAMP_ISSET_ID, value);
310 }
311
312 public void setFieldValue(_Fields field, Object value) {
313 switch (field) {
314 case FAMILY:
315 if (value == null) {
316 unsetFamily();
317 } else {
318 setFamily((ByteBuffer)value);
319 }
320 break;
321
322 case QUALIFIER:
323 if (value == null) {
324 unsetQualifier();
325 } else {
326 setQualifier((ByteBuffer)value);
327 }
328 break;
329
330 case VALUE:
331 if (value == null) {
332 unsetValue();
333 } else {
334 setValue((ByteBuffer)value);
335 }
336 break;
337
338 case TIMESTAMP:
339 if (value == null) {
340 unsetTimestamp();
341 } else {
342 setTimestamp((Long)value);
343 }
344 break;
345
346 }
347 }
348
349 public Object getFieldValue(_Fields field) {
350 switch (field) {
351 case FAMILY:
352 return getFamily();
353
354 case QUALIFIER:
355 return getQualifier();
356
357 case VALUE:
358 return getValue();
359
360 case TIMESTAMP:
361 return Long.valueOf(getTimestamp());
362
363 }
364 throw new IllegalStateException();
365 }
366
367
368 public boolean isSet(_Fields field) {
369 if (field == null) {
370 throw new IllegalArgumentException();
371 }
372
373 switch (field) {
374 case FAMILY:
375 return isSetFamily();
376 case QUALIFIER:
377 return isSetQualifier();
378 case VALUE:
379 return isSetValue();
380 case TIMESTAMP:
381 return isSetTimestamp();
382 }
383 throw new IllegalStateException();
384 }
385
386 @Override
387 public boolean equals(Object that) {
388 if (that == null)
389 return false;
390 if (that instanceof TColumnValue)
391 return this.equals((TColumnValue)that);
392 return false;
393 }
394
395 public boolean equals(TColumnValue that) {
396 if (that == null)
397 return false;
398
399 boolean this_present_family = true && this.isSetFamily();
400 boolean that_present_family = true && that.isSetFamily();
401 if (this_present_family || that_present_family) {
402 if (!(this_present_family && that_present_family))
403 return false;
404 if (!this.family.equals(that.family))
405 return false;
406 }
407
408 boolean this_present_qualifier = true && this.isSetQualifier();
409 boolean that_present_qualifier = true && that.isSetQualifier();
410 if (this_present_qualifier || that_present_qualifier) {
411 if (!(this_present_qualifier && that_present_qualifier))
412 return false;
413 if (!this.qualifier.equals(that.qualifier))
414 return false;
415 }
416
417 boolean this_present_value = true && this.isSetValue();
418 boolean that_present_value = true && that.isSetValue();
419 if (this_present_value || that_present_value) {
420 if (!(this_present_value && that_present_value))
421 return false;
422 if (!this.value.equals(that.value))
423 return false;
424 }
425
426 boolean this_present_timestamp = true && this.isSetTimestamp();
427 boolean that_present_timestamp = true && that.isSetTimestamp();
428 if (this_present_timestamp || that_present_timestamp) {
429 if (!(this_present_timestamp && that_present_timestamp))
430 return false;
431 if (this.timestamp != that.timestamp)
432 return false;
433 }
434
435 return true;
436 }
437
438 @Override
439 public int hashCode() {
440 HashCodeBuilder builder = new HashCodeBuilder();
441
442 boolean present_family = true && (isSetFamily());
443 builder.append(present_family);
444 if (present_family)
445 builder.append(family);
446
447 boolean present_qualifier = true && (isSetQualifier());
448 builder.append(present_qualifier);
449 if (present_qualifier)
450 builder.append(qualifier);
451
452 boolean present_value = true && (isSetValue());
453 builder.append(present_value);
454 if (present_value)
455 builder.append(value);
456
457 boolean present_timestamp = true && (isSetTimestamp());
458 builder.append(present_timestamp);
459 if (present_timestamp)
460 builder.append(timestamp);
461
462 return builder.toHashCode();
463 }
464
465 public int compareTo(TColumnValue other) {
466 if (!getClass().equals(other.getClass())) {
467 return getClass().getName().compareTo(other.getClass().getName());
468 }
469
470 int lastComparison = 0;
471 TColumnValue typedOther = (TColumnValue)other;
472
473 lastComparison = Boolean.valueOf(isSetFamily()).compareTo(typedOther.isSetFamily());
474 if (lastComparison != 0) {
475 return lastComparison;
476 }
477 if (isSetFamily()) {
478 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.family, typedOther.family);
479 if (lastComparison != 0) {
480 return lastComparison;
481 }
482 }
483 lastComparison = Boolean.valueOf(isSetQualifier()).compareTo(typedOther.isSetQualifier());
484 if (lastComparison != 0) {
485 return lastComparison;
486 }
487 if (isSetQualifier()) {
488 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.qualifier, typedOther.qualifier);
489 if (lastComparison != 0) {
490 return lastComparison;
491 }
492 }
493 lastComparison = Boolean.valueOf(isSetValue()).compareTo(typedOther.isSetValue());
494 if (lastComparison != 0) {
495 return lastComparison;
496 }
497 if (isSetValue()) {
498 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.value, typedOther.value);
499 if (lastComparison != 0) {
500 return lastComparison;
501 }
502 }
503 lastComparison = Boolean.valueOf(isSetTimestamp()).compareTo(typedOther.isSetTimestamp());
504 if (lastComparison != 0) {
505 return lastComparison;
506 }
507 if (isSetTimestamp()) {
508 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.timestamp, typedOther.timestamp);
509 if (lastComparison != 0) {
510 return lastComparison;
511 }
512 }
513 return 0;
514 }
515
516 public _Fields fieldForId(int fieldId) {
517 return _Fields.findByThriftId(fieldId);
518 }
519
520 public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
521 schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
522 }
523
524 public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
525 schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
526 }
527
528 @Override
529 public String toString() {
530 StringBuilder sb = new StringBuilder("TColumnValue(");
531 boolean first = true;
532
533 sb.append("family:");
534 if (this.family == null) {
535 sb.append("null");
536 } else {
537 org.apache.thrift.TBaseHelper.toString(this.family, sb);
538 }
539 first = false;
540 if (!first) sb.append(", ");
541 sb.append("qualifier:");
542 if (this.qualifier == null) {
543 sb.append("null");
544 } else {
545 org.apache.thrift.TBaseHelper.toString(this.qualifier, sb);
546 }
547 first = false;
548 if (!first) sb.append(", ");
549 sb.append("value:");
550 if (this.value == null) {
551 sb.append("null");
552 } else {
553 org.apache.thrift.TBaseHelper.toString(this.value, sb);
554 }
555 first = false;
556 if (isSetTimestamp()) {
557 if (!first) sb.append(", ");
558 sb.append("timestamp:");
559 sb.append(this.timestamp);
560 first = false;
561 }
562 sb.append(")");
563 return sb.toString();
564 }
565
566 public void validate() throws org.apache.thrift.TException {
567
568 if (family == null) {
569 throw new org.apache.thrift.protocol.TProtocolException("Required field 'family' was not present! Struct: " + toString());
570 }
571 if (qualifier == null) {
572 throw new org.apache.thrift.protocol.TProtocolException("Required field 'qualifier' was not present! Struct: " + toString());
573 }
574 if (value == null) {
575 throw new org.apache.thrift.protocol.TProtocolException("Required field 'value' was not present! Struct: " + toString());
576 }
577 }
578
579 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
580 try {
581 write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
582 } catch (org.apache.thrift.TException te) {
583 throw new java.io.IOException(te);
584 }
585 }
586
587 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
588 try {
589
590 __isset_bit_vector = new BitSet(1);
591 read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
592 } catch (org.apache.thrift.TException te) {
593 throw new java.io.IOException(te);
594 }
595 }
596
597 private static class TColumnValueStandardSchemeFactory implements SchemeFactory {
598 public TColumnValueStandardScheme getScheme() {
599 return new TColumnValueStandardScheme();
600 }
601 }
602
603 private static class TColumnValueStandardScheme extends StandardScheme<TColumnValue> {
604
605 public void read(org.apache.thrift.protocol.TProtocol iprot, TColumnValue struct) throws org.apache.thrift.TException {
606 org.apache.thrift.protocol.TField schemeField;
607 iprot.readStructBegin();
608 while (true)
609 {
610 schemeField = iprot.readFieldBegin();
611 if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
612 break;
613 }
614 switch (schemeField.id) {
615 case 1:
616 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
617 struct.family = iprot.readBinary();
618 struct.setFamilyIsSet(true);
619 } else {
620 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
621 }
622 break;
623 case 2:
624 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
625 struct.qualifier = iprot.readBinary();
626 struct.setQualifierIsSet(true);
627 } else {
628 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
629 }
630 break;
631 case 3:
632 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
633 struct.value = iprot.readBinary();
634 struct.setValueIsSet(true);
635 } else {
636 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
637 }
638 break;
639 case 4:
640 if (schemeField.type == org.apache.thrift.protocol.TType.I64) {
641 struct.timestamp = iprot.readI64();
642 struct.setTimestampIsSet(true);
643 } else {
644 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
645 }
646 break;
647 default:
648 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
649 }
650 iprot.readFieldEnd();
651 }
652 iprot.readStructEnd();
653
654
655 struct.validate();
656 }
657
658 public void write(org.apache.thrift.protocol.TProtocol oprot, TColumnValue struct) throws org.apache.thrift.TException {
659 struct.validate();
660
661 oprot.writeStructBegin(STRUCT_DESC);
662 if (struct.family != null) {
663 oprot.writeFieldBegin(FAMILY_FIELD_DESC);
664 oprot.writeBinary(struct.family);
665 oprot.writeFieldEnd();
666 }
667 if (struct.qualifier != null) {
668 oprot.writeFieldBegin(QUALIFIER_FIELD_DESC);
669 oprot.writeBinary(struct.qualifier);
670 oprot.writeFieldEnd();
671 }
672 if (struct.value != null) {
673 oprot.writeFieldBegin(VALUE_FIELD_DESC);
674 oprot.writeBinary(struct.value);
675 oprot.writeFieldEnd();
676 }
677 if (struct.isSetTimestamp()) {
678 oprot.writeFieldBegin(TIMESTAMP_FIELD_DESC);
679 oprot.writeI64(struct.timestamp);
680 oprot.writeFieldEnd();
681 }
682 oprot.writeFieldStop();
683 oprot.writeStructEnd();
684 }
685
686 }
687
688 private static class TColumnValueTupleSchemeFactory implements SchemeFactory {
689 public TColumnValueTupleScheme getScheme() {
690 return new TColumnValueTupleScheme();
691 }
692 }
693
694 private static class TColumnValueTupleScheme extends TupleScheme<TColumnValue> {
695
696 @Override
697 public void write(org.apache.thrift.protocol.TProtocol prot, TColumnValue struct) throws org.apache.thrift.TException {
698 TTupleProtocol oprot = (TTupleProtocol) prot;
699 oprot.writeBinary(struct.family);
700 oprot.writeBinary(struct.qualifier);
701 oprot.writeBinary(struct.value);
702 BitSet optionals = new BitSet();
703 if (struct.isSetTimestamp()) {
704 optionals.set(0);
705 }
706 oprot.writeBitSet(optionals, 1);
707 if (struct.isSetTimestamp()) {
708 oprot.writeI64(struct.timestamp);
709 }
710 }
711
712 @Override
713 public void read(org.apache.thrift.protocol.TProtocol prot, TColumnValue struct) throws org.apache.thrift.TException {
714 TTupleProtocol iprot = (TTupleProtocol) prot;
715 struct.family = iprot.readBinary();
716 struct.setFamilyIsSet(true);
717 struct.qualifier = iprot.readBinary();
718 struct.setQualifierIsSet(true);
719 struct.value = iprot.readBinary();
720 struct.setValueIsSet(true);
721 BitSet incoming = iprot.readBitSet(1);
722 if (incoming.get(0)) {
723 struct.timestamp = iprot.readI64();
724 struct.setTimestampIsSet(true);
725 }
726 }
727 }
728
729 }
730