You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-user@hadoop.apache.org by Delip Rao <de...@gmail.com> on 2008/12/09 01:06:23 UTC
File I/O from Mapper.configure
Hi,
How do I read regular text files on HDFS from configure() in my
Mapper? I am doing the following and my jobs appear to fail randomly
(i.e., it works sometimes but mostly fails).
FileSystem fs = FileSystem.get(conf);
Path path = new Path("/path/to/file.txt");
FSDataInputStream fsin = fs.open(path);
LineRecordReader reader = new LineRecordReader(fsin, 0, 4*1024, conf);
LongWritable key = new LongWritable();
Text value = new Text("");
while(reader.next(key, value)) {
String line = value.toString();
...
}
Thanks,
Delip