optimized_take

Function optimized_take 

Source
pub fn optimized_take<I: UnsignedPType>(
    values: &BoolVector,
    indices: &[I],
    compute_validity: impl FnOnce() -> Mask,
) -> BoolVector
Expand description

Optimized take for boolean vectors with small value arrays.

Since booleans can only be true or false, we can optimize these specific cases:

  • All of the values are true, so create a BoolVector with n trues.
  • All of the values are false, so create a BoolVector with n falses.
  • There is a single true value, so compare indices against that index.
  • There is a single false value, so compare indices against that index and negate.
  • Otherwise, there are multiple trues and falses in the values vector and we must do a normal take on it.

The compute_validity closure computes the output validity mask, allowing callers to handle nullable vs non-nullable indices differently.