pub struct SortBuilder { /* private fields */ }Expand description
Streaming sort index builder.
Create with SortBuilder::new, feed batches via SortBuilder::push,
then call SortBuilder::finish to produce the sorted PermutationIndex.
§Example
ⓘ
let mut builder = SortBuilder::new(vec![
SortField::new(DataType::Int64),
SortField::new_with_options(DataType::Utf8, SortOptions { descending: true, .. }),
])?;
for batch in record_batch_stream {
builder.push(&batch, &[0, 2])?; // sort by columns 0 and 2
}
let index = builder.finish()?;Implementations§
Source§impl SortBuilder
impl SortBuilder
Sourcepub fn new(fields: Vec<SortField>) -> Result<Self, IndexError>
pub fn new(fields: Vec<SortField>) -> Result<Self, IndexError>
Create a new builder for a sort with the given fields.
fields defines the sort key schema and direction. One SortField per
sort column, in priority order (first = primary, second = tiebreaker, …).
§Errors
IndexError::EmptyColumnsiffieldsis empty.IndexError::RowEncodingFailedif theRowConvertercannot be created.
Sourcepub fn push(
&mut self,
batch: &RecordBatch,
sort_columns: &[usize],
) -> Result<(), IndexError>
pub fn push( &mut self, batch: &RecordBatch, sort_columns: &[usize], ) -> Result<(), IndexError>
Ingest one RecordBatch.
sort_columns are the column indices within batch that correspond
to the SortFields passed to SortBuilder::new. Must have the same length.
The batch’s sort columns are encoded into fixed-width row keys; the batch itself is NOT retained.
§Errors
IndexError::LengthMismatchifsort_columns.len() != fields.len().IndexError::TooManyRowsif cumulative rows exceedu32::MAX.IndexError::RowEncodingFailedon encoding failure.
Sourcepub fn rows_ingested(&self) -> u64
pub fn rows_ingested(&self) -> u64
Total rows ingested so far.
Sourcepub fn finish(self) -> Result<PermutationIndex, IndexError>
pub fn finish(self) -> Result<PermutationIndex, IndexError>
Consume the builder, run parallel argsort, and produce a PermutationIndex.
§Errors
IndexError::EmptyColumnsif no rows were pushed.- [
IndexError::MmapError] if mmap storage creation fails (whenmmapfeature is enabled).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SortBuilder
impl RefUnwindSafe for SortBuilder
impl Send for SortBuilder
impl Sync for SortBuilder
impl Unpin for SortBuilder
impl UnsafeUnpin for SortBuilder
impl UnwindSafe for SortBuilder
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
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>
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