datafusion_common::utils::proxy

Trait RawTableAllocExt

Source
pub trait RawTableAllocExt {
    type T;

    // Required method
    fn insert_accounted(
        &mut self,
        x: Self::T,
        hasher: impl Fn(&Self::T) -> u64,
        accounting: &mut usize,
    ) -> Bucket<Self::T>;
}
Expand description

Extension trait for hash browns RawTable to account for allocations.

Required Associated Types§

Source

type T

Item type.

Required Methods§

Source

fn insert_accounted( &mut self, x: Self::T, hasher: impl Fn(&Self::T) -> u64, accounting: &mut usize, ) -> Bucket<Self::T>

Insert new element into table and increase accounting by any newly allocated bytes.

Returns the bucket where the element was inserted. Note that allocation counts capacity, not size.

§Example:
let mut table = RawTable::new();
let mut allocated = 0;
let hash_fn = |x: &u32| (*x as u64) % 1000;
// pretend 0x3117 is the hash value for 1
table.insert_accounted(1, hash_fn, &mut allocated);
assert_eq!(allocated, 64);

// insert more values
for i in 0..100 { table.insert_accounted(i, hash_fn, &mut allocated); }
assert_eq!(allocated, 400);

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> RawTableAllocExt for RawTable<T>

Source§

type T = T

Source§

fn insert_accounted( &mut self, x: Self::T, hasher: impl Fn(&Self::T) -> u64, accounting: &mut usize, ) -> Bucket<Self::T>

Implementors§