/src/org/apache/hadoop/chukwa/ChukwaArchiveKey.java

https://github.com/thainb/Honu · Java · 360 lines · 328 code · 29 blank · 3 comment · 55 complexity · 79cb9bf56e7070554439a80418131355 MD5 · raw file

  1. // File generated by hadoop record compiler. Do not edit.
  2. package org.apache.hadoop.chukwa;
  3. public class ChukwaArchiveKey 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. "ChukwaArchiveKey");
  10. _rio_recTypeInfo.addField("timePartition",
  11. org.apache.hadoop.record.meta.TypeID.LongTypeID);
  12. _rio_recTypeInfo.addField("dataType",
  13. org.apache.hadoop.record.meta.TypeID.StringTypeID);
  14. _rio_recTypeInfo.addField("streamName",
  15. org.apache.hadoop.record.meta.TypeID.StringTypeID);
  16. _rio_recTypeInfo.addField("seqId",
  17. org.apache.hadoop.record.meta.TypeID.LongTypeID);
  18. }
  19. private long timePartition;
  20. private String dataType;
  21. private String streamName;
  22. private long seqId;
  23. public ChukwaArchiveKey() {
  24. }
  25. public ChukwaArchiveKey(final long timePartition, final String dataType,
  26. final String streamName, final long seqId) {
  27. this.timePartition = timePartition;
  28. this.dataType = dataType;
  29. this.streamName = streamName;
  30. this.seqId = seqId;
  31. }
  32. public static org.apache.hadoop.record.meta.RecordTypeInfo getTypeInfo() {
  33. return _rio_recTypeInfo;
  34. }
  35. public static void setTypeFilter(
  36. org.apache.hadoop.record.meta.RecordTypeInfo rti) {
  37. if (null == rti)
  38. return;
  39. _rio_rtiFilter = rti;
  40. _rio_rtiFilterFields = null;
  41. }
  42. private static void setupRtiFields() {
  43. if (null == _rio_rtiFilter)
  44. return;
  45. // we may already have done this
  46. if (null != _rio_rtiFilterFields)
  47. return;
  48. int _rio_i, _rio_j;
  49. _rio_rtiFilterFields = new int[_rio_rtiFilter.getFieldTypeInfos().size()];
  50. for (_rio_i = 0; _rio_i < _rio_rtiFilterFields.length; _rio_i++) {
  51. _rio_rtiFilterFields[_rio_i] = 0;
  52. }
  53. java.util.Iterator<org.apache.hadoop.record.meta.FieldTypeInfo> _rio_itFilter = _rio_rtiFilter
  54. .getFieldTypeInfos().iterator();
  55. _rio_i = 0;
  56. while (_rio_itFilter.hasNext()) {
  57. org.apache.hadoop.record.meta.FieldTypeInfo _rio_tInfoFilter = _rio_itFilter
  58. .next();
  59. java.util.Iterator<org.apache.hadoop.record.meta.FieldTypeInfo> _rio_it = _rio_recTypeInfo
  60. .getFieldTypeInfos().iterator();
  61. _rio_j = 1;
  62. while (_rio_it.hasNext()) {
  63. org.apache.hadoop.record.meta.FieldTypeInfo _rio_tInfo = _rio_it.next();
  64. if (_rio_tInfo.equals(_rio_tInfoFilter)) {
  65. _rio_rtiFilterFields[_rio_i] = _rio_j;
  66. break;
  67. }
  68. _rio_j++;
  69. }
  70. _rio_i++;
  71. }
  72. }
  73. public long getTimePartition() {
  74. return timePartition;
  75. }
  76. public void setTimePartition(final long timePartition) {
  77. this.timePartition = timePartition;
  78. }
  79. public String getDataType() {
  80. return dataType;
  81. }
  82. public void setDataType(final String dataType) {
  83. this.dataType = dataType;
  84. }
  85. public String getStreamName() {
  86. return streamName;
  87. }
  88. public void setStreamName(final String streamName) {
  89. this.streamName = streamName;
  90. }
  91. public long getSeqId() {
  92. return seqId;
  93. }
  94. public void setSeqId(final long seqId) {
  95. this.seqId = seqId;
  96. }
  97. public void serialize(final org.apache.hadoop.record.RecordOutput _rio_a,
  98. final String _rio_tag) throws java.io.IOException {
  99. _rio_a.startRecord(this, _rio_tag);
  100. _rio_a.writeLong(timePartition, "timePartition");
  101. _rio_a.writeString(dataType, "dataType");
  102. _rio_a.writeString(streamName, "streamName");
  103. _rio_a.writeLong(seqId, "seqId");
  104. _rio_a.endRecord(this, _rio_tag);
  105. }
  106. private void deserializeWithoutFilter(
  107. final org.apache.hadoop.record.RecordInput _rio_a, final String _rio_tag)
  108. throws java.io.IOException {
  109. _rio_a.startRecord(_rio_tag);
  110. timePartition = _rio_a.readLong("timePartition");
  111. dataType = _rio_a.readString("dataType");
  112. streamName = _rio_a.readString("streamName");
  113. seqId = _rio_a.readLong("seqId");
  114. _rio_a.endRecord(_rio_tag);
  115. }
  116. public void deserialize(final org.apache.hadoop.record.RecordInput _rio_a,
  117. final String _rio_tag) throws java.io.IOException {
  118. if (null == _rio_rtiFilter) {
  119. deserializeWithoutFilter(_rio_a, _rio_tag);
  120. return;
  121. }
  122. // if we're here, we need to read based on version info
  123. _rio_a.startRecord(_rio_tag);
  124. setupRtiFields();
  125. for (int _rio_i = 0; _rio_i < _rio_rtiFilter.getFieldTypeInfos().size(); _rio_i++) {
  126. if (1 == _rio_rtiFilterFields[_rio_i]) {
  127. timePartition = _rio_a.readLong("timePartition");
  128. } else if (2 == _rio_rtiFilterFields[_rio_i]) {
  129. dataType = _rio_a.readString("dataType");
  130. } else if (3 == _rio_rtiFilterFields[_rio_i]) {
  131. streamName = _rio_a.readString("streamName");
  132. } else if (4 == _rio_rtiFilterFields[_rio_i]) {
  133. seqId = _rio_a.readLong("seqId");
  134. } else {
  135. java.util.ArrayList<org.apache.hadoop.record.meta.FieldTypeInfo> typeInfos = (java.util.ArrayList<org.apache.hadoop.record.meta.FieldTypeInfo>) (_rio_rtiFilter
  136. .getFieldTypeInfos());
  137. org.apache.hadoop.record.meta.Utils.skip(_rio_a, typeInfos.get(_rio_i)
  138. .getFieldID(), typeInfos.get(_rio_i).getTypeID());
  139. }
  140. }
  141. _rio_a.endRecord(_rio_tag);
  142. }
  143. public int compareTo(final Object _rio_peer_) throws ClassCastException {
  144. if (!(_rio_peer_ instanceof ChukwaArchiveKey)) {
  145. throw new ClassCastException("Comparing different types of records.");
  146. }
  147. ChukwaArchiveKey _rio_peer = (ChukwaArchiveKey) _rio_peer_;
  148. int _rio_ret = 0;
  149. _rio_ret = (timePartition == _rio_peer.timePartition) ? 0
  150. : ((timePartition < _rio_peer.timePartition) ? -1 : 1);
  151. if (_rio_ret != 0)
  152. return _rio_ret;
  153. _rio_ret = dataType.compareTo(_rio_peer.dataType);
  154. if (_rio_ret != 0)
  155. return _rio_ret;
  156. _rio_ret = streamName.compareTo(_rio_peer.streamName);
  157. if (_rio_ret != 0)
  158. return _rio_ret;
  159. _rio_ret = (seqId == _rio_peer.seqId) ? 0 : ((seqId < _rio_peer.seqId) ? -1
  160. : 1);
  161. if (_rio_ret != 0)
  162. return _rio_ret;
  163. return _rio_ret;
  164. }
  165. public boolean equals(final Object _rio_peer_) {
  166. if (!(_rio_peer_ instanceof ChukwaArchiveKey)) {
  167. return false;
  168. }
  169. if (_rio_peer_ == this) {
  170. return true;
  171. }
  172. ChukwaArchiveKey _rio_peer = (ChukwaArchiveKey) _rio_peer_;
  173. boolean _rio_ret = false;
  174. _rio_ret = (timePartition == _rio_peer.timePartition);
  175. if (!_rio_ret)
  176. return _rio_ret;
  177. _rio_ret = dataType.equals(_rio_peer.dataType);
  178. if (!_rio_ret)
  179. return _rio_ret;
  180. _rio_ret = streamName.equals(_rio_peer.streamName);
  181. if (!_rio_ret)
  182. return _rio_ret;
  183. _rio_ret = (seqId == _rio_peer.seqId);
  184. if (!_rio_ret)
  185. return _rio_ret;
  186. return _rio_ret;
  187. }
  188. public Object clone() throws CloneNotSupportedException {
  189. ChukwaArchiveKey _rio_other = new ChukwaArchiveKey();
  190. _rio_other.timePartition = this.timePartition;
  191. _rio_other.dataType = this.dataType;
  192. _rio_other.streamName = this.streamName;
  193. _rio_other.seqId = this.seqId;
  194. return _rio_other;
  195. }
  196. public int hashCode() {
  197. int _rio_result = 17;
  198. int _rio_ret;
  199. _rio_ret = (int) (timePartition ^ (timePartition >>> 32));
  200. _rio_result = 37 * _rio_result + _rio_ret;
  201. _rio_ret = dataType.hashCode();
  202. _rio_result = 37 * _rio_result + _rio_ret;
  203. _rio_ret = streamName.hashCode();
  204. _rio_result = 37 * _rio_result + _rio_ret;
  205. _rio_ret = (int) (seqId ^ (seqId >>> 32));
  206. _rio_result = 37 * _rio_result + _rio_ret;
  207. return _rio_result;
  208. }
  209. public static String signature() {
  210. return "LChukwaArchiveKey(lssl)";
  211. }
  212. public static class Comparator extends
  213. org.apache.hadoop.record.RecordComparator {
  214. public Comparator() {
  215. super(ChukwaArchiveKey.class);
  216. }
  217. static public int slurpRaw(byte[] b, int s, int l) {
  218. try {
  219. int os = s;
  220. {
  221. long i = org.apache.hadoop.record.Utils.readVLong(b, s);
  222. int z = org.apache.hadoop.record.Utils.getVIntSize(i);
  223. s += z;
  224. l -= z;
  225. }
  226. {
  227. int i = org.apache.hadoop.record.Utils.readVInt(b, s);
  228. int z = org.apache.hadoop.record.Utils.getVIntSize(i);
  229. s += (z + i);
  230. l -= (z + i);
  231. }
  232. {
  233. int i = org.apache.hadoop.record.Utils.readVInt(b, s);
  234. int z = org.apache.hadoop.record.Utils.getVIntSize(i);
  235. s += (z + i);
  236. l -= (z + i);
  237. }
  238. {
  239. long i = org.apache.hadoop.record.Utils.readVLong(b, s);
  240. int z = org.apache.hadoop.record.Utils.getVIntSize(i);
  241. s += z;
  242. l -= z;
  243. }
  244. return (os - s);
  245. } catch (java.io.IOException e) {
  246. throw new RuntimeException(e);
  247. }
  248. }
  249. static public int compareRaw(byte[] b1, int s1, int l1, byte[] b2, int s2,
  250. int l2) {
  251. try {
  252. int os1 = s1;
  253. {
  254. long i1 = org.apache.hadoop.record.Utils.readVLong(b1, s1);
  255. long i2 = org.apache.hadoop.record.Utils.readVLong(b2, s2);
  256. if (i1 != i2) {
  257. return ((i1 - i2) < 0) ? -1 : 0;
  258. }
  259. int z1 = org.apache.hadoop.record.Utils.getVIntSize(i1);
  260. int z2 = org.apache.hadoop.record.Utils.getVIntSize(i2);
  261. s1 += z1;
  262. s2 += z2;
  263. l1 -= z1;
  264. l2 -= z2;
  265. }
  266. {
  267. int i1 = org.apache.hadoop.record.Utils.readVInt(b1, s1);
  268. int i2 = org.apache.hadoop.record.Utils.readVInt(b2, s2);
  269. int z1 = org.apache.hadoop.record.Utils.getVIntSize(i1);
  270. int z2 = org.apache.hadoop.record.Utils.getVIntSize(i2);
  271. s1 += z1;
  272. s2 += z2;
  273. l1 -= z1;
  274. l2 -= z2;
  275. int r1 = org.apache.hadoop.record.Utils.compareBytes(b1, s1, i1, b2,
  276. s2, i2);
  277. if (r1 != 0) {
  278. return (r1 < 0) ? -1 : 0;
  279. }
  280. s1 += i1;
  281. s2 += i2;
  282. l1 -= i1;
  283. l1 -= i2;
  284. }
  285. {
  286. int i1 = org.apache.hadoop.record.Utils.readVInt(b1, s1);
  287. int i2 = org.apache.hadoop.record.Utils.readVInt(b2, s2);
  288. int z1 = org.apache.hadoop.record.Utils.getVIntSize(i1);
  289. int z2 = org.apache.hadoop.record.Utils.getVIntSize(i2);
  290. s1 += z1;
  291. s2 += z2;
  292. l1 -= z1;
  293. l2 -= z2;
  294. int r1 = org.apache.hadoop.record.Utils.compareBytes(b1, s1, i1, b2,
  295. s2, i2);
  296. if (r1 != 0) {
  297. return (r1 < 0) ? -1 : 0;
  298. }
  299. s1 += i1;
  300. s2 += i2;
  301. l1 -= i1;
  302. l1 -= i2;
  303. }
  304. {
  305. long i1 = org.apache.hadoop.record.Utils.readVLong(b1, s1);
  306. long i2 = org.apache.hadoop.record.Utils.readVLong(b2, s2);
  307. if (i1 != i2) {
  308. return ((i1 - i2) < 0) ? -1 : 0;
  309. }
  310. int z1 = org.apache.hadoop.record.Utils.getVIntSize(i1);
  311. int z2 = org.apache.hadoop.record.Utils.getVIntSize(i2);
  312. s1 += z1;
  313. s2 += z2;
  314. l1 -= z1;
  315. l2 -= z2;
  316. }
  317. return (os1 - s1);
  318. } catch (java.io.IOException e) {
  319. throw new RuntimeException(e);
  320. }
  321. }
  322. public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) {
  323. int ret = compareRaw(b1, s1, l1, b2, s2, l2);
  324. return (ret == -1) ? -1 : ((ret == 0) ? 1 : 0);
  325. }
  326. }
  327. static {
  328. org.apache.hadoop.record.RecordComparator.define(ChukwaArchiveKey.class,
  329. new Comparator());
  330. }
  331. }