pub trait AggregateState:
Default
+ Send
+ Sync
+ 'static { }Expand description
Trait for types that can be used as DuckDB aggregate state.
Implement this for your state struct. It requires Default (used to
create the initial state in state_init), Send (DuckDB moves states
between worker threads) and Sync: a window’s segment tree keeps its
states in shared, unlocked storage (WindowSegmentTreeGlobalState,
window_segment_tree.cpp), and every thread evaluating a frame that covers
one reads it as a combine source, so two threads can hold &T to the
same state at once. A T with a Cell or RefCell would race there.
Breaking in 0.18.0: the Sync bound is new.
§Example
use quack_rs::aggregate::AggregateState;
#[derive(Default)]
struct WordCount {
count: u64,
}
impl AggregateState for WordCount {}
// FfiState::<WordCount>::size_callback and other methods are now available.Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".