Skip to content

Multiple prefix zipper bugfixes - #210

Open
imlvts wants to merge 3 commits into
Adam-Vandervorst:masterfrom
imlvts:fix/prefix-zipper-view
Open

imlvts wants to merge 3 commits into
Adam-Vandervorst:masterfrom
imlvts:fix/prefix-zipper-view

Conversation

@imlvts

@imlvts imlvts commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator
  • Merges from a focus inside the prefix read the source's root node.
  • get_focus_at / try_borrow_focus / trie_ref_at_path ignore the prefix.
  • descend_until runs past the seam.
  • Sibling moves one byte off the prefix return None.
  • val_count off the prefix returns the source's whole count instead of 0.
  • make_map off the prefix returns the whole source, and over an empty source it drops the dangling stem.

A location on the prefix holds "the rest of the prefix, then the source", with
the source's root value at the end of the prefix; a location off the prefix
holds nothing.  The subtrie methods ignored both:

* get_focus / get_focus_at / try_borrow_focus forwarded to the source zipper,
  which sits at its own root while the focus is on the prefix, so graft,
  join_into, meet_into, subtract_into, restrict, graft_src_at and
  graft_masked_branches from the prefix read the source's root node, and from
  off the prefix the whole source.
* trie_ref_at_path handed the path to the source without stripping the rest
  of the prefix, and read the source off the prefix.
* make_map / try_make_map returned the whole source off the prefix, and over
  an empty source lost the prefix chain that path_exists and child_count
  report (it is a dangling path).  The source's root value was dropped unless
  graft_root_vals is on.

The prefix part is now built as an owned trie over the source's nodes
(stem_map), as get_trie_ref already did; try_borrow_focus answers None on the
prefix, since no stored node backs it.  A location on the prefix can't be
expressed with the source's TrieRefT, so PrefixZipper's TrieRefT becomes
TrieRef.
* descend_until (and descend_until_max_bytes) consumed the rest of the prefix
  and kept descending into the source even when the source's root has a value
  or branches; it now stops there.
* to_next_sibling_byte / to_prev_sibling_byte returned None one byte off the
  prefix, where the next prefix byte is a sibling, so to_next_step and
  to_prev_step from there stopped instead of moving to the next existing path.
* to_next_k_path from off the prefix gave up, although the prefix may sort
  after the focus and hold the next location at that depth.
* val_count off the prefix reported the source's whole count instead of 0.
@imlvts
imlvts marked this pull request as ready for review November 30, 2026 20:38
* Build prefix subtrie nodes directly with wrap_stem_node (LineListNode /
  DenseByteNode) instead of allocating a temporary PathMap + WriteZipper,
  grafting, double-cloning root values under graft_root_vals, and calling
  create_path.  Short-circuit on !source.path_exists() before touching
  get_focus / trie_ref / val, use get_focus directly for
  ZipperInfallibleSubtries, and propagate None from source.trie_ref() in
  ZipperSubtries::trie_ref.
* Implement descend_until_max_bytes_observed natively on PrefixZipper to
  avoid default TruncatingObserver overshoot-and-ascend and forward
  directly to source when in PrefixPos::Source.
* Clean up prefix/source dispatch in consume_prefix, descend_until_observed,
  descend_first_k_path_observed, to_next_k_path_observed, to_next_val_observed,
  to_sibling_byte, val_count, try_borrow_focus, get_focus_at, and
  trie_ref_at_path.
@imlvts
imlvts force-pushed the fix/prefix-zipper-view branch from f925353 to f78a8f5 Compare December 1, 2026 20:15
@Adam-Vandervorst

Copy link
Copy Markdown
Owner

The latest commit did fix the performance regression for make_map, but not try_make_map and trie_ref_at_path?

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