Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Lazy Access to Field Dictionary #34

@agavra

Description

@agavra

Today when we deserialize an ImprintRecord it deserializes the entire field dictionary:

imprint/src/serde.rs

Lines 457 to 467 in 5d921ab

let mut directory = Vec::new();
let (count, count_size) = varint::decode(bytes.clone())?;
bytes.advance(count_size);
bytes_read += count_size;
for _ in 0..count {
let (entry, entry_size) = DirectoryEntry::read(bytes.clone())?;
bytes.advance(entry_size);
bytes_read += entry_size;
directory.push(entry);
}

Instead, we should just load the bytes into a struct and binary search on that when accessing fields, deserializing (and potentially caching the result) of a field id lookup only when necessary. This is in line with the ethos of Imprint, which optimizes for use cases that only read a few fields in a potentially large field dictionary.

We could consider making this configurable for the use case (eager/lazy deserialization of the field dictionary).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions