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

Function take

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

Take elements by index from [Array], creating a new [Array] from those indexes. ```text ┌─────────────────┐ ┌─────────┐ ┌─────────────────┐ │ A │ │ 0 │ │ A │ ├─────────────────┤ ├─────────┤ ├─────────────────┤ │ D │ │ 2 │

(
    values: &dyn Array,
    indices: &dyn Array,
    options: Option<TakeOptions>,
)

Source from the content-addressed store, hash-verified

86/// assert_eq!(*taken, StringArray::from(vec!["two", "one"]));
87/// ```
88pub fn take(
89 values: &dyn Array,
90 indices: &dyn Array,
91 options: Option<TakeOptions>,
92) -> Result<ArrayRef, ArrowError> {
93 let options = options.unwrap_or_default();
94 downcast_integer_array!(
95 indices => {
96 if options.check_bounds {
97 check_bounds(values.len(), indices)?;
98 }
99 let indices = indices.to_indices();
100 take_impl(values, &indices)
101 },
102 d => Err(ArrowError::InvalidArgumentError(format!("Take only supported for integers, got {d:?}")))
103 )
104}
105
106/// For each [ArrayRef] in the [`Vec<ArrayRef>`], take elements by index and create a new
107/// [`Vec<ArrayRef>`] from those indices.

Callers 15

bench_takeFunction · 0.85
bench_take_bounds_checkFunction · 0.85
criterion_benchmarkFunction · 0.85
projectMethod · 0.85
merge_extrasFunction · 0.85
flushMethod · 0.85
flushMethod · 0.85
flushMethod · 0.85
bitwise_bin_op_assignMethod · 0.85
finishMethod · 0.85
run_end_encoded_castFunction · 0.85

Calls

no outgoing calls