}
final IntWritable one = new IntWritable(1);
// Define a map that counts and group by #chars of line
PCollection po1 = input.map(new DoFn() {
@Override
public void process(Object v, EmitFn emitter) {
StringTokenizer itr = new StringTokenizer(v.toString());
int length = 0;
while (itr.hasMoreTokens()) {
length += itr.nextToken().length();
}
emitter.emit(Pair.create(new IntWritable(length), one));
}
}, tableOf(integers(), integers()))
.groupByKey()
.map(countReduceToText, tableOf(integers(), strings()));
// Define a map that counts and group by #tokens of line
PCollection po2 = input.map(new DoFn() {
@Override
public void process(Object v, EmitFn emitter) {
StringTokenizer itr = new StringTokenizer(v.toString());
int length = 0;
while (itr.hasMoreTokens()) {
length ++;
itr.nextToken();
}
emitter.emit(Pair.create(new IntWritable(length), one));
}
}, tableOf(integers(), integers()))
.groupByKey()
.map(countReduceToText, tableOf(integers(), strings()));
// Define a map that counts appearances of chars
PCollection po3 = input.map(new DoFn() {
@Override
public void process(Object v, EmitFn emitter) {
StringTokenizer itr = new StringTokenizer(v.toString());
while (itr.hasMoreTokens()) {
String token = itr.nextToken();