私たち全員が知っているように、これは
public static class SReducer extends MapReduceBase implements Reducer<Text, Text, Text, Text>
{
public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException
{
StringBuilder sb = new StringBuilder();
while (key.hasNext())
{
sb.append(key.next().toString());
}
output.collect(key, new Text(sb.toString()));
}
}
また
public static class Reduce extends MapReduceBase implements Reducer<Text, Text, Text, Text>
{
public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, Text> output, Reporter reporter) throws IOException
{
boolean start = true;
StringBuilder sb = new StringBuilder();
while (values.hasNext())
{
if(!start)
{
start=false;
sb.append(values.next().toString());
}
}
output.collect(key, new Text(sb.toString()));
}
}
これは、出力で重複する「値」を排除するために使用する一種のレデューサー関数です。しかし、重複した「キー」を排除するにはどうすればよいですか? 何か案が?ありがとう。
PS: 詳細情報: 私の < key,value > ペアでは、キーにはリンクが含まれ、値には単語が含まれます。しかし、私の出力では、各単語は 1 回しか出現しませんが、多くの重複したリンクが表示されます。