マッパーが取得する行数を制限しようとしています。 私のコードは次のようになります:サンプルの最後の行でhadoop入力形式をNLineInputFormatに設定するにはどうすればよいですか?
package com.iathao.mapreduce;
import java.io.IOException;
import java.net.MalformedURLException;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.lib.NLineInputFormat;
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.regexp.RESyntaxException;
import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException;
public class Main {
public static void main(String[] args) throws FailingHttpStatusCodeException, MalformedURLException, IOException, RESyntaxException {
try {
if (args.length != 2) {
System.err.println("Usage: NewMaxTemperature <input path> <output path>");
System.exit(-1);
}
Job job = new Job();
job.setJarByClass(Main.class);
job.getConfiguration().set("mapred.max.map.failures.percent", "100");
// job.getConfiguration().set("mapred.map.max.attempts", "10");
//NLineInputFormat. .setNumLinesPerSplit(job, 1);
job.setInputFormatClass(NLineInputFormat.class);
(job.setInputFormatClass(NLineInputFormat.class);)私は次のエラーを取得:
The method setInputFormatClass(Class<? extends InputFormat>) in the type Job is not applicable for the arguments (Class<NLineInputFormat>)
は私が何とか間違っを取得しましたがNLineInputFormatクラス?
実際、問題は、hadoop 0.20の新しいAPIでNLineInputFormatが実装されていないことでした。不運、私は今古いAPIを使用するつもりだ –
0.21は新しいAPIを持っていますが、安定版ではありません。 trunkまたは0.23ブランチからコードをダウンロードし、Linuxマシンでビルドすることもできます。トランクまたは0.23ブランチからコードを取得すると、多くの新機能にアクセスできます。しかし、トランクや0.23支店は変化を続けており、しばらくの間安定した状態にはありません。 –