asimsedhain commented on code in PR #9015:
URL: https://github.com/apache/arrow-datafusion/pull/9015#discussion_r1485786575


##########
datafusion/execution/src/memory_pool/pool.rs:
##########
@@ -310,4 +466,34 @@ mod tests {
         let err = r4.try_grow(30).unwrap_err().strip_backtrace();
         assert_eq!(err, "Resources exhausted: Failed to allocate additional 30 
bytes for s4 with 0 bytes already allocated - maximum available is 20");
     }
+
+    #[test]
+    fn test_greedy() {
+        let pool = Arc::new(GreedyMemoryPool::new(100)) as _;
+        let mut r1 = MemoryConsumer::new("r1").register(&pool);
+
+        // Can grow beyond capacity of pool
+        r1.grow(2000);
+        assert_eq!(pool.reserved(), 2000);
+
+        let mut r2 = MemoryConsumer::new("r2")
+            .with_can_spill(true)
+            .register(&pool);
+        // Can grow beyond capacity of pool
+        r2.grow(2000);
+
+        let err = r1.try_grow(1).unwrap_err().strip_backtrace();
+        assert_eq!(err, "Resources exhausted: Failed to allocate additional 1 
bytes for r1 with 2000 bytes already allocated - maximum available is 0");

Review Comment:
   Hey @alamb,
   Do you have an example that I can use as inspiration?
   
   I think I have addressed most of the other comments (Hacking away at it one 
step at a time). I will try to clean up the code a bit after I add the test for 
the generated reported. 
   
   Thank you for taking your time to review this PR.



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