Mapper读取HBase数据
package MapReduce;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
import org.apache.hadoop.hbase.mapreduce.TableMapper;
import java.io.IOException;
public class CallMapper extends TableMapper{
//将log的caller,callee,time,dur提取出来,相当于将每一行数据读取出来放入到 phoneInfo 对象中。
private phoneInfo pp = new phoneInfo();
private phoneInfoDBWritable pDB = null;
@Override
protected void map(ImmutableBytesWritable key, Result value, Context context) throws IOException, InterruptedException {
//获取rowkey
String rowkey = new String(key.get());
//获取一行数据
Cell[] cells = value.rawCells();
// 获取的数据,通话时长,日期
String caller = "";
String callee = "";
String time = "";
String dur = "";
String flag = "";
String dateCallk = "";
//循环取出
for (Cell cell :cells){
// 取出行名称
String lineName = new String(CellUtil.cloneQualifier(cell));
// 判断打电话的人
if(lineName.equals("caller")){
caller = new String(Cell