Results.java 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. /**
  2. * Autogenerated by Thrift
  3. *
  4. * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
  5. */
  6. package com.cloudera.beeswax.api;
  7. import org.apache.commons.lang.builder.HashCodeBuilder;
  8. import java.util.List;
  9. import java.util.ArrayList;
  10. import java.util.Map;
  11. import java.util.HashMap;
  12. import java.util.Set;
  13. import java.util.HashSet;
  14. import java.util.Collections;
  15. import org.apache.log4j.Logger;
  16. import org.apache.thrift.*;
  17. import org.apache.thrift.meta_data.*;
  18. import org.apache.thrift.protocol.*;
  19. public class Results implements TBase, java.io.Serializable, Cloneable {
  20. private static final TStruct STRUCT_DESC = new TStruct("Results");
  21. private static final TField READY_FIELD_DESC = new TField("ready", TType.BOOL, (short)1);
  22. private static final TField COLUMNS_FIELD_DESC = new TField("columns", TType.LIST, (short)2);
  23. private static final TField DATA_FIELD_DESC = new TField("data", TType.LIST, (short)3);
  24. private static final TField START_ROW_FIELD_DESC = new TField("start_row", TType.I64, (short)4);
  25. private static final TField HAS_MORE_FIELD_DESC = new TField("has_more", TType.BOOL, (short)5);
  26. public boolean ready;
  27. public static final int READY = 1;
  28. public List<String> columns;
  29. public static final int COLUMNS = 2;
  30. public List<String> data;
  31. public static final int DATA = 3;
  32. public long start_row;
  33. public static final int START_ROW = 4;
  34. public boolean has_more;
  35. public static final int HAS_MORE = 5;
  36. private final Isset __isset = new Isset();
  37. private static final class Isset implements java.io.Serializable {
  38. public boolean ready = false;
  39. public boolean start_row = false;
  40. public boolean has_more = false;
  41. }
  42. public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
  43. put(READY, new FieldMetaData("ready", TFieldRequirementType.DEFAULT,
  44. new FieldValueMetaData(TType.BOOL)));
  45. put(COLUMNS, new FieldMetaData("columns", TFieldRequirementType.DEFAULT,
  46. new ListMetaData(TType.LIST,
  47. new FieldValueMetaData(TType.STRING))));
  48. put(DATA, new FieldMetaData("data", TFieldRequirementType.DEFAULT,
  49. new ListMetaData(TType.LIST,
  50. new FieldValueMetaData(TType.STRING))));
  51. put(START_ROW, new FieldMetaData("start_row", TFieldRequirementType.DEFAULT,
  52. new FieldValueMetaData(TType.I64)));
  53. put(HAS_MORE, new FieldMetaData("has_more", TFieldRequirementType.DEFAULT,
  54. new FieldValueMetaData(TType.BOOL)));
  55. }});
  56. static {
  57. FieldMetaData.addStructMetaDataMap(Results.class, metaDataMap);
  58. }
  59. public Results() {
  60. }
  61. public Results(
  62. boolean ready,
  63. List<String> columns,
  64. List<String> data,
  65. long start_row,
  66. boolean has_more)
  67. {
  68. this();
  69. this.ready = ready;
  70. this.__isset.ready = true;
  71. this.columns = columns;
  72. this.data = data;
  73. this.start_row = start_row;
  74. this.__isset.start_row = true;
  75. this.has_more = has_more;
  76. this.__isset.has_more = true;
  77. }
  78. /**
  79. * Performs a deep copy on <i>other</i>.
  80. */
  81. public Results(Results other) {
  82. __isset.ready = other.__isset.ready;
  83. this.ready = other.ready;
  84. if (other.isSetColumns()) {
  85. List<String> __this__columns = new ArrayList<String>();
  86. for (String other_element : other.columns) {
  87. __this__columns.add(other_element);
  88. }
  89. this.columns = __this__columns;
  90. }
  91. if (other.isSetData()) {
  92. List<String> __this__data = new ArrayList<String>();
  93. for (String other_element : other.data) {
  94. __this__data.add(other_element);
  95. }
  96. this.data = __this__data;
  97. }
  98. __isset.start_row = other.__isset.start_row;
  99. this.start_row = other.start_row;
  100. __isset.has_more = other.__isset.has_more;
  101. this.has_more = other.has_more;
  102. }
  103. @Override
  104. public Results clone() {
  105. return new Results(this);
  106. }
  107. public boolean isReady() {
  108. return this.ready;
  109. }
  110. public void setReady(boolean ready) {
  111. this.ready = ready;
  112. this.__isset.ready = true;
  113. }
  114. public void unsetReady() {
  115. this.__isset.ready = false;
  116. }
  117. // Returns true if field ready is set (has been asigned a value) and false otherwise
  118. public boolean isSetReady() {
  119. return this.__isset.ready;
  120. }
  121. public void setReadyIsSet(boolean value) {
  122. this.__isset.ready = value;
  123. }
  124. public int getColumnsSize() {
  125. return (this.columns == null) ? 0 : this.columns.size();
  126. }
  127. public java.util.Iterator<String> getColumnsIterator() {
  128. return (this.columns == null) ? null : this.columns.iterator();
  129. }
  130. public void addToColumns(String elem) {
  131. if (this.columns == null) {
  132. this.columns = new ArrayList<String>();
  133. }
  134. this.columns.add(elem);
  135. }
  136. public List<String> getColumns() {
  137. return this.columns;
  138. }
  139. public void setColumns(List<String> columns) {
  140. this.columns = columns;
  141. }
  142. public void unsetColumns() {
  143. this.columns = null;
  144. }
  145. // Returns true if field columns is set (has been asigned a value) and false otherwise
  146. public boolean isSetColumns() {
  147. return this.columns != null;
  148. }
  149. public void setColumnsIsSet(boolean value) {
  150. if (!value) {
  151. this.columns = null;
  152. }
  153. }
  154. public int getDataSize() {
  155. return (this.data == null) ? 0 : this.data.size();
  156. }
  157. public java.util.Iterator<String> getDataIterator() {
  158. return (this.data == null) ? null : this.data.iterator();
  159. }
  160. public void addToData(String elem) {
  161. if (this.data == null) {
  162. this.data = new ArrayList<String>();
  163. }
  164. this.data.add(elem);
  165. }
  166. public List<String> getData() {
  167. return this.data;
  168. }
  169. public void setData(List<String> data) {
  170. this.data = data;
  171. }
  172. public void unsetData() {
  173. this.data = null;
  174. }
  175. // Returns true if field data is set (has been asigned a value) and false otherwise
  176. public boolean isSetData() {
  177. return this.data != null;
  178. }
  179. public void setDataIsSet(boolean value) {
  180. if (!value) {
  181. this.data = null;
  182. }
  183. }
  184. public long getStart_row() {
  185. return this.start_row;
  186. }
  187. public void setStart_row(long start_row) {
  188. this.start_row = start_row;
  189. this.__isset.start_row = true;
  190. }
  191. public void unsetStart_row() {
  192. this.__isset.start_row = false;
  193. }
  194. // Returns true if field start_row is set (has been asigned a value) and false otherwise
  195. public boolean isSetStart_row() {
  196. return this.__isset.start_row;
  197. }
  198. public void setStart_rowIsSet(boolean value) {
  199. this.__isset.start_row = value;
  200. }
  201. public boolean isHas_more() {
  202. return this.has_more;
  203. }
  204. public void setHas_more(boolean has_more) {
  205. this.has_more = has_more;
  206. this.__isset.has_more = true;
  207. }
  208. public void unsetHas_more() {
  209. this.__isset.has_more = false;
  210. }
  211. // Returns true if field has_more is set (has been asigned a value) and false otherwise
  212. public boolean isSetHas_more() {
  213. return this.__isset.has_more;
  214. }
  215. public void setHas_moreIsSet(boolean value) {
  216. this.__isset.has_more = value;
  217. }
  218. public void setFieldValue(int fieldID, Object value) {
  219. switch (fieldID) {
  220. case READY:
  221. if (value == null) {
  222. unsetReady();
  223. } else {
  224. setReady((Boolean)value);
  225. }
  226. break;
  227. case COLUMNS:
  228. if (value == null) {
  229. unsetColumns();
  230. } else {
  231. setColumns((List<String>)value);
  232. }
  233. break;
  234. case DATA:
  235. if (value == null) {
  236. unsetData();
  237. } else {
  238. setData((List<String>)value);
  239. }
  240. break;
  241. case START_ROW:
  242. if (value == null) {
  243. unsetStart_row();
  244. } else {
  245. setStart_row((Long)value);
  246. }
  247. break;
  248. case HAS_MORE:
  249. if (value == null) {
  250. unsetHas_more();
  251. } else {
  252. setHas_more((Boolean)value);
  253. }
  254. break;
  255. default:
  256. throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
  257. }
  258. }
  259. public Object getFieldValue(int fieldID) {
  260. switch (fieldID) {
  261. case READY:
  262. return new Boolean(isReady());
  263. case COLUMNS:
  264. return getColumns();
  265. case DATA:
  266. return getData();
  267. case START_ROW:
  268. return new Long(getStart_row());
  269. case HAS_MORE:
  270. return new Boolean(isHas_more());
  271. default:
  272. throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
  273. }
  274. }
  275. // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
  276. public boolean isSet(int fieldID) {
  277. switch (fieldID) {
  278. case READY:
  279. return isSetReady();
  280. case COLUMNS:
  281. return isSetColumns();
  282. case DATA:
  283. return isSetData();
  284. case START_ROW:
  285. return isSetStart_row();
  286. case HAS_MORE:
  287. return isSetHas_more();
  288. default:
  289. throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
  290. }
  291. }
  292. @Override
  293. public boolean equals(Object that) {
  294. if (that == null)
  295. return false;
  296. if (that instanceof Results)
  297. return this.equals((Results)that);
  298. return false;
  299. }
  300. public boolean equals(Results that) {
  301. if (that == null)
  302. return false;
  303. boolean this_present_ready = true;
  304. boolean that_present_ready = true;
  305. if (this_present_ready || that_present_ready) {
  306. if (!(this_present_ready && that_present_ready))
  307. return false;
  308. if (this.ready != that.ready)
  309. return false;
  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. boolean this_present_data = true && this.isSetData();
  320. boolean that_present_data = true && that.isSetData();
  321. if (this_present_data || that_present_data) {
  322. if (!(this_present_data && that_present_data))
  323. return false;
  324. if (!this.data.equals(that.data))
  325. return false;
  326. }
  327. boolean this_present_start_row = true;
  328. boolean that_present_start_row = true;
  329. if (this_present_start_row || that_present_start_row) {
  330. if (!(this_present_start_row && that_present_start_row))
  331. return false;
  332. if (this.start_row != that.start_row)
  333. return false;
  334. }
  335. boolean this_present_has_more = true;
  336. boolean that_present_has_more = true;
  337. if (this_present_has_more || that_present_has_more) {
  338. if (!(this_present_has_more && that_present_has_more))
  339. return false;
  340. if (this.has_more != that.has_more)
  341. return false;
  342. }
  343. return true;
  344. }
  345. @Override
  346. public int hashCode() {
  347. HashCodeBuilder builder = new HashCodeBuilder();
  348. boolean present_ready = true;
  349. builder.append(present_ready);
  350. if (present_ready)
  351. builder.append(ready);
  352. boolean present_columns = true && (isSetColumns());
  353. builder.append(present_columns);
  354. if (present_columns)
  355. builder.append(columns);
  356. boolean present_data = true && (isSetData());
  357. builder.append(present_data);
  358. if (present_data)
  359. builder.append(data);
  360. boolean present_start_row = true;
  361. builder.append(present_start_row);
  362. if (present_start_row)
  363. builder.append(start_row);
  364. boolean present_has_more = true;
  365. builder.append(present_has_more);
  366. if (present_has_more)
  367. builder.append(has_more);
  368. return builder.toHashCode();
  369. }
  370. public void read(TProtocol iprot) throws TException {
  371. TField field;
  372. iprot.readStructBegin();
  373. while (true)
  374. {
  375. field = iprot.readFieldBegin();
  376. if (field.type == TType.STOP) {
  377. break;
  378. }
  379. switch (field.id)
  380. {
  381. case READY:
  382. if (field.type == TType.BOOL) {
  383. this.ready = iprot.readBool();
  384. this.__isset.ready = true;
  385. } else {
  386. TProtocolUtil.skip(iprot, field.type);
  387. }
  388. break;
  389. case COLUMNS:
  390. if (field.type == TType.LIST) {
  391. {
  392. TList _list8 = iprot.readListBegin();
  393. this.columns = new ArrayList<String>(_list8.size);
  394. for (int _i9 = 0; _i9 < _list8.size; ++_i9)
  395. {
  396. String _elem10;
  397. _elem10 = iprot.readString();
  398. this.columns.add(_elem10);
  399. }
  400. iprot.readListEnd();
  401. }
  402. } else {
  403. TProtocolUtil.skip(iprot, field.type);
  404. }
  405. break;
  406. case DATA:
  407. if (field.type == TType.LIST) {
  408. {
  409. TList _list11 = iprot.readListBegin();
  410. this.data = new ArrayList<String>(_list11.size);
  411. for (int _i12 = 0; _i12 < _list11.size; ++_i12)
  412. {
  413. String _elem13;
  414. _elem13 = iprot.readString();
  415. this.data.add(_elem13);
  416. }
  417. iprot.readListEnd();
  418. }
  419. } else {
  420. TProtocolUtil.skip(iprot, field.type);
  421. }
  422. break;
  423. case START_ROW:
  424. if (field.type == TType.I64) {
  425. this.start_row = iprot.readI64();
  426. this.__isset.start_row = true;
  427. } else {
  428. TProtocolUtil.skip(iprot, field.type);
  429. }
  430. break;
  431. case HAS_MORE:
  432. if (field.type == TType.BOOL) {
  433. this.has_more = iprot.readBool();
  434. this.__isset.has_more = true;
  435. } else {
  436. TProtocolUtil.skip(iprot, field.type);
  437. }
  438. break;
  439. default:
  440. TProtocolUtil.skip(iprot, field.type);
  441. break;
  442. }
  443. iprot.readFieldEnd();
  444. }
  445. iprot.readStructEnd();
  446. // check for required fields of primitive type, which can't be checked in the validate method
  447. validate();
  448. }
  449. public void write(TProtocol oprot) throws TException {
  450. validate();
  451. oprot.writeStructBegin(STRUCT_DESC);
  452. oprot.writeFieldBegin(READY_FIELD_DESC);
  453. oprot.writeBool(this.ready);
  454. oprot.writeFieldEnd();
  455. if (this.columns != null) {
  456. oprot.writeFieldBegin(COLUMNS_FIELD_DESC);
  457. {
  458. oprot.writeListBegin(new TList(TType.STRING, this.columns.size()));
  459. for (String _iter14 : this.columns) {
  460. oprot.writeString(_iter14);
  461. }
  462. oprot.writeListEnd();
  463. }
  464. oprot.writeFieldEnd();
  465. }
  466. if (this.data != null) {
  467. oprot.writeFieldBegin(DATA_FIELD_DESC);
  468. {
  469. oprot.writeListBegin(new TList(TType.STRING, this.data.size()));
  470. for (String _iter15 : this.data) {
  471. oprot.writeString(_iter15);
  472. }
  473. oprot.writeListEnd();
  474. }
  475. oprot.writeFieldEnd();
  476. }
  477. oprot.writeFieldBegin(START_ROW_FIELD_DESC);
  478. oprot.writeI64(this.start_row);
  479. oprot.writeFieldEnd();
  480. oprot.writeFieldBegin(HAS_MORE_FIELD_DESC);
  481. oprot.writeBool(this.has_more);
  482. oprot.writeFieldEnd();
  483. oprot.writeFieldStop();
  484. oprot.writeStructEnd();
  485. }
  486. @Override
  487. public String toString() {
  488. StringBuilder sb = new StringBuilder("Results(");
  489. boolean first = true;
  490. sb.append("ready:");
  491. sb.append(this.ready);
  492. first = false;
  493. if (!first) sb.append(", ");
  494. sb.append("columns:");
  495. if (this.columns == null) {
  496. sb.append("null");
  497. } else {
  498. sb.append(this.columns);
  499. }
  500. first = false;
  501. if (!first) sb.append(", ");
  502. sb.append("data:");
  503. if (this.data == null) {
  504. sb.append("null");
  505. } else {
  506. sb.append(this.data);
  507. }
  508. first = false;
  509. if (!first) sb.append(", ");
  510. sb.append("start_row:");
  511. sb.append(this.start_row);
  512. first = false;
  513. if (!first) sb.append(", ");
  514. sb.append("has_more:");
  515. sb.append(this.has_more);
  516. first = false;
  517. sb.append(")");
  518. return sb.toString();
  519. }
  520. public void validate() throws TException {
  521. // check for required fields
  522. // check that fields of type enum have valid values
  523. }
  524. }