use std::fmt::Debug;
use std::pin::Pin;
use std::sync::Arc;
use futures::Stream;
use crate::err::Error;
pub(crate) use crate::expr::{ControlFlowExt, FlowResult, FlowResultExt};
use crate::val::Value;
#[cfg(target_family = "wasm")]
pub(crate) trait SendSyncRequirement {}
#[cfg(target_family = "wasm")]
impl<T> SendSyncRequirement for T {}
#[cfg(not(target_family = "wasm"))]
pub(crate) trait SendSyncRequirement: Send + Sync {}
#[cfg(not(target_family = "wasm"))]
impl<T: Send + Sync> SendSyncRequirement for T {}
#[cfg(target_family = "wasm")]
pub(crate) type BoxFut<'a, T> = Pin<Box<dyn std::future::Future<Output = T> + 'a>>;
#[cfg(not(target_family = "wasm"))]
pub(crate) type BoxFut<'a, T> = Pin<Box<dyn std::future::Future<Output = T> + Send + 'a>>;
pub(crate) mod access_mode;
pub(crate) mod buffer;
pub(crate) mod cardinality;
pub(crate) mod context;
pub(crate) mod expression_registry;
pub(crate) mod field_path;
pub(crate) mod function;
pub(crate) mod index;
pub(crate) mod metrics;
pub(crate) mod operators;
pub(crate) mod ordering;
pub(crate) mod parts;
pub(crate) mod permission;
pub(crate) mod physical_expr;
pub(crate) mod plan_or_compute;
pub(crate) mod planner;
pub(crate) mod pre_decode_filter;
pub(crate) mod topk_pushdown;
pub(crate) use access_mode::{AccessMode, CombineAccessModes};
pub(crate) use buffer::buffer_stream;
pub(crate) use cardinality::CardinalityHint;
pub(crate) use context::{ContextLevel, DatabaseContext, ExecutionContext};
pub(crate) use metrics::{OperatorMetrics, monitor_stream};
pub(crate) use ordering::OutputOrdering;
pub(crate) use physical_expr::{EvalContext, PhysicalExpr};
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct ValueBatch {
pub(crate) values: Vec<Value>,
}
#[cfg(target_family = "wasm")]
pub(crate) type ValueBatchStream = Pin<Box<dyn Stream<Item = FlowResult<ValueBatch>>>>;
#[cfg(not(target_family = "wasm"))]
pub(crate) type ValueBatchStream = Pin<Box<dyn Stream<Item = FlowResult<ValueBatch>> + Send>>;
pub(crate) trait ExecOperator: Debug + SendSyncRequirement {
fn name(&self) -> &'static str;
fn attrs(&self) -> Vec<(String, String)> {
vec![]
}
fn required_context(&self) -> ContextLevel;
fn execute(&self, ctx: &ExecutionContext) -> FlowResult<ValueBatchStream>;
fn children(&self) -> Vec<&Arc<dyn ExecOperator>> {
vec![]
}
fn mutates_context(&self) -> bool {
false
}
fn output_context<'a>(
&'a self,
input: &'a ExecutionContext,
) -> BoxFut<'a, Result<ExecutionContext, Error>> {
Box::pin(async move { Ok(input.clone()) })
}
fn access_mode(&self) -> AccessMode;
fn cardinality_hint(&self) -> CardinalityHint {
CardinalityHint::Unbounded
}
fn is_scalar(&self) -> bool {
false
}
fn metrics(&self) -> Option<&OperatorMetrics> {
None
}
fn enable_metrics(&self) {
if let Some(m) = self.metrics() {
m.enable();
}
for child in self.children() {
child.enable_metrics();
}
}
fn expressions(&self) -> Vec<(&str, &Arc<dyn PhysicalExpr>)> {
vec![]
}
fn output_ordering(&self) -> OutputOrdering {
OutputOrdering::Unordered
}
fn constant_output_fields(&self) -> Vec<crate::exec::field_path::FieldPath> {
vec![]
}
}