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