diff --git a/Cargo.lock b/Cargo.lock index baa3ecba2..954fa600c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -604,7 +604,7 @@ dependencies = [ [[package]] name = "asap_sketchlib" version = "0.4.0" -source = "git+https://github.com/ProjectASAP/asap_sketchlib?rev=389530ce23b121520f0218a4471e376db2c35945#389530ce23b121520f0218a4471e376db2c35945" +source = "git+https://github.com/ProjectASAP/asap_sketchlib?rev=01f3333cbdc7c55a36642e0938aa7f0040f2cfa8#01f3333cbdc7c55a36642e0938aa7f0040f2cfa8" dependencies = [ "rand 0.9.5", "rmp-serde", diff --git a/Cargo.toml b/Cargo.toml index 37b09bdfb..8efeb6caa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,18 +28,16 @@ resolver = "2" arrow = { version = "58.4", default-features = false } # The hasher Arrow already uses, for the executor's hot interning maps. ahash = { version = "0.8", default-features = false, features = ["std", "runtime-rng"] } -# main after release 0.4.0 (eb04e7f): #245 (checked f64 updates, heap -# rescoring), #246 (KLL lazy-buffer follow-ups), #247 (Count Sketch stack -# medians), #248 (`DdSketch::quantile_interpolated`), #249 (`memory_bytes` and -# `estimated_memory_bytes`; KMV without `experimental`), #251 (the public -# capability table) and #254 (Planner names in that table), plus -# `Kll::shrink_to_fit` from #267 and `DdSketch::shrink_to_fit` from #270 -# (branch `planner-pin/dd-kll-shrink-to-fit`: 21b6357, #267's commit, and -# #270's change and tests, since main has renamed the capability -# vocabulary since). Moves to a release once #267 and #270 are in one. -# Plus the zero-copy sketch views of #271 (branch `feat/zero-copy-views`, -# on that branch), which the executor's mapped state columns read. -asap_sketchlib = { git = "https://github.com/ProjectASAP/asap_sketchlib", rev = "389530ce23b121520f0218a4471e376db2c35945" } +# main at a05b35c (through #262: sketch analytics; #260 renamed the +# `SketchAlgorithm` variants to full names with upper-case acronyms; #252, +# #256, #257, #258 and #259 dropped exact side fields from the DDSketch, +# Bloom, Space-Saving and HLL-HIP states and moved them to new ASAPv1 kinds), +# plus three open PRs the executor needs, merged onto that main on branch +# `planner-pin/main-a05b35c-shrink-to-fit`: `Kll::shrink_to_fit` (#267), +# `DdSketch::shrink_to_fit` (#270), and the zero-copy sketch views of #271 +# (head 355093f, ported to main's DDSketch without sum/min/max), which the +# executor's mapped state columns read. Moves to main once they merge. +asap_sketchlib = { git = "https://github.com/ProjectASAP/asap_sketchlib", rev = "01f3333cbdc7c55a36642e0938aa7f0040f2cfa8" } [profile.dev] # Backtraces and profilers keep file:line; full variable info is opt-in via diff --git a/crates/accuracy/src/error_contract/tests.rs b/crates/accuracy/src/error_contract/tests.rs index 4bbdca982..bf357c502 100644 --- a/crates/accuracy/src/error_contract/tests.rs +++ b/crates/accuracy/src/error_contract/tests.rs @@ -33,7 +33,7 @@ fn key_filters_and_value_preserving_projects_have_unit_contracts() { let state = memo .find_or_add_group(Operator::ASAP(ASAPOp::SummaryAgg { child: g1, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KLL), input: SummaryUpdate::column(asap_types::ir::scalar::ColumnRef::SampleValue), reduction: Reduction::by(vec![2]), filter: None, @@ -199,7 +199,7 @@ fn a_reduction_keyed_by_an_estimate_has_no_contract() { let state = memo .find_or_add_group(Operator::ASAP(ASAPOp::SummaryAgg { child: g1, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KLL), input: SummaryUpdate::column(asap_types::ir::scalar::ColumnRef::SampleValue), reduction: Reduction::by(vec![2]), filter: None, diff --git a/crates/accuracy/src/guarantee/tests.rs b/crates/accuracy/src/guarantee/tests.rs index 370487a68..4becf0028 100644 --- a/crates/accuracy/src/guarantee/tests.rs +++ b/crates/accuracy/src/guarantee/tests.rs @@ -19,7 +19,7 @@ fn every_listed_parameters_has_a_guarantee_at_one_percent() { }; for (algorithm, statistic, metric) in [ ( - SketchAlgorithm::Kll, + SketchAlgorithm::KLL, SketchStatistic::Quantile { q: 0.5 }, AccuracyMetric::Rank, ), @@ -29,12 +29,12 @@ fn every_listed_parameters_has_a_guarantee_at_one_percent() { AccuracyMetric::Relative, ), ( - SketchAlgorithm::Kmv, + SketchAlgorithm::KMV, SketchStatistic::Cardinality, AccuracyMetric::Relative, ), ( - SketchAlgorithm::Cms, + SketchAlgorithm::CountMinSketch, point.clone(), AccuracyMetric::ABSOLUTE_STREAM_L1, ), @@ -44,7 +44,7 @@ fn every_listed_parameters_has_a_guarantee_at_one_percent() { AccuracyMetric::ABSOLUTE_STREAM_L2, ), ( - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchStatistic::TopK { k: 10 }, AccuracyMetric::ABSOLUTE_STREAM_L1, ), @@ -69,7 +69,7 @@ fn every_listed_parameters_has_a_guarantee_at_one_percent() { assert!(!errors.is_empty(), "{algorithm:?}"); if matches!( algorithm, - SketchAlgorithm::Kll | SketchAlgorithm::DDSketch | SketchAlgorithm::Kmv + SketchAlgorithm::KLL | SketchAlgorithm::DDSketch | SketchAlgorithm::KMV ) { assert!( errors.windows(2).all(|pair| pair[1] <= pair[0]), @@ -85,7 +85,7 @@ fn every_listed_parameters_has_a_guarantee_at_one_percent() { #[test] fn a_guarantee_is_evaluated_at_the_required_failure_probability() { let quantile = SketchStatistic::Quantile { q: 0.5 }; - let kll = FieldDataType::Sketch(SketchAlgorithm::Kll); + let kll = FieldDataType::Sketch(SketchAlgorithm::KLL); let k = SketchParams::Kll { k: 547 }; let error_at = |delta| { theoretical_guarantee(&kll, &k, &quantile, delta, None, None) @@ -97,7 +97,7 @@ fn a_guarantee_is_evaluated_at_the_required_failure_probability() { }; assert_eq!(error_at(1.0), error_at(0.01)); assert!(error_at(1e-6) > error_at(0.01)); - let cms = FieldDataType::Sketch(SketchAlgorithm::Cms); + let cms = FieldDataType::Sketch(SketchAlgorithm::CountMinSketch); let point = SketchStatistic::PointCount { key: ColumnRef::SampleValue, value: None, diff --git a/crates/accuracy/src/logical_edge/tests.rs b/crates/accuracy/src/logical_edge/tests.rs index 8556c248b..2d65e2c47 100644 --- a/crates/accuracy/src/logical_edge/tests.rs +++ b/crates/accuracy/src/logical_edge/tests.rs @@ -39,7 +39,7 @@ fn a_tiny_limit_is_widened_only_relatively() { /// reach the root unbounded; with no target reaching it, it holds. #[test] fn a_distinct_count_readout_without_an_evaluable_guarantee_serves_no_query_with_a_target() { - for algorithm in [SketchAlgorithm::Hll, SketchAlgorithm::UnivMon] { + for algorithm in [SketchAlgorithm::HLL, SketchAlgorithm::UnivMon] { let mut memo = Memo::new(&DataWorkload::default()); let events = memo.find_or_add_group(scan("events", &[], vec![])).unwrap(); let build = Operator::ASAP(ASAPOp::SummaryAgg { @@ -121,7 +121,7 @@ fn a_heap_smaller_than_k_fails_the_topk_readouts_edge() { let state = sketch_state( &mut memo, window, - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, Reduction::by(vec![]), ); let readout = estimate(&mut memo, state, SketchStatistic::TopK { k: 50 }); @@ -235,7 +235,7 @@ fn a_distinct_count_readout_reads_the_scanned_sources_distinct_bound() { }; let edge = readout_edge( facts, - SketchAlgorithm::Hll, + SketchAlgorithm::HLL, SketchParams::Hll { precision: 18 }, SketchStatistic::Cardinality, RequiredAccuracy { diff --git a/crates/accuracy/src/metric_rule/tests.rs b/crates/accuracy/src/metric_rule/tests.rs index 1e32b6d10..e8fdfe968 100644 --- a/crates/accuracy/src/metric_rule/tests.rs +++ b/crates/accuracy/src/metric_rule/tests.rs @@ -77,7 +77,7 @@ fn quantile_readouts(memo: &mut Memo, q: f64) -> QuantileReadouts { memo, window, q, - &[SketchAlgorithm::Kll, SketchAlgorithm::DDSketch], + &[SketchAlgorithm::KLL, SketchAlgorithm::DDSketch], ) } @@ -87,7 +87,7 @@ fn quantile_readouts(memo: &mut Memo, q: f64) -> QuantileReadouts { #[test] fn a_ratio_reads_no_rank_error() { let mut memo = Memo::new(&DataWorkload::default()); - let (_, state, p99) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.99, 300); + let (_, state, p99) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.99, 300); let p50 = estimate(&mut memo, state, SketchStatistic::Quantile { q: 0.5 }); let ratio = group(&mut memo, arithmetic(ArithmeticOpKind::Div, p99, p50)); let target = AccuracyTarget::max_error(0.05).accuracy_metric(AccuracyMetric::Relative); @@ -120,7 +120,7 @@ fn the_metric_rule_cuts_the_readout_edges_and_keeps_the_exact_division() { &mut memo, window, 0.9, - &[SketchAlgorithm::Kll, SketchAlgorithm::DDSketch], + &[SketchAlgorithm::KLL, SketchAlgorithm::DDSketch], ); let ratio = group( &mut memo, @@ -491,7 +491,7 @@ fn a_count_reads_its_input_in_any_metric() { #[test] fn a_counts_input_edge_from_a_readout_holds_in_a_metric_its_output_does_not_allow() { let mut memo = Memo::new(&DataWorkload::default()); - let (_, _, p99) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.99, 300); + let (_, _, p99) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.99, 300); let count = group( &mut memo, Operator::NonASAP(NonASAPOp::Aggregate { diff --git a/crates/accuracy/src/properties.rs b/crates/accuracy/src/properties.rs index e2d2d4a51..1f242bedf 100644 --- a/crates/accuracy/src/properties.rs +++ b/crates/accuracy/src/properties.rs @@ -67,12 +67,14 @@ fn probability() -> impl Strategy { fn parameters() -> impl Strategy { let size = || prop_oneof![Just(0u32), Just(1), Just(u32::MAX), 0..100_000u32]; prop_oneof![ - (0..KLL_MAX_K + 10).prop_map(|k| (SketchAlgorithm::Kll, SketchParams::Kll { k })), - size().prop_map(|k| (SketchAlgorithm::Kmv, SketchParams::Kmv { k })), - (size(), 0..64u32) - .prop_map(|(width, depth)| (SketchAlgorithm::Cms, SketchParams::Cms { width, depth })), + (0..KLL_MAX_K + 10).prop_map(|k| (SketchAlgorithm::KLL, SketchParams::Kll { k })), + size().prop_map(|k| (SketchAlgorithm::KMV, SketchParams::Kmv { k })), + (size(), 0..64u32).prop_map(|(width, depth)| ( + SketchAlgorithm::CountMinSketch, + SketchParams::Cms { width, depth } + )), (size(), 0..64u32, size()).prop_map(|(width, depth, heap_size)| ( - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchParams::CmsWithHeap { width, depth, @@ -91,7 +93,7 @@ fn parameters() -> impl Strategy { heap_size } )), - (0..=32u8).prop_map(|precision| (SketchAlgorithm::Hll, SketchParams::Hll { precision })), + (0..=32u8).prop_map(|precision| (SketchAlgorithm::HLL, SketchParams::Hll { precision })), prop_oneof![ Just(f64::MIN_POSITIVE), Just(1.0 - f64::EPSILON), @@ -181,8 +183,8 @@ fn is_a_bound(error: Option) -> bool { /// The statistic each algorithm's guarantee is for. fn statistic_of(algorithm: SketchAlgorithm) -> SketchStatistic { match algorithm { - SketchAlgorithm::Kll | SketchAlgorithm::DDSketch => SketchStatistic::Quantile { q: 0.5 }, - SketchAlgorithm::Kmv | SketchAlgorithm::Hll => SketchStatistic::Cardinality, + SketchAlgorithm::KLL | SketchAlgorithm::DDSketch => SketchStatistic::Quantile { q: 0.5 }, + SketchAlgorithm::KMV | SketchAlgorithm::HLL => SketchStatistic::Cardinality, SketchAlgorithm::UnivMon => SketchStatistic::FrequencyL2, _ => SketchStatistic::PointCount { key: ColumnRef::SampleValue, @@ -251,10 +253,12 @@ fn grown(parameters: &SketchParams, factor: u32) -> SketchParams { /// at sizes the planner lists (Count Sketch depth odd). fn valid_parameters() -> impl Strategy { prop_oneof![ - (2..KLL_MAX_K).prop_map(|k| (SketchAlgorithm::Kll, SketchParams::Kll { k })), - (2..100_000u32).prop_map(|k| (SketchAlgorithm::Kmv, SketchParams::Kmv { k })), - (1..100_000u32, 1..32u32) - .prop_map(|(width, depth)| (SketchAlgorithm::Cms, SketchParams::Cms { width, depth })), + (2..KLL_MAX_K).prop_map(|k| (SketchAlgorithm::KLL, SketchParams::Kll { k })), + (2..100_000u32).prop_map(|k| (SketchAlgorithm::KMV, SketchParams::Kmv { k })), + (1..100_000u32, 1..32u32).prop_map(|(width, depth)| ( + SketchAlgorithm::CountMinSketch, + SketchParams::Cms { width, depth } + )), (1..100_000u32, 0..16u32).prop_map(|(width, half)| ( SketchAlgorithm::CountSketch, SketchParams::CountSketch { @@ -262,7 +266,7 @@ fn valid_parameters() -> impl Strategy depth: 2 * half + 1 } )), - (4..=18u8).prop_map(|precision| (SketchAlgorithm::Hll, SketchParams::Hll { precision })), + (4..=18u8).prop_map(|precision| (SketchAlgorithm::HLL, SketchParams::Hll { precision })), (1e-6..0.5f64) .prop_map(|alpha| (SketchAlgorithm::DDSketch, SketchParams::DDSketch { alpha })), ] @@ -429,7 +433,7 @@ proptest! { fn meeting_a_readout_level_is_monotone( (algorithm, parameters) in valid_parameters() .prop_filter("HLL needs a declared distinct bound", |(algorithm, _)| { - *algorithm != SketchAlgorithm::Hll + *algorithm != SketchAlgorithm::HLL }), failure_probability in probability(), slack in 0.5..2.0f64, @@ -500,7 +504,7 @@ proptest! { Just(ArithmeticOpKind::Div), ], ) { - let (memo, operand) = state_memo(SketchAlgorithm::Kll); + let (memo, operand) = state_memo(SketchAlgorithm::KLL); let consumer = arithmetic(kind.clone(), operand, operand); for metric in AccuracyMetric::ALL { let Some(contract) = error_contract(&memo, &consumer, metric) else { @@ -587,7 +591,7 @@ fn binary_operators( /// sample). #[test] fn contracts_never_shrink_an_input_error() { - let (memo, operand) = state_memo(SketchAlgorithm::Kll); + let (memo, operand) = state_memo(SketchAlgorithm::KLL); for consumer in binary_operators(operand, operand) { for metric in AccuracyMetric::ALL { let Some(ErrorContract { @@ -617,7 +621,7 @@ fn contracts_never_shrink_an_input_error() { /// (1, 0) in every metric. #[test] fn symmetric_operators_have_order_independent_contracts() { - let (mut memo, source, left) = scan_and_state_memo(SketchAlgorithm::Kll); + let (mut memo, source, left) = scan_and_state_memo(SketchAlgorithm::KLL); let right = memo .find_or_add_group(state( FieldDataType::Sketch(SketchAlgorithm::DDSketch), diff --git a/crates/accuracy/src/readout/tests.rs b/crates/accuracy/src/readout/tests.rs index b8a0418b5..ac1048bcc 100644 --- a/crates/accuracy/src/readout/tests.rs +++ b/crates/accuracy/src/readout/tests.rs @@ -10,7 +10,7 @@ fn a_readouts_metric_is_its_algorithms() { let quantile = SketchStatistic::Quantile { q: 0.9 }; let sketch = |algorithm| FieldDataType::Sketch(algorithm); assert_eq!( - readout_error_metric(&sketch(SketchAlgorithm::Kll), &quantile), + readout_error_metric(&sketch(SketchAlgorithm::KLL), &quantile), Some(AccuracyMetric::Rank) ); assert_eq!( @@ -18,7 +18,7 @@ fn a_readouts_metric_is_its_algorithms() { Some(AccuracyMetric::Relative) ); assert_eq!( - readout_error_metric(&sketch(SketchAlgorithm::Hll), &SketchStatistic::Cardinality), + readout_error_metric(&sketch(SketchAlgorithm::HLL), &SketchStatistic::Cardinality), Some(AccuracyMetric::Relative) ); assert_eq!( diff --git a/crates/accuracy/src/readout_caps/tests.rs b/crates/accuracy/src/readout_caps/tests.rs index ed846c6f1..a3ffee50f 100644 --- a/crates/accuracy/src/readout_caps/tests.rs +++ b/crates/accuracy/src/readout_caps/tests.rs @@ -34,7 +34,7 @@ fn levels_of(memo: &Memo, readout: MemoGroupId) -> Vec { #[test] fn a_whole_result_failure_probability_is_split_per_value() { let mut memo = Memo::new(&with_series("m", 100)); - let (_, _, readout) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.9, 300); + let (_, _, readout) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.9, 300); memo.add_query(MemoQuery { root: QueryRoot::Operator(readout), accuracy_target: Some(AccuracyTarget::max_error(0.01).failure_probability(0.01)), @@ -144,7 +144,7 @@ fn a_count_over_readouts_gives_them_no_level() { fn a_readout_of_one_value_keeps_the_whole_failure_probability() { let mut memo = Memo::new(&with_series("flows", 1000)); let rows = scan_group(&mut memo, "flows", &["dst"], vec![]); - let state = sketch_state(&mut memo, rows, SketchAlgorithm::Kmv, Reduction::by(vec![])); + let state = sketch_state(&mut memo, rows, SketchAlgorithm::KMV, Reduction::by(vec![])); let distinct = estimate(&mut memo, state, SketchStatistic::Cardinality); memo.add_query(MemoQuery { root: QueryRoot::Operator(distinct), @@ -399,7 +399,7 @@ fn with_series_over_jobs(series: u64, jobs: u64) -> DataWorkload { #[test] fn a_per_value_target_without_a_reduction_keeps_the_whole_failure_probability() { let mut memo = Memo::new(&with_series("m", 8)); - let (_, _, readout) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.99, 300); + let (_, _, readout) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.99, 300); let target = AccuracyTarget::max_error(0.0025) .failure_probability(0.01) .accuracy_metric(AccuracyMetric::Rank) @@ -413,7 +413,7 @@ fn a_per_value_target_without_a_reduction_keeps_the_whole_failure_probability() #[test] fn a_whole_result_target_without_a_reduction_splits_over_the_values_returned() { let mut memo = Memo::new(&with_series("m", 8)); - let (_, _, readout) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.99, 300); + let (_, _, readout) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.99, 300); let target = AccuracyTarget::max_error(0.0025) .failure_probability(0.01) .accuracy_metric(AccuracyMetric::Rank); @@ -697,7 +697,7 @@ fn a_topk_readout_splits_over_every_value_it_ranks() { let state = sketch_state( &mut memo, window, - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, Reduction::PerEntity, ); let topk = estimate(&mut memo, state, SketchStatistic::TopK { k: 10 }); @@ -772,7 +772,7 @@ fn a_level_met_by_the_same_builds_as_a_stricter_one_is_dropped() { #[test] fn levels_met_by_different_builds_are_both_kept() { let mut memo = Memo::new(&with_series("m", 8)); - let (_, _, readout) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.99, 300); + let (_, _, readout) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.99, 300); let rank = |scope| { AccuracyTarget::max_error(0.0025) .failure_probability(0.01) diff --git a/crates/accuracy/tests/measured_sketch_accuracy.rs b/crates/accuracy/tests/measured_sketch_accuracy.rs index f0fd13878..3bcee361c 100644 --- a/crates/accuracy/tests/measured_sketch_accuracy.rs +++ b/crates/accuracy/tests/measured_sketch_accuracy.rs @@ -12,7 +12,7 @@ use asap_types::ir::schema::FieldDataType; use asap_types::summary_type::{SketchAlgorithm, SketchParams, SketchStatistic}; fn kll() -> FieldDataType { - FieldDataType::Sketch(SketchAlgorithm::Kll) + FieldDataType::Sketch(SketchAlgorithm::KLL) } fn p99() -> SketchStatistic { @@ -337,7 +337,7 @@ fn the_returned_guarantee_states_the_recorded_failure_probability() { /// for a state merged from that many windows. #[test] fn a_measured_entry_supplies_a_guarantee_where_theory_states_no_failure_probability() { - let hll = FieldDataType::Sketch(SketchAlgorithm::Hll); + let hll = FieldDataType::Sketch(SketchAlgorithm::HLL); let parameters = SketchParams::Hll { precision: 13 }; let table = MeasuredSketchAccuracy { entries: vec![MeasuredAccuracyEntry { diff --git a/crates/cost/src/node/state_bytes/mod.rs b/crates/cost/src/node/state_bytes/mod.rs index 92d281d25..6ac79e339 100644 --- a/crates/cost/src/node/state_bytes/mod.rs +++ b/crates/cost/src/node/state_bytes/mod.rs @@ -93,7 +93,7 @@ pub fn keeps_every_value(measure: &AggIntent) -> bool { /// Bytes per state, from the summary's family, its /// parameters and `input_rows` (the rows one state folds). The bytes are -/// `asap_sketchlib`'s `estimated_memory_bytes` for the type the executor +/// `asap_sketchlib`'s `theoretical_memory_bytes` for the type the executor /// builds (Count-Min and Count Sketch over `f64` counters), given what the /// state is assumed to hold: /// - a Count-Min / Count Sketch top-k heap full of keys of @@ -282,10 +282,10 @@ pub fn sketch_state_bytes(params: &SketchParams, input_rows: StateInputRows) -> match params { SketchParams::Hydra(hydra) => sketch_state_bytes(&hydra.per_subpopulation(), input_rows), SketchParams::Cms { width, depth } => { - CountMinF64::estimated_memory_bytes(*depth as usize, *width as usize) as u64 + CountMinF64::theoretical_memory_bytes(*depth as usize, *width as usize) as u64 } SketchParams::CountSketch { width, depth } => { - CountSketch::, RegularPath>::estimated_memory_bytes( + CountSketch::, RegularPath>::theoretical_memory_bytes( *depth as usize, *width as usize, ) as u64 @@ -294,7 +294,7 @@ pub fn sketch_state_bytes(params: &SketchParams, input_rows: StateInputRows) -> width, depth, heap_size, - } => CountMinSketchWithHeap::, RegularPath>::estimated_memory_bytes( + } => CountMinSketchWithHeap::, RegularPath>::theoretical_memory_bytes( *depth as usize, *width as usize, *heap_size as usize, @@ -304,7 +304,7 @@ pub fn sketch_state_bytes(params: &SketchParams, input_rows: StateInputRows) -> width, depth, heap_size, - } => CountSketchWithHeap::, RegularPath>::estimated_memory_bytes( + } => CountSketchWithHeap::, RegularPath>::theoretical_memory_bytes( *depth as usize, *width as usize, *heap_size as usize, @@ -320,16 +320,16 @@ pub fn sketch_state_bytes(params: &SketchParams, input_rows: StateInputRows) -> // one assumed when none is declared (`assumed_magnitude_range`). SketchParams::DDSketch { alpha } => ddsketch_state_bytes(*alpha, input_rows), SketchParams::Hll { precision, .. } => { - HyperLogLog::::estimated_memory_bytes(usize::from(*precision)) as u64 + HyperLogLog::::theoretical_memory_bytes(usize::from(*precision)) as u64 } - SketchParams::Kmv { k, .. } => Kmv::estimated_memory_bytes(*k as usize, rows) as u64, + SketchParams::Kmv { k, .. } => Kmv::theoretical_memory_bytes(*k as usize, rows) as u64, SketchParams::UnivMon { heap_size, sketch_rows, sketch_cols, layers, .. - } => UnivMon::estimated_memory_bytes( + } => UnivMon::theoretical_memory_bytes( *heap_size as usize, *sketch_rows as usize, *sketch_cols as usize, @@ -603,7 +603,7 @@ fn ddsketch_span(alpha: f64, input_rows: StateInputRows) -> (u64, u64) { /// read in place), so its price is that layout's size, an upper bound on /// it whatever the values within the column's range: /// -/// - an 88-byte header (scalars, count width, form, each store's offset and +/// - a 64-byte header (scalars, count width, form, each store's offset and /// length) and the state's 4-byte offset in its column; /// - its counts at the narrowest width holding every count (1, 2, 4 or 8 /// bytes; no count exceeds the state's rows, so the width follows from @@ -628,19 +628,19 @@ fn ddsketch_span(alpha: f64, input_rows: StateInputRows) -> (u64, u64) { /// /// | values | range declared | charged ÷ held | /// |---|---|---| -/// | exponential (latency-like) | no | 1.0–4.0 | -/// | exponential (latency-like) | the generator's [2.7e-8, 1104] | 1.0–4.7 | -/// | lognormal σ = 1 | no | 1.0–5.4 | -/// | lognormal σ = 2 | no | 1.0–3.0 | -/// | log-uniform over 7 decades | no | 1.0–2.4 | +/// | exponential (latency-like) | no | 1.0–4.2 | +/// | exponential (latency-like) | the generator's [2.7e-8, 1104] | 1.0–4.9 | +/// | lognormal σ = 1 | no | 1.0–5.6 | +/// | lognormal σ = 2 | no | 1.0–3.1 | +/// | log-uniform over 7 decades | no | 1.0–2.5 | /// | log-uniform over 7 decades | [0.001, 1e4] | 1.0–1.9 | -/// | Zipf(1.1) integers in [1, 1e6] | no | 1.02–2.8 | +/// | Zipf(1.1) integers in [1, 1e6] | no | 1.03–2.8 | /// | Zipf(1.1) integers in [1, 1e6] | [1, 1e6] | 1.0–1.9 | -/// | narrow gauge 100 ± 10 | no | 1.4–20 | -/// | narrow gauge 100 ± 10 | [90, 110] | 1.0–1.07 | -/// | counter readings near 1e6 | no | 1.5–22 | -/// | per-series levels ± 10%, levels over [1, 1e5] | no | 1.4–20 | -/// | per-series levels ± 10%, levels over [1, 1e5] | [1, 1e5] | 1.4–12 | +/// | narrow gauge 100 ± 10 | no | 1.5–26 | +/// | narrow gauge 100 ± 10 | [90, 110] | 1.0–1.10 | +/// | counter readings near 1e6 | no | 1.6–28 | +/// | per-series levels ± 10%, levels over [1, 1e5] | no | 1.5–26 | +/// | per-series levels ± 10%, levels over [1, 1e5] | [1, 1e5] | 1.5–14.6 | /// /// Few rows per state are stored sparse and priced closely. Past them the /// price is the whole column range dense: values narrower than it (without @@ -653,12 +653,12 @@ fn ddsketch_span(alpha: f64, input_rows: StateInputRows) -> (u64, u64) { /// family, replace it. /// /// Example: at α = 0.01, a state of 10 values with no declared range is -/// stored sparse in at most 10 buckets at 1-byte counts: 88 + 4 + 40 + 16 = -/// 148 bytes. A gauge declared within [90, 110] spans 12 buckets: 600 rows, -/// dense at 2-byte counts, 88 + 4 + 24 = 116 bytes. +/// stored sparse in at most 10 buckets at 1-byte counts: 64 + 4 + 40 + 16 = +/// 124 bytes. A gauge declared within [90, 110] spans 12 buckets: 600 rows, +/// dense at 2-byte counts, 64 + 4 + 24 = 92 bytes. fn ddsketch_state_bytes(alpha: f64, input_rows: StateInputRows) -> u64 { // The view's header, and the state's 4-byte offset in its column. - const HEADER_BYTES: u64 = 88; + const HEADER_BYTES: u64 = 64; const OFFSET_BYTES: u64 = 4; let padded = |bytes: u64| bytes.div_ceil(8) * 8; let (_, stores) = ddsketch_span(alpha, input_rows); @@ -701,7 +701,7 @@ fn ddsketch_open_state_bytes(alpha: f64, input_rows: StateInputRows) -> u64 { use asap_sketchlib::DdSketch; let struct_bytes = std::mem::size_of::() as u64; let block_bytes = - DdSketch::estimated_memory_bytes(alpha, 1, 1.0, 1.0, false) as u64 - struct_bytes; + DdSketch::theoretical_memory_bytes(alpha, 1, 1.0, 1.0, false) as u64 - struct_bytes; let (span, stores) = ddsketch_span(alpha, input_rows); struct_bytes + stores * (block_bytes + 8 * (span - 1)) } diff --git a/crates/cost/src/node/state_bytes/tests.rs b/crates/cost/src/node/state_bytes/tests.rs index f1278e645..0c5db3f4b 100644 --- a/crates/cost/src/node/state_bytes/tests.rs +++ b/crates/cost/src/node/state_bytes/tests.rs @@ -366,7 +366,7 @@ fn state_bytes_bound_the_executors_charge() { let univmon_key_bounds = 2 * size_of::(); let families = [ ( - A::Kll, + A::KLL, SketchParams::Kll { k: 200 }, Rows::Values, Priced::Kll { k: 200 }, @@ -382,7 +382,7 @@ fn state_bytes_bound_the_executors_charge() { 10_000, ), ( - A::Cms, + A::CountMinSketch, SketchParams::Cms { width: 1_024, depth: 5, @@ -404,7 +404,7 @@ fn state_bytes_bound_the_executors_charge() { 10_000, ), ( - A::CmsWithHeap, + A::CountMinSketchWithHeap, SketchParams::CmsWithHeap { width: 16, depth: 1, @@ -428,7 +428,7 @@ fn state_bytes_bound_the_executors_charge() { 1_024, ), ( - A::Hll, + A::HLL, SketchParams::Hll { precision: 12 }, Rows::Values, Priced::Exact, @@ -436,7 +436,7 @@ fn state_bytes_bound_the_executors_charge() { 10_000, ), ( - A::Kmv, + A::KMV, SketchParams::Kmv { k: 1_024 }, Rows::Values, Priced::Exact, @@ -597,12 +597,12 @@ fn next_uniform(state: &mut u64) -> f64 { /// sets. Its charge as the executor seals it (a sketch shrunk, its /// `approx_memory_bytes`, but KLL, whose 10,000 rows are past `k` and /// priced open; an exact family's sealed column of 1,024 groups, -/// per group; for HydraCms its shared grid over its 10 groups) is compared +/// per group; for HydraCountMinSketch its shared grid over its 10 groups) is compared /// with `summary_state_bytes` for the same rows. Priced ÷ /// charged lies within [`BYTES_AGREEMENT_FACTOR`], or the family's row /// carries its [`KnownBytesGap`]. /// -/// HydraKll is left out: no plan builds it (it has no parameter list, +/// HydraKLL is left out: no plan builds it (it has no parameter list, /// and the executor's factory refuses it). #[test] fn priced_bytes_agree_with_the_executor() { @@ -642,25 +642,25 @@ fn priced_bytes_agree_with_the_executor() { // coin differs per run: the charge varies by about 0.2% (e.g. // 10,376 or 10,392 bytes), well inside `BYTES_AGREEMENT_FACTOR`. ( - sketch(A::Kll), + sketch(A::KLL), Some(SketchParams::Kll { k: 269 }), Rows::Values, None, ), ( - sketch(A::Hll), + sketch(A::HLL), Some(SketchParams::Hll { precision: 18 }), Rows::Values, None, ), ( - sketch(A::Kmv), + sketch(A::KMV), Some(SketchParams::Kmv { k: 106_263 }), Rows::Values, None, ), ( - sketch(A::Cms), + sketch(A::CountMinSketch), Some(SketchParams::Cms { width: 272, depth: 5, @@ -678,7 +678,7 @@ fn priced_bytes_agree_with_the_executor() { None, ), ( - sketch(A::CmsWithHeap), + sketch(A::CountMinSketchWithHeap), Some(SketchParams::CmsWithHeap { width: 272, depth: 5, @@ -773,7 +773,7 @@ fn priced_bytes_agree_with_the_executor() { // As the executor seals a window, except a KLL past `k` rows, // which is priced as the open sketch a query-time merge holds // (`kll_sealed_bytes`). - if !matches!(family, FieldDataType::Sketch(A::Kll)) { + if !matches!(family, FieldDataType::Sketch(A::KLL)) { updater.shrink_to_fit(); } let charged = updater.into_accumulator().approx_memory_bytes() as u64; @@ -824,7 +824,7 @@ fn priced_bytes_agree_with_the_executor() { shared_rows: 3, shared_columns: 64, }); - let hydra_family = sketch(A::HydraCms); + let hydra_family = sketch(A::HydraCountMinSketch); let mut grid = create_hydra_cms(&hydra_family, Some(&hydra)).unwrap(); let hydra_rows_fed = Rows::Keyed.fed(); let mut seed = 0x5EED_u64; @@ -946,9 +946,9 @@ fn counter_near_a_million(series: u64, n: u32) -> Vec { /// stored sparse, priced closely); the count width is bounded by the rows, /// which over-charges 256 to 65,535 rows whose largest count fits a byte /// up to about 2x (latency-like values in the generator's declared range -/// 4.7x at 600 rows); narrow values without a declared range (a gauge, a +/// 4.9x at 600 rows); narrow values without a declared range (a gauge, a /// counter's readings, per-series levels) are over-charged by the -/// wide-spread margin's span, up to 20x at 36,000 rows. +/// wide-spread margin's span, up to 28x. #[test] fn ddsketch_state_bytes_by_value_shape_lie_within_their_bands() { let alpha = 0.01; @@ -988,20 +988,20 @@ fn ddsketch_state_bytes_by_value_shape_lie_within_their_bands() { range(1.0, 1e6), 0.95..=2.0, ), - ("narrow gauge", narrow_gauge, None, 1.3..=21.2), + ("narrow gauge", narrow_gauge, None, 1.3..=26.0), ( "narrow gauge, declared", narrow_gauge, range(90.0, 110.0), 0.95..=1.15, ), - ("counter near 1e6", counter_near_a_million, None, 1.4..=22.9), - ("per-series levels", per_series_levels, None, 1.3..=21.2), + ("counter near 1e6", counter_near_a_million, None, 1.4..=28.7), + ("per-series levels", per_series_levels, None, 1.3..=26.0), ( "per-series levels, column range declared", per_series_levels, range(1.0, 1e5), - 1.3..=12.2, + 1.3..=14.9, ), ]; for (name, values, value_magnitude_range, band) in shapes { @@ -1025,8 +1025,30 @@ fn ddsketch_state_bytes_by_value_shape_lie_within_their_bands() { } } +/// The view header the price charges is the library's: a one-value +/// DDSketch's view bytes (header and one 1-byte count padded to 8), plus +/// the state's 4-byte offset in its column, are what a one-row state is +/// priced at. +#[test] +fn stored_ddsketch_header_is_the_librarys_view_header() { + let alpha = 0.01; + let mut sketch = asap_sketchlib::DdSketch::new(alpha); + sketch.add(&42.0); + let held = sketch.to_view_bytes().len() as u64 + 4; + let priced = sketch_state_bytes( + &SketchParams::DDSketch { alpha }, + StateInputRows { + folded_rows_per_state: Some(1.0), + non_negative: true, + value_magnitude_range: None, + distinct_values: None, + }, + ); + assert_eq!(priced, held, "priced {priced} B, view layout {held} B"); +} + /// A stored DDSketch is priced at its view layout and its offset in the -/// column (88 + 4 bytes), then the occupied buckets dense over the +/// column (the library's 64-byte header + 4 bytes), then the occupied buckets dense over the /// column's range (declared, or the assumed nine decades; plus one bucket /// for an unaligned start) or sparse at one bucket per row (4-byte index /// and count each), whichever is smaller, at the narrowest count width the @@ -1034,6 +1056,9 @@ fn ddsketch_state_bytes_by_value_shape_lie_within_their_bands() { #[test] fn stored_ddsketch_states_are_priced_at_their_view_layout() { let alpha = 0.01; + // The library's view header (an empty sketch's view holds only it) and + // the state's 4-byte offset in its column. + let fixed = asap_sketchlib::DdSketch::new(alpha).to_view_bytes().len() as u64 + 4; let priced = |rows_per_state: Option, non_negative, value_magnitude_range| { sketch_state_bytes( &SketchParams::DDSketch { alpha }, @@ -1050,26 +1075,26 @@ fn stored_ddsketch_states_are_priced_at_their_view_layout() { max_abs: 110.0, }); // One row: one bucket, a 1-byte count dense (padded to 8). - assert_eq!(priced(Some(1), true, None), 92 + 8); + assert_eq!(priced(Some(1), true, None), fixed + 8); // 10 rows over the assumed nine decades: sparse, 10 buckets at most. - assert_eq!(priced(Some(10), true, None), 92 + 40 + 16); + assert_eq!(priced(Some(10), true, None), fixed + 40 + 16); // A gauge's 12 buckets, dense: 1, 2 and 2 bytes per count. - assert_eq!(priced(Some(10), true, gauge), 92 + 16); - assert_eq!(priced(Some(600), true, gauge), 92 + 24); - assert_eq!(priced(Some(36_000), true, gauge), 92 + 24); + assert_eq!(priced(Some(10), true, gauge), fixed + 16); + assert_eq!(priced(Some(600), true, gauge), fixed + 24); + assert_eq!(priced(Some(36_000), true, gauge), fixed + 24); // 4 bytes up to u32::MAX rows, then 8 (2^33: past u32::MAX once the // rows are rounded within their relative 1e-9, `rows_per_state`). - assert_eq!(priced(Some(u64::from(u32::MAX)), true, gauge), 92 + 48); - assert_eq!(priced(Some(1 << 33), true, gauge), 92 + 96); + assert_eq!(priced(Some(u64::from(u32::MAX)), true, gauge), fixed + 48); + assert_eq!(priced(Some(1 << 33), true, gauge), fixed + 96); assert!(priced(Some(10), true, None) < priced(Some(100), true, None)); // Unknown rows: the assumed range, dense at 8 bytes. let unknown = priced(None, true, None); - assert_eq!((unknown - 92) % 8, 0); + assert_eq!((unknown - fixed) % 8, 0); assert!(unknown > priced(Some(1_000_000), true, None)); // Signed values fill two stores. assert_eq!( - priced(Some(20_000), false, None) - 92, - 2 * (priced(Some(10_000), true, None) - 92) + priced(Some(20_000), false, None) - fixed, + 2 * (priced(Some(10_000), true, None) - fixed) ); } diff --git a/crates/cost/src/node/usage/mod.rs b/crates/cost/src/node/usage/mod.rs index be51e28d7..8afa56b60 100644 --- a/crates/cost/src/node/usage/mod.rs +++ b/crates/cost/src/node/usage/mod.rs @@ -3043,7 +3043,7 @@ fn operations_text(operations: f64) -> String { } /// A summary type's name in reports: a sketch by its algorithm, e.g. -/// `HydraCms`; an exact accumulator by its kind. +/// `HydraCountMinSketch`; an exact accumulator by its kind. // Any other type prints its Debug form, which names a new variant too, so // listing them would decide nothing. #[allow(clippy::wildcard_enum_match_arm)] diff --git a/crates/cost/src/node/usage/tests.rs b/crates/cost/src/node/usage/tests.rs index 075380f54..1ea07c071 100644 --- a/crates/cost/src/node/usage/tests.rs +++ b/crates/cost/src/node/usage/tests.rs @@ -297,7 +297,7 @@ fn a_project_or_filter_over_states_passes_their_family_on() { let kll = SketchParams::Kll { k: 547 }; let state_field = Field { name: "state".into(), - dtype: FieldDataType::Sketch(asap_types::summary_type::SketchAlgorithm::Kll), + dtype: FieldDataType::Sketch(asap_types::summary_type::SketchAlgorithm::KLL), nullable: false, }; let states = PhysicalASAPDAGNode { @@ -964,7 +964,7 @@ fn a_query_time_chain_sizes_its_windows_from_the_time_its_input_spans() { retention_ms: Some(300_000), ..node(Payload::ASAP(ASAPOp::SummaryTumblingWindowChain { child: 0, - summary_type: FieldDataType::Sketch(asap_types::summary_type::SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(asap_types::summary_type::SketchAlgorithm::KLL), input: SummaryUpdate::column(ColumnRef::SampleValue), reduction: Reduction::PerEntity, filter: None, @@ -1380,7 +1380,7 @@ fn a_kmv_build_costs_per_retained_hash_it_compares() { parameters: Some(SketchParams::Kmv { k }), ..node(Payload::ASAP(ASAPOp::SummaryAgg { child: 0, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kmv), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KMV), input: SummaryUpdate::column(ColumnRef::Named("user_id".into())), reduction: Reduction::by(keys.clone()), filter: None, @@ -1465,7 +1465,7 @@ fn an_operation_count_prints_to_three_decimals() { #[test] fn a_build_detail_prints_its_operations_per_row_to_three_decimals() { use asap_types::summary_type::SketchAlgorithm; - let detail = user_id_sketch_detail(SketchParams::Kmv { k: 4_323 }, SketchAlgorithm::Kmv, false); + let detail = user_id_sketch_detail(SketchParams::Kmv { k: 4_323 }, SketchAlgorithm::KMV, false); assert!(detail.contains("300000 rows x 304.926 ops"), "{detail}"); } @@ -1474,7 +1474,7 @@ fn a_build_detail_prints_its_operations_per_row_to_three_decimals() { #[test] fn a_chain_detail_prints_its_operations_per_row_to_three_decimals() { use asap_types::summary_type::SketchAlgorithm; - let detail = user_id_sketch_detail(SketchParams::Kmv { k: 4_323 }, SketchAlgorithm::Kmv, true); + let detail = user_id_sketch_detail(SketchParams::Kmv { k: 4_323 }, SketchAlgorithm::KMV, true); assert!(detail.contains("300000 rows x 714.976 ops"), "{detail}"); } @@ -1485,7 +1485,7 @@ fn a_state_allocation_prints_to_three_decimals() { use asap_types::summary_type::SketchAlgorithm; let detail = user_id_sketch_detail( SketchParams::Cms { width: 7, depth: 1 }, - SketchAlgorithm::Cms, + SketchAlgorithm::CountMinSketch, false, ); assert!( @@ -1531,7 +1531,7 @@ fn a_kmv_build_charges_its_measured_time_per_row() { parameters: Some(SketchParams::Kmv { k }), ..node(Payload::ASAP(ASAPOp::SummaryAgg { child: 0, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kmv), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KMV), input: SummaryUpdate::column(ColumnRef::Named("user_id".into())), reduction: Reduction::by(keys.clone()), filter: None, @@ -1655,11 +1655,11 @@ fn a_kmv_rollup_merge_costs_per_hash_it_inserts() { output_schema: Schema::new(vec![ Field::new("region", FieldDataType::Plain(DataType::Utf8), false), Field::new("service", FieldDataType::Plain(DataType::Utf8), false), - Field::new("state", FieldDataType::Sketch(SketchAlgorithm::Kmv), false), + Field::new("state", FieldDataType::Sketch(SketchAlgorithm::KMV), false), ]), ..node(Payload::ASAP(ASAPOp::SummaryAgg { child: 0, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kmv), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KMV), input: SummaryUpdate::column(ColumnRef::Named("user_id".into())), reduction: Reduction::by(vec![0, 1]), filter: None, @@ -1735,11 +1735,11 @@ fn a_rollup_merges_its_states_when_its_group_estimate_ties_its_input() { output_schema: Schema::new(vec![ Field::new("region", FieldDataType::Plain(DataType::Utf8), false), Field::new("service", FieldDataType::Plain(DataType::Utf8), false), - Field::new("state", FieldDataType::Sketch(SketchAlgorithm::Kmv), false), + Field::new("state", FieldDataType::Sketch(SketchAlgorithm::KMV), false), ]), ..node(Payload::ASAP(ASAPOp::SummaryAgg { child: 0, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kmv), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KMV), input: SummaryUpdate::column(ColumnRef::Named("user_id".into())), reduction: Reduction::by(vec![0, 1]), filter: None, @@ -2653,7 +2653,7 @@ fn kll_merge_cpu_ops_over(k: u32, window_ms: u64, range_s: u64) -> f64 { }; let mut chain = node(Payload::ASAP(ASAPOp::SummaryTumblingWindowChain { child: 0, - summary_type: FieldDataType::Sketch(asap_types::summary_type::SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(asap_types::summary_type::SketchAlgorithm::KLL), input: SummaryUpdate::column(ColumnRef::SampleValue), reduction: Reduction::PerEntity, filter: None, @@ -2664,7 +2664,7 @@ fn kll_merge_cpu_ops_over(k: u32, window_ms: u64, range_s: u64) -> f64 { chain.retention_ms = Some(range_s * 1_000); chain.parameters = Some(SketchParams::Kll { k }); chain.output_schema = state_schema( - FieldDataType::Sketch(asap_types::summary_type::SketchAlgorithm::Kll), + FieldDataType::Sketch(asap_types::summary_type::SketchAlgorithm::KLL), &[asap_types::ir::schema::PROMQL_SERIES_IDENTITY], ); let chain_usage = node_resource_usage_and_cost( @@ -2926,7 +2926,7 @@ fn a_merge_over_several_inputs_sizes_its_state_for_all_of_them() { let k = 4_000; let windows = PhysicalASAPDAGNode { output_schema: state_schema( - FieldDataType::Sketch(asap_types::summary_type::SketchAlgorithm::Kll), + FieldDataType::Sketch(asap_types::summary_type::SketchAlgorithm::KLL), &[asap_types::ir::schema::PROMQL_SERIES_IDENTITY], ), ..node(Payload::NonASAP(NonASAPOp::TimeRange { @@ -3114,7 +3114,7 @@ fn a_kll_estimate_over_a_state_built_by_updates_charges_its_measured_time() { kll_estimate_us_per_group( Payload::ASAP(ASAPOp::SummaryAgg { child: 0, - summary_type: FieldDataType::Sketch(asap_types::summary_type::SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(asap_types::summary_type::SketchAlgorithm::KLL), input: SummaryUpdate::column(ColumnRef::SampleValue), reduction: Reduction::PerEntity, filter: None, @@ -3241,7 +3241,7 @@ fn an_ingestion_time_kll_chain_is_updates_routing_visits_emits_and_a_carried_lab use asap_types::summary_type::SketchAlgorithm; let settings = CostInputs::default(); let data = thousand_series_sampled_every(1_000); - let kll = FieldDataType::Sketch(SketchAlgorithm::Kll); + let kll = FieldDataType::Sketch(SketchAlgorithm::KLL); let scan = node(metric_scan("latency")); let chain = PhysicalASAPDAGNode { retention_ms: Some(300_000), @@ -3487,13 +3487,13 @@ fn terms_reproduce_the_formula_cpu_of_every_costed_node() { ), ( "KLL k = 547", - FieldDataType::Sketch(SketchAlgorithm::Kll), + FieldDataType::Sketch(SketchAlgorithm::KLL), StateFamily::Sketch(&kll_547), Some(kll_547.clone()), ), ( "KLL k = 1,404", - FieldDataType::Sketch(SketchAlgorithm::Kll), + FieldDataType::Sketch(SketchAlgorithm::KLL), StateFamily::Sketch(&kll_1404), Some(kll_1404.clone()), ), @@ -3601,7 +3601,7 @@ fn terms_reproduce_the_formula_cpu_of_every_costed_node() { parameters: Some(SketchParams::Kmv { k }), ..node(Payload::ASAP(ASAPOp::SummaryAgg { child: 0, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kmv), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KMV), input: SummaryUpdate::column(ColumnRef::Named("user_id".into())), reduction: Reduction::by(keys.clone()), filter: None, @@ -3651,11 +3651,11 @@ fn terms_reproduce_the_formula_cpu_of_every_costed_node() { output_schema: Schema::new(vec![ Field::new("region", FieldDataType::Plain(DataType::Utf8), false), Field::new("service", FieldDataType::Plain(DataType::Utf8), false), - Field::new("state", FieldDataType::Sketch(SketchAlgorithm::Kmv), false), + Field::new("state", FieldDataType::Sketch(SketchAlgorithm::KMV), false), ]), ..node(Payload::ASAP(ASAPOp::SummaryAgg { child: 0, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kmv), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KMV), input: SummaryUpdate::column(ColumnRef::Named("user_id".into())), reduction: Reduction::by(vec![0, 1]), filter: None, @@ -3734,7 +3734,7 @@ fn terms_reproduce_the_formula_cpu_of_every_costed_node() { })); let kll_updates = node(Payload::ASAP(ASAPOp::SummaryAgg { child: 0, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KLL), input: SummaryUpdate::column(ColumnRef::SampleValue), reduction: Reduction::PerEntity, filter: None, @@ -3943,7 +3943,7 @@ fn terms_ignore_the_measured_table_and_the_calibration_factor() { parameters: Some(SketchParams::Kll { k: 547 }), ..node(Payload::ASAP(ASAPOp::SummaryAgg { child: 0, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KLL), input: SummaryUpdate::column(ColumnRef::SampleValue), reduction: Reduction::PerEntity, filter: None, @@ -4250,7 +4250,11 @@ fn counter_sketch_charges_ms(shape: &CounterSketchShape) -> CounterSketchCharges keyed(SummaryInputExpr::Constant(1.0)), SketchStatistic::FrequencyL2, ), - SketchParams::CmsWithHeap { .. } => (SketchAlgorithm::CmsWithHeap, keyed(value()), top_10), + SketchParams::CmsWithHeap { .. } => ( + SketchAlgorithm::CountMinSketchWithHeap, + keyed(value()), + top_10, + ), SketchParams::CountSketchWithHeap { .. } => { (SketchAlgorithm::CountSketchWithHeap, keyed(value()), top_10) } @@ -4835,7 +4839,7 @@ fn ingestion_and_query_time_chains_over_a_fractional_rate_fold_the_same_rows() { parameters: Some(SketchParams::Kll { k: 547 }), ..node(Payload::ASAP(ASAPOp::SummaryTumblingWindowChain { child: 0, - summary_type: FieldDataType::Sketch(asap_types::summary_type::SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(asap_types::summary_type::SketchAlgorithm::KLL), input: SummaryUpdate::column(ColumnRef::SampleValue), reduction: Reduction::PerEntity, filter: None, diff --git a/crates/devtools/tests/planner_fuzz.rs b/crates/devtools/tests/planner_fuzz.rs index 49132d5ac..43434b609 100644 --- a/crates/devtools/tests/planner_fuzz.rs +++ b/crates/devtools/tests/planner_fuzz.rs @@ -250,7 +250,7 @@ fn sketch_rollup_witness_costs_for_a_grouped_quantile() { .expect("the data facts deserialize"); match check(Relation::CoarserGrouping, workload, 0) { Outcome::Holds(m) | Outcome::Violated(m) => { - assert!(m.base_plan.contains("Kll"), "{}", m.base_plan); + assert!(m.base_plan.contains("KLL"), "{}", m.base_plan); assert_eq!( m.witness.and_then(|w| w.derivation), Some(Witness::SketchRollup { diff --git a/crates/executor/src/capability/mod.rs b/crates/executor/src/capability/mod.rs index 133c3e0c5..f9d51ed96 100644 --- a/crates/executor/src/capability/mod.rs +++ b/crates/executor/src/capability/mod.rs @@ -71,15 +71,15 @@ fn validate_sketch_parameters( use SketchParams as P; let keyed = match (algorithm, parameters) { // `asap_sketchlib` silently caps a larger `k`. - (A::Kll, P::Kll { k }) if (8..=planner_types::summary_type::KLL_MAX_K).contains(k) => false, + (A::KLL, P::Kll { k }) if (8..=planner_types::summary_type::KLL_MAX_K).contains(k) => false, (A::DDSketch, P::DDSketch { alpha }) if alpha.is_finite() && *alpha > 0.0 && *alpha < 1.0 => { false } - (A::Hll, P::Hll { precision }) if HLL_PRECISIONS.contains(precision) => false, - (A::Kmv, P::Kmv { k }) if *k >= crate::summary_kernels::kmv::KMV_MIN_K => false, - (A::Cms, P::Cms { width, depth }) if valid_matrix(*width, *depth) => true, + (A::HLL, P::Hll { precision }) if HLL_PRECISIONS.contains(precision) => false, + (A::KMV, P::Kmv { k }) if *k >= crate::summary_kernels::kmv::KMV_MIN_K => false, + (A::CountMinSketch, P::Cms { width, depth }) if valid_matrix(*width, *depth) => true, // The kernel's shape rules (an odd depth, for the median). (A::CountSketch, P::CountSketch { width, depth }) if valid_matrix(*width, *depth) @@ -92,7 +92,7 @@ fn validate_sketch_parameters( { true } - (A::CmsWithHeap | A::CountSketchWithHeap, _) + (A::CountMinSketchWithHeap | A::CountSketchWithHeap, _) if weighted_frequency::WeightedFrequency::configuration(algorithm, parameters) .is_ok_and(|(_, width, depth, _)| valid_matrix(width as u32, depth as u32)) => { @@ -173,11 +173,13 @@ pub(crate) fn constant_row_weight(weight: f64) -> Result Result<(), String> { match family { - SummaryFamilyType::Sketch(SketchAlgorithm::HydraCms) => Ok(()), - _ => Err("a Hydra algorithm other than HydraCms has no registered kernel".into()), + SummaryFamilyType::Sketch(SketchAlgorithm::HydraCountMinSketch) => Ok(()), + _ => { + Err("a Hydra algorithm other than HydraCountMinSketch has no registered kernel".into()) + } } } @@ -248,18 +250,18 @@ pub fn validate_native_family(family: &SummaryFamilyType) -> Result<(), Error> { use planner_types::summary_type::SketchAlgorithm as A; let native = match family { SummaryFamilyType::ExactAggregate(..) => exact_kernel(family), - // HydraCms is built by the all-groups summary build. Plain Count-Min + // HydraCountMinSketch is built by the all-groups summary build. Plain Count-Min // is native as stored state only: it merges and reads its bare // count, but the DAG does not build it from rows. SummaryFamilyType::Sketch( - A::HydraCms - | A::Cms - | A::CmsWithHeap + A::HydraCountMinSketch + | A::CountMinSketch + | A::CountMinSketchWithHeap | A::CountSketchWithHeap - | A::Kll + | A::KLL | A::DDSketch - | A::Hll - | A::Kmv + | A::HLL + | A::KMV | A::UnivMon, ) => true, _ => false, @@ -281,12 +283,15 @@ pub fn validate_native_family(family: &SummaryFamilyType) -> Result<(), Error> { /// grid; KLL's rank; UnivMon's G-sum). Plain Count Sketch is built but read /// from nothing. pub(crate) const EVALUATED_READOUTS: &[(SketchAlgorithm, &[StatisticKind])] = &[ - (SketchAlgorithm::Cms, &[StatisticKind::Total]), - (SketchAlgorithm::CmsWithHeap, &[StatisticKind::TopK]), + (SketchAlgorithm::CountMinSketch, &[StatisticKind::Total]), + ( + SketchAlgorithm::CountMinSketchWithHeap, + &[StatisticKind::TopK], + ), (SketchAlgorithm::CountSketchWithHeap, &[StatisticKind::TopK]), - (SketchAlgorithm::Hll, &[StatisticKind::Distinct]), - (SketchAlgorithm::Kmv, &[StatisticKind::Distinct]), - (SketchAlgorithm::Kll, &[StatisticKind::Quantile]), + (SketchAlgorithm::HLL, &[StatisticKind::Distinct]), + (SketchAlgorithm::KMV, &[StatisticKind::Distinct]), + (SketchAlgorithm::KLL, &[StatisticKind::Quantile]), (SketchAlgorithm::DDSketch, &[StatisticKind::Quantile]), ( SketchAlgorithm::UnivMon, @@ -303,7 +308,9 @@ pub(crate) const EVALUATED_READOUTS: &[(SketchAlgorithm, &[StatisticKind])] = &[ /// family-capability table row answers it. fn evaluates(family: &SummaryFamilyType, readout: StatisticKind) -> bool { match family { - SummaryFamilyType::Sketch(SketchAlgorithm::HydraCms | SketchAlgorithm::HydraKll) => true, + SummaryFamilyType::Sketch( + SketchAlgorithm::HydraCountMinSketch | SketchAlgorithm::HydraKLL, + ) => true, SummaryFamilyType::Sketch(kind) => EVALUATED_READOUTS .iter() .any(|(family, readouts)| family == kind && readouts.contains(&readout)), @@ -324,7 +331,10 @@ pub fn validate_sketch_evaluation( // HydraCms answers a group's item frequency. A group's total needs a // group-mass query asap_sketchlib's Hydra lacks. if readout == StatisticKind::Total - && matches!(family, SummaryFamilyType::Sketch(SketchAlgorithm::HydraCms)) + && matches!( + family, + SummaryFamilyType::Sketch(SketchAlgorithm::HydraCountMinSketch) + ) { return Err(Error::Invalid( "HydraCms does not answer a group total: asap_sketchlib's Hydra has no group-mass \ diff --git a/crates/executor/src/operators/summary/mod.rs b/crates/executor/src/operators/summary/mod.rs index 0b51dfc06..fd532806b 100644 --- a/crates/executor/src/operators/summary/mod.rs +++ b/crates/executor/src/operators/summary/mod.rs @@ -46,8 +46,9 @@ impl Operator { use crate::summary_kernels::weighted_frequency::WeightedFrequency; use planner_types::summary_type::SketchAlgorithm as A; crate::values::validate_family(&family)?; - let SummaryFamilyType::Sketch(algorithm @ (A::CmsWithHeap | A::CountSketchWithHeap)) = - &family + let SummaryFamilyType::Sketch( + algorithm @ (A::CountMinSketchWithHeap | A::CountSketchWithHeap), + ) = &family else { return Err(invalid("keyed sketch required")); }; @@ -198,7 +199,7 @@ impl Operator { crate::values::validate_family(family)?; if !matches!( family, - SummaryFamilyType::Sketch(A::CmsWithHeap | A::CountSketchWithHeap) + SummaryFamilyType::Sketch(A::CountMinSketchWithHeap | A::CountSketchWithHeap) ) { return Err(invalid("keyed evaluation requires a keyed summary state")); } @@ -367,7 +368,7 @@ fn accepts_update_type(family: &SummaryFamilyType, dtype: &DataType) -> bool { }; match dtype { DataType::Float64 | DataType::Int64 => true, - DataType::Utf8 => matches!(kind, A::Kmv | A::Hll | A::UnivMon), + DataType::Utf8 => matches!(kind, A::KMV | A::HLL | A::UnivMon), DataType::Bool => kind == &A::UnivMon, _ => false, } @@ -402,7 +403,7 @@ impl Operator { /// non-integral total rather than rounding it. fn integral_count(family: &SummaryFamilyType, query: &SummaryEvaluation) -> bool { matches!(family, SummaryFamilyType::Sketch(kind) - if kind == &planner_types::summary_type::SketchAlgorithm::Cms) + if kind == &planner_types::summary_type::SketchAlgorithm::CountMinSketch) && matches!( query, SummaryEvaluation::Sketch(planner_types::summary_type::SketchStatistic::PointCount { diff --git a/crates/executor/src/physical_planner/mod.rs b/crates/executor/src/physical_planner/mod.rs index 96dfb010a..6e38ae546 100644 --- a/crates/executor/src/physical_planner/mod.rs +++ b/crates/executor/src/physical_planner/mod.rs @@ -1593,7 +1593,7 @@ fn summary_agg_build( }; if matches!( family, - FieldDataType::Sketch(planner_types::summary_type::SketchAlgorithm::HydraCms) + FieldDataType::Sketch(planner_types::summary_type::SketchAlgorithm::HydraCountMinSketch) ) { crate::capability::validate_summary_kernel(family, parameters, update) .map_err(Error::Invalid)?; @@ -1693,7 +1693,7 @@ fn unkeyed_frequency_family(family: &FieldDataType) -> bool { matches!(family, FieldDataType::Sketch(kind) if matches!( kind, planner_types::summary_type::SketchAlgorithm::UnivMon - | planner_types::summary_type::SketchAlgorithm::Hll + | planner_types::summary_type::SketchAlgorithm::HLL )) } fn summary_column(input: &SchemaRef) -> Result { diff --git a/crates/executor/src/summary_kernels/dd_sketch.rs b/crates/executor/src/summary_kernels/dd_sketch.rs index 1ad645616..aac258980 100644 --- a/crates/executor/src/summary_kernels/dd_sketch.rs +++ b/crates/executor/src/summary_kernels/dd_sketch.rs @@ -114,7 +114,8 @@ mod tests { // at ranks ⌊q (n − 1)⌋ and ⌈q (n − 1)⌉, as PromQL `quantile_over_time` // and SQL `percentile_cont` do: [20, 40] at q = 0.9 is 38 (nearest rank // read 40), within α of the interpolated value; q = 0 and q = 1 read the - // exact minimum and maximum. + // lowest and highest occupied bucket, within α of the minimum and + // maximum (the sketch keeps no exact minimum or maximum). #[test] fn quantile_interpolates_between_adjacent_order_statistics() { let alpha = 0.01; @@ -124,8 +125,8 @@ mod tests { } let at = |q| dd.estimate(&SketchStatistic::Quantile { q }).unwrap(); assert!((at(0.9) - 38.0).abs() <= alpha * 38.0, "{}", at(0.9)); - assert_eq!(at(0.0), 20.0); - assert_eq!(at(1.0), 40.0); + assert!((at(0.0) - 20.0).abs() <= alpha * 20.0, "{}", at(0.0)); + assert!((at(1.0) - 40.0).abs() <= alpha * 40.0, "{}", at(1.0)); let mut four = DDSketchAccumulator::new(alpha); for v in [1.0, 2.0, 3.0, 4.0] { four.inner.add(&v); diff --git a/crates/executor/src/summary_kernels/factory/mod.rs b/crates/executor/src/summary_kernels/factory/mod.rs index 36d675c61..4b67d6ece 100644 --- a/crates/executor/src/summary_kernels/factory/mod.rs +++ b/crates/executor/src/summary_kernels/factory/mod.rs @@ -510,7 +510,7 @@ fn cms_dims(params: &SketchParams) -> (usize, usize) { (*depth as usize, *width as usize) } other => unreachable!( - "accumulator_spec() paired SketchAlgorithm::Cms/CountSketch with unexpected params: {other:?}" + "accumulator_spec() paired SketchAlgorithm::CountMinSketch/CountSketch with unexpected params: {other:?}" ), } } @@ -526,7 +526,10 @@ pub fn create_planner_accumulator( input: &planner_types::summary_type::SummaryUpdate, ) -> Result, String> { crate::capability::validate_summary_kernel(family, parameters, input)?; - if matches!(family, SummaryFamilyType::Sketch(SketchAlgorithm::HydraCms)) { + if matches!( + family, + SummaryFamilyType::Sketch(SketchAlgorithm::HydraCountMinSketch) + ) { return Err( "HydraCms has one state for all groups; build it with `create_hydra_cms`".into(), ); @@ -546,7 +549,7 @@ pub fn create_planner_accumulator( return Err("a sketch summary needs its parameters θ".into()); }; let updater: Box = match (kind, params) { - (SketchAlgorithm::Kll, SketchParams::Kll { k, .. }) => { + (SketchAlgorithm::KLL, SketchParams::Kll { k, .. }) => { if *k > planner_types::summary_type::KLL_MAX_K { return Err("KLL k exceeds runtime bound".into()); } @@ -557,7 +560,7 @@ pub fn create_planner_accumulator( (SketchAlgorithm::DDSketch, SketchParams::DDSketch { alpha }) => { Box::new(DDSketchAccumulatorUpdater::new(*alpha)) } - (SketchAlgorithm::Cms, params @ SketchParams::Cms { .. }) => { + (SketchAlgorithm::CountMinSketch, params @ SketchParams::Cms { .. }) => { let (r, c) = cms_dims(params); Box::new(CmsAccumulatorUpdater::new(r, c)?) } @@ -568,7 +571,7 @@ pub fn create_planner_accumulator( .map_err(|e| e.to_string())?, ) } - (SketchAlgorithm::CmsWithHeap | SketchAlgorithm::CountSketchWithHeap, _) => { + (SketchAlgorithm::CountMinSketchWithHeap | SketchAlgorithm::CountSketchWithHeap, _) => { let (algorithm, width, depth, capacity) = WeightedFrequency::configuration(kind, params).map_err(|e| e.to_string())?; Box::new( @@ -576,10 +579,10 @@ pub fn create_planner_accumulator( .map_err(|e| e.to_string())?, ) } - (SketchAlgorithm::Hll, SketchParams::Hll { precision, .. }) => Box::new(HllUpdater { + (SketchAlgorithm::HLL, SketchParams::Hll { precision, .. }) => Box::new(HllUpdater { acc: HllSketchAccumulator::new(*precision).map_err(|e| e.to_string())?, }), - (SketchAlgorithm::Kmv, SketchParams::Kmv { k, .. }) => { + (SketchAlgorithm::KMV, SketchParams::Kmv { k, .. }) => { Box::new(crate::summary_kernels::kmv::KmvAccumulator::new(*k)) } ( @@ -614,7 +617,7 @@ pub fn create_planner_accumulator( Ok(updater) } -/// Construct the one state a HydraCms family shares across its groups, +/// Construct the one state a HydraCountMinSketch family shares across its groups, /// sized by its θ `parameters` (`SketchParams::Hydra(HydraParams::HydraCms /// { .. })`). The update contract is checked with the plan by /// `validate_summary_kernel`. diff --git a/crates/executor/src/summary_kernels/factory/tests.rs b/crates/executor/src/summary_kernels/factory/tests.rs index 5c5521248..49edb56d2 100644 --- a/crates/executor/src/summary_kernels/factory/tests.rs +++ b/crates/executor/src/summary_kernels/factory/tests.rs @@ -5,7 +5,7 @@ use super::*; fn sketch_kernels_need_their_own_parameters() { use planner_types::summary_type::{ExactKind, ExactParams, SummaryUpdate}; let update = SummaryUpdate::column(planner_types::ir::scalar::ColumnRef::SampleValue); - let kll = SummaryFamilyType::Sketch(SketchAlgorithm::Kll); + let kll = SummaryFamilyType::Sketch(SketchAlgorithm::KLL); let k200 = SketchParams::Kll { k: 200 }; assert!(create_planner_accumulator(&kll, Some(&k200), &update).is_ok()); assert!(create_planner_accumulator(&kll, None, &update).is_err()); @@ -21,7 +21,7 @@ fn sketch_kernels_need_their_own_parameters() { #[test] fn hydra_cms_builds_one_shared_grid() { use planner_types::summary_type::{HydraParams, SummaryInputExpr, SummaryUpdate}; - let family = SummaryFamilyType::Sketch(SketchAlgorithm::HydraCms); + let family = SummaryFamilyType::Sketch(SketchAlgorithm::HydraCountMinSketch); let hydra = SketchParams::Hydra(HydraParams::HydraCms { width: 128, depth: 3, diff --git a/crates/executor/src/summary_kernels/hydra_cms.rs b/crates/executor/src/summary_kernels/hydra_cms.rs index e5f09e043..a47c9496d 100644 --- a/crates/executor/src/summary_kernels/hydra_cms.rs +++ b/crates/executor/src/summary_kernels/hydra_cms.rs @@ -1,4 +1,4 @@ -//! Hydra over Count-Min Sketch (`SketchAlgorithm::HydraCms`) over `asap_sketchlib::Hydra`. +//! Hydra over Count-Min Sketch (`SketchAlgorithm::HydraCountMinSketch`) over `asap_sketchlib::Hydra`. //! //! One `shared_rows × shared_columns` grid of Count-Min cells serves every //! group: a group hashes to one cell per row, and that cell's Count-Min diff --git a/crates/executor/src/summary_kernels/state_column_updater/mod.rs b/crates/executor/src/summary_kernels/state_column_updater/mod.rs index 37ba0113e..a46fd4094 100644 --- a/crates/executor/src/summary_kernels/state_column_updater/mod.rs +++ b/crates/executor/src/summary_kernels/state_column_updater/mod.rs @@ -87,12 +87,12 @@ impl StateColumnUpdater { pub fn new(family: &FieldDataType, parameters: Option<&SketchParams>) -> Result { crate::values::validate_family(family)?; let states = match family { - FieldDataType::Sketch(planner_types::summary_type::SketchAlgorithm::HydraCms) => { - GroupStates::Hydra { - grid: Box::new(create_hydra_cms(family, parameters).map_err(Error::Invalid)?), - names: Vec::new(), - } - } + FieldDataType::Sketch( + planner_types::summary_type::SketchAlgorithm::HydraCountMinSketch, + ) => GroupStates::Hydra { + grid: Box::new(create_hydra_cms(family, parameters).map_err(Error::Invalid)?), + names: Vec::new(), + }, FieldDataType::ExactAggregate(..) if parameters.is_some() => { return Err(Error::Invalid( "an exact summary has no parameters θ".into(), @@ -103,7 +103,7 @@ impl StateColumnUpdater { states: Vec::new(), }, FieldDataType::Sketch( - algorithm @ (planner_types::summary_type::SketchAlgorithm::CmsWithHeap + algorithm @ (planner_types::summary_type::SketchAlgorithm::CountMinSketchWithHeap | planner_types::summary_type::SketchAlgorithm::CountSketchWithHeap), ) => { let Some(parameters) = parameters else { @@ -262,7 +262,7 @@ impl StateColumnUpdater { } /// Add a group with an empty state; returns its number. Bad input for a - /// HydraCms family, whose groups are added with + /// HydraCountMinSketch family, whose groups are added with /// [`Self::add_group_with_key`]. pub fn add_group(&mut self) -> Result { let group = u32::try_from(self.group_count()) diff --git a/crates/executor/src/summary_kernels/state_column_updater/tests.rs b/crates/executor/src/summary_kernels/state_column_updater/tests.rs index 076a2bcaa..087a76bd0 100644 --- a/crates/executor/src/summary_kernels/state_column_updater/tests.rs +++ b/crates/executor/src/summary_kernels/state_column_updater/tests.rs @@ -126,7 +126,7 @@ fn ten_thousand_series( #[test] fn sealed_ten_thousand_series_answer_alike_and_hold_less() { use planner_types::summary_type::{SketchAlgorithm, SketchStatistic}; - let kll = FieldDataType::Sketch(SketchAlgorithm::Kll); + let kll = FieldDataType::Sketch(SketchAlgorithm::KLL); let k132 = SketchParams::Kll { k: 132 }; let updater = ten_thousand_series(&kll, Some(&k132)); let open_bytes = updater.memory_bytes(); diff --git a/crates/executor/src/summary_kernels/univmon.rs b/crates/executor/src/summary_kernels/univmon.rs index bbd2c1945..504cf6457 100644 --- a/crates/executor/src/summary_kernels/univmon.rs +++ b/crates/executor/src/summary_kernels/univmon.rs @@ -206,7 +206,7 @@ impl UnivMonAccumulator { impl AggregateCore for UnivMonAccumulator { /// This accumulator's own fields, sketchlib's bytes for the sketch's - /// shape with keys that own no bytes ([`UnivMon::estimated_memory_bytes`]: + /// shape with keys that own no bytes ([`UnivMon::theoretical_memory_bytes`]: /// at least what it holds), and an upper bound on the variable-length /// keys the heaps retain: the smaller of every slot holding the longest /// key seen and every layer holding a copy of every key inserted. @@ -221,7 +221,7 @@ impl AggregateCore for UnivMonAccumulator { .saturating_mul(self.max_key_bytes) .min(layers.saturating_mul(self.inserted_key_bytes)); (std::mem::size_of::() - std::mem::size_of::()) - .saturating_add(UnivMon::estimated_memory_bytes( + .saturating_add(UnivMon::theoretical_memory_bytes( heap_size, rows, cols, diff --git a/crates/executor/src/summary_kernels/weighted_frequency.rs b/crates/executor/src/summary_kernels/weighted_frequency.rs index 0a5a19af0..cf7c052cc 100644 --- a/crates/executor/src/summary_kernels/weighted_frequency.rs +++ b/crates/executor/src/summary_kernels/weighted_frequency.rs @@ -105,7 +105,7 @@ impl WeightedFrequency { use planner_types::summary_type::{SketchAlgorithm as A, SketchParams as P}; let (algorithm, width, depth, capacity) = match (algorithm, params) { ( - A::CmsWithHeap, + A::CountMinSketchWithHeap, P::CmsWithHeap { width, depth, diff --git a/crates/executor/src/supported_summaries/tests.rs b/crates/executor/src/supported_summaries/tests.rs index e02398258..3f53d721f 100644 --- a/crates/executor/src/supported_summaries/tests.rs +++ b/crates/executor/src/supported_summaries/tests.rs @@ -13,12 +13,12 @@ use planner_types::summary_type::{ const ALGORITHMS: [SketchAlgorithm; 9] = [ SketchAlgorithm::UnivMon, - SketchAlgorithm::Kll, - SketchAlgorithm::Cms, - SketchAlgorithm::Hll, + SketchAlgorithm::KLL, + SketchAlgorithm::CountMinSketch, + SketchAlgorithm::HLL, SketchAlgorithm::DDSketch, - SketchAlgorithm::CmsWithHeap, - SketchAlgorithm::Kmv, + SketchAlgorithm::CountMinSketchWithHeap, + SketchAlgorithm::KMV, SketchAlgorithm::CountSketch, SketchAlgorithm::CountSketchWithHeap, ]; @@ -82,7 +82,7 @@ fn evaluation_answers(family: &FieldDataType, readout: StatisticKind) -> bool { match (readout, family) { (StatisticKind::TopK, FieldDataType::Sketch(kind)) => matches!( kind, - planner_types::summary_type::SketchAlgorithm::CmsWithHeap + planner_types::summary_type::SketchAlgorithm::CountMinSketchWithHeap | planner_types::summary_type::SketchAlgorithm::CountSketchWithHeap ), _ => { diff --git a/crates/executor/src/values/batch/tests.rs b/crates/executor/src/values/batch/tests.rs index 734c85950..fd0e6f28c 100644 --- a/crates/executor/src/values/batch/tests.rs +++ b/crates/executor/src/values/batch/tests.rs @@ -533,7 +533,7 @@ fn state_batch(count: u32, exact: bool) -> Batch { ) } else { ( - FieldDataType::Sketch(SketchAlgorithm::Kll), + FieldDataType::Sketch(SketchAlgorithm::KLL), Some(planner_types::summary_type::SketchParams::Kll { k: 200 }), ) }; diff --git a/crates/executor/src/values/mapped_states.rs b/crates/executor/src/values/mapped_states.rs index 0732ee610..28fc0ad0c 100644 --- a/crates/executor/src/values/mapped_states.rs +++ b/crates/executor/src/values/mapped_states.rs @@ -33,8 +33,8 @@ impl MappedSketchKernel { pub(crate) fn of(family: &FieldDataType) -> Option { match family { FieldDataType::Sketch(SketchAlgorithm::DDSketch) => Some(Self::DDSketch), - FieldDataType::Sketch(SketchAlgorithm::Kll) => Some(Self::Kll), - FieldDataType::Sketch(SketchAlgorithm::Cms) => Some(Self::CountMin), + FieldDataType::Sketch(SketchAlgorithm::KLL) => Some(Self::Kll), + FieldDataType::Sketch(SketchAlgorithm::CountMinSketch) => Some(Self::CountMin), _ => None, } } @@ -452,7 +452,7 @@ mod tests { series: u32, samples: u32, ) -> Vec> { - if *family == FieldDataType::Sketch(SketchAlgorithm::Cms) { + if *family == FieldDataType::Sketch(SketchAlgorithm::CountMinSketch) { return (0..series) .map(|s| { let mut state = CountMinSketchAccumulator::new(3, 64).unwrap(); @@ -624,12 +624,12 @@ mod tests { false, ), ( - FieldDataType::Sketch(SketchAlgorithm::Kll), + FieldDataType::Sketch(SketchAlgorithm::KLL), SketchParams::Kll { k: 200 }, true, ), ( - FieldDataType::Sketch(SketchAlgorithm::Cms), + FieldDataType::Sketch(SketchAlgorithm::CountMinSketch), SketchParams::Cms { width: 64, depth: 3, @@ -667,7 +667,7 @@ mod tests { /// (each group's accumulator is seeded from its key). #[test] fn kll_view_merges_are_reproducible_and_within_the_bound() { - let family = FieldDataType::Sketch(SketchAlgorithm::Kll); + let family = FieldDataType::Sketch(SketchAlgorithm::KLL); let parameters = SketchParams::Kll { k: 200 }; let windows = |views: bool| -> Vec { (0..12) diff --git a/crates/executor/src/values/mod.rs b/crates/executor/src/values/mod.rs index ab1eccaea..5cf79f8a7 100644 --- a/crates/executor/src/values/mod.rs +++ b/crates/executor/src/values/mod.rs @@ -247,15 +247,15 @@ pub(super) fn validate_state( .downcast_ref::() .is_some_and(|s| s.family() == family && !s.is_keyed()), SummaryFamilyType::Sketch(algorithm) => match algorithm { - A::HydraCms => state.is::(), - A::CmsWithHeap => frequency(FrequencyAlgorithm::Cms), + A::HydraCountMinSketch => state.is::(), + A::CountMinSketchWithHeap => frequency(FrequencyAlgorithm::Cms), A::CountSketchWithHeap => frequency(FrequencyAlgorithm::CountSketch), - A::Kll => state.is::(), + A::KLL => state.is::(), A::DDSketch => state.is::(), - A::Hll => state.is::(), - A::Kmv => state.is::(), + A::HLL => state.is::(), + A::KMV => state.is::(), A::UnivMon => state.is::(), - A::Cms => state.is::(), + A::CountMinSketch => state.is::(), _ => false, }, _ => false, diff --git a/crates/executor/src/values/tests.rs b/crates/executor/src/values/tests.rs index 180ac9629..b47698e9e 100644 --- a/crates/executor/src/values/tests.rs +++ b/crates/executor/src/values/tests.rs @@ -6,7 +6,7 @@ use planner_types::summary_type::SketchAlgorithm; // batch; states of different shapes (θ) do not merge. #[test] fn weighted_state_family_must_match_and_shapes_must_merge() { - let cms = SummaryFamilyType::Sketch(SketchAlgorithm::CmsWithHeap); + let cms = SummaryFamilyType::Sketch(SketchAlgorithm::CountMinSketchWithHeap); let cs = SummaryFamilyType::Sketch(SketchAlgorithm::CountSketchWithHeap); let state = WeightedFrequency::new(FrequencyAlgorithm::CountSketch, 32, 5, 8).unwrap(); assert!(validate_state(&cs, &state).is_ok()); diff --git a/crates/executor/tests/blocking_resources.rs b/crates/executor/tests/blocking_resources.rs index b783608f9..30cf2d160 100644 --- a/crates/executor/tests/blocking_resources.rs +++ b/crates/executor/tests/blocking_resources.rs @@ -303,7 +303,7 @@ fn weighted_summary_build_yields_within_a_batch() { Lifetime::None, ) .unwrap(); - let family = FieldDataType::Sketch(SketchAlgorithm::CmsWithHeap); + let family = FieldDataType::Sketch(SketchAlgorithm::CountMinSketchWithHeap); let operator = Operator::per_group_keyed_summary_build( input, family, diff --git a/crates/executor/tests/current_series_heap.rs b/crates/executor/tests/current_series_heap.rs index bb8c90616..06caa5e79 100644 --- a/crates/executor/tests/current_series_heap.rs +++ b/crates/executor/tests/current_series_heap.rs @@ -157,11 +157,11 @@ fn latest_snapshot_replaces_decreases_expires_and_retains_full_identity() { #[test] fn spatial_heap_ranks_latest_values_in_independent_runs() { for algorithm in [ - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchAlgorithm::CountSketchWithHeap, ] { let params = match algorithm { - SketchAlgorithm::CmsWithHeap => SketchParams::CmsWithHeap { + SketchAlgorithm::CountMinSketchWithHeap => SketchParams::CmsWithHeap { width: 2048, depth: 5, heap_size: 100, diff --git a/crates/executor/tests/deployment.rs b/crates/executor/tests/deployment.rs index 5dc88278b..9a494fdff 100644 --- a/crates/executor/tests/deployment.rs +++ b/crates/executor/tests/deployment.rs @@ -17,7 +17,7 @@ fn accumulator( fn family(k: u32) -> Family { ( - FieldDataType::Sketch(SketchAlgorithm::Kll), + FieldDataType::Sketch(SketchAlgorithm::KLL), SketchParams::Kll { k }, ) } @@ -205,7 +205,7 @@ fn deep_plain_count_sketch_rows_hash_independently() { fn heap_sketch(algorithm: SketchAlgorithm, width: u32, depth: u32, heap_size: u32) -> Family { let params = match algorithm { - SketchAlgorithm::CmsWithHeap => SketchParams::CmsWithHeap { + SketchAlgorithm::CountMinSketchWithHeap => SketchParams::CmsWithHeap { width, depth, heap_size, @@ -224,7 +224,7 @@ fn heap_sketch(algorithm: SketchAlgorithm, width: u32, depth: u32, heap_size: u3 #[test] fn deep_heap_sketch_rows_hash_independently() { for algorithm in [ - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchAlgorithm::CountSketchWithHeap, ] { assert_rows_hash_independently(&heap_sketch(algorithm, 30_000, 25, 4), 30_000, 25, 1_000); @@ -241,7 +241,7 @@ fn heap_sketch_states_load_as_dag_summary_values() { values::{Batch, Value}, }; for algorithm in [ - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchAlgorithm::CountSketchWithHeap, ] { let family = heap_sketch(algorithm, 1_024, 5, 4); @@ -287,7 +287,10 @@ fn factory_and_dag_heap_states_are_interchangeable() { .unwrap() }; for (algorithm, frequency) in [ - (SketchAlgorithm::CmsWithHeap, FrequencyAlgorithm::Cms), + ( + SketchAlgorithm::CountMinSketchWithHeap, + FrequencyAlgorithm::Cms, + ), ( SketchAlgorithm::CountSketchWithHeap, FrequencyAlgorithm::CountSketch, @@ -320,7 +323,7 @@ fn count_min_heap_rejects_negative_inputs() { use asap_executor::planner::summary_type::SummaryInputExpr; let mut update = SummaryUpdate::column(ColumnRef::SampleValue); update.item = Some(SummaryInputExpr::Column(ColumnRef::Named("host".into()))); - let family = heap_sketch(SketchAlgorithm::CmsWithHeap, 64, 3, 4); + let family = heap_sketch(SketchAlgorithm::CountMinSketchWithHeap, 64, 3, 4); let operator = accumulator(&family, &update).unwrap(); assert!(operator.validate_single_input(-1.0).is_err()); assert!(operator.validate_single_input(0.5).is_ok()); diff --git a/crates/executor/tests/hydra_cms_execution.rs b/crates/executor/tests/hydra_cms_execution.rs index 5b72f4a04..6b9698585 100644 --- a/crates/executor/tests/hydra_cms_execution.rs +++ b/crates/executor/tests/hydra_cms_execution.rs @@ -48,7 +48,7 @@ fn hydra_params() -> SketchParams { } fn family() -> FieldDataType { - FieldDataType::Sketch(SketchAlgorithm::HydraCms) + FieldDataType::Sketch(SketchAlgorithm::HydraCountMinSketch) } fn schema(fields: Vec) -> Schema { diff --git a/crates/executor/tests/keyed_summary_row_weight.rs b/crates/executor/tests/keyed_summary_row_weight.rs index 92a7300b5..e8333027c 100644 --- a/crates/executor/tests/keyed_summary_row_weight.rs +++ b/crates/executor/tests/keyed_summary_row_weight.rs @@ -41,7 +41,7 @@ fn heap_params() -> Option { } fn heap_family() -> FieldDataType { - FieldDataType::Sketch(SketchAlgorithm::CmsWithHeap) + FieldDataType::Sketch(SketchAlgorithm::CountMinSketchWithHeap) } fn schema(fields: Vec) -> SchemaRef { diff --git a/crates/executor/tests/multi_level_window_chains.rs b/crates/executor/tests/multi_level_window_chains.rs index 0e4370a57..1198df65a 100644 --- a/crates/executor/tests/multi_level_window_chains.rs +++ b/crates/executor/tests/multi_level_window_chains.rs @@ -110,7 +110,7 @@ fn chain(width_ms: i64, built: Built) -> Rc { Built::Sum => FieldDataType::ExactAggregate(ExactKind::Sum, ExactParams::Sum), Built::Max => FieldDataType::ExactAggregate(ExactKind::Max, ExactParams::Max), Built::DDSketchP99 => FieldDataType::Sketch(SketchAlgorithm::DDSketch), - Built::KllP99 => FieldDataType::Sketch(SketchAlgorithm::Kll), + Built::KllP99 => FieldDataType::Sketch(SketchAlgorithm::KLL), }, input: SummaryUpdate::column(ColumnRef::SampleValue), reduction: Reduction::by(vec![0]), diff --git a/crates/executor/tests/physical_dag.rs b/crates/executor/tests/physical_dag.rs index 477c489f9..9e626b249 100644 --- a/crates/executor/tests/physical_dag.rs +++ b/crates/executor/tests/physical_dag.rs @@ -385,7 +385,7 @@ fn kll_raw_partial_and_precomputed_are_native_dags() { use planner_types::summary_type::SketchAlgorithm; let input = schema(&[("value", DataType::Float64, false)]); - let family = FieldDataType::Sketch(SketchAlgorithm::Kll); + let family = FieldDataType::Sketch(SketchAlgorithm::KLL); let build = Operator::per_group_summary_build( input.clone(), family, @@ -1080,7 +1080,7 @@ fn assert_weighted_rate_topk(count_sketch: bool) { let family = FieldDataType::Sketch(if count_sketch { SketchAlgorithm::CountSketchWithHeap } else { - SketchAlgorithm::CmsWithHeap + SketchAlgorithm::CountMinSketchWithHeap }); let parameters = if count_sketch { SketchParams::CountSketchWithHeap { diff --git a/crates/executor/tests/physical_semantics.rs b/crates/executor/tests/physical_semantics.rs index 8d20f775b..704325ca4 100644 --- a/crates/executor/tests/physical_semantics.rs +++ b/crates/executor/tests/physical_semantics.rs @@ -1010,7 +1010,7 @@ fn kll_partial_merge_and_multiple_evaluations_preserve_population() { use planner_types::summary_type::SketchAlgorithm; let input = schema(&[("v", DataType::Float64, false)]); - let family = FieldDataType::Sketch(SketchAlgorithm::Kll); + let family = FieldDataType::Sketch(SketchAlgorithm::KLL); let mut dag = PhysicalDAG::default(); for (id, range) in [(0, 0..64), (1, 64..128), (2, 0..128)] { let rows = range.map(|n| vec![Value::Float64(n as f64)]).collect(); @@ -1119,7 +1119,7 @@ fn compacted_kll_tumbling_windows_merge_within_the_calibrated_rank_error() { let bound = 2.296 / f64::from(K).powf(0.9723); let n = (TUMBLING_WINDOW_COUNT * ROWS_PER_TUMBLING_WINDOW) as f64; let input = schema(&[("v", DataType::Float64, false)]); - let family = FieldDataType::Sketch(SketchAlgorithm::Kll); + let family = FieldDataType::Sketch(SketchAlgorithm::KLL); let build = || { Operator::per_group_summary_build( input.clone(), @@ -1522,7 +1522,7 @@ fn filtered_summary_build_keeps_empty_groups() { ExactKind, ExactParams, SketchAlgorithm, SketchStatistic, SummaryUpdate, }; let (input, rows) = filtered_input(); - let kll = FieldDataType::Sketch(SketchAlgorithm::Kll); + let kll = FieldDataType::Sketch(SketchAlgorithm::KLL); let count = FieldDataType::ExactAggregate(ExactKind::Count, ExactParams::Count); let cases = [ ( diff --git a/crates/executor/tests/plan_properties.rs b/crates/executor/tests/plan_properties.rs index 5623fe603..558bec231 100644 --- a/crates/executor/tests/plan_properties.rs +++ b/crates/executor/tests/plan_properties.rs @@ -137,7 +137,7 @@ fn kll_kernel_rejects_a_k_above_the_library_cap() { use planner_types::ir::scalar::ColumnRef; use planner_types::summary_type::{SketchAlgorithm, SketchParams, SummaryUpdate}; let update = SummaryUpdate::column(ColumnRef::SampleValue); - let kll = FieldDataType::Sketch(SketchAlgorithm::Kll); + let kll = FieldDataType::Sketch(SketchAlgorithm::KLL); let params = |k| SketchParams::Kll { k }; assert!(validate_summary_kernel(&kll, Some(¶ms(26_602)), &update).is_ok()); assert!(validate_summary_kernel(&kll, Some(¶ms(26_603)), &update).is_err()); @@ -177,7 +177,7 @@ fn summary_capability_levels_are_distinct() { use asap_executor::planner::summary_type::SketchStatistic; use planner_types::ir::scalar::ColumnRef; use planner_types::summary_type::{SketchAlgorithm, SummaryUpdate}; - let cms = FieldDataType::Sketch(SketchAlgorithm::Cms); + let cms = FieldDataType::Sketch(SketchAlgorithm::CountMinSketch); let update = SummaryUpdate { item: Some(planner_types::summary_type::SummaryInputExpr::Column( ColumnRef::Named("host".into()), @@ -206,7 +206,7 @@ fn summary_capability_levels_are_distinct() { } ) .is_err()); - let kll = FieldDataType::Sketch(SketchAlgorithm::Kll); + let kll = FieldDataType::Sketch(SketchAlgorithm::KLL); assert!(validate_native_family(&kll).is_ok()); assert!(validate_sketch_evaluation(&kll, &SketchStatistic::Quantile { q: 1.5 }).is_err()); assert!(validate_sketch_evaluation(&kll, &SketchStatistic::Cardinality).is_err()); diff --git a/crates/executor/tests/state_column_updater.rs b/crates/executor/tests/state_column_updater.rs index af2c44af6..c3f681bde 100644 --- a/crates/executor/tests/state_column_updater.rs +++ b/crates/executor/tests/state_column_updater.rs @@ -119,13 +119,13 @@ fn value_families() -> Vec { exact(ExactKind::Counter, ExactParams::Counter), // `k` above any group's sample count (at most 600): no compaction, // so the random compaction coin never flips. - sketch(SketchAlgorithm::Kll, SketchParams::Kll { k: 1024 }), + sketch(SketchAlgorithm::KLL, SketchParams::Kll { k: 1024 }), sketch( SketchAlgorithm::DDSketch, SketchParams::DDSketch { alpha: 0.01 }, ), - sketch(SketchAlgorithm::Hll, SketchParams::Hll { precision: 10 }), - sketch(SketchAlgorithm::Kmv, SketchParams::Kmv { k: 32 }), + sketch(SketchAlgorithm::HLL, SketchParams::Hll { precision: 10 }), + sketch(SketchAlgorithm::KMV, SketchParams::Kmv { k: 32 }), sketch( SketchAlgorithm::UnivMon, SketchParams::UnivMon { @@ -142,7 +142,7 @@ fn value_families() -> Vec { fn keyed_families() -> Vec { vec![ sketch( - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchParams::CmsWithHeap { width: 64, depth: 3, @@ -707,10 +707,10 @@ fn an_unknown_group_is_bad_input() { sum.update(2, 1.0, 0).unwrap(); } -/// A HydraCms family: one shared grid for all groups. +/// A HydraCountMinSketch family: one shared grid for all groups. fn hydra_family() -> Family { ( - FieldDataType::Sketch(SketchAlgorithm::HydraCms), + FieldDataType::Sketch(SketchAlgorithm::HydraCountMinSketch), Some(SketchParams::Hydra(HydraParams::HydraCms { width: 64, depth: 3, diff --git a/crates/executor/tests/stored_tumbling_window_memory_limit.rs b/crates/executor/tests/stored_tumbling_window_memory_limit.rs index a3cf908cb..35363ec6e 100644 --- a/crates/executor/tests/stored_tumbling_window_memory_limit.rs +++ b/crates/executor/tests/stored_tumbling_window_memory_limit.rs @@ -27,7 +27,7 @@ fn tumbling_window() -> (Arc, Batch) { /// One tumbling window of `series` KLL states (k = 200), keyed by series. fn tumbling_window_of(series_count: u32) -> (Arc, Batch) { - let family = FieldDataType::Sketch(SketchAlgorithm::Kll); + let family = FieldDataType::Sketch(SketchAlgorithm::KLL); let schema = Arc::new(Schema { fields: vec![ Field { diff --git a/crates/executor/tests/summary_build_memory_limit.rs b/crates/executor/tests/summary_build_memory_limit.rs index 19d3b4ac5..18402022a 100644 --- a/crates/executor/tests/summary_build_memory_limit.rs +++ b/crates/executor/tests/summary_build_memory_limit.rs @@ -56,7 +56,7 @@ fn one_large_batch_fails_near_the_memory_limit() { .map(|i| vec![Value::Utf8(format!("s{i}").into()), Value::Float64(1.0)]) .collect(); let batch = Batch::try_new(input.clone(), rows).unwrap(); - let family = FieldDataType::Sketch(SketchAlgorithm::Kll); + let family = FieldDataType::Sketch(SketchAlgorithm::KLL); let mut dag = PhysicalDAG::default(); dag.add( 0, diff --git a/crates/integration-tests/tests/accuracy_at_query_roots.rs b/crates/integration-tests/tests/accuracy_at_query_roots.rs index f49f9161a..12b37991d 100644 --- a/crates/integration-tests/tests/accuracy_at_query_roots.rs +++ b/crates/integration-tests/tests/accuracy_at_query_roots.rs @@ -143,7 +143,7 @@ fn each_query_meets_its_target_at_its_root() { let (plan, accepted) = selection(&PROBLEM_EXAMPLE, LATENCY_SERIES, false); assert_eq!( accepted, - ["accepted rank (Kll)", "accepted relative (DDSketch)"], + ["accepted rank (KLL)", "accepted relative (DDSketch)"], "the metric of each query's readouts" ); let parameters = sketch_parameters(&plan); diff --git a/crates/integration-tests/tests/default_cost_plan_ranking_fixtures/quantile_rank_1_hz_every_10_s_query_time_kll.json b/crates/integration-tests/tests/default_cost_plan_ranking_fixtures/quantile_rank_1_hz_every_10_s_query_time_kll.json index 755f5c035..5379ec7a7 100644 --- a/crates/integration-tests/tests/default_cost_plan_ranking_fixtures/quantile_rank_1_hz_every_10_s_query_time_kll.json +++ b/crates/integration-tests/tests/default_cost_plan_ranking_fixtures/quantile_rank_1_hz_every_10_s_query_time_kll.json @@ -1 +1 @@ -{"nodes":[{"id":0,"payload":{"NonASAP":{"Scan":{"source":{"TimeSeries":{"metric":"latency"}},"predicates":[],"schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"value","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true}}}},"output_state":{"timing":"query_time","primitive":"Raw"},"lifetime":"None","output_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"value","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true},"retention_ms":3600000},{"id":1,"payload":{"NonASAP":{"TimeRange":{"range":{"secs":3600,"nanos":0},"kind":"range","child":0}}},"output_state":{"timing":"query_time","primitive":"Raw"},"lifetime":"None","output_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"value","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true}},{"id":2,"payload":{"ASAP":{"SummaryAgg":{"child":1,"summary_type":{"Sketch":"Kll"},"input":{"item":null,"weight":{"Column":"SampleValue"}},"reduction":"PerEntity","filter":null}}},"output_state":{"timing":"query_time","primitive":"SummaryState"},"lifetime":"None","parameters":{"Kll":{"k":547}},"output_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"state","dtype":{"Sketch":"Kll"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true}},{"id":3,"payload":{"ASAP":{"SummaryEstimate":{"summary_input":2,"query":{"Quantile":{"q":0.99}}}}},"output_state":{"timing":"query_time","primitive":"Raw"},"lifetime":"None","output_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"quantile","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true}},{"id":4,"payload":{"NonASAP":{"Project":{"cols":[{"alias":"ts","expr":{"Column":0}},{"alias":"value","expr":{"Column":1}},{"alias":"$promql_series_identity","expr":{"Column":2}}],"child":3}}},"output_state":{"timing":"query_time","primitive":"Raw"},"lifetime":"None","output_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"value","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true}}],"edges":[{"producer":0,"consumer":1,"role":"Input","intermediate_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"value","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true},"data_state":{"timing":"query_time","primitive":"Raw"},"grouping":"NotApplicable","window":"NotApplicable"},{"producer":1,"consumer":2,"role":"Input","intermediate_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"value","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true},"data_state":{"timing":"query_time","primitive":"Raw"},"grouping":"NotApplicable","window":"NotApplicable"},{"producer":2,"consumer":3,"role":"Input","intermediate_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"state","dtype":{"Sketch":"Kll"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true},"data_state":{"timing":"query_time","primitive":"SummaryState"},"grouping":"NotApplicable","window":"NotApplicable"},{"producer":3,"consumer":4,"role":"Input","intermediate_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"quantile","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true},"data_state":{"timing":"query_time","primitive":"Raw"},"grouping":"NotApplicable","window":"NotApplicable"}],"roots":[4],"scalar_roots":[]} +{"nodes":[{"id":0,"payload":{"NonASAP":{"Scan":{"source":{"TimeSeries":{"metric":"latency"}},"predicates":[],"schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"value","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true}}}},"output_state":{"timing":"query_time","primitive":"Raw"},"lifetime":"None","output_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"value","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true},"retention_ms":3600000},{"id":1,"payload":{"NonASAP":{"TimeRange":{"range":{"secs":3600,"nanos":0},"kind":"range","child":0}}},"output_state":{"timing":"query_time","primitive":"Raw"},"lifetime":"None","output_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"value","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true}},{"id":2,"payload":{"ASAP":{"SummaryAgg":{"child":1,"summary_type":{"Sketch":"KLL"},"input":{"item":null,"weight":{"Column":"SampleValue"}},"reduction":"PerEntity","filter":null}}},"output_state":{"timing":"query_time","primitive":"SummaryState"},"lifetime":"None","parameters":{"Kll":{"k":547}},"output_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"state","dtype":{"Sketch":"KLL"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true}},{"id":3,"payload":{"ASAP":{"SummaryEstimate":{"summary_input":2,"query":{"Quantile":{"q":0.99}}}}},"output_state":{"timing":"query_time","primitive":"Raw"},"lifetime":"None","output_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"quantile","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true}},{"id":4,"payload":{"NonASAP":{"Project":{"cols":[{"alias":"ts","expr":{"Column":0}},{"alias":"value","expr":{"Column":1}},{"alias":"$promql_series_identity","expr":{"Column":2}}],"child":3}}},"output_state":{"timing":"query_time","primitive":"Raw"},"lifetime":"None","output_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"value","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true}}],"edges":[{"producer":0,"consumer":1,"role":"Input","intermediate_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"value","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true},"data_state":{"timing":"query_time","primitive":"Raw"},"grouping":"NotApplicable","window":"NotApplicable"},{"producer":1,"consumer":2,"role":"Input","intermediate_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"value","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true},"data_state":{"timing":"query_time","primitive":"Raw"},"grouping":"NotApplicable","window":"NotApplicable"},{"producer":2,"consumer":3,"role":"Input","intermediate_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"state","dtype":{"Sketch":"KLL"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true},"data_state":{"timing":"query_time","primitive":"SummaryState"},"grouping":"NotApplicable","window":"NotApplicable"},{"producer":3,"consumer":4,"role":"Input","intermediate_schema":{"fields":[{"name":"ts","dtype":{"Plain":"timestamp"},"nullable":false},{"name":"quantile","dtype":{"Plain":"float64"},"nullable":false},{"name":"$promql_series_identity","dtype":{"Plain":"utf8"},"nullable":false}],"time_index":0,"unique_keys":[[2,0]],"closed":true},"data_state":{"timing":"query_time","primitive":"Raw"},"grouping":"NotApplicable","window":"NotApplicable"}],"roots":[4],"scalar_roots":[]} diff --git a/crates/integration-tests/tests/deployment_exclusions.rs b/crates/integration-tests/tests/deployment_exclusions.rs index 36c32ec8c..f84a5e4d9 100644 --- a/crates/integration-tests/tests/deployment_exclusions.rs +++ b/crates/integration-tests/tests/deployment_exclusions.rs @@ -298,7 +298,7 @@ const STORED_KLL_PLAN: [(OperatorKind, ExecutionTiming); 6] = [ fn kll(k: u32) -> (FieldDataType, Option) { ( - FieldDataType::Sketch(SketchAlgorithm::Kll), + FieldDataType::Sketch(SketchAlgorithm::KLL), Some(SketchParams::Kll { k }), ) } @@ -373,7 +373,7 @@ fn a_kll_k_range_moves_the_quantile_to_a_larger_k() { fn excluding_every_kll_size_selects_a_plan_without_kll() { let workload = kll_workload(); let by_family = CandidateExclusion { - summary_family: Some(SummaryFamily::Sketch(SketchAlgorithm::Kll)), + summary_family: Some(SummaryFamily::Sketch(SketchAlgorithm::KLL)), ..Default::default() }; for exclusion in [by_family, kll_at_most(2863)] { diff --git a/crates/integration-tests/tests/filtered_aggregates.rs b/crates/integration-tests/tests/filtered_aggregates.rs index c8f6cfadd..d13242fc4 100644 --- a/crates/integration-tests/tests/filtered_aggregates.rs +++ b/crates/integration-tests/tests/filtered_aggregates.rs @@ -259,7 +259,7 @@ async fn hand_filtered_kll_compiles_and_executes() { .await; let roots = hand_filtered( "SELECT g, approx_percentile_cont(x, 0.5) AS q FROM events GROUP BY g", - |f| matches!(f, FieldDataType::Sketch(kind) if kind == &SketchAlgorithm::Kll), + |f| matches!(f, FieldDataType::Sketch(kind) if kind == &SketchAlgorithm::KLL), &filter, ) .await; @@ -277,7 +277,7 @@ async fn kll_candidates(sql: &str) -> Vec> { supported_summaries: Some( asap_executor::supported_summary_families() .into_iter() - .filter(|family| family.summary_type == SketchAlgorithm::Kll) + .filter(|family| family.summary_type == SketchAlgorithm::KLL) .collect(), ), ..DeploymentCapabilities::default() @@ -288,7 +288,7 @@ async fn kll_candidates(sql: &str) -> Vec> { .filter(|root| { OperatorNode::reachable(root).iter().any(|n| { matches!(n.asap(), Some(ASAPOp::SummaryAgg { summary_type: FieldDataType::Sketch(kind), .. }) - if kind == &SketchAlgorithm::Kll) + if kind == &SketchAlgorithm::KLL) }) }) .collect(); diff --git a/crates/integration-tests/tests/kll_tumbling_window_execution.rs b/crates/integration-tests/tests/kll_tumbling_window_execution.rs index 3f13b9179..5c9e3441e 100644 --- a/crates/integration-tests/tests/kll_tumbling_window_execution.rs +++ b/crates/integration-tests/tests/kll_tumbling_window_execution.rs @@ -32,7 +32,7 @@ use std::{ const TUMBLING_WINDOW_WIDTH_MS: i64 = 60_000; fn kll() -> FieldDataType { - FieldDataType::Sketch(SketchAlgorithm::Kll) + FieldDataType::Sketch(SketchAlgorithm::KLL) } /// `t(ts, value)`, time index `ts`. fn table_schema() -> Schema { diff --git a/crates/integration-tests/tests/pass1_candidates.rs b/crates/integration-tests/tests/pass1_candidates.rs index 4a0a11796..a5fcc6307 100644 --- a/crates/integration-tests/tests/pass1_candidates.rs +++ b/crates/integration-tests/tests/pass1_candidates.rs @@ -191,12 +191,14 @@ fn topk_offers_both_heap_algorithms() { assert_eq!( algorithms, [ - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchAlgorithm::CountSketchWithHeap ] ); let count = sketch_builds(promql("count by (job) (m)")); - assert!(count.iter().any(|(kind, _)| *kind == SketchAlgorithm::Cms)); + assert!(count + .iter() + .any(|(kind, _)| *kind == SketchAlgorithm::CountMinSketch)); } /// Top-K over a grouped sum is a whole-expression heap: it absorbs the @@ -892,7 +894,8 @@ async fn heap_updates_over(fields: Vec, sql: &str) -> Vec<(String, String Operator::ASAP(ASAPOp::SummaryAgg { summary_type: FieldDataType::Sketch( - SketchAlgorithm::CmsWithHeap | SketchAlgorithm::CountSketchWithHeap, + SketchAlgorithm::CountMinSketchWithHeap + | SketchAlgorithm::CountSketchWithHeap, ), input, .. diff --git a/crates/integration-tests/tests/pass2_promql/exact_only_groups.rs b/crates/integration-tests/tests/pass2_promql/exact_only_groups.rs index fb3c67dfa..feb1c4f38 100644 --- a/crates/integration-tests/tests/pass2_promql/exact_only_groups.rs +++ b/crates/integration-tests/tests/pass2_promql/exact_only_groups.rs @@ -60,7 +60,7 @@ fn each_query_reads_only_the_readouts_in_its_targets_metric() { ), ]); let exact_only = &logical.exact_only_groups_of_query; - let kll = readout_groups(&logical, SketchAlgorithm::Kll); + let kll = readout_groups(&logical, SketchAlgorithm::KLL); let ddsketch = readout_groups(&logical, SketchAlgorithm::DDSketch); assert!(!kll.is_empty() && !ddsketch.is_empty()); for (group, rank_query_reads_it) in kll @@ -131,7 +131,7 @@ fn an_exact_query_reads_every_sketch_readout_only_exactly() { (query, json!({"max_error": 0.01, "accuracy_metric": "rank"})), ]); let exact_only = &logical.exact_only_groups_of_query; - let kll = readout_groups(&logical, SketchAlgorithm::Kll); + let kll = readout_groups(&logical, SketchAlgorithm::KLL); assert!(!kll.is_empty()); for group in kll { assert!(live(&logical, group), "G{} survives", group.0); diff --git a/crates/integration-tests/tests/pass2_sql.rs b/crates/integration-tests/tests/pass2_sql.rs index f36fa1373..29a3f2823 100644 --- a/crates/integration-tests/tests/pass2_sql.rs +++ b/crates/integration-tests/tests/pass2_sql.rs @@ -32,7 +32,7 @@ fn a_global_distinct_count_keeps_its_whole_failure_probability() { if memo.groups()[summary_input.0 as usize] .group_properties .sketch_algorithm_of_state() - == Some(SketchAlgorithm::Kmv) => + == Some(SketchAlgorithm::KMV) => { let required = candidate.input_requirements[0] .required_accuracy @@ -44,7 +44,7 @@ fn a_global_distinct_count_keeps_its_whole_failure_probability() { kmv_readouts += 1; } Operator::ASAP(ASAPOp::SummaryAgg { - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kmv), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KMV), .. }) if live => { if let Some(SketchParams::Kmv { k }) = candidate.logical_properties.parameters() @@ -75,7 +75,7 @@ fn kll_readouts(logical: &LogicalASAPMemoCandidates) -> Vec<(bool, Option)> if memo.groups()[summary_input.0 as usize] .group_properties .sketch_algorithm_of_state() - != Some(SketchAlgorithm::Kll) + != Some(SketchAlgorithm::KLL) { continue; } diff --git a/crates/integration-tests/tests/production_rollup_workloads.rs b/crates/integration-tests/tests/production_rollup_workloads.rs index 354f3d1a6..03839ba8b 100644 --- a/crates/integration-tests/tests/production_rollup_workloads.rs +++ b/crates/integration-tests/tests/production_rollup_workloads.rs @@ -151,7 +151,7 @@ async fn production_three_sql_groupings_share_kll() { .accuracy_metric(AccuracyMetric::Rank) .accuracy_scope(AccuracyScope::PerValue); let queries: Vec<_> = ["region, service", "region", "service"].iter().map(|keys| format!("SELECT {keys}, approx_percentile_cont(latency, 0.99) AS value FROM http WHERE ts >= now() - INTERVAL '5 minutes' GROUP BY {keys}")).collect(); - check(&sql(&queries, accuracy).await, 3, 2, "Kll"); + check(&sql(&queries, accuracy).await, 3, 2, "KLL"); } /// `COUNT(DISTINCT user_id)` by (region, service) and by service: the two diff --git a/crates/integration-tests/tests/promql_to_post_asap.rs b/crates/integration-tests/tests/promql_to_post_asap.rs index 68e517d9e..fe05cd49f 100644 --- a/crates/integration-tests/tests/promql_to_post_asap.rs +++ b/crates/integration-tests/tests/promql_to_post_asap.rs @@ -400,7 +400,7 @@ fn planner_heap_topk_reference_execution_matches_ground_truth() { // different execution contract and must not enter this fixture. let accuracy = AccuracyTarget::max_error(0.01).failure_probability(0.01); let candidates: Vec<_> = [ - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchAlgorithm::CountSketchWithHeap, ] .into_iter() @@ -421,7 +421,7 @@ fn planner_heap_topk_reference_execution_matches_ground_truth() { /// /// ```text /// SummaryEstimate { query: Quantile{0.99} } → {quantile: Float64} -/// └─ SummaryAgg { Kll{k:269}, input: SampleValue } → {state: Sketch(Kll)} +/// └─ SummaryAgg { Kll{k:269}, input: SampleValue } → {state: Sketch(KLL)} /// └─ FinalizeExactAccumulator /// └─ SummaryAgg { Counter, input: SampleValue } → {ts, state: ExactAggregate(Counter), …} /// └─ TimeRange{5m} → Scan → {ts, value} @@ -441,7 +441,7 @@ fn promql_quantile_of_rate_binds_kll_over_rate_accumulator() { let root = &candidates_using( &pre_asap, AccuracyTarget::max_error(0.01), - SketchAlgorithm::Kll, + SketchAlgorithm::KLL, ) .into_iter() .find(|plan| { @@ -481,7 +481,7 @@ fn promql_quantile_of_rate_binds_kll_over_rate_accumulator() { else { panic!("expected SummaryAgg, got {:?}", summary_input.operator); }; - assert_eq!(family, &FieldDataType::Sketch(SketchAlgorithm::Kll)); + assert_eq!(family, &FieldDataType::Sketch(SketchAlgorithm::KLL)); assert_eq!(input, &SummaryUpdate::column(ColumnRef::SampleValue)); assert_eq!( reduction, @@ -490,7 +490,7 @@ fn promql_quantile_of_rate_binds_kll_over_rate_accumulator() { ); assert_eq!( dtype(&summary_input.schema, "state"), - &FieldDataType::Sketch(SketchAlgorithm::Kll) + &FieldDataType::Sketch(SketchAlgorithm::KLL) ); let Some(ASAPOp::FinalizeExactAccumulator { child, .. }) = child.asap() else { diff --git a/crates/integration-tests/tests/rollup_controlled.rs b/crates/integration-tests/tests/rollup_controlled.rs index 16b69dbc5..34e3e5682 100644 --- a/crates/integration-tests/tests/rollup_controlled.rs +++ b/crates/integration-tests/tests/rollup_controlled.rs @@ -92,10 +92,10 @@ fn plan_rollup(sample_interval_ms: u64) -> (Vec>, usize) { node.asap(), Some( ASAPOp::SummaryAgg { - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kmv), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KMV), .. } | ASAPOp::SummaryTumblingWindowChain { - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kmv), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KMV), .. } ) @@ -124,7 +124,7 @@ fn production_distinct_rollup_builds_kmv_at_60k_rows_per_state() { let (sketches, kmv_builds) = plan_rollup(5); assert_eq!(sketches.len(), 2); assert!( - sketches.iter().all(|sketches| sketches == &["Kmv"]), + sketches.iter().all(|sketches| sketches == &["KMV"]), "both queries read a KMV: {sketches:?}" ); assert!(kmv_builds > 0, "the selected plan builds a KMV"); diff --git a/crates/integration-tests/tests/view_state_key.rs b/crates/integration-tests/tests/view_state_key.rs index 65cfe9ccd..da532b496 100644 --- a/crates/integration-tests/tests/view_state_key.rs +++ b/crates/integration-tests/tests/view_state_key.rs @@ -45,7 +45,7 @@ fn chain_dag(width_ms: u64) -> (PhysicalASAPDAG, usize, usize) { })); let chain: Rc = new(Operator::ASAP(ASAPOp::SummaryTumblingWindowChain { child: scan, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KLL), input: SummaryUpdate::column(ColumnRef::Named("value".into())), reduction: Reduction::Reduce(GroupKeys::default()), filter: None, @@ -176,7 +176,7 @@ fn cover_view() -> MaterializedView { let chain = |width_ms: u64| { new(Operator::ASAP(ASAPOp::SummaryTumblingWindowChain { child: scan.clone(), - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KLL), input: SummaryUpdate::column(ColumnRef::Named("value".into())), reduction: Reduction::Reduce(GroupKeys::default()), filter: None, @@ -371,7 +371,7 @@ async fn the_view_state_key_of_a_planned_chain_is_pinned_and_round_trips_through assert_eq!( serde_json::to_value(key).unwrap(), serde_json::json!({ - "definition_id": "bfbffb8f01ab202d585c3e18c9f78080", + "definition_id": "2d963bc6757b98ad80934456821cc040", "window": {"tumbling": {"width_ms": 300000}}, "logical_properties": {"parameters": {"Kll": {"k": 2863}}} }) diff --git a/crates/planner-cli/src/candidate_labels.rs b/crates/planner-cli/src/candidate_labels.rs index 167ce5d7b..3c92b07a6 100644 --- a/crates/planner-cli/src/candidate_labels.rs +++ b/crates/planner-cli/src/candidate_labels.rs @@ -9,7 +9,7 @@ use asap_types::summary_type::SketchParams; /// An operator's kind with its summary type, its summary query, its time /// range and its tumbling-window width, when it has them, without its -/// inputs: e.g. `SummaryAgg Kll`, `SummaryEstimate Quantile(q=0.5)`, +/// inputs: e.g. `SummaryAgg KLL`, `SummaryEstimate Quantile(q=0.5)`, /// `TimeRange 600s`. pub fn operator_label(operator: &Operator) -> String { let operator = serde_json::to_value(operator.map_children(|_| ())).unwrap_or_default(); @@ -102,7 +102,7 @@ fn find_details(value: &Value, details: &mut Vec, depth: usize) { details.push(format!("{kind}({})", params.join(", "))); } } - // A summary type, e.g. `Kll` or `ExactAggregate(Counter)`. + // A summary type, e.g. `KLL` or `ExactAggregate(Counter)`. "summary_type" => details.push(summary_type_text(field)), // A time range's length, e.g. `60s`. "range" => details.push(duration_text(field)), @@ -121,7 +121,7 @@ fn find_details(value: &Value, details: &mut Vec, depth: usize) { } } -/// A serialized summary type: `Kll` (`{"Sketch": "Kll"}`), +/// A serialized summary type: `KLL` (`{"Sketch": "KLL"}`), /// `ExactAggregate(Counter)` (`{"ExactAggregate": ["Counter", "Counter"]}`, the /// distinct names), or the JSON of any other value. fn summary_type_text(value: &Value) -> String { diff --git a/crates/planner-cli/src/planning_stages_text.rs b/crates/planner-cli/src/planning_stages_text.rs index 5e916aa64..3630027f4 100644 --- a/crates/planner-cli/src/planning_stages_text.rs +++ b/crates/planner-cli/src/planning_stages_text.rs @@ -333,7 +333,7 @@ pub fn column_lineage_text( /// on, and an aggregate's coverage ([`aggregate_coverage_text`]): /// `State ts=latency.ts:Unknown state=G4.1:Unknown · depends on the /// evaluation time · scans latency · every 60000 ms · covers G1 through -/// [SummaryAgg Kll] selecting [...]`. +/// [SummaryAgg KLL] selecting [...]`. fn group_properties_text(group: &MemoGroup, grid: Option>) -> String { let properties = &group.group_properties; let columns: Vec = properties @@ -380,7 +380,7 @@ fn group_properties_text(group: &MemoGroup, grid: Option /// group (`a scan` when the scan's matchers are lifted too), its /// operators not lifted into the selection, top down, and its selection as /// JSON, the input group named by `group_id`. Example: `covers G1 through -/// [SummaryAgg Kll] selecting [{"columns":[...]}]`. +/// [SummaryAgg KLL] selecting [{"columns":[...]}]`. pub fn aggregate_coverage_text( coverage: &AggregateCoverage, group_id: impl Fn(MemoGroupId) -> u32, @@ -448,11 +448,11 @@ enum MemoStep<'a> { /// ([`write_stored_logical_edges`]), and a pruned one lists none: /// /// ```text -/// G9: SummaryAgg CmsWithHeap <- G1 -/// [0..279] Pass1 SummaryAgg CmsWithHeap <- G1 fuses=[G4] +/// G9: SummaryAgg CountMinSketchWithHeap <- G1 +/// [0..279] Pass1 SummaryAgg CountMinSketchWithHeap <- G1 fuses=[G4] /// θ: depth ∈ {5, 7, 10, 12}, heap_size ∈ {10..10000} (7 values), width ∈ {28..2719} (10 values) /// 280 candidates: 278 pruned (BelowRequiredAccuracy 270, MetricRule 8), 2 kept -/// [57] Pass1 SummaryAgg CmsWithHeap <- G1 θ=CmsWithHeap(depth=7, heap_size=10, width=544) fuses=[G4] +/// [57] Pass1 SummaryAgg CountMinSketchWithHeap <- G1 θ=CmsWithHeap(depth=7, heap_size=10, width=544) fuses=[G4] /// input 0 <- G1: ✓ G1[0] /// ``` fn write_memo(out: &mut String, memo: &Memo, step: Option>, verbose: bool) { @@ -920,7 +920,7 @@ fn candidate_id_text(id: CandidateForMemoGroupId) -> String { format!("G{}[{}]", id.group.0, id.index_in_group) } -/// A candidate on one line: `SummaryAgg Kll <- G1 θ=Kll(k=269)` (θ only +/// A candidate on one line: `SummaryAgg KLL <- G1 θ=Kll(k=269)` (θ only /// with `parameters`), then `fuses=[..]` and `requires=[..]` when it has /// them. fn candidate_text(candidate: &CandidateForMemoGroup, parameters: bool) -> String { diff --git a/crates/planner-cli/src/stable_output.rs b/crates/planner-cli/src/stable_output.rs index 909fec0c2..cd6c56c70 100644 --- a/crates/planner-cli/src/stable_output.rs +++ b/crates/planner-cli/src/stable_output.rs @@ -36,7 +36,7 @@ use serde_json::{json, Value}; /// quantile` root group id 0, the `TimeRange 300s` below it 1 and the /// `Scan` 2 (the planner numbers them the other way round, `Scan` first), /// then the groups its candidates read: the `SummaryEstimate` readout 3 -/// and its `SummaryAgg Kll` 4. +/// and its `SummaryAgg KLL` 4. pub struct CanonicalIds { /// Indexed by the planner's group id. canonical_group_of_planner_group: Vec, diff --git a/crates/planner-cli/tests/asap_planner.rs b/crates/planner-cli/tests/asap_planner.rs index 6a28d5e2c..fc32de16a 100644 --- a/crates/planner-cli/tests/asap_planner.rs +++ b/crates/planner-cli/tests/asap_planner.rs @@ -673,7 +673,7 @@ fn a_quantile_target_without_a_metric_accepts_rank_or_relative() { .get("default_metric") .is_some_and(Value::is_null)); let labels = memo_labels(&unset, "pass1"); - for family in ["Kll", "DDSketch"] { + for family in ["KLL", "DDSketch"] { assert!( labels.iter().any(|l| l.contains(family)), "{family}: {labels:?}" @@ -687,7 +687,7 @@ fn a_quantile_target_without_a_metric_accepts_rank_or_relative() { let rank = query(Some("rank")); let accepted = summary(&rank); assert!( - accepted == "accepted rank (Kll)" || accepted == "accepted exact", + accepted == "accepted rank (KLL)" || accepted == "accepted exact", "{accepted}" ); } @@ -823,14 +823,14 @@ fn deployment_capabilities_flag_sets_the_capabilities_and_shows_them() { }) ); let kll_kept = with_capabilities( - r#"{"supported_summaries": [{"summary_type": "Kll", "readouts": ["Quantile"]}], + r#"{"supported_summaries": [{"summary_type": "KLL", "readouts": ["Quantile"]}], "query_time_results_retained": true}"#, &["--ignore-accuracy-guarantees"], ); assert_eq!( kll_kept["deployment_capabilities"], json!({ - "supported_summaries": [{ "summary_type": "Kll", "readouts": ["Quantile"] }], + "supported_summaries": [{ "summary_type": "KLL", "readouts": ["Quantile"] }], "raw_data_retained": true, "query_time_results_retained": true, "counter_semantics": { "reset_handling": true, "extrapolation": true }, @@ -1071,7 +1071,7 @@ fn undeclared_supported_summaries_default_to_the_executors_families() { ], ); let labels = memo_labels(&document, "pass1"); - for family in ["FinalizeExactAccumulator", "Cms", "UnivMon"] { + for family in ["FinalizeExactAccumulator", "CountMinSketch", "UnivMon"] { assert!( labels.iter().any(|label| label.contains(family)), "missing {family}: {labels:?}" @@ -2065,8 +2065,8 @@ fn milp_search_selects_checked_plans_on_ratio_and_rollupheavy() { let milp = milp_args(&capabilities); let tables = catalog_tables(Path::new(&memo_example("sql/tables.json"))); for (workload, pruned_family) in [ - ("promql/ratio-of-quantiles-5m.json", "Kll"), - ("sql/rollupheavy-t11-service-endpoint-5m.json", "Hll"), + ("promql/ratio-of-quantiles-5m.json", "KLL"), + ("sql/rollupheavy-t11-service-endpoint-5m.json", "HLL"), ] { let path = memo_example(workload); let mut args = vec!["--workload", path.as_str()]; @@ -2618,7 +2618,7 @@ fn summary_families_come_from_the_deployment_capabilities() { planned_with(&["--deployment-capabilities", &every_family]), declared["supported_summaries"] ); - let kll = json!([{"summary_type": "Kll", "readouts": ["Quantile"]}]); + let kll = json!([{"summary_type": "KLL", "readouts": ["Quantile"]}]); let kll_only = TempFile::json(&json!({ "supported_summaries": kll })); assert_eq!( planned_with(&["--deployment-capabilities", kll_only.path()]), diff --git a/crates/planner-cli/tests/goldens/stage0/promql_quantile_over_time/expected.json b/crates/planner-cli/tests/goldens/stage0/promql_quantile_over_time/expected.json index 6e8921c7b..21cb9c620 100644 --- a/crates/planner-cli/tests/goldens/stage0/promql_quantile_over_time/expected.json +++ b/crates/planner-cli/tests/goldens/stage0/promql_quantile_over_time/expected.json @@ -36,13 +36,13 @@ "readouts": [ "Total" ], - "summary_type": "Cms" + "summary_type": "CountMinSketch" }, { "readouts": [ "TopK" ], - "summary_type": "CmsWithHeap" + "summary_type": "CountMinSketchWithHeap" }, { "readouts": [ @@ -54,19 +54,19 @@ "readouts": [ "Distinct" ], - "summary_type": "Hll" + "summary_type": "HLL" }, { "readouts": [ "Distinct" ], - "summary_type": "Kmv" + "summary_type": "KMV" }, { "readouts": [ "Quantile" ], - "summary_type": "Kll" + "summary_type": "KLL" }, { "readouts": [ diff --git a/crates/planner-cli/tests/goldens/stage0/promql_shared_subexpression/expected.json b/crates/planner-cli/tests/goldens/stage0/promql_shared_subexpression/expected.json index 17b82f918..92988cd05 100644 --- a/crates/planner-cli/tests/goldens/stage0/promql_shared_subexpression/expected.json +++ b/crates/planner-cli/tests/goldens/stage0/promql_shared_subexpression/expected.json @@ -36,13 +36,13 @@ "readouts": [ "Total" ], - "summary_type": "Cms" + "summary_type": "CountMinSketch" }, { "readouts": [ "TopK" ], - "summary_type": "CmsWithHeap" + "summary_type": "CountMinSketchWithHeap" }, { "readouts": [ @@ -54,19 +54,19 @@ "readouts": [ "Distinct" ], - "summary_type": "Hll" + "summary_type": "HLL" }, { "readouts": [ "Distinct" ], - "summary_type": "Kmv" + "summary_type": "KMV" }, { "readouts": [ "Quantile" ], - "summary_type": "Kll" + "summary_type": "KLL" }, { "readouts": [ diff --git a/crates/planner-cli/tests/goldens/stage0/promql_sum_by_rate/expected.json b/crates/planner-cli/tests/goldens/stage0/promql_sum_by_rate/expected.json index 7be7a913d..a43bf4f54 100644 --- a/crates/planner-cli/tests/goldens/stage0/promql_sum_by_rate/expected.json +++ b/crates/planner-cli/tests/goldens/stage0/promql_sum_by_rate/expected.json @@ -36,13 +36,13 @@ "readouts": [ "Total" ], - "summary_type": "Cms" + "summary_type": "CountMinSketch" }, { "readouts": [ "TopK" ], - "summary_type": "CmsWithHeap" + "summary_type": "CountMinSketchWithHeap" }, { "readouts": [ @@ -54,19 +54,19 @@ "readouts": [ "Distinct" ], - "summary_type": "Hll" + "summary_type": "HLL" }, { "readouts": [ "Distinct" ], - "summary_type": "Kmv" + "summary_type": "KMV" }, { "readouts": [ "Quantile" ], - "summary_type": "Kll" + "summary_type": "KLL" }, { "readouts": [ diff --git a/crates/planner-cli/tests/goldens/stage0/sql_group_by/expected.json b/crates/planner-cli/tests/goldens/stage0/sql_group_by/expected.json index 3a0c64214..e7c7e876d 100644 --- a/crates/planner-cli/tests/goldens/stage0/sql_group_by/expected.json +++ b/crates/planner-cli/tests/goldens/stage0/sql_group_by/expected.json @@ -36,13 +36,13 @@ "readouts": [ "Total" ], - "summary_type": "Cms" + "summary_type": "CountMinSketch" }, { "readouts": [ "TopK" ], - "summary_type": "CmsWithHeap" + "summary_type": "CountMinSketchWithHeap" }, { "readouts": [ @@ -54,19 +54,19 @@ "readouts": [ "Distinct" ], - "summary_type": "Hll" + "summary_type": "HLL" }, { "readouts": [ "Distinct" ], - "summary_type": "Kmv" + "summary_type": "KMV" }, { "readouts": [ "Quantile" ], - "summary_type": "Kll" + "summary_type": "KLL" }, { "readouts": [ diff --git a/crates/planner-cli/tests/goldens/stage0/two_workloads/expected.json b/crates/planner-cli/tests/goldens/stage0/two_workloads/expected.json index 52f34f764..5de065674 100644 --- a/crates/planner-cli/tests/goldens/stage0/two_workloads/expected.json +++ b/crates/planner-cli/tests/goldens/stage0/two_workloads/expected.json @@ -36,13 +36,13 @@ "readouts": [ "Total" ], - "summary_type": "Cms" + "summary_type": "CountMinSketch" }, { "readouts": [ "TopK" ], - "summary_type": "CmsWithHeap" + "summary_type": "CountMinSketchWithHeap" }, { "readouts": [ @@ -54,19 +54,19 @@ "readouts": [ "Distinct" ], - "summary_type": "Hll" + "summary_type": "HLL" }, { "readouts": [ "Distinct" ], - "summary_type": "Kmv" + "summary_type": "KMV" }, { "readouts": [ "Quantile" ], - "summary_type": "Kll" + "summary_type": "KLL" }, { "readouts": [ diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/chains-10m-5m-3m-10s-mvp.json b/crates/planner-cli/tests/sketch_plan_snapshots/chains-10m-5m-3m-10s-mvp.json index 6a09150af..f1ad15ba1 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/chains-10m-5m-3m-10s-mvp.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/chains-10m-5m-3m-10s-mvp.json @@ -3,7 +3,7 @@ "materialized_views": [ { "coverage": { - "definition_id": "bfbffb8f01ab202d585c3e18c9f78080", + "definition_id": "2d963bc6757b98ad80934456821cc040", "selection": [ { "columns": [] @@ -14,11 +14,11 @@ "materialized_views": [] }, "node_id": 1, - "plan_id": "f6f31722b12fc85f69ff48e068761870", + "plan_id": "0d803bcba0819ca0aa4d8407f9c79197", "refresh": "at_ingestion", "retention_ms": 600000, "view_state_key": { - "definition_id": "bfbffb8f01ab202d585c3e18c9f78080", + "definition_id": "2d963bc6757b98ad80934456821cc040", "logical_properties": { "parameters": { "Kll": { @@ -35,7 +35,7 @@ }, { "coverage": { - "definition_id": "bfbffb8f01ab202d585c3e18c9f78080", + "definition_id": "2d963bc6757b98ad80934456821cc040", "selection": [ { "columns": [] @@ -46,11 +46,11 @@ "materialized_views": [] }, "node_id": 10, - "plan_id": "f6f31722b12fc85f69ff48e068761870", + "plan_id": "0d803bcba0819ca0aa4d8407f9c79197", "refresh": "at_ingestion", "retention_ms": 180000, "view_state_key": { - "definition_id": "bfbffb8f01ab202d585c3e18c9f78080", + "definition_id": "2d963bc6757b98ad80934456821cc040", "logical_properties": { "parameters": { "Kll": { @@ -67,7 +67,7 @@ }, { "coverage": { - "definition_id": "bfbffb8f01ab202d585c3e18c9f78080", + "definition_id": "2d963bc6757b98ad80934456821cc040", "selection": [ { "columns": [] @@ -80,11 +80,11 @@ ] }, "node_id": 11, - "plan_id": "f6f31722b12fc85f69ff48e068761870", + "plan_id": "0d803bcba0819ca0aa4d8407f9c79197", "refresh": "at_ingestion", "retention_ms": 180000, "view_state_key": { - "definition_id": "bfbffb8f01ab202d585c3e18c9f78080", + "definition_id": "2d963bc6757b98ad80934456821cc040", "logical_properties": { "parameters": { "Kll": { @@ -110,23 +110,23 @@ { "accepted_metric": "rank", "sketches": [ - "Kll" + "KLL" ], - "summary": "accepted rank (Kll)" + "summary": "accepted rank (KLL)" }, { "accepted_metric": "rank", "sketches": [ - "Kll" + "KLL" ], - "summary": "accepted rank (Kll)" + "summary": "accepted rank (KLL)" }, { "accepted_metric": "rank", "sketches": [ - "Kll" + "KLL" ], - "summary": "accepted rank (Kll)" + "summary": "accepted rank (KLL)" } ], "cost": { @@ -151,7 +151,7 @@ "cost_per_second": 1.78533090643e-8, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.000262089333333, - "detail": "build Kll in tumbling windows of 300000 ms for 10000 groups: 667 rows x 84 ops, 667 group visits, 33.3 states emitted; x 1.0000/s; keeps 12960000 bytes", + "detail": "build KLL in tumbling windows of 300000 ms for 10000 groups: 667 rows x 84 ops, 667 group visits, 33.3 states emitted; x 1.0000/s; keeps 12960000 bytes", "ingest_cpu_core_seconds_per_second": 0.000178756, "multiplier": 1, "operator": "SummaryTumblingWindowChain", @@ -165,7 +165,7 @@ "cost_per_second": 9.13096882614e-8, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.002678756, - "detail": "build Kll in tumbling windows of 10000 ms for 10000 groups: 667 rows x 84 ops, 667 group visits, 1000.0 states emitted; x 1.0000/s; keeps 53200000 bytes", + "detail": "build KLL in tumbling windows of 10000 ms for 10000 groups: 667 rows x 84 ops, 667 group visits, 1000.0 states emitted; x 1.0000/s; keeps 53200000 bytes", "ingest_cpu_core_seconds_per_second": 0.000178756, "multiplier": 1, "operator": "SummaryTumblingWindowChain", @@ -474,7 +474,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -518,7 +518,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -562,7 +562,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -650,7 +650,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -694,7 +694,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -738,7 +738,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -870,7 +870,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -914,7 +914,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -958,7 +958,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1002,7 +1002,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1046,7 +1046,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1220,7 +1220,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1263,7 +1263,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" }, "tumbling_window_width_ms": 300000 } @@ -1271,7 +1271,7 @@ }, "retention_ms": 600000, "view_coverage": { - "definition_id": "bfbffb8f01ab202d585c3e18c9f78080", + "definition_id": "2d963bc6757b98ad80934456821cc040", "selection": [ { "columns": [] @@ -1294,7 +1294,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1354,7 +1354,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1530,7 +1530,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1590,7 +1590,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1768,7 +1768,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1811,7 +1811,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" }, "tumbling_window_width_ms": 10000 } @@ -1819,7 +1819,7 @@ }, "retention_ms": 180000, "view_coverage": { - "definition_id": "bfbffb8f01ab202d585c3e18c9f78080", + "definition_id": "2d963bc6757b98ad80934456821cc040", "selection": [ { "columns": [] @@ -1844,7 +1844,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1884,7 +1884,7 @@ }, "retention_ms": 180000, "view_coverage": { - "definition_id": "bfbffb8f01ab202d585c3e18c9f78080", + "definition_id": "2d963bc6757b98ad80934456821cc040", "selection": [ { "columns": [] @@ -1907,7 +1907,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1969,7 +1969,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/distinct-over-time-5pct-raw-retained.json b/crates/planner-cli/tests/sketch_plan_snapshots/distinct-over-time-5pct-raw-retained.json index 08cfa8c3a..0f48df13f 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/distinct-over-time-5pct-raw-retained.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/distinct-over-time-5pct-raw-retained.json @@ -10,16 +10,16 @@ { "accepted_metric": "relative", "sketches": [ - "Kmv" + "KMV" ], - "summary": "accepted relative (Kmv)" + "summary": "accepted relative (KMV)" }, { "accepted_metric": "relative", "sketches": [ - "Kmv" + "KMV" ], - "summary": "accepted relative (Kmv)" + "summary": "accepted relative (KMV)" } ], "cost": { @@ -44,7 +44,7 @@ "cost_per_second": 5.43807654299e-9, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.0004796, - "detail": "build Kmv in tumbling windows of 300000 ms for 10000 groups: 400000 rows x 116.2 ops, 400000 group visits, 10000.0 states emitted; x 0.0033/s; holds 82400000 bytes for 143.880 ms", + "detail": "build KMV in tumbling windows of 300000 ms for 10000 groups: 400000 rows x 116.2 ops, 400000 group visits, 10000.0 states emitted; x 0.0033/s; holds 82400000 bytes for 143.880 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryTumblingWindowChain", @@ -275,7 +275,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false @@ -319,7 +319,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false @@ -363,7 +363,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false @@ -451,7 +451,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false @@ -495,7 +495,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false @@ -539,7 +539,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false @@ -714,7 +714,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false @@ -757,7 +757,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "tumbling_window_width_ms": 300000 } @@ -779,7 +779,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false @@ -839,7 +839,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false @@ -1011,7 +1011,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false @@ -1071,7 +1071,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/distinct-two-forms-raw-retained.json b/crates/planner-cli/tests/sketch_plan_snapshots/distinct-two-forms-raw-retained.json index 952d5a76f..d475491fd 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/distinct-two-forms-raw-retained.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/distinct-two-forms-raw-retained.json @@ -10,9 +10,9 @@ { "accepted_metric": "relative", "sketches": [ - "Kmv" + "KMV" ], - "summary": "accepted relative (Kmv)" + "summary": "accepted relative (KMV)" }, { "accepted_metric": null, @@ -98,7 +98,7 @@ "cost_per_second": 1.08171883312e-8, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.000953999724464, - "detail": "build Kmv into 10000 states: 200000 rows x 116.2 ops, 200000 group visits; x 0.0167/s; holds 82400000 bytes for 57.240 ms", + "detail": "build KMV into 10000 states: 200000 rows x 116.2 ops, 200000 group visits; x 0.0167/s; holds 82400000 bytes for 57.240 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryAgg", @@ -409,7 +409,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false @@ -788,7 +788,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false @@ -831,7 +831,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kmv" + "Sketch": "KMV" } } } diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/entropy-and-distinct-raw-retained.json b/crates/planner-cli/tests/sketch_plan_snapshots/entropy-and-distinct-raw-retained.json index 57d4ac31c..b8e06835c 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/entropy-and-distinct-raw-retained.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/entropy-and-distinct-raw-retained.json @@ -15,9 +15,9 @@ { "accepted_metric": "relative", "sketches": [ - "Kmv" + "KMV" ], - "summary": "accepted relative (Kmv)" + "summary": "accepted relative (KMV)" } ], "cost": { @@ -56,7 +56,7 @@ "cost_per_second": 1.08171914554e-8, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.000954, - "detail": "build Kmv into 10000 states: 200000 rows x 116.2 ops, 200000 group visits; x 0.0167/s; holds 82400000 bytes for 57.240 ms", + "detail": "build KMV into 10000 states: 200000 rows x 116.2 ops, 200000 group visits; x 0.0167/s; holds 82400000 bytes for 57.240 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryAgg", @@ -261,7 +261,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false @@ -535,7 +535,7 @@ }, { "dtype": { - "Sketch": "Kmv" + "Sketch": "KMV" }, "name": "state", "nullable": false @@ -578,7 +578,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kmv" + "Sketch": "KMV" } } } diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/mixed-quantiles-raw-retained.json b/crates/planner-cli/tests/sketch_plan_snapshots/mixed-quantiles-raw-retained.json index 43c77eeec..418d8070d 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/mixed-quantiles-raw-retained.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/mixed-quantiles-raw-retained.json @@ -13,16 +13,16 @@ { "accepted_metric": "rank", "sketches": [ - "Kll" + "KLL" ], - "summary": "accepted rank (Kll)" + "summary": "accepted rank (KLL)" }, { "accepted_metric": "rank", "sketches": [ - "Kll" + "KLL" ], - "summary": "accepted rank (Kll)" + "summary": "accepted rank (KLL)" }, { "accepted_metric": null, @@ -160,7 +160,7 @@ "cost_per_second": 9.52412691073e-9, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.000846666666667, - "detail": "build Kll into 10000 states: 200000 rows x 84 ops, 200000 group visits; x 0.0167/s; holds 4320000 bytes for 50.800 ms", + "detail": "build KLL into 10000 states: 200000 rows x 84 ops, 200000 group visits; x 0.0167/s; holds 4320000 bytes for 50.800 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryAgg", @@ -445,7 +445,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -533,7 +533,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1067,7 +1067,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1110,7 +1110,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/nested-windows-15m-1h-mvp.json b/crates/planner-cli/tests/sketch_plan_snapshots/nested-windows-15m-1h-mvp.json index 254a48e74..efbcb1d78 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/nested-windows-15m-1h-mvp.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/nested-windows-15m-1h-mvp.json @@ -90,7 +90,7 @@ } ], "cost": { - "cost_per_second": 5.73348028975e-6, + "cost_per_second": 5.71305047031e-6, "cpu_core_seconds_per_second": 0.467976233333, "per_node": { "0": { @@ -108,10 +108,10 @@ "timing": "ingestion_time" }, "1": { - "cost_per_second": 5.43681112249e-6, + "cost_per_second": 5.41997243781e-6, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.448586666667, - "detail": "build DDSketch in tumbling windows of 60000 ms for 10000 groups: 2000000 rows x 210 ops, 1000 group visits, 166.7 states emitted; x 1.0000/s; keeps 341600000 bytes", + "detail": "build DDSketch in tumbling windows of 60000 ms for 10000 groups: 2000000 rows x 210 ops, 1000 group visits, 166.7 states emitted; x 1.0000/s; keeps 326960000 bytes", "ingest_cpu_core_seconds_per_second": 0.44817, "multiplier": 1, "operator": "SummaryTumblingWindowChain", @@ -136,10 +136,10 @@ "timing": "query_time" }, "2": { - "cost_per_second": 8.39724918218e-8, + "cost_per_second": 8.03839196773e-8, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.0005, - "detail": "merge tumbling windows of 60000 ms into 300000 ms for 10000 groups: 166.7 states merged, 33.3 states emitted; x 1.0000/s; keeps 68120000 bytes", + "detail": "merge tumbling windows of 60000 ms into 300000 ms for 10000 groups: 166.7 states merged, 33.3 states emitted; x 1.0000/s; keeps 65000000 bytes", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMergeWindows", @@ -150,10 +150,10 @@ "timing": "ingestion_time" }, "3": { - "cost_per_second": 3.13332816795e-10, + "cost_per_second": 3.13332816026e-10, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.0000278666666667, - "detail": "time range cover 3600s: 11.20 + 4.00 tumbling windows of states per level; x 0.0167/s; holds 524 bytes for 1.672 ms", + "detail": "time range cover 3600s: 11.20 + 4.00 tumbling windows of states per level; x 0.0167/s; holds 500 bytes for 1.672 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "TimeRangeCover", @@ -164,10 +164,10 @@ "timing": "query_time" }, "4": { - "cost_per_second": 7.34856686431e-8, + "cost_per_second": 7.34838697563e-8, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.00651666666667, - "detail": "merge 152000 states into 10000; x 0.0167/s; holds 28320000 bytes for 391.000 ms", + "detail": "merge 152000 states into 10000; x 0.0167/s; holds 28080000 bytes for 391.000 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMerge", @@ -206,10 +206,10 @@ "timing": "query_time" }, "7": { - "cost_per_second": 1.27806806851e-10, + "cost_per_second": 1.27806806537e-10, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.0000113666666667, - "detail": "time range cover 900s: 2.20 + 4.00 tumbling windows of states per level; x 0.0167/s; holds 524 bytes for 0.682 ms", + "detail": "time range cover 900s: 2.20 + 4.00 tumbling windows of states per level; x 0.0167/s; holds 500 bytes for 0.682 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "TimeRangeCover", @@ -220,10 +220,10 @@ "timing": "query_time" }, "8": { - "cost_per_second": 3.11985191682e-8, + "cost_per_second": 3.11977554464e-8, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.00276666666667, - "detail": "merge 62000 states into 10000; x 0.0167/s; holds 28320000 bytes for 166.000 ms", + "detail": "merge 62000 states into 10000; x 0.0167/s; holds 28080000 bytes for 166.000 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMerge", @@ -250,7 +250,7 @@ }, "source": "analytical-cost-v2 (illustrative statistics)", "usage": { - "average_memory_bytes": 409982904.021, + "average_memory_bytes": 392220676.02, "cpu_ops_per_second": 461576233.333, "disk_bytes": 0, "latency_per_query": [ @@ -272,7 +272,7 @@ } ], "peak_cpu_cores": 3, - "peak_memory_bytes": 466361144, + "peak_memory_bytes": 448121096, "precompute_load": 0.000916666666667, "recommended_configuration": { "ingest": { diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/quantile-grouped-mvp.json b/crates/planner-cli/tests/sketch_plan_snapshots/quantile-grouped-mvp.json index 7445a5d6f..66ae312c8 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/quantile-grouped-mvp.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/quantile-grouped-mvp.json @@ -82,7 +82,7 @@ } ], "cost": { - "cost_per_second": 8.76149650182e-7, + "cost_per_second": 8.65929392088e-7, "cpu_core_seconds_per_second": 0.0625752503667, "per_node": { "0": { @@ -100,10 +100,10 @@ "timing": "ingestion_time" }, "1": { - "cost_per_second": 4.58889467452e-7, + "cost_per_second": 4.50332103108e-7, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.02877, - "detail": "build DDSketch in tumbling windows of 10000 ms for 10000 groups: 100000 rows x 247 ops, 1000 group visits, 1000.0 states emitted; x 1.0000/s; keeps 117720000 bytes", + "detail": "build DDSketch in tumbling windows of 10000 ms for 10000 groups: 100000 rows x 247 ops, 1000 group visits, 1000.0 states emitted; x 1.0000/s; keeps 110280000 bytes", "ingest_cpu_core_seconds_per_second": 0.02627, "multiplier": 1, "operator": "SummaryTumblingWindowChain", @@ -114,10 +114,10 @@ "timing": "ingestion_time" }, "2": { - "cost_per_second": 6.92328094673e-8, + "cost_per_second": 6.75765454006e-8, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.00291666666667, - "detail": "merge tumbling windows of 10000 ms into 60000 ms for 10000 groups: 1000.0 states merged, 166.7 states emitted; x 1.0000/s; keeps 31680000 bytes", + "detail": "merge tumbling windows of 10000 ms into 60000 ms for 10000 groups: 1000.0 states merged, 166.7 states emitted; x 1.0000/s; keeps 30240000 bytes", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMergeWindows", @@ -128,10 +128,10 @@ "timing": "ingestion_time" }, "3": { - "cost_per_second": 1.13377417093e-9, + "cost_per_second": 1.13377416815e-9, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.0001008337, - "detail": "time range cover 300s: 4.17 + 5.00 tumbling windows of states per level; x 0.1000/s; holds 415 bytes for 1.008 ms", + "detail": "time range cover 300s: 4.17 + 5.00 tumbling windows of states per level; x 0.1000/s; holds 391 bytes for 1.008 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "TimeRangeCover", @@ -142,10 +142,10 @@ "timing": "query_time" }, "4": { - "cost_per_second": 2.70759237494e-7, + "cost_per_second": 2.70752607814e-7, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.02401675, - "detail": "merge 91667 states into 10000; x 0.1000/s; holds 25880000 bytes for 240.167 ms", + "detail": "merge 91667 states into 10000; x 0.1000/s; holds 25640000 bytes for 240.167 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMerge", @@ -200,7 +200,7 @@ }, "source": "analytical-cost-v2 (illustrative statistics)", "usage": { - "average_memory_bytes": 150022629.532, + "average_memory_bytes": 141136865.509, "cpu_ops_per_second": 62095250.3667, "disk_bytes": 0, "latency_per_query": [ @@ -214,7 +214,7 @@ } ], "peak_cpu_cores": 2, - "peak_memory_bytes": 175680511, + "peak_memory_bytes": 166560487, "precompute_load": 0.00541666666667, "recommended_configuration": { "ingest": { diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/quantile-over-time-phase-0-raw-retained.json b/crates/planner-cli/tests/sketch_plan_snapshots/quantile-over-time-phase-0-raw-retained.json index d19e56d7d..284feecce 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/quantile-over-time-phase-0-raw-retained.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/quantile-over-time-phase-0-raw-retained.json @@ -10,16 +10,16 @@ { "accepted_metric": "rank", "sketches": [ - "Kll" + "KLL" ], - "summary": "accepted rank (Kll)" + "summary": "accepted rank (KLL)" }, { "accepted_metric": "rank", "sketches": [ - "Kll" + "KLL" ], - "summary": "accepted rank (Kll)" + "summary": "accepted rank (KLL)" } ], "cost": { @@ -58,7 +58,7 @@ "cost_per_second": 9.52412691073e-9, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.000846666666667, - "detail": "build Kll into 10000 states: 200000 rows x 84 ops, 200000 group visits; x 0.0167/s; holds 4320000 bytes for 50.800 ms", + "detail": "build KLL into 10000 states: 200000 rows x 84 ops, 200000 group visits; x 0.0167/s; holds 4320000 bytes for 50.800 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryAgg", @@ -277,7 +277,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -365,7 +365,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -593,7 +593,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -636,7 +636,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/quantile-single-mvp.json b/crates/planner-cli/tests/sketch_plan_snapshots/quantile-single-mvp.json index 1e3b9ed0d..33051e27d 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/quantile-single-mvp.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/quantile-single-mvp.json @@ -82,7 +82,7 @@ } ], "cost": { - "cost_per_second": 8.00796836235e-7, + "cost_per_second": 7.90576578141e-7, "cpu_core_seconds_per_second": 0.0560252503667, "per_node": { "0": { @@ -100,10 +100,10 @@ "timing": "ingestion_time" }, "1": { - "cost_per_second": 4.15860440062e-7, + "cost_per_second": 4.07303075717e-7, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.02507, - "detail": "build DDSketch in tumbling windows of 10000 ms for 10000 groups: 100000 rows x 210 ops, 1000 group visits, 1000.0 states emitted; x 1.0000/s; keeps 116480000 bytes", + "detail": "build DDSketch in tumbling windows of 10000 ms for 10000 groups: 100000 rows x 210 ops, 1000 group visits, 1000.0 states emitted; x 1.0000/s; keeps 109040000 bytes", "ingest_cpu_core_seconds_per_second": 0.02257, "multiplier": 1, "operator": "SummaryTumblingWindowChain", @@ -114,10 +114,10 @@ "timing": "ingestion_time" }, "2": { - "cost_per_second": 6.89567654562e-8, + "cost_per_second": 6.73005013895e-8, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.00291666666667, - "detail": "merge tumbling windows of 10000 ms into 60000 ms for 10000 groups: 1000.0 states merged, 166.7 states emitted; x 1.0000/s; keeps 31440000 bytes", + "detail": "merge tumbling windows of 10000 ms into 60000 ms for 10000 groups: 1000.0 states merged, 166.7 states emitted; x 1.0000/s; keeps 30000000 bytes", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMergeWindows", @@ -128,10 +128,10 @@ "timing": "ingestion_time" }, "3": { - "cost_per_second": 1.13377417047e-9, + "cost_per_second": 1.13377416768e-9, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.0001008337, - "detail": "time range cover 300s: 4.17 + 5.00 tumbling windows of states per level; x 0.1000/s; holds 411 bytes for 1.008 ms", + "detail": "time range cover 300s: 4.17 + 5.00 tumbling windows of states per level; x 0.1000/s; holds 387 bytes for 1.008 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "TimeRangeCover", @@ -142,10 +142,10 @@ "timing": "query_time" }, "4": { - "cost_per_second": 2.70758132547e-7, + "cost_per_second": 2.70751502867e-7, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.02401675, - "detail": "merge 91667 states into 10000; x 0.1000/s; holds 25840000 bytes for 240.167 ms", + "detail": "merge 91667 states into 10000; x 0.1000/s; holds 25600000 bytes for 240.167 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMerge", @@ -186,7 +186,7 @@ }, "source": "analytical-cost-v2 (illustrative statistics)", "usage": { - "average_memory_bytes": 148540592.861, + "average_memory_bytes": 139654828.839, "cpu_ops_per_second": 55705250.3667, "disk_bytes": 0, "latency_per_query": [ @@ -200,7 +200,7 @@ } ], "peak_cpu_cores": 2, - "peak_memory_bytes": 173760475, + "peak_memory_bytes": 164640451, "precompute_load": 0.00541666666667, "recommended_configuration": { "ingest": { diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/random-mixed-seed-862-long-w01-q3-mvp.json b/crates/planner-cli/tests/sketch_plan_snapshots/random-mixed-seed-862-long-w01-q3-mvp.json index 777b24251..0032ed98f 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/random-mixed-seed-862-long-w01-q3-mvp.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/random-mixed-seed-862-long-w01-q3-mvp.json @@ -82,7 +82,7 @@ } ], "cost": { - "cost_per_second": 0.0000201369403744, + "cost_per_second": 0.0000200517569418, "cpu_core_seconds_per_second": 1.73252600367, "per_node": { "0": { @@ -100,10 +100,10 @@ "timing": "ingestion_time" }, "1": { - "cost_per_second": 1.14922519573e-6, + "cost_per_second": 1.06613594838e-6, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.05127, - "detail": "build DDSketch in tumbling windows of 1000 ms for 10000 groups: 100000 rows x 247 ops, 1000 group visits, 10000.0 states emitted; x 1.0000/s; keeps 497960000 bytes", + "detail": "build DDSketch in tumbling windows of 1000 ms for 10000 groups: 100000 rows x 247 ops, 1000 group visits, 10000.0 states emitted; x 1.0000/s; keeps 425720000 bytes", "ingest_cpu_core_seconds_per_second": 0.02627, "multiplier": 1, "operator": "SummaryTumblingWindowChain", @@ -114,10 +114,10 @@ "timing": "ingestion_time" }, "2": { - "cost_per_second": 3.22222809467e-7, + "cost_per_second": 3.20566545401e-7, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.0254166666667, - "detail": "merge tumbling windows of 1000 ms into 60000 ms for 10000 groups: 10000.0 states merged, 166.7 states emitted; x 1.0000/s; keeps 31680000 bytes", + "detail": "merge tumbling windows of 1000 ms into 60000 ms for 10000 groups: 10000.0 states merged, 166.7 states emitted; x 1.0000/s; keeps 30240000 bytes", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMergeWindows", @@ -128,10 +128,10 @@ "timing": "ingestion_time" }, "3": { - "cost_per_second": 7.7941576695e-8, + "cost_per_second": 7.79415765037e-8, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.006931837, - "detail": "time range cover 300s: 4.02 + 59.00 tumbling windows of states per level; x 1.0000/s; holds 184 bytes for 6.932 ms", + "detail": "time range cover 300s: 4.02 + 59.00 tumbling windows of states per level; x 1.0000/s; holds 160 bytes for 6.932 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "TimeRangeCover", @@ -142,10 +142,10 @@ "timing": "query_time" }, "4": { - "cost_per_second": 0.0000178849008566, + "cost_per_second": 0.0000178844629355, "cost_source": "analytical", "cpu_core_seconds_per_second": 1.5864175, - "detail": "merge 630167 states into 10000; x 1.0000/s; holds 25880000 bytes for 1586.418 ms", + "detail": "merge 630167 states into 10000; x 1.0000/s; holds 25640000 bytes for 1586.418 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMerge", @@ -200,7 +200,7 @@ }, "source": "analytical-cost-v2 (illustrative statistics)", "usage": { - "average_memory_bytes": 570707246.176, + "average_memory_bytes": 496646505.81, "cpu_ops_per_second": 1732046003.67, "disk_bytes": 0, "latency_per_query": [ @@ -214,7 +214,7 @@ } ], "peak_cpu_cores": 3, - "peak_memory_bytes": 555920280, + "peak_memory_bytes": 482000256, "precompute_load": 0.0504166666667, "recommended_configuration": { "ingest": { diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/random-mixed-seed-862-w01-q3-q8-mvp.json b/crates/planner-cli/tests/sketch_plan_snapshots/random-mixed-seed-862-w01-q3-q8-mvp.json index 7062c108f..4b9b82a93 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/random-mixed-seed-862-w01-q3-q8-mvp.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/random-mixed-seed-862-w01-q3-q8-mvp.json @@ -142,7 +142,7 @@ } ], "cost": { - "cost_per_second": 0.0000301080959229, + "cost_per_second": 0.0000300795223309, "cpu_core_seconds_per_second": 2.64897803333, "per_node": { "0": { @@ -160,10 +160,10 @@ "timing": "ingestion_time" }, "1": { - "cost_per_second": 7.81166514243e-7, + "cost_per_second": 7.5328606912e-7, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.05127, - "detail": "build DDSketch in tumbling windows of 1000 ms for 10000 groups: 100000 rows x 247 ops, 1000 group visits, 10000.0 states emitted; x 1.0000/s; keeps 177960000 bytes", + "detail": "build DDSketch in tumbling windows of 1000 ms for 10000 groups: 100000 rows x 247 ops, 1000 group visits, 10000.0 states emitted; x 1.0000/s; keeps 153720000 bytes", "ingest_cpu_core_seconds_per_second": 0.02627, "multiplier": 1, "operator": "SummaryTumblingWindowChain", @@ -244,10 +244,10 @@ "timing": "query_time" }, "2": { - "cost_per_second": 1.23684002024e-7, + "cost_per_second": 1.23684001721e-7, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.011, - "detail": "time range 100s: 100 tumbling windows of states; x 1.0000/s; holds 160 bytes for 11.000 ms", + "detail": "time range 100s: 100 tumbling windows of states; x 1.0000/s; holds 136 bytes for 11.000 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "TimeRange", @@ -258,10 +258,10 @@ "timing": "query_time" }, "3": { - "cost_per_second": 0.0000283049625663, + "cost_per_second": 0.0000283042694198, "cost_source": "analytical", "cpu_core_seconds_per_second": 2.511, - "detail": "merge 1000000 states into 10000; x 1.0000/s; holds 24680000 bytes for 2511.000 ms", + "detail": "merge 1000000 states into 10000; x 1.0000/s; holds 24440000 bytes for 2511.000 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMerge", @@ -358,7 +358,7 @@ }, "source": "analytical-cost-v2 (illustrative statistics)", "usage": { - "average_memory_bytes": 280813409.212, + "average_memory_bytes": 255970768.948, "cpu_ops_per_second": 2648018033.33, "disk_bytes": 0, "latency_per_query": [ @@ -380,7 +380,7 @@ } ], "peak_cpu_cores": 4, - "peak_memory_bytes": 244920365, + "peak_memory_bytes": 220440341, "precompute_load": 0.025975, "recommended_configuration": { "ingest": { diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/random-mixed-seed-862-w02-q2-q7-mvp.json b/crates/planner-cli/tests/sketch_plan_snapshots/random-mixed-seed-862-w02-q2-q7-mvp.json index 925859288..b04004b53 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/random-mixed-seed-862-w02-q2-q7-mvp.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/random-mixed-seed-862-w02-q2-q7-mvp.json @@ -112,7 +112,7 @@ } ], "cost": { - "cost_per_second": 0.0000303721390498, + "cost_per_second": 0.0000303435654579, "cpu_core_seconds_per_second": 2.6724601426, "per_node": { "0": { @@ -130,10 +130,10 @@ "timing": "ingestion_time" }, "1": { - "cost_per_second": 7.81166514243e-7, + "cost_per_second": 7.5328606912e-7, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.05127, - "detail": "build DDSketch in tumbling windows of 1000 ms for 10000 groups: 100000 rows x 247 ops, 1000 group visits, 10000.0 states emitted; x 1.0000/s; keeps 177960000 bytes", + "detail": "build DDSketch in tumbling windows of 1000 ms for 10000 groups: 100000 rows x 247 ops, 1000 group visits, 10000.0 states emitted; x 1.0000/s; keeps 153720000 bytes", "ingest_cpu_core_seconds_per_second": 0.02627, "multiplier": 1, "operator": "SummaryTumblingWindowChain", @@ -200,10 +200,10 @@ "timing": "query_time" }, "2": { - "cost_per_second": 1.23684002024e-7, + "cost_per_second": 1.23684001721e-7, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.011, - "detail": "time range 100s: 100 tumbling windows of states; x 1.0000/s; holds 160 bytes for 11.000 ms", + "detail": "time range 100s: 100 tumbling windows of states; x 1.0000/s; holds 136 bytes for 11.000 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "TimeRange", @@ -214,10 +214,10 @@ "timing": "query_time" }, "3": { - "cost_per_second": 0.0000283049625663, + "cost_per_second": 0.0000283042694198, "cost_source": "analytical", "cpu_core_seconds_per_second": 2.511, - "detail": "merge 1000000 states into 10000; x 1.0000/s; holds 24680000 bytes for 2511.000 ms", + "detail": "merge 1000000 states into 10000; x 1.0000/s; holds 24440000 bytes for 2511.000 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMerge", @@ -314,7 +314,7 @@ }, "source": "analytical-cost-v2 (illustrative statistics)", "usage": { - "average_memory_bytes": 280822355.933, + "average_memory_bytes": 255979715.669, "cpu_ops_per_second": 2671500142.6, "disk_bytes": 0, "latency_per_query": [ @@ -336,7 +336,7 @@ } ], "peak_cpu_cores": 4, - "peak_memory_bytes": 244930366, + "peak_memory_bytes": 220450342, "precompute_load": 0.02895, "recommended_configuration": { "ingest": { diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/ratio-of-quantiles-1h-mvp.json b/crates/planner-cli/tests/sketch_plan_snapshots/ratio-of-quantiles-1h-mvp.json index e351ddc87..5b6df988b 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/ratio-of-quantiles-1h-mvp.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/ratio-of-quantiles-1h-mvp.json @@ -82,7 +82,7 @@ } ], "cost": { - "cost_per_second": 6.2464250683e-6, + "cost_per_second": 6.22599601259e-6, "cpu_core_seconds_per_second": 0.465198366667, "per_node": { "0": { @@ -100,10 +100,10 @@ "timing": "ingestion_time" }, "1": { - "cost_per_second": 5.88878718336e-6, + "cost_per_second": 5.87194849868e-6, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.448586666667, - "detail": "build DDSketch in tumbling windows of 60000 ms for 10000 groups: 2000000 rows x 210 ops, 1000 group visits, 166.7 states emitted; x 1.0000/s; keeps 734560000 bytes", + "detail": "build DDSketch in tumbling windows of 60000 ms for 10000 groups: 2000000 rows x 210 ops, 1000 group visits, 166.7 states emitted; x 1.0000/s; keeps 719920000 bytes", "ingest_cpu_core_seconds_per_second": 0.44817, "multiplier": 1, "operator": "SummaryTumblingWindowChain", @@ -114,10 +114,10 @@ "timing": "ingestion_time" }, "2": { - "cost_per_second": 1.76079176864e-7, + "cost_per_second": 1.7249060472e-7, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.0005, - "detail": "merge tumbling windows of 60000 ms into 300000 ms for 10000 groups: 166.7 states merged, 33.3 states emitted; x 1.0000/s; keeps 148200000 bytes", + "detail": "merge tumbling windows of 60000 ms into 300000 ms for 10000 groups: 166.7 states merged, 33.3 states emitted; x 1.0000/s; keeps 145080000 bytes", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMergeWindows", @@ -128,10 +128,10 @@ "timing": "ingestion_time" }, "3": { - "cost_per_second": 3.13332836539e-10, + "cost_per_second": 3.1333283577e-10, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.0000278666666667, - "detail": "time range cover 3600s: 11.20 + 4.00 tumbling windows of states per level; x 0.0167/s; holds 1140 bytes for 1.672 ms", + "detail": "time range cover 3600s: 11.20 + 4.00 tumbling windows of states per level; x 0.0167/s; holds 1116 bytes for 1.672 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "TimeRangeCover", @@ -142,10 +142,10 @@ "timing": "query_time" }, "4": { - "cost_per_second": 7.36721532419e-8, + "cost_per_second": 7.36703543551e-8, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.00651666666667, - "detail": "merge 152000 states into 10000; x 0.0167/s; holds 53200000 bytes for 391.000 ms", + "detail": "merge 152000 states into 10000; x 0.0167/s; holds 52960000 bytes for 391.000 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMerge", @@ -228,7 +228,7 @@ }, "source": "analytical-cost-v2 (illustrative statistics)", "usage": { - "average_memory_bytes": 883106686.698, + "average_memory_bytes": 865345122.698, "cpu_ops_per_second": 458798366.667, "disk_bytes": 0, "latency_per_query": [ @@ -242,7 +242,7 @@ } ], "peak_cpu_cores": 2, - "peak_memory_bytes": 935961268, + "peak_memory_bytes": 917961244, "precompute_load": 0.000916666666667, "recommended_configuration": { "ingest": { diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/shared-quantiles-1h-mvp.json b/crates/planner-cli/tests/sketch_plan_snapshots/shared-quantiles-1h-mvp.json index 5c930e67e..5a8209670 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/shared-quantiles-1h-mvp.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/shared-quantiles-1h-mvp.json @@ -90,7 +90,7 @@ } ], "cost": { - "cost_per_second": 5.70215396377e-6, + "cost_per_second": 5.68172490806e-6, "cpu_core_seconds_per_second": 0.4651982, "per_node": { "0": { @@ -108,10 +108,10 @@ "timing": "ingestion_time" }, "1": { - "cost_per_second": 5.43681112249e-6, + "cost_per_second": 5.41997243781e-6, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.448586666667, - "detail": "build DDSketch in tumbling windows of 60000 ms for 10000 groups: 2000000 rows x 210 ops, 1000 group visits, 166.7 states emitted; x 1.0000/s; keeps 341600000 bytes", + "detail": "build DDSketch in tumbling windows of 60000 ms for 10000 groups: 2000000 rows x 210 ops, 1000 group visits, 166.7 states emitted; x 1.0000/s; keeps 326960000 bytes", "ingest_cpu_core_seconds_per_second": 0.44817, "multiplier": 1, "operator": "SummaryTumblingWindowChain", @@ -122,10 +122,10 @@ "timing": "ingestion_time" }, "2": { - "cost_per_second": 8.39724918218e-8, + "cost_per_second": 8.03839196773e-8, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.0005, - "detail": "merge tumbling windows of 60000 ms into 300000 ms for 10000 groups: 166.7 states merged, 33.3 states emitted; x 1.0000/s; keeps 68120000 bytes", + "detail": "merge tumbling windows of 60000 ms into 300000 ms for 10000 groups: 166.7 states merged, 33.3 states emitted; x 1.0000/s; keeps 65000000 bytes", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMergeWindows", @@ -136,10 +136,10 @@ "timing": "ingestion_time" }, "3": { - "cost_per_second": 3.13332816795e-10, + "cost_per_second": 3.13332816026e-10, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.0000278666666667, - "detail": "time range cover 3600s: 11.20 + 4.00 tumbling windows of states per level; x 0.0167/s; holds 524 bytes for 1.672 ms", + "detail": "time range cover 3600s: 11.20 + 4.00 tumbling windows of states per level; x 0.0167/s; holds 500 bytes for 1.672 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "TimeRangeCover", @@ -150,10 +150,10 @@ "timing": "query_time" }, "4": { - "cost_per_second": 7.34856686431e-8, + "cost_per_second": 7.34838697563e-8, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.00651666666667, - "detail": "merge 152000 states into 10000; x 0.0167/s; holds 28320000 bytes for 391.000 ms", + "detail": "merge 152000 states into 10000; x 0.0167/s; holds 28080000 bytes for 391.000 ms", "ingest_cpu_core_seconds_per_second": 0.0, "multiplier": 1, "operator": "SummaryMerge", @@ -222,7 +222,7 @@ }, "source": "analytical-cost-v2 (illustrative statistics)", "usage": { - "average_memory_bytes": 409904552.015, + "average_memory_bytes": 392142988.014, "cpu_ops_per_second": 458798200.0, "disk_bytes": 0, "latency_per_query": [ @@ -244,7 +244,7 @@ } ], "peak_cpu_cores": 3, - "peak_memory_bytes": 438040620, + "peak_memory_bytes": 420040596, "precompute_load": 0.000916666666667, "recommended_configuration": { "ingest": { diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/sql-rollup-quantile-different-windows-raw-retained.json b/crates/planner-cli/tests/sketch_plan_snapshots/sql-rollup-quantile-different-windows-raw-retained.json index 88bc5cd2e..31785b350 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/sql-rollup-quantile-different-windows-raw-retained.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/sql-rollup-quantile-different-windows-raw-retained.json @@ -3,7 +3,7 @@ "materialized_views": [ { "coverage": { - "definition_id": "a446d509bf79a41e64d4c7dc4e541037", + "definition_id": "6f1cdb35c5c714b2f0c0d076a4f2f3f7", "selection": [ { "columns": [] @@ -14,11 +14,11 @@ "materialized_views": [] }, "node_id": 5, - "plan_id": "6d7351cc3cf7ce07c425fd0b394d9508", + "plan_id": "d79a20a6ab11b3524444d7c9ec9f2b14", "refresh": "at_ingestion", "retention_ms": 300000, "view_state_key": { - "definition_id": "a446d509bf79a41e64d4c7dc4e541037", + "definition_id": "6f1cdb35c5c714b2f0c0d076a4f2f3f7", "logical_properties": { "parameters": { "Kll": { @@ -44,9 +44,9 @@ { "accepted_metric": "rank", "sketches": [ - "Kll" + "KLL" ], - "summary": "accepted rank (Kll)" + "summary": "accepted rank (KLL)" }, { "accepted_metric": null, @@ -146,7 +146,7 @@ "cost_per_second": 1.883841902e-9, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.0000659526666667, - "detail": "build Kll in tumbling windows of 60000 ms for 10 groups: 667 rows x 84 ops, 1 group visits, 0.2 states emitted; x 1.0000/s; keeps 993120 bytes", + "detail": "build KLL in tumbling windows of 60000 ms for 10 groups: 667 rows x 84 ops, 1 group visits, 0.2 states emitted; x 1.0000/s; keeps 993120 bytes", "ingest_cpu_core_seconds_per_second": 0.000065536, "multiplier": 1, "operator": "SummaryTumblingWindowChain", @@ -466,7 +466,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -510,7 +510,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -547,7 +547,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1034,7 +1034,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1076,7 +1076,7 @@ ] }, "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" }, "tumbling_window_width_ms": 60000 } @@ -1084,7 +1084,7 @@ }, "retention_ms": 300000, "view_coverage": { - "definition_id": "a446d509bf79a41e64d4c7dc4e541037", + "definition_id": "6f1cdb35c5c714b2f0c0d076a4f2f3f7", "selection": [ { "columns": [] @@ -1114,7 +1114,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1167,7 +1167,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false diff --git a/crates/planner-cli/tests/sketch_plan_snapshots/sql-rollup-quantile-same-window-raw-retained.json b/crates/planner-cli/tests/sketch_plan_snapshots/sql-rollup-quantile-same-window-raw-retained.json index d24ff8824..bb55625fc 100644 --- a/crates/planner-cli/tests/sketch_plan_snapshots/sql-rollup-quantile-same-window-raw-retained.json +++ b/crates/planner-cli/tests/sketch_plan_snapshots/sql-rollup-quantile-same-window-raw-retained.json @@ -3,7 +3,7 @@ "materialized_views": [ { "coverage": { - "definition_id": "a446d509bf79a41e64d4c7dc4e541037", + "definition_id": "6f1cdb35c5c714b2f0c0d076a4f2f3f7", "selection": [ { "columns": [] @@ -14,11 +14,11 @@ "materialized_views": [] }, "node_id": 5, - "plan_id": "89012c8e68fdc98e4a2444c794e86277", + "plan_id": "a59c94b8de3148ac0060db8d65c29b7b", "refresh": "at_ingestion", "retention_ms": 300000, "view_state_key": { - "definition_id": "a446d509bf79a41e64d4c7dc4e541037", + "definition_id": "6f1cdb35c5c714b2f0c0d076a4f2f3f7", "logical_properties": { "parameters": { "Kll": { @@ -44,9 +44,9 @@ { "accepted_metric": "rank", "sketches": [ - "Kll" + "KLL" ], - "summary": "accepted rank (Kll)" + "summary": "accepted rank (KLL)" }, { "accepted_metric": null, @@ -146,7 +146,7 @@ "cost_per_second": 1.883841902e-9, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.0000659526666667, - "detail": "build Kll in tumbling windows of 60000 ms for 10 groups: 667 rows x 84 ops, 1 group visits, 0.2 states emitted; x 1.0000/s; keeps 993120 bytes", + "detail": "build KLL in tumbling windows of 60000 ms for 10 groups: 667 rows x 84 ops, 1 group visits, 0.2 states emitted; x 1.0000/s; keeps 993120 bytes", "ingest_cpu_core_seconds_per_second": 0.000065536, "multiplier": 1, "operator": "SummaryTumblingWindowChain", @@ -466,7 +466,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -510,7 +510,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -547,7 +547,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1034,7 +1034,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1076,7 +1076,7 @@ ] }, "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" }, "tumbling_window_width_ms": 60000 } @@ -1084,7 +1084,7 @@ }, "retention_ms": 300000, "view_coverage": { - "definition_id": "a446d509bf79a41e64d4c7dc4e541037", + "definition_id": "6f1cdb35c5c714b2f0c0d076a4f2f3f7", "selection": [ { "columns": [] @@ -1114,7 +1114,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -1167,7 +1167,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false diff --git a/crates/planner/src/installable/mod.rs b/crates/planner/src/installable/mod.rs index 3244a12b0..21ce111cb 100644 --- a/crates/planner/src/installable/mod.rs +++ b/crates/planner/src/installable/mod.rs @@ -44,8 +44,10 @@ use serde::{Deserialize, Serialize}; use crate::{e2e_plan, PlanError, UserInput}; /// The version of the plan-file format [`InstallablePlan`] serializes to: -/// the DAG, its nodes' fields and the query texts. -pub const INSTALLABLE_PLAN_WIRE_VERSION: u32 = 15; +/// the DAG, its nodes' fields and the query texts. Bumped to 16 when a +/// sketch family started being written by `asap_sketchlib`'s full +/// `SketchAlgorithm` names (`{"Sketch": "KLL"}`, `"CountMinSketch"`, ...). +pub const INSTALLABLE_PLAN_WIRE_VERSION: u32 = 16; /// The selected plan, ready to install and execute: what /// [`plan_installable`] returns and a runtime writes as its plan file. diff --git a/crates/planner/src/installable/tests.rs b/crates/planner/src/installable/tests.rs index f23dfb9ca..45e783092 100644 --- a/crates/planner/src/installable/tests.rs +++ b/crates/planner/src/installable/tests.rs @@ -321,7 +321,7 @@ fn unrestricted_summaries_default_to_the_executors_families() { })); let kll_only = DeploymentCapabilities { supported_summaries: Some(vec![SupportedSummary { - summary_type: SketchAlgorithm::Kll, + summary_type: SketchAlgorithm::KLL, readouts: vec![StatisticKind::Quantile], }]), ..DeploymentCapabilities::default() diff --git a/crates/planner/tests/exact_only_reads.rs b/crates/planner/tests/exact_only_reads.rs index a022ea53d..65389a8dd 100644 --- a/crates/planner/tests/exact_only_reads.rs +++ b/crates/planner/tests/exact_only_reads.rs @@ -87,7 +87,7 @@ async fn a_relative_query_reads_no_rank_sketch_of_a_query_sharing_its_groups() { .await; let read = payloads_read_by(&dag, 1); assert!( - !read.iter().any(|payload| payload.contains("Sketch(Kll)")), + !read.iter().any(|payload| payload.contains("Sketch(KLL)")), "the relative query reads a KLL sketch: {read:?}" ); } diff --git a/crates/stage1-pass1-per-computation-candidates/src/summary_realization.rs b/crates/stage1-pass1-per-computation-candidates/src/summary_realization.rs index 1fd027824..af8af42a4 100644 --- a/crates/stage1-pass1-per-computation-candidates/src/summary_realization.rs +++ b/crates/stage1-pass1-per-computation-candidates/src/summary_realization.rs @@ -24,13 +24,13 @@ use crate::{expression, schema, PerComputationCandidateError}; /// offers those that answer an intent's statistic: the specialized algorithms /// before the universal UnivMon. const ALGORITHM_PREFERENCE: &[SketchAlgorithm] = &[ - SketchAlgorithm::Kll, + SketchAlgorithm::KLL, SketchAlgorithm::DDSketch, - SketchAlgorithm::Hll, - SketchAlgorithm::Kmv, - SketchAlgorithm::Cms, + SketchAlgorithm::HLL, + SketchAlgorithm::KMV, + SketchAlgorithm::CountMinSketch, SketchAlgorithm::CountSketch, - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchAlgorithm::CountSketchWithHeap, SketchAlgorithm::UnivMon, ]; @@ -416,12 +416,11 @@ pub(crate) fn summary_update( weight, } } - (_, Some(SketchAlgorithm::UnivMon)) | (AggIntent::Count, Some(SketchAlgorithm::Cms)) => { - SummaryUpdate { - item: Some(weight), - weight: SummaryInputExpr::Constant(1.0), - } - } + (_, Some(SketchAlgorithm::UnivMon)) + | (AggIntent::Count, Some(SketchAlgorithm::CountMinSketch)) => SummaryUpdate { + item: Some(weight), + weight: SummaryInputExpr::Constant(1.0), + }, _ => SummaryUpdate { item: None, weight }, }) } diff --git a/crates/stage1-pass1-per-computation-candidates/src/tests/fused.rs b/crates/stage1-pass1-per-computation-candidates/src/tests/fused.rs index 32b9ec573..b312d6418 100644 --- a/crates/stage1-pass1-per-computation-candidates/src/tests/fused.rs +++ b/crates/stage1-pass1-per-computation-candidates/src/tests/fused.rs @@ -38,7 +38,7 @@ fn whole_expression_topk_heaps_read_the_raw_samples() { query(&mut memo, ranked, None); let memo = pass1_memo(memo, &[]).unwrap(); for algorithm in [ - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchAlgorithm::CountSketchWithHeap, ] { let (state, update) = state_group(&memo, algorithm); @@ -101,7 +101,7 @@ fn whole_expression_topk_heap_candidates() { memo_printout(&memo) ); for (project, algorithm) in ranked_candidates[1..].iter().zip([ - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchAlgorithm::CountSketchWithHeap, ]) { assert!(project.fused_groups.is_empty()); @@ -150,7 +150,7 @@ fn count_ranked_topk_counts_with_unit_weight() { ); query(&mut memo, ranked, None); let memo = pass1_memo(memo, &[]).unwrap(); - let (_, update) = state_group(&memo, SketchAlgorithm::CmsWithHeap); + let (_, update) = state_group(&memo, SketchAlgorithm::CountMinSketchWithHeap); assert_eq!(update.weight, SummaryInputExpr::Constant(1.0)); } diff --git a/crates/stage1-pass1-per-computation-candidates/src/tests/intents.rs b/crates/stage1-pass1-per-computation-candidates/src/tests/intents.rs index a2dcd75da..17ed56b00 100644 --- a/crates/stage1-pass1-per-computation-candidates/src/tests/intents.rs +++ b/crates/stage1-pass1-per-computation-candidates/src/tests/intents.rs @@ -24,8 +24,8 @@ fn cardinality_keeps_specialized_and_universal_summaries() { assert_eq!( algorithms(&choices), vec![ - SketchAlgorithm::Hll, - SketchAlgorithm::Kmv, + SketchAlgorithm::HLL, + SketchAlgorithm::KMV, SketchAlgorithm::UnivMon ] ); @@ -57,7 +57,7 @@ fn topk_keeps_both_specialized_heap_choices() { assert_eq!( algorithms(&choices), vec![ - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchAlgorithm::CountSketchWithHeap ] ); diff --git a/crates/stage1-pass1-per-computation-candidates/src/tests/running_example.rs b/crates/stage1-pass1-per-computation-candidates/src/tests/running_example.rs index f2a56611c..515be145c 100644 --- a/crates/stage1-pass1-per-computation-candidates/src/tests/running_example.rs +++ b/crates/stage1-pass1-per-computation-candidates/src/tests/running_example.rs @@ -58,10 +58,10 @@ fn running_example_gives_one_build_per_theta_and_separate_readouts() { query(&mut memo, g6, None); let memo = pass1_memo(memo, &[]).unwrap(); println!("{}", memo_printout(&memo)); - let (kll, _) = state_group(&memo, SketchAlgorithm::Kll); + let (kll, _) = state_group(&memo, SketchAlgorithm::KLL); let (ddsketch, _) = state_group(&memo, SketchAlgorithm::DDSketch); for (state, algorithm) in [ - (kll, SketchAlgorithm::Kll), + (kll, SketchAlgorithm::KLL), (ddsketch, SketchAlgorithm::DDSketch), ] { let thetas: Vec = candidates_of(&memo, state) diff --git a/crates/stage1-pass1-per-computation-candidates/src/tests/summary_realization.rs b/crates/stage1-pass1-per-computation-candidates/src/tests/summary_realization.rs index c27a965dc..2ed66b9be 100644 --- a/crates/stage1-pass1-per-computation-candidates/src/tests/summary_realization.rs +++ b/crates/stage1-pass1-per-computation-candidates/src/tests/summary_realization.rs @@ -95,18 +95,18 @@ fn summary_candidates_keep_the_hand_written_lists() { let cases = [ ( AggIntent::Quantile { col: None, q: 0.99 }, - vec![S::Kll, S::DDSketch], + vec![S::KLL, S::DDSketch], ), - (cardinality(vec![]), vec![S::Hll, S::Kmv, S::UnivMon]), - (cardinality(vec![1]), vec![S::Hll, S::Kmv, S::UnivMon]), - (cardinality(vec![1, 2]), vec![S::Hll, S::Kmv]), + (cardinality(vec![]), vec![S::HLL, S::KMV, S::UnivMon]), + (cardinality(vec![1]), vec![S::HLL, S::KMV, S::UnivMon]), + (cardinality(vec![1, 2]), vec![S::HLL, S::KMV]), (AggIntent::FrequencyL2 { col: None }, vec![S::UnivMon]), (AggIntent::FrequencyEntropy { col: None }, vec![S::UnivMon]), ( AggIntent::TopK { k: 10 }, - vec![S::CmsWithHeap, S::CountSketchWithHeap], + vec![S::CountMinSketchWithHeap, S::CountSketchWithHeap], ), - (AggIntent::Count, vec![S::Cms, S::UnivMon]), + (AggIntent::Count, vec![S::CountMinSketch, S::UnivMon]), (AggIntent::Sum { col: None }, vec![]), ]; for (intent, want) in cases { @@ -124,9 +124,9 @@ fn an_algorithm_without_the_readout_is_not_offered() { let answers = |algorithm| { SummaryTypeCapability::of(&FieldDataType::Sketch(algorithm)).answers(&statistic) }; - assert!(!answers(SketchAlgorithm::Cms)); - assert!(answers(SketchAlgorithm::CmsWithHeap)); + assert!(!answers(SketchAlgorithm::CountMinSketch)); + assert!(answers(SketchAlgorithm::CountMinSketchWithHeap)); let offered = summary_candidates(&top_k); - assert!(!offered.contains(&SketchAlgorithm::Cms)); + assert!(!offered.contains(&SketchAlgorithm::CountMinSketch)); assert!(offered.iter().all(|algorithm| answers(*algorithm))); } diff --git a/crates/stage1-pass1-per-computation-candidates/src/tests/targets.rs b/crates/stage1-pass1-per-computation-candidates/src/tests/targets.rs index 1e61cd80d..6fa30bb42 100644 --- a/crates/stage1-pass1-per-computation-candidates/src/tests/targets.rs +++ b/crates/stage1-pass1-per-computation-candidates/src/tests/targets.rs @@ -165,7 +165,7 @@ fn an_excluded_exact_family_is_left_to_stage_2() { fn an_excluded_readout_of_the_measure_skips_the_summary() { let kll_with = |readouts| DeploymentCapabilities { supported_summaries: Some(vec![SupportedSummary { - summary_type: SketchAlgorithm::Kll, + summary_type: SketchAlgorithm::KLL, readouts, }]), ..Default::default() @@ -178,7 +178,7 @@ fn an_excluded_readout_of_the_measure_skips_the_summary() { quantile(0.9), &kll_with(vec![StatisticKind::Quantile]).exclusions(), ); - assert!(built_summary_types(&memo).contains(&FieldDataType::Sketch(SketchAlgorithm::Kll))); + assert!(built_summary_types(&memo).contains(&FieldDataType::Sketch(SketchAlgorithm::KLL))); } /// Only an exclusion of every state of a family, or of the readout the @@ -187,9 +187,9 @@ fn an_excluded_readout_of_the_measure_skips_the_summary() { #[test] fn a_partial_exclusion_keeps_the_summary() { let kll_not_mergeable = DeploymentCapabilities { - state_not_mergeable_across_windows: vec![SummaryFamily::Sketch(SketchAlgorithm::Kll)], + state_not_mergeable_across_windows: vec![SummaryFamily::Sketch(SketchAlgorithm::KLL)], ..Default::default() }; let (memo, _) = pass1_under(quantile(0.9), &kll_not_mergeable.exclusions()); - assert!(built_summary_types(&memo).contains(&FieldDataType::Sketch(SketchAlgorithm::Kll))); + assert!(built_summary_types(&memo).contains(&FieldDataType::Sketch(SketchAlgorithm::KLL))); } diff --git a/crates/stage1-pass1-per-computation-candidates/src/tests/unsupported_ways.rs b/crates/stage1-pass1-per-computation-candidates/src/tests/unsupported_ways.rs index c6ace31f6..ac35fa7c6 100644 --- a/crates/stage1-pass1-per-computation-candidates/src/tests/unsupported_ways.rs +++ b/crates/stage1-pass1-per-computation-candidates/src/tests/unsupported_ways.rs @@ -103,7 +103,7 @@ fn a_readout_an_open_group_cannot_rename_adds_nothing() { assert_unsupported_way_adds_nothing( &mut memo, &measure, - HowToComputeAggregateMeasure::Summary(SketchAlgorithm::Kll), + HowToComputeAggregateMeasure::Summary(SketchAlgorithm::KLL), per_series, ); } diff --git a/crates/stage1-pass1-per-computation-candidates/src/tests/update_weights.rs b/crates/stage1-pass1-per-computation-candidates/src/tests/update_weights.rs index 8f6ff5f10..a3c3beae1 100644 --- a/crates/stage1-pass1-per-computation-candidates/src/tests/update_weights.rs +++ b/crates/stage1-pass1-per-computation-candidates/src/tests/update_weights.rs @@ -25,7 +25,7 @@ fn update_weights_follow_the_measure() { ); query(&mut memo, counts, None); let memo = pass1_memo(memo, &[]).unwrap(); - let (_, update) = state_group(&memo, SketchAlgorithm::Cms); + let (_, update) = state_group(&memo, SketchAlgorithm::CountMinSketch); assert_eq!(update.weight, SummaryInputExpr::Constant(1.0)); let mut memo = Memo::new(&DataWorkload::default()); let rows = selector(&mut memo, TimeRangeKind::Instant, "m", &["job"]); diff --git a/crates/stage1-pass2-reuse-candidates/src/tests/chains.rs b/crates/stage1-pass2-reuse-candidates/src/tests/chains.rs index 457bf9466..daee7ee8c 100644 --- a/crates/stage1-pass2-reuse-candidates/src/tests/chains.rs +++ b/crates/stage1-pass2-reuse-candidates/src/tests/chains.rs @@ -24,7 +24,7 @@ use asap_types::test_support::memo_fixtures::{range, shift}; #[test] fn a_mergeable_state_reads_a_chain_with_one_build_per_surviving_parameters() { let mut memo = Memo::new(&DataWorkload::default()); - let (_, state, readout) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.9, 300); + let (_, state, readout) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.9, 300); query(&mut memo, readout, None); let logical = pass2(memo, &[entry(120_000)]); let memo = &logical.memo; @@ -32,7 +32,7 @@ fn a_mergeable_state_reads_a_chain_with_one_build_per_surviving_parameters() { let chains = groups_where(memo, |e| { matches!(e, Operator::ASAP(ASAPOp::SummaryTumblingWindowChain { .. })) }); - let listed = parameter_list(SketchAlgorithm::Kll).len(); + let listed = parameter_list(SketchAlgorithm::KLL).len(); assert_eq!(candidates_of(memo, chains[0]).len(), listed); // The builds and one merge per θ. assert_eq!( @@ -101,7 +101,7 @@ fn no_chain_without_a_merge_an_anchor_or_a_grid() { #[test] fn a_chain_whose_width_does_not_divide_the_readers_grid_fails_its_edge() { let mut memo = Memo::new(&DataWorkload::default()); - let (_, state, readout) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.9, 30); + let (_, state, readout) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.9, 30); query(&mut memo, readout, None); query(&mut memo, readout, None); let logical = pass2(memo, &[entry(15_000), entry(10_000)]); diff --git a/crates/stage1-pass2-reuse-candidates/src/tests/dead_candidates.rs b/crates/stage1-pass2-reuse-candidates/src/tests/dead_candidates.rs index 3a24e3c29..fa42a8868 100644 --- a/crates/stage1-pass2-reuse-candidates/src/tests/dead_candidates.rs +++ b/crates/stage1-pass2-reuse-candidates/src/tests/dead_candidates.rs @@ -27,7 +27,7 @@ fn dead_candidates_are_pruned_and_listed_before_chain_groups() { let mut memo = Memo::new(&with_non_negative_values("m")); let input = scan_group(&mut memo, "m", &["job"], vec![]); let window = group(&mut memo, range(300_000, input)); - let algorithms = [SketchAlgorithm::Kll, SketchAlgorithm::DDSketch]; + let algorithms = [SketchAlgorithm::KLL, SketchAlgorithm::DDSketch]; let p99 = quantile_over_time_readouts(&mut memo, window, 0.99, &algorithms); let p50 = quantile_over_time_readouts(&mut memo, window, 0.5, &algorithms); let ratio = group( @@ -51,7 +51,7 @@ fn dead_candidates_are_pruned_and_listed_before_chain_groups() { } // Every KLL build: the metric rule on its edge into a KLL readout, // whose output accepts only relative error. - for index_in_group in 0..parameter_list(SketchAlgorithm::Kll).len() { + for index_in_group in 0..parameter_list(SketchAlgorithm::KLL).len() { let build = CandidateForMemoGroupId { group: kll_state, index_in_group, @@ -104,7 +104,7 @@ fn dead_candidates_are_pruned_and_listed_before_chain_groups() { assert!(groups_where(memo, |e| matches!( e, Operator::ASAP(ASAPOp::SummaryTumblingWindowChain { summary_type, .. }) - if *summary_type == FieldDataType::Sketch(SketchAlgorithm::Kll) + if *summary_type == FieldDataType::Sketch(SketchAlgorithm::KLL) )) .is_empty()); // No logical edge names a pruned candidate. diff --git a/crates/stage1-pass2-reuse-candidates/src/tests/edges.rs b/crates/stage1-pass2-reuse-candidates/src/tests/edges.rs index 2883c676b..81862ade8 100644 --- a/crates/stage1-pass2-reuse-candidates/src/tests/edges.rs +++ b/crates/stage1-pass2-reuse-candidates/src/tests/edges.rs @@ -21,7 +21,7 @@ use asap_types::test_support::memo_fixtures::arithmetic; #[test] fn without_targets_every_edge_is_admissible() { let mut memo = Memo::new(&DataWorkload::default()); - let (_, _, p99) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.99, 300); + let (_, _, p99) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.99, 300); let p50 = estimate( &mut memo, MemoGroupId(2), @@ -84,8 +84,8 @@ fn every_candidate_of_an_input_group_is_an_edge_of_matching_parameters() { #[test] fn a_merge_is_judged_by_the_parameters_it_carries() { let mut memo = Memo::new(&DataWorkload::default()); - let (_, p_state, p_readout) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.9, 300); - let (_, _, q_readout) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.9, 600); + let (_, p_state, p_readout) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.9, 300); + let (_, _, q_readout) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.9, 600); query(&mut memo, p_readout, Some(AccuracyTarget::max_error(0.005))); query(&mut memo, q_readout, Some(AccuracyTarget::max_error(0.01))); let logical = pass2(memo, &[entry(60_000), entry(60_000)]); @@ -214,7 +214,7 @@ fn measured_accuracy_keeps_a_smaller_kll_that_theory_prunes() { let k1404 = SketchParams::Kll { k: 1404 }; let (memo, state, readout) = - p99_with_per_value_target(SketchAlgorithm::Kll, AccuracyMetric::Rank, 0.0025); + p99_with_per_value_target(SketchAlgorithm::KLL, AccuracyMetric::Rank, 0.0025); let theory = pass2(memo, &[entry(60_000)]); assert!( pruned_below_required_accuracy(&theory, build_with(&theory, state, &k547)), @@ -227,7 +227,7 @@ fn measured_accuracy_keeps_a_smaller_kll_that_theory_prunes() { ); let (memo, state, readout) = - p99_with_per_value_target(SketchAlgorithm::Kll, AccuracyMetric::Rank, 0.0025); + p99_with_per_value_target(SketchAlgorithm::KLL, AccuracyMetric::Rank, 0.0025); let measured = measured_p99(k547.clone(), AccuracyMetric::Rank, 0.0024); let with_table = pass2_with_evidence(memo, &[entry(60_000)], &measured); let build_547 = build_with(&with_table, state, &k547); diff --git a/crates/stage1-pass2-reuse-candidates/src/tests/multi_level_windows.rs b/crates/stage1-pass2-reuse-candidates/src/tests/multi_level_windows.rs index 6e04ae4a5..5ebbb1392 100644 --- a/crates/stage1-pass2-reuse-candidates/src/tests/multi_level_windows.rs +++ b/crates/stage1-pass2-reuse-candidates/src/tests/multi_level_windows.rs @@ -56,7 +56,7 @@ fn covers_merged_by(memo: &Memo, state: MemoGroupId) -> BTreeSet> { #[test] fn a_long_range_gets_wider_levels() { let mut memo = Memo::new(&DataWorkload::default()); - let (_, state, readout) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.99, 3_600); + let (_, state, readout) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.99, 3_600); query(&mut memo, readout, None); let logical = pass2(memo, &[entry(15_000)]); let memo = &logical.memo; @@ -104,7 +104,7 @@ fn a_long_range_gets_wider_levels() { #[test] fn a_short_range_gets_no_wider_level() { let mut memo = Memo::new(&DataWorkload::default()); - let (_, state, readout) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.99, 60); + let (_, state, readout) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.99, 60); query(&mut memo, readout, None); let logical = pass2(memo, &[entry(15_000)]); assert_eq!(chain_widths(&logical.memo), BTreeSet::from([15_000])); diff --git a/crates/stage1-pass2-reuse-candidates/src/tests/readout_requirements.rs b/crates/stage1-pass2-reuse-candidates/src/tests/readout_requirements.rs index 625b0eb23..8f69cbea5 100644 --- a/crates/stage1-pass2-reuse-candidates/src/tests/readout_requirements.rs +++ b/crates/stage1-pass2-reuse-candidates/src/tests/readout_requirements.rs @@ -16,7 +16,7 @@ use asap_types::test_support::memo_builders::*; #[test] fn a_single_readout_requires_the_query_target() { let mut memo = Memo::new(&DataWorkload::default()); - let (_, state, readout) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.9, 300); + let (_, state, readout) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.9, 300); query(&mut memo, readout, Some(AccuracyTarget::max_error(0.01))); let logical = pass2(memo, &[entry(60_000)]); assert_eq!( @@ -61,7 +61,7 @@ fn a_single_readout_requires_the_query_target() { #[test] fn a_whole_result_failure_probability_without_values_per_evaluation_prunes_the_readout() { let mut memo = Memo::new(&DataWorkload::default()); - let (_, _, readout) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.9, 300); + let (_, _, readout) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.9, 300); let query = memo.add_query(MemoQuery { root: QueryRoot::Operator(readout), accuracy_target: Some(AccuracyTarget::max_error(0.01).failure_probability(0.01)), @@ -92,7 +92,7 @@ fn a_whole_result_failure_probability_without_values_per_evaluation_prunes_the_r #[test] fn a_readout_another_query_gives_a_level_survives_unknown_values_per_evaluation() { let mut memo = Memo::new(&DataWorkload::default()); - let (window, state, readout) = quantile_over_time(&mut memo, SketchAlgorithm::Kll, 0.9, 300); + let (window, state, readout) = quantile_over_time(&mut memo, SketchAlgorithm::KLL, 0.9, 300); let q0 = memo.add_query(MemoQuery { root: QueryRoot::Operator(readout), accuracy_target: Some(AccuracyTarget::max_error(0.01).failure_probability(0.01)), diff --git a/crates/stage1-pass2-reuse-candidates/src/tests/rollup/filters.rs b/crates/stage1-pass2-reuse-candidates/src/tests/rollup/filters.rs index 099c3da98..bce264f21 100644 --- a/crates/stage1-pass2-reuse-candidates/src/tests/rollup/filters.rs +++ b/crates/stage1-pass2-reuse-candidates/src/tests/rollup/filters.rs @@ -44,13 +44,13 @@ fn a_filtered_coarse_sketch_state_merges_the_finer_states_through_a_compensating let fine = sketch_state( &mut memo, fine_window, - SketchAlgorithm::Kll, + SketchAlgorithm::KLL, Reduction::by(vec![2, 3]), ); let coarse = sketch_state( &mut memo, coarse_window, - SketchAlgorithm::Kll, + SketchAlgorithm::KLL, Reduction::by(vec![3]), ); let groups_before = memo.groups().len(); @@ -117,13 +117,13 @@ fn a_narrowing_on_a_column_that_is_no_key_gives_no_rollup() { let fine = sketch_state( &mut memo, all_window, - SketchAlgorithm::Kll, + SketchAlgorithm::KLL, Reduction::by(vec![2, 3]), ); let coarse = sketch_state( &mut memo, errors_window, - SketchAlgorithm::Kll, + SketchAlgorithm::KLL, Reduction::by(vec![2]), ); for state in [fine, coarse] { @@ -339,7 +339,7 @@ fn a_narrower_group_of_the_same_keys_filters_the_wider_state_and_estimate() { sketch_state( &mut memo, window, - SketchAlgorithm::Kll, + SketchAlgorithm::KLL, Reduction::by(vec![2, 3]), ) }); @@ -479,7 +479,7 @@ fn nested_selections_of_the_same_keys_each_filter_every_wider_one() { let state = sketch_state( &mut memo, window, - SketchAlgorithm::Kll, + SketchAlgorithm::KLL, Reduction::by(vec![2]), ); let readout = estimate(&mut memo, state, SketchStatistic::Quantile { q: 0.99 }); diff --git a/crates/stage1-pass2-reuse-candidates/src/tests/rollup/finest_common_group.rs b/crates/stage1-pass2-reuse-candidates/src/tests/rollup/finest_common_group.rs index c141acc40..c7f8ed74f 100644 --- a/crates/stage1-pass2-reuse-candidates/src/tests/rollup/finest_common_group.rs +++ b/crates/stage1-pass2-reuse-candidates/src/tests/rollup/finest_common_group.rs @@ -40,13 +40,13 @@ fn a_finest_common_group_no_query_asks_for_serves_both() { let by_host = sketch_state( &mut memo, all_window, - SketchAlgorithm::Kll, + SketchAlgorithm::KLL, Reduction::by(vec![3]), ); let by_job = sketch_state( &mut memo, xxx_window, - SketchAlgorithm::Kll, + SketchAlgorithm::KLL, Reduction::by(vec![2]), ); for state in [by_host, by_job] { @@ -58,7 +58,7 @@ fn a_finest_common_group_no_query_asks_for_serves_both() { let finest = group_of( memo, &state_grouped_by( - FieldDataType::Sketch(SketchAlgorithm::Kll), + FieldDataType::Sketch(SketchAlgorithm::KLL), Reduction::by(vec![2, 3]), all_window, ), @@ -69,7 +69,7 @@ fn a_finest_common_group_no_query_asks_for_serves_both() { .iter() .filter(|c| c.expression.operator == memo.groups()[finest.0 as usize].expression) .count(), - parameter_list(SketchAlgorithm::Kll).len() + parameter_list(SketchAlgorithm::KLL).len() ); let merges = |state: MemoGroupId| -> Vec> { candidates_of(memo, state) @@ -78,7 +78,7 @@ fn a_finest_common_group_no_query_asks_for_serves_both() { .map(|c| c.expression.operator.clone()) .collect() }; - let listed = parameter_list(SketchAlgorithm::Kll).len(); + let listed = parameter_list(SketchAlgorithm::KLL).len(); // One merge per θ of G*'s builds. assert_eq!( merges(by_host), diff --git a/crates/stage2-physical-optimization/src/candidate.rs b/crates/stage2-physical-optimization/src/candidate.rs index 128b36281..57ef52d19 100644 --- a/crates/stage2-physical-optimization/src/candidate.rs +++ b/crates/stage2-physical-optimization/src/candidate.rs @@ -275,7 +275,7 @@ pub fn assumed_in_order_arrival( } /// Whether a build of `summary_type` in group `group` is a Count-Min state -/// (`Cms`, `CmsWithHeap`, `HydraCms`) whose weights are not proven +/// (`CountMinSketch`, `CountMinSketchWithHeap`, `HydraCountMinSketch`) whose weights are not proven /// non-negative: the state column of its group, which records the sign of /// the weights it is updated with (`column_signs`), is not `NonNegative`. fn count_min_weights_not_proven_non_negative( @@ -286,7 +286,9 @@ fn count_min_weights_not_proven_non_negative( if !matches!( summary_type, FieldDataType::Sketch( - SketchAlgorithm::Cms | SketchAlgorithm::CmsWithHeap | SketchAlgorithm::HydraCms + SketchAlgorithm::CountMinSketch + | SketchAlgorithm::CountMinSketchWithHeap + | SketchAlgorithm::HydraCountMinSketch ) ) { return false; diff --git a/crates/stage2-physical-optimization/src/test_fixtures.rs b/crates/stage2-physical-optimization/src/test_fixtures.rs index edd9756e0..fb2b7786e 100644 --- a/crates/stage2-physical-optimization/src/test_fixtures.rs +++ b/crates/stage2-physical-optimization/src/test_fixtures.rs @@ -137,25 +137,25 @@ pub fn example_read_by(root: impl FnOnce(MemoGroupId) -> QueryRoot) let last_minute = group(&mut memo, range(60_000, scan)); let build_state = sketch_group( &mut memo, - state(FieldDataType::Sketch(SketchAlgorithm::Kll), last_minute), - SketchAlgorithm::Kll, + state(FieldDataType::Sketch(SketchAlgorithm::KLL), last_minute), + SketchAlgorithm::KLL, 1, ); let chain = sketch_group( &mut memo, Operator::ASAP(ASAPOp::SummaryTumblingWindowChain { child: scan, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KLL), input: SummaryUpdate::column(ColumnRef::SampleValue), reduction: Reduction::PerEntity, filter: None, tumbling_window_width_ms: 60_000, }), - SketchAlgorithm::Kll, + SketchAlgorithm::KLL, 1, ); // The windows and the merge carry the chain build's θ. - let windows = sketch_group(&mut memo, range(60_000, chain), SketchAlgorithm::Kll, 1); + let windows = sketch_group(&mut memo, range(60_000, chain), SketchAlgorithm::KLL, 1); let merge = candidate( &mut memo, build_state, @@ -163,7 +163,7 @@ pub fn example_read_by(root: impl FnOnce(MemoGroupId) -> QueryRoot) children: vec![windows], group_by: None, }), - Some(parameter_list(SketchAlgorithm::Kll)[0].clone()), + Some(parameter_list(SketchAlgorithm::KLL)[0].clone()), ); let readout = group( &mut memo, diff --git a/crates/stage2-physical-optimization/src/tests/candidates.rs b/crates/stage2-physical-optimization/src/tests/candidates.rs index 456f9e8cf..1db538136 100644 --- a/crates/stage2-physical-optimization/src/tests/candidates.rs +++ b/crates/stage2-physical-optimization/src/tests/candidates.rs @@ -206,7 +206,7 @@ fn unsupported_summaries_and_readouts_are_pruned() { let kll_total_only = DeploymentCapabilities { supported_summaries: Some(vec![SupportedSummary { - summary_type: SketchAlgorithm::Kll, + summary_type: SketchAlgorithm::KLL, readouts: vec![StatisticKind::Total], }]), ..retaining_everything() @@ -492,7 +492,7 @@ fn a_count_min_build_needs_weights_proven_non_negative() { &mut memo, Operator::ASAP(ASAPOp::SummaryAgg { child: scan, - summary_type: FieldDataType::Sketch(SketchAlgorithm::CmsWithHeap), + summary_type: FieldDataType::Sketch(SketchAlgorithm::CountMinSketchWithHeap), input: SummaryUpdate { item: Some(SummaryInputExpr::EntityIdentity( EntityIdentity::PromqlLabelSet { excluding: vec![] }, @@ -502,7 +502,7 @@ fn a_count_min_build_needs_weights_proven_non_negative() { reduction: Reduction::Reduce(Default::default()), filter: None, }), - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, 1, ); query(&mut memo, state, None); diff --git a/crates/stage3-plan-selection/src/cost/tests.rs b/crates/stage3-plan-selection/src/cost/tests.rs index 5ad16442f..f6ecf5a33 100644 --- a/crates/stage3-plan-selection/src/cost/tests.rs +++ b/crates/stage3-plan-selection/src/cost/tests.rs @@ -59,8 +59,8 @@ fn kll_group( /// and a retention cost per ms inflated by those rows). #[test] fn no_execution_reading_a_producer_costs_less_than_nothing() { - let kll = ¶meter_list(SketchAlgorithm::Kll)[6]; - let summary_type = FieldDataType::Sketch(SketchAlgorithm::Kll); + let kll = ¶meter_list(SketchAlgorithm::KLL)[6]; + let summary_type = FieldDataType::Sketch(SketchAlgorithm::KLL); let mut memo = Memo::new(&DataWorkload::default()); let scan = scan_group(&mut memo, "m", &[], vec![]); let chain = kll_group( diff --git a/crates/stage3-plan-selection/src/milp/model/tests.rs b/crates/stage3-plan-selection/src/milp/model/tests.rs index 19f411601..4e01de70d 100644 --- a/crates/stage3-plan-selection/src/milp/model/tests.rs +++ b/crates/stage3-plan-selection/src/milp/model/tests.rs @@ -831,7 +831,7 @@ fn a_query_reads_its_exact_only_groups_through_exact_candidates_only() { let mut memo = empty_memo(); let m = scan(&mut memo); let window = range(&mut memo, 300, m); - let quantile = quantile_over_time_readouts(&mut memo, window, 0.9, &[SketchAlgorithm::Kll]); + let quantile = quantile_over_time_readouts(&mut memo, window, 0.9, &[SketchAlgorithm::KLL]); let state = quantile.by_algorithm[0].state; query(&mut memo, quantile.result, None); query(&mut memo, quantile.result, None); @@ -922,7 +922,7 @@ fn queries_differing_in_exact_only_groups_with_a_materialized_answer( let mut memo = empty_memo(); let m = scan(&mut memo); let window = range(&mut memo, 300, m); - let quantile = quantile_over_time_readouts(&mut memo, window, 0.9, &[SketchAlgorithm::Kll]); + let quantile = quantile_over_time_readouts(&mut memo, window, 0.9, &[SketchAlgorithm::KLL]); let state = quantile.by_algorithm[0].state; query(&mut memo, quantile.result, None); query(&mut memo, quantile.result, None); @@ -1046,7 +1046,7 @@ fn the_bound_leaves_out_of_each_query_only_what_it_must_not_read() { let mut memo = empty_memo(); let m = scan(&mut memo); let window = range(&mut memo, 300, m); - let quantile = quantile_over_time_readouts(&mut memo, window, 0.9, &[SketchAlgorithm::Kll]); + let quantile = quantile_over_time_readouts(&mut memo, window, 0.9, &[SketchAlgorithm::KLL]); let state = quantile.by_algorithm[0].state; query(&mut memo, quantile.result, None); query(&mut memo, quantile.result, None); @@ -2275,7 +2275,7 @@ fn k_charges_a_top_k_readout_for_every_estimate_it_ranks() { let (top_k, _) = readouts_of( &mut memo, "m", - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchStatistic::TopK { k: 3 }, AccuracyMetric::Relative, &[(0.01, level)], @@ -2306,7 +2306,7 @@ fn set_operator_over_top_k( let (top_k, _) = readouts_of( &mut memo, "m", - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchStatistic::TopK { k: 3 }, AccuracyMetric::Relative, &[(0.01, top_k_level)], diff --git a/crates/stage3-plan-selection/src/report.rs b/crates/stage3-plan-selection/src/report.rs index a23fc7818..884f618f1 100644 --- a/crates/stage3-plan-selection/src/report.rs +++ b/crates/stage3-plan-selection/src/report.rs @@ -140,12 +140,12 @@ pub struct AcceptedAccuracy { /// accuracy target. pub accepted_metric: Option, /// The sketch algorithms the query's output reads, in plan order - /// (e.g. `["Kll"]`); empty for an exact plan. + /// (e.g. `["KLL"]`); empty for an exact plan. pub sketches: Vec, } impl std::fmt::Display for AcceptedAccuracy { - /// E.g. `accepted rank (Kll)`, `accepted exact`, or `no accuracy + /// E.g. `accepted rank (KLL)`, `accepted exact`, or `no accuracy /// target (DDSketch)`. fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self.accepted_metric { diff --git a/crates/types/src/deployment_capabilities/exclusion.rs b/crates/types/src/deployment_capabilities/exclusion.rs index 69ca77af0..c3a46f643 100644 --- a/crates/types/src/deployment_capabilities/exclusion.rs +++ b/crates/types/src/deployment_capabilities/exclusion.rs @@ -69,7 +69,7 @@ pub struct CandidateExclusion { } /// A statistic read from a sketch algorithm's state, e.g. a quantile from -/// a KLL. JSON: `{"summary_type": "Kll", "statistic": "Quantile"}`. +/// a KLL. JSON: `{"summary_type": "KLL", "statistic": "Quantile"}`. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(deny_unknown_fields)] pub struct SketchReadout { diff --git a/crates/types/src/deployment_capabilities/tests.rs b/crates/types/src/deployment_capabilities/tests.rs index cd8991587..45c4ac312 100644 --- a/crates/types/src/deployment_capabilities/tests.rs +++ b/crates/types/src/deployment_capabilities/tests.rs @@ -115,7 +115,7 @@ fn exact(kind: ExactKind) -> FieldDataType { FieldDataType::exact(kind) } fn kll() -> FieldDataType { - FieldDataType::Sketch(SketchAlgorithm::Kll) + FieldDataType::Sketch(SketchAlgorithm::KLL) } /// `operator` as a candidate at `physical_properties`, with θ `parameters`. @@ -243,7 +243,7 @@ fn summary_family_and_parameter_range_match_state_builds_only() { described(&kll_merge, Some(&k547), qt_one()), ]; let family = CandidateExclusion { - summary_family: Some(SummaryFamily::Sketch(SketchAlgorithm::Kll)), + summary_family: Some(SummaryFamily::Sketch(SketchAlgorithm::KLL)), ..Default::default() }; assert_eq!( @@ -485,14 +485,14 @@ fn counter_semantics_left_out_expand_into_the_functions_and_states_that_need_the fn readout_matches_an_estimate_by_statistic_and_the_state_it_reads() { let kll_total = CandidateExclusion { readout: Some(SketchReadout { - summary_type: SketchAlgorithm::Kll, + summary_type: SketchAlgorithm::KLL, statistic: StatisticKind::Total, }), ..Default::default() }; let total_readout = estimate(total()); let quantile_readout = estimate(SketchStatistic::Quantile { q: 0.99 }); - let cms = FieldDataType::Sketch(SketchAlgorithm::Cms); + let cms = FieldDataType::Sketch(SketchAlgorithm::CountMinSketch); let reading = |operator, state| CandidateDescription { read_summary_type: state, ..described(operator, None, qt_none()) @@ -612,7 +612,7 @@ fn each_capability_left_out_expands_into_its_exclusions() { fn supported_summaries_expand_into_family_and_readout_exclusions() { let capabilities = DeploymentCapabilities { supported_summaries: Some(vec![SupportedSummary { - summary_type: SketchAlgorithm::Kll, + summary_type: SketchAlgorithm::KLL, readouts: vec![StatisticKind::Quantile], }]), query_time_results_retained: true, @@ -630,7 +630,7 @@ fn supported_summaries_expand_into_family_and_readout_exclusions() { source: ExclusionSource::ReadoutNotSupported, exclusion: CandidateExclusion { readout: Some(SketchReadout { - summary_type: SketchAlgorithm::Kll, + summary_type: SketchAlgorithm::KLL, statistic, }), ..Default::default() @@ -638,7 +638,7 @@ fn supported_summaries_expand_into_family_and_readout_exclusions() { }; let unlisted: Vec<_> = SketchAlgorithm::ALL .iter() - .filter(|&&algorithm| algorithm != SketchAlgorithm::Kll) + .filter(|&&algorithm| algorithm != SketchAlgorithm::KLL) .map(|&algorithm| family(algorithm)) .collect(); let unsupported_readouts: Vec<_> = SummaryTypeCapability::of(&kll()) @@ -651,7 +651,7 @@ fn supported_summaries_expand_into_family_and_readout_exclusions() { for expected in unlisted.iter().chain(&unsupported_readouts) { assert!(exclusions.contains(expected), "missing {expected:?}"); } - assert!(!exclusions.contains(&family(SketchAlgorithm::Kll))); + assert!(!exclusions.contains(&family(SketchAlgorithm::KLL))); assert!(!exclusions.contains(&readout(StatisticKind::Quantile))); assert_eq!( exclusions.len(), @@ -745,7 +745,7 @@ fn invalid_excluded_candidates_are_rejected() { fn self_contradicting_exclusions_are_rejected() { let data = crate::workload::DataWorkload::default(); let kll_readout = SketchReadout { - summary_type: SketchAlgorithm::Kll, + summary_type: SketchAlgorithm::KLL, statistic: StatisticKind::Quantile, }; let with_operator = |operator, exclusion: CandidateExclusion| CandidateExclusion { @@ -835,7 +835,7 @@ fn self_contradicting_exclusions_are_rejected() { /// does not list; any further field narrows it. #[test] fn a_family_is_excluded_outright_only_by_a_family_only_exclusion() { - let kll = SummaryFamily::Sketch(SketchAlgorithm::Kll); + let kll = SummaryFamily::Sketch(SketchAlgorithm::KLL); let family_only = CandidateExclusion { summary_family: Some(kll), ..Default::default() @@ -878,10 +878,10 @@ fn excluded_candidates_json_loads_field_by_field() { {"operator": "Aggregate", "per_entity_reduction": true}, {"timing": "query_time", "operator": "SummaryAgg"}, {"timing": "query_time", "operator": "SummaryTumblingWindowChain"}, - {"summary_family": {"sketch": "Kll"}, "sketch_parameter_range": {"kll_k": {"at_most": 1403}}}, + {"summary_family": {"sketch": "KLL"}, "sketch_parameter_range": {"kll_k": {"at_most": 1403}}}, {"timing": "query_time", "aggregate_measure": "rate"}, {"summary_family": {"exact": "Counter"}, "operator": "SummaryTumblingWindowChain"}, - {"readout": {"summary_type": "Kll", "statistic": "Total"}}, + {"readout": {"summary_type": "KLL", "statistic": "Total"}}, {"operator": "Scan", "kept_across_evaluations": true}]}"#; let loaded: DeploymentCapabilities = serde_json::from_str(json).unwrap(); let exclusion = |exclusion: CandidateExclusion| exclusion; @@ -909,7 +909,7 @@ fn excluded_candidates_json_loads_field_by_field() { ..Default::default() }), exclusion(CandidateExclusion { - summary_family: Some(SummaryFamily::Sketch(SketchAlgorithm::Kll)), + summary_family: Some(SummaryFamily::Sketch(SketchAlgorithm::KLL)), sketch_parameter_range: Some(SketchParameterRange::KllK { at_least: None, at_most: Some(1403), @@ -928,7 +928,7 @@ fn excluded_candidates_json_loads_field_by_field() { }), exclusion(CandidateExclusion { readout: Some(SketchReadout { - summary_type: SketchAlgorithm::Kll, + summary_type: SketchAlgorithm::KLL, statistic: StatisticKind::Total, }), ..Default::default() @@ -993,13 +993,13 @@ fn default_capabilities_and_json_fill_the_rest() { assert!(default.raw_data_retained && !default.query_time_results_retained); assert_eq!(default.supported_summaries, None); let parsed: DeploymentCapabilities = serde_json::from_str( - r#"{"supported_summaries": [{"summary_type": "Kll", "readouts": ["Quantile"]}]}"#, + r#"{"supported_summaries": [{"summary_type": "KLL", "readouts": ["Quantile"]}]}"#, ) .unwrap(); assert_eq!( parsed.supported_summaries, Some(vec![SupportedSummary { - summary_type: SketchAlgorithm::Kll, + summary_type: SketchAlgorithm::KLL, readouts: vec![StatisticKind::Quantile], }]) ); diff --git a/crates/types/src/ir/operator/node.rs b/crates/types/src/ir/operator/node.rs index 3d634fb59..ab7aa7790 100644 --- a/crates/types/src/ir/operator/node.rs +++ b/crates/types/src/ir/operator/node.rs @@ -617,7 +617,7 @@ mod tests { fn summary_agg() -> Operator { Operator::ASAP(ASAPOp::SummaryAgg { child: 0, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KLL), input: SummaryUpdate::column(ColumnRef::SampleValue), reduction: Reduction::PerEntity, filter: None, @@ -627,7 +627,7 @@ mod tests { fn chain_one_minute() -> Operator { Operator::ASAP(ASAPOp::SummaryTumblingWindowChain { child: 0, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KLL), input: SummaryUpdate::column(ColumnRef::SampleValue), reduction: Reduction::PerEntity, filter: None, diff --git a/crates/types/src/ir/schema/mod.rs b/crates/types/src/ir/schema/mod.rs index 2f35c5522..a2f6e805e 100644 --- a/crates/types/src/ir/schema/mod.rs +++ b/crates/types/src/ir/schema/mod.rs @@ -119,8 +119,8 @@ impl From> for Field { /// /// Every non-`Plain` variant is a summary type: its family (the variant) and /// its algorithm, so the type system can reject merges of incompatible -/// summaries at plan construction time — a `SummaryMerge` over `Sketch(Kll)` -/// and `Sketch(Cms)` inputs is a plan-time error, and a `Sketch(…)` can never +/// summaries at plan construction time — a `SummaryMerge` over `Sketch(KLL)` +/// and `Sketch(CountMinSketch)` inputs is a plan-time error, and a `Sketch(…)` can never /// be confused for a `SummarySample(…)` even though both are "opaque summary /// state" at a glance. /// @@ -289,7 +289,7 @@ pub fn is_label_set_column(field: &Field) -> bool { impl Schema { /// The type of the summary state this schema carries: its first field - /// that is not a plain value, e.g. `Sketch(Kll)` for a KLL state keyed + /// that is not a plain value, e.g. `Sketch(KLL)` for a KLL state keyed /// by series; `None` for rows of plain values. pub fn summary_state_type(&self) -> Option<&FieldDataType> { self.fields diff --git a/crates/types/src/plan/time_window.rs b/crates/types/src/plan/time_window.rs index e78949a8a..dffef1d42 100644 --- a/crates/types/src/plan/time_window.rs +++ b/crates/types/src/plan/time_window.rs @@ -510,7 +510,7 @@ mod tests { let chain = || { Operator::ASAP(ASAPOp::SummaryTumblingWindowChain { child: 0, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KLL), input: SummaryUpdate::column(ColumnRef::SampleValue), reduction: Reduction::PerEntity, filter: None, diff --git a/crates/types/src/stages/logical/candidate/tests.rs b/crates/types/src/stages/logical/candidate/tests.rs index 828f85a8d..54fd6c668 100644 --- a/crates/types/src/stages/logical/candidate/tests.rs +++ b/crates/types/src/stages/logical/candidate/tests.rs @@ -9,7 +9,7 @@ use crate::test_support::memo_fixtures::state; /// and of a chain, and of no other operator. #[test] fn summary_type_of_operator_reads_the_builds_summary_type() { - let kll = FieldDataType::Sketch(SketchAlgorithm::Kll); + let kll = FieldDataType::Sketch(SketchAlgorithm::KLL); let chain = Operator::ASAP(ASAPOp::SummaryTumblingWindowChain { child: MemoGroupId(0), summary_type: kll.clone(), @@ -34,7 +34,7 @@ fn summary_type_of_operator_reads_the_builds_summary_type() { /// without θ. #[test] fn listed_build_parameters_lists_a_sketch_builds_parameters() { - let kll = SketchAlgorithm::Kll; + let kll = SketchAlgorithm::KLL; assert_eq!( listed_build_parameters(&state(FieldDataType::Sketch(kll), MemoGroupId(0))), parameter_list(kll) diff --git a/crates/types/src/stages/logical/memo/hash_consing/tests.rs b/crates/types/src/stages/logical/memo/hash_consing/tests.rs index 5f03ab8ae..906f12509 100644 --- a/crates/types/src/stages/logical/memo/hash_consing/tests.rs +++ b/crates/types/src/stages/logical/memo/hash_consing/tests.rs @@ -33,7 +33,7 @@ fn find_or_add_group_returns_the_group_of_an_equal_expression() { .find_or_add_group(scan("latency", &[], vec![])) .unwrap(); let g2 = memo - .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1)) + .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1)) .unwrap(); assert_eq!( memo.find_or_add_group(scan("latency", &[], vec![])) @@ -41,7 +41,7 @@ fn find_or_add_group_returns_the_group_of_an_equal_expression() { g1 ); assert_eq!( - memo.find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1)) + memo.find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1)) .unwrap(), g2 ); @@ -65,9 +65,9 @@ fn find_or_add_group_separates_equal_operators_over_different_inputs() { .unwrap(); let errors = memo.find_or_add_group(scan("errors", &[], vec![])).unwrap(); assert_ne!( - memo.find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Kll), latency)) + memo.find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::KLL), latency)) .unwrap(), - memo.find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Kll), errors)) + memo.find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::KLL), errors)) .unwrap() ); } @@ -95,22 +95,22 @@ fn kll_builds_with_k_269_and_k_547_share_one_group() { .find_or_add_group(scan("latency", &[], vec![])) .unwrap(); let k269_group = memo - .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1)) + .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1)) .unwrap(); let k269 = try_candidate( &mut memo, k269_group, - state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1), + state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1), kll_k(269), ) .unwrap(); let k547_group = memo - .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1)) + .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1)) .unwrap(); let k547 = try_candidate( &mut memo, k547_group, - state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1), + state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1), kll_k(547), ) .unwrap(); @@ -132,19 +132,19 @@ fn add_candidate_returns_the_existing_candidate_for_a_duplicate() { .find_or_add_group(scan("latency", &[], vec![])) .unwrap(); let g2 = memo - .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1)) + .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1)) .unwrap(); let first = try_candidate( &mut memo, g2, - state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1), + state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1), kll_k(269), ) .unwrap(); let again = try_candidate( &mut memo, g2, - state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1), + state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1), kll_k(269), ) .unwrap(); @@ -159,7 +159,7 @@ fn add_candidate_returns_the_existing_candidate_for_a_duplicate() { let other_size = try_candidate( &mut memo, g2, - state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1), + state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1), kll_k(547), ); assert_ne!(other_size.unwrap(), first); diff --git a/crates/types/src/stages/logical/memo/tests.rs b/crates/types/src/stages/logical/memo/tests.rs index 9a11d59d2..287275140 100644 --- a/crates/types/src/stages/logical/memo/tests.rs +++ b/crates/types/src/stages/logical/memo/tests.rs @@ -37,9 +37,9 @@ fn find_or_add_group_lists_the_new_group_among_its_inputs_parents() { .find_or_add_group(scan("latency", &[], vec![])) .unwrap(); let g2 = memo - .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1)) + .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1)) .unwrap(); - memo.find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1)) + memo.find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1)) .unwrap(); assert_eq!(memo.groups()[g1.0 as usize].parent_groups(), &[g2]); assert!(memo.groups()[g2.0 as usize].parent_groups().is_empty()); @@ -55,7 +55,7 @@ fn add_candidate_maintains_parents_and_queries() { .find_or_add_group(scan("latency", &[], vec![])) .unwrap(); let g2 = memo - .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1)) + .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1)) .unwrap(); let g3 = memo .find_or_add_group(readout(SketchStatistic::Quantile { q: 0.95 }, g2)) @@ -67,7 +67,7 @@ fn add_candidate_maintains_parents_and_queries() { .find_or_add_group(scan("latency_copy", &[], vec![])) .unwrap(); let g5 = memo - .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Kll), g4)) + .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::KLL), g4)) .unwrap(); assert!(memo.groups()[g5.0 as usize].reached_by_queries().is_empty()); // G3 gains a candidate reading G5: G5 and G4 now serve query 0. @@ -105,7 +105,7 @@ fn add_candidate_rejects_a_candidate_whose_output_differs_from_its_group() { .find_or_add_group(scan("latency", &[], vec![])) .unwrap(); let g2 = memo - .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1)) + .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1)) .unwrap(); let before = format!("{memo:?}"); assert!(matches!( @@ -128,7 +128,7 @@ fn add_candidate_rejects_a_candidate_whose_inputs_fail_validation() { .find_or_add_group(scan("latency", &[], vec![])) .unwrap(); let g2 = memo - .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1)) + .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1)) .unwrap(); let g3 = memo .find_or_add_group(readout(SketchStatistic::Quantile { q: 0.95 }, g2)) @@ -191,7 +191,7 @@ fn output_schema_of_a_pending_expression_is_its_groups_schema() { let latency = memo .find_or_add_group(scan("latency", &[], vec![])) .unwrap(); - let state_expression = state(FieldDataType::Sketch(SketchAlgorithm::Kll), latency); + let state_expression = state(FieldDataType::Sketch(SketchAlgorithm::KLL), latency); let pending_state = MemoGroupId(memo.groups().len() as u32); let readout_expression = readout(SketchStatistic::Quantile { q: 0.99 }, pending_state); let before = format!("{memo:?}"); @@ -248,7 +248,7 @@ fn set_candidate_input_requirements_replaces_only_the_named_candidate() { .find_or_add_group(scan("latency", &[], vec![])) .unwrap(); let g2 = memo - .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1)) + .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1)) .unwrap(); let p90 = || readout(SketchStatistic::Quantile { q: 0.9 }, g2); let g3 = memo.find_or_add_group(p90()).unwrap(); @@ -274,7 +274,7 @@ fn a_merge_carries_the_parameters_of_the_states_it_reads() { let g1 = memo .find_or_add_group(scan("latency", &[], vec![])) .unwrap(); - let kll_state = || state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1); + let kll_state = || state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1); let g2 = memo.find_or_add_group(kll_state()).unwrap(); for k in [269, 547] { try_candidate(&mut memo, g2, kll_state(), kll_k(k)).unwrap(); @@ -308,7 +308,7 @@ fn set_candidate_input_requirements_panics_on_a_length_mismatch() { let g1 = memo .find_or_add_group(scan("latency", &[], vec![])) .unwrap(); - let kll_state = || state(FieldDataType::Sketch(SketchAlgorithm::Kll), g1); + let kll_state = || state(FieldDataType::Sketch(SketchAlgorithm::KLL), g1); let g2 = memo.find_or_add_group(kll_state()).unwrap(); let build = try_candidate(&mut memo, g2, kll_state(), kll_k(269)).unwrap(); memo.set_candidate_input_requirements(build, Vec::new()); @@ -329,7 +329,7 @@ fn add_candidate_checks_parameters_against_the_groups_output() { let g1 = memo .find_or_add_group(scan("latency", &[], vec![])) .unwrap(); - let kll = FieldDataType::Sketch(SketchAlgorithm::Kll); + let kll = FieldDataType::Sketch(SketchAlgorithm::KLL); let kll_state = memo.find_or_add_group(state(kll.clone(), g1)).unwrap(); let kll_chain = Operator::ASAP(ASAPOp::SummaryTumblingWindowChain { child: g1, @@ -381,7 +381,10 @@ fn add_candidate_checks_parameters_against_the_groups_output() { let table = [ (state(kll, g1), kll_state_output), ( - state(FieldDataType::Sketch(SketchAlgorithm::HydraCms), g1), + state( + FieldDataType::Sketch(SketchAlgorithm::HydraCountMinSketch), + g1, + ), [ needs_parameters, not_in_list, @@ -452,7 +455,7 @@ fn max_values_per_evaluation_bounds_a_readout_by_its_states_keys() { ] { let state = memo .find_or_add_group(state_grouped_by( - FieldDataType::Sketch(SketchAlgorithm::Kll), + FieldDataType::Sketch(SketchAlgorithm::KLL), reduction, input, )) @@ -518,7 +521,7 @@ fn max_estimates_per_evaluation_counts_every_item_a_top_k_ranks() { )) .unwrap() }; - let heap = state_of(&mut memo, SketchAlgorithm::CmsWithHeap); + let heap = state_of(&mut memo, SketchAlgorithm::CountMinSketchWithHeap); let top_k = memo .find_or_add_group(readout(SketchStatistic::TopK { k: 5 }, heap)) .unwrap(); @@ -527,7 +530,7 @@ fn max_estimates_per_evaluation_counts_every_item_a_top_k_ranks() { Some(estimates), "{max_distinct:?} {reduction_is_by_job}" ); - let kll = state_of(&mut memo, SketchAlgorithm::Kll); + let kll = state_of(&mut memo, SketchAlgorithm::KLL); let quantile = memo .find_or_add_group(readout(SketchStatistic::Quantile { q: 0.9 }, kll)) .unwrap(); @@ -561,7 +564,7 @@ fn max_distinct_per_evaluation_sums_the_scanned_sources_bounds() { let mut scan_of = |source: &str| memo.find_or_add_group(scan(source, &[], vec![])).unwrap(); let (events, clicks, logs) = (scan_of("events"), scan_of("clicks"), scan_of("logs")); let state = memo - .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::Hll), events)) + .find_or_add_group(state(FieldDataType::Sketch(SketchAlgorithm::HLL), events)) .unwrap(); assert_eq!(memo.max_distinct_per_evaluation(events), Some(9_636)); assert_eq!(memo.max_distinct_per_evaluation(state), Some(9_636)); @@ -637,7 +640,7 @@ fn max_values_per_evaluation_is_unbounded_for_a_computed_or_time_key() { ] { let state = memo .find_or_add_group(state_grouped_by( - FieldDataType::Sketch(SketchAlgorithm::Kll), + FieldDataType::Sketch(SketchAlgorithm::KLL), Reduction::by(keys.clone()), bucketed, )) @@ -707,7 +710,7 @@ fn max_values_per_evaluation_multiplies_the_keys_of_different_scans() { for (keys, values) in [(vec![2, 5], 400), (vec![2], 20)] { let state = memo .find_or_add_group(state_grouped_by( - FieldDataType::Sketch(SketchAlgorithm::Kll), + FieldDataType::Sketch(SketchAlgorithm::KLL), Reduction::by(keys.clone()), joined, )) diff --git a/crates/types/src/stages/physical/memo_candidates/tests.rs b/crates/types/src/stages/physical/memo_candidates/tests.rs index 1af97abe8..4331d2986 100644 --- a/crates/types/src/stages/physical/memo_candidates/tests.rs +++ b/crates/types/src/stages/physical/memo_candidates/tests.rs @@ -79,7 +79,7 @@ fn memo() -> Memo { ), })) .unwrap(); - let kll = FieldDataType::Sketch(SketchAlgorithm::Kll); + let kll = FieldDataType::Sketch(SketchAlgorithm::KLL); let build = Operator::ASAP(ASAPOp::SummaryAgg { child: scan, summary_type: kll.clone(), @@ -762,7 +762,7 @@ fn a_stored_chain_and_an_ingestion_time_result_are_stored_on_their_refresh_windo let chain = add( Operator::ASAP(ASAPOp::SummaryTumblingWindowChain { child: shifted.group, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KLL), input: SummaryUpdate::column(ColumnRef::SampleValue), reduction: Reduction::PerEntity, filter: None, diff --git a/crates/types/src/stages/pruning.rs b/crates/types/src/stages/pruning.rs index 91847e42b..d02479a5a 100644 --- a/crates/types/src/stages/pruning.rs +++ b/crates/types/src/stages/pruning.rs @@ -129,7 +129,7 @@ pub enum PruneReason { /// Stage 2: no query output can read it, directly or through other /// candidates, once each candidate's allowed consumers are applied. ReachesNoQueryOutput, - /// Stage 2: a Count-Min build (`Cms`, `CmsWithHeap`, `HydraCms`) whose + /// Stage 2: a Count-Min build (`CountMinSketch`, `CountMinSketchWithHeap`, `HydraCountMinSketch`) whose /// weight column's `column_signs` is not `NonNegative`: its estimates are /// bounds only for non-negative weights. CountMinWeightsNotProvenNonNegative, diff --git a/crates/types/src/summary_type/capability.rs b/crates/types/src/summary_type/capability.rs index dadf90923..6fed20978 100644 --- a/crates/types/src/summary_type/capability.rs +++ b/crates/types/src/summary_type/capability.rs @@ -138,22 +138,22 @@ impl SummaryTypeCapability { | A::UnivMonQ | A::UnivMonTwoTier | A::HydraUnivMon => true, - A::Cms - | A::CmsWithHeap - | A::CmsWithSpaceSaving - | A::CmsFold - | A::HydraCms - | A::Hll - | A::HllHip - | A::Kmv - | A::Kll - | A::KllDynamic - | A::HydraKll - | A::HydraHll + A::CountMinSketch + | A::CountMinSketchWithHeap + | A::CountMinSketchWithSpaceSaving + | A::CountMinSketchFold + | A::HydraCountMinSketch + | A::HLL + | A::HLLHip + | A::KMV + | A::KLL + | A::KLLDynamic + | A::HydraKLL + | A::HydraHLL | A::DDSketch | A::SpaceSaving - | A::Elastic - | A::Coco + | A::ElasticSketch + | A::CocoSketch | A::Bloom | A::SetAggregator => false, } @@ -166,7 +166,11 @@ impl SummaryTypeCapability { matches!( summary_type, FieldDataType::Sketch( - A::HydraCms | A::HydraCountSketch | A::HydraKll | A::HydraHll | A::HydraUnivMon + A::HydraCountMinSketch + | A::HydraCountSketch + | A::HydraKLL + | A::HydraHLL + | A::HydraUnivMon ) ) } @@ -209,7 +213,7 @@ impl SummaryTypeCapability { // tumbling window does not keep across its boundary. E::IRate => (None, &[]), }, - // A sketch algorithm's row is sketchlib's. HydraKll merges as + // A sketch algorithm's row is sketchlib's. HydraKLL merges as // that row says: `Hydra::merge` requires the same k and m and // otherwise returns an error (asap_sketchlib). FieldDataType::Sketch(algorithm) => { @@ -314,11 +318,11 @@ mod tests { /// HLL answers the distinct count, not its total. #[test] fn summary_capability_facts() { - let kll = FieldDataType::Sketch(SketchAlgorithm::Kll); + let kll = FieldDataType::Sketch(SketchAlgorithm::KLL); let ddsketch = FieldDataType::Sketch(SketchAlgorithm::DDSketch); let count_sketch = FieldDataType::Sketch(SketchAlgorithm::CountSketch); - let cms_heap = FieldDataType::Sketch(SketchAlgorithm::CmsWithHeap); - let hll = FieldDataType::Sketch(SketchAlgorithm::Hll); + let cms_heap = FieldDataType::Sketch(SketchAlgorithm::CountMinSketchWithHeap); + let hll = FieldDataType::Sketch(SketchAlgorithm::HLL); for (summary_type, yes, no) in [ ( &kll, @@ -375,7 +379,7 @@ mod tests { /// per group: not counters, IRate or a Hydra. #[test] fn only_per_group_mergeable_families_merge_groups() { - let kll = FieldDataType::Sketch(SketchAlgorithm::Kll); + let kll = FieldDataType::Sketch(SketchAlgorithm::KLL); assert!(SummaryTypeCapability::merges_groups(&kll)); assert!(SummaryTypeCapability::merges_groups( &FieldDataType::ExactAggregate(ExactKind::Sum, ExactParams::Sum) @@ -388,7 +392,7 @@ mod tests { &FieldDataType::ExactAggregate(kind, params) )); } - let hydra = FieldDataType::Sketch(SketchAlgorithm::HydraCms); + let hydra = FieldDataType::Sketch(SketchAlgorithm::HydraCountMinSketch); assert_eq!( SummaryTypeCapability::of(&hydra).merge_inputs, Some(MergeInputRule::Disjoint) diff --git a/crates/types/src/summary_type/family.rs b/crates/types/src/summary_type/family.rs index 2b7a7f76d..8a24ab916 100644 --- a/crates/types/src/summary_type/family.rs +++ b/crates/types/src/summary_type/family.rs @@ -7,7 +7,7 @@ use super::{ExactKind, SketchAlgorithm}; use crate::ir::schema::FieldDataType; /// The family of a summary state without its parameters: a sketch -/// algorithm or an exact accumulator kind. JSON: `{"sketch": "Kll"}`, +/// algorithm or an exact accumulator kind. JSON: `{"sketch": "KLL"}`, /// `{"exact": "Sum"}`. #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)] #[serde(rename_all = "snake_case")] @@ -17,7 +17,7 @@ pub enum SummaryFamily { } impl SummaryFamily { - /// `Sketch(Kll)` for `FieldDataType::Sketch(Kll)`, `Exact(Sum)` for + /// `Sketch(KLL)` for `FieldDataType::Sketch(KLL)`, `Exact(Sum)` for /// `ExactAggregate(Sum, _)`, `None` for any other field type. pub fn of(summary_type: &FieldDataType) -> Option { match summary_type { @@ -39,8 +39,8 @@ mod tests { #[test] fn summary_family_of_a_field_type() { assert_eq!( - SummaryFamily::of(&FieldDataType::Sketch(SketchAlgorithm::Kll)), - Some(SummaryFamily::Sketch(SketchAlgorithm::Kll)) + SummaryFamily::of(&FieldDataType::Sketch(SketchAlgorithm::KLL)), + Some(SummaryFamily::Sketch(SketchAlgorithm::KLL)) ); assert_eq!( SummaryFamily::of(&FieldDataType::ExactAggregate( diff --git a/crates/types/src/summary_type/parameter_lists/mod.rs b/crates/types/src/summary_type/parameter_lists/mod.rs index d1ecd65e4..9d4510d75 100644 --- a/crates/types/src/summary_type/parameter_lists/mod.rs +++ b/crates/types/src/summary_type/parameter_lists/mod.rs @@ -24,35 +24,35 @@ use super::{SketchAlgorithm, SketchParams}; /// valid candidate. pub fn parameter_list(algorithm: SketchAlgorithm) -> &'static [SketchParams] { match algorithm { - SketchAlgorithm::Kll => &KLL_PARAMETERS, + SketchAlgorithm::KLL => &KLL_PARAMETERS, SketchAlgorithm::DDSketch => &DDSKETCH_PARAMETERS, - SketchAlgorithm::Hll => &HLL_PARAMETERS, - SketchAlgorithm::Kmv => &KMV_PARAMETERS, - SketchAlgorithm::Cms => &CMS_PARAMETERS, + SketchAlgorithm::HLL => &HLL_PARAMETERS, + SketchAlgorithm::KMV => &KMV_PARAMETERS, + SketchAlgorithm::CountMinSketch => &CMS_PARAMETERS, SketchAlgorithm::CountSketch => &COUNT_SKETCH_PARAMETERS, - SketchAlgorithm::CmsWithHeap => &CMS_WITH_HEAP_PARAMETERS, + SketchAlgorithm::CountMinSketchWithHeap => &CMS_WITH_HEAP_PARAMETERS, SketchAlgorithm::CountSketchWithHeap => &COUNT_SKETCH_WITH_HEAP_PARAMETERS, SketchAlgorithm::UnivMon => &UNIVMON_PARAMETERS, // Listed, not `_`: an algorithm `asap_sketchlib` adds fails to // compile here until it gets a list or is listed without one. SketchAlgorithm::CountSketchWithL2Norm - | SketchAlgorithm::CmsWithSpaceSaving + | SketchAlgorithm::CountMinSketchWithSpaceSaving | SketchAlgorithm::CountSketchWithSpaceSaving - | SketchAlgorithm::CmsFold + | SketchAlgorithm::CountMinSketchFold | SketchAlgorithm::CountSketchFold - | SketchAlgorithm::HllHip - | SketchAlgorithm::KllDynamic + | SketchAlgorithm::HLLHip + | SketchAlgorithm::KLLDynamic | SketchAlgorithm::SpaceSaving - | SketchAlgorithm::Elastic - | SketchAlgorithm::Coco + | SketchAlgorithm::ElasticSketch + | SketchAlgorithm::CocoSketch | SketchAlgorithm::Bloom | SketchAlgorithm::SetAggregator | SketchAlgorithm::UnivMonTwoTier | SketchAlgorithm::UnivMonQ - | SketchAlgorithm::HydraCms + | SketchAlgorithm::HydraCountMinSketch | SketchAlgorithm::HydraCountSketch - | SketchAlgorithm::HydraKll - | SketchAlgorithm::HydraHll + | SketchAlgorithm::HydraKLL + | SketchAlgorithm::HydraHLL | SketchAlgorithm::HydraUnivMon => &[], } } diff --git a/crates/types/src/summary_type/parameter_lists/tests.rs b/crates/types/src/summary_type/parameter_lists/tests.rs index 39c1f4513..2321052a2 100644 --- a/crates/types/src/summary_type/parameter_lists/tests.rs +++ b/crates/types/src/summary_type/parameter_lists/tests.rs @@ -9,21 +9,21 @@ use super::*; #[test] fn parameter_list_holds_its_algorithm_without_repeats() { let listed = [ - SketchAlgorithm::Kll, + SketchAlgorithm::KLL, SketchAlgorithm::DDSketch, - SketchAlgorithm::Hll, - SketchAlgorithm::Kmv, - SketchAlgorithm::Cms, + SketchAlgorithm::HLL, + SketchAlgorithm::KMV, + SketchAlgorithm::CountMinSketch, SketchAlgorithm::CountSketch, - SketchAlgorithm::CmsWithHeap, + SketchAlgorithm::CountMinSketchWithHeap, SketchAlgorithm::CountSketchWithHeap, SketchAlgorithm::UnivMon, ]; for algorithm in listed.iter().copied().chain([ - SketchAlgorithm::HydraCms, + SketchAlgorithm::HydraCountMinSketch, SketchAlgorithm::HydraCountSketch, - SketchAlgorithm::HydraKll, - SketchAlgorithm::HllHip, + SketchAlgorithm::HydraKLL, + SketchAlgorithm::HLLHip, ]) { let list = parameter_list(algorithm); assert_eq!( @@ -52,10 +52,16 @@ fn parameter_list_holds_its_algorithm_without_repeats() { }) .collect() }; - assert_eq!(depths(SketchAlgorithm::Cms), [5, 7, 10, 12]); + assert_eq!(depths(SketchAlgorithm::CountMinSketch), [5, 7, 10, 12]); assert_eq!(depths(SketchAlgorithm::CountSketch), [47, 81, 117, 155]); - assert_eq!(depths(SketchAlgorithm::CmsWithHeap), [5, 5, 5, 5]); - assert_eq!(parameter_list(SketchAlgorithm::Cms).len(), 28); - assert_eq!(parameter_list(SketchAlgorithm::CmsWithHeap).len(), 280); + assert_eq!( + depths(SketchAlgorithm::CountMinSketchWithHeap), + [5, 5, 5, 5] + ); + assert_eq!(parameter_list(SketchAlgorithm::CountMinSketch).len(), 28); + assert_eq!( + parameter_list(SketchAlgorithm::CountMinSketchWithHeap).len(), + 280 + ); assert_eq!(parameter_list(SketchAlgorithm::UnivMon).len(), 40); } diff --git a/crates/types/src/summary_type/parameters.rs b/crates/types/src/summary_type/parameters.rs index b25c63bf0..d2ec6ada3 100644 --- a/crates/types/src/summary_type/parameters.rs +++ b/crates/types/src/summary_type/parameters.rs @@ -265,14 +265,14 @@ pub enum StatModelParams { }, } -/// θ of the `Hydra*` algorithms ([`SketchAlgorithm::HydraKll`](crate::summary_type::SketchAlgorithm::HydraKll), -/// [`SketchAlgorithm::HydraCms`](crate::summary_type::SketchAlgorithm::HydraCms), [`SketchAlgorithm::HydraCountSketch`](crate::summary_type::SketchAlgorithm::HydraCountSketch)): one +/// θ of the `Hydra*` algorithms ([`SketchAlgorithm::HydraKLL`](crate::summary_type::SketchAlgorithm::HydraKLL), +/// [`SketchAlgorithm::HydraCountMinSketch`](crate::summary_type::SketchAlgorithm::HydraCountMinSketch), [`SketchAlgorithm::HydraCountSketch`](crate::summary_type::SketchAlgorithm::HydraCountSketch)): one /// structure shared by every subpopulation of a grouped aggregate (Manousis /// et al., "Enabling Efficient and General Subpopulation Analytics in /// Multidimensional Data Streams", VLDB 2022). It holds both the -/// per-subpopulation sketch's sizes and the shared grid's. HydraCms and +/// per-subpopulation sketch's sizes and the shared grid's. HydraCountMinSketch and /// HydraCountSketch are the paper's proven construction (§4.5, Theorem 2); -/// HydraKll is not (the paper excludes quantiles, §4.3), so no error model +/// HydraKLL is not (the paper excludes quantiles, §4.3), so no error model /// covers it. #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub enum HydraParams { @@ -364,20 +364,20 @@ pub enum SketchParameterRange { } impl SketchParameterRange { - /// The algorithm whose parameter it ranges over (`Kll`, `Kmv`, + /// The algorithm whose parameter it ranges over (`KLL`, `KMV`, /// `DDSketch`). pub fn algorithm(&self) -> super::SketchAlgorithm { use super::SketchAlgorithm; match self { - Self::KllK { .. } => SketchAlgorithm::Kll, - Self::KmvK { .. } => SketchAlgorithm::Kmv, + Self::KllK { .. } => SketchAlgorithm::KLL, + Self::KmvK { .. } => SketchAlgorithm::KMV, Self::DDSketchAlpha { .. } => SketchAlgorithm::DDSketch, } } /// Whether `parameters` are that algorithm's and the parameter is in /// range, both ends included: `KllK { at_most: Some(547) }` contains - /// `Kll { k: 547 }`, not `Kll { k: 1404 }` nor any `Kmv`. + /// `Kll { k: 547 }`, not `Kll { k: 1404 }` nor any `KMV`. pub fn contains(&self, parameters: &SketchParams) -> bool { fn within(value: T, at_least: Option, at_most: Option) -> bool { at_least.is_none_or(|low| value >= low) && at_most.is_none_or(|high| value <= high) @@ -449,7 +449,7 @@ mod sketch_parameter_range_tests { at_least: None, at_most: Some(2863), }; - assert_eq!(at_most_2863.algorithm(), SketchAlgorithm::Kll); + assert_eq!(at_most_2863.algorithm(), SketchAlgorithm::KLL); assert!(!at_most_2863.contains(&SketchParams::Kmv { k: 547 })); assert!(!at_most_2863.contains(&SketchParams::DDSketch { alpha: 0.01 })); } @@ -462,7 +462,7 @@ mod sketch_parameter_range_tests { at_least: Some(4323), at_most: None, }; - assert_eq!(kmv.algorithm(), SketchAlgorithm::Kmv); + assert_eq!(kmv.algorithm(), SketchAlgorithm::KMV); let kmv_contained: Vec = [1_118, 4_323, 26_656, 106_263] .into_iter() .map(|k| kmv.contains(&SketchParams::Kmv { k })) diff --git a/crates/types/tests/column_lineage.rs b/crates/types/tests/column_lineage.rs index 0a2ab50a4..206057996 100644 --- a/crates/types/tests/column_lineage.rs +++ b/crates/types/tests/column_lineage.rs @@ -62,7 +62,7 @@ fn equals(column: usize, value: &str) -> ScalarExpr { fn hll(child: MemoGroupId, keys: Vec, column: &str) -> Operator { Operator::ASAP(ASAPOp::SummaryAgg { child, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Hll), + summary_type: FieldDataType::Sketch(SketchAlgorithm::HLL), input: SummaryUpdate::column(ColumnRef::Named(column.into())), reduction: Reduction::by(keys), filter: None, @@ -351,7 +351,7 @@ fn a_chain_computes_window_end_and_state_and_its_window_selections_pass_lineage_ let chain = memo .find_or_add_group(Operator::ASAP(ASAPOp::SummaryTumblingWindowChain { child: series, - summary_type: FieldDataType::Sketch(SketchAlgorithm::Kll), + summary_type: FieldDataType::Sketch(SketchAlgorithm::KLL), input: SummaryUpdate::column(ColumnRef::SampleValue), reduction: Reduction::by(vec![2]), filter: None, diff --git a/crates/types/tests/memo_aggregate_coverage.rs b/crates/types/tests/memo_aggregate_coverage.rs index d91cf8d3c..ccf93e31d 100644 --- a/crates/types/tests/memo_aggregate_coverage.rs +++ b/crates/types/tests/memo_aggregate_coverage.rs @@ -74,7 +74,7 @@ fn a_plus_b_above_10() -> ScalarExpr { } fn kll_summary_type() -> FieldDataType { - FieldDataType::Sketch(SketchAlgorithm::Kll) + FieldDataType::Sketch(SketchAlgorithm::KLL) } /// `SummaryAgg[KLL]` of the sample value per series. diff --git a/crates/types/tests/memo_group_properties.rs b/crates/types/tests/memo_group_properties.rs index 6cd2178cb..f67a2f5ed 100644 --- a/crates/types/tests/memo_group_properties.rs +++ b/crates/types/tests/memo_group_properties.rs @@ -317,13 +317,13 @@ fn states_record_their_input_sign_and_readouts_read_it() { let g2 = add(&mut memo, range(MINUTE_MS, g1)); let g3 = add( &mut memo, - state(FieldDataType::Sketch(SketchAlgorithm::Kll), g2), + state(FieldDataType::Sketch(SketchAlgorithm::KLL), g2), ); let g4 = add(&mut memo, shift(MINUTE_MS, None, g1)); let g5 = add(&mut memo, range(MINUTE_MS, g4)); let g6 = add( &mut memo, - state(FieldDataType::Sketch(SketchAlgorithm::Kll), g5), + state(FieldDataType::Sketch(SketchAlgorithm::KLL), g5), ); let g7 = add( &mut memo, @@ -340,7 +340,7 @@ fn states_record_their_input_sign_and_readouts_read_it() { let g10 = add(&mut memo, range(MINUTE_MS, g9)); let g11 = add( &mut memo, - state(FieldDataType::Sketch(SketchAlgorithm::Hll), g10), + state(FieldDataType::Sketch(SketchAlgorithm::HLL), g10), ); let g12 = add(&mut memo, readout(SketchStatistic::Cardinality, g11)); // [ts, state, host] @@ -437,7 +437,7 @@ fn a_result_depends_on_the_evaluation_time_under_a_time_range_or_now() { let g3 = add(&mut memo, range(MINUTE_MS, g1)); let g4 = add( &mut memo, - state(FieldDataType::Sketch(SketchAlgorithm::Kll), g3), + state(FieldDataType::Sketch(SketchAlgorithm::KLL), g3), ); let g5 = add( &mut memo, @@ -449,7 +449,7 @@ fn a_result_depends_on_the_evaluation_time_under_a_time_range_or_now() { ); let g6 = add( &mut memo, - state(FieldDataType::Sketch(SketchAlgorithm::Kll), g5), + state(FieldDataType::Sketch(SketchAlgorithm::KLL), g5), ); let g7 = add(&mut memo, shift(MINUTE_MS, Some(AtModifier::End), g3)); let g8 = add( @@ -644,7 +644,7 @@ fn group_properties_come_from_input_groups() { let g3 = add(&mut memo, range(MINUTE_MS, g2)); let g4 = add( &mut memo, - state(FieldDataType::Sketch(SketchAlgorithm::Kll), g3), + state(FieldDataType::Sketch(SketchAlgorithm::KLL), g3), ); let readout = memo .find_or_add_group(Operator::ASAP(ASAPOp::SummaryEstimate { @@ -698,7 +698,7 @@ fn a_count_sketch_point_count_has_no_sign_a_count_min_one_keeps_it() { ) }; let count_sketch = point_count(&mut memo, SketchAlgorithm::CountSketch); - let count_min = point_count(&mut memo, SketchAlgorithm::Cms); + let count_min = point_count(&mut memo, SketchAlgorithm::CountMinSketch); // [ts, count, host]: the count is the state's column. let value = |group: MemoGroupId| { let schema = &memo.groups()[group.0 as usize].group_properties.schema; @@ -733,7 +733,7 @@ fn a_quantile_outside_the_unit_interval_has_no_sign() { let g2 = add(&mut memo, range(MINUTE_MS, g1)); let kll = add( &mut memo, - state(FieldDataType::Sketch(SketchAlgorithm::Kll), g2), + state(FieldDataType::Sketch(SketchAlgorithm::KLL), g2), ); let read = add( &mut memo, diff --git a/crates/types/tests/structure_contract.rs b/crates/types/tests/structure_contract.rs index a0e7a33d6..a9acac71a 100644 --- a/crates/types/tests/structure_contract.rs +++ b/crates/types/tests/structure_contract.rs @@ -118,7 +118,7 @@ fn state_evaluations_and_passthrough_keep_their_contracts() { use asap_types::ir::schema::FieldDataType; use asap_types::ir::{ASAPOp, Operator, ProjectItem}; use asap_types::summary_type::{SketchAlgorithm, SketchStatistic, SummaryUpdate}; - let family = FieldDataType::Sketch(SketchAlgorithm::Kll); + let family = FieldDataType::Sketch(SketchAlgorithm::KLL); let state = Rc::new( OperatorNode::new(Operator::ASAP(ASAPOp::SummaryAgg { child: scan(), diff --git a/crates/types/tests/summary_merge_structure.rs b/crates/types/tests/summary_merge_structure.rs index 2a104a4ca..d32c00336 100644 --- a/crates/types/tests/summary_merge_structure.rs +++ b/crates/types/tests/summary_merge_structure.rs @@ -15,7 +15,7 @@ use std::rc::Rc; /// KLL over `value` for one `region`, so states of different regions are /// disjoint. fn state(_k: u32, region: &str) -> Rc { - family_state(FieldDataType::Sketch(SketchAlgorithm::Kll), region) + family_state(FieldDataType::Sketch(SketchAlgorithm::KLL), region) } /// A `family` state over `value` for one `region`. fn family_state(family: FieldDataType, region: &str) -> Rc { @@ -83,13 +83,13 @@ fn exact(kind: ExactKind, params: ExactParams) -> FieldDataType { FieldDataType::ExactAggregate(kind, params) } fn kll() -> FieldDataType { - sketch(SketchAlgorithm::Kll) + sketch(SketchAlgorithm::KLL) } fn hll() -> FieldDataType { - sketch(SketchAlgorithm::Hll) + sketch(SketchAlgorithm::HLL) } fn cms_with_heap() -> FieldDataType { - sketch(SketchAlgorithm::CmsWithHeap) + sketch(SketchAlgorithm::CountMinSketchWithHeap) } fn merge(children: Vec>) -> Result, String> { OperatorNode::new_shared(Operator::ASAP(ASAPOp::SummaryMerge { @@ -176,32 +176,35 @@ fn summary_type_capability_table() { ) }; let sketches = [ - (kll(), SketchAlgorithm::Kll), + (kll(), SketchAlgorithm::KLL), (sketch(SketchAlgorithm::DDSketch), SketchAlgorithm::DDSketch), - (hll(), SketchAlgorithm::Hll), - (sketch(SketchAlgorithm::Cms), SketchAlgorithm::Cms), + (hll(), SketchAlgorithm::HLL), + ( + sketch(SketchAlgorithm::CountMinSketch), + SketchAlgorithm::CountMinSketch, + ), ( sketch(SketchAlgorithm::CountSketch), SketchAlgorithm::CountSketch, ), (sketch(SketchAlgorithm::UnivMon), SketchAlgorithm::UnivMon), - (sketch(SketchAlgorithm::Kmv), SketchAlgorithm::Kmv), - (cms_with_heap(), SketchAlgorithm::CmsWithHeap), + (sketch(SketchAlgorithm::KMV), SketchAlgorithm::KMV), + (cms_with_heap(), SketchAlgorithm::CountMinSketchWithHeap), ( sketch(SketchAlgorithm::CountSketchWithHeap), SketchAlgorithm::CountSketchWithHeap, ), ( - FieldDataType::Sketch(SketchAlgorithm::HydraCms), - SketchAlgorithm::HydraCms, + FieldDataType::Sketch(SketchAlgorithm::HydraCountMinSketch), + SketchAlgorithm::HydraCountMinSketch, ), ( FieldDataType::Sketch(SketchAlgorithm::HydraCountSketch), SketchAlgorithm::HydraCountSketch, ), ( - FieldDataType::Sketch(SketchAlgorithm::HydraKll), - SketchAlgorithm::HydraKll, + FieldDataType::Sketch(SketchAlgorithm::HydraKLL), + SketchAlgorithm::HydraKLL, ), ]; let rows = rows @@ -329,7 +332,7 @@ fn estimate(family: FieldDataType, query: SketchStatistic) -> Result use SketchAlgorithm as A; use SketchStatistic as Q; match algorithm { - A::Kll | A::DDSketch => matches!(query, Q::Quantile { .. }), - A::Hll | A::Kmv => matches!(query, Q::Cardinality), - A::Cms | A::CountSketch => matches!(query, Q::PointCount { .. }), - A::CmsWithHeap | A::CountSketchWithHeap => matches!(query, Q::TopK { .. }), + A::KLL | A::DDSketch => matches!(query, Q::Quantile { .. }), + A::HLL | A::KMV => matches!(query, Q::Cardinality), + A::CountMinSketch | A::CountSketch => matches!(query, Q::PointCount { .. }), + A::CountMinSketchWithHeap | A::CountSketchWithHeap => matches!(query, Q::TopK { .. }), A::UnivMon => !matches!(query, Q::Quantile { .. }), - A::HydraKll => matches!(query, Q::Quantile { .. }), - A::HydraCms | A::HydraCountSketch => matches!(query, Q::PointCount { .. }), + A::HydraKLL => matches!(query, Q::Quantile { .. }), + A::HydraCountMinSketch | A::HydraCountSketch => matches!(query, Q::PointCount { .. }), _ => unreachable!("{algorithm:?} is not probed"), } } @@ -381,13 +384,13 @@ fn accepted_by_category(algorithm: &SketchAlgorithm, query: &SketchStatistic) -> fn estimate_validation_matches_the_category_match_except_the_fixed_rows() { use SketchAlgorithm as A; let mut families: Vec = [ - A::Kll, + A::KLL, A::DDSketch, - A::Hll, - A::Kmv, - A::Cms, + A::HLL, + A::KMV, + A::CountMinSketch, A::CountSketch, - A::CmsWithHeap, + A::CountMinSketchWithHeap, A::CountSketchWithHeap, A::UnivMon, ] @@ -395,9 +398,9 @@ fn estimate_validation_matches_the_category_match_except_the_fixed_rows() { .map(sketch) .collect(); families.extend([ - FieldDataType::Sketch(SketchAlgorithm::HydraCms), + FieldDataType::Sketch(SketchAlgorithm::HydraCountMinSketch), FieldDataType::Sketch(SketchAlgorithm::HydraCountSketch), - FieldDataType::Sketch(SketchAlgorithm::HydraKll), + FieldDataType::Sketch(SketchAlgorithm::HydraKLL), ]); let statistics = [ SketchStatistic::PointCount { @@ -428,7 +431,7 @@ fn estimate_validation_matches_the_category_match_except_the_fixed_rows() { SketchAlgorithm::CountSketch | SketchAlgorithm::HydraCountSketch, StatisticKind::Total ) | ( - SketchAlgorithm::CmsWithHeap | SketchAlgorithm::CountSketchWithHeap, + SketchAlgorithm::CountMinSketchWithHeap | SketchAlgorithm::CountSketchWithHeap, StatisticKind::ItemFrequency, ) ); diff --git a/crates/types/tests/tumbling_window_chain.rs b/crates/types/tests/tumbling_window_chain.rs index a8228d8ae..a53b164d5 100644 --- a/crates/types/tests/tumbling_window_chain.rs +++ b/crates/types/tests/tumbling_window_chain.rs @@ -30,7 +30,7 @@ fn scan() -> Rc { } fn kll() -> FieldDataType { - FieldDataType::Sketch(SketchAlgorithm::Kll) + FieldDataType::Sketch(SketchAlgorithm::KLL) } /// 1-min KLL tumbling windows per series over `input`. diff --git a/docs/design_docs/concepts/accuracy-models.md b/docs/design_docs/concepts/accuracy-models.md index e354e511d..c0e572f9f 100644 --- a/docs/design_docs/concepts/accuracy-models.md +++ b/docs/design_docs/concepts/accuracy-models.md @@ -66,7 +66,7 @@ a per-value guarantee is restated over a scope. A scope bounds only the failure probability; the error bound is unchanged. Every estimator produces a per-value guarantee (for a grouped -query, one per group: a Kmv or HLL distinct count per group, a KLL or DDSketch +query, one per group: a KMV or HLL distinct count per group, a KLL or DDSketch quantile per group, a Count-Min or Count Sketch frequency per key, a Hydra estimate per subpopulation; an exact value fails with probability 0). Stated over a scope, a per-value failure probability `δ` becomes `V · δ` by the union diff --git a/docs/design_docs/proposals/asap-primitive-schema.md b/docs/design_docs/proposals/asap-primitive-schema.md index a7606147e..59afc3ba3 100644 --- a/docs/design_docs/proposals/asap-primitive-schema.md +++ b/docs/design_docs/proposals/asap-primitive-schema.md @@ -73,13 +73,13 @@ Based on our requirement, each field should contain the following information. | Term | Code | Values | KLL example | |---|---|---|---| | Family | `FieldDataType` variant | `ExactAggregate`, `Sketch`, `SummarySample`, `Wavelet`, `StatModel` | `Sketch` | - | Algorithm | `SketchAlgorithm` (other families: `ExactKind`, `SamplingKind`, …) | `Kll`, `Cms`, `Hll`, `DDSketch`, `HydraKll`, … | `Kll` | - | Summary type | family and algorithm: one `FieldDataType` value, the column's type | `FieldDataType::Sketch(SketchAlgorithm)`, … | `Sketch(Kll)` | + | Algorithm | `SketchAlgorithm` (other families: `ExactKind`, `SamplingKind`, …) | `KLL`, `CountMinSketch`, `HLL`, `DDSketch`, `HydraKLL`, … | `KLL` | + | Summary type | family and algorithm: one `FieldDataType` value, the column's type | `FieldDataType::Sketch(SketchAlgorithm)`, … | `Sketch(KLL)` | | Parameters θ | `SketchParams` (other families: `ExactParams`, `SamplingParams`, …), on the candidate's `LogicalProperties`, not in the type | per algorithm, from `parameter_list(algorithm)` | `Kll { k: 547 }` | - The summary type is the operator's `summary_type` argument (`SummaryAgg`, the chain). θ is structure only (sizes, no sized-for error fields) and lives on the candidate, so builds that differ only in θ are candidates of one memo group. - - A shared multi-subpopulation structure (Hydra) is an algorithm of its own (`HydraKll`, `HydraCms`, `HydraCountSketch`, …), not a separate grouping dimension. - - So a quantile KLL sketch with `k = 547` has the type `Sketch(Kll)` and θ `Kll { k: 547 }`. Which statistics a summary type answers is its row of the capability table (`SummaryTypeCapability`), not part of the type. + - A shared multi-subpopulation structure (Hydra) is an algorithm of its own (`HydraKLL`, `HydraCountMinSketch`, `HydraCountSketch`, …), not a separate grouping dimension. + - So a quantile KLL sketch with `k = 547` has the type `Sketch(KLL)` and θ `Kll { k: 547 }`. Which statistics a summary type answers is its row of the capability table (`SummaryTypeCapability`), not part of the type. 2. **What query intent the summarized ASAP Primitive can support.** This is not stored in the field: it follows from the type in item 1. There are two kinds of intent: @@ -87,10 +87,10 @@ Based on our requirement, each field should contain the following information. | Intent | Candidate types | Evaluation | |---|---|---| - | `Quantile` | `Sketch`: `Kll`, `DDSketch` | `SummaryEstimate(Quantile { q })` | - | `Cardinality` | `Sketch`: `Hll`, `Kmv`, `UnivMon` (one column only) | `SummaryEstimate(Cardinality)` | - | `Count` (approximate) | `Sketch`: `Cms`, `UnivMon` | `SummaryEstimate(PointCount { .. })` | - | `TopK` | `Sketch`: `CmsWithHeap`, `CountSketchWithHeap` | `SummaryEstimate(TopK { k })` | + | `Quantile` | `Sketch`: `KLL`, `DDSketch` | `SummaryEstimate(Quantile { q })` | + | `Cardinality` | `Sketch`: `HLL`, `KMV`, `UnivMon` (one column only) | `SummaryEstimate(Cardinality)` | + | `Count` (approximate) | `Sketch`: `CountMinSketch`, `UnivMon` | `SummaryEstimate(PointCount { .. })` | + | `TopK` | `Sketch`: `CountMinSketchWithHeap`, `CountSketchWithHeap` | `SummaryEstimate(TopK { k })` | | `FrequencyL2`, `FrequencyEntropy` | `Sketch`: `UnivMon` | `SummaryEstimate(FrequencyL2 \| FrequencyEntropy)` | | `Sum`, `Count`, `Min`, `Max`, `Rate`, `IRate`, `Increase` (exact) | `ExactAggregate(ExactKind, …)` | `FinalizeExactAccumulator` | @@ -881,7 +881,7 @@ input groups output groups |---|---|---| | **must not overlap** | KLL, DDSketch, Count-Min, Count Sketch, UnivMon, exact `Sum`/`Count` | KLL `A + C` ✗: the rows in `(t − 60s, t − 30s]` would be counted twice | | **may overlap** | HLL, exact `Min`/`Max` | HLL over `A`'s and `C`'s rows ✓: a value seen twice is still one distinct value. The result keeps both boxes, `(t − 1m, t]` and `(t − 90s, t − 30s]`, which together cover `(t − 90s, t]` | -| **cannot merge (yet)** | `CmsWithHeap`, `CountSketchWithHeap`, Theta, KMV, exact `Rate`/`IRate`/`Increase`, samples, wavelets, models | no sound merge is modeled yet, so #592 rejects them | +| **cannot merge (yet)** | `CountMinSketchWithHeap`, `CountSketchWithHeap`, Theta, KMV, exact `Rate`/`IRate`/`Increase`, samples, wavelets, models | no sound merge is modeled yet, so #592 rejects them | | **right inside left** | subtraction | 5.7 | | Question | Answer | @@ -965,7 +965,7 @@ MemoGroup.group_properties.aggregate_coverage: AggregateCoverage §6.6 | §6.5 Update input and evaluations | `SummaryUpdate`, `SketchStatistic`, `MaintainedPopulation`, `PopulationStatistic` | fields of the `ASAPOp` variants in §6.2 | | §6.6 Aggregate coverage | `AggregateCoverage`, `AggregateDefinition`, `SelectionBox`, `Constraint` | `GroupProperties::aggregate_coverage` of aggregate memo groups | -**Example: the p99 latency state of §5.1.** The `SummaryAgg` node (§6.1) holds `ASAPOp::SummaryAgg` (§6.2) with `summary_type = Sketch(Kll)` (§6.3, §6.4) and `input = SummaryUpdate::column(latency)` (§6.5); its candidate's θ is `Kll { k: 200 }`. Its `schema` (§6.3) is `(job Utf8, state Sketch(Kll))`: the `state` field has the same type as `summary_type`. A `SummaryEstimate` above it holds `query = Quantile { q: 0.99 }` (§6.5). The memo derives the `SummaryAgg` group's `AggregateCoverage` (§6.6) and stores it in the group's `GroupProperties::aggregate_coverage`. +**Example: the p99 latency state of §5.1.** The `SummaryAgg` node (§6.1) holds `ASAPOp::SummaryAgg` (§6.2) with `summary_type = Sketch(KLL)` (§6.3, §6.4) and `input = SummaryUpdate::column(latency)` (§6.5); its candidate's θ is `Kll { k: 200 }`. Its `schema` (§6.3) is `(job Utf8, state Sketch(KLL))`: the `state` field has the same type as `summary_type`. A `SummaryEstimate` above it holds `query = Quantile { q: 0.99 }` (§6.5). The memo derives the `SummaryAgg` group's `AggregateCoverage` (§6.6) and stores it in the group's `GroupProperties::aggregate_coverage`. ### 6.1 DAG node (`crates/types/src/ir/operator/node.rs`) @@ -1192,8 +1192,8 @@ pub enum DataType { pub enum ExactKind { Sum, Count, Min, Max, Increase, Rate, IRate } pub enum ExactParams { Sum, Count, Min, Max, Increase, Rate, IRate } -/// `asap_sketchlib`'s algorithm enum, the Hydra algorithms (`HydraKll`, -/// `HydraCms`, `HydraCountSketch`, …) included. Which statistics each +/// `asap_sketchlib`'s algorithm enum, the Hydra algorithms (`HydraKLL`, +/// `HydraCountMinSketch`, `HydraCountSketch`, …) included. Which statistics each /// answers is its row of the capability table (`SummaryTypeCapability`). pub use asap_sketchlib::SketchAlgorithm; diff --git a/docs/design_docs/proposals/planner-layering-example1-acceptance.md b/docs/design_docs/proposals/planner-layering-example1-acceptance.md index 3dce70214..df9f717cf 100644 --- a/docs/design_docs/proposals/planner-layering-example1-acceptance.md +++ b/docs/design_docs/proposals/planner-layering-example1-acceptance.md @@ -84,7 +84,7 @@ Invariants: Q2, two with a heap Q2 (Q1's rate and sum). Q2's heaps are whole-expression heaps, Q2 top-*k*'s fused computation: they absorb its `sum_over_time`, which is then not computed. -* Q2's sketch families are exactly {`CmsWithHeap`, `CountSketchWithHeap`}, +* Q2's sketch families are exactly {`CountMinSketchWithHeap`, `CountSketchWithHeap`}, each per subpopulation (job). Exact Q2 has no sketch. * Only the scan and range nodes may be shared between the queries. No summary is shared. @@ -93,7 +93,7 @@ Invariants: Ignored until their feature lands: -* Hydra (`HydraCms` over all (job, series) keys, a heap per job) as a third +* Hydra (`HydraCountMinSketch` over all (job, series) keys, a heap per job) as a third Q2 summary (#605). ## Physical ASAP-aware optimization: 72 candidates @@ -200,7 +200,7 @@ per evaluation, within its 100 ms. sort + limit a physical choice. The tests require sort → limit only after physical ASAP-aware optimization. 6. **Hydra's inner sketch.** The doc says "Hydra over the whole `job` - column" without naming the inner sketch. The test assumes `HydraCms`. + column" without naming the inner sketch. The test assumes `HydraCountMinSketch`. 7. **"Shared summary charged once"** does not apply literally: the doc says no summary is shared in Example 1. Plan selection charges a `Lifetime::None` node once per consuming query and a materialized one diff --git a/docs/develop_docs/end-to-end-accuracy-guarantees.md b/docs/develop_docs/end-to-end-accuracy-guarantees.md index 8a874ab03..359fe4f62 100644 --- a/docs/develop_docs/end-to-end-accuracy-guarantees.md +++ b/docs/develop_docs/end-to-end-accuracy-guarantees.md @@ -291,7 +291,7 @@ declared facts, and is recorded in provenance. The default evidence has no measu ### TopK membership Planner has no membership certificate for a top-k. A top-k readout from a -heap variant (`CmsWithHeap`, `CountSketchWithHeap`) is admitted when its +heap variant (`CountMinSketchWithHeap`, `CountSketchWithHeap`) is admitted when its heap holds at least `k` entries (else the edge fails with `RootPruneReason::HeapSmallerThanTopK`) and the counts it reports meet the requirement: the Count-Min L1 or Count Sketch L2 absolute stream bound of diff --git a/docs/develop_docs/extend-asap-aware-mapping.md b/docs/develop_docs/extend-asap-aware-mapping.md index 2c2c61573..42e9dd055 100644 --- a/docs/develop_docs/extend-asap-aware-mapping.md +++ b/docs/develop_docs/extend-asap-aware-mapping.md @@ -33,7 +33,7 @@ A new sketch that Pass 1 can offer for an intent. it from `theoretical_guarantee`, evaluated at the required failure probability. Without a guarantee, every candidate that uses it is rejected. -5. **Cost.** Give it a state size (the library's `estimated_memory_bytes` +5. **Cost.** Give it a state size (the library's `theoretical_memory_bytes` for the type the executor builds; KLL keeps the planner's own formula) in `sketch_state_bytes` (`crates/cost/src/node/state_bytes/mod.rs`), its per-row and per-merge CPU in diff --git a/docs/user_guide_docs/asap-planner.md b/docs/user_guide_docs/asap-planner.md index 28263451a..f6fc7fd48 100644 --- a/docs/user_guide_docs/asap-planner.md +++ b/docs/user_guide_docs/asap-planner.md @@ -77,7 +77,7 @@ object; an omitted field keeps its default. `supported_summaries` lists the sketch summary types the deployment builds, each with the statistics it reads from them, e.g. -`[{"summary_type": "Kll", "readouts": ["Quantile"]}]`. Without the file, or +`[{"summary_type": "KLL", "readouts": ["Quantile"]}]`. Without the file, or when the file leaves it out, the planner uses the summary types the Planner's executor builds. To plan for a runtime that builds every summary type, pass the ready-to-use @@ -92,10 +92,10 @@ do or what the caller rules out: ```json { "counter_semantics": {"reset_handling": true, "extrapolation": false}, - "state_not_mergeable_across_windows": [{"exact": "Counter"}, {"sketch": "Kll"}], + "state_not_mergeable_across_windows": [{"exact": "Counter"}, {"sketch": "KLL"}], "excluded_candidates": [ {"timing": "query_time", "operator": "Scan"}, - {"summary_family": {"sketch": "Kll"}, "sketch_parameter_range": {"kll_k": {"at_most": 1403}}}, + {"summary_family": {"sketch": "KLL"}, "sketch_parameter_range": {"kll_k": {"at_most": 1403}}}, {"timing": "query_time", "aggregate_measure": "rate"} ] } @@ -115,7 +115,7 @@ do or what the caller rules out: the fields it sets: `timing`, `kept_across_evaluations`, `operator`, `per_entity_reduction`, `aggregate_measure` (an `Aggregate` measure's JSON `kind`, e.g. `"rate"` or `"i_rate"`), `summary_family`, - `sketch_parameter_range` and `readout` (`{"summary_type": "Kll", + `sketch_parameter_range` and `readout` (`{"summary_type": "KLL", "statistic": "Quantile"}`). `aggregate_measure` matches the `Aggregate` only: to rule out the counter state as well, add `{"summary_family": {"exact": "Counter"}}`. An entry that sets no field, or whose fields match diff --git a/tools/dag-viewer/README.md b/tools/dag-viewer/README.md index 892575e1a..65f4eaacc 100644 --- a/tools/dag-viewer/README.md +++ b/tools/dag-viewer/README.md @@ -56,7 +56,7 @@ To run it, see [RUNNING.md](RUNNING.md). when a node that is not materialized is computed once per consumer). Each lane is the whole workload's DAG, so a node shared by several queries appears once and says `shared ×n`. Summary builds print their summary type - (`summary: Kll`, `summary: exact Sum`) and grouping; a + (`summary: KLL`, `summary: exact Sum`) and grouping; a `SummaryTumblingWindowChain` prints its tumbling-window width. A standalone scalar query (`time()`, `scalar(v)`, `1 + 2`) is a dashed `Scalar` node over the nodes it reads. Query roots have a thick border. diff --git a/tools/dag-viewer/deployment-capabilities/every-summary-family.json b/tools/dag-viewer/deployment-capabilities/every-summary-family.json index cb8d73a6b..0e3ce52f6 100644 --- a/tools/dag-viewer/deployment-capabilities/every-summary-family.json +++ b/tools/dag-viewer/deployment-capabilities/every-summary-family.json @@ -1,32 +1,32 @@ { "supported_summaries": [ - {"summary_type": "Cms", "readouts": ["ItemFrequency", "Total"]}, + {"summary_type": "CountMinSketch", "readouts": ["ItemFrequency", "Total"]}, {"summary_type": "CountSketch", "readouts": ["ItemFrequency"]}, {"summary_type": "CountSketchWithL2Norm", "readouts": ["ItemFrequency", "FrequencyL2"]}, - {"summary_type": "CmsWithHeap", "readouts": ["ItemFrequency", "TopK"]}, + {"summary_type": "CountMinSketchWithHeap", "readouts": ["ItemFrequency", "TopK"]}, {"summary_type": "CountSketchWithHeap", "readouts": ["ItemFrequency", "TopK"]}, - {"summary_type": "CmsWithSpaceSaving", "readouts": ["ItemFrequency", "TopK"]}, + {"summary_type": "CountMinSketchWithSpaceSaving", "readouts": ["ItemFrequency", "TopK"]}, {"summary_type": "CountSketchWithSpaceSaving", "readouts": ["ItemFrequency", "TopK"]}, - {"summary_type": "CmsFold", "readouts": ["ItemFrequency", "TopK"]}, + {"summary_type": "CountMinSketchFold", "readouts": ["ItemFrequency", "TopK"]}, {"summary_type": "CountSketchFold", "readouts": ["ItemFrequency", "TopK"]}, - {"summary_type": "Hll", "readouts": ["Distinct"]}, - {"summary_type": "HllHip", "readouts": ["Distinct"]}, - {"summary_type": "Kmv", "readouts": ["Distinct"]}, - {"summary_type": "Kll", "readouts": ["Quantile", "Rank"]}, - {"summary_type": "KllDynamic", "readouts": ["Quantile", "Rank"]}, - {"summary_type": "DDSketch", "readouts": ["Quantile"]}, + {"summary_type": "HLL", "readouts": ["Distinct"]}, + {"summary_type": "HLLHip", "readouts": ["Distinct"]}, + {"summary_type": "KMV", "readouts": ["Distinct"]}, + {"summary_type": "KLL", "readouts": ["Quantile", "Rank"]}, + {"summary_type": "KLLDynamic", "readouts": ["Quantile", "Rank"]}, + {"summary_type": "DDSketch", "readouts": ["Quantile", "QuantileInterpolated"]}, {"summary_type": "SpaceSaving", "readouts": ["ItemFrequency", "TopK"]}, - {"summary_type": "Elastic", "readouts": ["ItemFrequency", "TopK"]}, - {"summary_type": "Coco", "readouts": ["ItemFrequency", "PartialKeySum"]}, + {"summary_type": "ElasticSketch", "readouts": ["ItemFrequency", "TopK"]}, + {"summary_type": "CocoSketch", "readouts": ["ItemFrequency", "PartialKeySum"]}, {"summary_type": "Bloom", "readouts": ["Membership"]}, {"summary_type": "SetAggregator", "readouts": ["Distinct", "Membership"]}, {"summary_type": "UnivMon", "readouts": ["Total", "FrequencyL2", "Distinct", "FrequencyEntropy", "GSum"]}, {"summary_type": "UnivMonTwoTier", "readouts": ["Total", "FrequencyL2", "Distinct", "FrequencyEntropy", "GSum"]}, {"summary_type": "UnivMonQ", "readouts": ["ItemFrequency", "FrequencyL2", "Distinct", "Quantile", "Rank", "GSum", "FrequencyEntropy", "TopK"]}, - {"summary_type": "HydraCms", "readouts": ["ItemFrequency", "Total"]}, + {"summary_type": "HydraCountMinSketch", "readouts": ["ItemFrequency", "Total"]}, {"summary_type": "HydraCountSketch", "readouts": ["ItemFrequency"]}, - {"summary_type": "HydraKll", "readouts": ["Quantile", "Rank"]}, - {"summary_type": "HydraHll", "readouts": ["Distinct"]}, + {"summary_type": "HydraKLL", "readouts": ["Quantile", "Rank"]}, + {"summary_type": "HydraHLL", "readouts": ["Distinct"]}, {"summary_type": "HydraUnivMon", "readouts": ["Total", "Distinct", "FrequencyL2", "FrequencyEntropy"]} ] } diff --git a/tools/dag-viewer/memo.test.mjs b/tools/dag-viewer/memo.test.mjs index b97981ac6..5bd2fc6c5 100644 --- a/tools/dag-viewer/memo.test.mjs +++ b/tools/dag-viewer/memo.test.mjs @@ -113,7 +113,7 @@ test('each candidate sits inside its group, colored by origin, with θ, and an e const kll = byId(elements, 'g4c6'); assert.equal(kll.data.parent, 'g4'); assert.equal(kll.data.color, vm.runInContext('MEMO_ORIGINS.pass1.color', context)); - assert.equal(kll.data.label, '#6 SummaryAgg Kll\nθ Kll(k=2863)\nPass1'); + assert.equal(kll.data.label, '#6 SummaryAgg KLL\nθ Kll(k=2863)\nPass1'); // A candidate without θ says so on its middle line; a new one is marked // (its last line clipped). assert.equal(byId(elements, 'g0c1').data.label, '#1 Project\n—\nPass1 · ✓ selected'); @@ -133,7 +133,7 @@ test("Pass 2's pruned candidates are marked and counted on their group", () => { const elements = call('memoStepElements', fixture(), PASS2, {}); assert.deepEqual(nodesOf(elements).filter((e) => /\bpruned\b/.test(e.classes || '')).map((e) => e.data.id), ['g4c0', 'g4c1', 'g4c2', 'g4c3']); assert.match(byId(elements, 'g4c0').data.label, /Pass1 · ✗ pruned$/); - assert.match(byId(elements, 'g4').data.label, /^G4 · SummaryAgg Kll\n10 candidates \(4 pruned by Pass 2\)$/); + assert.match(byId(elements, 'g4').data.label, /^G4 · SummaryAgg KLL\n10 candidates \(4 pruned by Pass 2\)$/); // Pass 1 does not prune. assert.ok(!call('memoStepElements', fixture(), 1, {}).some((e) => /pruned/.test(e.classes || ''))); }); diff --git a/tools/dag-viewer/stages.js b/tools/dag-viewer/stages.js index 7d9bb10e5..93e3b13ec 100644 --- a/tools/dag-viewer/stages.js +++ b/tools/dag-viewer/stages.js @@ -417,7 +417,7 @@ function formatTiming(timing) { return String(timing || 'unknown'); } -// A summary type (`FieldDataType` JSON), e.g. `{"Sketch": "Kll"}` as "Kll" +// A summary type (`FieldDataType` JSON), e.g. `{"Sketch": "KLL"}` as "KLL" // and `{"ExactAggregate": ["Sum", "Sum"]}` as "exact Sum". θ is not part // of the type: the memo view shows each candidate's. function summaryTypeText(summaryType) { diff --git a/tools/dag-viewer/stages.test.mjs b/tools/dag-viewer/stages.test.mjs index b9085a8cb..7719cb9ad 100644 --- a/tools/dag-viewer/stages.test.mjs +++ b/tools/dag-viewer/stages.test.mjs @@ -63,7 +63,7 @@ test("the plan's lane draws each node with its timing and Stage 3 cost; cytoscap assert.deepEqual(node.data.reachedBy, ['q1']); } const kll = nodesOf(elements).find((n) => n.data.kind === 'SummaryTumblingWindowChain'); - assert.deepEqual(kll.data.label.split('\n').slice(0, 4), ['SummaryTumblingWindowChain', 'summary: Kll', 'tumbling windows of 1 min', 'per series']); + assert.deepEqual(kll.data.label.split('\n').slice(0, 4), ['SummaryTumblingWindowChain', 'summary: KLL', 'tumbling windows of 1 min', 'per series']); assert.deepEqual(nodesOf(elements).filter((n) => n.data.rootFor.length).map((n) => n.data.nodeId), plan.roots); assert.equal(cytoscape(elements).nodes().length, plan.nodes.length); }); @@ -77,10 +77,10 @@ test('Stage 0 nodes carry no timing; timing classes color the plan', () => { }); test('summary types read as their algorithm or exact kind', () => { - assert.equal(call('summaryTypeText', { Sketch: 'Kll' }), 'Kll'); + assert.equal(call('summaryTypeText', { Sketch: 'KLL' }), 'KLL'); assert.equal(call('summaryTypeText', { ExactAggregate: ['Sum', 'Sum'] }), 'exact Sum'); - const chain = { ASAP: { SummaryTumblingWindowChain: { child: 0, summary_type: { Sketch: 'Kll' }, reduction: 'PerEntity', tumbling_window_width_ms: 86400000 } } }; - assert.deepEqual(call('stageNodeLines', chain, null), ['SummaryTumblingWindowChain', 'summary: Kll', 'tumbling windows of 24 h', 'per series']); + const chain = { ASAP: { SummaryTumblingWindowChain: { child: 0, summary_type: { Sketch: 'KLL' }, reduction: 'PerEntity', tumbling_window_width_ms: 86400000 } } }; + assert.deepEqual(call('stageNodeLines', chain, null), ['SummaryTumblingWindowChain', 'summary: KLL', 'tumbling windows of 24 h', 'per series']); }); test('the header shows why a stage failed and the selection\'s warnings', () => { @@ -129,7 +129,7 @@ test('a materialized view row names its plan node, kind, refresh, inputs, cost a const chain = s3.plan.nodes.find((n) => n.payload.ASAP && n.payload.ASAP.SummaryTumblingWindowChain); assert.deepEqual(call('validateStagePipeline', doc), []); assert.deepEqual(call('materializedViewRows', doc), [{ - nodeId: chain.id, definition: s3.materialized_views[0].coverage.definition_id, kind: 'SummaryTumblingWindowChain · Kll', + nodeId: chain.id, definition: s3.materialized_views[0].coverage.definition_id, kind: 'SummaryTumblingWindowChain · KLL', refresh: 'at ingestion', inputs: 'raw data', retention: '5 min', cost: s3.cost.per_node[String(chain.id)].detail, readBy: ['q1'], }]); // A view that reads other views names them. @@ -210,9 +210,9 @@ test('the deployment settings name each capability left out and the caller exclu assert.match(text, /excluded candidates: 2/); // Each supported summary by its wire field `summary_type`. const kllOnly = call('settingsRows', { - deployment_capabilities: { supported_summaries: [{ summary_type: 'Kll', readouts: ['Quantile'] }] }, + deployment_capabilities: { supported_summaries: [{ summary_type: 'KLL', readouts: ['Quantile'] }] }, }); - assert.deepEqual(kllOnly.find(([name]) => name === 'summaries'), ['summaries', 'Kll (Quantile)']); + assert.deepEqual(kllOnly.find(([name]) => name === 'summaries'), ['summaries', 'KLL (Quantile)']); // The defaults leave nothing out, so the line names none of them. const defaults = call('capabilityLimitsText', { raw_data_retained: true, query_time_results_retained: false }); assert.equal(defaults, ''); diff --git a/tools/dag-viewer/test-fixtures/kll-only-no-raw-data-capabilities.json b/tools/dag-viewer/test-fixtures/kll-only-no-raw-data-capabilities.json index 4091b236b..8a01ab56b 100644 --- a/tools/dag-viewer/test-fixtures/kll-only-no-raw-data-capabilities.json +++ b/tools/dag-viewer/test-fixtures/kll-only-no-raw-data-capabilities.json @@ -3,7 +3,7 @@ "query_time_results_retained": false, "supported_summaries": [ { - "summary_type": "Kll", + "summary_type": "KLL", "readouts": [ "Quantile" ] diff --git a/tools/dag-viewer/test-fixtures/p90-kll.json b/tools/dag-viewer/test-fixtures/p90-kll.json index 7b63a0aef..0a825f8b9 100644 --- a/tools/dag-viewer/test-fixtures/p90-kll.json +++ b/tools/dag-viewer/test-fixtures/p90-kll.json @@ -14,7 +14,7 @@ "readouts": [ "Quantile" ], - "summary_type": "Kll" + "summary_type": "KLL" } ] }, @@ -680,7 +680,7 @@ "shareable_when_equal": true }, { - "aggregate_coverage": "covers G2 through [SummaryAgg Kll] selecting [{\"columns\":[{\"column\":{\"source\":{\"TimeSeries\":{\"metric\":\"data\"}},\"scan_ordinal\":0,\"column\":\"ts\"},\"constraint\":{\"interval\":{\"lower\":{\"excluded\":{\"evaluation_time_plus_ms\":-300000}},\"upper\":{\"included\":{\"evaluation_time_plus_ms\":0}}}}}]}]", + "aggregate_coverage": "covers G2 through [SummaryAgg KLL] selecting [{\"columns\":[{\"column\":{\"source\":{\"TimeSeries\":{\"metric\":\"data\"}},\"scan_ordinal\":0,\"column\":\"ts\"},\"constraint\":{\"interval\":{\"lower\":{\"excluded\":{\"evaluation_time_plus_ms\":-300000}},\"upper\":{\"included\":{\"evaluation_time_plus_ms\":0}}}}}]}]", "candidate_count": 7, "candidate_count_by_origin": { "pass1": 7 @@ -693,7 +693,7 @@ ], "fused_groups": [], "index": 0, - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -707,7 +707,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -729,7 +729,7 @@ ], "fused_groups": [], "index": 1, - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -743,7 +743,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -765,7 +765,7 @@ ], "fused_groups": [], "index": 2, - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -779,7 +779,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -801,7 +801,7 @@ ], "fused_groups": [], "index": 3, - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -815,7 +815,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -837,7 +837,7 @@ ], "fused_groups": [], "index": 4, - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -851,7 +851,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -873,7 +873,7 @@ ], "fused_groups": [], "index": 5, - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -887,7 +887,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -909,7 +909,7 @@ ], "fused_groups": [], "index": 6, - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -923,7 +923,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -955,7 +955,7 @@ "depends_on_evaluation_time": true, "evaluation_grid": null, "id": 4, - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -969,7 +969,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -1552,7 +1552,7 @@ "shareable_when_equal": true }, { - "aggregate_coverage": "covers G2 through [SummaryAgg Kll] selecting [{\"columns\":[{\"column\":{\"source\":{\"TimeSeries\":{\"metric\":\"data\"}},\"scan_ordinal\":0,\"column\":\"ts\"},\"constraint\":{\"interval\":{\"lower\":{\"excluded\":{\"evaluation_time_plus_ms\":-300000}},\"upper\":{\"included\":{\"evaluation_time_plus_ms\":0}}}}}]}]", + "aggregate_coverage": "covers G2 through [SummaryAgg KLL] selecting [{\"columns\":[{\"column\":{\"source\":{\"TimeSeries\":{\"metric\":\"data\"}},\"scan_ordinal\":0,\"column\":\"ts\"},\"constraint\":{\"interval\":{\"lower\":{\"excluded\":{\"evaluation_time_plus_ms\":-300000}},\"upper\":{\"included\":{\"evaluation_time_plus_ms\":0}}}}}]}]", "candidate_count": 10, "candidate_count_by_origin": { "pass1": 7, @@ -1578,7 +1578,7 @@ "group": 1 } ], - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -1592,7 +1592,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -1627,7 +1627,7 @@ "group": 1 } ], - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -1641,7 +1641,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -1676,7 +1676,7 @@ "group": 1 } ], - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -1690,7 +1690,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -1725,7 +1725,7 @@ "group": 1 } ], - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -1739,7 +1739,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -1774,7 +1774,7 @@ "group": 1 } ], - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -1788,7 +1788,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -1823,7 +1823,7 @@ "group": 1 } ], - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -1837,7 +1837,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -1872,7 +1872,7 @@ "group": 1 } ], - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -1886,7 +1886,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -2072,7 +2072,7 @@ "phase_ms": 0 }, "id": 4, - "label": "SummaryAgg Kll", + "label": "SummaryAgg KLL", "operator": { "ASAP": { "SummaryAgg": { @@ -2086,7 +2086,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" } } } @@ -2109,7 +2109,7 @@ "shareable_when_equal": true }, { - "aggregate_coverage": "covers G2 through [SummaryAgg Kll] selecting [{\"columns\":[{\"column\":{\"source\":{\"TimeSeries\":{\"metric\":\"data\"}},\"scan_ordinal\":0,\"column\":\"ts\"},\"constraint\":{\"interval\":{\"lower\":{\"excluded\":{\"evaluation_time_plus_ms\":-300000}},\"upper\":{\"included\":{\"evaluation_time_plus_ms\":0}}}}}]}]", + "aggregate_coverage": "covers G2 through [SummaryAgg KLL] selecting [{\"columns\":[{\"column\":{\"source\":{\"TimeSeries\":{\"metric\":\"data\"}},\"scan_ordinal\":0,\"column\":\"ts\"},\"constraint\":{\"interval\":{\"lower\":{\"excluded\":{\"evaluation_time_plus_ms\":-300000}},\"upper\":{\"included\":{\"evaluation_time_plus_ms\":0}}}}}]}]", "candidate_count": 3, "candidate_count_by_origin": { "tumbling_windows": 3 @@ -2325,7 +2325,7 @@ "shareable_when_equal": true }, { - "aggregate_coverage": "covers G2 through [SummaryAgg Kll] selecting [{\"columns\":[]}]", + "aggregate_coverage": "covers G2 through [SummaryAgg KLL] selecting [{\"columns\":[]}]", "candidate_count": 3, "candidate_count_by_origin": { "tumbling_windows": 3 @@ -2350,7 +2350,7 @@ "group": 2 } ], - "label": "SummaryTumblingWindowChain Kll tumbling_window_width_ms=60000", + "label": "SummaryTumblingWindowChain KLL tumbling_window_width_ms=60000", "operator": { "ASAP": { "SummaryTumblingWindowChain": { @@ -2364,7 +2364,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" }, "tumbling_window_width_ms": 60000 } @@ -2400,7 +2400,7 @@ "group": 2 } ], - "label": "SummaryTumblingWindowChain Kll tumbling_window_width_ms=60000", + "label": "SummaryTumblingWindowChain KLL tumbling_window_width_ms=60000", "operator": { "ASAP": { "SummaryTumblingWindowChain": { @@ -2414,7 +2414,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" }, "tumbling_window_width_ms": 60000 } @@ -2450,7 +2450,7 @@ "group": 2 } ], - "label": "SummaryTumblingWindowChain Kll tumbling_window_width_ms=60000", + "label": "SummaryTumblingWindowChain KLL tumbling_window_width_ms=60000", "operator": { "ASAP": { "SummaryTumblingWindowChain": { @@ -2464,7 +2464,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" }, "tumbling_window_width_ms": 60000 } @@ -2501,7 +2501,7 @@ "phase_ms": 0 }, "id": 6, - "label": "SummaryTumblingWindowChain Kll tumbling_window_width_ms=60000", + "label": "SummaryTumblingWindowChain KLL tumbling_window_width_ms=60000", "operator": { "ASAP": { "SummaryTumblingWindowChain": { @@ -2515,7 +2515,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" }, "tumbling_window_width_ms": 60000 } @@ -3829,9 +3829,9 @@ { "accepted_metric": "rank", "sketches": [ - "Kll" + "KLL" ], - "summary": "accepted rank (Kll)" + "summary": "accepted rank (KLL)" } ], "cost": { @@ -3851,7 +3851,7 @@ "cost_per_second": 1.15266666667, "cost_source": "analytical", "cpu_core_seconds_per_second": 0.000156666666667, - "detail": "build Kll in tumbling windows of 60000 ms for 1000 groups: 1000 rows x 84 ops, 100 group visits, 16.7 states emitted; x 1.0000/s; keeps 7968000 bytes", + "detail": "build KLL in tumbling windows of 60000 ms for 1000 groups: 1000 rows x 84 ops, 100 group visits, 16.7 states emitted; x 1.0000/s; keeps 7968000 bytes", "multiplier": 1, "operator": "SummaryTumblingWindowChain", "timing": "ingestion_time" @@ -3906,7 +3906,7 @@ "materialized_views": [ { "coverage": { - "definition_id": "bfbffb8f01ab202d585c3e18c9f78080", + "definition_id": "2d963bc6757b98ad80934456821cc040", "selection": [ { "columns": [] @@ -3989,7 +3989,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -4033,7 +4033,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -4077,7 +4077,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -4251,7 +4251,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -4294,7 +4294,7 @@ }, "reduction": "PerEntity", "summary_type": { - "Sketch": "Kll" + "Sketch": "KLL" }, "tumbling_window_width_ms": 60000 } @@ -4302,7 +4302,7 @@ }, "retention_ms": 300000, "view_coverage": { - "definition_id": "bfbffb8f01ab202d585c3e18c9f78080", + "definition_id": "2d963bc6757b98ad80934456821cc040", "selection": [ { "columns": [] @@ -4325,7 +4325,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false @@ -4385,7 +4385,7 @@ }, { "dtype": { - "Sketch": "Kll" + "Sketch": "KLL" }, "name": "state", "nullable": false diff --git a/tools/dag-viewer/test_viewer.py b/tools/dag-viewer/test_viewer.py index cdac77de2..b4cf051da 100644 --- a/tools/dag-viewer/test_viewer.py +++ b/tools/dag-viewer/test_viewer.py @@ -341,9 +341,9 @@ def test_plan_lane_without_stage3_cost_has_none(self): def test_summary_nodes_print_their_summary_type_and_grouping(self): """Summary nodes print their summary type and grouping.""" - kll = {"ASAP": {"SummaryAgg": {"child": 0, "filter": None, "reduction": {"Reduce": [0]}, "summary_type": {"Sketch": "Kll"}}}} + kll = {"ASAP": {"SummaryAgg": {"child": 0, "filter": None, "reduction": {"Reduce": [0]}, "summary_type": {"Sketch": "KLL"}}}} schema = {"fields": [{"name": "job"}]} - self.assertEqual(self.js.call("stageNodeLines", kll, schema), ["SummaryAgg", "summary: Kll", "group by job"]) + self.assertEqual(self.js.call("stageNodeLines", kll, schema), ["SummaryAgg", "summary: KLL", "group by job"]) exact = {"ASAP": {"SummaryAgg": {"child": 0, "summary_type": {"ExactAggregate": ["Sum", "Sum"]}, "reduction": "PerEntity"}}} self.assertEqual(self.js.call("stageNodeLines", exact, None)[1:], ["summary: exact Sum", "per series"]) self.assertEqual(self.js.call("stageNodeLines", {"ASAP": {"FinalizeExactAccumulator": {"child": 0}}}, None), ["FinalizeExactAccumulator"]) @@ -538,7 +538,7 @@ def test_tumbling_window_chain_box_shows_its_summary_type_and_width(self): """A tumbling-window chain's box shows its summary type and tumbling-window width.""" chain = next(n for n in example3a()["stage3_plan_selection"]["plan"]["nodes"] if "SummaryTumblingWindowChain" in n["payload"].get("ASAP", {})) lines = self.js.call("stageNodeLines", chain["payload"], None) - self.assertEqual(lines[:3], ["SummaryTumblingWindowChain", "summary: Kll", "tumbling windows of 24 h"]) + self.assertEqual(lines[:3], ["SummaryTumblingWindowChain", "summary: KLL", "tumbling windows of 24 h"]) def test_usage_and_deployment_lines(self): """The usage and deployment lines read the plan's cost and capabilities.""" @@ -548,7 +548,7 @@ def test_usage_and_deployment_lines(self): self.assertEqual([no_raw["raw data"], no_raw["query-time results"], no_raw["summaries"]], ["not retained", "not retained", "every summary the planner builds"]) rows = dict(self.js.call("settingsRows", self.doc)) self.assertEqual(rows["raw data"], "retained") - self.assertTrue(rows["summaries"].startswith("Cms (Total), ")) + self.assertTrue(rows["summaries"].startswith("CountMinSketch (Total), ")) self.assertEqual(rows["cost model"], cost["source"]) def test_planning_workload_queries_read_the_workload_json(self): @@ -979,7 +979,7 @@ def test_tapping_a_group_lists_its_candidates_and_pruned_candidates(self): js = self.memo_page(doc) self.tap_memo(js, "g4") details = self.text(js, "details") - self.assertIn("#0 SummaryAgg Kll · θ Kll(k=26) · pruned by Pass 2", details) + self.assertIn("#0 SummaryAgg KLL · θ Kll(k=26) · pruned by Pass 2", details) self.assertIn("pruned by Pass 24", details) self.assertIn("#0: the producer", details) self.assertIn("#4 (query_time, AcrossEvaluations(Memory)): excluded by the deployment: query time results not retained", details)