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

Function take_primitive

arrow-select/src/take.rs:400–411  ·  view source on GitHub ↗

`take` implementation for all primitive arrays This checks if an `indices` slot is populated, and gets the value from `values` as the populated index. If the `indices` slot is null, a null value is returned. For example, given: values: [1, 2, 3, null, 5] indices: [0, null, 4, 3] The result is: [1 (slot 0), null (null slot), 5 (slot 4), null (slot 3)]

(
    values: &PrimitiveArray<T>,
    indices: &PrimitiveArray<I>,
)

Source from the content-addressed store, hash-verified

398/// indices: [0, null, 4, 3]
399/// The result is: [1 (slot 0), null (null slot), 5 (slot 4), null (slot 3)]
400fn take_primitive<T, I>(
401 values: &PrimitiveArray<T>,
402 indices: &PrimitiveArray<I>,
403) -> Result<PrimitiveArray<T>, ArrowError>
404where
405 T: ArrowPrimitiveType,
406 I: ArrowPrimitiveType,
407{
408 let values_buf = take_native(values.values(), indices);
409 let nulls = take_nulls(values.nulls(), indices);
410 Ok(PrimitiveArray::try_new(values_buf, nulls)?.with_data_type(values.data_type().clone()))
411}
412
413#[inline(never)]
414fn take_nulls<I: ArrowPrimitiveType>(

Callers 1

take_dictFunction · 0.85

Calls 8

take_nativeFunction · 0.85
take_nullsFunction · 0.85
try_newFunction · 0.85
valuesMethod · 0.45
nullsMethod · 0.45
with_data_typeMethod · 0.45
cloneMethod · 0.45
data_typeMethod · 0.45

Tested by

no test coverage detected