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) -> &ChunkColumnDescriptors
pub fn view_contents(&self) -> &ChunkColumnDescriptors
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(&mut self, row_idx: usize)
pub fn seek_to_row(&mut 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.
§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 row_index_at_or_before_time(&self, time: TimeInt) -> Option<u64>
pub fn row_index_at_or_before_time(&self, time: TimeInt) -> Option<u64>
Returns the row index of the last row whose index value is <= the given time,
or None if no such row exists.
Sourcepub fn next_row(&mut self) -> Option<Vec<ArrayRef>>
pub fn next_row(&mut 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(
&mut self,
) -> impl Future<Output = Option<Vec<ArrayRef>>> + use<E>
pub fn next_row_async( &mut self, ) -> impl Future<Output = Option<Vec<ArrayRef>>> + use<E>
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 {
// …
}Sourcepub fn next_n_rows(
&mut self,
max_rows: usize,
max_bytes: usize,
) -> NextNRowsOutput
pub fn next_n_rows( &mut self, max_rows: usize, max_bytes: usize, ) -> NextNRowsOutput
Append up to max_rows rows of data into freshly allocated per-column arrays.
Throughput-oriented sibling of Self::next_row: shares the streaming-join machinery but
amortizes per-row allocation by batching MutableArrayData extends and only finalizing
to ArrayRef once per call.
The returned NextNRowsOutput::columns strictly follows the schema specified by
Self::schema, with num_rows == 0 signalling exhaustion.
max_bytes caps the estimated output-buffer footprint of the batch (sum of
per-row source-array bytes, computed from ArrayData::get_array_memory_size / len). Pass usize::MAX to disable the byte cap. The first row is always
admitted regardless of the cap, so a single wide row can exceed max_bytes.
Sourcepub fn next_n_rows_async(
&mut self,
max_rows: usize,
max_bytes: usize,
) -> impl Future<Output = NextNRowsOutput> + use<'_, E>
pub fn next_n_rows_async( &mut self, max_rows: usize, max_bytes: usize, ) -> impl Future<Output = NextNRowsOutput> + use<'_, E>
Asynchronous sibling of Self::next_n_rows.
Sourcepub fn next_row_batch(&mut self) -> Option<ArrowRecordBatch>
pub fn next_row_batch(&mut 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(&mut self) -> Option<ArrowRecordBatch>
Source§impl<E: StorageEngineLike> QueryHandle<E>
impl<E: StorageEngineLike> QueryHandle<E>
Sourcepub fn iter(&mut self) -> impl Iterator<Item = Vec<ArrowArrayRef>> + '_
pub fn iter(&mut 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(&mut self) -> impl Iterator<Item = ArrowRecordBatch> + '_
pub fn batch_iter(&mut 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> UnsafeUnpin for QueryHandle<E>where
E: UnsafeUnpin,
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> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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::Request