-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBattingMapper.java
More file actions
51 lines (24 loc) · 839 Bytes
/
BattingMapper.java
File metadata and controls
51 lines (24 loc) · 839 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
39
40
41
42
43
44
45
46
47
48
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;
import org.apache.commons.logging.*;
public class BattingMapper extends Mapper<LongWritable, Text, Text, Text>
{
@Override
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String line = value.toString();
try {
String [] tokens = line.split("\\,+");
String year = tokens[1];
String player = tokens[0];
String runs = tokens[8];
//int batt;
//batt = Integer.parseInt(tokens[7]);
context.write(new Text(year), new Text(runs+" "+player));
}catch (ArrayIndexOutOfBoundsException e) {
// e.printStackTrace();
}
}
}