Repository navigation
refactor(cmsheap)!: ASAPv1 only — drop the portable format, add goldens - #170
Closed
GordonYuanyc wants to merge 2 commits into
Closed
GordonYuanyc wants to merge 2 commits into
GordonYuanyc wants to merge 2 commits into
Conversation
CMSHeap serializes through ASAPv1 only. Removes message_pack_format::portable::countminsketch_topk (CountMinSketchWithHeap, CmsHeapItem, its wire DTOs and sketchlib_cms_heap_* helpers) and the crate-root re-exports. The e2e merge-and-wire test runs on CMSHeap over ASAPv1, and two CMSHeap golden fixtures are added (submodule bump). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The spec states the key comparison: signed keys by their two's-complement bit pattern read unsigned, floats by their bits, strings and bytes byte-wise with a proper prefix first. Three new golden fixtures pin i64 ties across zero and i64::MIN, string ties across case, length and prefix, and the empty-heap form (submodule bump). The docs defer the fixture list to the golden README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 6, 2026
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of the ASAPv1-only series: one PR per sketch group, each off
main. This one removes the portable Count-Min-with-heap format; ASAPv1 (0x03 0x00) is the only CMSHeap format left, and it gets its first goldens.Draft because of the heap tie-order question below.
Removed
message_pack_format::portable::countminsketch_topk:CountMinSketchWithHeap(incl.aggregate_topk,merge_refs,from_legacy_matrix,MessagePackCodec),CmsHeapItem,WireHeapItem,SketchlibCMSHeap, thesketchlib_cms_heap_*/new_sketchlib_cms_heap/matrix_from_sketchlib_cms_heap/heap_to_wirehelpers,CountMinSketchInnerWire,CountMinSketchWithHeapWire; crate-root re-exportsCountMinSketchWithHeap,CmsHeapItem.Added
cmsheap_i64_regular_2x3_strkeys,cmsheap_i32_fast_2x3_i64keys,cmsheap_i64_regular_2x3_i64tie,cmsheap_i64_regular_2x3_strtie,cmsheap_i64_regular_2x3_empty. The tie fixtures seat entries in two orders and check both encode to the same bytes.CMSHeap+ ASAPv1.Open question: heap key order within a count tie
Rust's
key_order(shared by CMSHeap, CSHeap, Space-Saving, UnivMon) compares keys as unsigned bits: a signed key by its two's-complement pattern, so ties emit0, 1, …, MAX, MIN, …, -1; floats by IEEE-754 bits; strings byte-wise. The spec did not say so, and a natural signed sort would have passed the old fixtures. This PR documents the current rule and pins it (…_i64tie,…_strtie) without changing the encoder. Alternative: switch to plain signed order now, before Go mirrors it and before more goldens lock it in.Downstream
ASAPQuery-backend decodes/writes CMS-with-heap via
CountMinSketchWithHeap::{from_msgpack, to_msgpack}; the equivalent native state isCMSHeap<Vector2D<i64>, RegularPath>with string keys. Behaviour differences for callers:CMSHeap::mergepanics on a dimension mismatch (the portable type returnedErr), and callers must round f64 weights themselves.Verification (rustc 1.99)
cargo fmt --check; clippy-D warningsfor all four CI feature sets;RUSTDOCFLAGS="-D warnings" cargo doc; gen-proto drift clean; filtered tests (asapv1_golden,msgpack_compat,e2e -- composition::,--lib -- countsketch_topk countminsketch_topk,pbt -- heaps::). The reviewer hand-decoded the goldens against spec §3.7. Implemented and reviewed by separate agents; review findings are addressed in the second commit.🤖 Generated with Claude Code