Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 10 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions crates/accuracy/src/error_contract/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions crates/accuracy/src/guarantee/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand All @@ -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,
),
Expand All @@ -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,
),
Expand All @@ -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]),
Expand All @@ -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)
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions crates/accuracy/src/logical_edge/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions crates/accuracy/src/metric_rule/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ fn quantile_readouts(memo: &mut Memo, q: f64) -> QuantileReadouts {
memo,
window,
q,
&[SketchAlgorithm::Kll, SketchAlgorithm::DDSketch],
&[SketchAlgorithm::KLL, SketchAlgorithm::DDSketch],
)
}

Expand All @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down
38 changes: 21 additions & 17 deletions crates/accuracy/src/properties.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,14 @@ fn probability() -> impl Strategy<Value = f64> {
fn parameters() -> impl Strategy<Value = (SketchAlgorithm, SketchParams)> {
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,
Expand All @@ -91,7 +93,7 @@ fn parameters() -> impl Strategy<Value = (SketchAlgorithm, SketchParams)> {
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),
Expand Down Expand Up @@ -181,8 +183,8 @@ fn is_a_bound(error: Option<f64>) -> 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,
Expand Down Expand Up @@ -251,18 +253,20 @@ fn grown(parameters: &SketchParams, factor: u32) -> SketchParams {
/// at sizes the planner lists (Count Sketch depth odd).
fn valid_parameters() -> impl Strategy<Value = (SketchAlgorithm, SketchParams)> {
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 {
width,
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 })),
]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions crates/accuracy/src/readout/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ 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!(
readout_error_metric(&sketch(SketchAlgorithm::DDSketch), &quantile),
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!(
Expand Down
12 changes: 6 additions & 6 deletions crates/accuracy/src/readout_caps/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn levels_of(memo: &Memo, readout: MemoGroupId) -> Vec<RequiredAccuracy> {
#[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)),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions crates/accuracy/tests/measured_sketch_accuracy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Loading
Loading