Apache DataFusion SQL Query Engine
Clarify docs about `Accumulator::update` and `Accumulator::update_batch` (#1542)
Andrew Lambb42ebe70b2d7
diff --git a/datafusion/src/physical_plan/mod.rs b/datafusion/src/physical_plan/mod.rsindex 8c5f662a4a..d39a7a0066 100644--- a/datafusion/src/physical_plan/mod.rs+++ b/datafusion/src/physical_plan/mod.rs@@ -565,7 +565,17 @@ pub trait Accumulator: Send + Sync + Debug {// of two values, sum and n.fn state(&self) -> Result<Vec<ScalarValue>>;- /// updates the accumulator's state from a vector of scalars.+ /// Updates the accumulator's state from a vector of scalars+ /// (called by default implementation of [`update_batch`]).+ ///+ /// Note: this method is often the simplest to implement and is+ /// backwards compatible to help to lower the barrier to entry for+ /// new users to write `Accumulators`+ ///+ /// You should always implement `update_batch` instead of this+ /// method for production aggregators or if you find yourself+ /// wanting to use mathematical kernels for [`ScalarValue`] such as+ /// `ScalarValue::add`, `ScalarValue::mul`, etcfn update(&mut self, values: &[ScalarValue]) -> Result<()>;/// updates the accumulator's state from a vector of arrays.@@ -582,7 +592,12 @@ pub trait Accumulator: Send + Sync + Debug {})}- /// updates the accumulator's state from a vector of scalars.+ /// Updates the accumulator's state from a vector of scalars.+ /// (called by default implementation of [`merge`]).+ ///+ /// You should always implement `merge_batch` instead of this+ /// method for production aggregators. Please see notes on+ /// [`update`] for more detail and rationale.fn merge(&mut self, states: &[ScalarValue]) -> Result<()>;/// updates the accumulator's state from a vector of states.