Skip to content

Generate a zero-branch root for empty tries - #140

Merged
mcculls merged 1 commit into
mainfrom
mcculls/trie-empty-generation
Oct 19, 2026
Merged

mcculls merged 1 commit into
mainfrom
mcculls/trie-empty-generation

Conversation

@mcculls

@mcculls mcculls commented Oct 17, 2026 •

Copy link
Copy Markdown
Collaborator

What Does This Do

Encode the empty root sentinel when generating Java source from an empty mapping. Both lookup overloads now return -1 for unmatched keys.

Motivation

The generator emitted an empty data array, but lookup expects a root branch count. Any nonempty lookup on the generated trie threw ArrayIndexOutOfBoundsException.

Additional Notes

The regression test generates and compiles an empty trie, then exercises both lookup overloads with empty and nonempty keys.

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
  5. Generate a zero-branch root for empty tries (this PR)
  6. Branch-count limit

This PR targets mcculls/trie-unicode-segments.

Contributor Checklist

  • 85 trie tests and the Java formatting check passed.

@mcculls
mcculls force-pushed the mcculls/trie-unicode-segments branch from 2367fab to 948af7b Compare October 19, 2026 16:39
Base automatically changed from mcculls/trie-unicode-segments to main October 19, 2026 16:45
Encode the empty root sentinel when generating Java source from an empty
mapping, so nonempty lookups return no match instead of reading past an
empty array.

Generate and compile an empty trie in a regression test and exercise
both lookup overloads.
@mcculls
mcculls force-pushed the mcculls/trie-empty-generation branch from 19d2d70 to a1d650a Compare October 19, 2026 16:48
@mcculls
mcculls merged commit d221974 into main Oct 19, 2026
6 checks passed
@mcculls
mcculls deleted the mcculls/trie-empty-generation branch October 19, 2026 16:53
@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