pub struct PrimitiveScalar<'a> { /* private fields */ }
Expand description
A scalar value representing a primitive type.
This type provides a view into a primitive scalar value of any primitive type (integers, floats) with various bit widths.
Implementations§
Source§impl<'a> PrimitiveScalar<'a>
impl<'a> PrimitiveScalar<'a>
Sourcepub fn try_new(dtype: &'a DType, value: &ScalarValue) -> VortexResult<Self>
pub fn try_new(dtype: &'a DType, value: &ScalarValue) -> VortexResult<Self>
Creates a new primitive scalar from a data type and scalar value.
§Errors
Returns an error if the data type is not a primitive type or if the value cannot be converted to the expected primitive type.
Sourcepub fn typed_value<T: NativePType + TryFrom<PValue, Error = VortexError>>(
&self,
) -> Option<T>
pub fn typed_value<T: NativePType + TryFrom<PValue, Error = VortexError>>( &self, ) -> Option<T>
Returns the value as a specific native primitive type.
§Panics
Panics if the primitive type of this scalar does not match the requested type.
Sourcepub fn as_<T: FromPrimitiveOrF16>(&self) -> VortexResult<Option<T>>
pub fn as_<T: FromPrimitiveOrF16>(&self) -> VortexResult<Option<T>>
Attempts to extract the primitive value as the given type.
§Errors
Returns an error if the cast fails due to overflow or type incompatibility.
Source§impl<'a> PrimitiveScalar<'a>
impl<'a> PrimitiveScalar<'a>
Sourcepub fn checked_binary_numeric(
&self,
other: &PrimitiveScalar<'a>,
op: NumericOperator,
) -> Option<PrimitiveScalar<'a>>
pub fn checked_binary_numeric( &self, other: &PrimitiveScalar<'a>, op: NumericOperator, ) -> Option<PrimitiveScalar<'a>>
Apply the (checked) operator to self and other using SQL-style null semantics.
If the operation overflows, Ok(None) is returned.
If the types are incompatible (ignoring nullability), an error is returned.
If either value is null, the result is null.
Trait Implementations§
Source§impl Add for PrimitiveScalar<'_>
impl Add for PrimitiveScalar<'_>
Source§impl CheckedAdd for PrimitiveScalar<'_>
impl CheckedAdd for PrimitiveScalar<'_>
Source§fn checked_add(&self, rhs: &Self) -> Option<Self>
fn checked_add(&self, rhs: &Self) -> Option<Self>
None
is
returned.Source§impl CheckedSub for PrimitiveScalar<'_>
impl CheckedSub for PrimitiveScalar<'_>
Source§fn checked_sub(&self, rhs: &Self) -> Option<Self>
fn checked_sub(&self, rhs: &Self) -> Option<Self>
None
is returned.Source§impl<'a> Clone for PrimitiveScalar<'a>
impl<'a> Clone for PrimitiveScalar<'a>
Source§fn clone(&self) -> PrimitiveScalar<'a>
fn clone(&self) -> PrimitiveScalar<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<'a> Debug for PrimitiveScalar<'a>
impl<'a> Debug for PrimitiveScalar<'a>
Source§impl Display for PrimitiveScalar<'_>
impl Display for PrimitiveScalar<'_>
Source§impl From<PrimitiveScalar<'_>> for Scalar
impl From<PrimitiveScalar<'_>> for Scalar
Source§fn from(pscalar: PrimitiveScalar<'_>) -> Self
fn from(pscalar: PrimitiveScalar<'_>) -> Self
Source§impl<'a> Hash for PrimitiveScalar<'a>
impl<'a> Hash for PrimitiveScalar<'a>
Source§impl PartialEq for PrimitiveScalar<'_>
impl PartialEq for PrimitiveScalar<'_>
Source§impl PartialOrd for PrimitiveScalar<'_>
Ord is not implemented since it’s undefined for different PTypes
impl PartialOrd for PrimitiveScalar<'_>
Ord is not implemented since it’s undefined for different PTypes
Source§impl Sub for PrimitiveScalar<'_>
impl Sub for PrimitiveScalar<'_>
Source§impl<'a> TryFrom<&'a Scalar> for PrimitiveScalar<'a>
impl<'a> TryFrom<&'a Scalar> for PrimitiveScalar<'a>
impl<'a> Copy for PrimitiveScalar<'a>
impl Eq for PrimitiveScalar<'_>
Auto Trait Implementations§
impl<'a> Freeze for PrimitiveScalar<'a>
impl<'a> RefUnwindSafe for PrimitiveScalar<'a>
impl<'a> Send for PrimitiveScalar<'a>
impl<'a> Sync for PrimitiveScalar<'a>
impl<'a> Unpin for PrimitiveScalar<'a>
impl<'a> UnwindSafe for PrimitiveScalar<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more