Skip to content

Add ACTOutputStream: build an ACT on disk from a stream of ordered paths#54

Open
imlvts wants to merge 1 commit into
Adam-Vandervorst:masterfrom
imlvts:act-output-stream
Open

Add ACTOutputStream: build an ACT on disk from a stream of ordered paths#54
imlvts wants to merge 1 commit into
Adam-Vandervorst:masterfrom
imlvts:act-output-stream

Conversation

@imlvts

@imlvts imlvts commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Streams strictly-increasing paths into an on-disk ArenaCompactTree without holding the trie in memory: a stack of in-construction frames (one per byte of the current path) is sealed bottom-up whenever the input diverges, writing each node's children contiguously as the format requires and folding non-branching runs into line nodes. Reuses the existing FileDumper writer, including line-data dedup.

    let mut b = ACTOutputStream::new("file.act")?;
    b.push("123")?;
    b.push_val("124", 42)?;
    let tree = b.finish()?;  // mmap-backed ArenaCompactTree

Also fixes a pre-existing out-of-bounds walk in get_val_at: it never checked the branch bytemask before index_of/nth_node, so looking up a byte absent from a branch with children stepped past the last sibling into unrelated arena bytes (subtract-overflow panic in debug builds).

Streams strictly-increasing paths into an on-disk ArenaCompactTree
without holding the trie in memory: a stack of in-construction frames
(one per byte of the current path) is sealed bottom-up whenever the
input diverges, writing each node's children contiguously as the
format requires and folding non-branching runs into line nodes.
Reuses the existing FileDumper writer, including line-data dedup.

    let mut b = ACTOutputStream::new("file.act")?;
    b.push("123")?;
    b.push_val("124", 42)?;
    let tree = b.finish()?;  // mmap-backed ArenaCompactTree

Also fixes a pre-existing out-of-bounds walk in get_val_at: it never
checked the branch bytemask before index_of/nth_node, so looking up a
byte absent from a branch with children stepped past the last sibling
into unrelated arena bytes (subtract-overflow panic in debug builds).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant