-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTVCleanDriverMapper.java
More file actions
39 lines (27 loc) · 1.02 KB
/
TVCleanDriverMapper.java
File metadata and controls
39 lines (27 loc) · 1.02 KB
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 java.util.StringTokenizer;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
// Set data types
public class TVMapper extends Mapper<LongWritable,Text,Text,Text>
{
private final static String DELIMITER = "|";
private final static String NA = "NA";
@Override
public void map(LongWritable key,Text value,Context context) throws IOException, InterruptedException
{
//Input format : Company|Product|Size|State|ZIP|Price
String strValue = value.toString();
System.out.println("Current value is "+strValue);
StringTokenizer tokenizer = new StringTokenizer(strValue, DELIMITER);
String strCompanyName = tokenizer.nextToken();
String strProductName = tokenizer.nextToken();
//Check if CompanyName or Product Name is 'NA'
if(!strCompanyName.equalsIgnoreCase(NA) && !strProductName.equalsIgnoreCase(NA))
{
context.write(value,null);
System.out.println("Put value "+strValue+" in context");
}
}
}