Skip to content

Commit 6d9bcac

Browse files
committed
Aggregate Fns
Signed-off-by: Nicholas Gates <[email protected]>
1 parent a17f2a8 commit 6d9bcac

5 files changed

Lines changed: 242 additions & 1 deletion

File tree

‎vortex-array/public-api.lock‎

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,178 @@ impl<T: vortex_array::dtype::NativePType> vortex_array::accessor::ArrayAccessor<
2626

2727
pub fn vortex_array::arrays::PrimitiveArray::with_iterator<F, R>(&self, f: F) -> R where F: for<'a> core::ops::function::FnOnce(&mut dyn core::iter::traits::iterator::Iterator<Item = core::option::Option<&'a T>>) -> R
2828

29+
pub mod vortex_array::aggregate_fn
30+
31+
pub mod vortex_array::aggregate_fn::fns
32+
33+
pub mod vortex_array::aggregate_fn::session
34+
35+
pub struct vortex_array::aggregate_fn::session::AggregateFnSession
36+
37+
impl vortex_array::aggregate_fn::session::AggregateFnSession
38+
39+
pub fn vortex_array::aggregate_fn::session::AggregateFnSession::register<V: vortex_array::aggregate_fn::AggregateFnVTable>(&self, vtable: V)
40+
41+
pub fn vortex_array::aggregate_fn::session::AggregateFnSession::registry(&self) -> &vortex_array::aggregate_fn::session::AggregateFnRegistry
42+
43+
impl core::default::Default for vortex_array::aggregate_fn::session::AggregateFnSession
44+
45+
pub fn vortex_array::aggregate_fn::session::AggregateFnSession::default() -> vortex_array::aggregate_fn::session::AggregateFnSession
46+
47+
impl core::fmt::Debug for vortex_array::aggregate_fn::session::AggregateFnSession
48+
49+
pub fn vortex_array::aggregate_fn::session::AggregateFnSession::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
50+
51+
pub trait vortex_array::aggregate_fn::session::AggregateFnSessionExt: vortex_session::SessionExt
52+
53+
pub fn vortex_array::aggregate_fn::session::AggregateFnSessionExt::aggregate_fns(&self) -> vortex_session::Ref<'_, vortex_array::aggregate_fn::session::AggregateFnSession>
54+
55+
impl<S: vortex_session::SessionExt> vortex_array::aggregate_fn::session::AggregateFnSessionExt for S
56+
57+
pub fn S::aggregate_fns(&self) -> vortex_session::Ref<'_, vortex_array::aggregate_fn::session::AggregateFnSession>
58+
59+
pub type vortex_array::aggregate_fn::session::AggregateFnRegistry = vortex_session::registry::Registry<vortex_array::aggregate_fn::AggregateFnPluginRef>
60+
61+
pub struct vortex_array::aggregate_fn::AggregateFn<V: vortex_array::aggregate_fn::AggregateFnVTable>(_)
62+
63+
impl<V: vortex_array::aggregate_fn::AggregateFnVTable> vortex_array::aggregate_fn::AggregateFn<V>
64+
65+
pub fn vortex_array::aggregate_fn::AggregateFn<V>::erased(self) -> vortex_array::aggregate_fn::AggregateFnRef
66+
67+
pub fn vortex_array::aggregate_fn::AggregateFn<V>::new(vtable: V, options: <V as vortex_array::aggregate_fn::AggregateFnVTable>::Options) -> Self
68+
69+
pub fn vortex_array::aggregate_fn::AggregateFn<V>::options(&self) -> &<V as vortex_array::aggregate_fn::AggregateFnVTable>::Options
70+
71+
pub fn vortex_array::aggregate_fn::AggregateFn<V>::vtable(&self) -> &V
72+
73+
pub struct vortex_array::aggregate_fn::AggregateFnOptions<'a>
74+
75+
impl vortex_array::aggregate_fn::AggregateFnOptions<'_>
76+
77+
pub fn vortex_array::aggregate_fn::AggregateFnOptions<'_>::serialize(&self) -> vortex_error::VortexResult<core::option::Option<alloc::vec::Vec<u8>>>
78+
79+
impl<'a> vortex_array::aggregate_fn::AggregateFnOptions<'a>
80+
81+
pub fn vortex_array::aggregate_fn::AggregateFnOptions<'a>::as_any(&self) -> &'a dyn core::any::Any
82+
83+
impl core::cmp::Eq for vortex_array::aggregate_fn::AggregateFnOptions<'_>
84+
85+
impl core::cmp::PartialEq for vortex_array::aggregate_fn::AggregateFnOptions<'_>
86+
87+
pub fn vortex_array::aggregate_fn::AggregateFnOptions<'_>::eq(&self, other: &Self) -> bool
88+
89+
impl core::fmt::Debug for vortex_array::aggregate_fn::AggregateFnOptions<'_>
90+
91+
pub fn vortex_array::aggregate_fn::AggregateFnOptions<'_>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
92+
93+
impl core::fmt::Display for vortex_array::aggregate_fn::AggregateFnOptions<'_>
94+
95+
pub fn vortex_array::aggregate_fn::AggregateFnOptions<'_>::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
96+
97+
impl core::hash::Hash for vortex_array::aggregate_fn::AggregateFnOptions<'_>
98+
99+
pub fn vortex_array::aggregate_fn::AggregateFnOptions<'_>::hash<H: core::hash::Hasher>(&self, state: &mut H)
100+
101+
pub struct vortex_array::aggregate_fn::AggregateFnRef(_)
102+
103+
impl vortex_array::aggregate_fn::AggregateFnRef
104+
105+
pub fn vortex_array::aggregate_fn::AggregateFnRef::accumulator(&self, input_dtype: &vortex_array::dtype::DType) -> vortex_error::VortexResult<alloc::boxed::Box<dyn vortex_array::aggregate_fn::Accumulator>>
106+
107+
pub fn vortex_array::aggregate_fn::AggregateFnRef::as_<V: vortex_array::aggregate_fn::AggregateFnVTable>(&self) -> &<V as vortex_array::aggregate_fn::AggregateFnVTable>::Options
108+
109+
pub fn vortex_array::aggregate_fn::AggregateFnRef::as_opt<V: vortex_array::aggregate_fn::AggregateFnVTable>(&self) -> core::option::Option<&<V as vortex_array::aggregate_fn::AggregateFnVTable>::Options>
110+
111+
pub fn vortex_array::aggregate_fn::AggregateFnRef::id(&self) -> vortex_array::aggregate_fn::AggregateFnId
112+
113+
pub fn vortex_array::aggregate_fn::AggregateFnRef::is<V: vortex_array::aggregate_fn::AggregateFnVTable>(&self) -> bool
114+
115+
pub fn vortex_array::aggregate_fn::AggregateFnRef::options(&self) -> vortex_array::aggregate_fn::AggregateFnOptions<'_>
116+
117+
pub fn vortex_array::aggregate_fn::AggregateFnRef::return_dtype(&self, input_dtype: &vortex_array::dtype::DType) -> vortex_error::VortexResult<vortex_array::dtype::DType>
118+
119+
pub fn vortex_array::aggregate_fn::AggregateFnRef::state_dtype(&self, input_dtype: &vortex_array::dtype::DType) -> vortex_error::VortexResult<vortex_array::dtype::DType>
120+
121+
pub fn vortex_array::aggregate_fn::AggregateFnRef::vtable_ref<V: vortex_array::aggregate_fn::AggregateFnVTable>(&self) -> core::option::Option<&V>
122+
123+
impl core::clone::Clone for vortex_array::aggregate_fn::AggregateFnRef
124+
125+
pub fn vortex_array::aggregate_fn::AggregateFnRef::clone(&self) -> vortex_array::aggregate_fn::AggregateFnRef
126+
127+
impl core::cmp::Eq for vortex_array::aggregate_fn::AggregateFnRef
128+
129+
impl core::cmp::PartialEq for vortex_array::aggregate_fn::AggregateFnRef
130+
131+
pub fn vortex_array::aggregate_fn::AggregateFnRef::eq(&self, other: &Self) -> bool
132+
133+
impl core::fmt::Debug for vortex_array::aggregate_fn::AggregateFnRef
134+
135+
pub fn vortex_array::aggregate_fn::AggregateFnRef::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
136+
137+
impl core::fmt::Display for vortex_array::aggregate_fn::AggregateFnRef
138+
139+
pub fn vortex_array::aggregate_fn::AggregateFnRef::fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result
140+
141+
impl core::hash::Hash for vortex_array::aggregate_fn::AggregateFnRef
142+
143+
pub fn vortex_array::aggregate_fn::AggregateFnRef::hash<H: core::hash::Hasher>(&self, state: &mut H)
144+
145+
pub trait vortex_array::aggregate_fn::Accumulator: core::marker::Send + core::marker::Sync
146+
147+
pub fn vortex_array::aggregate_fn::Accumulator::accumulate(&mut self, batch: &vortex_array::ArrayRef) -> vortex_error::VortexResult<()>
148+
149+
pub fn vortex_array::aggregate_fn::Accumulator::accumulate_list(&mut self, list: &vortex_array::arrays::ListViewArray) -> vortex_error::VortexResult<()>
150+
151+
pub fn vortex_array::aggregate_fn::Accumulator::finish(self: alloc::boxed::Box<Self>) -> vortex_error::VortexResult<vortex_array::ArrayRef>
152+
153+
pub fn vortex_array::aggregate_fn::Accumulator::flush(&mut self) -> vortex_error::VortexResult<()>
154+
155+
pub fn vortex_array::aggregate_fn::Accumulator::is_saturated(&self) -> bool
156+
157+
pub fn vortex_array::aggregate_fn::Accumulator::merge(&mut self, state: &vortex_array::scalar::Scalar) -> vortex_error::VortexResult<()>
158+
159+
pub fn vortex_array::aggregate_fn::Accumulator::merge_list(&mut self, states: &vortex_array::ArrayRef) -> vortex_error::VortexResult<()>
160+
161+
pub trait vortex_array::aggregate_fn::AggregateFnPlugin: 'static + core::marker::Send + core::marker::Sync
162+
163+
pub fn vortex_array::aggregate_fn::AggregateFnPlugin::deserialize(&self, metadata: &[u8], session: &vortex_session::VortexSession) -> vortex_error::VortexResult<vortex_array::aggregate_fn::AggregateFnRef>
164+
165+
pub fn vortex_array::aggregate_fn::AggregateFnPlugin::id(&self) -> vortex_array::aggregate_fn::AggregateFnId
166+
167+
impl<V: vortex_array::aggregate_fn::AggregateFnVTable> vortex_array::aggregate_fn::AggregateFnPlugin for V
168+
169+
pub fn V::deserialize(&self, metadata: &[u8], session: &vortex_session::VortexSession) -> vortex_error::VortexResult<vortex_array::aggregate_fn::AggregateFnRef>
170+
171+
pub fn V::id(&self) -> vortex_array::aggregate_fn::AggregateFnId
172+
173+
pub trait vortex_array::aggregate_fn::AggregateFnVTable: 'static + core::marker::Sized + core::clone::Clone + core::marker::Send + core::marker::Sync
174+
175+
pub type vortex_array::aggregate_fn::AggregateFnVTable::Options: 'static + core::marker::Send + core::marker::Sync + core::clone::Clone + core::fmt::Debug + core::fmt::Display + core::cmp::PartialEq + core::cmp::Eq + core::hash::Hash
176+
177+
pub fn vortex_array::aggregate_fn::AggregateFnVTable::accumulator(&self, options: &Self::Options, input_dtype: &vortex_array::dtype::DType) -> vortex_error::VortexResult<alloc::boxed::Box<dyn vortex_array::aggregate_fn::Accumulator>>
178+
179+
pub fn vortex_array::aggregate_fn::AggregateFnVTable::deserialize(&self, _metadata: &[u8], _session: &vortex_session::VortexSession) -> vortex_error::VortexResult<Self::Options>
180+
181+
pub fn vortex_array::aggregate_fn::AggregateFnVTable::id(&self) -> vortex_array::aggregate_fn::AggregateFnId
182+
183+
pub fn vortex_array::aggregate_fn::AggregateFnVTable::return_dtype(&self, options: &Self::Options, input_dtype: &vortex_array::dtype::DType) -> vortex_error::VortexResult<vortex_array::dtype::DType>
184+
185+
pub fn vortex_array::aggregate_fn::AggregateFnVTable::serialize(&self, options: &Self::Options) -> vortex_error::VortexResult<core::option::Option<alloc::vec::Vec<u8>>>
186+
187+
pub fn vortex_array::aggregate_fn::AggregateFnVTable::state_dtype(&self, options: &Self::Options, input_dtype: &vortex_array::dtype::DType) -> vortex_error::VortexResult<vortex_array::dtype::DType>
188+
189+
pub trait vortex_array::aggregate_fn::AggregateFnVTableExt: vortex_array::aggregate_fn::AggregateFnVTable
190+
191+
pub fn vortex_array::aggregate_fn::AggregateFnVTableExt::bind(&self, options: Self::Options) -> vortex_array::aggregate_fn::AggregateFnRef
192+
193+
impl<V: vortex_array::aggregate_fn::AggregateFnVTable> vortex_array::aggregate_fn::AggregateFnVTableExt for V
194+
195+
pub fn V::bind(&self, options: Self::Options) -> vortex_array::aggregate_fn::AggregateFnRef
196+
197+
pub type vortex_array::aggregate_fn::AggregateFnId = arcref::ArcRef<str>
198+
199+
pub type vortex_array::aggregate_fn::AggregateFnPluginRef = alloc::sync::Arc<dyn vortex_array::aggregate_fn::AggregateFnPlugin>
200+
29201
pub mod vortex_array::arrays
30202

