16 package uk.ac.cam.eng.extraction.hadoop.datatypes;
18 import java.io.DataInput;
19 import java.io.DataOutput;
20 import java.io.IOException;
22 import org.apache.hadoop.io.Writable;
32 class PairWritable<
F extends Writable, S extends Writable> implements
38 public static <F extends Writable, S extends Writable> PairWritable<F, S> createPair(
40 return new PairWritable<F, S>(f, s);
49 public int hashCode() {
52 result = prime * result + ((first == null) ? 0 : first.hashCode());
53 result = prime * result + ((second == null) ? 0 : second.hashCode());
63 public boolean equals(Object obj) {
68 if (getClass() != obj.getClass())
70 PairWritable<?, ?> other = (PairWritable<?, ?>) obj;
72 if (other.first != null)
74 }
else if (!first.equals(other.first))
77 if (other.second != null)
79 }
else if (!second.equals(other.second))
84 public PairWritable(
F first, S second) {
90 public PairWritable(Class<F> classF, Class<S> classS) {
92 this.first = classF.newInstance();
93 this.second = classS.newInstance();
94 }
catch (InstantiationException | IllegalAccessException e) {
95 throw new RuntimeException(e);
99 public void set(
F f, S s) {
104 public void setFirst(
F f) {
108 public void setSecond(S s) {
113 public void readFields(DataInput in)
throws IOException {
114 first.readFields(in);
115 second.readFields(in);
119 public void write(DataOutput out)
throws IOException {
124 public F getFirst() {
128 public S getSecond() {
134 StringBuilder builder =
new StringBuilder(first.toString());
135 builder.append(
"\t").append(second.toString());
136 return builder.toString();
std::string toString(const T &x, uint pr=2)
Converts an arbitrary type to string Converts to string integers, floats, doubles Quits execution if ...