Skip to content

Preserve built tries when builders are modified - #138

Merged
mcculls merged 1 commit into
mainfrom
mcculls/trie-builder-isolation
Oct 19, 2026
Merged

mcculls merged 1 commit into
mainfrom
mcculls/trie-builder-isolation

Conversation

@mcculls

@mcculls mcculls commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

What Does This Do

Detach shared trie data and long-jump arrays before the first subsequent builder write. Previously built tries retain their values and offsets.

Motivation

Builders shared arrays with built tries. Overwrites changed existing tries, while branch extensions could update shared long-jump offsets and make existing trie lookups read past the data array.

Additional Notes

Copying is deferred until a builder writes after sharing its arrays. Regression tests cover repeated builds, overwrites, and long-jump updates for reused builders and builders created from existing tries.

Stack (merge in order):

  1. Preserve trie mappings when long-jump capacity is exhausted
  2. Fix long-jump table growth after compaction
  3. Preserve built tries when builders are modified (this PR)
  4. Preserve Unicode segments when extending trie leaves
  5. Generate a zero-branch root for empty tries
  6. Branch-count limit

This PR targets mcculls/trie-long-jump-growth.

Contributor Checklist

  • 81 trie tests and the Java formatting check passed.

@mcculls
mcculls force-pushed the mcculls/trie-long-jump-growth branch from 3199436 to d024306 Compare October 19, 2026 16:35
Base automatically changed from mcculls/trie-long-jump-growth to main October 19, 2026 16:36
Detach shared trie data and long-jump arrays before a builder modifies
them, keeping previously built tries immutable. Defer copying until the
first subsequent write.

Cover overwrites and long-jump updates for both reused builders and
builders created from an existing trie.
@mcculls
mcculls force-pushed the mcculls/trie-builder-isolation branch from 5a85d45 to 22ae36d Compare October 19, 2026 16:37
@mcculls
mcculls merged commit 66e7413 into main Oct 19, 2026
3 of 5 checks passed
@mcculls
mcculls deleted the mcculls/trie-builder-isolation branch October 19, 2026 16:38
@github-actions github-actions Bot added this to the 0.1.0 milestone Oct 19, 2026
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.

2 participants