pub struct CorrelationGroupsAccumulator { /* private fields */ }
Implementations§
Trait Implementations§
Source§impl Default for CorrelationGroupsAccumulator
impl Default for CorrelationGroupsAccumulator
Source§fn default() -> CorrelationGroupsAccumulator
fn default() -> CorrelationGroupsAccumulator
Returns the “default value” for a type. Read more
Source§impl GroupsAccumulator for CorrelationGroupsAccumulator
GroupsAccumulator implementation for corr(x, y)
that computes the Pearson correlation coefficient
between two numeric columns.
impl GroupsAccumulator for CorrelationGroupsAccumulator
GroupsAccumulator implementation for corr(x, y)
that computes the Pearson correlation coefficient
between two numeric columns.
Online algorithm for correlation:
r = (n * sum_xy - sum_x * sum_y) / sqrt((n * sum_xx - sum_x^2) * (n * sum_yy - sum_y^2))
where:
n = number of observations
sum_x = sum of x values
sum_y = sum of y values
sum_xy = sum of (x * y)
sum_xx = sum of x^2 values
sum_yy = sum of y^2 values
Reference: https://en.wikipedia.org/wiki/Pearson_correlation_coefficient#For_a_sample
Source§fn update_batch(
&mut self,
values: &[ArrayRef],
group_indices: &[usize],
opt_filter: Option<&BooleanArray>,
total_num_groups: usize,
) -> Result<()>
fn update_batch( &mut self, values: &[ArrayRef], group_indices: &[usize], opt_filter: Option<&BooleanArray>, total_num_groups: usize, ) -> Result<()>
Source§fn merge_batch(
&mut self,
values: &[ArrayRef],
group_indices: &[usize],
opt_filter: Option<&BooleanArray>,
total_num_groups: usize,
) -> Result<()>
fn merge_batch( &mut self, values: &[ArrayRef], group_indices: &[usize], opt_filter: Option<&BooleanArray>, total_num_groups: usize, ) -> Result<()>
Merges intermediate state (the output from
Self::state
)
into this accumulator’s current state. Read moreSource§fn evaluate(&mut self, emit_to: EmitTo) -> Result<ArrayRef>
fn evaluate(&mut self, emit_to: EmitTo) -> Result<ArrayRef>
Returns the final aggregate value for each group as a single
RecordBatch
, resetting the internal state. Read moreSource§fn state(&mut self, emit_to: EmitTo) -> Result<Vec<ArrayRef>>
fn state(&mut self, emit_to: EmitTo) -> Result<Vec<ArrayRef>>
Returns the intermediate aggregate state for this accumulator,
used for multi-phase grouping, resetting its internal state. Read more
Source§fn size(&self) -> usize
fn size(&self) -> usize
Amount of memory used to store the state of this accumulator,
in bytes. Read more
Source§fn convert_to_state(
&self,
_values: &[Arc<dyn Array>],
_opt_filter: Option<&BooleanArray>,
) -> Result<Vec<Arc<dyn Array>>, DataFusionError>
fn convert_to_state( &self, _values: &[Arc<dyn Array>], _opt_filter: Option<&BooleanArray>, ) -> Result<Vec<Arc<dyn Array>>, DataFusionError>
Converts an input batch directly to the intermediate aggregate state. Read more
Source§fn supports_convert_to_state(&self) -> bool
fn supports_convert_to_state(&self) -> bool
Returns
true
if Self::convert_to_state
is implemented to support
intermediate aggregate state conversion.Auto Trait Implementations§
impl Freeze for CorrelationGroupsAccumulator
impl RefUnwindSafe for CorrelationGroupsAccumulator
impl Send for CorrelationGroupsAccumulator
impl Sync for CorrelationGroupsAccumulator
impl Unpin for CorrelationGroupsAccumulator
impl UnwindSafe for CorrelationGroupsAccumulator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more