Class AvroRowReader
java.lang.Object
dev.hardwood.avro.AvroRowReader
- All Implemented Interfaces:
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, decimals
as ByteBuffer), matching the behavior of parquet-java's
AvroReadSupport.
try (AvroRowReader reader = AvroReaders.createRowReader(fileReader)) {
while (reader.hasNext()) {
GenericRecord record = reader.next();
long id = (Long) record.get("id");
}
}
-
Method Summary
-
Method Details
-
hasNext
public boolean hasNext()Check if there are more rows to read.- Returns:
- true if there are more rows
-
next
public org.apache.avro.generic.GenericRecord next()Advance to the next row and return it as a GenericRecord.- Returns:
- the current row as a GenericRecord
-
getSchema
public org.apache.avro.Schema getSchema()Returns the Avro schema used for materialization.- Returns:
- the Avro record schema
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-