feat(summary_executor): support SketchQuery::TopK via a two-shape Value - #412
Merged
Merged
Conversation
SummaryExecutor::Value was Vec<(i64, f64)> -- one scalar per point --
which can't represent TopK's "K ranked (item, count) pairs per point"
answer, so it errored Unsupported. Value is a fully deployment-opaque
associated type (no upstream ASAPController trait bounds), so this is
local to data_plane: introduce SummaryValue::{Points, TopK} and branch
readout_cumulative/readout_per_window on the query once each.
No new merge logic needed -- SummaryState::topk_items already decodes
heap items for CmsWithHeap/CountSketchWithHeap, and the existing
merge_same_family pipeline (asap_sketchlib's heap merge) already
reconciles the heap against the merged matrix across sids, so top-k
readout reuses the exact same cross-sid merge every other query goes
through.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
6 tasks
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.
Summary
Step 1 of 3 toward retiring the legacy
sketch_reducer.rsquery path in favor of the plan-basedSummaryExecutormerged in #411 — the user wants no duplicate/parallel query-execution implementations, and this was the one functional gap (of two) blocking a full cutover.SummaryExecutor::ValuewasVec<(i64, f64)>— one scalar per point — which can't representSketchQuery::TopK's answer (K ranked(item, count)pairs per point), so it erroredUnsupported.Valueis a fully deployment-opaque associated type (no bounds in the upstreamASAPControllertrait), so this is 100% local todata_plane:SummaryValue::{Points(Vec<(i64,f64)>), TopK(Vec<(i64, Vec<(String,f64)>)>)}, replacing the oldValuetype.readout_cumulative/readout_per_windoweach branch once onmatches!(query, SketchQuery::TopK)to decide which shape to produce (merge loop itself is unchanged).topk_ranked(rs, k)helper: readsSummaryState::topk_items()(already existed), sorts descending by value (load-bearing — the heap's backing array isn't actually ordered despite its own doc comment's claim), caps atk.merge_same_familyalready reconciles heaps correctly across sids (asap_sketchlib'sCountMinSketchWithHeap/CountSketchWithHeap::mergere-queries every candidate key against the merged matrix) — top-k readout just reads the final merged state's heap, reusing the exact same cross-sid merge pipeline every other query already goes through.Blast radius confirmed via full-crate grep before starting: this executor isn't wired into
engine.rs's liveASAPQueryEngineyet, so nothing outside this one file/its own test module is affected.Test plan
cargo test -p data_plane --lib summary_executor— 15 tests (12 existing + 3 new), all passing:single_cms_with_heap_sid_topk_readout_sorted_and_capped— proves sort+cap.two_cms_with_heap_sids_same_group_topk_merges_cross_sid— two sids with disjoint keys, proves the merged answer contains both — the actual cross-sid merge proof.per_window_matrix_topk_produces_per_window_ranked_lists— the one genuinely new code path (readout_per_window's TopK branch), two windows with different top keys each.topk_query_against_non_heap_sketch_is_unsupported(renamed from..._is_explicitly_unsupported_not_silently_wrong) — still errors for a heap-less family; now documented as a family limitation, not "unimplemented."cargo test -p data_plane --lib— full lib suite: 911 passed, 2 ignored (908 + 3 new).cargo build -p data_plane— clean.cargo clippy -p data_plane --lib --tests— zero warnings in the touched file.rustfmtscoped to the one touched file.Not in this PR (separate, later steps per the user's own sequencing): wiring
SummaryExecutorintoengine.rs's liveASAPQueryEngine, the named-keyPointCountgap, and deletingsketch_reducer.rs.🤖 Generated with Claude Code