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 invalid slot shapes.
32    #[cfg(test)]
33    #[must_use]
34    pub(crate) fn from_parts_for_test(index: usize, field: impl Into<String>) -> Self {
35        Self {
36            index,
37            field: field.into(),
38            kind: None,
39        }
40    }
41}
42
43impl GroupedExecutionConfig {
44    /// Build one grouped execution config with explicit hard limits.
45    #[must_use]
46    pub(crate) const fn with_hard_limits(max_groups: u64, max_group_bytes: u64) -> Self {
47        Self {
48            max_groups,
49            max_group_bytes,
50        }
51    }
52
53    /// Build one unbounded grouped execution config.
54    #[must_use]
55    pub(crate) const fn unbounded() -> Self {
56        Self::with_hard_limits(u64::MAX, u64::MAX)
57    }
58
59    /// Return grouped hard limit for maximum groups.
60    #[must_use]
61    pub(crate) const fn max_groups(&self) -> u64 {
62        self.max_groups
63    }
64
65    /// Return grouped hard limit for estimated grouped bytes.
66    #[must_use]
67    pub(crate) const fn max_group_bytes(&self) -> u64 {
68        self.max_group_bytes
69    }
70}
71
72impl Default for GroupedExecutionConfig {
73    fn default() -> Self {
74        Self::unbounded()
75    }
76}