Skip to content

Preserve Unicode segments when extending trie leaves - #139

Merged
mcculls merged 1 commit into
mainfrom
mcculls/trie-unicode-segments
Oct 19, 2026
Merged

mcculls merged 1 commit into
mainfrom
mcculls/trie-unicode-segments

Conversation

@mcculls

@mcculls mcculls commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

What Does This Do

Pass the leaf-segment context explicitly to appendLeaf instead of inferring it from the next data character.

Motivation

When extending a collapsed leaf, the next character can belong to another branch. If that Unicode character had the leaf-marker bit set, appendLeaf misinterpreted it as a marker, corrupted mappings, and caused later insertions to throw an array bounds exception.

Additional Notes

Regression tests cover characters around the marker boundary, short and longer extensions, and subsequent insertions.

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
  4. Preserve Unicode segments when extending trie leaves (this PR)
  5. Generate a zero-branch root for empty tries
  6. Branch-count limit

This PR targets mcculls/trie-builder-isolation.

Contributor Checklist

  • 84 trie tests and the Java formatting check passed.

@mcculls
mcculls force-pushed the mcculls/trie-builder-isolation branch from 5a85d45 to 22ae36d Compare October 19, 2026 16:37
Base automatically changed from mcculls/trie-builder-isolation to main October 19, 2026 16:38
Pass the leaf-segment context to appendLeaf instead of inferring it from
the next data character, which may belong to another branch and have the
leaf-marker bit set.

Cover characters around the marker boundary, short and longer
extensions, and subsequent insertions.
@mcculls
mcculls force-pushed the mcculls/trie-unicode-segments branch from 2367fab to 948af7b Compare October 19, 2026 16:39
@mcculls
mcculls merged commit 79b2c2d into main Oct 19, 2026
6 checks passed
@mcculls
mcculls deleted the mcculls/trie-unicode-segments branch October 19, 2026 16:45
@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