1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| public class FlowMapper extends Mapper<Long, Text,Text,FlowBean> { private Text outK = new Text(); private FlowBean outV = new FlowBean(); @Override protected void map(Long key, Text value, Mapper<Long, Text, Text, FlowBean>.Context context) throws IOException, InterruptedException { String line = value.toString(); String []split = line.split("\t"); String phone = split[1]; String up = split[split.length-3]; String down =split[split.length-2]; outK.set(phone); outV.setUpFlow(Long.parseLong(up)); outV.setDownFlow(Long.parseLong(down)); outV.setSumFlow(); context.write(outK,outV); } }
|