我在java中使用mapreduce框架,我想创建一个定制的文件输入格式。假设我的文件格式如下:
7cjasjjr1#
我已经做过类似的事情了,这里我用“$$$”作为分隔符(我把它作为配置参数传递给job)。您可以在这里检查代码,并在同一个项目上检查代码的具体实现。我定制了读写器和输入格式。
vs91vp4v2#
在本例中,每个记录都被视为多行的数组。按照教程,我写了以下内容:
public class CustomInputFormat extends FileInputFormat<Text, IdxValues> { public RecordReader<Text, IdxValues> getRecordReader( InputSplit input, JobConf job, Reporter report) throws IOException { report.setStatus(input.toString()); return new CustomReader(job, (FileSplit)input); } }
public class CustomInputFormat extends FileInputFormat<Text, IdxValues> {
public RecordReader<Text, IdxValues> getRecordReader(
InputSplit input, JobConf job, Reporter report) throws IOException {
report.setStatus(input.toString());
return new CustomReader(job, (FileSplit)input);
}
现在我想知道应该如何实现customreader类,将[我真正想要的]和[以及另一部分]分别作为两个数组来读取?
yfjy0ee73#
$-标志-$什么我真正地希望$-标志-$和另一个零件
3条答案
按热度按时间7cjasjjr1#
我已经做过类似的事情了,这里我用“$$$”作为分隔符(我把它作为配置参数传递给job)。您可以在这里检查代码,并在同一个项目上检查代码的具体实现。我定制了读写器和输入格式。
vs91vp4v2#
在本例中,每个记录都被视为多行的数组。
按照教程,我写了以下内容:
现在我想知道应该如何实现customreader类,将[我真正想要的]和[以及另一部分]分别作为两个数组来读取?
yfjy0ee73#
$-标志-$
什么
我
真正地
希望
$-标志-$
和
另一个
零件