-
Notifications
You must be signed in to change notification settings - Fork 186
Expand file tree
/
Copy pathmod.rs
More file actions
53 lines (45 loc) · 1.58 KB
/
Copy pathmod.rs
File metadata and controls
53 lines (45 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright the Vortex contributors
//! Scalar values and types for the Vortex system.
//!
//! This crate provides scalar types and values that can be used to represent individual data
//! elements in the Vortex array system. A [`Scalar`] pairs a logical data type ([`DType`]) with an
//! optional non-null value ([`ScalarValue`]); [`None`] represents a null scalar.
//!
//! Note that the implementations of `Scalar` are split into several different modules.
//!
//! `Scalar` is the single-row counterpart to [`ArrayRef`](crate::ArrayRef): it is logical, not tied
//! to any physical array encoding. A scalar always carries its [`DType`], and null scalars are
//! represented by `value == None`.
#[cfg(feature = "arbitrary")]
pub mod arbitrary;
mod cast;
mod constructor;
mod convert;
mod display;
mod downcast;
mod proto;
mod scalar_impl;
mod scalar_value;
mod truncation;
mod typed_view;
mod validate;
pub use scalar_value::*;
pub use truncation::*;
pub use typed_view::*;
use crate::dtype::DType;
/// A typed scalar value.
///
/// Scalars represent a single value with an associated [`DType`]. The value can be null, in which
/// case the [`value`][Scalar::value] method returns `None`.
#[derive(Clone, Debug, Eq)]
pub struct Scalar {
/// The type of the scalar.
dtype: DType,
/// The value of the scalar. This is [`None`] if the value is null, otherwise it is [`Some`].
///
/// Invariant: If the [`DType`] is non-nullable, then this value _cannot_ be [`None`].
value: Option<ScalarValue>,
}
#[cfg(test)]
mod tests;