DType

Enum DType 

Source
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 i32 values.
  • 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

Source

pub fn to_arrow_schema(&self) -> VortexResult<Schema>

Convert a Vortex DType into an Arrow Schema.

Source

pub fn to_arrow_dtype(&self) -> VortexResult<DataType>

Returns the Arrow DataType that best corresponds to this Vortex DType.

Source§

impl DType

Source

pub const BYTES: Self

The default DType for bytes.

Source

pub fn nullability(&self) -> Nullability

Get the nullability of the DType.

Source

pub fn is_nullable(&self) -> bool

Check if the DType is Nullability::Nullable.

Source

pub fn as_nonnullable(&self) -> Self

Get a new DType with Nullability::NonNullable (but otherwise the same as self)

Source

pub fn as_nullable(&self) -> Self

Get a new DType with Nullability::Nullable (but otherwise the same as self)

Source

pub fn with_nullability(&self, nullability: Nullability) -> Self

Get a new DType with the given nullability (but otherwise the same as self)

Source

pub fn union_nullability(&self, other: Nullability) -> Self

Union the nullability of this DType with the other nullability, returning a new DType.

Source

pub fn eq_ignore_nullability(&self, other: &Self) -> bool

Check if self and other are equal, ignoring nullability.

Source

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.

Source

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.

Source

pub fn is_boolean(&self) -> bool

Check if self is a boolean

Source

pub fn is_primitive(&self) -> bool

Check if self is a primitive type

Source

pub fn as_ptype(&self) -> PType

Returns this DType’s PType if it is a primitive type, otherwise panics.

Source

pub fn is_unsigned_int(&self) -> bool

Check if self is an unsigned integer

Source

pub fn is_signed_int(&self) -> bool

Check if self is a signed integer

Source

pub fn is_int(&self) -> bool

Check if self is an integer (signed or unsigned)

Source

pub fn is_float(&self) -> bool

Check if self is a floating point number

Source

pub fn is_decimal(&self) -> bool

Check if self is a DType::Decimal.

Source

pub fn is_utf8(&self) -> bool

Check if self is a DType::Utf8

Source

pub fn is_binary(&self) -> bool

Check if self is a DType::Binary

Source

pub fn is_list(&self) -> bool

Check if self is a DType::List.

Source

pub fn is_fixed_size_list(&self) -> bool

Check if self is a DType::FixedSizeList,

Source

pub fn is_struct(&self) -> bool

Check if self is a DType::Struct

Source

pub fn is_extension(&self) -> bool

Check if self is a DType::Extension type

Source

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.

Source

pub fn as_decimal_opt(&self) -> Option<&DecimalDType>

Check returns the inner decimal type if the dtype is a DType::Decimal.

Source

pub fn into_decimal_opt(self) -> Option<DecimalDType>

Owned version of Self::as_decimal_opt.

Source

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.

Source

pub fn into_list_element_opt(self) -> Option<Arc<DType>>

Owned version of Self::as_list_element_opt.

Source

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.

Source

pub fn into_fixed_size_list_element_opt(self) -> Option<Arc<DType>>

Source

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

Source

pub fn into_any_size_list_element_opt(self) -> Option<Arc<DType>>

Source

pub fn as_struct_fields(&self) -> &StructFields

Returns the StructFields from a struct DType.

§Panics

If the DType is not a struct.

Source

pub fn into_struct_fields(self) -> StructFields

Owned version of Self::as_struct_fields.

Source

pub fn as_struct_fields_opt(&self) -> Option<&StructFields>

Get the StructDType if self is a StructDType, otherwise None

Source

pub fn into_struct_fields_opt(self) -> Option<StructFields>

Owned version of Self::as_struct_fields_opt.

Source

pub fn list(dtype: impl Into<DType>, nullability: Nullability) -> Self

Convenience method for creating a DType::List.

Source

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

Source

pub fn try_from_view(fb: DType<'_>, buffer: FlatBuffer) -> VortexResult<Self>

Create a new

Trait Implementations§

Source§

impl<'a> Arbitrary<'a> for DType

Source§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl Clone for DType

Source§

fn clone(&self) -> DType

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for DType

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for DType

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&DType> for DType

Source§

fn from(value: &DType) -> Self

Converts to this type from the input type.
Source§

impl From<DType> for FieldDType

Source§

fn from(value: DType) -> Self

Converts to this type from the input type.
Source§

impl From<PType> for &DType

Source§

fn from(item: PType) -> Self

Converts to this type from the input type.
Source§

impl From<PType> for DType

Source§

fn from(item: PType) -> Self

Converts to this type from the input type.
Source§

impl FromArrowType<&Field> for DType

Source§

fn from_arrow(field: &Field) -> Self

Convert the Arrow type to a Vortex type.
Source§

impl FromArrowType<&Schema> for DType

Source§

fn from_arrow(value: &Schema) -> Self

Convert the Arrow type to a Vortex type.
Source§

impl FromArrowType<(&DataType, Nullability)> for DType

Source§

fn from_arrow((data_type, nullability): (&DataType, Nullability)) -> Self

Convert the Arrow type to a Vortex type.
Source§

impl FromArrowType<Arc<Schema>> for DType

Source§

fn from_arrow(value: SchemaRef) -> Self

Convert the Arrow type to a Vortex type.
Source§

impl Hash for DType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for DType

Source§

fn eq(&self, other: &DType) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for DType

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl TryFrom<&DType> for DType

Source§

type Error = VortexError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &DType) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&DType> for DecimalDType

