Class DataFileReader<D>

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

public class DataFileReader<D> extends DataFileStream<D> implements FileReader<D>
Random access to files written with DataFileWriter.
See Also:
  • Constructor Details

    • DataFileReader

      public DataFileReader(File file, DatumReader<D> reader) throws IOException
      Construct a reader for a file. For example,if you want to read a file record,you need to close the resource. You can use try-with-resource as follows:
       try (FileReader dataFileReader =
       DataFileReader.openReader(file,datumReader)) { //Consume the reader } catch
       (IOException e) { throw new RunTimeIOException(e,"Failed to read metadata for
       file: %s", file); }
      
       
      Throws:
      IOException
    • DataFileReader

      public DataFileReader(SeekableInput sin, DatumReader<D> reader) throws IOException
      Construct a reader for a file. For example,if you want to read a file record,you need to close the resource. You can use try-with-resource as follows:
       try (FileReader dataFileReader =
       DataFileReader.openReader(file,datumReader)) { //Consume the reader } catch
       (IOException e) { throw new RunTimeIOException(e,"Failed to read metadata for
       file: %s", file); }
      
       
      Throws:
      IOException
    • DataFileReader

      protected DataFileReader(SeekableInput sin, DatumReader<D> reader, boolean closeOnError, byte[] magic) throws IOException
      Construct a reader for a file. Please close resource files yourself.
      Throws:
      IOException
    • DataFileReader

      protected DataFileReader(SeekableInput sin, DatumReader<D> reader, DataFileStream.Header header) throws IOException
      Construct using a DataFileStream.Header. Does not call sync(long) or seek(long).
      Throws:
      IOException
  • Method Details