pub struct ChunkBuilder { /* private fields */ }
Expand description
Helper to incrementally build a Chunk
.
Can be created using Chunk::builder
.
Implementations§
Source§impl ChunkBuilder
impl ChunkBuilder
Sourcepub fn new(id: ChunkId, entity_path: EntityPath) -> Self
pub fn new(id: ChunkId, entity_path: EntityPath) -> Self
Initializes a new ChunkBuilder
.
See also Chunk::builder
.
Sourcepub fn with_sparse_row(
self,
row_id: RowId,
timepoint: impl Into<TimePoint>,
components: impl IntoIterator<Item = (ComponentName, Option<Box<dyn ArrowArray>>)>,
) -> Self
pub fn with_sparse_row( self, row_id: RowId, timepoint: impl Into<TimePoint>, components: impl IntoIterator<Item = (ComponentName, Option<Box<dyn ArrowArray>>)>, ) -> Self
Add a row’s worth of data using the given sparse component data.
Sourcepub fn with_row(
self,
row_id: RowId,
timepoint: impl Into<TimePoint>,
components: impl IntoIterator<Item = (ComponentName, Box<dyn ArrowArray>)>,
) -> Self
pub fn with_row( self, row_id: RowId, timepoint: impl Into<TimePoint>, components: impl IntoIterator<Item = (ComponentName, Box<dyn ArrowArray>)>, ) -> Self
Add a row’s worth of data using the given component data.
Sourcepub fn with_archetype(
self,
row_id: RowId,
timepoint: impl Into<TimePoint>,
as_components: &dyn AsComponents,
) -> Self
pub fn with_archetype( self, row_id: RowId, timepoint: impl Into<TimePoint>, as_components: &dyn AsComponents, ) -> Self
Add a row’s worth of data by destructuring an archetype into component columns.
Sourcepub fn with_component_batch(
self,
row_id: RowId,
timepoint: impl Into<TimePoint>,
component_batch: &dyn ComponentBatch,
) -> Self
pub fn with_component_batch( self, row_id: RowId, timepoint: impl Into<TimePoint>, component_batch: &dyn ComponentBatch, ) -> Self
Add a row’s worth of data by serializing a single ComponentBatch
.
Sourcepub fn with_component_batches<'a>(
self,
row_id: RowId,
timepoint: impl Into<TimePoint>,
component_batches: impl IntoIterator<Item = &'a dyn ComponentBatch>,
) -> Self
pub fn with_component_batches<'a>( self, row_id: RowId, timepoint: impl Into<TimePoint>, component_batches: impl IntoIterator<Item = &'a dyn ComponentBatch>, ) -> Self
Add a row’s worth of data by serializing many ComponentBatch
es.
Sourcepub fn with_sparse_component_batches<'a>(
self,
row_id: RowId,
timepoint: impl Into<TimePoint>,
component_batches: impl IntoIterator<Item = (ComponentName, Option<&'a dyn ComponentBatch>)>,
) -> Self
pub fn with_sparse_component_batches<'a>( self, row_id: RowId, timepoint: impl Into<TimePoint>, component_batches: impl IntoIterator<Item = (ComponentName, Option<&'a dyn ComponentBatch>)>, ) -> Self
Add a row’s worth of data by serializing many sparse ComponentBatch
es.
Sourcepub fn build(self) -> ChunkResult<Chunk>
pub fn build(self) -> ChunkResult<Chunk>
Builds and returns the final Chunk
.
The arrow datatype of each individual column will be guessed by inspecting the data.
If any component column turns out to be fully sparse (i.e. only null values), that column will be stripped out (how could we guess its datatype without any single value to inspect)?
This is generally the desired behavior but, if you want to make sure to keep fully sparse
columns (can be useful e.g. for testing purposes), see ChunkBuilder::build_with_datatypes
instead.
This returns an error if the chunk fails to sanity_check
.
Sourcepub fn build_with_datatypes(
self,
datatypes: &IntMap<ComponentName, ArrowDatatype>,
) -> ChunkResult<Chunk>
pub fn build_with_datatypes( self, datatypes: &IntMap<ComponentName, ArrowDatatype>, ) -> ChunkResult<Chunk>
Builds and returns the final Chunk
.
The arrow datatype of each individual column will be guessed by inspecting the data.
If any component column turns out to be fully sparse (i.e. only null values), datatypes
will be used as a fallback.
If any component column turns out to be fully sparse (i.e. only null values) and doesn’t have an explicit datatype passed in, that column will be stripped out (how could we guess its datatype without any single value to inspect)?
You should rarely want to keep fully sparse columns around outside of testing scenarios.
See Self::build
.
This returns an error if the chunk fails to sanity_check
.
Auto Trait Implementations§
impl Freeze for ChunkBuilder
impl !RefUnwindSafe for ChunkBuilder
impl Send for ChunkBuilder
impl Sync for ChunkBuilder
impl Unpin for ChunkBuilder
impl !UnwindSafe for ChunkBuilder
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 more