Skip to content

Commit

Permalink
Add note about the narrow use case for array_eq_scalar
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Aug 10, 2021
1 parent 9886303 commit 49aa351
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion datafusion/src/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,14 +1011,22 @@ impl ScalarValue {
})
}

/// Compares array @ index for equality with self, in an optimized fashion
/// Compares a single row of array @ index for equality with self,
/// in an optimized fashion.
///
/// This method implements an optimized version of:
///
/// ``text
/// let arr_scalar = Self::try_from_array(array, index).unwrap();
/// arr_scalar.eq(self)
/// ```
///
/// *Performance note*: the arrow compute kernels should be
/// preferred over this function if at all possible as they can be
/// vectorized and are generally much faster.
///
/// This function has some narrow usescases such as hash table key
/// comparisons where comparing a single row at a time is necessary.
#[inline]
pub fn eq_array(&self, array: &ArrayRef, index: usize) -> bool {
if let DataType::Dictionary(key_type, _) = array.data_type() {
Expand Down

0 comments on commit 49aa351

Please sign in to comment.