Java 运行简单的Hadoop map/reduce教程

Java 运行简单的Hadoop map/reduce教程,java,hadoop,Java,Hadoop,你知道为什么简单的Hadoop map/reduce教程为我指出了一个错误吗。这是直接从Apache教程中复制的代码: public class Mining { public static class MapClass extends MapReduceBase implements Mapper<LongWritable, Text, Text, IntWritable> { private final static IntWritable one = new IntW

你知道为什么简单的Hadoop map/reduce教程为我指出了一个错误吗。这是直接从Apache教程中复制的代码:

public class Mining {

public static class MapClass 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(Mining.class);
    conf.setJobName("wordcount");

    conf.setOutputKeyClass(Text.class);
    conf.setOutputValueClass(IntWritable.class);

    conf.setMapperClass(MapClass.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);
}
}   

请检查一下您的进口商品。也许您在程序中混合了新旧API。此外,我建议您使用新的API,即mapreduce而不是mapred


HTH

我现在已经包括了我的导入内容。你认为mapred是问题的根源?我尝试将mapreduce更改为mapreduce,但现在所有的extends和implements部件都抱怨,因为它们需要mapred版本。如果要使用旧API,请确保没有从新API导入任何内容。以下是问题的确切答案:
The type Mapper is not generic; it cannot be parameterized with arguments <LongWritable, Text, Text, IntWritable>
import java.io.IOException;
import java.util.*;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.conf.*;
import org.apache.hadoop.io.*; 
import org.apache.hadoop.mapred.*;
import org.apache.hadoop.util.*;