Struct vortex_array::array::TemporalArray
source · pub struct TemporalArray { /* private fields */ }
Expand description
An array wrapper for primitive values that have an associated temporal meaning.
This is a wrapper around ExtensionArrays containing numeric types, each of which corresponds to either a timestamp or julian date (both referenced to UNIX epoch), OR a time since midnight.
§Arrow compatibility
TemporalArray can be created from Arrow arrays containing the following datatypes:
Time32
Time64
Timestamp
Date32
Date64
Anything that can be constructed and held in a TemporalArray
can also be zero-copy converted
back to the relevant Arrow datatype.
Implementations§
source§impl TemporalArray
impl TemporalArray
sourcepub fn new_date(array: ArrayData, time_unit: TimeUnit) -> Self
pub fn new_date(array: ArrayData, time_unit: TimeUnit) -> Self
Create a new TemporalArray
holding either i32 day offsets, or i64 millisecond offsets
that are evenly divisible by the number of 86,400,000.
This is equivalent to the data described by either of the Date32
or Date64
data types
from Arrow.
§Panics
If the time unit is milliseconds, and the array is not of primitive I64 type, it panics.
If the time unit is days, and the array is not of primitive I32 type, it panics.
If any other time unit is provided, it panics.
sourcepub fn new_time(array: ArrayData, time_unit: TimeUnit) -> Self
pub fn new_time(array: ArrayData, time_unit: TimeUnit) -> Self
Create a new TemporalArray
holding one of the following values:
i32
values representing seconds since midnighti32
values representing milliseconds since midnighti64
values representing microseconds since midnighti64
values representing nanoseconds since midnight
Note, this is equivalent to the set of values represented by the Time32 or Time64 types from Arrow.
§Panics
If the time unit is seconds, and the array is not of primitive I32 type, it panics.
If the time unit is milliseconds, and the array is not of primitive I32 type, it panics.
If the time unit is microseconds, and the array is not of primitive I64 type, it panics.
If the time unit is nanoseconds, and the array is not of primitive I64 type, it panics.
sourcepub fn new_timestamp(
array: ArrayData,
time_unit: TimeUnit,
time_zone: Option<String>,
) -> Self
pub fn new_timestamp( array: ArrayData, time_unit: TimeUnit, time_zone: Option<String>, ) -> Self
Create a new TemporalArray
holding Arrow spec compliant Timestamp data, with an
optional timezone.
§Panics
If array
does not hold Primitive i64 data, the function will panic.
If the time_unit is days, the function will panic.
source§impl TemporalArray
impl TemporalArray
sourcepub fn temporal_values(&self) -> ArrayData
pub fn temporal_values(&self) -> ArrayData
Access the underlying temporal values in the underlying ExtensionArray storage.
These values are to be interpreted based on the time unit and optional time-zone stored in the TemporalMetadata.
sourcepub fn temporal_metadata(&self) -> &TemporalMetadata
pub fn temporal_metadata(&self) -> &TemporalMetadata
Retrieve the temporal metadata.
The metadata is used to provide semantic meaning to the temporal values Array, for example to understand the granularity of the samples and if they have an associated timezone.
Trait Implementations§
source§impl Clone for TemporalArray
impl Clone for TemporalArray
source§fn clone(&self) -> TemporalArray
fn clone(&self) -> TemporalArray
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TemporalArray
impl Debug for TemporalArray
source§impl From<&TemporalArray> for ExtensionArray
impl From<&TemporalArray> for ExtensionArray
source§fn from(value: &TemporalArray) -> Self
fn from(value: &TemporalArray) -> Self
source§impl From<TemporalArray> for ArrayData
impl From<TemporalArray> for ArrayData
source§fn from(value: TemporalArray) -> Self
fn from(value: TemporalArray) -> Self
source§impl From<TemporalArray> for ExtensionArray
impl From<TemporalArray> for ExtensionArray
source§fn from(value: TemporalArray) -> Self
fn from(value: TemporalArray) -> Self
source§impl TryFrom<ArrayData> for TemporalArray
impl TryFrom<ArrayData> for TemporalArray
source§fn try_from(value: ArrayData) -> Result<Self, Self::Error>
fn try_from(value: ArrayData) -> Result<Self, Self::Error>
Try to specialize a generic Vortex array as a TemporalArray.
§Errors
If the provided Array does not have vortex.ext
encoding, an error will be returned.
If the provided Array does not have recognized ExtMetadata corresponding to one of the known
TemporalMetadata
variants, an error is returned.
source§impl TryFrom<ExtensionArray> for TemporalArray
impl TryFrom<ExtensionArray> for TemporalArray
Auto Trait Implementations§
impl !Freeze for TemporalArray
impl !RefUnwindSafe for TemporalArray
impl Send for TemporalArray
impl Sync for TemporalArray
impl Unpin for TemporalArray
impl !UnwindSafe for TemporalArray
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more