-
Notifications
You must be signed in to change notification settings - Fork 0
/
StringLong.java
46 lines (37 loc) · 1015 Bytes
/
StringLong.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import org.apache.hadoop.io.WritableComparable;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
public class StringLong implements WritableComparable<StringLong> {
private String word;
private Long count;
public StringLong(){}
public StringLong(String w,Long c){
word= w;
count= c;
}
@Override
public int compareTo(StringLong other) {
return this.toString().compareTo(other.toString());
}
@Override
public void write(DataOutput dataOutput) throws IOException {
dataOutput.writeUTF(word);
dataOutput.writeLong(count);
}
@Override
public void readFields(DataInput dataInput) throws IOException {
word= dataInput.readUTF();
count= dataInput.readLong();
}
public long getCount (){
return count;
}
public String getWord (){
return word;
}
@Override
public String toString() {
return word+" "+count.toString();
}
}