import java.io.IOException; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configured; import org.apache.hadoop.fs.Path; import org.apache.hadoop.io.*; import org.apache.hadoop.mapred.JobClient; import org.apache.hadoop.mapred.OutputCollector; import org.apache.hadoop.mapred.Reporter; import org.apache.hadoop.mapred.lib.MultipleTextOutputFormat; import org.apache.hadoop.mapreduce.*; import org.apache.hadoop.mapreduce.lib.input.FileInputFormat; import org.apache.hadoop.mapreduce.lib.input.TextInputFormat; import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat; import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat; import org.apache.hadoop.util.Tool; import org.apache.hadoop.util.ToolRunner; public class MultiFile extends Configured { public static class MapClass extends Mapper<LongWritable, Text, NullWritable, Text> { public void map(LongWritable key, Text value, OutputCollector<NullWritable, Text> output, Reporter reporter) throws IOException { output.collect(NullWritable.get(), value); } } public static class PartitionByCountryMTOF extends MultipleTextOutputFormat<NullWritable,Text> { protected String generateFileNameForKeyValue(NullWritable key, Text value, String filename) { String[] arr = value.toString().split(",", -1); String country = arr[4].substring(1,3); return country + "/" + filename; } } public static void main(String[] args) throws Exception { Configuration conf = new Configuration(); Job job = new Job(conf, "MultiFile"); job.setJarByClass(MultiFile.class); Path in = new Path(args[0]); Path out = new Path(args[1]); FileInputFormat.setInputPaths(job, in);//輸入路徑 FileOutputFormat.setOutputPath(job, out);//輸出路徑 job.setJobName("MultiFile");//job名稱 job.setMapperClass(MapClass.class); job.setInputFormatClass(TextInputFormat.class);//輸入格式 job.setOutputFormatClass(PartitionByCountryMTOF.class);//輸出格式設置 job.setMapOutputValueClass(LongWritable.class);// job.setOutputKeyClass(NullWritable.class);輸出key的類型 job.setOutputValueClass(Text.class);//輸出value的類型 job.setNumReduceTasks(0);//設置reduce個數 System.exit(job.waitForCompletion(true)?0:1); } }
job.setOutputFormatClass(PartitionByCountryMTOF.class);java
顯示The method setOutputFormatClass(Class<? extends OutputFormat>) in the type Job is apache
not applicable for the arguments (Class<MultiFile.PartitionByCountryMTOF>)app
請問怎麼解決??oop