-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUsers.java
More file actions
38 lines (28 loc) · 882 Bytes
/
Copy pathUsers.java
File metadata and controls
38 lines (28 loc) · 882 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
33
34
35
36
37
38
import java.io.IOException;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
public class Users extends Mapper <Object, Text, Text, Text>
{
static String head1;
public static String getHead()
{
return head1;
}
public void map(Object key, Text value, Context context) throws IOException, InterruptedException
{
//Mapper for user_age table
System.out.println("-----------------------------------This is users mapper process--------------------------------------------------");
String record = value.toString();
String[] parts = record.split("\t");
String strKey = key.toString();
//If header then store in static variable else write in buffer for the reducer
if (Integer.parseInt(strKey) == 0)
{
head1= parts[1];
}
else
{
context.write(new Text(parts[0]), new Text("userInfo\t" + parts[1]));
}
}
}