<legend id='ffKNt'><style id='ffKNt'><dir id='ffKNt'><q id='ffKNt'></q></dir></style></legend>

        <bdo id='ffKNt'></bdo><ul id='ffKNt'></ul>

        <i id='ffKNt'><tr id='ffKNt'><dt id='ffKNt'><q id='ffKNt'><span id='ffKNt'><b id='ffKNt'><form id='ffKNt'><ins id='ffKNt'></ins><ul id='ffKNt'></ul><sub id='ffKNt'></sub></form><legend id='ffKNt'></legend><bdo id='ffKNt'><pre id='ffKNt'><center id='ffKNt'></center></pre></bdo></b><th id='ffKNt'></th></span></q></dt></tr></i><div id='ffKNt'><tfoot id='ffKNt'></tfoot><dl id='ffKNt'><fieldset id='ffKNt'></fieldset></dl></div>

        <tfoot id='ffKNt'></tfoot>

        <small id='ffKNt'></small><noframes id='ffKNt'>

      1. Hadoop:在 MapReduce 期间 OutputCollector 如何工作?

        时间:2023-09-26

              <tfoot id='ZtXHX'></tfoot>

              1. <legend id='ZtXHX'><style id='ZtXHX'><dir id='ZtXHX'><q id='ZtXHX'></q></dir></style></legend>
                • <bdo id='ZtXHX'></bdo><ul id='ZtXHX'></ul>
                  <i id='ZtXHX'><tr id='ZtXHX'><dt id='ZtXHX'><q id='ZtXHX'><span id='ZtXHX'><b id='ZtXHX'><form id='ZtXHX'><ins id='ZtXHX'></ins><ul id='ZtXHX'></ul><sub id='ZtXHX'></sub></form><legend id='ZtXHX'></legend><bdo id='ZtXHX'><pre id='ZtXHX'><center id='ZtXHX'></center></pre></bdo></b><th id='ZtXHX'></th></span></q></dt></tr></i><div id='ZtXHX'><tfoot id='ZtXHX'></tfoot><dl id='ZtXHX'><fieldset id='ZtXHX'></fieldset></dl></div>
                • <small id='ZtXHX'></small><noframes id='ZtXHX'>

                    <tbody id='ZtXHX'></tbody>
                  本文介绍了Hadoop:在 MapReduce 期间 OutputCollector 如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想知道 Map 函数中是否使用了 OutputCollector 的实例"输出:output.collect(键,值)这个 - 输出 - 将键值对存储在某处?即使它发送到reducer函数,它们也必须是一个中间文件,对吧?那些文件是什么?它们是否可见并由程序员决定?我们在 main 函数中指定的 OutputKeyClass 和 OutputValueClasses 是这些存储的地方吗?[Text.class 和 IntWritable.class]

                  I want to know if the OutputCollector's 'instance' output used in the map function: output.collect(key, value) this -output- be storing the key value pairs somewhere? even if it emits to the reducer function, their must be an intermediate file, right? What are those files? Are they visible and decided by the programer? Are the OutputKeyClass, and OutputValueClasses which we specify in the main function these places of storage? [Text.class and IntWritable.class]

                  我给出了 MapReduce 中 Word Count 示例的标准代码,我们可以在网络的许多地方找到它.

                  Im giving the standard code for Word Count example in MapReduce, which we can find at many places in the net.

                  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 reduce(Text key, Iterator<IntWritable> values, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
                  int sum = 0;
                  while (values.hasNext()) {
                  sum += values.next().get();
                  }
                  output.collect(key, new IntWritable(sum));
                  }
                  }
                  
                  public static void main(String[] args) throws Exception {
                  JobConf conf = new JobConf(WordCount.class);
                  conf.setJobName("wordcount");
                  
                  conf.setOutputKeyClass(Text.class);
                  conf.setOutputValueClass(IntWritable.class);
                  
                  conf.setMapperClass(Map.class);
                  conf.setCombinerClass(Reduce.class);
                  conf.setReducerClass(Reduce.class);
                  
                  conf.setInputFormat(TextInputFormat.class);
                  conf.setOutputFormat(TextOutputFormat.class);
                  
                  FileInputFormat.setInputPaths(conf, new Path(args[0]));
                  FileOutputFormat.setOutputPath(conf, new Path(args[1]));    
                  JobClient.runJob(conf);
                  }
                  }
                  

                  推荐答案

                  Map 函数的输出存储在临时中间文件中.这些文件由 Hadoop 透明处理,因此在正常情况下,程序员无权访问它.如果您对每个映射器内部发生的事情感到好奇,您可以查看相应作业的日志,您可以在其中找到每个映射任务的日志文件.

                  The output from the Map function is stored in Temporary Intermediate Files. These files are handled transparently by Hadoop, so in a normal scenario, the programmer doesn't have access to that. If you're curious about what's happening inside each mapper, you can review the logs for the respective job where you'll find a log file for each map task.

                  如果您想控制临时文件的生成位置并访问它们,您必须创建自己的 OutputCollector 类,我不知道这有多容易.

                  If you want to control where the temporary files are generated, and have access to them, you have to create your own OutputCollector class, and I don't know how easy that is.

                  如果想看源码,可以使用svn来获取.我认为它可以在这里找到:http://hadoop.apache.org/common/version_control.html.

                  If you want to have a look at the source code, you can use svn to get it. I think it is available here: http://hadoop.apache.org/common/version_control.html.

                  这篇关于Hadoop:在 MapReduce 期间 OutputCollector 如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Hadoop:JPS 找不到安装的 Java 下一篇:在 Hadoop 中传播自定义配置值

                  相关文章

                  最新文章

                  <small id='ideKr'></small><noframes id='ideKr'>

                    <tfoot id='ideKr'></tfoot>
                    <i id='ideKr'><tr id='ideKr'><dt id='ideKr'><q id='ideKr'><span id='ideKr'><b id='ideKr'><form id='ideKr'><ins id='ideKr'></ins><ul id='ideKr'></ul><sub id='ideKr'></sub></form><legend id='ideKr'></legend><bdo id='ideKr'><pre id='ideKr'><center id='ideKr'></center></pre></bdo></b><th id='ideKr'></th></span></q></dt></tr></i><div id='ideKr'><tfoot id='ideKr'></tfoot><dl id='ideKr'><fieldset id='ideKr'></fieldset></dl></div>
                    • <bdo id='ideKr'></bdo><ul id='ideKr'></ul>

                      <legend id='ideKr'><style id='ideKr'><dir id='ideKr'><q id='ideKr'></q></dir></style></legend>