-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDMap.java
More file actions
29 lines (20 loc) · 825 Bytes
/
DMap.java
File metadata and controls
29 lines (20 loc) · 825 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
package ufl.cloudcomp;
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
public class DMap extends Mapper<Object, Text, Text, IntWritable>{
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
@Override
public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
String line = value.toString();
//Tokenize each line of input on white spaces as well as standard punctuation marks
StringTokenizer tokenizer = new StringTokenizer(line, " \t\n\r\f,.:;?![]'");
while (tokenizer.hasMoreTokens()) {
word.set(tokenizer.nextToken());
context.write(word, one); //emit a key value of <<word>, 1>
}
}
}