Class AvroRowReader
java.lang.Object
dev.hardwood.avro.AvroRowReader
- All Implemented Interfaces:
Closeable, AutoCloseable
Reads Parquet rows as Avro GenericRecord instances.
Wraps a Hardwood RowReader and materializes each row into a
GenericRecord using the converted Avro schema. Values are stored
in Avro's raw representation (e.g. timestamps as Long, bytes-backed
decimals as ByteBuffer, fixed-typed columns as GenericData.Fixed).
parquet-java's AvroReadSupport uses the same representations, except that it
reads decimals over INT32 and INT64 as Integer and Long, and reads an
INT96 as a fixed only when parquet.avro.readInt96AsFixed is set.
try (AvroRowReader reader = AvroReaders.rowReader(fileReader)) {
while (reader.hasNext()) {
GenericRecord record = reader.next();
long id = (Long) record.get("id");
}
}
-
Method Summary
-
Method Details
-
hasNext
Check if there are more rows to read.- Returns:
- true if there are more rows
- Throws:
IOException
-
next
Advance to the next row and return it as a GenericRecord.- Returns:
- the current row as a GenericRecord
- Throws:
IOException
-
getSchema
public org.apache.avro.Schema getSchema()Returns the Avro schema used for materialization.- Returns:
- the Avro record schema
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-