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