Skip to content

Commit 92ba27f

Browse files
style: apply rustfmt formatting across core crates
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent a25316d commit 92ba27f

6 files changed

Lines changed: 142 additions & 57 deletions

File tree

‎crates/core/src/intent_algebra/expr.rs‎

Lines changed: 110 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,51 @@
11
use std::rc::Rc;
22
use std::time::Duration;
33

4-
use crate::types::AccuracyTarget;
54
use super::schema::{HasSchema, L3Schema, SchemaCatalog};
5+
use crate::types::AccuracyTarget;
66

77
// ── Stub leaf / supporting types ──────────────────────────────────────────────
88
// Full definitions will be added as the respective layers are implemented.
99

1010
/// A row-level filter predicate (WHERE clause / PromQL label matcher).
11-
#[derive(Debug, Clone)] pub struct Predicate;
11+
#[derive(Debug, Clone)]
12+
pub struct Predicate;
1213
/// One item in a SELECT projection list.
13-
#[derive(Debug, Clone)] pub struct ProjectItem;
14+
#[derive(Debug, Clone)]
15+
pub struct ProjectItem;
1416
/// A GROUP BY key reference.
15-
#[derive(Debug, Clone)] pub struct GroupKey;
17+
#[derive(Debug, Clone)]
18+
pub struct GroupKey;
1619
/// A reference to a column by name.
17-
#[derive(Debug, Clone)] pub struct ColumnRef;
20+
#[derive(Debug, Clone)]
21+
pub struct ColumnRef;
1822
/// A set of partitioning keys (sharding hint for L5 stage allocator).
19-
#[derive(Debug, Clone)] pub struct PartitionKeys;
23+
#[derive(Debug, Clone)]
24+
pub struct PartitionKeys;
2025
/// One key in an ORDER BY clause.
21-
#[derive(Debug, Clone)] pub struct SortKey;
26+
#[derive(Debug, Clone)]
27+
pub struct SortKey;
2228
/// An analytic window frame (ROWS / RANGE BETWEEN …).
23-
#[derive(Debug, Clone)] pub struct WindowFrame;
29+
#[derive(Debug, Clone)]
30+
pub struct WindowFrame;
2431
/// PromQL vector-match modifiers (`on`/`ignoring` + `group_left`/`group_right`).
25-
#[derive(Debug, Clone)] pub struct VectorMatch;
32+
#[derive(Debug, Clone)]
33+
pub struct VectorMatch;
2634
/// Reference to a metric by name (PromQL / OTLP).
27-
#[derive(Debug, Clone)] pub struct MetricRef;
35+
#[derive(Debug, Clone)]
36+
pub struct MetricRef;
2837
/// Closed time interval for a time-series scan.
29-
#[derive(Debug, Clone)] pub struct TimeRange;
38+
#[derive(Debug, Clone)]
39+
pub struct TimeRange;
3040
/// Label matchers applied to a time-series scan.
31-
#[derive(Debug, Clone)] pub struct LabelFilter;
41+
#[derive(Debug, Clone)]
42+
pub struct LabelFilter;
3243
/// Reference to a relational table by name.
33-
#[derive(Debug, Clone)] pub struct TableRef;
44+
#[derive(Debug, Clone)]
45+
pub struct TableRef;
3446
/// Join key specification (USING / ON column reference).
35-
#[derive(Debug, Clone)] pub struct JoinKey;
47+
#[derive(Debug, Clone)]
48+
pub struct JoinKey;
3649

3750
// ── Enum supporting types ─────────────────────────────────────────────────────
3851

