Interface RowReader

All Superinterfaces:
AutoCloseable, Closeable, FieldAccessor, StructAccessor

public interface RowReader extends StructAccessor, Closeable

Provides row-oriented iteration over a Parquet file.

A RowReader is a stateful, mutable view providing access to the current row in the iterator. The values returned by its accessors change between calls of next().

Usage example:

try (RowReader rowReader = fileReader.rowReader()) {
    while (rowReader.hasNext()) {
        rowReader.next();
        long id = rowReader.getLong("id");
        PqStruct address = rowReader.getStruct("address");
        String city = address.getString("city");
    }
}
  • Method Details

    • hasNext

      boolean hasNext() throws IOException

      Check if there are more rows to read.

      Reaches the file when the current batch runs out, so it can fail the way any read can.

      Returns:
      true if there are more rows available
      Throws:
      IOException - if the bytes could not be read
      ParquetReadException - if the file's bytes are not what a Parquet file can say: a footer or a page index that will not parse, a dictionary page the metadata places outside its column chunk, a page whose checksum fails, values that do not decode under the encoding declared for them. In a multi-file read this covers a later file that is not Parquet at all, or whose schema cannot be reconciled with the first file's
    • next

      void next() throws IOException
      Advance to the next row. Must be called before accessing row data. Call hasNext() before every next(): next() does not load rows itself.
      Throws:
      NoSuchElementException - if no row is available to next() without a preceding hasNext(): at the end of the current batch, or on a filtered read when hasNext() has not selected the next matching row
      IOException - if the bytes could not be read
      ParquetReadException - if the file's bytes are not what a Parquet file can say: a footer or a page index that will not parse, a dictionary page the metadata places outside its column chunk, a page whose checksum fails, values that do not decode under the encoding declared for them. In a multi-file read this covers a later file that is not Parquet at all, or whose schema cannot be reconciled with the first file's
    • close

      void close() throws IOException
      Releases the resources held by this reader. Idempotent: calling it more than once has no further effect.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException - if a file this reader owns could not be closed