vortex_array/arrays/constant/
array.rs

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