我想知道OutputCollector的'实例'输出是否在map函数中使用:output.collect(key,value)this -output-在某处存储键值对?即使它发送到reducer函数,它们也必须是一个中间文件,对吧?那些文件是什么?它们是否可见并由程序员决定?我们在main函数中指定的OutputKeyClass和OutputValueClasses这些存储位置是什么?[Text.class和IntWritable.class]
我在MapReduce中给出了Word Count示例的标准代码,我们可以在网络的许多地方找到它.
public class WordCount {
public static class Map extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(LongWritable key, Text value, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
String line = value.toString();
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
word.set(tokenizer.nextToken());
output.collect(word, one);
}
}
}
public static class Reduce extends MapReduceBase implements Reducer<Text, IntWritable, Text, IntWritable> {
public void …Run Code Online (Sandbox Code Playgroud)