# avro API reference

> The `avro` package, from avro 0.4.4, as published on mojoshelf (commit db833d86ddbd), by `mojo doc` from Mojo 1.2.0.

## Modules

- [avro.codec](https://magmalake.dev/s/avro/api/codec.md): Object Container File block codecs.
- [avro.crc32](https://magmalake.dev/s/avro/api/crc32.md): CRC-32 (IEEE 802.3, the zlib/gzip polynomial).
- [avro.cursor](https://magmalake.dev/s/avro/api/cursor.md): `RecordCursor` — a schema-compiled, allocation-free Avro reader.
- [avro.datafile](https://magmalake.dev/s/avro/api/datafile.md): Avro Object Container Files — the reader and the writer.
- [avro.decoder](https://magmalake.dev/s/avro/api/decoder.md): The Avro binary decoder.
- [avro.encoder](https://magmalake.dev/s/avro/api/encoder.md): The Avro binary encoder — the inverse of `avro.decoder`.
- [avro.json](https://magmalake.dev/s/avro/api/json.md): A small, self-contained JSON reader/writer.
- [avro.resolve](https://magmalake.dev/s/avro/api/resolve.md): Schema resolution — reading data written with one schema as another.
- [avro.schema](https://magmalake.dev/s/avro/api/schema.md): Avro schema parsing and printing.
- [avro.value](https://magmalake.dev/s/avro/api/value.md): `Value` — a dynamically typed Avro datum.

Apache Avro in pure Mojo — the `avro` package of avro.mojo.

Part of magmalake: data lake building blocks in Mojo.

```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:

```mojo
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`.
