pub struct RecordBatchMemoryCounter { /* private fields */ }Expand description
Tracks the memory used by a sequence of RecordBatches that may share
underlying buffers, counting each buffer exactly once.
Use this instead of get_record_batch_memory_size to account for the
total memory of a sequence of batches, e.g. when buffering the batches of
an input stream. Such batches can share buffers (for example, operators
like aggregates emit one large batch as multiple zero-copy slices), and
calling get_record_batch_memory_size per batch counts the shared
buffers once per batch, while this counter counts them exactly once. A
batch’s buffers are kept alive by the batch even when only a sub-range is
referenced, so counting unique buffers in full reflects the memory the
batches actually retain.
This counter only adds. Use RecordBatchMemoryTracker when batches are
dropped one at a time and their memory must be released.
Implementations§
Source§impl RecordBatchMemoryCounter
impl RecordBatchMemoryCounter
pub fn new() -> Self
Sourcepub fn count_batch(&mut self, batch: &RecordBatch) -> usize
pub fn count_batch(&mut self, batch: &RecordBatch) -> usize
Count batch, returning the memory used by its buffers that have not
been counted before.
Sourcepub fn count_array(&mut self, array: &dyn Array) -> usize
pub fn count_array(&mut self, array: &dyn Array) -> usize
Count array, returning the memory used by its buffers that have not
been counted before.
Sourcepub fn count_batch_with_array_overhead(&mut self, batch: &RecordBatch) -> usize
pub fn count_batch_with_array_overhead(&mut self, batch: &RecordBatch) -> usize
Counts unique buffers and Array objects retained by batch.
This is useful for accounting a sequence of batches at an operator
boundary. It counts buffers once, including buffers shared by multiple
batches. Array-object overhead is deduplicated recursively when a shared
child has the same ArrayRef identity; Arrow constructors that rebuild
child array objects may conservatively count their object overhead again.
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Total memory of all counted allocations.
Trait Implementations§
Source§impl Debug for RecordBatchMemoryCounter
impl Debug for RecordBatchMemoryCounter
Auto Trait Implementations§
impl Forget for RecordBatchMemoryCounter
impl Freeze for RecordBatchMemoryCounter
impl Move for RecordBatchMemoryCounter
impl RefUnwindSafe for RecordBatchMemoryCounter
impl Send for RecordBatchMemoryCounter
impl Sync for RecordBatchMemoryCounter
impl Unpin for RecordBatchMemoryCounter
impl UnsafeUnpin for RecordBatchMemoryCounter
impl UnwindSafe for RecordBatchMemoryCounter
Blanket Implementations§
impl<T> Allocation for T
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> 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