我有一个问题.. 我怎样才能使用一个映射器和两个reducer 进行mapreduce 工作,而这两个reducer 输入都来自map 输出?每个减速器都有自己的输出?另一件事是映射器可以有2个或更多输入吗?
public static class dpred extends Reducer<Text, DoubleWritable, Text, DoubleWritable>
{
public void reduce1(Text key, Iterable<DoubleWritable> values, Context context) throws IOException, InterruptedException
{
double beta = 17.62;
DoubleWritable result1 = new DoubleWritable();
double mul = 1;
double res = 1;
for (DoubleWritable val : values){
// System.out.println(val.get());
mul *= val.get();
}
res = beta*mul;
result1.set(res);
context.write(key, result1);
}
///////////////////////////////////////////////////////////
public void reduce2(Text key, Iterable<DoubleWritable> values, Context context) throws IOException, InterruptedException
{
double landa = 243.12;
double sum = 0;
double res = 0;
DoubleWritable result2 = new DoubleWritable();
for (DoubleWritable val : values){
// System.out.println(val.get());
landa += val.get();
}
// System.out.println(sum);
result2.set(landa);
context.write(key, result2);
}
}