avro · API

avro.decoder

The Avro binary decoder.

A Decoder is a cursor over a Span[UInt8]: the primitive readers follow the spec's binary encoding (zigzag varints, little-endian IEEE floats, length-prefixed bytes, block-encoded arrays and maps), and read_value drives them from a parsed Schema.

Structs

Decoder

struct Decoder[origin: ImmOrigin]

A cursor over Avro binary data.

Implements Copyable, Movable

Fields
data: Span[UInt8, origin]
pos: Int

__init__

def __init__(out self, data: Span[UInt8, origin])
def __init__(out self, data: Span[UInt8, origin], pos: Int)

remaining

def remaining(self) -> Int

at_end

def at_end(self) -> Bool

read_byte

def read_byte(mut self) -> UInt8

read_boolean

def read_boolean(mut self) -> Bool

read_long

def read_long(mut self) -> Int64

A zigzag-encoded variable-length integer.

read_int

def read_int(mut self) -> Int32

read_float

def read_float(mut self) -> Float32

read_double

def read_double(mut self) -> Float64

read_fixed

def read_fixed(mut self, n: Int) -> List[UInt8]

read_bytes

def read_bytes(mut self) -> List[UInt8]

read_string

def read_string(mut self) -> String

skip

def skip(mut self, n: Int)

read_block_count

def read_block_count(mut self) -> Int64

Read one array/map block header.

A negative count means the writer also wrote the block's byte size, which is consumed here and discarded (it is only a skip hint).

read_value

def read_value(mut self, schema: Schema) -> Value

Decode one datum described by schema's root.

read_value_at

def read_value_at(mut self, schema: Schema, i: Int) -> Value

decode_into

def decode_into(mut self, schema: Schema, i: Int, mut arena: List[ValueNode]) -> Int

Decode node i straight into arena, returning its index.

The building block avro.resolve shares for the parts of a resolved read that need no conversion.

skip_value

def skip_value(mut self, schema: Schema, i: Int)

Advance past one datum without materialising it.