pre_selection_scatter

Function pre_selection_scatter 

Source
fn pre_selection_scatter(
    left_result: &BooleanArray,
    right_result: Option<&BooleanArray>,
) -> Result<ColumnarValue>
Expand description

Creates a new boolean array based on the evaluation of the right expression, but only for positions where the left_result is true.

This function is used for short-circuit evaluation optimization of logical AND operations:

  • When left_result has few true values, we only evaluate the right expression for those positions
  • Values are copied from right_array where left_result is true
  • All other positions are filled with false values

§Parameters

  • left_result Boolean array with selection mask (typically from left side of AND)
  • right_result Result of evaluating right side of expression (only for selected positions)

§Returns

A combined ColumnarValue with values from right_result where left_result is true

§Example

Initial Data: { 1, 2, 3, 4, 5 } Left Evaluation (Condition: Equal to 2 or 3) ↓ Filtered Data: {2, 3} Left Bitmap: { 0, 1, 1, 0, 0 } ↓ Right Evaluation (Condition: Even numbers) ↓ Right Data: { 2 } Right Bitmap: { 1, 0 } ↓ Combine Results Final Bitmap: { 0, 1, 0, 0, 0 }

§Note

Perhaps it would be better to modify left_result directly without creating a copy? In practice, left_result should have only one owner, so making changes should be safe. However, this is difficult to achieve under the immutable constraints of Arc and [BooleanArray].