use std::sync::Arc;
use vortex_session::Ref;
use vortex_session::SessionExt;
use vortex_session::registry::Registry;
use crate::arrays::Bool;
use crate::arrays::Chunked;
use crate::arrays::Constant;
use crate::arrays::Decimal;
use crate::arrays::Extension;
use crate::arrays::FixedSizeList;
use crate::arrays::List;
use crate::arrays::ListView;
use crate::arrays::Masked;
use crate::arrays::Null;
use crate::arrays::Primitive;
use crate::arrays::Struct;
use crate::arrays::VarBin;
use crate::arrays::VarBinView;
use crate::vtable::DynVTableRef;
use crate::vtable::VTable;
pub type ArrayRegistry = Registry<DynVTableRef>;
#[derive(Debug)]
pub struct ArraySession {
registry: ArrayRegistry,
}
impl ArraySession {
pub fn empty() -> ArraySession {
Self {
registry: ArrayRegistry::default(),
}
}
pub fn registry(&self) -> &ArrayRegistry {
&self.registry
}
pub fn register<V: VTable>(&self, vtable: V) {
self.registry
.register(vtable.id(), Arc::new(vtable) as DynVTableRef);
}
}
impl Default for ArraySession {
fn default() -> Self {
let this = ArraySession {
registry: ArrayRegistry::default(),
};
this.register(Null);
this.register(Bool);
this.register(Primitive);
this.register(Decimal);
this.register(VarBinView);
this.register(ListView);
this.register(FixedSizeList);
this.register(Struct);
this.register(Extension);
this.register(Chunked);
this.register(Constant);
this.register(Masked);
this.register(List);
this.register(VarBin);
this
}
}
pub trait ArraySessionExt: SessionExt {
fn arrays(&self) -> Ref<'_, ArraySession> {
self.get::<ArraySession>()
}
}
impl<S: SessionExt> ArraySessionExt for S {}