public static class Map extends Mapper {
Text mk = new Text();
public void map(Object key, Text value, Context context)
throws IOException, InterruptedException {
try {
String[] line = value.toString().split("\t");
while (line != null) {
String one = line[0] + "\t" + line[1] + "\t" + line[2];
String qm = line[3];
String tg = line[4] + "\t" + line[5];
System.out.println(one + "\t" + tg);
if (qm.contains("*")) {
String[] two = qm.split("*");
for (String sign : two) {
mk.set(one + "\t" + sign + "\t" + tg);
}
} else {
mk.set(one + "\t" + qm + "\t" + tg);
}
context.write(mk, NullWritable.get());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
看看哪里出错,改一下
原文件实例数据
00022 000CE34D03F8B551F2346D19D8379B33 2013-10-09 [大天开]*[开天] F 车主
00022 000CE34D03F6B551F9904D19D8379B33 2013-10-09 [大天开]*[开天] X 新老用户
想要的到的数据
00022 000CE34D03F8B551F2346D19D8379B33 2013-10-09 [大天开] F 车主
00022 000CE34D03F8B551F2346D19D8379B33 2013-10-09 [开天] F 车主
00022 000CE34D03F6B551F9904D19D8379B33 2013-10-09 [大天开] X 新老用户
00022 000CE34D03F6B551F9904D19D8379B33 2013-10-09 [开天] X 新老用户