[英]error: <identifier> expected in java hadoop
I'm compiling a java file for word count hadoop, but when it's compiling it throws an error: 我正在为字数hadoop编译一个java文件,但是在编译时会抛出错误:
CountBook.java:33: error: expected public void reduce(Text_key,Iteratorvalues,OutputCollectoroutput,Reporter reporter)throws IOException
CountBook.java:33:错误:预期的公共空白减少(Text_key,Iteratorvalues,OutputCollectoroutput,Reporter记者)引发IOException
this is my code 这是我的代码
public class CountBook
{
public static class EMapper extends MapReducebase implements
Mapper<LongWritable,Text,Text,IntWritable>
{
private final static Intwritable one = new Intwritable(1);
public void map(LongWritable key,Text value,OutputCollector<Text,IntWritable>output,Reporter reporter)throws IOException
{
String line = value.toString();
String[] Data = line.split("\";\"");
output.collect(new text(Data[0]),one);
}
}
public static class EReduce extends MapReduceBase implements
Reducer<Text,IntWritable,Text,IntWritable>
{
public void reduce(Text_key,Iterator<IntWritable>values,OutputCollector<text,intWritable>output,Reporter reporter)throws IOException
{
Text key=_key;
int authid=0;
while(values.hasNext())
{
IntWritable value = (IntWritable)values.next();
authid+=value.get();
}
output.collect(key,new intWritable(authid));
}
}
public static void main(String args[])throws Exception
{
JobConf conf = new JbConf(CountBook.class);
conf.setjobName("CountBookByAuthor");
conf.setOutputkeyClass(Text.class);
conf.setOutputValueClass(IntWritable.class);
conf.setMapperClass(EMapper.class);
conf.setCombinerClass(EReduce.class);
conf.setReducerClass(EReducer.class);
conf.setOutputFormat(TextOutputFormat.class);
FileInputFormat.setInputPaths(conf,new path(args[0]));
FileOutputFormat.setOutputPath(conf,new Path(args[1]));
JobCLient.runJob(conf);
}
}
I'm using hadoop-core-1.2.1.jar for classpath library and running in centos 7 我正在将hadoop-core-1.2.1.jar用于类路径库并在centos 7中运行
You currently have: 您目前有:
reduce(Text_key,
Iterator<IntWritable>values,
OutputCollector<text,intWritable>output,
Reporter reporter)
It should be: 它应该是:
reduce(Text key,
Iterator<IntWritable> values,
OutputCollector<Text,IntWritable> output,
Reporter reporter)
The main differences being key
needs a space between it and Text
and the types in OutputCollector<>
need to be capatilized. 主要区别在于
key
需要在key
和Text
之间留一个空格,并且必须对OutputCollector<>
的类型进行电容化。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.