-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMapper2.java
26 lines (26 loc) · 1.06 KB
/
Mapper2.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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.util.HashMap;
import java.util.StringTokenizer;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Mapper.Context;
import org.apache.hadoop.mapreduce.filecache.DistributedCache;
public class Mapper2 extends Mapper<Object, Text, Text, IntWritable>{
public void map(Object key,Text value,Context context) throws IOException, InterruptedException{
String[] data = value.toString().split("\t");
int reviewStat = Integer.parseInt(data[1]);
if(reviewStat == 0)
context.write(new Text("Neutral"),new IntWritable(1));
else if(reviewStat > 0)
context.write(new Text("Positive"),new IntWritable(1));
else
context.write(new Text("Negative"),new IntWritable(1));
}
}