Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions vortex-array/src/aggregate_fn/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::aggregate_fn::AggregateFn;
use crate::aggregate_fn::AggregateFnId;
use crate::aggregate_fn::AggregateFnRef;
use crate::aggregate_fn::AggregateFnVTable;
use crate::dtype::DType;

/// Reference-counted pointer to an aggregate function plugin.
pub type AggregateFnPluginRef = Arc<dyn AggregateFnPlugin>;
Expand All @@ -28,6 +29,9 @@ pub trait AggregateFnPlugin: 'static + Send + Sync {
/// Deserialize an aggregate function from serialized metadata.
fn deserialize(&self, metadata: &[u8], session: &VortexSession)
-> VortexResult<AggregateFnRef>;

/// The default per-chunk zone statistic to store for a column of `input_dtype`, or `None` if this aggregate isn't one.
fn zone_stat_default(&self, input_dtype: &DType) -> Option<AggregateFnRef>;
}

impl std::fmt::Debug for dyn AggregateFnPlugin {
Expand All @@ -51,4 +55,8 @@ impl<V: AggregateFnVTable> AggregateFnPlugin for V {
let options = AggregateFnVTable::deserialize(self, metadata, session)?;
Ok(AggregateFn::new(self.clone(), options).erased())
}

fn zone_stat_default(&self, input_dtype: &DType) -> Option<AggregateFnRef> {
AggregateFnVTable::zone_stat_default(self, input_dtype)
}
}
13 changes: 13 additions & 0 deletions vortex-array/src/aggregate_fn/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use vortex_session::SessionVar;

use crate::aggregate_fn::AggregateFnId;
use crate::aggregate_fn::AggregateFnPluginRef;
use crate::aggregate_fn::AggregateFnRef;
use crate::aggregate_fn::AggregateFnVTable;
use crate::aggregate_fn::fns::all_nan::AllNan;
use crate::aggregate_fn::fns::all_non_distinct::AllNonDistinct;
Expand Down Expand Up @@ -43,6 +44,7 @@ use crate::arrays::chunked::compute::aggregate::ChunkedArrayAggregate;
use crate::arrays::dict::compute::is_constant::DictIsConstantKernel;
use crate::arrays::dict::compute::is_sorted::DictIsSortedKernel;
use crate::arrays::dict::compute::min_max::DictMinMaxKernel;
use crate::dtype::DType;

/// Session state for aggregate functions and encoding-specific aggregate kernels.
///
Expand Down Expand Up @@ -133,6 +135,17 @@ impl AggregateFnSession {
self.registry.insert(id, pluginref);
}

/// The default per-chunk zone statistics for a column of `input_dtype`, collected from every
/// registered aggregate's `zone_stat_default`.
pub fn zone_stat_defaults(&self, input_dtype: &DType) -> Vec<AggregateFnRef> {
self.registry.read(|registry| {
registry
.values()
.filter_map(|plugin| plugin.zone_stat_default(input_dtype))
.collect()
})
}

/// Returns the aggregate kernel registered for `array_id` and `agg_fn_id`, if any.
///
/// Lookup first checks for a kernel registered for the exact aggregate function, then falls
Expand Down
7 changes: 7 additions & 0 deletions vortex-array/src/aggregate_fn/vtable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ pub trait AggregateFnVTable: 'static + Sized + Clone + Send + Sync {
/// Returns `None` if the aggregate function cannot be applied to the input dtype.
fn return_dtype(&self, options: &Self::Options, input_dtype: &DType) -> Option<DType>;

/// If this aggregate should be computed as a default zone statistic for `input_dtype`, return
/// the bound aggregate to store. Default: not a zone-map default.
fn zone_stat_default(&self, input_dtype: &DType) -> Option<AggregateFnRef> {
let _ = input_dtype;
None
}

/// DType of the intermediate partial accumulator state.
///
/// Use a struct dtype when multiple fields are needed
Expand Down
1 change: 1 addition & 0 deletions vortex-geo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ wkb = { workspace = true }

[dev-dependencies]
rstest = { workspace = true }
vortex-layout = { workspace = true }

[lints]
workspace = true
Loading
Loading