Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
6c30b92
test(accuracy): failure probability splits over the readout values th…
zzylol Nov 16, 2026
45d5133
fix(accuracy): split δ over the readout values the covered output val…
zzylol Nov 16, 2026
ad81ca8
test(accuracy): readout groups holding reductions, top-k readouts, co…
zzylol Nov 16, 2026
e9d3008
fix(accuracy): count a readout group's other candidates, rank top-k o…
zzylol Nov 16, 2026
441b156
test(accuracy): a readout grouped by a time bucket has no bound from …
zzylol Nov 16, 2026
6539882
fix(accuracy): bound a readout's values by the groups of rows only wh…
zzylol Nov 16, 2026
3fdb75a
test(accuracy): a readout's values multiply over joined scans and are…
zzylol Nov 16, 2026
7597f69
fix(accuracy): bound a readout's values by its keys' declared distinc…
zzylol Nov 16, 2026
eb639c9
test(accuracy): a grouped SQL result's values are its keys' declared …
zzylol Nov 16, 2026
ddb77f8
fix(accuracy): bound a query's values by its keys' declared values pe…
zzylol Nov 16, 2026
b71e053
test(accuracy): a many-to-one match pairs two series' labels, an oute…
zzylol Nov 16, 2026
f346208
fix(accuracy): shift a many-to-one match's other side past the output…
zzylol Nov 16, 2026
bc2a1b5
test(accuracy): check the memo's value bounds against execution on da…
zzylol Nov 16, 2026
f9e7bbf
docs(accuracy): a many-to-one match's other side is another scan; an …
zzylol Nov 16, 2026
51c9a0d
test(types): a same-source group_right's one-side label is the other …
zzylol Nov 16, 2026
df28818
refactor(types): name the join side whose columns an outer join makes…
zzylol Nov 16, 2026
a4b6120
test(types): a LIMIT above a grouping bounds its values by n
zzylol Nov 16, 2026
fe3a22a
fix(types): a LIMIT above a grouping bounds its values by n
zzylol Nov 16, 2026
9a54746
refactor(types): a semi or anti join skips the right side's lineage; …
zzylol Nov 16, 2026
e27d103
test(accuracy): check every memo bound the executor runs, and cross f…
zzylol Nov 16, 2026
9a9bee5
test(cost): the KLL test reads Stage 1's offered k; the distinct roll…
zzylol Nov 16, 2026
83f9f7a
test(cost): the KLL test checks the measured k pair again; name the r…
zzylol Nov 16, 2026
5209432
fix(accuracy): the redundant-level check reads the state's sign and d…
zzylol Nov 16, 2026
386ea88
test(accuracy): the executor now runs casts to BIGINT, DISTINCT, rate…
zzylol Nov 17, 2026
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
73 changes: 61 additions & 12 deletions crates/accuracy/src/logical_edge/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@
//! comparison of an evaluated bound with a required limit
//! ([`within_limit`]).

use asap_types::accuracy::AccuracyMetric;
use asap_types::accuracy::{AccuracyGuarantee, AccuracyMetric};
use asap_types::ir::schema::FieldDataType;
use asap_types::ir::{ASAPOp, Operator};
use asap_types::stages::{CandidateForMemoGroupId, Memo, RootPruneReason};
use asap_types::stages::{
CandidateForMemoGroupId, Memo, MemoGroupId, RequiredAccuracy, RootPruneReason,
};
use asap_types::summary_type::{MergedError, SketchParams, SketchStatistic, SummaryTypeCapability};

use crate::guarantee::{guarantee_before_failure_probability_check, holds_at_failure_probability};
use crate::guarantee::{
guarantee_before_failure_probability_check, holds_at_failure_probability, theoretical_guarantee,
};
use crate::readout::sketch_readout;
use crate::{AccuracyEvidence, ErrorMetricsOfMemo};

Expand Down Expand Up @@ -169,15 +174,7 @@ impl ErrorMetricsOfMemo {
holds_at_failure_probability(guarantee, required.failure_probability)
})
});
let meets = guarantee.is_some_and(|guarantee| {
guarantee.spec.accuracy_metric == required.metric
&& guarantee
.spec
.error
.evaluate()
.is_some_and(|error| within_limit(error, required.max_error))
});
if keeps && meets {
if keeps && guarantee_meets(guarantee.as_ref(), required) {
Ok(())
} else {
Err(RootPruneReason::BelowRequiredAccuracy {
Expand All @@ -189,6 +186,58 @@ impl ErrorMetricsOfMemo {
}
}

/// Whether a state of `summary_type` built with `parameters` meets readout
/// level `required` for `statistic`, as the edge from the build checks it
/// ([`ErrorMetricsOfMemo::edge_meets_logical_requirements`]): its guarantee
/// at the required failure probability (`evidence`'s measurement, else the
/// theoretical one over the sign and distinct bound of the state group
/// `summary_input`) is in the required metric and within the required
/// error. A KLL build of k = 1404 meets rank error 0.0025 at δ = 0.01, not
/// at δ = 0.00125.
pub(crate) fn build_meets_level(
memo: &Memo,
summary_input: MemoGroupId,
summary_type: &FieldDataType,
parameters: &SketchParams,
statistic: &SketchStatistic,
required: RequiredAccuracy,
evidence: &dyn AccuracyEvidence,
) -> bool {
let guarantee = evidence
.measured_guarantee(
summary_type,
parameters,
statistic,
required.failure_probability,
)
.or_else(|| {
theoretical_guarantee(
summary_type,
parameters,
statistic,
required.failure_probability,
memo.groups()[summary_input.0 as usize]
.group_properties
.state_column_sign(),
memo.max_distinct_per_evaluation(summary_input),
)
});
guarantee_meets(guarantee.as_ref(), required)
}

/// Whether `guarantee`, a θ's at the required failure probability, meets
/// `required`: in its metric, with an error within its error.
fn guarantee_meets(guarantee: Option<&AccuracyGuarantee>, required: RequiredAccuracy) -> bool {
guarantee.is_some_and(|guarantee| {
guarantee.spec.accuracy_metric == required.metric
&& guarantee
.spec
.error
.evaluate()
.is_some_and(|error| within_limit(error, required.max_error))
})
}

/// A heap variant's heap size.
fn heap_size(parameters: &SketchParams) -> Option<u32> {
match parameters {
Expand Down
Loading
Loading