これは、いわゆる「新しいAPI」からのCombineFileInputFormatを使用する最も簡単な方法です。あなたの実際の入力形式はMyFormatであると仮定し、それが(例えば、SequenceFileInputFormat< MyKey, MyValue >
のいくつかのサブクラスであるかもしれない)MYKEYの鍵とMyValueの値で動作します。あなたの仕事のドライバで
public class CombinedMyFormat extends CombineFileInputFormat< MyKey, MyValue > {
// exists merely to fix the key/value types and
// inject the delegate format to the superclass
// if MyFormat does not use state, consider a constant instead
private static class CombineMyKeyMyValueReaderWrapper
extends CombineFileRecordReaderWrapper< MyKey, MyValue > {
protected CombineMyKeyMyValueReaderWrapper(
CombineFileSplit split, TaskAttemptContext ctx, Integer idx
) throws IOException, InterruptedException {
super(new MyFormat(), split, ctx, idx);
}
}
@Override
public RecordReader< MyKey, MyValue > createRecordReader(
InputSplit split, TaskAttemptContext ctx
) throws IOException {
return new CombineFileRecordReader< MyKey, MyValue >(
(CombineFileSplit)split, ctx, CombineMyKeyMyValueReaderWrapper.class
);
}
}
、あなたは今だけのMyFormat
ためCombinedMyFormat
にドロップすることができるはずです。 Hadoopが入力全体を1つの分割にまとめるのを防ぐには、max split size propertyも設定する必要があります。
「レコードごとに1つのファイル」の意味を詳しく説明できますか? –