MCPcopy Create free account
hub / github.com/apache/arrow-rs / take_bits

Function take_bits

arrow-select/src/take.rs:455–481  ·  view source on GitHub ↗
(
    values: &BooleanBuffer,
    indices: &PrimitiveArray<I>,
)

Source from the content-addressed store, hash-verified

453
454#[inline(never)]
455fn take_bits<I: ArrowPrimitiveType>(
456 values: &BooleanBuffer,
457 indices: &PrimitiveArray<I>,
458) -> BooleanBuffer {
459 let len = indices.len();
460
461 match indices.nulls().filter(|n| n.null_count() > 0) {
462 Some(nulls) => {
463 let mut output_buffer = MutableBuffer::new_null(len);
464 let output_slice = output_buffer.as_slice_mut();
465 nulls.valid_indices().for_each(|idx| {
466 // SAFETY: idx is a valid index in indices.nulls() --> idx<indices.len()
467 if values.value(unsafe { indices.value_unchecked(idx).as_usize() }) {
468 // SAFETY: MutableBuffer was created with space for indices.len() bit, and idx < indices.len()
469 unsafe { bit_util::set_bit_raw(output_slice.as_mut_ptr(), idx) };
470 }
471 });
472 BooleanBuffer::new(output_buffer.into(), 0, len)
473 }
474 None => {
475 BooleanBuffer::collect_bool(len, |idx: usize| {
476 // SAFETY: idx<indices.len()
477 values.value(unsafe { indices.value_unchecked(idx).as_usize() })
478 })
479 }
480 }
481}
482
483/// `take` implementation for boolean arrays
484fn take_boolean<IndexType: ArrowPrimitiveType>(

Callers 2

take_nullsFunction · 0.70
take_booleanFunction · 0.70

Calls 12

set_bit_rawFunction · 0.85
collect_boolFunction · 0.85
filterMethod · 0.80
valid_indicesMethod · 0.80
as_usizeMethod · 0.80
as_mut_ptrMethod · 0.80
lenMethod · 0.45
nullsMethod · 0.45
null_countMethod · 0.45
as_slice_mutMethod · 0.45
valueMethod · 0.45
value_uncheckedMethod · 0.45

Tested by

no test coverage detected