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 BatchMutation implements org.apache.thrift.TBase<BatchMutation, BatchMutation._Fields>, java.io.Serializable, Cloneable {
35 private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("BatchMutation");
36
37 private static final org.apache.thrift.protocol.TField ROW_FIELD_DESC = new org.apache.thrift.protocol.TField("row", org.apache.thrift.protocol.TType.STRING, (short)1);
38 private static final org.apache.thrift.protocol.TField MUTATIONS_FIELD_DESC = new org.apache.thrift.protocol.TField("mutations", org.apache.thrift.protocol.TType.LIST, (short)2);
39
40 private static final Map<Class<? extends IScheme>, SchemeFactory> schemes = new HashMap<Class<? extends IScheme>, SchemeFactory>();
41 static {
42 schemes.put(StandardScheme.class, new BatchMutationStandardSchemeFactory());
43 schemes.put(TupleScheme.class, new BatchMutationTupleSchemeFactory());
44 }
45
46 public ByteBuffer row;
47 public List<Mutation> mutations;
48
49
50 public enum _Fields implements org.apache.thrift.TFieldIdEnum {
51 ROW((short)1, "row"),
52 MUTATIONS((short)2, "mutations");
53
54 private static final Map<String, _Fields> byName = new HashMap<String, _Fields>();
55
56 static {
57 for (_Fields field : EnumSet.allOf(_Fields.class)) {
58 byName.put(field.getFieldName(), field);
59 }
60 }
61
62
63
64
65 public static _Fields findByThriftId(int fieldId) {
66 switch(fieldId) {
67 case 1:
68 return ROW;
69 case 2:
70 return MUTATIONS;
71 default:
72 return null;
73 }
74 }
75
76
77
78
79
80 public static _Fields findByThriftIdOrThrow(int fieldId) {
81 _Fields fields = findByThriftId(fieldId);
82 if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!");
83 return fields;
84 }
85
86
87
88
89 public static _Fields findByName(String name) {
90 return byName.get(name);
91 }
92
93 private final short _thriftId;
94 private final String _fieldName;
95
96 _Fields(short thriftId, String fieldName) {
97 _thriftId = thriftId;
98 _fieldName = fieldName;
99 }
100
101 public short getThriftFieldId() {
102 return _thriftId;
103 }
104
105 public String getFieldName() {
106 return _fieldName;
107 }
108 }
109
110
111 public static final Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap;
112 static {
113 Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class);
114 tmpMap.put(_Fields.ROW, new org.apache.thrift.meta_data.FieldMetaData("row", org.apache.thrift.TFieldRequirementType.DEFAULT,
115 new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING , "Text")));
116 tmpMap.put(_Fields.MUTATIONS, new org.apache.thrift.meta_data.FieldMetaData("mutations", org.apache.thrift.TFieldRequirementType.DEFAULT,
117 new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST,
118 new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, Mutation.class))));
119 metaDataMap = Collections.unmodifiableMap(tmpMap);
120 org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(BatchMutation.class, metaDataMap);
121 }
122
123 public BatchMutation() {
124 }
125
126 public BatchMutation(
127 ByteBuffer row,
128 List<Mutation> mutations)
129 {
130 this();
131 this.row = row;
132 this.mutations = mutations;
133 }
134
135
136
137
138 public BatchMutation(BatchMutation other) {
139 if (other.isSetRow()) {
140 this.row = other.row;
141 }
142 if (other.isSetMutations()) {
143 List<Mutation> __this__mutations = new ArrayList<Mutation>();
144 for (Mutation other_element : other.mutations) {
145 __this__mutations.add(new Mutation(other_element));
146 }
147 this.mutations = __this__mutations;
148 }
149 }
150
151 public BatchMutation deepCopy() {
152 return new BatchMutation(this);
153 }
154
155 @Override
156 public void clear() {
157 this.row = null;
158 this.mutations = null;
159 }
160
161 public byte[] getRow() {
162 setRow(org.apache.thrift.TBaseHelper.rightSize(row));
163 return row == null ? null : row.array();
164 }
165
166 public ByteBuffer bufferForRow() {
167 return row;
168 }
169
170 public BatchMutation setRow(byte[] row) {
171 setRow(row == null ? (ByteBuffer)null : ByteBuffer.wrap(row));
172 return this;
173 }
174
175 public BatchMutation setRow(ByteBuffer row) {
176 this.row = row;
177 return this;
178 }
179
180 public void unsetRow() {
181 this.row = null;
182 }
183
184
185 public boolean isSetRow() {
186 return this.row != null;
187 }
188
189 public void setRowIsSet(boolean value) {
190 if (!value) {
191 this.row = null;
192 }
193 }
194
195 public int getMutationsSize() {
196 return (this.mutations == null) ? 0 : this.mutations.size();
197 }
198
199 public java.util.Iterator<Mutation> getMutationsIterator() {
200 return (this.mutations == null) ? null : this.mutations.iterator();
201 }
202
203 public void addToMutations(Mutation elem) {
204 if (this.mutations == null) {
205 this.mutations = new ArrayList<Mutation>();
206 }
207 this.mutations.add(elem);
208 }
209
210 public List<Mutation> getMutations() {
211 return this.mutations;
212 }
213
214 public BatchMutation setMutations(List<Mutation> mutations) {
215 this.mutations = mutations;
216 return this;
217 }
218
219 public void unsetMutations() {
220 this.mutations = null;
221 }
222
223
224 public boolean isSetMutations() {
225 return this.mutations != null;
226 }
227
228 public void setMutationsIsSet(boolean value) {
229 if (!value) {
230 this.mutations = null;
231 }
232 }
233
234 public void setFieldValue(_Fields field, Object value) {
235 switch (field) {
236 case ROW:
237 if (value == null) {
238 unsetRow();
239 } else {
240 setRow((ByteBuffer)value);
241 }
242 break;
243
244 case MUTATIONS:
245 if (value == null) {
246 unsetMutations();
247 } else {
248 setMutations((List<Mutation>)value);
249 }
250 break;
251
252 }
253 }
254
255 public Object getFieldValue(_Fields field) {
256 switch (field) {
257 case ROW:
258 return getRow();
259
260 case MUTATIONS:
261 return getMutations();
262
263 }
264 throw new IllegalStateException();
265 }
266
267
268 public boolean isSet(_Fields field) {
269 if (field == null) {
270 throw new IllegalArgumentException();
271 }
272
273 switch (field) {
274 case ROW:
275 return isSetRow();
276 case MUTATIONS:
277 return isSetMutations();
278 }
279 throw new IllegalStateException();
280 }
281
282 @Override
283 public boolean equals(Object that) {
284 if (that == null)
285 return false;
286 if (that instanceof BatchMutation)
287 return this.equals((BatchMutation)that);
288 return false;
289 }
290
291 public boolean equals(BatchMutation that) {
292 if (that == null)
293 return false;
294
295 boolean this_present_row = true && this.isSetRow();
296 boolean that_present_row = true && that.isSetRow();
297 if (this_present_row || that_present_row) {
298 if (!(this_present_row && that_present_row))
299 return false;
300 if (!this.row.equals(that.row))
301 return false;
302 }
303
304 boolean this_present_mutations = true && this.isSetMutations();
305 boolean that_present_mutations = true && that.isSetMutations();
306 if (this_present_mutations || that_present_mutations) {
307 if (!(this_present_mutations && that_present_mutations))
308 return false;
309 if (!this.mutations.equals(that.mutations))
310 return false;
311 }
312
313 return true;
314 }
315
316 @Override
317 public int hashCode() {
318 HashCodeBuilder builder = new HashCodeBuilder();
319
320 boolean present_row = true && (isSetRow());
321 builder.append(present_row);
322 if (present_row)
323 builder.append(row);
324
325 boolean present_mutations = true && (isSetMutations());
326 builder.append(present_mutations);
327 if (present_mutations)
328 builder.append(mutations);
329
330 return builder.toHashCode();
331 }
332
333 public int compareTo(BatchMutation other) {
334 if (!getClass().equals(other.getClass())) {
335 return getClass().getName().compareTo(other.getClass().getName());
336 }
337
338 int lastComparison = 0;
339 BatchMutation typedOther = (BatchMutation)other;
340
341 lastComparison = Boolean.valueOf(isSetRow()).compareTo(typedOther.isSetRow());
342 if (lastComparison != 0) {
343 return lastComparison;
344 }
345 if (isSetRow()) {
346 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.row, typedOther.row);
347 if (lastComparison != 0) {
348 return lastComparison;
349 }
350 }
351 lastComparison = Boolean.valueOf(isSetMutations()).compareTo(typedOther.isSetMutations());
352 if (lastComparison != 0) {
353 return lastComparison;
354 }
355 if (isSetMutations()) {
356 lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.mutations, typedOther.mutations);
357 if (lastComparison != 0) {
358 return lastComparison;
359 }
360 }
361 return 0;
362 }
363
364 public _Fields fieldForId(int fieldId) {
365 return _Fields.findByThriftId(fieldId);
366 }
367
368 public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException {
369 schemes.get(iprot.getScheme()).getScheme().read(iprot, this);
370 }
371
372 public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException {
373 schemes.get(oprot.getScheme()).getScheme().write(oprot, this);
374 }
375
376 @Override
377 public String toString() {
378 StringBuilder sb = new StringBuilder("BatchMutation(");
379 boolean first = true;
380
381 sb.append("row:");
382 if (this.row == null) {
383 sb.append("null");
384 } else {
385 sb.append(this.row);
386 }
387 first = false;
388 if (!first) sb.append(", ");
389 sb.append("mutations:");
390 if (this.mutations == null) {
391 sb.append("null");
392 } else {
393 sb.append(this.mutations);
394 }
395 first = false;
396 sb.append(")");
397 return sb.toString();
398 }
399
400 public void validate() throws org.apache.thrift.TException {
401
402 }
403
404 private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException {
405 try {
406 write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out)));
407 } catch (org.apache.thrift.TException te) {
408 throw new java.io.IOException(te);
409 }
410 }
411
412 private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException {
413 try {
414 read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in)));
415 } catch (org.apache.thrift.TException te) {
416 throw new java.io.IOException(te);
417 }
418 }
419
420 private static class BatchMutationStandardSchemeFactory implements SchemeFactory {
421 public BatchMutationStandardScheme getScheme() {
422 return new BatchMutationStandardScheme();
423 }
424 }
425
426 private static class BatchMutationStandardScheme extends StandardScheme<BatchMutation> {
427
428 public void read(org.apache.thrift.protocol.TProtocol iprot, BatchMutation struct) throws org.apache.thrift.TException {
429 org.apache.thrift.protocol.TField schemeField;
430 iprot.readStructBegin();
431 while (true)
432 {
433 schemeField = iprot.readFieldBegin();
434 if (schemeField.type == org.apache.thrift.protocol.TType.STOP) {
435 break;
436 }
437 switch (schemeField.id) {
438 case 1:
439 if (schemeField.type == org.apache.thrift.protocol.TType.STRING) {
440 struct.row = iprot.readBinary();
441 struct.setRowIsSet(true);
442 } else {
443 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
444 }
445 break;
446 case 2:
447 if (schemeField.type == org.apache.thrift.protocol.TType.LIST) {
448 {
449 org.apache.thrift.protocol.TList _list0 = iprot.readListBegin();
450 struct.mutations = new ArrayList<Mutation>(_list0.size);
451 for (int _i1 = 0; _i1 < _list0.size; ++_i1)
452 {
453 Mutation _elem2;
454 _elem2 = new Mutation();
455 _elem2.read(iprot);
456 struct.mutations.add(_elem2);
457 }
458 iprot.readListEnd();
459 }
460 struct.setMutationsIsSet(true);
461 } else {
462 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
463 }
464 break;
465 default:
466 org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type);
467 }
468 iprot.readFieldEnd();
469 }
470 iprot.readStructEnd();
471
472
473 struct.validate();
474 }
475
476 public void write(org.apache.thrift.protocol.TProtocol oprot, BatchMutation struct) throws org.apache.thrift.TException {
477 struct.validate();
478
479 oprot.writeStructBegin(STRUCT_DESC);
480 if (struct.row != null) {
481 oprot.writeFieldBegin(ROW_FIELD_DESC);
482 oprot.writeBinary(struct.row);
483 oprot.writeFieldEnd();
484 }
485 if (struct.mutations != null) {
486 oprot.writeFieldBegin(MUTATIONS_FIELD_DESC);
487 {
488 oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, struct.mutations.size()));
489 for (Mutation _iter3 : struct.mutations)
490 {
491 _iter3.write(oprot);
492 }
493 oprot.writeListEnd();
494 }
495 oprot.writeFieldEnd();
496 }
497 oprot.writeFieldStop();
498 oprot.writeStructEnd();
499 }
500
501 }
502
503 private static class BatchMutationTupleSchemeFactory implements SchemeFactory {
504 public BatchMutationTupleScheme getScheme() {
505 return new BatchMutationTupleScheme();
506 }
507 }
508
509 private static class BatchMutationTupleScheme extends TupleScheme<BatchMutation> {
510
511 @Override
512 public void write(org.apache.thrift.protocol.TProtocol prot, BatchMutation struct) throws org.apache.thrift.TException {
513 TTupleProtocol oprot = (TTupleProtocol) prot;
514 BitSet optionals = new BitSet();
515 if (struct.isSetRow()) {
516 optionals.set(0);
517 }
518 if (struct.isSetMutations()) {
519 optionals.set(1);
520 }
521 oprot.writeBitSet(optionals, 2);
522 if (struct.isSetRow()) {
523 oprot.writeBinary(struct.row);
524 }
525 if (struct.isSetMutations()) {
526 {
527 oprot.writeI32(struct.mutations.size());
528 for (Mutation _iter4 : struct.mutations)
529 {
530 _iter4.write(oprot);
531 }
532 }
533 }
534 }
535
536 @Override
537 public void read(org.apache.thrift.protocol.TProtocol prot, BatchMutation struct) throws org.apache.thrift.TException {
538 TTupleProtocol iprot = (TTupleProtocol) prot;
539 BitSet incoming = iprot.readBitSet(2);
540 if (incoming.get(0)) {
541 struct.row = iprot.readBinary();
542 struct.setRowIsSet(true);
543 }
544 if (incoming.get(1)) {
545 {
546 org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.STRUCT, iprot.readI32());
547 struct.mutations = new ArrayList<Mutation>(_list5.size);
548 for (int _i6 = 0; _i6 < _list5.size; ++_i6)
549 {
550 Mutation _elem7;
551 _elem7 = new Mutation();
552 _elem7.read(iprot);
553 struct.mutations.add(_elem7);
554 }
555 }
556 struct.setMutationsIsSet(true);
557 }
558 }
559 }
560
561 }
562