Skip to content

Extract MergeLadder from MergeBatcher; split Extractor from Merger - #938

Merged
frankmcsherry merged 1 commit into
master-nextfrom
merge-ladder
Oct 16, 2026
Merged

frankmcsherry merged 1 commit into
master-nextfrom
merge-ladder

Conversation

@frankmcsherry

Copy link
Copy Markdown
Member

Summary

The merge batcher's geometric ladder of chains becomes MergeLadder, a type other batchers can use.
The ladder holds no opinion about how updates leave it; that opinion stays with MergeBatcher.
The first other user is the corgi half join's batcher (#937), which keeps chains in time order and releases prefixes from the fronts of chains rather than merging everything at each extraction.

Changes

  • MergeLadder<M: Merger> holds the chains with their cached weights, the stash, the merger, and the size accounting.
  • Its public methods are new, insert_chain, merge_all, chains, and retain_chains.
  • retain_chains lets a caller remove updates from each chain and re-accounts the chain for the logger.
  • A chain keeps the weight it was pushed with, so the ladder stays logarithmic in the updates inserted; chains left empty are removed.
  • MergeBatcher is a chunker, a ladder, and the carve by frontier, with unchanged behavior, including the stash shared between merging and extraction.
  • Merger keeps Chunk, merge, len, and allocation.
  • Time and extract move to a new Extractor: Merger, which only MergeBatcher requires.
  • VecMerger and ChunkMerger implement both; their bodies are unchanged.

Breaking change

Implementors of Merger outside this repository move type Time and fn extract into an impl Extractor.

Testing

The workspace builds, and every test passes.
The two existing MergeBatcher frontier tests now push chains through the ladder.

🤖 Generated with Claude Code

The merge batcher's geometric ladder of chains is now `MergeLadder`, which holds no opinion about how updates leave it.
`MergeBatcher` is a chunker, a ladder, and the carve by frontier, and behaves as before.
The ladder offers `insert_chain`, `merge_all`, `chains`, and `retain_chains`; the last lets a batcher remove updates from the fronts of chains, keeping the weights chains were pushed with.

`Merger` keeps `Chunk`, `merge`, `len`, and `allocation`.
`Time` and `extract` move to `Extractor: Merger`, which only `MergeBatcher` requires.
Implementors of `Merger` outside this repository move those two items into an `impl Extractor`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@frankmcsherry
frankmcsherry merged commit b9e7528 into master-next Oct 16, 2026
6 checks passed
@frankmcsherry
frankmcsherry deleted the merge-ladder branch October 16, 2026 17:01
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