ProviceCountMapper.java
package os.bigdata.provincflowcount
import java.io.IOException
import org.apache.commons.lang.StringUtils
import org.apache.hadoop.io.LongWritable
import org.apache.hadoop.io.Text
import org.apache.hadoop.mapreduce.Mapper
public class ProviceCountMapper extends Mapper<LongWritable, Text, Text, FlowBean>{
private Text k = new Text()
private FlowBean bean = new FlowBean()
@Override
protected void map(LongWritable key, Text value, Context context)throws IOException, InterruptedException {
String line = value.toString()
String[] fields = StringUtils.split(line,'\t')
String phone = fields[1]
long upflow = Long.parseLong(fields[fields.length-3])
long downflow = Long.parseLong(fields[fields.length-2])
bean = new FlowBean(upflow,downflow)
k.set(phone)
bean.set(upflow, downflow)
context.write(k, bean)
}
}
ProviceCountReducer.java
import java.io.IOException;
import org.apache.hadoop.io.Text;
i