pub struct ChunkBuilder {
id: ChunkId,
entity_path: EntityPath,
row_ids: Vec<RowId>,
timelines: BTreeMap<Timeline, TimeColumnBuilder>,
components: BTreeMap<ComponentName, Vec<Option<Box<dyn Array>>>>,
}
Expand description
Helper to incrementally build a Chunk
.
Can be created using Chunk::builder
.
Fields§
§id: ChunkId
§entity_path: EntityPath
§row_ids: Vec<RowId>
§timelines: BTreeMap<Timeline, TimeColumnBuilder>
§components: BTreeMap<ComponentName, Vec<Option<Box<dyn Array>>>>
Implementations§
source§impl ChunkBuilder
impl ChunkBuilder
sourcepub fn new(id: ChunkId, entity_path: EntityPath) -> ChunkBuilder
pub fn new(id: ChunkId, entity_path: EntityPath) -> ChunkBuilder
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 Array>>)>
) -> ChunkBuilder
pub fn with_sparse_row( self, row_id: RowId, timepoint: impl Into<TimePoint>, components: impl IntoIterator<Item = (ComponentName, Option<Box<dyn Array>>)> ) -> ChunkBuilder
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 Array>)>
) -> ChunkBuilder
pub fn with_row( self, row_id: RowId, timepoint: impl Into<TimePoint>, components: impl IntoIterator<Item = (ComponentName, Box<dyn Array>)> ) -> ChunkBuilder
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
) -> ChunkBuilder
pub fn with_archetype( self, row_id: RowId, timepoint: impl Into<TimePoint>, as_components: &dyn AsComponents ) -> ChunkBuilder
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<Name = ComponentName>
) -> ChunkBuilder
pub fn with_component_batch( self, row_id: RowId, timepoint: impl Into<TimePoint>, component_batch: &dyn ComponentBatch<Name = ComponentName> ) -> ChunkBuilder
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<Name = ComponentName>>
) -> ChunkBuilder
pub fn with_component_batches<'a>( self, row_id: RowId, timepoint: impl Into<TimePoint>, component_batches: impl IntoIterator<Item = &'a dyn ComponentBatch<Name = ComponentName>> ) -> ChunkBuilder
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<Name = ComponentName>>)>
) -> ChunkBuilder
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<Name = ComponentName>>)> ) -> ChunkBuilder
Add a row’s worth of data by serializing many sparse ComponentBatch
es.
sourcepub fn build(self) -> Result<Chunk, ChunkError>
pub fn build(self) -> Result<Chunk, ChunkError>
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: &HashMap<ComponentName, DataType, BuildHasherDefault<NoHashHasher<ComponentName>>>
) -> Result<Chunk, ChunkError>
pub fn build_with_datatypes( self, datatypes: &HashMap<ComponentName, DataType, BuildHasherDefault<NoHashHasher<ComponentName>>> ) -> Result<Chunk, ChunkError>
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>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for 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 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