pub struct QueryHandle<E: StorageEngineLike> { /* private fields */ }Expand description
A handle to a dataframe query, ready to be executed.
Cheaply created via QueryEngine::query.
Implementations§
Source§impl<E: StorageEngineLike> QueryHandle<E>
impl<E: StorageEngineLike> QueryHandle<E>
Sourcepub fn query(&self) -> &QueryExpression
pub fn query(&self) -> &QueryExpression
The query used to instantiate this handle.
Sourcepub fn view_contents(&self) -> &SorbetColumnDescriptors
pub fn view_contents(&self) -> &SorbetColumnDescriptors
Describes the columns that make up this view.
Sourcepub fn selected_contents(&self) -> &[(usize, ColumnDescriptor)]
pub fn selected_contents(&self) -> &[(usize, ColumnDescriptor)]
Describes the columns that make up this selection.
The extra usize is the index in Self::view_contents that this selection points to.
Sourcepub fn schema(&self) -> &ArrowSchemaRef
pub fn schema(&self) -> &ArrowSchemaRef
All results returned by this handle will strictly follow this Arrow schema.
Columns that do not yield any data will still be present in the results, filled with null values.
Sourcepub fn seek_to_row(&self, row_idx: usize)
pub fn seek_to_row(&self, row_idx: usize)
Advance all internal cursors so that the next row yielded will correspond to row_idx.
Does nothing if row_idx is out of bounds.
§Concurrency
Cursors are implemented using atomic variables, which means calling any of the seek_*
while iteration is concurrently ongoing is memory-safe but logically undefined racy
behavior. Be careful.
§Performance
This requires going through every chunk once, and for each chunk running a binary search if
the chunk’s time range contains the index_value.
I.e.: it’s pretty cheap already.
Sourcepub fn num_rows(&self) -> u64
pub fn num_rows(&self) -> u64
How many rows of data will be returned?
The number of rows depends and only depends on the view contents. The selected contents has no influence on this value.
Sourcepub fn next_row(&self) -> Option<Vec<ArrayRef>>
pub fn next_row(&self) -> Option<Vec<ArrayRef>>
Returns the next row’s worth of data.
The returned vector of Arrow arrays strictly follows the schema specified by Self::schema.
Columns that do not yield any data will still be present in the results, filled with null values.
Each cell in the result corresponds to the latest locally known value at that particular point in
the index, for each respective ColumnDescriptor.
See QueryExpression::sparse_fill_strategy to go beyond local resolution.
Example:
while let Some(row) = query_handle.next_row() {
// …
}§Pagination
Use Self::seek_to_row:
query_handle.seek_to_row(42);
for row in query_handle.into_iter().take(len) {
// …
}Sourcepub fn next_row_async(&self) -> impl Future<Output = Option<Vec<ArrayRef>>>
pub fn next_row_async(&self) -> impl Future<Output = Option<Vec<ArrayRef>>>
Asynchronously returns the next row’s worth of data.
The returned vector of Arrow arrays strictly follows the schema specified by Self::schema.
Columns that do not yield any data will still be present in the results, filled with null values.
Each cell in the result corresponds to the latest locally known value at that particular point in
the index, for each respective ColumnDescriptor.
See QueryExpression::sparse_fill_strategy to go beyond local resolution.
Example:
while let Some(row) = query_handle.next_row_async().await {
// …
}pub fn _next_row( &self, store: &ChunkStore, cache: &QueryCache, ) -> Option<Vec<ArrowArrayRef>>
Sourcepub fn next_row_batch(&self) -> Option<ArrowRecordBatch>
pub fn next_row_batch(&self) -> Option<ArrowRecordBatch>
Calls Self::next_row and wraps the result in a ArrowRecordBatch.
Only use this if you absolutely need a ArrowRecordBatch as this adds a
some overhead for schema validation.
See Self::next_row for more information.
pub async fn next_row_batch_async(&self) -> Option<ArrowRecordBatch>
Source§impl<E: StorageEngineLike> QueryHandle<E>
impl<E: StorageEngineLike> QueryHandle<E>
Sourcepub fn iter(&self) -> impl Iterator<Item = Vec<ArrowArrayRef>> + '_
pub fn iter(&self) -> impl Iterator<Item = Vec<ArrowArrayRef>> + '_
Returns an iterator backed by Self::next_row.
Sourcepub fn into_iter(self) -> impl Iterator<Item = Vec<ArrowArrayRef>>
pub fn into_iter(self) -> impl Iterator<Item = Vec<ArrowArrayRef>>
Returns an iterator backed by Self::next_row.
Sourcepub fn batch_iter(&self) -> impl Iterator<Item = ArrowRecordBatch> + '_
pub fn batch_iter(&self) -> impl Iterator<Item = ArrowRecordBatch> + '_
Returns an iterator backed by Self::next_row_batch.
Sourcepub fn into_batch_iter(self) -> impl Iterator<Item = ArrowRecordBatch>
pub fn into_batch_iter(self) -> impl Iterator<Item = ArrowRecordBatch>
Returns an iterator backed by Self::next_row_batch.
Auto Trait Implementations§
impl<E> !Freeze for QueryHandle<E>
impl<E> !RefUnwindSafe for QueryHandle<E>
impl<E> Send for QueryHandle<E>where
E: Send,
impl<E> Sync for QueryHandle<E>where
E: Sync,
impl<E> Unpin for QueryHandle<E>where
E: Unpin,
impl<E> !UnwindSafe for QueryHandle<E>
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§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> Pointable for T
impl<T> Pointable for T
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
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.