pub struct BatchBuilder {
schema: SchemaRef,
batches: Vec<(usize, RecordBatch)>,
reservation: MemoryReservation,
cursors: Vec<BatchCursor>,
indices: Vec<(usize, usize)>,
}Expand description
Provides an API to incrementally build a [RecordBatch] from partitioned [RecordBatch]
Fields§
§schema: SchemaRefThe schema of the RecordBatches yielded by this stream
batches: Vec<(usize, RecordBatch)>Maintain a list of [RecordBatch] and their corresponding stream
reservation: MemoryReservationAccounts for memory used by buffered batches
cursors: Vec<BatchCursor>The current BatchCursor for each stream
indices: Vec<(usize, usize)>The accumulated stream indexes from which to pull rows
Consists of a tuple of (batch_idx, row_idx)
Implementations§
Source§impl BatchBuilder
impl BatchBuilder
Sourcepub fn new(
schema: SchemaRef,
stream_count: usize,
batch_size: usize,
reservation: MemoryReservation,
) -> Self
pub fn new( schema: SchemaRef, stream_count: usize, batch_size: usize, reservation: MemoryReservation, ) -> Self
Create a new BatchBuilder with the provided stream_count and batch_size
Sourcepub fn push_batch(
&mut self,
stream_idx: usize,
batch: RecordBatch,
) -> Result<()>
pub fn push_batch( &mut self, stream_idx: usize, batch: RecordBatch, ) -> Result<()>
Append a new batch in stream_idx
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Returns the number of in-progress rows in this BatchBuilder
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if this BatchBuilder contains no in-progress rows
Sourcepub fn schema(&self) -> &SchemaRef
pub fn schema(&self) -> &SchemaRef
Returns the schema of this BatchBuilder
Sourcepub fn build_record_batch(&mut self) -> Result<Option<RecordBatch>>
pub fn build_record_batch(&mut self) -> Result<Option<RecordBatch>>
Drains the in_progress row indexes, and builds a new RecordBatch from them
Will then drop any batches for which all rows have been yielded to the output
Returns None if no pending rows
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BatchBuilder
impl !RefUnwindSafe for BatchBuilder
impl Send for BatchBuilder
impl Sync for BatchBuilder
impl Unpin for BatchBuilder
impl !UnwindSafe for BatchBuilder
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
§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