Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .agents/skills/asap-code-review/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ a trade-off, give the author choices here too.
For example:

- `price` recomputes `query_reach(dag)`, a walk over the whole DAG, for every
MatAtQuery node: O(n · (n + e)) per candidate, times every candidate. At
`OneEvaluation` node: O(n · (n + e)) per candidate, times every candidate. At
Example 3's 972 candidates, if each DAG has about 50 nodes, that is about 2.5·10⁶
node visits instead of 5·10⁴. Alternative: compute it once per candidate
before the loop and pass it in.
Expand Down
11 changes: 0 additions & 11 deletions Cargo.lock

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

18 changes: 6 additions & 12 deletions crates/accuracy/src/estimators/cms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,11 @@ mod tests {
#[test]
fn local_guarantee_inverts_frequency_sizing() {
use crate::estimators::size_params;
use asap_types::ir::schema::{GroupingStrategy, SketchKind};
let c = asap_types::ir::operator::agg_intent::default_cardinality();
let params = size_params(SketchAlgorithm::Cms, &c, 0.01, 0.001);
let g = local_guarantee(
&FieldDataType::Sketch(
SketchKind::new(SketchAlgorithm::Cms, params),
GroupingStrategy::default(),
),
let g = sketch_guarantee(
&SketchAlgorithm::Cms,
&params,
&SketchStatistic::PointCount {
key: asap_types::ir::scalar::expr_ir::ColumnRef::SampleValue,
value: None,
Expand All @@ -68,17 +65,14 @@ mod tests {

#[test]
fn heap_evaluation_retains_frequency_metric() {
use asap_types::ir::schema::{GroupingStrategy, SketchKind};
let cms_heap = SketchParams::CmsWithHeap {
width: 272,
depth: 5,
heap_size: 10,
};
let topk_frequency = local_guarantee(
&FieldDataType::Sketch(
SketchKind::new(SketchAlgorithm::CmsWithHeap, cms_heap),
GroupingStrategy::default(),
),
let topk_frequency = sketch_guarantee(
&SketchAlgorithm::CmsWithHeap,
&cms_heap,
&SketchStatistic::TopK { k: 10 },
)
.expect("heap sketch still provides per-key frequency intervals");
Expand Down
9 changes: 3 additions & 6 deletions crates/accuracy/src/estimators/count_sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,11 @@ mod tests {
fn count_sketch_uses_an_l2_guarantee() {
use crate::estimators::size_params;
use asap_types::ir::operator::agg_intent::default_cardinality;
use asap_types::ir::schema::{GroupingStrategy, SketchKind};
let intent = default_cardinality();
let count_sketch = size_params(SketchAlgorithm::CountSketch, &intent, 0.01, 0.01);
let guarantee = local_guarantee(
&FieldDataType::Sketch(
SketchKind::new(SketchAlgorithm::CountSketch, count_sketch),
GroupingStrategy::default(),
),
let guarantee = sketch_guarantee(
&SketchAlgorithm::CountSketch,
&count_sketch,
&SketchStatistic::PointCount {
key: asap_types::ir::scalar::expr_ir::ColumnRef::SampleValue,
value: Some("1".into()),
Expand Down
10 changes: 4 additions & 6 deletions crates/accuracy/src/estimators/hll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ pub fn parse_classic_failure_statistic(statistic: &str) -> Option<(u8, f64, &str
/// distinct bound ([`classic_failure_statistic`]). The failure probability
/// is per output row: each group's estimate fails with at most it. `None`
/// for a precision outside the contract's.
#[allow(dead_code)] // Read again in #1207 PR 4, with θ from `LogicalProperties::parameters`.
pub(crate) fn classic_guarantee(
precision: u8,
relative_error: Option<f64>,
Expand Down Expand Up @@ -479,14 +480,11 @@ mod tests {
fn generic_rse_sizing_does_not_certify_confidence() {
use crate::estimators::size_params;
use asap_types::ir::operator::agg_intent::default_cardinality;
use asap_types::ir::schema::{GroupingStrategy, SketchKind};
let c = default_cardinality();
let params = size_params(SketchAlgorithm::Hll, &c, 0.01, 0.01);
let g = local_guarantee(
&FieldDataType::Sketch(
SketchKind::new(SketchAlgorithm::Hll, params),
GroupingStrategy::default(),
),
let g = sketch_guarantee(
&SketchAlgorithm::Hll,
&params,
&SketchStatistic::Cardinality,
)
.unwrap();
Expand Down
37 changes: 3 additions & 34 deletions crates/accuracy/src/estimators/kll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,34 +180,6 @@ pub(crate) fn with_failure_probability(params: &SketchParams, delta: f64) -> Ske
}
}

/// The `k` of one KLL shared by two readers sized alone at `(k, δ)` and
/// `(k2, δ2)`: each `k` resized to the smaller failure probability at no
/// larger rank error ([`with_failure_probability`]), then the larger. The
/// shared build states its guarantee at that smaller δ, where a `k` sized
/// for a larger δ has a larger rank error, so the larger `k` alone could
/// miss its reader's ε.
pub(crate) fn shared_k(
k: u32,
failure_probability: Option<f64>,
k2: u32,
failure_probability2: Option<f64>,
) -> u32 {
let delta = failure_probability
.unwrap_or(KLL_CALIBRATED_FAILURE_PROBABILITY)
.min(failure_probability2.unwrap_or(KLL_CALIBRATED_FAILURE_PROBABILITY));
let resized = |k, failure_probability| match with_failure_probability(
&SketchParams::Kll {
k,
failure_probability,
},
delta,
) {
SketchParams::Kll { k, .. } => k,
_ => k,
};
resized(k, failure_probability).max(resized(k2, failure_probability2))
}

#[cfg(test)]
mod tests {
use super::*;
Expand All @@ -216,14 +188,11 @@ mod tests {
fn local_guarantee_inverts_rank_sizing() {
use crate::estimators::size_params;
use asap_types::ir::operator::agg_intent::default_quantile;
use asap_types::ir::schema::{GroupingStrategy, SketchKind};
let q = default_quantile(0.99);
let params = size_params(SketchAlgorithm::Kll, &q, 0.01, 0.01);
let g = local_guarantee(
&FieldDataType::Sketch(
SketchKind::new(SketchAlgorithm::Kll, params),
GroupingStrategy::default(),
),
let g = sketch_guarantee(
&SketchAlgorithm::Kll,
&params,
&SketchStatistic::Quantile { q: 0.99 },
)
.unwrap();
Expand Down
Loading
Loading