不推荐使用 MapReduceBase 和 Mapper

MapReduceBase and Mapper deprecated(不推荐使用 MapReduceBase 和 Mapper)
本文介绍了不推荐使用 MapReduceBase 和 Mapper的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..
public static class Map extends MapReduceBase implements Mapper

MapReduceBaseMapperJobConfHadoop 0.20.203 中已弃用.

MapReduceBase, Mapper and JobConf are deprecated in Hadoop 0.20.203.

我们现在应该使用什么?

What should we use now?

Edit 1 - 对于 MapperMapReduceBase,我发现我们只需要扩展 Mapper

Edit 1 - for the Mapper and the MapReduceBase, I found that we just need to extends the Mapper

public static class Map extends 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);
    }
  }
}

Edit 2 - 对于 JobConf 我们应该使用如下配置:

Edit 2 - For JobConf we should use configuration like this:

public static void main(String[] args) throws Exception {
        Configuration conf = new Configuration();
        Job job = new Job(conf);
        job.setMapperClass(WordCount.Map.class);
    }

编辑 3 - 我根据新 API 找到了一个很好的教程:http://sonerbalkir.blogspot.com/2010/01/new-hadoop-api-020x.html

Edit 3 - I found a good tutorial according to the new API : http://sonerbalkir.blogspot.com/2010/01/new-hadoop-api-020x.html

推荐答案

Javadoc 包含信息在这个过时的类中使用什么:

Javadoc contains info what to use instaed of this depraceated classes:

例如http://hadoop.apache.org/common/docs/current/api/org/apache/hadoop/mapred/JobConf.html

 Deprecated. Use Configuration instead

当你使用 maven 和开放类声明 (F3) 时,maven 可以自动下载源代码,你会看到带有解释的 javadoc 注释内容.

When you use maven and open class declaration (F3) maven can automatically download source code and you'll see content of javadoc comments with explanations.

这篇关于不推荐使用 MapReduceBase 和 Mapper的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

Sending a keyboard event from java to any application (on-screen-keyboard)(将键盘事件从 java 发送到任何应用程序(屏幕键盘))
How to make JComboBox selected item not changed when scrolling through its popuplist using keyboard(使用键盘滚动其弹出列表时如何使 JComboBox 所选项目不更改)
Capturing keystrokes without focus(在没有焦点的情况下捕获击键)
How can I position a layout right above the android on-screen keyboard?(如何将布局放置在 android 屏幕键盘的正上方?)
How to check for key being held down on startup in Java(如何检查在Java中启动时按住的键)
Android - Get keyboard key press(Android - 获取键盘按键)