-
Notifications
You must be signed in to change notification settings - Fork 0
/
Task1 Map.java
30 lines (25 loc) · 935 Bytes
/
Task1 Map.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
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
public class Map extends
Mapper<Object,Text,Text,IntWritable>{
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(Object key,
Text value,
Context context ) throws
IOException, InterruptedException {
StringTokenizer itr = new StringTokenizer(value.toString().toLowerCase());
while(itr.hasMoreTokens()) {
word.set(itr.nextToken());
context.write(word,one);
}
}
}