hadoop-common-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Open Study" <open.st...@gmail.com>
Subject Re: MapFile usage
Date Wed, 04 Jul 2007 09:08:38 GMT
Hi Phantom

   To operate the Mapfile isn't difficult by itself, simply follow the order
1) create the mapfile writer or reader by specifying the JobConf, file
system, the path name of the mapfile. If creating the MapFile you also need
to specify the key class(shall implement
org.apache.hadoop.io.WritableComparable) and value class (shall implement

/* create the MapFile writer and write to it */
MapFile.Writer writer = new MapFile.Writer(conf, fs, dir,
                        MyKey.class, MyValue.class,
MyKey key = new MyKey();
MyValue value = new MyValue();
writer.append(key, value);

/* create the MapFile reader and read from it */
MapFile.Reader reader = new MapFile.Reader(fs, dir, conf);
MyKey key = new MyKey();
MyValue value = new MyValue();
while (reader.next(key, value))
    // do sth with the key and value

   You can also turn to the source code of Nutch,
org.apache.nutch.fetcher.FetcherOutputFormat for referrence.

On 7/3/07, Phantom <ghostwhoowalks@gmail.com> wrote:
> Would someone be kind enough to share with me any code/sample they have
> for
> using the MapFile class ?
> Thanks
> A

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message