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 that PartialOrd is implemented only for an exact match of the scalar’s dtype,
including nullability. When the DType does match, ordering is nulls first (lowest), then the
natural ordering of the scalar value.
Implementations§
Source§impl Scalar
impl Scalar
pub fn binary( buffer: impl Into<Arc<ByteBuffer>>, nullability: Nullability, ) -> Self
Source§impl Scalar
impl Scalar
pub fn decimal( value: DecimalValue, decimal_type: DecimalDType, nullability: Nullability, ) -> Self
Source§impl Scalar
impl Scalar
pub fn list( element_dtype: Arc<DType>, children: Vec<Scalar>, nullability: Nullability, ) -> Self
pub fn list_empty(element_dtype: Arc<DType>, nullability: Nullability) -> Self
Source§impl Scalar
impl Scalar
pub fn primitive<T: NativePType + Into<PValue>>( value: T, nullability: Nullability, ) -> Self
Sourcepub fn primitive_value(
value: PValue,
ptype: PType,
nullability: Nullability,
) -> Self
pub fn primitive_value( value: PValue, ptype: PType, nullability: Nullability, ) -> Self
Create a PrimitiveScalar from a PValue.
Note that an explicit PType is passed since any compatible PValue may be used as the value for a primitive type.
pub fn reinterpret_cast(&self, ptype: PType) -> 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 value(&self) -> &ScalarValue
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, target: &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_decimal(&self) -> DecimalScalar<'_>
pub fn as_decimal_opt(&self) -> Option<DecimalScalar<'_>>
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<Arc<Buffer<u8>>> for Scalar
impl From<Arc<Buffer<u8>>> for Scalar
Source§fn from(value: Arc<ByteBuffer>) -> Self
fn from(value: Arc<ByteBuffer>) -> Self
Converts to this type from the input type.
Source§impl From<Arc<BufferString>> for Scalar
impl From<Arc<BufferString>> for Scalar
Source§fn from(value: Arc<BufferString>) -> Self
fn from(value: Arc<BufferString>) -> Self
Converts to this type from the input type.
Source§impl From<Buffer<u8>> for Scalar
impl From<Buffer<u8>> for Scalar
Source§fn from(value: ByteBuffer) -> Self
fn from(value: ByteBuffer) -> Self
Converts to this type from the input type.
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<DecimalScalar<'_>> for Scalar
impl From<DecimalScalar<'_>> for Scalar
Source§fn from(decimal_scalar: DecimalScalar<'_>) -> Self
fn from(decimal_scalar: DecimalScalar<'_>) -> Self
Converts to this type from the input type.
Source§impl From<PrimitiveScalar<'_>> for Scalar
impl From<PrimitiveScalar<'_>> for Scalar
Source§fn from(pscalar: PrimitiveScalar<'_>) -> Self
fn from(pscalar: PrimitiveScalar<'_>) -> Self
Converts to this type from the input type.
Source§impl From<Vec<Buffer<u8>>> for Scalar
impl From<Vec<Buffer<u8>>> for Scalar
Source§fn from(value: Vec<ByteBuffer>) -> Self
fn from(value: Vec<ByteBuffer>) -> 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
Read a scalar as usize. For usize only, we implicitly cast for better ergonomics.
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 ByteBuffer
impl<'a> TryFrom<&'a Scalar> for ByteBuffer
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 DecimalScalar<'a>
impl<'a> TryFrom<&'a Scalar> for DecimalScalar<'a>
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<ByteBuffer>
impl<'a> TryFrom<&'a Scalar> for Option<ByteBuffer>
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
Read a scalar as usize. For usize only, we implicitly cast for better ergonomics.
impl TryFrom<&Scalar> for usize
Read a scalar as usize. For usize only, we implicitly cast for better ergonomics.
Source§impl TryFrom<Scalar> for ByteBuffer
impl TryFrom<Scalar> for ByteBuffer
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<ByteBuffer>
impl TryFrom<Scalar> for Option<ByteBuffer>
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.
impl Eq for Scalar
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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