Skip to main content

vortex_array/arrays/constant/
array.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright the Vortex contributors
3
4use crate::scalar::Scalar;
5use crate::stats::ArrayStats;
6
7#[derive(Clone, Debug)]
8pub struct ConstantArray {
9    pub(super) scalar: Scalar,
10    pub(super) len: usize,
11    pub(super) stats_set: ArrayStats,
12}
13
14impl ConstantArray {
15    pub fn new<S>(scalar: S, len: usize) -> Self
16    where
17        S: Into<Scalar>,
18    {
19        let scalar = scalar.into();
20        Self {
21            scalar,
22            len,
23            stats_set: Default::default(),
24        }
25    }
26
27    /// Returns the [`Scalar`] value of this constant array.
28    pub fn scalar(&self) -> &Scalar {
29        &self.scalar
30    }
31
32    pub fn into_parts(self) -> Scalar {
33        self.scalar
34    }
35}