MCPcopy Create free account
hub / github.com/apache/datafusion / insert_accounted

Method insert_accounted

datafusion/common/src/utils/proxy.rs:158–185  ·  view source on GitHub ↗
(
        &mut self,
        x: Self::T,
        hasher: impl Fn(&Self::T) -> u64,
        accounting: &mut usize,
    )

Source from the content-addressed store, hash-verified

156 type T = T;
157
158 fn insert_accounted(
159 &mut self,
160 x: Self::T,
161 hasher: impl Fn(&Self::T) -> u64,
162 accounting: &mut usize,
163 ) {
164 let hash = hasher(&x);
165
166 if cfg!(debug_assertions) {
167 // In debug mode, check that the element is not already present
168 debug_assert!(
169 self.find_entry(hash, |y| y == &x).is_err(),
170 "attempted to insert duplicate element into HashTableAllocExt::insert_accounted"
171 );
172 }
173
174 if self.len() == self.capacity() {
175 // need to request more memory
176 let bump_elements = self.capacity().max(16);
177 let bump_size = bump_elements * size_of::<T>();
178 *accounting = (*accounting).checked_add(bump_size).expect("overflow");
179
180 self.reserve(bump_elements, &hasher);
181 }
182
183 // We assume the element is not already present
184 self.insert_unique(hash, x, hasher);
185 }
186}

Callers 7

internMethod · 0.80
scalarized_internMethod · 0.80
insert_if_new_innerMethod · 0.80
insert_if_new_innerMethod · 0.80

Calls 4

reserveMethod · 0.80
lenMethod · 0.45
capacityMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected