@@ -8,7 +8,6 @@ use arc_swap::ArcSwap;
88use vortex_session:: Ref ;
99use vortex_session:: SessionExt ;
1010use vortex_session:: SessionVar ;
11- use vortex_session:: registry:: Registry ;
1211use vortex_utils:: aliases:: hash_map:: HashMap ;
1312
1413use crate :: aggregate_fn:: AggregateFnId ;
@@ -43,16 +42,13 @@ use crate::arrays::dict::compute::is_constant::DictIsConstantKernel;
4342use crate :: arrays:: dict:: compute:: is_sorted:: DictIsSortedKernel ;
4443use crate :: arrays:: dict:: compute:: min_max:: DictMinMaxKernel ;
4544
46- /// Registry of aggregate function vtables.
47- pub type AggregateFnRegistry = Registry < AggregateFnPluginRef > ;
48-
4945/// Session state for aggregate function vtables.
5046#[ derive( Debug ) ]
5147pub struct AggregateFnSession {
5248 registry : ArcSwap < HashMap < AggregateFnId , AggregateFnPluginRef > > ,
5349
54- pub ( super ) kernels : ArcSwap < HashMap < KernelKey , & ' static dyn DynAggregateKernel > > ,
55- pub ( super ) grouped_kernels : ArcSwap < HashMap < KernelKey , & ' static dyn DynGroupedAggregateKernel > > ,
50+ kernels : ArcSwap < HashMap < KernelKey , & ' static dyn DynAggregateKernel > > ,
51+ grouped_kernels : ArcSwap < HashMap < KernelKey , & ' static dyn DynGroupedAggregateKernel > > ,
5652}
5753
5854impl SessionVar for AggregateFnSession {
@@ -106,7 +102,7 @@ impl Default for AggregateFnSession {
106102}
107103
108104impl AggregateFnSession {
109- /// Returns the aggregate function registry.
105+ /// Find plugin in the registry for the given id
110106 pub fn find_plugin ( & self , id : & AggregateFnId ) -> Option < AggregateFnPluginRef > {
111107 self . registry . load ( ) . get ( id) . cloned ( )
112108 }
@@ -123,6 +119,20 @@ impl AggregateFnSession {
123119 } ) ;
124120 }
125121
122+ pub fn find_aggregate_kernel (
123+ & self ,
124+ array_id : impl Into < ArrayId > ,
125+ agg_fn_id : impl Into < AggregateFnId > ,
126+ ) -> Option < & ' static dyn DynAggregateKernel > {
127+ let loaded = self . kernels . load ( ) ;
128+ let id = array_id. into ( ) ;
129+ let fn_id = agg_fn_id. into ( ) ;
130+ loaded
131+ . get ( & ( id, Some ( fn_id) ) )
132+ . or_else ( || loaded. get ( & ( id, None ) ) )
133+ . copied ( )
134+ }
135+
126136 /// Register an aggregate function kernel for a specific aggregate function and array type.
127137 pub fn register_aggregate_kernel (
128138 & self ,
@@ -137,6 +147,20 @@ impl AggregateFnSession {
137147 existing
138148 } ) ;
139149 }
150+
151+ pub fn find_groupped_kernel (
152+ & self ,
153+ array_id : impl Into < ArrayId > ,
154+ agg_fn_id : impl Into < AggregateFnId > ,
155+ ) -> Option < & ' static dyn DynGroupedAggregateKernel > {
156+ let loaded = self . grouped_kernels . load ( ) ;
157+ let id = array_id. into ( ) ;
158+ let fn_id = agg_fn_id. into ( ) ;
159+ loaded
160+ . get ( & ( id, Some ( fn_id) ) )
161+ . or_else ( || loaded. get ( & ( id, None ) ) )
162+ . copied ( )
163+ }
140164}
141165
142166/// Extension trait for accessing aggregate function session data.
0 commit comments