Apache DataFusion SQL Query Engine
[Minor] Remove RawTableAllocExt (#18748)
Daniël Heres8a75075a0f19
diff --git a/datafusion/common/src/utils/proxy.rs b/datafusion/common/src/utils/proxy.rsindex fb951aa3b0..fddf834912 100644--- a/datafusion/common/src/utils/proxy.rs+++ b/datafusion/common/src/utils/proxy.rs@@ -15,12 +15,9 @@// specific language governing permissions and limitations// under the License.-//! [`VecAllocExt`] and [`RawTableAllocExt`] to help tracking of memory allocations+//! [`VecAllocExt`] to help tracking of memory allocations-use hashbrown::{- hash_table::HashTable,- raw::{Bucket, RawTable},-};+use hashbrown::hash_table::HashTable;use std::mem::size_of;/// Extension trait for [`Vec`] to account for allocations.@@ -114,75 +111,6 @@ impl<T> VecAllocExt for Vec<T> {}}-/// Extension trait for hash browns [`RawTable`] to account for allocations.-pub trait RawTableAllocExt {- /// Item type.- type T;-- /// [Insert](RawTable::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:- /// ```- /// # use datafusion_common::utils::proxy::RawTableAllocExt;- /// # use hashbrown::raw::RawTable;- /// 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);- /// ```- fn insert_accounted(- &mut self,- x: Self::T,- hasher: impl Fn(&Self::T) -> u64,- accounting: &mut usize,- ) -> Bucket<Self::T>;-}--impl<T> RawTableAllocExt for RawTable<T> {- type T = T;-- fn insert_accounted(- &mut self,- x: Self::T,- hasher: impl Fn(&Self::T) -> u64,- accounting: &mut usize,- ) -> Bucket<Self::T> {- let hash = hasher(&x);-- match self.try_insert_no_grow(hash, x) {- Ok(bucket) => bucket,- Err(x) => {- // need to request more memory-- let bump_elements = self.capacity().max(16);- let bump_size = bump_elements * size_of::<T>();- *accounting = (*accounting).checked_add(bump_size).expect("overflow");-- self.reserve(bump_elements, hasher);-- // still need to insert the element since first try failed- // Note: cannot use `.expect` here because `T` may not implement `Debug`- match self.try_insert_no_grow(hash, x) {- Ok(bucket) => bucket,- Err(_) => panic!("just grew the container"),- }- }- }- }-}-/// Extension trait for hash browns [`HashTable`] to account for allocations.pub trait HashTableAllocExt {/// Item type.diff --git a/datafusion/execution/src/memory_pool/mod.rs b/datafusion/execution/src/memory_pool/mod.rsindex e620b23267..7f9ef447d9 100644--- a/datafusion/execution/src/memory_pool/mod.rs+++ b/datafusion/execution/src/memory_pool/mod.rs@@ -24,9 +24,7 @@ use std::{cmp::Ordering, sync::atomic, sync::Arc};mod pool;pub mod proxy {- pub use datafusion_common::utils::proxy::{- HashTableAllocExt, RawTableAllocExt, VecAllocExt,- };+ pub use datafusion_common::utils::proxy::{HashTableAllocExt, VecAllocExt};}pub use pool::*;