pub struct Scalar { /* private fields */ }Expand description
A single logical item, composed of both a ScalarValue and a logical DType.
A ScalarValue is opaque, and should be accessed via one of the type-specific scalar wrappers
for example BoolScalar, PrimitiveScalar, etc.
Note: PartialEq and PartialOrd are implemented only for an exact match of the scalar’s
dtype, including nullability.
Implementations§
Source§impl Scalar
impl Scalar
pub fn primitive<T: NativePType + Into<PValue>>( value: T, nullability: Nullability, ) -> Self
pub fn reinterpret_cast(&self, ptype: PType) -> Self
pub fn zero<T: NativePType + Into<PValue>>(nullability: Nullability) -> Self
Source§impl Scalar
impl Scalar
pub fn utf8<B>(str: B, nullability: Nullability) -> Selfwhere
B: Into<BufferString>,
pub fn try_utf8<B>(
str: B,
nullability: Nullability,
) -> Result<Self, <B as TryInto<BufferString>>::Error>where
B: TryInto<BufferString>,
Source§impl Scalar
impl Scalar
pub fn new(dtype: DType, value: ScalarValue) -> Self
pub fn dtype(&self) -> &DType
pub fn into_parts(self) -> (DType, ScalarValue)
pub fn into_value(self) -> ScalarValue
pub fn is_valid(&self) -> bool
pub fn is_null(&self) -> bool
pub fn null(dtype: DType) -> Self
pub fn null_typed<T: ScalarType>() -> Self
pub fn cast(&self, dtype: &DType) -> VortexResult<Self>
pub fn into_nullable(self) -> Self
Source§impl Scalar
impl Scalar
pub fn as_bool(&self) -> BoolScalar<'_>
pub fn as_bool_opt(&self) -> Option<BoolScalar<'_>>
pub fn as_primitive(&self) -> PrimitiveScalar<'_>
pub fn as_primitive_opt(&self) -> Option<PrimitiveScalar<'_>>
pub fn as_utf8(&self) -> Utf8Scalar<'_>
pub fn as_utf8_opt(&self) -> Option<Utf8Scalar<'_>>
pub fn as_binary(&self) -> BinaryScalar<'_>
pub fn as_binary_opt(&self) -> Option<BinaryScalar<'_>>
pub fn as_struct(&self) -> StructScalar<'_>
pub fn as_struct_opt(&self) -> Option<StructScalar<'_>>
pub fn as_list(&self) -> ListScalar<'_>
pub fn as_list_opt(&self) -> Option<ListScalar<'_>>
pub fn as_extension(&self) -> ExtScalar<'_>
pub fn as_extension_opt(&self) -> Option<ExtScalar<'_>>
Trait Implementations§
Source§impl From<BufferString> for Scalar
impl From<BufferString> for Scalar
Source§fn from(value: BufferString) -> Self
fn from(value: BufferString) -> Self
Converts to this type from the input type.
Source§impl From<Vec<BufferString>> for Scalar
impl From<Vec<BufferString>> for Scalar
Source§fn from(value: Vec<BufferString>) -> Self
fn from(value: Vec<BufferString>) -> Self
Converts to this type from the input type.
Source§impl From<usize> for Scalar
impl From<usize> for Scalar
Read a scalar as usize. For usize only, we implicitly cast for better ergonomics.
Source§impl PartialOrd for Scalar
impl PartialOrd for Scalar
Source§impl<'a> TryFrom<&'a Scalar> for BinaryScalar<'a>
impl<'a> TryFrom<&'a Scalar> for BinaryScalar<'a>
Source§impl<'a> TryFrom<&'a Scalar> for BoolScalar<'a>
impl<'a> TryFrom<&'a Scalar> for BoolScalar<'a>
Source§impl<'a> TryFrom<&'a Scalar> for Buffer
impl<'a> TryFrom<&'a Scalar> for Buffer
Source§type Error = VortexError
type Error = VortexError
The type returned in the event of a conversion error.
Source§fn try_from(scalar: &'a Scalar) -> VortexResult<Self>
fn try_from(scalar: &'a Scalar) -> VortexResult<Self>
Performs the conversion.
Source§impl<'a> TryFrom<&'a Scalar> for BufferString
impl<'a> TryFrom<&'a Scalar> for BufferString
Source§type Error = VortexError
type Error = VortexError
The type returned in the event of a conversion error.
Source§fn try_from(scalar: &'a Scalar) -> VortexResult<Self>
fn try_from(scalar: &'a Scalar) -> VortexResult<Self>
Performs the conversion.
Source§impl<'a> TryFrom<&'a Scalar> for ListScalar<'a>
impl<'a> TryFrom<&'a Scalar> for ListScalar<'a>
Source§impl<'a> TryFrom<&'a Scalar> for Option<Buffer>
impl<'a> TryFrom<&'a Scalar> for Option<Buffer>
Source§type Error = VortexError
type Error = VortexError
The type returned in the event of a conversion error.
Source§fn try_from(scalar: &'a Scalar) -> VortexResult<Self>
fn try_from(scalar: &'a Scalar) -> VortexResult<Self>
Performs the conversion.
Source§impl TryFrom<&Scalar> for Option<bool>
impl TryFrom<&Scalar> for Option<bool>
Source§type Error = VortexError
type Error = VortexError
The type returned in the event of a conversion error.
Source§fn try_from(value: &Scalar) -> VortexResult<Self>
fn try_from(value: &Scalar) -> VortexResult<Self>
Performs the conversion.
Source§impl<'a> TryFrom<&'a Scalar> for PrimitiveScalar<'a>
impl<'a> TryFrom<&'a Scalar> for PrimitiveScalar<'a>
Source§impl<'a> TryFrom<&'a Scalar> for StructScalar<'a>
impl<'a> TryFrom<&'a Scalar> for StructScalar<'a>
Source§impl<'a> TryFrom<&'a Scalar> for Utf8Scalar<'a>
impl<'a> TryFrom<&'a Scalar> for Utf8Scalar<'a>
Source§impl TryFrom<&Scalar> for bool
impl TryFrom<&Scalar> for bool
Source§type Error = VortexError
type Error = VortexError
The type returned in the event of a conversion error.
Source§fn try_from(value: &Scalar) -> VortexResult<Self>
fn try_from(value: &Scalar) -> VortexResult<Self>
Performs the conversion.
Source§impl TryFrom<&Scalar> for usize
impl TryFrom<&Scalar> for usize
Read a scalar as usize. For usize only, we implicitly cast for better ergonomics.
Source§impl TryFrom<Scalar> for Buffer
impl TryFrom<Scalar> for Buffer
Source§type Error = VortexError
type Error = VortexError
The type returned in the event of a conversion error.
Source§fn try_from(scalar: Scalar) -> VortexResult<Self>
fn try_from(scalar: Scalar) -> VortexResult<Self>
Performs the conversion.
Source§impl TryFrom<Scalar> for BufferString
impl TryFrom<Scalar> for BufferString
Source§impl TryFrom<Scalar> for Option<Buffer>
impl TryFrom<Scalar> for Option<Buffer>
Source§type Error = VortexError
type Error = VortexError
The type returned in the event of a conversion error.
Source§fn try_from(scalar: Scalar) -> VortexResult<Self>
fn try_from(scalar: Scalar) -> VortexResult<Self>
Performs the conversion.
Source§impl TryFrom<Scalar> for Option<bool>
impl TryFrom<Scalar> for Option<bool>
Source§type Error = VortexError
type Error = VortexError
The type returned in the event of a conversion error.
Source§fn try_from(value: Scalar) -> VortexResult<Self>
fn try_from(value: Scalar) -> VortexResult<Self>
Performs the conversion.
Source§impl TryFrom<Scalar> for bool
impl TryFrom<Scalar> for bool
Source§type Error = VortexError
type Error = VortexError
The type returned in the event of a conversion error.
Source§fn try_from(value: Scalar) -> VortexResult<Self>
fn try_from(value: Scalar) -> VortexResult<Self>
Performs the conversion.
Auto Trait Implementations§
impl !Freeze for Scalar
impl RefUnwindSafe for Scalar
impl Send for Scalar
impl Sync for Scalar
impl Unpin for Scalar
impl UnwindSafe for Scalar
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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