use crate::db::query::{
builder::AggregateExpr,
plan::{AggregateKind, GroupedPlanStrategy},
};
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(in crate::db::executor) enum FastPathOrder {
PrimaryKey,
SecondaryPrefix,
PrimaryScan,
IndexRange,
Composite,
}
pub(in crate::db::executor) const LOAD_FAST_PATH_ORDER: [FastPathOrder; 3] = [
FastPathOrder::PrimaryKey,
FastPathOrder::SecondaryPrefix,
FastPathOrder::IndexRange,
];
pub(in crate::db::executor) const AGGREGATE_FAST_PATH_ORDER: [FastPathOrder; 5] = [
FastPathOrder::PrimaryKey,
FastPathOrder::SecondaryPrefix,
FastPathOrder::PrimaryScan,
FastPathOrder::IndexRange,
FastPathOrder::Composite,
];
pub(in crate::db::executor) const GROUPED_AGGREGATE_FAST_PATH_ORDER: [FastPathOrder; 0] = [];
pub(in crate::db::executor) const MUTATION_FAST_PATH_ORDER: [FastPathOrder; 0] = [];
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(in crate::db) struct AggregateRouteShape<'a> {
kind: AggregateKind,
target_field: Option<&'a str>,
}
impl<'a> AggregateRouteShape<'a> {
#[must_use]
pub(in crate::db) const fn new(kind: AggregateKind, target_field: Option<&'a str>) -> Self {
Self { kind, target_field }
}
#[must_use]
pub(in crate::db) fn from_aggregate_expr(aggregate: &'a AggregateExpr) -> Self {
Self::new(aggregate.kind(), aggregate.target_field())
}
#[must_use]
pub(in crate::db) const fn kind(self) -> AggregateKind {
self.kind
}
#[must_use]
pub(in crate::db) const fn target_field(self) -> Option<&'a str> {
self.target_field
}
}
pub(in crate::db::executor::route) enum RouteIntent<'a> {
Load,
Aggregate {
aggregate: AggregateRouteShape<'a>,
aggregate_force_materialized_due_to_predicate_uncertainty: bool,
},
AggregateGrouped {
grouped_plan_strategy: GroupedPlanStrategy,
aggregate_force_materialized_due_to_predicate_uncertainty: bool,
},
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(in crate::db::executor) enum RouteShapeKind {
LoadScalar,
AggregateCount,
AggregateNonCount,
AggregateGrouped,
MutationDelete,
}