Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.92 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package do0036484958.zadatak2;
  7.  
  8. import java.io.DataInput;
  9. import java.io.DataOutput;
  10. import java.io.IOException;
  11. import java.util.Objects;
  12. import org.apache.hadoop.io.DoubleWritable;
  13. import org.apache.hadoop.io.IntWritable;
  14. import org.apache.hadoop.io.Text;
  15. import org.apache.hadoop.io.WritableComparable;
  16.  
  17. /**
  18. *
  19. * @author Dominik
  20. */
  21. public class Zadatak2DEBSOutput implements WritableComparable<Zadatak2DEBSOutput> {
  22. private final Text medallion;
  23. private final Text hackLicense;
  24. private final Text vendorId;
  25. private final IntWritable rateCode;
  26. private final Text storeAndFwdFlag;
  27. private final Text pickupDatetime;
  28. private final Text dropoffDatetime;
  29. private final IntWritable passengerCount;
  30. private final IntWritable tripTimeInSecs;
  31. private final DoubleWritable tripDistance;
  32. private final DoubleWritable pickupLongitude;
  33. private final DoubleWritable pickupLatitude;
  34. private final DoubleWritable dropoffLongitude;
  35. private final DoubleWritable dropoffLatitude;
  36.  
  37. public Zadatak2DEBSOutput() {
  38. this("", "", "", 0, "", "", "", 0, 0, 0, 0, 0, 0, 0);
  39. }
  40.  
  41. public Zadatak2DEBSOutput(String medallion, String hackLicense, String vendorId, int rateCode, String storeAndFwdFlag, String pickupDatetime, String dropoffDatetime, int passengerCount, int tripTimeInSecs, double tripDistance, double pickupLongitude, double pickupLatitude, double dropoffLongitude, double dropoffLatitude) {
  42. this.medallion = new Text(medallion);
  43. this.hackLicense = new Text(hackLicense);
  44. this.vendorId = new Text(vendorId);
  45. this.rateCode = new IntWritable(rateCode);
  46. this.storeAndFwdFlag = new Text(storeAndFwdFlag);
  47. this.pickupDatetime = new Text(pickupDatetime);
  48. this.dropoffDatetime = new Text(dropoffDatetime);
  49. this.passengerCount = new IntWritable(passengerCount);
  50. this.tripTimeInSecs = new IntWritable(tripTimeInSecs);
  51. this.tripDistance = new DoubleWritable(tripDistance);
  52. this.pickupLongitude = new DoubleWritable(pickupLongitude);
  53. this.pickupLatitude = new DoubleWritable(pickupLatitude);
  54. this.dropoffLongitude = new DoubleWritable(dropoffLongitude);
  55. this.dropoffLatitude = new DoubleWritable(dropoffLatitude);
  56. }
  57.  
  58.  
  59.  
  60. @Override
  61. public void write(DataOutput d) throws IOException {
  62. medallion.write(d);
  63. hackLicense.write(d);
  64. vendorId.write(d);
  65. rateCode.write(d);
  66. storeAndFwdFlag.write(d);
  67. pickupDatetime.write(d);
  68. dropoffDatetime.write(d);
  69. passengerCount.write(d);
  70. tripTimeInSecs.write(d);
  71. tripDistance.write(d);
  72. pickupLongitude.write(d);
  73. pickupLatitude.write(d);
  74. dropoffLongitude.write(d);
  75. dropoffLatitude.write(d);
  76. }
  77.  
  78. @Override
  79. public void readFields(DataInput di) throws IOException {
  80. medallion.readFields(di);
  81. hackLicense.readFields(di);
  82. vendorId.readFields(di);
  83. rateCode.readFields(di);
  84. storeAndFwdFlag.readFields(di);
  85. pickupDatetime.readFields(di);
  86. dropoffDatetime.readFields(di);
  87. passengerCount.readFields(di);
  88. tripTimeInSecs.readFields(di);
  89. tripDistance.readFields(di);
  90. pickupLongitude.readFields(di);
  91. pickupLatitude.readFields(di);
  92. dropoffLongitude.readFields(di);
  93. dropoffLatitude.readFields(di);
  94. }
  95.  
  96. @Override
  97. public int hashCode() {
  98. int hash = 5;
  99. hash = 11 * hash + Objects.hashCode(this.medallion);
  100. hash = 11 * hash + Objects.hashCode(this.hackLicense);
  101. hash = 11 * hash + Objects.hashCode(this.vendorId);
  102. hash = 11 * hash + Objects.hashCode(this.rateCode);
  103. hash = 11 * hash + Objects.hashCode(this.storeAndFwdFlag);
  104. hash = 11 * hash + Objects.hashCode(this.pickupDatetime);
  105. hash = 11 * hash + Objects.hashCode(this.dropoffDatetime);
  106. hash = 11 * hash + Objects.hashCode(this.passengerCount);
  107. hash = 11 * hash + Objects.hashCode(this.tripTimeInSecs);
  108. hash = 11 * hash + Objects.hashCode(this.tripDistance);
  109. hash = 11 * hash + Objects.hashCode(this.pickupLongitude);
  110. hash = 11 * hash + Objects.hashCode(this.pickupLatitude);
  111. hash = 11 * hash + Objects.hashCode(this.dropoffLongitude);
  112. hash = 11 * hash + Objects.hashCode(this.dropoffLatitude);
  113. return hash;
  114. }
  115.  
  116. @Override
  117. public boolean equals(Object obj) {
  118. if (this == obj) {
  119. return true;
  120. }
  121. if (obj == null) {
  122. return false;
  123. }
  124. if (getClass() != obj.getClass()) {
  125. return false;
  126. }
  127. final Zadatak2DEBSOutput other = (Zadatak2DEBSOutput) obj;
  128. if (!Objects.equals(this.medallion, other.medallion)) {
  129. return false;
  130. }
  131. if (!Objects.equals(this.hackLicense, other.hackLicense)) {
  132. return false;
  133. }
  134. if (!Objects.equals(this.vendorId, other.vendorId)) {
  135. return false;
  136. }
  137. if (!Objects.equals(this.rateCode, other.rateCode)) {
  138. return false;
  139. }
  140. if (!Objects.equals(this.storeAndFwdFlag, other.storeAndFwdFlag)) {
  141. return false;
  142. }
  143. if (!Objects.equals(this.pickupDatetime, other.pickupDatetime)) {
  144. return false;
  145. }
  146. if (!Objects.equals(this.dropoffDatetime, other.dropoffDatetime)) {
  147. return false;
  148. }
  149. if (!Objects.equals(this.passengerCount, other.passengerCount)) {
  150. return false;
  151. }
  152. if (!Objects.equals(this.tripTimeInSecs, other.tripTimeInSecs)) {
  153. return false;
  154. }
  155. if (!Objects.equals(this.tripDistance, other.tripDistance)) {
  156. return false;
  157. }
  158. if (!Objects.equals(this.pickupLongitude, other.pickupLongitude)) {
  159. return false;
  160. }
  161. if (!Objects.equals(this.pickupLatitude, other.pickupLatitude)) {
  162. return false;
  163. }
  164. if (!Objects.equals(this.dropoffLongitude, other.dropoffLongitude)) {
  165. return false;
  166. }
  167. if (!Objects.equals(this.dropoffLatitude, other.dropoffLatitude)) {
  168. return false;
  169. }
  170. return true;
  171. }
  172.  
  173.  
  174.  
  175. @Override
  176. public String toString() {
  177. StringBuilder sb = new StringBuilder();
  178. sb.append(medallion).append(",");
  179. sb.append(hackLicense).append(",");
  180. sb.append(vendorId).append(",");
  181. sb.append(rateCode).append(",");
  182. sb.append(storeAndFwdFlag).append(",");
  183. sb.append(pickupDatetime).append(",");
  184. sb.append(dropoffDatetime).append(",");
  185. sb.append(passengerCount).append(",");
  186. sb.append(tripTimeInSecs).append(",");
  187. sb.append(tripDistance).append(",");
  188. sb.append(pickupLongitude).append(",");
  189. sb.append(pickupLatitude).append(",");
  190. sb.append(dropoffLongitude).append(",");
  191. sb.append(dropoffLatitude);
  192. return sb.toString();
  193. }
  194.  
  195. @Override
  196. public int compareTo(Zadatak2DEBSOutput o) {
  197. int cmp = medallion.compareTo(o.medallion);
  198. if (cmp != 0) {
  199. return cmp;
  200. }
  201. cmp = hackLicense.compareTo(o.hackLicense);
  202. if (cmp != 0) {
  203. return cmp;
  204. }
  205. cmp = vendorId.compareTo(o.vendorId);
  206. if (cmp != 0) {
  207. return cmp;
  208. }
  209. cmp = rateCode.compareTo(o.rateCode);
  210. if (cmp != 0) {
  211. return cmp;
  212. }
  213. cmp = storeAndFwdFlag.compareTo(o.storeAndFwdFlag);
  214. if (cmp != 0) {
  215. return cmp;
  216. }
  217. cmp = pickupDatetime.compareTo(o.pickupDatetime);
  218. if (cmp != 0) {
  219. return cmp;
  220. }
  221. cmp = dropoffDatetime.compareTo(o.dropoffDatetime);
  222. if (cmp != 0) {
  223. return cmp;
  224. }
  225. cmp = passengerCount.compareTo(o.passengerCount);
  226. if (cmp != 0) {
  227. return cmp;
  228. }
  229. cmp = tripTimeInSecs.compareTo(o.tripTimeInSecs);
  230. if (cmp != 0) {
  231. return cmp;
  232. }
  233. cmp = tripDistance.compareTo(o.tripDistance);
  234. if (cmp != 0) {
  235. return cmp;
  236. }
  237. cmp = pickupLongitude.compareTo(o.pickupLongitude);
  238. if (cmp != 0) {
  239. return cmp;
  240. }
  241. cmp = pickupLatitude.compareTo(o.pickupLatitude);
  242. if (cmp != 0) {
  243. return cmp;
  244. }
  245. cmp = dropoffLongitude.compareTo(o.dropoffLongitude);
  246. if (cmp != 0) {
  247. return cmp;
  248. }
  249. return dropoffLatitude.compareTo(o.dropoffLatitude);
  250. }
  251.  
  252.  
  253.  
  254. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement