vortex_compute/take/
mod.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4//! Take function.
5
6mod bit_buffer;
7mod buffer;
8mod mask;
9pub mod slice;
10mod vector;
11
12pub use vector::default_take;
13pub use vector::optimized_take;
14
15/// The size of a page in Linux.
16const LINUX_PAGE_SIZE: usize = 4096;
17
18/// Function for taking based on indices (which can have different representations).
19pub trait Take<Indices: ?Sized> {
20    /// The result type after performing the operation.
21    type Output;
22
23    /// Creates a new object using the elements from the input indexed by `indices`.
24    ///
25    /// For example, if we have an array `[1, 2, 3, 4, 5]` and `indices` `[4, 2]`, the resulting
26    /// array would be `[5, 3]`.
27    ///
28    /// The output should have the same length as the `indices`.
29    ///
30    /// # Panics
31    ///
32    /// This should panic if an index in `indices` is out-of-bounds with respect to `self`.
33    fn take(self, indices: &Indices) -> Self::Output;
34}