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
16#[derive(Debug)]
17pub struct ExecutablePlan<E: EntityKind> {
18    plan: LogicalPlan,
19    _marker: PhantomData<E>,
20}
21
22impl<E: EntityKind> ExecutablePlan<E> {
23    pub(crate) const fn new(plan: LogicalPlan) -> Self {
24        Self {
25            plan,
26            _marker: PhantomData,
27        }
28    }
29
30    /// Explain this plan without executing it.
31    #[must_use]
32    pub fn explain(&self) -> ExplainPlan {
33        self.plan.explain()
34    }
35
36    /// Compute a stable fingerprint for this plan.
37    #[must_use]
38    pub fn fingerprint(&self) -> PlanFingerprint {
39        self.plan.fingerprint()
40    }
41
42    /// Return the plan mode (load vs delete).
43    #[must_use]
44    pub(crate) const fn mode(&self) -> QueryMode {
45        self.plan.mode
46    }
47
48    pub(crate) const fn access(&self) -> &crate::db::query::plan::AccessPlan {
49        &self.plan.access
50    }
51
52    pub(crate) fn into_inner(self) -> LogicalPlan {
53        self.plan
54    }
55}