Skip to content

Commit e37679f

Browse files
committed
Improve docs, add comments on merge_batch
1 parent a0dd38f commit e37679f

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

  • datafusion/src/physical_plan

‎datafusion/src/physical_plan/mod.rs‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -565,17 +565,17 @@ pub trait Accumulator: Send + Sync + Debug {
565565
// of two values, sum and n.
566566
fn state(&self) -> Result<Vec<ScalarValue>>;
567567

568-
/// updates the accumulator's state from a vector of scalars
569-
/// (called by default implementation of [`update_batch`])
568+
/// Updates the accumulator's state from a vector of scalars
569+
/// (called by default implementation of [`update_batch`]).
570570
///
571-
/// Note: this method is often the simplest to implement and
572-
/// is backwards compatible to help to lower the barrier to entry for
571+
/// Note: this method is often the simplest to implement and is
572+
/// backwards compatible to help to lower the barrier to entry for
573573
/// new users to write `Accumulators`
574574
///
575575
/// You should always implement `update_batch` instead of this
576576
/// method for production aggregators or if you find yourself
577-
/// wanting mathematical kernels for `ScalarValue`s such as `add`,
578-
/// `mul`, etc
577+
/// wanting to use mathematical kernels for [`ScalarValue`] such as
578+
/// `ScalarValue::add`, `ScalarValue::mul`, etc
579579
fn update(&mut self, values: &[ScalarValue]) -> Result<()>;
580580

581581
/// updates the accumulator's state from a vector of arrays.
@@ -592,9 +592,12 @@ pub trait Accumulator: Send + Sync + Debug {
592592
})
593593
}
594594

595-
/// updates the accumulator's state from a vector of scalars.
595+
/// Updates the accumulator's state from a vector of scalars.
596+
/// (called by default implementation of [`merge`]).
596597
///
597-
/// (called by default implementation of [`merge`])
598+
/// You should always implement `merge_batch` instead of this
599+
/// method for production aggregators. Please see notes on
600+
/// [`update`] for more detail and rationale.
598601
fn merge(&mut self, states: &[ScalarValue]) -> Result<()>;
599602

600603
/// updates the accumulator's state from a vector of states.

0 commit comments

Comments
 (0)