pub struct LimitedBatchCoalescer {
inner: BatchCoalescer,
total_rows: usize,
fetch: Option<usize>,
finished: bool,
}Expand description
Concatenate multiple [RecordBatch]es and apply a limit
See [BatchCoalescer] for more details on how this works.
Fields§
§inner: BatchCoalescerThe arrow structure that builds the output batches
total_rows: usizeTotal number of rows returned so far
fetch: Option<usize>Limit: maximum number of rows to fetch, None means fetch all rows
finished: boolIndicates if the coalescer is finished
Implementations§
Source§impl LimitedBatchCoalescer
impl LimitedBatchCoalescer
Sourcepub fn new(
schema: SchemaRef,
target_batch_size: usize,
fetch: Option<usize>,
) -> Self
pub fn new( schema: SchemaRef, target_batch_size: usize, fetch: Option<usize>, ) -> Self
Create a new BatchCoalescer
§Arguments
schema- the schema of the output batchestarget_batch_size- the minimum number of rows for each output batch (until limit reached)fetch- the maximum number of rows to fetch,Nonemeans fetch all rows
Sourcepub fn push_batch(&mut self, batch: RecordBatch) -> Result<PushBatchStatus>
pub fn push_batch(&mut self, batch: RecordBatch) -> Result<PushBatchStatus>
Pushes the next [RecordBatch] into the coalescer and returns its status.
§Arguments
batch- The [RecordBatch] to append.
§Returns
PushBatchStatus::Continue- More batches can still be pushed.PushBatchStatus::LimitReached- The row limit was reached after processing this batch. The caller should callSelf::finishbefore retrieving the remaining buffered batches.
§Errors
Returns an error if called after Self::finish or if the internal push
operation fails.
Sourcepub fn finish(&mut self) -> Result<()>
pub fn finish(&mut self) -> Result<()>
Complete the current buffered batch and finish the coalescer
Any subsequent calls to push_batch() will return an Err
Sourcepub fn next_completed_batch(&mut self) -> Option<RecordBatch>
pub fn next_completed_batch(&mut self) -> Option<RecordBatch>
Return the next completed batch, if any
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LimitedBatchCoalescer
impl !RefUnwindSafe for LimitedBatchCoalescer
impl Send for LimitedBatchCoalescer
impl Sync for LimitedBatchCoalescer
impl Unpin for LimitedBatchCoalescer
impl !UnwindSafe for LimitedBatchCoalescer
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
§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>
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