Class DataFileStream<D>

java.lang.Object
org.apache.avro.file.DataFileStream<D>
All Implemented Interfaces:
Closeable, AutoCloseable, 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:
  • Constructor Details

  • Method Details

    • getHeader

      public DataFileStream.Header getHeader()
      A handle that can be used to reopen this stream without rereading the head.
    • getSchema

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

      public List<String> getMetaKeys()
      Return the list of keys in the metadata
    • 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
    • nextBlock

      public ByteBuffer nextBlock() throws IOException
      Expert: Return the next block in the file, as binary-encoded data.
      Throws:
      IOException
    • getBlockCount

      public long getBlockCount()
      Expert: Return the count of items in the current block.
    • getBlockSize

      public long getBlockSize()
      Expert: Return the size in bytes (uncompressed) of the current block.
    • 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 AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException