Skip to content

Commit f9ea40b

Browse files
refactor: simple_engine (#280)
1 parent 5a22b3c commit f9ea40b

16 files changed

Lines changed: 494 additions & 544 deletions

asap-common/dependencies/rs/sql_utilities/src/ast_matching/sqlpattern_matcher.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,17 @@ impl SQLQuery {
7171
pub fn is_valid(&self) -> bool {
7272
self.error.is_none()
7373
}
74+
75+
/// The outer (spatial / single) query's data — always `query_data[0]`.
76+
pub fn outer_data(&self) -> Option<&SQLQueryData> {
77+
self.query_data.first()
78+
}
79+
80+
/// The inner (temporal) query's data for nested queries — always `query_data[1]`.
81+
/// Only valid for `OneTemporalOneSpatial` patterns.
82+
pub fn inner_data(&self) -> Option<&SQLQueryData> {
83+
self.query_data.get(1)
84+
}
7485
}
7586

7687
pub struct SQLPatternMatcher {

asap-query-engine/src/data_model/traits.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ pub trait AggregateCore: SerializableToSink + Send + Sync {
3030

3131
/// Get all keys stored in this accumulator
3232
fn get_keys(&self) -> Option<Vec<KeyByLabelValues>>;
33+
34+
/// Dispatch a statistic query without downcasting.
35+
///
36+
/// Replaces the 12-arm `match get_accumulator_type()` in the engine.
37+
/// Single-subpopulation types ignore `key`; multiple-subpopulation types
38+
/// require it and return `Err` when it is `None`.
39+
/// Special cases (DeltaSetAggregator, SetAggregator) fall back to a
40+
/// cardinality value when `key` is `None`.
41+
fn query_statistic(
42+
&self,
43+
statistic: Statistic,
44+
key: &Option<KeyByLabelValues>,
45+
query_kwargs: &HashMap<String, String>,
46+
) -> Result<f64, Box<dyn std::error::Error + Send + Sync>>;
3347
}
3448

3549
/// Trait for accumulators that support a single subpopulation

0 commit comments

Comments
 (0)