-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSumCountPair.java
More file actions
executable file
·51 lines (37 loc) · 868 Bytes
/
SumCountPair.java
File metadata and controls
executable file
·51 lines (37 loc) · 868 Bytes
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
47
48
49
50
package calculateAverage;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import org.apache.hadoop.io.Writable;
public class SumCountPair implements Writable {
private int sum;
private int count;
public SumCountPair() {
this.sum = 0;
this.count = 0;
}
public SumCountPair(int sum, int count) {
this.sum = sum;
this.count = count;
}
@Override
public void write(DataOutput out) throws IOException {
out.writeInt(sum);
out.writeInt(count);
}
@Override
public void readFields(DataInput in) throws IOException {
sum = in.readInt();
count = in.readInt();
}
public int getSum() {
return this.sum;
}
public int getCount() {
return this.count;
}
@Override
public String toString() {
return sum+" "+count+":"+((double)sum/count);
}
}