问题描述
public static class Map extends MapReduceBase implements Mapper
MapReduceBase , Mapper
和 JobConf
0.20.203
我们现在应该使用什么?
编辑1 - code> Mapper 和 MapReduceBase
,我发现我们只需要扩展 Mapper $ c
pre pre $ public static class Map扩展映射
< LongWritable,Text,Text,IntWritable> {
private static static IntWritable one = new IntWritable(1);
私人文字=新文字();
$ b $ 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);
}
}
}
编辑2 - 对于 JobConf
我们应该使用如下配置:
public static void main(String [ ] args)抛出异常{
Configuration conf = new Configuration();
工作职位=新职位(conf);
job.setMapperClass(WordCount.Map.class);
}
编辑3 - 根据新的API找到一个很好的教程:
Javadoc包含了如何使用这些depraceated类的instaed:
例如
已弃用。使用配置代替
编辑:当你使用maven和open类声明(F3)maven可以自动下载源码代码,您将看到javadoc注释的内容和解释。
public static class Map extends MapReduceBase implements Mapper
MapReduceBase
, Mapper
and JobConf
are deprecated in Hadoop 0.20.203.
What should we use now?
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 - 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);
}
Edit 3 - I found a good tutorial according to the new API : http://sonerbalkir.blogspot.com/2010/01/new-hadoop-api-020x.html
Javadoc contains info what to use instaed of this depraceated classes:
e.g. http://hadoop.apache.org/common/docs/current/api/org/apache/hadoop/mapred/JobConf.html
Deprecated. Use Configuration instead
Edit: 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已弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!