MapReduceプログラムを実行しています。私はKEYVALUEのペアの形式で入力テキストファイルを与える必要があります。そのように私が書く場合Mapreduceでjob.setInputFormatClassを設定する際にエラーが発生しました
job.setInputFormatClass(KeyValueTextInputFormat.class);
私はInputFormatを使用することはできませんエラーを表示しています。 とにかく入力のフォーマットをKeyValueTextInputFormatとして設定する必要があります どうすればいいですか?何か案が ?????
マイコードが
`
package com.iot.dictionary;
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.mapred.KeyValueTextInputFormat;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
import com.iot.dictionary.Dictionary.AllTranslationsReducer;
import com.iot.dictionary.Dictionary.WordMapper;
public class Driver2 {
public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
Configuration conf = new Configuration();
String[] otherArgs = new GenericOptionsParser(conf, args).getRemainingArgs();
if (otherArgs.length != 2) {
System.err.println("Usage: wordcount <in> <out>");
System.exit(2);
}
Job job = new Job(conf, "dictionary");
System.out.println("Job-> "+job.toString());
job.setJarByClass(Dictionary.class);
job.setMapperClass(WordMapper.class);
job.setReducerClass(AllTranslationsReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
job.setInputFormatClass(KeyValueTextInputFormat.class);
FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
}
`
私がインポートしても、同じコンパイラエラーが発生します。 KeyValueInputFormatをジョブに設定するにはどうすればよいですか? – Sri
質問を編集して、インポートしたパッケージとともに使用している基本コードを入力してください。 –
私が推測したように、パッケージのインポートに問題があります。私は私の答えを編集して、見てください。ありがとう。 –