org.apache.avro.file
Class DataFileReader<D>

java.lang.Object
  extended by org.apache.avro.file.DataFileStream<D>
      extended by org.apache.avro.file.DataFileReader<D>
All Implemented Interfaces:
Closeable, Iterable<D>, Iterator<D>

public class DataFileReader<D>
extends DataFileStream<D>

Random access to files written with DataFileWriter.

See Also:
DataFileWriter

Constructor Summary
DataFileReader(File file, DatumReader<D> reader)
          Construct a reader for a file.
DataFileReader(SeekableInput sin, DatumReader<D> reader)
          Construct a reader for a file.
 
Method Summary
protected  void blockFinished()
           
 boolean pastSync(long position)
          Return true if past the next synchronization point after a position.
 void seek(long position)
          Move to a specific, known synchronization point, one returned from DataFileWriter.sync() while writing.
 void sync(long position)
          Move to the next synchronization point after a position.
 
Methods inherited from class org.apache.avro.file.DataFileStream
close, getMeta, getMetaLong, getMetaString, getSchema, hasNext, iterator, next, next, remove
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataFileReader

public DataFileReader(File file,
                      DatumReader<D> reader)
               throws IOException
Construct a reader for a file.

Throws:
IOException

DataFileReader

public DataFileReader(SeekableInput sin,
                      DatumReader<D> reader)
               throws IOException
Construct a reader for a file.

Throws:
IOException
Method Detail

seek

public void seek(long position)
          throws IOException
Move to a specific, known synchronization point, one returned from DataFileWriter.sync() while writing. If synchronization points were not saved while writing a file, use {#sync(long)} instead.

Throws:
IOException

sync

public void sync(long position)
          throws IOException
Move to the next synchronization point after a position. To process a range of file entires, call this with the starting position, then check pastSync(long) with the end point before each call to DataFileStream.next().

Throws:
IOException

blockFinished

protected void blockFinished()
                      throws IOException
Overrides:
blockFinished in class DataFileStream<D>
Throws:
IOException

pastSync

public boolean pastSync(long position)
                 throws IOException
Return true if past the next synchronization point after a position.

Throws:
IOException


Copyright © 2010 The Apache Software Foundation