mod grouped;
mod scalar;
#[cfg(all(feature = "sql", feature = "perf-attribution"))]
use crate::{
db::{
Db,
executor::{
EntityAuthority,
pipeline::contracts::{ProjectionMaterializationMode, StructuralCursorPage},
},
query::plan::AccessPlannedQuery,
},
traits::CanisterKind,
};
use crate::{
db::{
PersistedRow,
cursor::{GroupedPlannedCursor, PlannedCursor},
executor::{
ExecutablePlan, ExecutionTrace, LoadCursorInput,
pipeline::contracts::{CursorPage, GroupedCursorPage, LoadExecutor},
},
response::EntityResponse,
},
error::InternalError,
traits::EntityValue,
};
pub(in crate::db::executor) use crate::db::executor::pipeline::orchestrator::{
LoadExecutionMode, LoadTracingMode,
};
#[cfg(test)]
pub(in crate::db::executor) use crate::db::executor::pipeline::orchestrator::{
load_execute_stage_order_guard, load_pipeline_state_optional_slot_count_guard,
};
#[cfg(feature = "sql")]
pub(in crate::db) use grouped::execute_initial_grouped_rows_for_canister;
pub(in crate::db::executor) use grouped::{
PreparedGroupedRouteRuntime, execute_prepared_grouped_route_runtime,
};
pub(in crate::db::executor) use scalar::{
PreparedScalarMaterializedBoundary, PreparedScalarRouteRuntime,
execute_prepared_scalar_route_runtime, execute_prepared_scalar_rows_for_canister,
};
#[cfg(feature = "sql")]
pub(in crate::db) use scalar::{
execute_initial_scalar_sql_projection_rows_for_canister,
execute_initial_scalar_sql_projection_text_rows_for_canister,
};
#[cfg(all(feature = "sql", feature = "perf-attribution"))]
pub(in crate::db) fn execute_initial_scalar_sql_projection_page_for_canister<C>(
db: &Db<C>,
debug: bool,
authority: EntityAuthority,
plan: AccessPlannedQuery,
projection_runtime_mode: ProjectionMaterializationMode,
) -> Result<StructuralCursorPage, InternalError>
where
C: CanisterKind,
{
scalar::execute_initial_scalar_sql_projection_page_for_canister(
db,
debug,
authority,
plan,
projection_runtime_mode,
)
}
impl<E> LoadExecutor<E>
where
E: PersistedRow + EntityValue,
{
pub(crate) fn execute(
&self,
plan: ExecutablePlan<E>,
) -> Result<EntityResponse<E>, InternalError> {
let page = execute_prepared_scalar_rows_for_canister(
&self.db,
self.debug,
plan.into_prepared_load_plan(),
)?;
page.into_entity_response::<E>()
}
pub(in crate::db) fn execute_paged_with_cursor_traced(
&self,
plan: ExecutablePlan<E>,
cursor: impl Into<PlannedCursor>,
) -> Result<(CursorPage<E>, Option<ExecutionTrace>), InternalError> {
self.execute_load_scalar_page_with_trace(
plan.into_prepared_load_plan(),
LoadCursorInput::scalar(cursor),
)
}
#[cfg(test)]
pub(in crate::db) fn execute_paged_with_cursor(
&self,
plan: ExecutablePlan<E>,
cursor: impl Into<PlannedCursor>,
) -> Result<CursorPage<E>, InternalError> {
let (page, _) = self.execute_paged_with_cursor_traced(plan, cursor)?;
Ok(page)
}
pub(in crate::db) fn execute_grouped_paged_with_cursor_traced(
&self,
plan: ExecutablePlan<E>,
cursor: impl Into<GroupedPlannedCursor>,
) -> Result<(GroupedCursorPage, Option<ExecutionTrace>), InternalError> {
self.execute_load_grouped_page_with_trace(
plan.into_prepared_load_plan(),
LoadCursorInput::grouped(cursor),
)
}
}