Struct rerun::sdk::log::ChunkBatcher
source · pub struct ChunkBatcher {
inner: Arc<ChunkBatcherInner>,
}
Expand description
Implements an asynchronous batcher that coalesces PendingRow
s into Chunk
s based upon
the thresholds defined in the associated ChunkBatcherConfig
.
§Batching vs. splitting
The batching process is triggered solely by time and space thresholds – whichever is hit first. This process will result in one big dataframe.
The splitting process will then run on top of that big dataframe, and split it further down
into smaller Chunk
s.
Specifically, the dataframe will be splits into enough Chunk
s so as to guarantee that:
- no chunk contains data for more than one entity path
- no chunk contains rows with different sets of timelines
- no chunk uses more than one datatype for a given component
- no chunk contains more rows than a pre-configured threshold if one or more timelines are unsorted
§Multithreading and ordering
ChunkBatcher
can be cheaply clone and used freely across any number of threads.
Internally, all operations are linearized into a pipeline:
- All operations sent by a given thread will take effect in the same exact order as that thread originally sent them in, from its point of view.
- There isn’t any well defined global order across multiple threads.
This means that e.g. flushing the pipeline (Self::flush_blocking
) guarantees that all
previous data sent by the calling thread has been batched and sent down the channel returned
by ChunkBatcher::chunks
; no more, no less.
§Shutdown
The batcher can only be shutdown by dropping all instances of it, at which point it will automatically take care of flushing any pending data that might remain in the pipeline.
Shutting down cannot ever block.
Fields§
§inner: Arc<ChunkBatcherInner>
Implementations§
source§impl ChunkBatcher
impl ChunkBatcher
sourcepub fn new(
config: ChunkBatcherConfig
) -> Result<ChunkBatcher, ChunkBatcherError>
pub fn new( config: ChunkBatcherConfig ) -> Result<ChunkBatcher, ChunkBatcherError>
Creates a new ChunkBatcher
using the passed in config
.
The returned object must be kept in scope: dropping it will trigger a clean shutdown of the batcher.
pub fn push_chunk(&self, chunk: Chunk)
sourcepub fn push_row(&self, entity_path: EntityPath, row: PendingRow)
pub fn push_row(&self, entity_path: EntityPath, row: PendingRow)
Pushes a PendingRow
down the batching pipeline.
This will computea the size of the row from the batching thread!
See ChunkBatcher
docs for ordering semantics and multithreading guarantees.
sourcepub fn flush_async(&self)
pub fn flush_async(&self)
Initiates a flush of the pipeline and returns immediately.
This does not wait for the flush to propagate (see Self::flush_blocking
).
See ChunkBatcher
docs for ordering semantics and multithreading guarantees.
sourcepub fn flush_blocking(&self)
pub fn flush_blocking(&self)
Initiates a flush the batching pipeline and waits for it to propagate.
See ChunkBatcher
docs for ordering semantics and multithreading guarantees.
Trait Implementations§
source§impl Clone for ChunkBatcher
impl Clone for ChunkBatcher
source§fn clone(&self) -> ChunkBatcher
fn clone(&self) -> ChunkBatcher
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for ChunkBatcher
impl !RefUnwindSafe for ChunkBatcher
impl Send for ChunkBatcher
impl Sync for ChunkBatcher
impl Unpin for ChunkBatcher
impl !UnwindSafe for ChunkBatcher
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