我面臨一定的誤差,同時設置我的工作自定義InputFormat錯誤設置job.setInputFormatClass
下面是我的代碼
package com.nline_delimiter;
import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
public class NL_driver {
public static void main(String [] args) throws IOException, InterruptedException, ClassNotFoundException
{
Configuration conf=new Configuration(true);
Job job_run =new Job(conf);
job_run.setJobName("nline input format each line seperate wth delimiter");
job_run.setJarByClass(NL_driver.class);
job_run.setMapperClass(NL_mapper.class);
job_run.setReducerClass(NL_reducer.class);
job_run.setInputFormatClass(NL_inputformatter.class);;
job_run.setMapOutputKeyClass(Text.class);
job_run.setMapOutputValueClass(IntWritable.class);
job_run.setOutputKeyClass(Text.class);
job_run.setOutputValueClass(IntWritable.class);
FileInputFormat.setInputPaths(job_run,new Path("/home/hduser/input_formatter_usage.txt"));
FileOutputFormat.setOutputPath(job_run, new Path("/home/hduser/input_formatter_usage"));
job_run.waitForCompletion(true);
}
}
行
job_run.setInputFormatClass(NL_inputformatter.class)
顯示錯誤
NL_inputformatter是一個自定義的Inputformatter類,它擴展了FileInputFor墊
有什麼我需要導入的setInputFormatClass,因爲Eclipse中的默認錯誤檢查要求我將setInputFormatClass更改爲setOutFormatClass但不要求任何導入。
NL_inputformatter的源代碼如下。
package com.nline_delimiter;
import java.io.IOException;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.FileInputFormat;
import org.apache.hadoop.mapred.FileSplit;
import org.apache.hadoop.mapred.InputSplit;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.RecordReader;
import org.apache.hadoop.mapred.Reporter;
public class NL_inputformatter extends FileInputFormat<Text, IntWritable>{
@Override
public RecordReader<Text, IntWritable> getRecordReader(InputSplit input,
JobConf job_run, Reporter reporter) throws IOException {
// TODO Auto-generated method stub
System.out.println("I am Inside the NL_inputformatter class");
reporter.setStatus(input.toString());
return new NL_record_reader(job_run, (FileSplit)input);
}
}
您的幫助,將不勝感激。
說明了什麼錯誤?請發佈編譯器錯誤和NL_inputformatter源代碼。 –
按照要求我有加法器NI_inputformatter的源代碼....那麼錯誤是--------類型Job中的setInputFormatClass(Class <?extends InputFormat>)方法不適用於參數( Class) –
Sam