alamb commented on code in PR #9058:
URL: https://github.com/apache/arrow-datafusion/pull/9058#discussion_r1470126386


##########
datafusion/execution/src/memory_pool/proxy.rs:
##########
@@ -28,6 +28,25 @@ pub trait VecAllocExt {
     /// `accounting` by any newly allocated bytes.
     ///
     /// Note that allocation counts  capacity, not size
+    ///
+    /// # Example:
+    /// ```
+    /// # use datafusion_execution::memory_pool::proxy::VecAllocExt;
+    /// // use allocated to incrementally track how much memory is allocated 
in the vec
+    /// let mut allocated = 0;
+    /// let mut vec = Vec::new();
+    /// // Push data into the vec and the accounting will be updated to reflect
+    /// // memory allocation
+    /// vec.push_accounted(1, &mut allocated);
+    /// assert_eq!(allocated, 16); // space for 4 u32s
+    /// vec.push_accounted(1, &mut allocated);
+    /// assert_eq!(allocated, 16); // no new allocation needed
+    ///
+    /// // push more data into the vec
+    /// for _ in 0..10 { vec.push_accounted(1, &mut allocated); }
+    /// assert_eq!(allocated, 64); // underlying vec has space for 10 u32s
+    /// assert_eq!(vec.allocated_size(), 64);

Review Comment:
   The allocated size was different than what was obtained by `push_accounted` 
prior to this change



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to