vortex_array/aggregate_fn/
plugin.rs1use std::sync::Arc;
5
6use vortex_error::VortexResult;
7use vortex_session::VortexSession;
8
9use crate::aggregate_fn::AggregateFn;
10use crate::aggregate_fn::AggregateFnId;
11use crate::aggregate_fn::AggregateFnRef;
12use crate::aggregate_fn::AggregateFnVTable;
13
14pub type AggregateFnPluginRef = Arc<dyn AggregateFnPlugin>;
16
17pub trait AggregateFnPlugin: 'static + Send + Sync {
25 fn id(&self) -> AggregateFnId;
27
28 fn deserialize(&self, metadata: &[u8], session: &VortexSession)
30 -> VortexResult<AggregateFnRef>;
31}
32
33impl std::fmt::Debug for dyn AggregateFnPlugin {
34 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35 f.debug_tuple("AggregateFnPlugin")
36 .field(&self.id())
37 .finish()
38 }
39}
40
41impl<V: AggregateFnVTable> AggregateFnPlugin for V {
42 fn id(&self) -> AggregateFnId {
43 AggregateFnVTable::id(self)
44 }
45
46 fn deserialize(
47 &self,
48 metadata: &[u8],
49 session: &VortexSession,
50 ) -> VortexResult<AggregateFnRef> {
51 let options = AggregateFnVTable::deserialize(self, metadata, session)?;
52 Ok(AggregateFn::new(self.clone(), options).erased())
53 }
54}