/chukwa-hitune-dist/src/java/org/apache/hadoop/chukwa/extraction/engine/ChukwaRecordKey.java

https://github.com/haitaoyao/HiTune · Java · 269 lines · 241 code · 25 blank · 3 comment · 35 complexity · 78922c90428a49a26c3902a9dcb45cf6 MD5 · raw file

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