feat(sketchdb): CMS-with-heap top-K accuracy bound - #57
Merged
Merged
Conversation
Splits `CountMinSketchWithHeap` out of the plain-CMS branch in `AccuracyProfile::derive` and gives it its own bound: * per-item frequency: e/w (CMS, Cormode-Muthukrishnan 2005) * top-K retention: 1/k (Metwally et al., ICDT 2005) → reported ε = max(e/w, 1/k); δ = 1/2^d (CMS depth) → new `AccuracyKind::TopK` variant (serialised as "top_k") Heap size `k` is read from `parameters.heap_size` (or aliases `topk` / `k`), default 100. ## Why split Plain CMS has *per-key point-lookup* accuracy; CMS-with-heap further guarantees *top-K retention* — items with true frequency ≥ N·ε are guaranteed to be in the returned heap. Conflating the two bounds under `AdditiveFrequency` lost the retention guarantee, which is what users actually query the heap for. ## Tests +4 on top of #55's 5: cms_with_heap_carries_top_k_kind_and_heap_bound cms_with_heap_cms_bound_dominates_when_heap_is_generous cms_with_heap_uses_default_heap_size_100 cms_with_heap_accepts_alternative_param_names 784 → 788 lib tests green; clippy + fmt clean.
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.
Splits
CountMinSketchWithHeapfrom plain CMS in the accuracy derivation; gives it a top-K retention bound from Metwally-Agrawal-El Abbadi (ICDT 2005) alongside the Cormode-Muthukrishnan CMS point-lookup bound. NewAccuracyKind::TopKvariant. ε = max(e/w, 1/heap_size), δ = 1/2^d. +4 tests, 788 green, clippy + fmt clean.