use std::sync::Arc;
use vortex_session::Ref;
use vortex_session::SessionExt;
use vortex_session::registry::Registry;
use crate::scalar_fn::ScalarFnPluginRef;
use crate::scalar_fn::ScalarFnVTable;
use crate::scalar_fn::fns::between::Between;
use crate::scalar_fn::fns::binary::Binary;
use crate::scalar_fn::fns::cast::Cast;
use crate::scalar_fn::fns::fill_null::FillNull;
use crate::scalar_fn::fns::get_item::GetItem;
use crate::scalar_fn::fns::is_null::IsNull;
use crate::scalar_fn::fns::like::Like;
use crate::scalar_fn::fns::list_contains::ListContains;
use crate::scalar_fn::fns::literal::Literal;
use crate::scalar_fn::fns::merge::Merge;
use crate::scalar_fn::fns::not::Not;
use crate::scalar_fn::fns::pack::Pack;
use crate::scalar_fn::fns::root::Root;
use crate::scalar_fn::fns::select::Select;
pub type ScalarFnRegistry = Registry<ScalarFnPluginRef>;
#[derive(Debug)]
pub struct ScalarFnSession {
registry: ScalarFnRegistry,
}
impl ScalarFnSession {
pub fn registry(&self) -> &ScalarFnRegistry {
&self.registry
}
pub fn register<V: ScalarFnVTable>(&self, vtable: V) {
self.registry
.register(vtable.id(), Arc::new(vtable) as ScalarFnPluginRef);
}
}
impl Default for ScalarFnSession {
fn default() -> Self {
let this = Self {
registry: ScalarFnRegistry::default(),
};
this.register(Between);
this.register(Binary);
this.register(Cast);
this.register(FillNull);
this.register(GetItem);
this.register(IsNull);
this.register(Like);
this.register(ListContains);
this.register(Literal);
this.register(Merge);
this.register(Not);
this.register(Pack);
this.register(Root);
this.register(Select);
this
}
}
pub trait ScalarFnSessionExt: SessionExt {
fn scalar_fns(&self) -> Ref<'_, ScalarFnSession> {
self.get::<ScalarFnSession>()
}
}
impl<S: SessionExt> ScalarFnSessionExt for S {}