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