2017-01-18 7 views
2

を構築するには?このように、日付を処理するために)mapDriver.withOutput(new IntWritable(1981), new Text("Mercurey"));どのように、私はこのコードで助けを必要としてくださいbuildOutputValue方法

とbuildOutputValue(する必要があります:マッパーでの出力は次のようであることを知って

List<Text> values = new ArrayList<Text>(); values.add(new Text("Pommard")); values.add(new Text("Gentil")); reduceDriver.withInput(new IntWritable(1980), values);

と減速して出力することは、このようなものです:

あなたがimplemことができ、事前

答えて

1

で​​

感謝以下のようにそれをENT:

パブリッククラスThirdQueryReducerが リデューサー{

private NullWritable nullWritableKey = NullWritable.get(); 
private Text outputValue = new Text(); 

private StringBuilder buildOutputValue(IntWritable key, 
     StringBuilder reduceValueBuilder, Text value) { 
    return reduceValueBuilder.append(value); 
} 

@Override 
public void reduce(IntWritable key, Iterable<Text> values, Context context) 
     throws IOException, InterruptedException { 
    Iterator<Text> valueIter = values.iterator(); 
    StringBuilder reduceValueBuilder = new StringBuilder(); 
    while (valueIter.hasNext()) { 
     buildOutputValue(key, valueIter.next(), reduceValueBuilder); 
     if (valueIter.hasNext()) { 
      reduceValueBuilder.append("\n"); 
     } 
    } 
    context.write(NullWritable.get(), new Text(reduceValueBuilder.toString())); 
} 

}

+0

感謝を拡張し、これは素晴らしい選択肢です! –

関連する問題