use std::cmp::Ordering;
use selene_core::DbString;
use crate::{
GqlType, Literal, OrderDirection, SourceSpan,
analyze::BindingId,
plan::optimize::{IndexHandle, IndexKind},
};
#[derive(Clone, Debug, Default, PartialEq)]
#[non_exhaustive]
pub enum ScanAccess {
#[default]
Linear,
LabelIndex {
handle: IndexHandle,
},
TypedIndexRange {
handle: IndexHandle,
property: DbString,
kind: IndexKind,
bounds: TypedIndexBounds,
},
BitmapUnion {
handle: IndexHandle,
property: DbString,
kind: IndexKind,
keys: Vec<IndexKey>,
},
CompositeLookup {
handle: IndexHandle,
properties: Vec<(DbString, IndexKind)>,
keys: Vec<(DbString, IndexKey)>,
},
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum IndexKey {
Literal(Literal),
Parameter {
name: DbString,
declared_type: Option<GqlType>,
span: SourceSpan,
},
ParameterList {
name: DbString,
declared_type: GqlType,
span: SourceSpan,
},
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum TypedIndexBounds {
Equality(IndexKey),
GreaterThan(IndexKey),
GreaterEqual(IndexKey),
LessThan(IndexKey),
LessEqual(IndexKey),
Range {
lo: IndexKey,
lo_inclusive: bool,
hi: IndexKey,
hi_inclusive: bool,
},
}
#[derive(Clone, Debug, PartialEq)]
#[non_exhaustive]
pub enum OrderAccess {
TypedIndex {
handle: IndexHandle,
direction: OrderDirection,
},
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub struct NodeIdOrdering {
pub left: BindingId,
pub ordering: Ordering,
pub right: BindingId,
}