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

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

public class DataFileStream<D>
extends Object
implements Iterator<D>, Iterable<D>, Closeable

Streaming access to files written by DataFileWriter. Use DataFileReader for file-based input.

See Also:
DataFileWriter

Constructor Summary
protected DataFileStream(DatumReader<D> reader)
          create an unitialized DataFileStream
  DataFileStream(InputStream in, DatumReader<D> reader)
          Construct a reader for an input stream.
 
Method Summary
protected  void blockFinished()
           
 void close()
          Close this reader.
 byte[] getMeta(String key)
          Return the value of a metadata property.
 long getMetaLong(String key)
          Return the value of a metadata property.
 String getMetaString(String key)
          Return the value of a metadata property.
 Schema getSchema()
          Return the schema used in this file.
 boolean hasNext()
          True if more entries remain in this file.
 Iterator<D> iterator()
          Returns an iterator over entries in this file.
 D next()
          Read the next datum in the file.
 D next(D reuse)
          Read the next datum from the file.
 void remove()
          Not supported.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataFileStream

public DataFileStream(InputStream in,
                      DatumReader<D> reader)
               throws IOException
Construct a reader for an input stream. For file-based input, use DataFileReader. This will buffer, wrapping with a BufferedInputStream is not necessary.

Throws:
IOException

DataFileStream

protected DataFileStream(DatumReader<D> reader)
                  throws IOException
create an unitialized DataFileStream

Throws:
IOException
Method Detail

getSchema

public Schema getSchema()
Return the schema used in this file.


getMeta

public byte[] getMeta(String key)
Return the value of a metadata property.


getMetaString

public String getMetaString(String key)
Return the value of a metadata property.


getMetaLong

public long getMetaLong(String key)
Return the value of a metadata property.


iterator

public Iterator<D> iterator()
Returns an iterator over entries in this file. Note that this iterator is shared with other users of the file: it does not contain a separate pointer into the file.

Specified by:
iterator in interface Iterable<D>

hasNext

public boolean hasNext()
True if more entries remain in this file.

Specified by:
hasNext in interface Iterator<D>

next

public D next()
Read the next datum in the file.

Specified by:
next in interface Iterator<D>
Throws:
NoSuchElementException - if no more remain in the file.

next

public D next(D reuse)
       throws IOException
Read the next datum from the file.

Parameters:
reuse - an instance to reuse.
Throws:
NoSuchElementException - if no more remain in the file.
IOException

blockFinished

protected void blockFinished()
                      throws IOException
Throws:
IOException

remove

public void remove()
Not supported.

Specified by:
remove in interface Iterator<D>

close

public void close()
           throws IOException
Close this reader.

Specified by:
close in interface Closeable
Throws:
IOException


Copyright © 2010 The Apache Software Foundation