Interface RowReader
- All Superinterfaces:
AutoCloseable, Closeable, FieldAccessor, StructAccessor
Provides row-oriented iteration over a Parquet file.
A RowReader is a stateful, mutable view providing access to the current row
in the iterator: its accessors read the row next() moved to. A value an accessor
has returned does not change when the reader moves on, and can be held. A binary
value (getBinary, or getRawValue of a binary column) is a new byte[] per call,
which the caller owns. A PqStruct, PqList or
PqMap reads the batch of rows it was obtained from, and keeps that
batch in memory while it is reachable; to keep a few values of many rows, copy them
out instead. A value can be handed to another thread and read
there while this reader moves on; neither this reader nor a value is safe for use by
several threads at once.
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 Summary
Methods inherited from interface FieldAccessor
getBinary, getBoolean, getDate, getDecimal, getDouble, getFieldCount, getFieldName, getFloat, getInt, getInterval, getLocalTimestamp, getLong, getRawValue, getString, getTime, getTimestamp, getUuid, getValue, getVariant, isNullMethods inherited from interface StructAccessor
getBinary, getBoolean, getDate, getDecimal, getDouble, getFile, getFile, getFloat, getInt, getInterval, getList, getList, getLocalTimestamp, getLong, getMap, getMap, getRawValue, getString, getStruct, getStruct, getTime, getTimestamp, getUuid, getValue, getVariant, isNull
-
Method Details
-
hasNext
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 readParquetReadException- 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
Advance to the next row. Must be called before accessing row data. CallhasNext()before everynext():next()does not load rows itself.- Throws:
NoSuchElementException- if no row is available tonext()without a precedinghasNext(): at the end of the current batch, or on a filtered read whenhasNext()has not selected the next matching rowIOException- if the bytes could not be readParquetReadException- 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
Releases the resources held by this reader. Idempotent: calling it more than once has no further effect, and a call on another thread while a close runs, such as theParquetFileReader's, returns once that close has completed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException- if a file this reader owns could not be closed
-