Skip to main content

icydb_core/db/query/plan/
model_builder.rs

1//! Module: query::plan::model_builder
2//! Responsibility: pure logical plan-model constructors/builders.
3//! Does not own: access-plan coupling or semantic interpretation.
4//! Boundary: model-only helpers that remain independent of access planning.
5
6use crate::db::query::plan::{DeleteSpec, FieldSlot, GroupedExecutionConfig, LoadSpec};
7
8impl LoadSpec {
9    /// Create an empty load spec.
10    #[must_use]
11    pub const fn new() -> Self {
12        Self {
13            limit: None,
14            offset: 0,
15        }
16    }
17}
18
19impl DeleteSpec {
20    /// Create an empty delete spec.
21    #[must_use]
22    pub const fn new() -> Self {
23        Self {
24            limit: None,
25            offset: 0,
26        }
27    }
28}
29
30impl FieldSlot {
31    /// Build one field slot directly for tests that need custom slot shapes.
32    #[cfg(test)]
33    #[must_use]
34    pub(in crate::db) fn from_test_slot(index: usize, field: impl Into<String>) -> Self {
35        Self::unresolved(index, field)
36    }
37}
38
39impl GroupedExecutionConfig {
40    /// Build one grouped execution config with explicit hard limits.
41    #[must_use]
42    pub(in crate::db) const fn with_hard_limits(max_groups: u64, max_group_bytes: u64) -> Self {
43        Self {
44            max_groups,
45            max_group_bytes,
46        }
47    }
48
49    /// Build one unbounded grouped execution config.
50    #[must_use]
51    pub(in crate::db) const fn unbounded() -> Self {
52        Self::with_hard_limits(u64::MAX, u64::MAX)
53    }
54
55    /// Return grouped hard limit for maximum groups.
56    #[must_use]
57    pub(in crate::db) const fn max_groups(&self) -> u64 {
58        self.max_groups
59    }
60
61    /// Return grouped hard limit for estimated grouped bytes.
62    #[must_use]
63    pub(in crate::db) const fn max_group_bytes(&self) -> u64 {
64        self.max_group_bytes
65    }
66}
67
68impl Default for GroupedExecutionConfig {
69    fn default() -> Self {
70        Self::unbounded()
71    }
72}