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.

This counter only adds. Use RecordBatchMemoryTracker when batches are dropped one at a time and their memory must be released.

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 count_array(&mut self, array: &dyn Array) -> usize

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

Source

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.

Source

pub fn memory_usage(&self) -> usize

Total memory of all counted allocations.

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() -> Self

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.