org.apache.nutch.io
Class SequenceFile.Reader

java.lang.Object
  extended byorg.apache.nutch.io.SequenceFile.Reader
Enclosing class:
SequenceFile

public static class SequenceFile.Reader
extends Object

Writes key/value pairs from a sequence-format file.


Constructor Summary
SequenceFile.Reader(NutchFileSystem nfs, String file)
          Open the named file.
 
Method Summary
 void close()
          Close the file.
 Class getKeyClass()
          Returns the class of keys in this file.
 long getPosition()
          Return the current byte position in the input file.
 Class getValueClass()
          Returns the class of values in this file.
 int next(DataOutputBuffer buffer)
          Read the next key/value pair in the file into buffer.
 boolean next(Writable key)
          Read the next key in the file into key, skipping its value.
 boolean next(Writable key, Writable val)
          Read the next key/value pair in the file into key and val.
 void seek(long position)
          Set the current byte position in the input file.
 void sync(long position)
          Seek to the next sync mark past a given position.
 boolean syncSeen()
          Returns true iff the previous call to next passed a sync mark.
 String toString()
          Returns the name of the file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SequenceFile.Reader

public SequenceFile.Reader(NutchFileSystem nfs,
                           String file)
                    throws IOException
Open the named file.

Method Detail

close

public void close()
           throws IOException
Close the file.

Throws:
IOException

getKeyClass

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


getValueClass

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


next

public boolean next(Writable key)
             throws IOException
Read the next key in the file into key, skipping its value. True if another entry exists, and false at end of file.

Throws:
IOException

next

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

Throws:
IOException

next

public int next(DataOutputBuffer buffer)
         throws IOException
Read the next key/value pair in the file into buffer. Returns the length of the key read, or -1 if at end of file. The length of the value may be computed by calling buffer.getLength() before and after calls to this method.

Throws:
IOException

seek

public void seek(long position)
          throws IOException
Set the current byte position in the input file.

Throws:
IOException

sync

public void sync(long position)
          throws IOException
Seek to the next sync mark past a given position.

Throws:
IOException

syncSeen

public boolean syncSeen()
Returns true iff the previous call to next passed a sync mark.


getPosition

public long getPosition()
                 throws IOException
Return the current byte position in the input file.

Throws:
IOException

toString

public String toString()
Returns the name of the file.



Copyright © 2006 The Apache Software Foundation