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 { limit: None }
24    }
25}
26
27impl FieldSlot {
28    /// Build one field slot directly for tests that need invalid slot shapes.
29    #[cfg(test)]
30    #[must_use]
31    pub(crate) fn from_parts_for_test(index: usize, field: impl Into<String>) -> Self {
32        Self {
33            index,
34            field: field.into(),
35        }
36    }
37}
38
39impl GroupedExecutionConfig {
40    /// Build one grouped execution config with explicit hard limits.
41    #[must_use]
42    pub(crate) 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(crate) 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(crate) 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(crate) 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}