Skip to main content

icydb_core/db/query/plan/
executable.rs

1use crate::{
2    db::query::{
3        QueryMode,
4        plan::{ExplainPlan, LogicalPlan, PlanFingerprint},
5    },
6    traits::EntityKind,
7};
8use std::marker::PhantomData;
9
10///
11/// ExecutablePlan
12///
13/// Executor-ready plan bound to a specific entity type.
14///
15
16pub struct ExecutablePlan<E: EntityKind> {
17    plan: LogicalPlan,
18    _marker: PhantomData<E>,
19}
20
21impl<E: EntityKind> ExecutablePlan<E> {
22    pub(crate) const fn new(plan: LogicalPlan) -> Self {
23        Self {
24            plan,
25            _marker: PhantomData,
26        }
27    }
28
29    /// Explain this plan without executing it.
30    #[must_use]
31    pub fn explain(&self) -> ExplainPlan {
32        self.plan.explain()
33    }
34
35    /// Compute a stable fingerprint for this plan.
36    #[must_use]
37    pub fn fingerprint(&self) -> PlanFingerprint {
38        self.plan.fingerprint()
39    }
40
41    /// Return the plan mode (load vs delete).
42    #[must_use]
43    pub(crate) const fn mode(&self) -> QueryMode {
44        self.plan.mode
45    }
46
47    pub(crate) const fn access(&self) -> &crate::db::query::plan::AccessPlan {
48        &self.plan.access
49    }
50
51    pub(crate) fn into_inner(self) -> LogicalPlan {
52        self.plan
53    }
54}