pub enum DType {
Null,
Bool(Nullability),
Primitive(PType, Nullability),
Decimal(DecimalDType, Nullability),
Utf8(Nullability),
Binary(Nullability),
List(Arc<DType>, Nullability),
FixedSizeList(Arc<DType>, u32, Nullability),
Struct(StructFields, Nullability),
Extension(Arc<ExtDType>),
}Expand description
The logical types of elements in Vortex arrays.
DType represents the different logical data types that can be represented in a Vortex array.
This is different from physical types, which represent the actual layout of data (compressed or uncompressed). The set of physical types/formats (or data layout) is surjective into the set of logical types (or in other words, all physical types map to a single logical type).
Note that a DType represents the logical type of the elements in the Arrays, not the
logical type of the Array itself.
For example, an array with DType::Primitive(I32, NonNullable) could be physically
encoded as any of the following:
- A flat array of
i32values. - A run-length encoded sequence.
- Dictionary encoded values with bitpacked codes.
All of these physical encodings preserve the same logical I32 type, even if the physical
data is different.
Variants§
Null
A logical null type.
Null only has a single value, null.
Bool(Nullability)
A logical boolean type.
Bool can be true or false if non-nullable. It can be true, false, or null if
nullable.
Primitive(PType, Nullability)
A logical fixed-width numeric type.
This can be unsigned, signed, or floating point. See PType for more information.
Decimal(DecimalDType, Nullability)
Logical real numbers with fixed precision and scale.
See DecimalDType for more information.
Utf8(Nullability)
Logical UTF-8 strings.
Binary(Nullability)
Logical binary data.
List(Arc<DType>, Nullability)
A logical variable-length list type.
This is parameterized by a single DType that represents the element type of the inner
lists.
FixedSizeList(Arc<DType>, u32, Nullability)
A logical fixed-size list type.
This is parameterized by a DType that represents the element type of the inner lists, as
well as a u32 size that determines the fixed length of each FixedSizeList scalar.
Struct(StructFields, Nullability)
A logical struct type.
A Struct type is composed of an ordered list of fields, each with a corresponding name and
DType. See StructFields for more information.
Extension(Arc<ExtDType>)
A user-defined extension type.
See ExtDType for more information.
Implementations§
Source§impl DType
impl DType
Sourcepub fn to_arrow_schema(&self) -> VortexResult<Schema>
pub fn to_arrow_schema(&self) -> VortexResult<Schema>
Sourcepub fn to_arrow_dtype(&self) -> VortexResult<DataType>
pub fn to_arrow_dtype(&self) -> VortexResult<DataType>
Source§impl DType
impl DType
Sourcepub fn nullability(&self) -> Nullability
pub fn nullability(&self) -> Nullability
Get the nullability of the DType.
Sourcepub fn is_nullable(&self) -> bool
pub fn is_nullable(&self) -> bool
Check if the DType is Nullability::Nullable.
Sourcepub fn as_nonnullable(&self) -> Self
pub fn as_nonnullable(&self) -> Self
Get a new DType with Nullability::NonNullable (but otherwise the same as self)
Sourcepub fn as_nullable(&self) -> Self
pub fn as_nullable(&self) -> Self
Get a new DType with Nullability::Nullable (but otherwise the same as self)
Sourcepub fn with_nullability(&self, nullability: Nullability) -> Self
pub fn with_nullability(&self, nullability: Nullability) -> Self
Get a new DType with the given nullability (but otherwise the same as self)
Sourcepub fn union_nullability(&self, other: Nullability) -> Self
pub fn union_nullability(&self, other: Nullability) -> Self
Union the nullability of this DType with the other nullability, returning a new DType.
Sourcepub fn eq_ignore_nullability(&self, other: &Self) -> bool
pub fn eq_ignore_nullability(&self, other: &Self) -> bool
Check if self and other are equal, ignoring nullability.
Sourcepub fn eq_with_nullability_subset(&self, other: &Self) -> bool
pub fn eq_with_nullability_subset(&self, other: &Self) -> bool
Returns true if self is a subset type of other, otherwise false`.
If self is nullable, this means that the other DType must also be nullable (since a
nullable type represents more values than a non-nullable type) and equal.
If self is non-nullable, then the other DType must be equal ignoring nullabillity.
We implement this functionality as a complement to is_superset_of.
Sourcepub fn eq_with_nullability_superset(&self, other: &Self) -> bool
pub fn eq_with_nullability_superset(&self, other: &Self) -> bool
Returns true if self is a superset type of other, otherwise false`.
If self is non-nullable, this means that the other DType must also be non-nullable
(since a non-nullable type represents less values than a nullable type) and equal.
If self is nullable, then the other DType must be equal ignoring nullabillity.
This function is useful (in the vortex-array crate) for determining if an Array can
extend a given ArrayBuilder: it can only extend it if the DType of the builder is a
superset of the Array.
Sourcepub fn is_boolean(&self) -> bool
pub fn is_boolean(&self) -> bool
Check if self is a boolean
Sourcepub fn is_primitive(&self) -> bool
pub fn is_primitive(&self) -> bool
Check if self is a primitive type
Sourcepub fn is_unsigned_int(&self) -> bool
pub fn is_unsigned_int(&self) -> bool
Check if self is an unsigned integer
Sourcepub fn is_signed_int(&self) -> bool
pub fn is_signed_int(&self) -> bool
Check if self is a signed integer
Sourcepub fn is_decimal(&self) -> bool
pub fn is_decimal(&self) -> bool
Check if self is a DType::Decimal.
Sourcepub fn is_utf8(&self) -> bool
pub fn is_utf8(&self) -> bool
Check if self is a DType::Utf8
Sourcepub fn is_binary(&self) -> bool
pub fn is_binary(&self) -> bool
Check if self is a DType::Binary
Sourcepub fn is_list(&self) -> bool
pub fn is_list(&self) -> bool
Check if self is a DType::List.
Sourcepub fn is_fixed_size_list(&self) -> bool
pub fn is_fixed_size_list(&self) -> bool
Check if self is a DType::FixedSizeList,
Sourcepub fn is_struct(&self) -> bool
pub fn is_struct(&self) -> bool
Check if self is a DType::Struct
Sourcepub fn is_extension(&self) -> bool
pub fn is_extension(&self) -> bool
Check if self is a DType::Extension type
Sourcepub fn is_nested(&self) -> bool
pub fn is_nested(&self) -> bool
Check if self is a nested type, i.e. list, fixed size list, struct, or extension of a
recursive type.
Sourcepub fn as_decimal_opt(&self) -> Option<&DecimalDType>
pub fn as_decimal_opt(&self) -> Option<&DecimalDType>
Check returns the inner decimal type if the dtype is a DType::Decimal.
Sourcepub fn into_decimal_opt(self) -> Option<DecimalDType>
pub fn into_decimal_opt(self) -> Option<DecimalDType>
Owned version of Self::as_decimal_opt.
Sourcepub fn as_list_element_opt(&self) -> Option<&Arc<DType>>
pub fn as_list_element_opt(&self) -> Option<&Arc<DType>>
Get the inner element dtype if self is a DType::List, otherwise returns None.
Note that this does not return Some if self is a DType::FixedSizeList.
Sourcepub fn into_list_element_opt(self) -> Option<Arc<DType>>
pub fn into_list_element_opt(self) -> Option<Arc<DType>>
Owned version of Self::as_list_element_opt.
Sourcepub fn as_fixed_size_list_element_opt(&self) -> Option<&Arc<DType>>
pub fn as_fixed_size_list_element_opt(&self) -> Option<&Arc<DType>>
Get the inner element dtype if self is a DType::FixedSizeList, otherwise returns
None.
Note that this does not return Some if self is a DType::List.
Sourcepub fn into_fixed_size_list_element_opt(self) -> Option<Arc<DType>>
pub fn into_fixed_size_list_element_opt(self) -> Option<Arc<DType>>
Owned version of Self::as_fixed_size_list_element_opt.
Sourcepub fn as_any_size_list_element_opt(&self) -> Option<&Arc<DType>>
pub fn as_any_size_list_element_opt(&self) -> Option<&Arc<DType>>
Get the inner element dtype if self is either a DType::List or a
DType::FixedSizeList, otherwise returns None
Sourcepub fn into_any_size_list_element_opt(self) -> Option<Arc<DType>>
pub fn into_any_size_list_element_opt(self) -> Option<Arc<DType>>
Owned version of Self::as_any_size_list_element_opt.
Sourcepub fn as_struct_fields(&self) -> &StructFields
pub fn as_struct_fields(&self) -> &StructFields
Sourcepub fn into_struct_fields(self) -> StructFields
pub fn into_struct_fields(self) -> StructFields
Owned version of Self::as_struct_fields.
Sourcepub fn as_struct_fields_opt(&self) -> Option<&StructFields>
pub fn as_struct_fields_opt(&self) -> Option<&StructFields>
Get the StructDType if self is a StructDType, otherwise None
Sourcepub fn into_struct_fields_opt(self) -> Option<StructFields>
pub fn into_struct_fields_opt(self) -> Option<StructFields>
Owned version of Self::as_struct_fields_opt.
Sourcepub fn list(dtype: impl Into<DType>, nullability: Nullability) -> Self
pub fn list(dtype: impl Into<DType>, nullability: Nullability) -> Self
Convenience method for creating a DType::List.
Sourcepub fn struct_<I: IntoIterator<Item = (impl Into<FieldName>, impl Into<FieldDType>)>>(
iter: I,
nullability: Nullability,
) -> Self
pub fn struct_<I: IntoIterator<Item = (impl Into<FieldName>, impl Into<FieldDType>)>>( iter: I, nullability: Nullability, ) -> Self
Convenience method for creating a DType::Struct.
Source§impl DType
impl DType
Sourcepub fn try_from_view(fb: DType<'_>, buffer: FlatBuffer) -> VortexResult<Self>
pub fn try_from_view(fb: DType<'_>, buffer: FlatBuffer) -> VortexResult<Self>
Create a new
Trait Implementations§
Source§impl<'a> Arbitrary<'a> for DType
impl<'a> Arbitrary<'a> for DType
Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured this type
needs to construct itself. Read moreSource§impl<'de> Deserialize<'de> for DType
impl<'de> Deserialize<'de> for DType
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl From<DType> for FieldDType
impl From<DType> for FieldDType
Source§impl FromArrowType<&Field> for DType
impl FromArrowType<&Field> for DType
Source§fn from_arrow(field: &Field) -> Self
fn from_arrow(field: &Field) -> Self
Source§impl FromArrowType<&Schema> for DType
impl FromArrowType<&Schema> for DType
Source§fn from_arrow(value: &Schema) -> Self
fn from_arrow(value: &Schema) -> Self
Source§impl FromArrowType<(&DataType, Nullability)> for DType
impl FromArrowType<(&DataType, Nullability)> for DType
Source§fn from_arrow((data_type, nullability): (&DataType, Nullability)) -> Self
fn from_arrow((data_type, nullability): (&DataType, Nullability)) -> Self
Source§impl FromArrowType<Arc<Schema>> for DType
impl FromArrowType<Arc<Schema>> for DType
Source§fn from_arrow(value: SchemaRef) -> Self
fn from_arrow(value: SchemaRef) -> Self
Source§impl TryFrom<&DType> for DecimalDType
impl TryFrom<&DType> for DecimalDType
Source§impl TryFrom<&DType> for PType
impl TryFrom<&DType> for PType
Source§type Error = VortexError
type Error = VortexError
Source§fn try_from(value: &DType) -> VortexResult<Self>
fn try_from(value: &DType) -> VortexResult<Self>
Source§impl TryFrom<DType> for DecimalDType
impl TryFrom<DType> for DecimalDType
Source§impl WriteFlatBuffer for DType
impl WriteFlatBuffer for DType
Source§fn write_flatbuffer<'fb>(
&self,
fbb: &mut FlatBufferBuilder<'fb>,
) -> WIPOffset<Self::Target<'fb>>
fn write_flatbuffer<'fb>( &self, fbb: &mut FlatBufferBuilder<'fb>, ) -> WIPOffset<Self::Target<'fb>>
impl Eq for DType
impl FlatBufferRoot for DType
impl StructuralPartialEq for DType
Auto Trait Implementations§
impl Freeze for DType
impl RefUnwindSafe for DType
impl Send for DType
impl Sync for DType
impl Unpin for DType
impl UnwindSafe for DType
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> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.Source§impl<F> WriteFlatBufferExt for Fwhere
F: WriteFlatBuffer + FlatBufferRoot,
impl<F> WriteFlatBufferExt for Fwhere
F: WriteFlatBuffer + FlatBufferRoot,
Source§fn write_flatbuffer_bytes(&self) -> ConstBuffer<u8, 8>
fn write_flatbuffer_bytes(&self) -> ConstBuffer<u8, 8>
FlatBuffer byte buffer.