当我在基于Hadoop 0.20 API的Hadoop in Action手册中尝试Map Reduce编程示例时,我收到了错误
java.io.IOException:从map中键入不匹配的值:expected org.apache.hadoop.io.IntWritable,recieved org.apache.hadoop.io.Text
但据我检查,我正在通过一切正常.如果有人可以帮助我,这将是非常有帮助的.
这是代码.它与书中的代码相同.
@SuppressWarnings("unused")
public class CountPatents extends Configured implements Tool {
@SuppressWarnings("deprecation")
public static class MapClass extends MapReduceBase implements Mapper<Text, Text, Text, Text> {
public void map(Text key, Text value,OutputCollector<Text, Text> output,Reporter reporter) throws IOException {
output.collect(value, key);
}
}
public static class Reduce extends MapReduceBase implements Reducer<Text, Text, Text, IntWritable> {
public void reduce(Text key, Iterator<Text> values, OutputCollector<Text, IntWritable> output, Reporter reporter) throws IOException {
int count=0;
while(values.hasNext()){
count=count+1;
values.next(); …Run Code Online (Sandbox Code Playgroud)