java在mapreduce作业中设置自定义文件格式类

tquggr8v  于 2021-05-30  发布在  Hadoop
关注(0)|答案(1)|浏览(413)

我延长了一些时间 FileInputFormatXMLFileInputFormat . 问题是当我把这门课设置在 job ```
job.setInputFormatClass(XMLFileInputFormat.class);

我得到一些错误告诉它希望这个类扩展 `or.apache.hadoop.mapreduce.InputFormat` (但我查过了 `FileInputFormat` 工具 `InputFormat` )
这个班是这样安排的

public class XMLFileInputFormat extends FileInputFormat<NullWritable, BytesWritable> {

@Override
protected boolean isSplitable(FileSystem fs, Path filename) {
    return false; }

@Override
public RecordReader<NullWritable, BytesWritable> getRecordReader(
        InputSplit split, JobConf job, Reporter reporter) throws IOException {
    return new XMLFileRecordReader((FileSplit) split, job);
}

}

如何正确设置 `InputFormat` ?
sauutmhj

sauutmhj1#

请验证导入语句中的包结构。它应该是org.apache.hadoop.mapreduce.fileinputformat。
您可以导入:org.apache.hadoop.mapred.fileinputformat

相关问题