@@ -55,20 +68,39 @@ pub enum SetOpKind {
5568
#[derive(Debug, Clone, PartialEq, Eq)]
5669
pub enum BinaryOpKind {
5770
// Arithmetic
58-
Add, Sub, Mul, Div, Mod,
71+
Add,
72+
Sub,
73+
Mul,
74+
Div,
75+
Mod,
5976
// Comparison
60-
Eq, NotEq, Lt, LtEq, Gt, GtEq,
77+
Eq,
78+
NotEq,
79+
Lt,
80+
LtEq,
81+
Gt,
82+
GtEq,
6183
// Boolean / PromQL set operators
62-
And, Or, Unless,
84+
And,
85+
Or,
86+
Unless,
6387
}
6488

6589
#[derive(Debug, Clone, PartialEq, Eq)]
6690
pub enum WindowFuncKind {
67-
RowNumber, Rank, DenseRank,
68-
Lag, Lead,
69-
FirstValue, LastValue,
91+
RowNumber,
92+
Rank,
93+
DenseRank,
94+
Lag,
95+
Lead,
96+
FirstValue,
97+
LastValue,
7098
NthValue(u64),
71-
Sum, Avg, Count, Min, Max,
99+
Sum,
100+
Avg,
101+
Count,
102+
Min,
103+
Max,
72104
}
73105

74106
/// Which data model a `Source` or `AggIntent` operates over.
@@ -141,23 +173,38 @@ impl Source {
141173
#[derive(Debug, Clone)]
142174
pub enum AggIntent {
143175
// ── Data-model-agnostic ───────────────────────────────────────────────────
144-
Count { accuracy: AccuracyTarget },
176+
Count {
177+
accuracy: AccuracyTarget,
178+
},
145179
Sum,
146180
Min,
147181
Max,
148-
Quantile { q: f64, accuracy: AccuracyTarget },
182+
Quantile {
183+
q: f64,
184+
accuracy: AccuracyTarget,
185+
},
149186
/// Heavy-hitter top-k. Distinct from generic `Sort + Limit` — a
150187
/// dedicated sketch (SpaceSaving, CMS-with-heap) computes it as a single
151188
/// primitive. Recognised by L1→L2→L3 lowering on `ORDER BY count DESC
152189
/// LIMIT k` / PromQL `topk(k, …)`.
153-
TopK { k: usize, by: Vec<ColumnRef>, accuracy: AccuracyTarget },
154-
Cardinality { accuracy: AccuracyTarget },
190+
TopK {
191+
k: usize,
192+
by: Vec<ColumnRef>,
193+
accuracy: AccuracyTarget,
194+
},
195+
Cardinality {
196+
accuracy: AccuracyTarget,
197+
},
155198

156199
// ── Time-series streaming derivatives ────────────────────────────────────
157200
// Include PromQL counter-reset adjustment; not equivalent to Sum/Count
158201
// over a Window. Kept distinct so delta-set aggregators bind directly.
159-
Rate { window: Duration },
160-
Increase { window: Duration },
202+
Rate {
203+
window: Duration,
204+
},
205+
Increase {
206+
window: Duration,
207+
},
161208
}
162209

163210
impl AggIntent {
@@ -197,15 +244,24 @@ pub struct L3Node {
197244
pub enum QueryExpr {
198245
// ── Base relations ────────────────────────────────────────────────────────
199246
/// Outermost leaf. `source` carries the data-model-specific leaf shape.
200-
Scan { source: Source, predicates: Vec<Predicate> },
247+
Scan {
248+
source: Source,
249+
predicates: Vec<Predicate>,
250+
},
201251
/// Reference to a named `LetBinding` sub-expression; resolved at plan time.
202252
Ref(String),
203253

204254
// ── Filtering & projection ────────────────────────────────────────────────
205255
/// σ — row-level filter. Output schema = child schema (unchanged).
206-
Filter { child: Rc<L3Node>, pred: Predicate },
256+
Filter {
257+
child: Rc<L3Node>,
258+
pred: Predicate,
259+
},
207260
/// π — column projection. Output schema = child schema projected to `cols`.
208-
Project { child: Rc<L3Node>, cols: Vec<ProjectItem> },
261+
Project {
262+
child: Rc<L3Node>,
263+
cols: Vec<ProjectItem>,
264+
},
209265

210266
// ── Aggregation ───────────────────────────────────────────────────────────
211267
/// γ + α — GROUP BY + aggregate intents. Concrete operator (HashAgg /
@@ -231,13 +287,21 @@ pub enum QueryExpr {
231287
// ── Distributed-execution structure ───────────────────────────────────────
232288
/// Logical-only partitioning marker. Output schema = child schema.
233289
/// Carries a sharding hint for the L5 stage allocator.
234-
Partition { child: Rc<L3Node>, keys: PartitionKeys },
290+
Partition {
291+
child: Rc<L3Node>,
292+
keys: PartitionKeys,
293+
},
235294
/// δ — SQL `DISTINCT` / row deduplication.
236-
Distinct { child: Rc<L3Node>, cols: Vec<ColumnRef> },
295+
Distinct {
296+
child: Rc<L3Node>,
297+
cols: Vec<ColumnRef>,
298+
},
237299
/// ⊕ — exact union of sub-results from independent stages or shards.
238300
/// Sketch unions are a separate node in `SummaryExpr` because they carry
239301
/// sketch-family / params type constraints.
240-
Merge { children: Vec<Rc<L3Node>> },
302+
Merge {
303+
children: Vec<Rc<L3Node>>,
304+
},
241305

242306
// ── Joins ─────────────────────────────────────────────────────────────────
243307
/// Logical join. L4 picks the physical alternative (HashJoin /
@@ -261,11 +325,21 @@ pub enum QueryExpr {
261325
// ── Ordering & limiting ───────────────────────────────────────────────────
262326
/// Generic order-by for non-heavy-hitter cases (`ORDER BY name LIMIT 10`).
263327
/// Heavy-hitter shapes lower to `AggIntent::TopK` instead.
264-
Sort { child: Rc<L3Node>, keys: Vec<SortKey> },
265-
Limit { child: Rc<L3Node>, n: u64, offset: u64 },
328+
Sort {
329+
child: Rc<L3Node>,
330+
keys: Vec<SortKey>,
331+
},
332+
Limit {
333+
child: Rc<L3Node>,
334+
n: u64,
335+
offset: u64,
336+
},
266337

267338
// ── Subquery / CTE ────────────────────────────────────────────────────────
268-
Subquery { child: Rc<L3Node>, alias: String },
339+
Subquery {
340+
child: Rc<L3Node>,
341+
alias: String,
342+
},
269343
/// SQL `WITH name AS (expr) … body`; lowering target for PromQL
270344
/// recording-rule bindings. The `expr` sub-DAG may be referenced N times
271345
/// via `Ref(name)` in `body`, giving the DAG its fan-in.

‎crates/core/src/intent_algebra/mod.rs‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ pub mod schema;
33

44
pub use expr::{
55
AggIntent, BinaryOpKind, ColumnRef, DataModel, GroupKey, JoinKey, JoinKind, L3Node,
6-
LabelFilter, MetricRef, PartitionKeys, Predicate, ProjectItem, QueryExpr, SetOpKind,
7-
SortKey, Source, TableRef, TimeRange, TimeWindowKind, VectorMatch, WindowFrame,
8-
WindowFuncKind,
6+
LabelFilter, MetricRef, PartitionKeys, Predicate, ProjectItem, QueryExpr, SetOpKind, SortKey,
7+
Source, TableRef, TimeRange, TimeWindowKind, VectorMatch, WindowFrame, WindowFuncKind,
98
};
109
pub use schema::{HasSchema, L3DataType, L3Field, L3Schema, SchemaCatalog};

‎crates/core/src/sketch_algebra/expr.rs‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::rc::Rc;
22

3-
use crate::intent_algebra::{ColumnRef, GroupKey, L3Node};
43
use super::schema::L4Schema;
5-
use super::sketch::{SummaryKind, SummaryParams, SketchQuery};
4+
use super::sketch::{SketchQuery, SummaryKind, SummaryParams};
5+
use crate::intent_algebra::{ColumnRef, GroupKey, L3Node};
66

77
// ── L4 DAG node ───────────────────────────────────────────────────────────────
88

@@ -63,10 +63,7 @@ pub enum SummaryExpr {
6363
/// linear-inverse property (CMS, theta, count-based). Catalog flag
6464
/// `subtractable` must be true for the sketch family.
6565
/// Output schema: one `Sketch(s, p)` field (same family + params as inputs).
66-
SummarySubtract {
67-
left: Rc<L4Node>,
68-
right: Rc<L4Node>,
69-
},
66+
SummarySubtract { left: Rc<L4Node>, right: Rc<L4Node> },
7067

7168
/// Delete a key from a sketch (CMS update with −1, deletable Bloom
7269
/// filter). Catalog flag `deletable` must be true. Output schema =
@@ -90,7 +87,5 @@ pub enum SummaryExpr {
9087
/// agree on `(sketch, params)` and the catalog flag `mergeable` must
9188
/// be true. Inserted by the L5 stage allocator on cut edges.
9289
/// Output schema: one `Sketch(s, p)` field (same family + params as inputs).
93-
SummaryMerge {
94-
children: Vec<Rc<L4Node>>,
95-
},
90+
SummaryMerge { children: Vec<Rc<L4Node>> },
9691
}

‎crates/core/src/sketch_algebra/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ pub mod sketch;
44

55
pub use expr::{L4Node, SummaryExpr};
66
pub use schema::{L4DataType, L4Field, L4Schema};
7-
pub use sketch::{SummaryKind, SummaryParams, SketchQuery};
7+
pub use sketch::{SketchQuery, SummaryKind, SummaryParams};

‎crates/core/src/sketch_algebra/schema.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::intent_algebra::L3DataType;
21
use super::sketch::{SummaryKind, SummaryParams};
2+
use crate::intent_algebra::L3DataType;
33

44
// ── L4 data types ─────────────────────────────────────────────────────────────
55

‎crates/core/src/sketch_algebra/sketch.rs‎

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,30 @@ pub enum SummaryParams {
5050
Increase,
5151
Rate,
5252
// Approximate sketches — algorithm-specific tuning parameters
53-
Kll { k: u32 },
54-
Cms { width: u32, depth: u32 },
55-
Hll { precision: u8 },
56-
DDSketch { alpha: f64 },
57-
CmsWithHeap { width: u32, depth: u32, heap_size: u32 },
58-
Kmv { k: u32 },
59-
Theta { k: u32 },
53+
Kll {
54+
k: u32,
55+
},
56+
Cms {
57+
width: u32,
58+
depth: u32,
59+
},
60+
Hll {
61+
precision: u8,
62+
},
63+
DDSketch {
64+
alpha: f64,
65+
},
66+
CmsWithHeap {
67+
width: u32,
68+
depth: u32,
69+
heap_size: u32,
70+
},
71+
Kmv {
72+
k: u32,
73+
},
74+
Theta {
75+
k: u32,
76+
},
6077
}
6178

6279
// ── Sketch read-out queries ───────────────────────────────────────────────────

0 commit comments

Comments
 (0)