Source§

type Error = VortexError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &DType) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<&DType> for PType

Source§

type Error = VortexError

The type returned in the event of a conversion error.
Source§

fn try_from(value: &DType) -> VortexResult<Self>

Performs the conversion.
Source§

impl TryFrom<DType> for DecimalDType

Source§

type Error = VortexError

The type returned in the event of a conversion error.
Source§

fn try_from(value: DType) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl WriteFlatBuffer for DType

Source§

type Target<'a> = DType<'a>

The FlatBuffer type that this type can be written to.
Source§

fn write_flatbuffer<'fb>( &self, fbb: &mut FlatBufferBuilder<'fb>, ) -> WIPOffset<Self::Target<'fb>>

Writes this type to a FlatBuffer builder.
Source§

impl Eq for DType

Source§

impl FlatBufferRoot for DType

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Conv for T

Source§

fn conv<T>(self) -> T
where Self: Into<T>,

Converts self into T using Into<T>. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> FmtForward for T

Source§

fn fmt_binary(self) -> FmtBinary<Self>
where Self: Binary,

Causes self to use its Binary implementation when Debug-formatted.
Source§

fn fmt_display(self) -> FmtDisplay<Self>
where Self: Display,

Causes self to use its Display implementation when Debug-formatted.
Source§

fn fmt_lower_exp(self) -> FmtLowerExp<Self>
where Self: LowerExp,

Causes self to use its LowerExp implementation when Debug-formatted.
Source§

fn fmt_lower_hex(self) -> FmtLowerHex<Self>
where Self: LowerHex,

Causes self to use its LowerHex implementation when Debug-formatted.
Source§

fn fmt_octal(self) -> FmtOctal<Self>
where Self: Octal,

Causes self to use its Octal implementation when Debug-formatted.
Source§

fn fmt_pointer(self) -> FmtPointer<Self>
where Self: Pointer,

Causes self to use its Pointer implementation when Debug-formatted.
Source§

fn fmt_upper_exp(self) -> FmtUpperExp<Self>
where Self: UpperExp,

Causes self to use its UpperExp implementation when Debug-formatted.
Source§

fn fmt_upper_hex(self) -> FmtUpperHex<Self>
where Self: UpperHex,

Causes self to use its UpperHex implementation when Debug-formatted.
Source§

fn fmt_list(self) -> FmtList<Self>
where &'a Self: for<'a> IntoIterator,

Formats each item in a sequence. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pipe for T
where T: ?Sized,

Source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
Source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
Source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
Source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows 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
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows 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
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
Source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R, ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
Source§

impl<T> Tap for T

Source§

fn tap(self, func: impl FnOnce(&Self)) -> Self

Immutable access to a value. Read more
Source§

fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self

Mutable access to a value. Read more
Source§

fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Immutable access to the Borrow<B> of a value. Read more
Source§

fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
where Self: BorrowMut<B>, B: ?Sized,

Mutable access to the BorrowMut<B> of a value. Read more
Source§

fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
where Self: AsRef<R>, R: ?Sized,

Immutable access to the AsRef<R> view of a value. Read more
Source§

fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
where Self: AsMut<R>, R: ?Sized,

Mutable access to the AsMut<R> view of a value. Read more
Source§

fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
where Self: Deref<Target = T>, T: ?Sized,

Immutable access to the Deref::Target of a value. Read more
Source§

fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Mutable access to the Deref::Target of a value. Read more
Source§

fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self

Calls .tap() only in debug builds, and is erased in release builds.
Source§

fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self

Calls .tap_mut() only in debug builds, and is erased in release builds.
Source§

fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
where Self: Borrow<B>, B: ?Sized,

Calls .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
where Self: BorrowMut<B>, B: ?Sized,

Calls .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
where Self: AsRef<R>, R: ?Sized,

Calls .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
where Self: AsMut<R>, R: ?Sized,

Calls .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
where Self: Deref<Target = T>, T: ?Sized,

Calls .tap_deref() only in debug builds, and is erased in release builds.
Source§

fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self
where Self: DerefMut<Target = T> + Deref, T: ?Sized,

Calls .tap_deref_mut() only in debug builds, and is erased in release builds.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T> TryConv for T

Source§

fn try_conv<T>(self) -> Result<T, Self::Error>
where Self: TryInto<T>,

Attempts to convert self into T using TryInto<T>. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<F> WriteFlatBufferExt for F

Source§

fn write_flatbuffer_bytes(&self) -> ConstBuffer<u8, 8>

Writes self as a FlatBuffer root object into a FlatBuffer byte buffer.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,