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


##########
datafusion/core/src/execution/memory_pool/mod.rs:
##########
@@ -25,43 +25,43 @@ pub mod proxy;
 
 pub use pool::*;
 
-/// The pool of memory from which [`TrackedAllocation`] allocate
+/// The pool of memory on which [`MemoryReservation`] record their memory usage
 pub trait MemoryPool: Send + Sync + std::fmt::Debug {
-    /// Records the creation of a new [`TrackedAllocation`] with 
[`AllocationOptions`]
-    fn allocate(&self, _options: &AllocationOptions) {}
+    /// Records the creation of a new [`MemoryReservation`] with 
[`MemoryConsumer`]
+    fn register(&self, _consumer: &MemoryConsumer) {}
 
-    /// Records the destruction of a [`TrackedAllocation`] with 
[`AllocationOptions`]
-    fn free(&self, _options: &AllocationOptions) {}
+    /// Records the destruction of a [`MemoryReservation`] with 
[`MemoryConsumer`]
+    fn unregister(&self, _consumer: &MemoryConsumer) {}
 
-    /// Infallibly grow the provided `allocation` by `additional` bytes
+    /// Infallibly grow the provided `reservation` by `additional` bytes
     ///
     /// This must always succeed
-    fn grow(&self, allocation: &TrackedAllocation, additional: usize);
+    fn grow(&self, reservation: &MemoryReservation, additional: usize);
 
-    /// Infallibly shrink the provided `allocation` by `shrink` bytes
-    fn shrink(&self, allocation: &TrackedAllocation, shrink: usize);
+    /// Infallibly shrink the provided `reservation` by `shrink` bytes
+    fn shrink(&self, reservation: &MemoryReservation, shrink: usize);
 
-    /// Attempt to grow the provided `allocation` by `additional` bytes
+    /// Attempt to grow the provided `reservation` by `additional` bytes
     ///
     /// On error the `allocation` will not be increased in size
-    fn try_grow(&self, allocation: &TrackedAllocation, additional: usize) -> 
Result<()>;
+    fn try_grow(&self, reservation: &MemoryReservation, additional: usize) -> 
Result<()>;
 
     /// Return the total amount of memory allocated
     fn allocated(&self) -> usize;
 }
 
-/// Options associated with a [`TrackedAllocation`]
+/// A memory consumer that can be tracked by [`MemoryReservation`] in a 
[`MemoryPool`]

Review Comment:
   👍 



##########
datafusion/core/src/execution/memory_pool/mod.rs:
##########
@@ -80,47 +80,35 @@ impl AllocationOptions {
     pub fn name(&self) -> &str {
         &self.name
     }
+
+    /// Registers this [`MemoryConsumer`] with the provided [`MemoryPool`] 
returning
+    /// a [`MemoryReservation`] that can be used to grow or shrink the memory 
reservation
+    pub fn register(self, pool: &Arc<dyn MemoryPool>) -> MemoryReservation {

Review Comment:
   This is a nice interface



-- 
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