I want to enablement an IPFlow statistics
First column is serial number,second is phone number,third is upflow data,forth is downflow data.I want to run a mapreduce program that combines the upflow add the downflow data.If data isn't null I can run it out successful.
1,1120487,10,20
2,1120417,20,30
3,1120427,30,40
4,1120437,,50
public class FlowMapper extends Mapper<LongWritable, Text, IntWritable,FlowBean> {
IntWritable phone = new IntWritable();
FlowBean flowbean= new FlowBean();
@Override
protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
int arg1;
int arg2;
String[] arr = value.toString().split("\t");
phone.set(Integer.parseInt(arr[1]));
// System.out.println(Arrays.toString(arr));
// if(!Character.isDigit(Integer.parseInt(arr[2]))){
// arg1 = 0;
// System.out.println("come in ");
// }else{
// arg1 =Integer.parseInt(arr[2]);
// System.out.println("is this in your think");
// }
// if(arr[3] == null){
// arg2 = 0;
// }else{
// arg2 =Integer.parseInt(arr[3]);
// }
// System.out.println(arg1);
// System.out.println(arg2);
arg1 =Integer.parseInt(arr[2]);
arg2 =Integer.parseInt(arr[3]);
flowbean.set(arg1, arg2);
context.write(phone,flowbean);
}
}
As you can see,I tried in the comments section, but I failed.I want give number 0 when the data is