vortex_vector/struct_/
scalar.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use crate::struct_::StructVector;
5use crate::{Scalar, ScalarOps, VectorMut, VectorOps};
6
7/// Represents a struct scalar value.
8///
9/// The inner value is a StructVector with length 1.
10#[derive(Debug)]
11pub struct StructScalar(StructVector);
12
13impl StructScalar {
14    /// Creates a new StructScalar from a length-1 StructVector.
15    ///
16    /// # Panics
17    ///
18    /// Panics if the input vector does not have length 1.
19    pub fn new(vector: StructVector) -> Self {
20        assert_eq!(vector.len(), 1);
21        Self(vector)
22    }
23}
24
25impl ScalarOps for StructScalar {
26    fn is_valid(&self) -> bool {
27        self.0.validity().value(0)
28    }
29
30    fn repeat(&self, _n: usize) -> VectorMut {
31        todo!()
32    }
33}
34
35impl From<StructScalar> for Scalar {
36    fn from(val: StructScalar) -> Self {
37        Scalar::Struct(val)
38    }
39}