Skip to content

feat(data_plane): persist exact sum-of-squared-deviations states compactly - #903

Draft
zzylol wants to merge 3 commits into
feat/raw-read-label-pushdownfrom
feat/sumsq-persist
Draft

zzylol wants to merge 3 commits into
feat/raw-read-label-pushdownfrom
feat/sumsq-persist

Conversation

@zzylol

@zzylol zzylol commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Problem: the planner adds an exact state for standard deviation and variance (ExactKind::SumOfSquaredDeviations, ASAPPlanner #1560). The data plane's compact state-column codec has no form for it, and compact_kind's exhaustive match stops compiling against that planner.
  • Change: pin that planner commit (71137c21, #1560 head). Add CompactKind::SumOfSquaredDeviations (code 7): an all-zero empty record is one tag byte; otherwise the record is a tag, the count as a varint, and the mean and sum of squared deviations as floats.
  • Effect: a chain of these states (for example stddev_over_time(x[1h]) kept at ingestion) persists and reads back cold byte for byte. A 3-value record takes 1 tag byte + a 1-byte varint + 2 floats, instead of a 24-byte raw record.

Review guide

Behavior: before → after

The planner selects SummaryTumblingWindowChain[SumOfSquaredDeviations] for stddev_over_time(data[1h]).

  • Before: the backend does not compile against that planner (compact_kind is a non-exhaustive match).
  • After: each sealed window's state column is written in the compact form (code 7) and decoded back to the executor's view record (count u64, mean f64, sum_squared_deviations f64).
  • States persisted through serde (StoredValue::Exact) need no change: the new ScalarState variant round-trips through rmp-serde.

Interfaces

data_plane/src/state_codec.rs

 /// State families with a compact form. The type stays; one variant added.
 pub enum CompactKind {
     DDSketch,
     Sum,
     Count,
     MinMax,
     Counter,
     LastTwoSamples,
+    /// Exact sum of squared deviations: `count` (u64), `mean`, `sum_squared_deviations`
+    /// (f64); an empty one is all zero. Column-descriptor code 7.
+    SumOfSquaredDeviations,
 }

On-disk format: column-descriptor code 7. Per record, tag 0 means the empty record. Tag 1 is followed by a uvarint count in the int stream, the mean in float stream 0, and the sum in float stream 1. A record in any other form keeps the existing RAW tag.

Algorithm changes

None. The codec is lossless and reuses the existing per-record framing.

Decisions and open questions

None.

Verification

scope result notes
cargo fmt --all --check pass
cargo clippy -p data_plane --all-targets -D warnings pass
cargo test -p data_plane --lib state_codec 9 passed new compact_sum_of_squared_deviations_columns_rebuild_the_records: covers empty, 3-value, mean 1e9, NaN, and non-writer records (the last kept whole); checks the code round-trips
cargo test -p data_plane --lib segment 8 passed

Follow-ups

  • Bump the planner pin again if #1560 moves. For the eval build, re-pin every Planner dependency (and the sketchlib pin) to the eval planner head (review I1).

🤖 Generated with Claude Code

https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi

…actly

Pins the planner commit that adds ExactKind::SumOfSquaredDeviations (a
standard deviation's or variance's count, mean and sum of squared
deviations, 24-byte view record) and gives its state columns a compact
form: CompactKind::SumOfSquaredDeviations (code 7), an all-zero empty
record as one tag byte, otherwise the count as a varint and the mean
and sum as floats; any other record is kept whole. Decoding rebuilds the
view bytes exactly. Serde-persisted exact states need no change (the new
ScalarState variant round-trips).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
@zzylol zzylol added enhancement New feature or request area: data plane Runtime ingestion, storage, and query-serving data paths integration: ASAPPlanner ASAPPlanner API, IR, candidate, and selected-plan integration labels Dec 3, 2026
zzylol and others added 2 commits December 3, 2026 23:18
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
…nullable)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K1M6boFpwkpMtRc1FnZuYi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: data plane Runtime ingestion, storage, and query-serving data paths enhancement New feature or request integration: ASAPPlanner ASAPPlanner API, IR, candidate, and selected-plan integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant