ResultsMetadata.java 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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. /**
  20. * Metadata information about the results.
  21. * Applicable only for SELECT.
  22. */
  23. public class ResultsMetadata implements TBase, java.io.Serializable, Cloneable {
  24. private static final TStruct STRUCT_DESC = new TStruct("ResultsMetadata");
  25. private static final TField SCHEMA_FIELD_DESC = new TField("schema", TType.STRUCT, (short)1);
  26. private static final TField TABLE_DIR_FIELD_DESC = new TField("table_dir", TType.STRING, (short)2);
  27. private static final TField IN_TABLENAME_FIELD_DESC = new TField("in_tablename", TType.STRING, (short)3);
  28. private static final TField DELIM_FIELD_DESC = new TField("delim", TType.STRING, (short)4);
  29. /**
  30. * The schema of the results
  31. */
  32. public org.apache.hadoop.hive.metastore.api.Schema schema;
  33. public static final int SCHEMA = 1;
  34. /**
  35. * The directory containing the results. Not applicable for partition table.
  36. */
  37. public String table_dir;
  38. public static final int TABLE_DIR = 2;
  39. /**
  40. * If the results are straight from an existing table, the table name.
  41. */
  42. public String in_tablename;
  43. public static final int IN_TABLENAME = 3;
  44. /**
  45. * Field delimiter
  46. */
  47. public String delim;
  48. public static final int DELIM = 4;
  49. private final Isset __isset = new Isset();
  50. private static final class Isset implements java.io.Serializable {
  51. }
  52. public static final Map<Integer, FieldMetaData> metaDataMap = Collections.unmodifiableMap(new HashMap<Integer, FieldMetaData>() {{
  53. put(SCHEMA, new FieldMetaData("schema", TFieldRequirementType.DEFAULT,
  54. new StructMetaData(TType.STRUCT, org.apache.hadoop.hive.metastore.api.Schema.class)));
  55. put(TABLE_DIR, new FieldMetaData("table_dir", TFieldRequirementType.DEFAULT,
  56. new FieldValueMetaData(TType.STRING)));
  57. put(IN_TABLENAME, new FieldMetaData("in_tablename", TFieldRequirementType.DEFAULT,
  58. new FieldValueMetaData(TType.STRING)));
  59. put(DELIM, new FieldMetaData("delim", TFieldRequirementType.DEFAULT,
  60. new FieldValueMetaData(TType.STRING)));
  61. }});
  62. static {
  63. FieldMetaData.addStructMetaDataMap(ResultsMetadata.class, metaDataMap);
  64. }
  65. public ResultsMetadata() {
  66. }
  67. public ResultsMetadata(
  68. org.apache.hadoop.hive.metastore.api.Schema schema,
  69. String table_dir,
  70. String in_tablename,
  71. String delim)
  72. {
  73. this();
  74. this.schema = schema;
  75. this.table_dir = table_dir;
  76. this.in_tablename = in_tablename;
  77. this.delim = delim;
  78. }
  79. /**
  80. * Performs a deep copy on <i>other</i>.
  81. */
  82. public ResultsMetadata(ResultsMetadata other) {
  83. if (other.isSetSchema()) {
  84. this.schema = new org.apache.hadoop.hive.metastore.api.Schema(other.schema);
  85. }
  86. if (other.isSetTable_dir()) {
  87. this.table_dir = other.table_dir;
  88. }
  89. if (other.isSetIn_tablename()) {
  90. this.in_tablename = other.in_tablename;
  91. }
  92. if (other.isSetDelim()) {
  93. this.delim = other.delim;
  94. }
  95. }
  96. @Override
  97. public ResultsMetadata clone() {
  98. return new ResultsMetadata(this);
  99. }
  100. /**
  101. * The schema of the results
  102. */
  103. public org.apache.hadoop.hive.metastore.api.Schema getSchema() {
  104. return this.schema;
  105. }
  106. /**
  107. * The schema of the results
  108. */
  109. public void setSchema(org.apache.hadoop.hive.metastore.api.Schema schema) {
  110. this.schema = schema;
  111. }
  112. public void unsetSchema() {
  113. this.schema = null;
  114. }
  115. // Returns true if field schema is set (has been asigned a value) and false otherwise
  116. public boolean isSetSchema() {
  117. return this.schema != null;
  118. }
  119. public void setSchemaIsSet(boolean value) {
  120. if (!value) {
  121. this.schema = null;
  122. }
  123. }
  124. /**
  125. * The directory containing the results. Not applicable for partition table.
  126. */
  127. public String getTable_dir() {
  128. return this.table_dir;
  129. }
  130. /**
  131. * The directory containing the results. Not applicable for partition table.
  132. */
  133. public void setTable_dir(String table_dir) {
  134. this.table_dir = table_dir;
  135. }
  136. public void unsetTable_dir() {
  137. this.table_dir = null;
  138. }
  139. // Returns true if field table_dir is set (has been asigned a value) and false otherwise
  140. public boolean isSetTable_dir() {
  141. return this.table_dir != null;
  142. }
  143. public void setTable_dirIsSet(boolean value) {
  144. if (!value) {
  145. this.table_dir = null;
  146. }
  147. }
  148. /**
  149. * If the results are straight from an existing table, the table name.
  150. */
  151. public String getIn_tablename() {
  152. return this.in_tablename;
  153. }
  154. /**
  155. * If the results are straight from an existing table, the table name.
  156. */
  157. public void setIn_tablename(String in_tablename) {
  158. this.in_tablename = in_tablename;
  159. }
  160. public void unsetIn_tablename() {
  161. this.in_tablename = null;
  162. }
  163. // Returns true if field in_tablename is set (has been asigned a value) and false otherwise
  164. public boolean isSetIn_tablename() {
  165. return this.in_tablename != null;
  166. }
  167. public void setIn_tablenameIsSet(boolean value) {
  168. if (!value) {
  169. this.in_tablename = null;
  170. }
  171. }
  172. /**
  173. * Field delimiter
  174. */
  175. public String getDelim() {
  176. return this.delim;
  177. }
  178. /**
  179. * Field delimiter
  180. */
  181. public void setDelim(String delim) {
  182. this.delim = delim;
  183. }
  184. public void unsetDelim() {
  185. this.delim = null;
  186. }
  187. // Returns true if field delim is set (has been asigned a value) and false otherwise
  188. public boolean isSetDelim() {
  189. return this.delim != null;
  190. }
  191. public void setDelimIsSet(boolean value) {
  192. if (!value) {
  193. this.delim = null;
  194. }
  195. }
  196. public void setFieldValue(int fieldID, Object value) {
  197. switch (fieldID) {
  198. case SCHEMA:
  199. if (value == null) {
  200. unsetSchema();
  201. } else {
  202. setSchema((org.apache.hadoop.hive.metastore.api.Schema)value);
  203. }
  204. break;
  205. case TABLE_DIR:
  206. if (value == null) {
  207. unsetTable_dir();
  208. } else {
  209. setTable_dir((String)value);
  210. }
  211. break;
  212. case IN_TABLENAME:
  213. if (value == null) {
  214. unsetIn_tablename();
  215. } else {
  216. setIn_tablename((String)value);
  217. }
  218. break;
  219. case DELIM:
  220. if (value == null) {
  221. unsetDelim();
  222. } else {
  223. setDelim((String)value);
  224. }
  225. break;
  226. default:
  227. throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
  228. }
  229. }
  230. public Object getFieldValue(int fieldID) {
  231. switch (fieldID) {
  232. case SCHEMA:
  233. return getSchema();
  234. case TABLE_DIR:
  235. return getTable_dir();
  236. case IN_TABLENAME:
  237. return getIn_tablename();
  238. case DELIM:
  239. return getDelim();
  240. default:
  241. throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
  242. }
  243. }
  244. // Returns true if field corresponding to fieldID is set (has been asigned a value) and false otherwise
  245. public boolean isSet(int fieldID) {
  246. switch (fieldID) {
  247. case SCHEMA:
  248. return isSetSchema();
  249. case TABLE_DIR:
  250. return isSetTable_dir();
  251. case IN_TABLENAME:
  252. return isSetIn_tablename();
  253. case DELIM:
  254. return isSetDelim();
  255. default:
  256. throw new IllegalArgumentException("Field " + fieldID + " doesn't exist!");
  257. }
  258. }
  259. @Override
  260. public boolean equals(Object that) {
  261. if (that == null)
  262. return false;
  263. if (that instanceof ResultsMetadata)
  264. return this.equals((ResultsMetadata)that);
  265. return false;
  266. }
  267. public boolean equals(ResultsMetadata that) {
  268. if (that == null)
  269. return false;
  270. boolean this_present_schema = true && this.isSetSchema();
  271. boolean that_present_schema = true && that.isSetSchema();
  272. if (this_present_schema || that_present_schema) {
  273. if (!(this_present_schema && that_present_schema))
  274. return false;
  275. if (!this.schema.equals(that.schema))
  276. return false;
  277. }
  278. boolean this_present_table_dir = true && this.isSetTable_dir();
  279. boolean that_present_table_dir = true && that.isSetTable_dir();
  280. if (this_present_table_dir || that_present_table_dir) {
  281. if (!(this_present_table_dir && that_present_table_dir))
  282. return false;
  283. if (!this.table_dir.equals(that.table_dir))
  284. return false;
  285. }
  286. boolean this_present_in_tablename = true && this.isSetIn_tablename();
  287. boolean that_present_in_tablename = true && that.isSetIn_tablename();
  288. if (this_present_in_tablename || that_present_in_tablename) {
  289. if (!(this_present_in_tablename && that_present_in_tablename))
  290. return false;
  291. if (!this.in_tablename.equals(that.in_tablename))
  292. return false;
  293. }
  294. boolean this_present_delim = true && this.isSetDelim();
  295. boolean that_present_delim = true && that.isSetDelim();
  296. if (this_present_delim || that_present_delim) {
  297. if (!(this_present_delim && that_present_delim))
  298. return false;
  299. if (!this.delim.equals(that.delim))
  300. return false;
  301. }
  302. return true;
  303. }
  304. @Override
  305. public int hashCode() {
  306. HashCodeBuilder builder = new HashCodeBuilder();
  307. boolean present_schema = true && (isSetSchema());
  308. builder.append(present_schema);
  309. if (present_schema)
  310. builder.append(schema);
  311. boolean present_table_dir = true && (isSetTable_dir());
  312. builder.append(present_table_dir);
  313. if (present_table_dir)
  314. builder.append(table_dir);
  315. boolean present_in_tablename = true && (isSetIn_tablename());
  316. builder.append(present_in_tablename);
  317. if (present_in_tablename)
  318. builder.append(in_tablename);
  319. boolean present_delim = true && (isSetDelim());
  320. builder.append(present_delim);
  321. if (present_delim)
  322. builder.append(delim);
  323. return builder.toHashCode();
  324. }
  325. public void read(TProtocol iprot) throws TException {
  326. TField field;
  327. iprot.readStructBegin();
  328. while (true)
  329. {
  330. field = iprot.readFieldBegin();
  331. if (field.type == TType.STOP) {
  332. break;
  333. }
  334. switch (field.id)
  335. {
  336. case SCHEMA:
  337. if (field.type == TType.STRUCT) {
  338. this.schema = new org.apache.hadoop.hive.metastore.api.Schema();
  339. this.schema.read(iprot);
  340. } else {
  341. TProtocolUtil.skip(iprot, field.type);
  342. }
  343. break;
  344. case TABLE_DIR:
  345. if (field.type == TType.STRING) {
  346. this.table_dir = iprot.readString();
  347. } else {
  348. TProtocolUtil.skip(iprot, field.type);
  349. }
  350. break;
  351. case IN_TABLENAME:
  352. if (field.type == TType.STRING) {
  353. this.in_tablename = iprot.readString();
  354. } else {
  355. TProtocolUtil.skip(iprot, field.type);
  356. }
  357. break;
  358. case DELIM:
  359. if (field.type == TType.STRING) {
  360. this.delim = iprot.readString();
  361. } else {
  362. TProtocolUtil.skip(iprot, field.type);
  363. }
  364. break;
  365. default:
  366. TProtocolUtil.skip(iprot, field.type);
  367. break;
  368. }
  369. iprot.readFieldEnd();
  370. }
  371. iprot.readStructEnd();
  372. // check for required fields of primitive type, which can't be checked in the validate method
  373. validate();
  374. }
  375. public void write(TProtocol oprot) throws TException {
  376. validate();
  377. oprot.writeStructBegin(STRUCT_DESC);
  378. if (this.schema != null) {
  379. oprot.writeFieldBegin(SCHEMA_FIELD_DESC);
  380. this.schema.write(oprot);
  381. oprot.writeFieldEnd();
  382. }
  383. if (this.table_dir != null) {
  384. oprot.writeFieldBegin(TABLE_DIR_FIELD_DESC);
  385. oprot.writeString(this.table_dir);
  386. oprot.writeFieldEnd();
  387. }
  388. if (this.in_tablename != null) {
  389. oprot.writeFieldBegin(IN_TABLENAME_FIELD_DESC);
  390. oprot.writeString(this.in_tablename);
  391. oprot.writeFieldEnd();
  392. }
  393. if (this.delim != null) {
  394. oprot.writeFieldBegin(DELIM_FIELD_DESC);
  395. oprot.writeString(this.delim);
  396. oprot.writeFieldEnd();
  397. }
  398. oprot.writeFieldStop();
  399. oprot.writeStructEnd();
  400. }
  401. @Override
  402. public String toString() {
  403. StringBuilder sb = new StringBuilder("ResultsMetadata(");
  404. boolean first = true;
  405. sb.append("schema:");
  406. if (this.schema == null) {
  407. sb.append("null");
  408. } else {
  409. sb.append(this.schema);
  410. }
  411. first = false;
  412. if (!first) sb.append(", ");
  413. sb.append("table_dir:");
  414. if (this.table_dir == null) {
  415. sb.append("null");
  416. } else {
  417. sb.append(this.table_dir);
  418. }
  419. first = false;
  420. if (!first) sb.append(", ");
  421. sb.append("in_tablename:");
  422. if (this.in_tablename == null) {
  423. sb.append("null");
  424. } else {
  425. sb.append(this.in_tablename);
  426. }
  427. first = false;
  428. if (!first) sb.append(", ");
  429. sb.append("delim:");
  430. if (this.delim == null) {
  431. sb.append("null");
  432. } else {
  433. sb.append(this.delim);
  434. }
  435. first = false;
  436. sb.append(")");
  437. return sb.toString();
  438. }
  439. public void validate() throws TException {
  440. // check for required fields
  441. // check that fields of type enum have valid values
  442. }
  443. }