This is an automated email from the ASF dual-hosted git repository.

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new c3f6c0f079 Minor: add doc examples for RawTableAllocExt (#9059)
c3f6c0f079 is described below

commit c3f6c0f0792fdcf0e7339a9ef2eef54656977851
Author: Andrew Lamb <[email protected]>
AuthorDate: Tue Jan 30 08:57:11 2024 -0500

    Minor: add doc examples for RawTableAllocExt (#9059)
---
 datafusion/execution/src/memory_pool/proxy.rs | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/datafusion/execution/src/memory_pool/proxy.rs 
b/datafusion/execution/src/memory_pool/proxy.rs
index d754bbaa34..75e6de2715 100644
--- a/datafusion/execution/src/memory_pool/proxy.rs
+++ b/datafusion/execution/src/memory_pool/proxy.rs
@@ -69,6 +69,23 @@ pub trait RawTableAllocExt {
     /// `accounting` by any newly allocated bytes.
     ///
     /// Returns the bucket where the element was inserted.
+    /// Note that allocation counts  capacity, not size.
+    ///
+    /// # Example:
+    /// ```
+    /// # use datafusion_execution::memory_pool::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,

Reply via email to