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