Skip to content

feat: add shared summary kernels and typed physical values - #473

Open
zzylol wants to merge 1 commit into
mainfrom
split/462-c-summary-kernels
Open

zzylol wants to merge 1 commit into
mainfrom
split/462-c-summary-kernels

Conversation

@zzylol

@zzylol zzylol commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Part 2 of the #462 split. It starts the asap-physical-operators crate with summary kernels only, and is independent of the other parts.

Before this PR

Summary kernels lived only in ASAPQuery-backend (data_plane/src/precompute_engine/operators/*_accumulator.rs). Each kernel mixed three concerns:

  • the sketch algorithm (asap_sketchlib);
  • Planner semantics (which readout answers which query);
  • Backend concerns: OTLP/msgpack/proto wire decoding, delta frames, edge sample_p, aux_stats for the sketch store, AggregationType config, keyed group-by kernels.

Queries were stringly typed (Statistic + HashMap<String, String>, e.g. "quantile" -> "0.99").

After this PR

One boundary:

Owner Responsibility
asap_sketchlib Sketch algorithms and their state encodings. The envelope codec moves there: ProjectASAP/asap_sketchlib#163.
Planner kernels (this PR) One population's in-memory state: merge, typed estimate(&SketchQuery), memory accounting. Exact states answer ExactAccumulator::readout(statistic, range_ms, key); an empty MIN/MAX reads as None.
Physical operators (#474) Grouping: one kernel per group.
Deployments Wire decoding, delta frames, edge sampling, storage statistics.

Kernels: exact (Sum/Count/Min/Max/Rate/Increase), KLL, DDSketch, HLL, Count-Min, CountSketch (both with or without heap), UnivMon, weighted frequency, and Hydra KLL (the Hydra shared-grouping strategy).

Not carried over from Backend:

  • wire decoding;
  • SerializableToSink, AggregationType, aux_stats, reset_to_empty, sample_p;
  • the keyed/sum/min/max/envelope kernels;
  • asap_sketch_codec.

HLL uses sketchlib's classic estimator. It differs from the removed Backend copy only for precision ≤ 6 (alpha constants) and in the 32-bit large-range correction, which sketchlib's 64-bit hashing does not need.

Backend is expected to align with this model when it moves its Planner pin. data_plane then also drops the extra_debugging feature reference.

Validation: cargo test -p asap-physical-operators (32 passed) and cargo clippy --workspace --all-targets -D warnings.

Split stack: #472 (merged) · this PR · #474 · #475.

🤖 Generated with Claude Code

Start `asap-physical-operators` with thin summary kernels over
`asap_sketchlib`, the kernel capability checks and the typed value model.

The boundary is:
- `asap_sketchlib` owns sketch algorithms and their state encodings.
- Kernels hold one population's in-memory state. They expose `merge`, a
  typed sketch readout (`estimate(&SketchQuery)`) and memory accounting.
  Exact states answer a typed `ExactReadout`; empty MIN/MAX read as `None`.
- Group-by belongs to physical operators.
- Deployments own wire decoding, delta frames, edge sampling and storage
  statistics.

So wire decoding, `SerializableToSink`, `AggregationType`, `aux_stats`,
`reset_to_empty` and the keyed/sum/min/max kernels are not carried over from
ASAPQuery-backend. The `asap_sketch_codec` crate is not carried over either;
it moves to `asap_sketchlib`. Hydra KLL remains as the Hydra shared-grouping
kernel. HLL uses sketchlib's classic estimator.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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