use std::collections::HashMap;
use crate::sharding::ShardCoordinator;
use crate::storage::StorageEngine;
use crate::sync::log::SyncLog;
mod aggregation;
pub mod builtins;
mod catalog;
mod data_source;
mod evaluate;
mod execution;
mod explain;
mod expression;
mod helpers;
mod index_opt;
mod materialized_views;
pub mod phonetic;
pub mod types;
pub mod utils;
mod window;
pub use helpers::{
compare_key_rows, compare_values, evaluate_binary_op, evaluate_unary_op, get_field_ref,
get_field_value, hash_value, to_bool, values_equal, ValueSet,
};
pub use types::*;
pub use utils::*;
pub use window::{contains_window_functions, extract_window_functions, generate_window_key};
pub struct QueryExecutor<'a> {
pub(super) storage: &'a StorageEngine,
pub(super) bind_vars: BindVars,
pub(super) database: Option<String>,
pub(super) replication: Option<&'a SyncLog>,
pub(super) shard_coordinator: Option<std::sync::Arc<ShardCoordinator>>,
pub(super) principal: Option<QueryPrincipal>,
}
impl<'a> QueryExecutor<'a> {
pub fn new(storage: &'a StorageEngine) -> Self {
Self {
storage,
bind_vars: HashMap::new(),
database: None,
replication: None,
shard_coordinator: None,
principal: None,
}
}
pub fn with_bind_vars(storage: &'a StorageEngine, bind_vars: BindVars) -> Self {
Self {
storage,
bind_vars,
database: None,
replication: None,
shard_coordinator: None,
principal: None,
}
}
pub fn with_database(storage: &'a StorageEngine, database: String) -> Self {
Self {
storage,
bind_vars: HashMap::new(),
database: Some(database),
replication: None,
shard_coordinator: None,
principal: None,
}
}
pub fn with_database_and_bind_vars(
storage: &'a StorageEngine,
database: String,
bind_vars: BindVars,
) -> Self {
Self {
storage,
bind_vars,
database: Some(database),
replication: None,
shard_coordinator: None,
principal: None,
}
}
pub fn with_replication(mut self, replication: &'a SyncLog) -> Self {
self.replication = Some(replication);
self
}
pub fn with_shard_coordinator(mut self, coordinator: std::sync::Arc<ShardCoordinator>) -> Self {
self.shard_coordinator = Some(coordinator);
self
}
pub fn with_principal(mut self, principal: QueryPrincipal) -> Self {
self.principal = Some(principal);
self
}
}