vortex_vector/
scalar_ops.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use crate::Scalar;
5use crate::VectorMut;
6use crate::private;
7
8/// Trait for scalar operations.
9pub trait ScalarOps: private::Sealed + Sized + Into<Scalar> {
10    /// Returns true if the scalar is valid (not null).
11    fn is_valid(&self) -> bool;
12
13    /// Returns true if the scalar is null.
14    fn is_invalid(&self) -> bool {
15        !self.is_valid()
16    }
17
18    /// Intersect the validity of this scalar with the provided mask value.
19    ///
20    /// If the mask is true, the scalar's validity remains unchanged.
21    /// If the mask is false, the resulting scalar is null.
22    fn mask_validity(&mut self, mask: bool);
23
24    /// Creates a new vector with n repetitions of this scalar.
25    fn repeat(&self, n: usize) -> VectorMut;
26}