Trait datafusion::common::utils::proxy::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§
Required Methods§
sourcefn insert_accounted(
&mut self,
x: Self::T,
hasher: impl Fn(&Self::T) -> u64,
accounting: &mut usize,
) -> Bucket<Self::T>
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);
Object Safety§
This trait is not object safe.