2017-04-13 5 views
0

私はワードカウントHadoopのためのJavaファイルをコンパイルするんだけど、それはそれはエラーをスローコンパイルだとき:エラー:JavaのHadoopのに期待<identifier>

CountBook.java:33: error: expected public void reduce(Text_key,Iteratorvalues,OutputCollectoroutput,Reporter reporter)throws IOException

これは私のコード

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); 
} 
} 

です私はクラスパスライブラリのためにhadoop-core-1.2.1.jarを使用し、centos 7で実行しています

+1

パブリッククラスをパブリッククラス内に埋め込むように見えますが、パブリッククラスはすべて独自のファイルにする必要があるため、これを行うことはできません –

答えて

1

現在あなたは:

reduce(Text_key, 
     Iterator<IntWritable>values, 
     OutputCollector<text,intWritable>output, 
     Reporter reporter) 

それは次のようになります。

reduce(Text key, 
     Iterator<IntWritable> values, 
     OutputCollector<Text,IntWritable> output, 
     Reporter reporter) 

主な違いはkeyはそれとTextとcapatilizedするOutputCollector<>必要とするタイプの間のスペースを必要としています。

関連する問題