Skip to main content

High-performance Avro encoding and decoding utilities.

This module provides optimized Avro serialization and deserialization using serde_avro_fast for best performance, with rayon parallelism for large batches.

Performance

  • Encoding: Uses serde_avro_fast for 2-3x faster encoding than apache_avro
  • Decoding: Uses serde_avro_fast + rayon for up to 8x faster decoding
  • Parallelism: Automatically enabled for batches above threshold (500 records)

These helpers split large batches over rayon’s threads, with the results of a sequential pass: records come back in order, and a batch with several bad records reports the first of them. Failures read “Could not encode object: …” and “Could not decode object: …”.

Usage

Encoding Records

Decoding Records

Constants

pub const PARALLEL_THRESHOLD: usize = 500;

Threshold for switching to parallel processing. Below this count, sequential processing is faster due to thread spawning overhead. Based on benchmarks: parallel becomes beneficial around 500 records.

Functions

Decodes binary Avro records to typed Rust structs.
Decodes binary Avro records in parallel using serde_avro_fast + rayon.
Decodes binary Avro records sequentially using serde_avro_fast.
Decodes a single binary Avro record using a pre-parsed schema.
Decodes binary Avro records using a pre-parsed serde_avro_fast schema.
Encodes Arc-wrapped records in parallel.
Encodes Arc-wrapped records, partitioning the batch over threads.
Encodes records to Avro binary format.
Encodes records in parallel using serde_avro_fast + rayon.
Encodes records, partitioning the batch over threads (non-Arc version).
Encodes records sequentially using serde_avro_fast.
Encodes a single record to Avro binary format.
Parses a schema string into a serde_avro_fast Schema for direct use.
Parses a schema string into a serde_avro_fast Schema.