4

我有一个问题。

我需要两个文件作为 mapreduce 程序的输入。

@Override
public int run(String[] args) throws Exception {

    (argument skip)
    Job job1 = new Job();           
    job1.setJarByClass(CFRecommenderDriver.class);

    job1.setMapperClass(CFRecommenderMapper.class);     
    //job1.setReducerClass(CFRecommenderReducer.class);    

    job1.setMapOutputKeyClass(Text.class);
    job1.setMapOutputValueClass(TextDoublePairWritableComparable.class);

    //job1.setOutputKeyClass(TextTwoWritableComparable.class);
    //job1.setOutputValueClass(TextDoubleTwoPairsWritableComparable.class);

    MultipleInputs.addInputPath(job1, new Path(args[0]), FileInputFormat.class);
    MultipleInputs.addInputPath(job1, new Path(args[1]), FileInputFormat.class);

job1.setNumReduceTasks(0);

    boolean step1 = job1.waitForCompletion(true);
    if(!(step1)) return -1;

如果我使用以下命令运行程序:

hadoop jar mapreduce-0.1.jar cf /input/cf-re/data1 /input/cf-re/data2 /output/cf-r/data1

我收到以下错误:

2013-07-01 13:13:44.822 java[45783:1603] Unable to load realm info from SCDynamicStore
13/07/01 13:13:45 WARN mapred.JobClient: Use GenericOptionsParser for parsing the        arguments. Applications should implement Tool for the same.
 13/07/01 13:13:45 INFO mapred.JobClient: Cleaning up the staging area  hdfs://127.0.0.1:9000/tmp/hadoop- suhyunjeon/mapred/staging/suhyunjeon/.staging/job_201306191432_0218
 java.lang.RuntimeException: java.lang.InstantiationException
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:115)
at org.apache.hadoop.mapreduce.lib.input.MultipleInputs.getInputFormatMap(MultipleInputs.java:109)
at org.apache.hadoop.mapreduce.lib.input.DelegatingInputFormat.getSplits(DelegatingInputFormat.java:58)
at org.apache.hadoop.mapred.JobClient.writeNewSplits(JobClient.java:1024)
at org.apache.hadoop.mapred.JobClient.writeSplits(JobClient.java:1041)
at org.apache.hadoop.mapred.JobClient.access$700(JobClient.java:179)
at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:959)
at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:912)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1149)
at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:912)
at org.apache.hadoop.mapreduce.Job.submit(Job.java:500)
at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:530)
at org.ankus.hadoop.mapreduce.algorithm.cf.recommender.CFRecommenderDriver.run(CFRecommenderDriver.java:86)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:65)
at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:79)
at org.ankus.hadoop.mapreduce.algorithm.cf.recommender.CFRecommenderDriver.main(CFRecommenderDriver.java:49)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.util.ProgramDriver$ProgramDescription.invoke(ProgramDriver.java:68)
at org.apache.hadoop.util.ProgramDriver.driver(ProgramDriver.java:139)
at org.ankus.hadoop.mapreduce.MapReduceDriver.main(MapReduceDriver.java:64)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.util.RunJar.main(RunJar.java:156)
Caused by: java.lang.InstantiationException
at sun.reflect.InstantiationExceptionConstructorAccessorImpl.newInstance(InstantiationExceptionConstructorAccessorImpl.java:30)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:113)
... 29 more

我不知道究竟是什么问题。请帮我。

4

3 回答 3

7

您不能FileInputFormat直接使用抽象类。如果您的输入是文本,您可以使用org.apache.hadoop.mapreduce.lib.input.TextInputFormat. 例如,

MultipleInputs.addInputPath(job1, new Path(args[0]), TextInputFormat.class);
MultipleInputs.addInputPath(job1, new Path(args[1]), TextInputFormat.class);
于 2013-07-01T05:07:38.123 回答
2

这是您可以在工作中使用多个输入文件的方式:

job1.setInputFormatClass(TextInputFormat.class);

FileInputFormat.setInputPaths(job1, input_1 + ","
                + input_2);
于 2013-07-01T07:45:23.327 回答
0

我认为值得一提的是另一种可用于添加多个输入路径的方法,在我看来是最漂亮和最简单的:FileInputFormat.setInputPaths(Job job, Path... inputPaths)

签名告诉您,Path...您可以为此调用提供任意数量的 Path 对象。例子:

FileInputFormat.setInputPaths(job, new Path(args[0]), new Path(args[1]), new Path(args[2]));
于 2013-12-02T20:07:13.427 回答