Hi Ives,
Thanks a lot for your reply. But how should I claim the Map class? Currently
I have "public static class Map extends MapReduceBase implements
Mapper<BytesWritable, SequenceFile, SequenceFile, BytesWritable>". Does not
seem to be right. I am pretty new to this field. Many thanks in advance for
your help.


On Fri, Dec 18, 2009 at 11:27 AM, Ives Aerts
<[email protected]<ives.aerts%[email protected]>
> wrote:

> On Fri, Dec 18, 2009 at 5:20 PM, Cao Kang <[email protected]> wrote:
> > Is there any example how a sequence file can be read and split in hadoop?
> > Many thanks!
>
> That should be fairly easy. The following code reads all entries in a
> sequence file:
>
>        SequenceFile.Reader reader = new
> SequenceFile.Reader(path.getFileSystem(config), path, config);
>
>        Writable key = (Writable)reader.getKeyClass().newInstance();
>        Writable value = (Writable)reader.getValueClass().newInstance();
>
>        while(reader.next(key, value)) {
>            System.out.println(key + "\t" + value);
>        }
>
>        reader.close();
>
> Add some logic to partition the entries and write them out using a
> SequenceFile.Writer.
>
> --
> Cheers,
> -Ives
>

Reply via email to