Conversation
zzylol
force-pushed
the
stack/528-15-frequency-inputs
branch
from
October 3, 2026 04:08
fb5b29d to
e0e1e2d
Compare
zzylol
force-pushed
the
stack/528-14-raw-latency
branch
from
October 3, 2026 04:08
902d3b5 to
a331146
Compare
This was referenced Oct 3, 2026
zzylol
marked this pull request as draft
October 3, 2026 19:28
Contributor
Author
|
Parked as draft: PR priorities changed (see #528). Order is now (A) finish #511 operator sharing, (B) the #572 crate/module reorganization, (C) #509 end-to-end stages. This PR sits on the old 🤖 Generated with Claude Code |
Contributor
Author
|
Ported onto the current stack in #597 |
zzylol
added a commit
that referenced
this pull request
Oct 4, 2026
…ntities Port of the parked runtime PRs for #509 Example 2 onto asap-executor: - native UnivMon build and Cardinality / FrequencyL2 / FrequencyEntropy readouts (the old stack's 14c8ac8, a prerequisite missing here); - #557: a UnivMon build accepts Utf8, Int64 and Bool identities as type-tagged keys; heap key bytes count toward state memory; - #559: exact FrequencyL2 / FrequencyEntropy reducers (bits, NULL skipped, 0 for an empty population, memory-accounted, cooperative); - #563: exact Cardinality reducer over typed tuples. The legacy raw-cost adapter lists the three intents as hash aggregates. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Problem: the native UnivMon build cannot consume the
src_ipidentities that #509 Example 2 shares#509 §Pass 2 (summary-capability rule) and §Example 2 ("One summary for several computations") describe this shared candidate:
#509 §Physical operator implementation then turns that node into summary build and estimation operators. The build operator must therefore accept a
src_ipvalue as a UnivMon update.Before this PR, the native summary build accepts only Float64 update columns, for every family:
So the Example 2 input fails before any row is read:
Converting the identity to Float64 first is not a fix. Int64 identities above 2^53 collapse:
9_007_199_254_740_992and9_007_199_254_740_993become the same Float64, so the distinct count, L2 and entropy all change.Scope. This PR covers the physical build side of the Example 2 shared candidate: one native UnivMon state built from typed
src_ip-like identities, read by the distinct, L2 and entropy estimators. It does not cover the frontend recognition of the Q2/Q3 SQL forms (#509 §Example 2 TODO), the Pass 2 sharing rule itself, sizing for the strictest ε, or UnivMon accuracy certification.Proposed method
All changes are in the physical runtime (
asap-physical-operators). Planning stages are unchanged.Operator::summary_buildstill requires Float64 for every family, except UnivMon. A UnivMon build also acceptsUtf8,Int64andBoolupdate columns. Any other type returns"summary update type is unsupported by its family".f64. It skipsValue::Null(as before: SQL aggregates ignore NULL samples while keeping the group) and passes the typed&Valueto a new trait methodAccumulatorUpdater::update_value.update_valuerequiresValue::Float64, runsvalidate_single_input, thenupdate_single. Every non-UnivMon family therefore behaves exactly as before.UnivMonUpdater::update_valuecalls the newUnivMonAccumulator::insert_value:Null→ no-op.Float64→ the existinginsert_samplepath (unchanged Float64 behavior).Bool/Int64/Utf8→ encode with the existing type-taggedValue::key()bytes, check the bucket counter for overflow, and insert asDataInput::Byteswith weight 1.Because
Value::key()stores Int64 as its 8 little-endian bytes with a type tag, neighboring large integers stay distinct.UnivMonAccumulator::approx_memory_bytesnow adds the capacity ofString/Byteskeys held in each layer's heavy-hitter heap. Long string identities count against the runtime memory reservation. Afterclear(), the value returns to the empty-state size.One built state still feeds the existing
SketchStatistic::Cardinality,FrequencyL2andFrequencyEntropyevaluations.Key code interfaces
crates/asap-physical-operators/src/summary_kernels/factory.rscrates/asap-physical-operators/src/summary_kernels/univmon.rscrates/asap-physical-operators/src/operators/summary/mod.rs(signature unchanged, accepted types widened)Usage, as in
tests/univmon_execution.rs:Fields
AccumulatorUpdater::update_valueself&mut selfvalue&ValueNull; it skips NULL rows before the call.timestamp_msi64timecolumn, or0whentimeisNone. Passed toupdate_singleby the default; ignored by UnivMon.Result<(), String>Errfor a type the family does not accept or for an inputvalidate_single_inputrejects. The build maps it toError::Operator.UnivMonAccumulator::insert_valueValue::NullOk(()).Value::Float64(x),xfiniteinsert_sample(x), same as before this PR.Value::Bool/Value::Int64/Value::Utf8Value::key()), weight 1. Errors with"UnivMon count overflow"ifbucket_size + 1overflows.Err("unsupported UnivMon identity type or nonfinite sample").Operator::summary_buildinputSchemaReffamilySummaryFamilyTypevalidate_family. UnivMon is detected withkind.algorithm() == SketchAlgorithm::UnivMon.valueusizeUtf8,Int64orBool.timeOption<usize>Timestamp(unchanged).groupsVec<usize>validate_groups(unchanged).Examples
End to end (
tests/univmon_execution.rs::typed_frequency_keys_preserve_identity). For each key type, the input columnsrc_ipholds two keys, each twice, and one NULL:Utf8"192.0.2.1","192.0.2.2"Int649_007_199_254_740_992,9_007_199_254_740_993Boolfalse,trueAll values are checked within 0.01. The NULL row contributes nothing. The two Int64 keys are 2^53 and 2^53+1, which would be one key after a Float64 cast.
Kernel tests (
src/summary_kernels/univmon.rs).typed_keys_merge_and_roundtrip: twoUtf8states (192.0.2.1×2 and192.0.2.2×2) are merged, serialized and restored. The restored state still gives distinct 2, L2 √8, entropy 1.memory_accounts_for_string_identities: inserting one 4,096-byteUtf8key raisesapprox_memory_bytesby at least 4,096. Afterclear()it equals the empty size.Accepted vs rejected update columns
Float64Utf8,Int64,BoolFloat64update_valuedefault rejects non-Float64 valuesThe developer note in
docs/develop_docs/operator-design-acceptance.md§"Planner-layering follow-up: typed frequency inputs" records the same contract.Out of scope
Stack and validation
Stacked on #556 · Next: #559 · Reference/tracker: #528
Validation: the typed-input regression fails before the change and passes afterward; all 225 native runtime tests/doctests passed; formatting; all-target Clippy for native runtime with warnings denied.
The full restacked tip passes all 1,608 workspace tests/doctests (two existing ignores), formatting and workspace/all-target/all-feature Clippy with warnings denied. The inherited UnivMon precompute fixture was fixed in #552, and the latency fixture lint in #554; later branches were restacked atomically with explicit leases. CI has been retriggered.
🤖 Generated with Claude Code