API reference
The avro package, from avro 0.4.4, as published on mojoshelf (commit db833d86ddbd), by mojo doc from Mojo 1.2.0.
Source.
Apache Avro in pure Mojo — the avro package of avro.mojo.
Part of magmalake: data lake building blocks in Mojo.
from avro import DataFileReader
var r = DataFileReader.open("manifest.avro")
while r.has_next():
var rec = r.next()
print(rec.field("manifest_path").as_string())
Value is the general reader. When the schema is known and the file is
large — a scan planner walking manifests, say — RecordCursor compiles the
schema into a decode plan once and then reads records into reused buffers,
about ten times faster and with no per-record allocation:
from avro import RecordCursor
var c = RecordCursor.open("manifest.avro", ["manifest_path"])
var path = c.plan.slot_of("manifest_path")
while c.next():
print(c.get_str(path))
Everything reachable from this module works on the null and deflate block
codecs, which need nothing but the sibling deflate.mojo tin — raw DEFLATE,
pure Mojo, no FFI. snappy and zstandard live in avro.ext_snappy /
avro.ext_zstd, which pull in snappy.mojo and zstd.mojo.
inflate and deflate themselves are no longer re-exported here. They moved
to deflate.mojo in avro 0.4.0, because parquet.mojo and iceberg.mojo
wanted raw DEFLATE without wanting Avro. Import them from deflate.
Modules
-
avro.codecObject Container File block codecs. 1 struct · 1 trait · 1 function -
avro.crc32CRC-32 (IEEE 802.3, the zlib/gzip polynomial). 1 function -
avro.cursorRecordCursor— a schema-compiled, allocation-free Avro reader. 7 structs · 1 function -
avro.datafileAvro Object Container Files — the reader and the writer. 2 structs · 3 functions -
avro.decoderThe Avro binary decoder. 1 struct -
avro.encoderThe Avro binary encoder — the inverse ofavro.decoder. 1 struct · 1 function -
avro.jsonA small, self-contained JSON reader/writer. 2 structs · 2 functions -
avro.resolveSchema resolution — reading data written with one schema as another. 2 structs · 2 functions -
avro.schemaAvro schema parsing and printing. 4 structs · 6 functions -
avro.valueValue— a dynamically typed Avro datum. 5 structs