2013-12-12 2 views
2

MapReduce 드라이버의 addInputPath 메소드에서 오류가 발생합니다. 내가 올바른 org.apache.hadoop.mapred.FileOutputFormat을 가져MapReduce 드라이버의 addInputPath에 오류가 발생했습니다.

package org.myorg; 

import org.apache.hadoop.conf.Configuration; 
import org.apache.hadoop.conf.Configured; 
import org.apache.hadoop.fs.Path; 
import org.apache.hadoop.io.IntWritable; 
import org.apache.hadoop.io.Text; 
import org.apache.hadoop.mapred.FileOutputFormat; 
import org.apache.hadoop.mapred.JobClient; 
import org.apache.hadoop.mapred.JobConf; 
import org.apache.hadoop.mapreduce.Job; 
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; 
import org.apache.hadoop.util.Tool; 
import org.apache.hadoop.util.ToolRunner; 

public class WordCount extends Configured implements Tool{ 
    public int run(String[] args) throws Exception 
    { 
      //creating a JobConf object and assigning a job name for identification purposes 
      JobConf conf = new JobConf(getConf(), org.myorg.WordCount.class); 
      conf.setJobName("WordCount"); 

      //Setting configuration object with the Data Type of output Key and Value 
      conf.setOutputKeyClass(Text.class); 
      conf.setOutputValueClass(IntWritable.class); 

      //Providing the mapper and reducer class names 
      conf.setMapperClass(WordCountMapper.class); 
      conf.setReducerClass(WordCountReducer.class); 

      //the hdfs input and output directory to be fetched from the command line 
      **FileInputFormat.addInputPath(conf, new Path(args[0]));** 
      FileOutputFormat.setOutputPath(conf, new Path(args[1])); 

      JobClient.runJob(conf); 
      return 0; 
    } 

    public static void main(String[] args) throws Exception 
    { 
      int res = ToolRunner.run(new Configuration(), new WordCount(),args); 
      System.exit(res); 
    } 
} 

: 오류는

"The method addInputPath(Job, Path) in the type FileInputFormat is not applicable for the arguments (JobConf, Path)" 

가 여기에 드라이버에 대한 내 코드입니다.

내 WordCountMapper가 올바르게 매퍼를 구현합니다.

FileOutputFormat.setOutputPath가 올바르게 작동합니다.

왜 addInputhPaths에서 오류가 발생합니까?

답변

7

기존 API (.mapred.)와 새 API (.mapreduce.)를 혼합하는 것이 문제입니다. 두 API는 호환되지 않습니다.

새 API의 모든 개체를 사용하고 이전 API의 개체는 사용하지 않는 것이 좋습니다. 즉, JobConf 또는 JobClient을 사용하지 마십시오. 대신 JobConfiguration을 사용하십시오. .mapreduce.이 아닌 Mapper, Reducer 등을 사용하고 있는지 확인하십시오..mapred.이 포함되어 있지 않은지 확인하십시오.

+0

고맙습니다.이 점에 관해서는 너무 혼란 스럽습니다. 이것은 그것을 지 웁니다. –

+0

대부분의 경우 이전 API의 존재를 완전히 무시합니다. –

+0

감사합니다. 너는 그것을 분명하게했다. – Neethu

관련 문제