Skip to main content

RecordBatchMemoryCounter

Struct RecordBatchMemoryCounter 

Source
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.

Implementations§

Source§

impl RecordBatchMemoryCounter

Source

pub fn new() -> Self

Source

pub fn count_batch(&mut self, batch: &RecordBatch) -> usize

Count batch, returning the memory used by its buffers that have not been counted before.

Source

pub fn memory_usage(&self) -> usize

Total memory of the unique buffers of all batches counted so far.

Trait Implementations§

Source§

impl Debug for RecordBatchMemoryCounter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RecordBatchMemoryCounter

Source§

fn default() -> RecordBatchMemoryCounter

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.