/tags/release-0.2.0-rc0/hive/external/ql/src/test/org/apache/hadoop/hive/ql/io/RecordTestObj.java

# · Java · 276 lines · 249 code · 24 blank · 3 comment · 37 complexity · eb50735e0ce155799bd7aad66e694bcb MD5 · raw file

  1. // File generated by hadoop record compiler. Do not edit.
  2. package org.apache.hadoop.hive.ql.io;
  3. public class RecordTestObj extends org.apache.hadoop.record.Record {
  4. private static final org.apache.hadoop.record.meta.RecordTypeInfo _rio_recTypeInfo;
  5. private static org.apache.hadoop.record.meta.RecordTypeInfo _rio_rtiFilter;
  6. private static int[] _rio_rtiFilterFields;
  7. static {
  8. _rio_recTypeInfo = new org.apache.hadoop.record.meta.RecordTypeInfo(
  9. "RecordTestObj");
  10. _rio_recTypeInfo.addField("s",
  11. org.apache.hadoop.record.meta.TypeID.StringTypeID);
  12. _rio_recTypeInfo.addField("num",
  13. org.apache.hadoop.record.meta.TypeID.LongTypeID);
  14. }
  15. private String s;
  16. private long num;
  17. public RecordTestObj() {
  18. }
  19. public RecordTestObj(final String s, final long num) {
  20. this.s = s;
  21. this.num = num;
  22. }
  23. public static org.apache.hadoop.record.meta.RecordTypeInfo getTypeInfo() {
  24. return _rio_recTypeInfo;
  25. }
  26. public static void setTypeFilter(
  27. org.apache.hadoop.record.meta.RecordTypeInfo rti) {
  28. if (null == rti) {
  29. return;
  30. }
  31. _rio_rtiFilter = rti;
  32. _rio_rtiFilterFields = null;
  33. }
  34. private static void setupRtiFields() {
  35. if (null == _rio_rtiFilter) {
  36. return;
  37. }
  38. // we may already have done this
  39. if (null != _rio_rtiFilterFields) {
  40. return;
  41. }
  42. int _rio_i, _rio_j;
  43. _rio_rtiFilterFields = new int[_rio_rtiFilter.getFieldTypeInfos().size()];
  44. for (_rio_i = 0; _rio_i < _rio_rtiFilterFields.length; _rio_i++) {
  45. _rio_rtiFilterFields[_rio_i] = 0;
  46. }
  47. java.util.Iterator<org.apache.hadoop.record.meta.FieldTypeInfo> _rio_itFilter = _rio_rtiFilter
  48. .getFieldTypeInfos().iterator();
  49. _rio_i = 0;
  50. while (_rio_itFilter.hasNext()) {
  51. org.apache.hadoop.record.meta.FieldTypeInfo _rio_tInfoFilter = _rio_itFilter
  52. .next();
  53. java.util.Iterator<org.apache.hadoop.record.meta.FieldTypeInfo> _rio_it = _rio_recTypeInfo
  54. .getFieldTypeInfos().iterator();
  55. _rio_j = 1;
  56. while (_rio_it.hasNext()) {
  57. org.apache.hadoop.record.meta.FieldTypeInfo _rio_tInfo = _rio_it.next();
  58. if (_rio_tInfo.equals(_rio_tInfoFilter)) {
  59. _rio_rtiFilterFields[_rio_i] = _rio_j;
  60. break;
  61. }
  62. _rio_j++;
  63. }
  64. _rio_i++;
  65. }
  66. }
  67. public String getS() {
  68. return s;
  69. }
  70. public void setS(final String s) {
  71. this.s = s;
  72. }
  73. public long getNum() {
  74. return num;
  75. }
  76. public void setNum(final long num) {
  77. this.num = num;
  78. }
  79. @Override
  80. public void serialize(final org.apache.hadoop.record.RecordOutput _rio_a,
  81. final String _rio_tag) throws java.io.IOException {
  82. _rio_a.startRecord(this, _rio_tag);
  83. _rio_a.writeString(s, "s");
  84. _rio_a.writeLong(num, "num");
  85. _rio_a.endRecord(this, _rio_tag);
  86. }
  87. private void deserializeWithoutFilter(
  88. final org.apache.hadoop.record.RecordInput _rio_a, final String _rio_tag)
  89. throws java.io.IOException {
  90. _rio_a.startRecord(_rio_tag);
  91. s = _rio_a.readString("s");
  92. num = _rio_a.readLong("num");
  93. _rio_a.endRecord(_rio_tag);
  94. }
  95. @Override
  96. public void deserialize(final org.apache.hadoop.record.RecordInput _rio_a,
  97. final String _rio_tag) throws java.io.IOException {
  98. if (null == _rio_rtiFilter) {
  99. deserializeWithoutFilter(_rio_a, _rio_tag);
  100. return;
  101. }
  102. // if we're here, we need to read based on version info
  103. _rio_a.startRecord(_rio_tag);
  104. setupRtiFields();
  105. for (int _rio_i = 0; _rio_i < _rio_rtiFilter.getFieldTypeInfos().size(); _rio_i++) {
  106. if (1 == _rio_rtiFilterFields[_rio_i]) {
  107. s = _rio_a.readString("s");
  108. } else if (2 == _rio_rtiFilterFields[_rio_i]) {
  109. num = _rio_a.readLong("num");
  110. } else {
  111. java.util.ArrayList<org.apache.hadoop.record.meta.FieldTypeInfo> typeInfos = (java.util.ArrayList<org.apache.hadoop.record.meta.FieldTypeInfo>) (_rio_rtiFilter
  112. .getFieldTypeInfos());
  113. org.apache.hadoop.record.meta.Utils.skip(_rio_a, typeInfos.get(_rio_i)
  114. .getFieldID(), typeInfos.get(_rio_i).getTypeID());
  115. }
  116. }
  117. _rio_a.endRecord(_rio_tag);
  118. }
  119. @Override
  120. public int compareTo(final Object _rio_peer_) throws ClassCastException {
  121. if (!(_rio_peer_ instanceof RecordTestObj)) {
  122. throw new ClassCastException("Comparing different types of records.");
  123. }
  124. RecordTestObj _rio_peer = (RecordTestObj) _rio_peer_;
  125. int _rio_ret = 0;
  126. _rio_ret = s.compareTo(_rio_peer.s);
  127. if (_rio_ret != 0) {
  128. return _rio_ret;
  129. }
  130. _rio_ret = (num == _rio_peer.num) ? 0 : ((num < _rio_peer.num) ? -1 : 1);
  131. if (_rio_ret != 0) {
  132. return _rio_ret;
  133. }
  134. return _rio_ret;
  135. }
  136. @Override
  137. public boolean equals(final Object _rio_peer_) {
  138. if (!(_rio_peer_ instanceof RecordTestObj)) {
  139. return false;
  140. }
  141. if (_rio_peer_ == this) {
  142. return true;
  143. }
  144. RecordTestObj _rio_peer = (RecordTestObj) _rio_peer_;
  145. boolean _rio_ret = false;
  146. _rio_ret = s.equals(_rio_peer.s);
  147. if (!_rio_ret) {
  148. return _rio_ret;
  149. }
  150. _rio_ret = (num == _rio_peer.num);
  151. if (!_rio_ret) {
  152. return _rio_ret;
  153. }
  154. return _rio_ret;
  155. }
  156. @Override
  157. public Object clone() throws CloneNotSupportedException {
  158. RecordTestObj _rio_other = new RecordTestObj();
  159. _rio_other.s = s;
  160. _rio_other.num = num;
  161. return _rio_other;
  162. }
  163. @Override
  164. public int hashCode() {
  165. int _rio_result = 17;
  166. int _rio_ret;
  167. _rio_ret = s.hashCode();
  168. _rio_result = 37 * _rio_result + _rio_ret;
  169. _rio_ret = (int) (num ^ (num >>> 32));
  170. _rio_result = 37 * _rio_result + _rio_ret;
  171. return _rio_result;
  172. }
  173. public static String signature() {
  174. return "LRecordTestObj(sl)";
  175. }
  176. public static class Comparator extends
  177. org.apache.hadoop.record.RecordComparator {
  178. public Comparator() {
  179. super(RecordTestObj.class);
  180. }
  181. static public int slurpRaw(byte[] b, int s, int l) {
  182. try {
  183. int os = s;
  184. {
  185. int i = org.apache.hadoop.record.Utils.readVInt(b, s);
  186. int z = org.apache.hadoop.record.Utils.getVIntSize(i);
  187. s += (z + i);
  188. l -= (z + i);
  189. }
  190. {
  191. long i = org.apache.hadoop.record.Utils.readVLong(b, s);
  192. int z = org.apache.hadoop.record.Utils.getVIntSize(i);
  193. s += z;
  194. l -= z;
  195. }
  196. return (os - s);
  197. } catch (java.io.IOException e) {
  198. throw new RuntimeException(e);
  199. }
  200. }
  201. static public int compareRaw(byte[] b1, int s1, int l1, byte[] b2, int s2,
  202. int l2) {
  203. try {
  204. int os1 = s1;
  205. {
  206. int i1 = org.apache.hadoop.record.Utils.readVInt(b1, s1);
  207. int i2 = org.apache.hadoop.record.Utils.readVInt(b2, s2);
  208. int z1 = org.apache.hadoop.record.Utils.getVIntSize(i1);
  209. int z2 = org.apache.hadoop.record.Utils.getVIntSize(i2);
  210. s1 += z1;
  211. s2 += z2;
  212. l1 -= z1;
  213. l2 -= z2;
  214. int r1 = org.apache.hadoop.record.Utils.compareBytes(b1, s1, i1, b2,
  215. s2, i2);
  216. if (r1 != 0) {
  217. return (r1 < 0) ? -1 : 0;
  218. }
  219. s1 += i1;
  220. s2 += i2;
  221. l1 -= i1;
  222. l1 -= i2;
  223. }
  224. {
  225. long i1 = org.apache.hadoop.record.Utils.readVLong(b1, s1);
  226. long i2 = org.apache.hadoop.record.Utils.readVLong(b2, s2);
  227. if (i1 != i2) {
  228. return ((i1 - i2) < 0) ? -1 : 0;
  229. }
  230. int z1 = org.apache.hadoop.record.Utils.getVIntSize(i1);
  231. int z2 = org.apache.hadoop.record.Utils.getVIntSize(i2);
  232. s1 += z1;
  233. s2 += z2;
  234. l1 -= z1;
  235. l2 -= z2;
  236. }
  237. return (os1 - s1);
  238. } catch (java.io.IOException e) {
  239. throw new RuntimeException(e);
  240. }
  241. }
  242. @Override
  243. public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
  244. int ret = compareRaw(b1, s1, l1, b2, s2, l2);
  245. return (ret == -1) ? -1 : ((ret == 0) ? 1 : 0);
  246. }
  247. }
  248. static {
  249. org.apache.hadoop.record.RecordComparator.define(RecordTestObj.class,
  250. new Comparator());
  251. }
  252. }