Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package do0036484958.zadatak2;
- import java.io.DataInput;
- import java.io.DataOutput;
- import java.io.IOException;
- import java.util.Objects;
- import org.apache.hadoop.io.DoubleWritable;
- import org.apache.hadoop.io.IntWritable;
- import org.apache.hadoop.io.Text;
- import org.apache.hadoop.io.WritableComparable;
- /**
- *
- * @author Dominik
- */
- public class Zadatak2DEBSOutput implements WritableComparable<Zadatak2DEBSOutput> {
- private final Text medallion;
- private final Text hackLicense;
- private final Text vendorId;
- private final IntWritable rateCode;
- private final Text storeAndFwdFlag;
- private final Text pickupDatetime;
- private final Text dropoffDatetime;
- private final IntWritable passengerCount;
- private final IntWritable tripTimeInSecs;
- private final DoubleWritable tripDistance;
- private final DoubleWritable pickupLongitude;
- private final DoubleWritable pickupLatitude;
- private final DoubleWritable dropoffLongitude;
- private final DoubleWritable dropoffLatitude;
- public Zadatak2DEBSOutput() {
- this("", "", "", 0, "", "", "", 0, 0, 0, 0, 0, 0, 0);
- }
- 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) {
- this.medallion = new Text(medallion);
- this.hackLicense = new Text(hackLicense);
- this.vendorId = new Text(vendorId);
- this.rateCode = new IntWritable(rateCode);
- this.storeAndFwdFlag = new Text(storeAndFwdFlag);
- this.pickupDatetime = new Text(pickupDatetime);
- this.dropoffDatetime = new Text(dropoffDatetime);
- this.passengerCount = new IntWritable(passengerCount);
- this.tripTimeInSecs = new IntWritable(tripTimeInSecs);
- this.tripDistance = new DoubleWritable(tripDistance);
- this.pickupLongitude = new DoubleWritable(pickupLongitude);
- this.pickupLatitude = new DoubleWritable(pickupLatitude);
- this.dropoffLongitude = new DoubleWritable(dropoffLongitude);
- this.dropoffLatitude = new DoubleWritable(dropoffLatitude);
- }
- @Override
- public void write(DataOutput d) throws IOException {
- medallion.write(d);
- hackLicense.write(d);
- vendorId.write(d);
- rateCode.write(d);
- storeAndFwdFlag.write(d);
- pickupDatetime.write(d);
- dropoffDatetime.write(d);
- passengerCount.write(d);
- tripTimeInSecs.write(d);
- tripDistance.write(d);
- pickupLongitude.write(d);
- pickupLatitude.write(d);
- dropoffLongitude.write(d);
- dropoffLatitude.write(d);
- }
- @Override
- public void readFields(DataInput di) throws IOException {
- medallion.readFields(di);
- hackLicense.readFields(di);
- vendorId.readFields(di);
- rateCode.readFields(di);
- storeAndFwdFlag.readFields(di);
- pickupDatetime.readFields(di);
- dropoffDatetime.readFields(di);
- passengerCount.readFields(di);
- tripTimeInSecs.readFields(di);
- tripDistance.readFields(di);
- pickupLongitude.readFields(di);
- pickupLatitude.readFields(di);
- dropoffLongitude.readFields(di);
- dropoffLatitude.readFields(di);
- }
- @Override
- public int hashCode() {
- int hash = 5;
- hash = 11 * hash + Objects.hashCode(this.medallion);
- hash = 11 * hash + Objects.hashCode(this.hackLicense);
- hash = 11 * hash + Objects.hashCode(this.vendorId);
- hash = 11 * hash + Objects.hashCode(this.rateCode);
- hash = 11 * hash + Objects.hashCode(this.storeAndFwdFlag);
- hash = 11 * hash + Objects.hashCode(this.pickupDatetime);
- hash = 11 * hash + Objects.hashCode(this.dropoffDatetime);
- hash = 11 * hash + Objects.hashCode(this.passengerCount);
- hash = 11 * hash + Objects.hashCode(this.tripTimeInSecs);
- hash = 11 * hash + Objects.hashCode(this.tripDistance);
- hash = 11 * hash + Objects.hashCode(this.pickupLongitude);
- hash = 11 * hash + Objects.hashCode(this.pickupLatitude);
- hash = 11 * hash + Objects.hashCode(this.dropoffLongitude);
- hash = 11 * hash + Objects.hashCode(this.dropoffLatitude);
- return hash;
- }
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Zadatak2DEBSOutput other = (Zadatak2DEBSOutput) obj;
- if (!Objects.equals(this.medallion, other.medallion)) {
- return false;
- }
- if (!Objects.equals(this.hackLicense, other.hackLicense)) {
- return false;
- }
- if (!Objects.equals(this.vendorId, other.vendorId)) {
- return false;
- }
- if (!Objects.equals(this.rateCode, other.rateCode)) {
- return false;
- }
- if (!Objects.equals(this.storeAndFwdFlag, other.storeAndFwdFlag)) {
- return false;
- }
- if (!Objects.equals(this.pickupDatetime, other.pickupDatetime)) {
- return false;
- }
- if (!Objects.equals(this.dropoffDatetime, other.dropoffDatetime)) {
- return false;
- }
- if (!Objects.equals(this.passengerCount, other.passengerCount)) {
- return false;
- }
- if (!Objects.equals(this.tripTimeInSecs, other.tripTimeInSecs)) {
- return false;
- }
- if (!Objects.equals(this.tripDistance, other.tripDistance)) {
- return false;
- }
- if (!Objects.equals(this.pickupLongitude, other.pickupLongitude)) {
- return false;
- }
- if (!Objects.equals(this.pickupLatitude, other.pickupLatitude)) {
- return false;
- }
- if (!Objects.equals(this.dropoffLongitude, other.dropoffLongitude)) {
- return false;
- }
- if (!Objects.equals(this.dropoffLatitude, other.dropoffLatitude)) {
- return false;
- }
- return true;
- }
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(medallion).append(",");
- sb.append(hackLicense).append(",");
- sb.append(vendorId).append(",");
- sb.append(rateCode).append(",");
- sb.append(storeAndFwdFlag).append(",");
- sb.append(pickupDatetime).append(",");
- sb.append(dropoffDatetime).append(",");
- sb.append(passengerCount).append(",");
- sb.append(tripTimeInSecs).append(",");
- sb.append(tripDistance).append(",");
- sb.append(pickupLongitude).append(",");
- sb.append(pickupLatitude).append(",");
- sb.append(dropoffLongitude).append(",");
- sb.append(dropoffLatitude);
- return sb.toString();
- }
- @Override
- public int compareTo(Zadatak2DEBSOutput o) {
- int cmp = medallion.compareTo(o.medallion);
- if (cmp != 0) {
- return cmp;
- }
- cmp = hackLicense.compareTo(o.hackLicense);
- if (cmp != 0) {
- return cmp;
- }
- cmp = vendorId.compareTo(o.vendorId);
- if (cmp != 0) {
- return cmp;
- }
- cmp = rateCode.compareTo(o.rateCode);
- if (cmp != 0) {
- return cmp;
- }
- cmp = storeAndFwdFlag.compareTo(o.storeAndFwdFlag);
- if (cmp != 0) {
- return cmp;
- }
- cmp = pickupDatetime.compareTo(o.pickupDatetime);
- if (cmp != 0) {
- return cmp;
- }
- cmp = dropoffDatetime.compareTo(o.dropoffDatetime);
- if (cmp != 0) {
- return cmp;
- }
- cmp = passengerCount.compareTo(o.passengerCount);
- if (cmp != 0) {
- return cmp;
- }
- cmp = tripTimeInSecs.compareTo(o.tripTimeInSecs);
- if (cmp != 0) {
- return cmp;
- }
- cmp = tripDistance.compareTo(o.tripDistance);
- if (cmp != 0) {
- return cmp;
- }
- cmp = pickupLongitude.compareTo(o.pickupLongitude);
- if (cmp != 0) {
- return cmp;
- }
- cmp = pickupLatitude.compareTo(o.pickupLatitude);
- if (cmp != 0) {
- return cmp;
- }
- cmp = dropoffLongitude.compareTo(o.dropoffLongitude);
- if (cmp != 0) {
- return cmp;
- }
- return dropoffLatitude.compareTo(o.dropoffLatitude);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement