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