org.apache.nutch.io
Class MapFile.Reader

java.lang.Object
  extended byorg.apache.nutch.io.MapFile.Reader
Direct Known Subclasses:
ArrayFile.Reader, SetFile.Reader
Enclosing class:
MapFile

public static class MapFile.Reader
extends Object

Provide access to an existing map.


Constructor Summary
MapFile.Reader(NutchFileSystem nfs, String dirName)
          Construct a map reader for the named map.
MapFile.Reader(NutchFileSystem nfs, String dirName, WritableComparator comparator)
          Construct a map reader for the named map using the named comparator.
 
Method Summary
 void close()
          Close the map.
 void finalKey(WritableComparable key)
          Reads the final key from the file.
 Writable get(WritableComparable key, Writable val)
          Return the value for the named key, or null if none exists.
 Class getKeyClass()
          Returns the class of keys in this file.
 Class getValueClass()
          Returns the class of values in this file.
 boolean next(WritableComparable key, Writable val)
          Read the next key/value pair in the map into key and val.
 void reset()
          Re-positions the reader before its first key.
 boolean seek(WritableComparable key)
          Positions the reader at the named key, or if none such exists, at the first entry after the named key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapFile.Reader

public MapFile.Reader(NutchFileSystem nfs,
                      String dirName)
               throws IOException
Construct a map reader for the named map.


MapFile.Reader

public MapFile.Reader(NutchFileSystem nfs,
                      String dirName,
                      WritableComparator comparator)
               throws IOException
Construct a map reader for the named map using the named comparator.

Method Detail

getKeyClass

public Class getKeyClass()
Returns the class of keys in this file.


getValueClass

public Class getValueClass()
Returns the class of values in this file.


reset

public void reset()
           throws IOException
Re-positions the reader before its first key.

Throws:
IOException

finalKey

public void finalKey(WritableComparable key)
              throws IOException
Reads the final key from the file.

Parameters:
key - key to read into
Throws:
IOException

seek

public boolean seek(WritableComparable key)
             throws IOException
Positions the reader at the named key, or if none such exists, at the first entry after the named key. Returns true iff the named key exists in this map.

Throws:
IOException

next

public boolean next(WritableComparable key,
                    Writable val)
             throws IOException
Read the next key/value pair in the map into key and val. Returns true if such a pair exists and false when at the end of the map

Throws:
IOException

get

public Writable get(WritableComparable key,
                    Writable val)
             throws IOException
Return the value for the named key, or null if none exists.

Throws:
IOException

close

public void close()
           throws IOException
Close the map.

Throws:
IOException


Copyright © 2006 The Apache Software Foundation