1. 问题描述
收集日志avro数据中有两个Map字段appInstall
、appUse
分别表示已安装的app、正在使用的app,且key值为app的名称,value值为app使用信息。现在要得到一份匹配上购物类app支付宝|京东|淘宝|天猫
的用户名单;MapReduce 解决办法如下:
public static class M extends Mapper<String, Pair, String, Text> {
Text text = new Text();
@SuppressWarnings("unchecked")
@Override
protected void map(String key, Pair value, Context context) throws IOException, InterruptedException {
Map data = value.fields.data;
String dvc = data.get("dvc").toString();
Map<String, Object> appInstall = (Map<String, Object>) data.get("appInstall");
Map<String, Object> appUse = (Map<String, Object>) data.get("appUse");