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