-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitMapper.java
More file actions
26 lines (19 loc) · 777 Bytes
/
Copy pathInitMapper.java
File metadata and controls
26 lines (19 loc) · 777 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
package edu.upenn.nets212.hw3;
import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
public class InitMapper extends Mapper<LongWritable, Text, Text, Text> {
public void map (LongWritable key, Text value, Context context) throws IOException, InterruptedException{
String val = value.toString();
String[] edge = val.split("\t"); //split on tab
if (edge.length < 2) {
return;
}
Text user = new Text(edge[0]);
Text follows = new Text(edge[1]);
context.write(user, follows); //user follower adjacency list essentially
context.write(follows, new Text("")); //to account for if the user doesn't follow anyone
}
}