-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRailMapper.java
More file actions
33 lines (23 loc) · 946 Bytes
/
RailMapper.java
File metadata and controls
33 lines (23 loc) · 946 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
package de.tuberlin.dbpra.mapreduce.rail;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
// Bin mir nicht sicher ob wir die Statiche Methode Tokenizer brauchen.
//import org.apache.tools.ant.filters.TokenFilter.StringTokenizer;
import java.io.IOException;
import java.util.*;
public class RailMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
// These values wild build my <key, value> tuples
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
@Override
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String line = value.toString();
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
word.set(tokenizer.nextToken());
context.write(word, one);
}
}
}