31203
pub mod vortex_array::arrays::build_views

‎vortex-array/src/aggregate_fn/erased.rs‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ use vortex_utils::debug_with::DebugWith;
1717
use crate::aggregate_fn::AggregateFnId;
1818
use crate::aggregate_fn::AggregateFnVTable;
1919
use crate::aggregate_fn::accumulator::Accumulator;
20+
use crate::aggregate_fn::options::AggregateFnOptions;
2021
use crate::aggregate_fn::typed::AggregateFnInner;
2122
use crate::aggregate_fn::typed::DynAggregateFn;
2223
use crate::dtype::DType;
@@ -67,6 +68,11 @@ impl AggregateFnRef {
6768
.vortex_expect("Aggregate function options type mismatch")
6869
}
6970

71+
/// The type-erased options for this aggregate function.
72+
pub fn options(&self) -> AggregateFnOptions<'_> {
73+
AggregateFnOptions { inner: &*self.0 }
74+
}
75+
7076
/// Compute the return [`DType`] per group given the input element type.
7177
pub fn return_dtype(&self, input_dtype: &DType) -> VortexResult<DType> {
7278
self.0.return_dtype(input_dtype)

‎vortex-array/src/aggregate_fn/mod.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
99
use arcref::ArcRef;
1010

11-
pub mod accumulator;
11+
mod accumulator;
12+
pub use accumulator::*;
1213

1314
mod vtable;
1415
pub use vtable::*;
@@ -22,6 +23,9 @@ pub use typed::*;
2223
mod erased;
2324
pub use erased::*;
2425

26+
mod options;
27+
pub use options::*;
28+
2529
pub mod fns;
2630
pub mod session;
2731

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// SPDX-FileCopyrightText: Copyright the Vortex contributors
3+
4+
use std::any::Any;
5+
use std::fmt::Debug;
6+
use std::fmt::Display;
7+
use std::hash::Hash;
8+
use std::hash::Hasher;
9+
10+
use vortex_error::VortexResult;
11+
12+
use crate::aggregate_fn::typed::DynAggregateFn;
13+
14+
/// An opaque handle to aggregate function options.
15+
pub struct AggregateFnOptions<'a> {
16+
pub(super) inner: &'a dyn DynAggregateFn,
17+
}
18+
19+
impl Display for AggregateFnOptions<'_> {
20+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21+
self.inner.options_display(f)
22+
}
23+
}
24+
25+
impl Debug for AggregateFnOptions<'_> {
26+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
27+
self.inner.options_debug(f)
28+
}
29+
}
30+
31+
impl PartialEq for AggregateFnOptions<'_> {
32+
fn eq(&self, other: &Self) -> bool {
33+
self.inner.id() == other.inner.id() && self.inner.options_eq(other.inner.options_any())
34+
}
35+
}
36+
impl Eq for AggregateFnOptions<'_> {}
37+
38+
impl Hash for AggregateFnOptions<'_> {
39+
fn hash<H: Hasher>(&self, state: &mut H) {
40+
self.inner.id().hash(state);
41+
self.inner.options_hash(state);
42+
}
43+
}
44+
45+
impl AggregateFnOptions<'_> {
46+
/// Serialize the options to a byte vector.
47+
pub fn serialize(&self) -> VortexResult<Option<Vec<u8>>> {
48+
self.inner.options_serialize()
49+
}
50+
}
51+
52+
impl<'a> AggregateFnOptions<'a> {
53+
/// Return the underlying `Any` reference.
54+
pub fn as_any(&self) -> &'a dyn Any {
55+
self.inner.options_any()
56+
}
57+
}

‎vortex/public-api.lock‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
pub mod vortex
22

3+
pub use vortex::aggregate_fn
4+
35
pub use vortex::compute
46

57
pub use vortex::expr

0 commit comments

Comments
 (0)