pub struct FieldPath(/* private fields */);
Expand description
A sequence of field selectors representing a path through zero or more layers of DType
.
§Examples
The empty path references the root:
use vortex_dtype::*;
let dtype_i32 = DType::Primitive(PType::I32, Nullability::NonNullable);
assert_eq!(dtype_i32, FieldPath::root().resolve(dtype_i32.clone()).unwrap());
Implementations§
Source§impl FieldPath
impl FieldPath
Sourcepub fn from_name<F: Into<Field>>(name: F) -> Self
pub fn from_name<F: Into<Field>>(name: F) -> Self
Constructs a new FieldPath
from a single field selector (i.e., a direct child field of the top-level struct)
Sourcepub fn push<F: Into<Field>>(self, field: F) -> Self
pub fn push<F: Into<Field>>(self, field: F) -> Self
Pushes a new field selector to the end of this path
Sourcepub fn starts_with_field(&self, field: &Field) -> bool
pub fn starts_with_field(&self, field: &Field) -> bool
Whether the path starts with the given field name TODO(joe): handle asserts better.
Sourcepub fn resolve(&self, dtype: DType) -> Option<DType>
pub fn resolve(&self, dtype: DType) -> Option<DType>
The dtype, within the given type, to which this field path refers.
Note that a nullable DType may contain a non-nullable DType. This function returns the literal nullability of the child.
§Examples
Extract the type of the “b” field from struct{a: list(struct{b: u32})?}
:
use std::sync::Arc;
use vortex_dtype::*;
use vortex_dtype::Nullability::*;
let dtype = DType::Struct(
StructFields::from_iter([(
"a",
DType::List(
Arc::new(DType::Struct(
StructFields::from_iter([(
"b",
DType::Primitive(PType::U32, NonNullable),
)]),
NonNullable,
)),
Nullable,
),
)]),
NonNullable,
);
let path = FieldPath::from(vec![Field::from("a"), Field::ElementType, Field::from("b")]);
let resolved = path.resolve(dtype).unwrap();
assert_eq!(resolved, DType::Primitive(PType::U32, NonNullable));
Trait Implementations§
Source§impl FromIterator<Field> for FieldPath
impl FromIterator<Field> for FieldPath
Source§impl FromIterator<FieldPath> for FieldPathSet
impl FromIterator<FieldPath> for FieldPathSet
impl Eq for FieldPath
impl StructuralPartialEq for FieldPath
Auto Trait Implementations§
impl Freeze for FieldPath
impl RefUnwindSafe for FieldPath
impl Send for FieldPath
impl Sync for FieldPath
impl Unpin for FieldPath
impl UnwindSafe for FieldPath
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
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>
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