|
15 | 15 | // specific language governing permissions and limitations |
16 | 16 | // under the License. |
17 | 17 |
|
18 | | -use crate::memory_pool::{MemoryConsumer, MemoryPool, MemoryReservation}; |
| 18 | +use crate::memory_pool::{MemoryConsumer, MemoryLimit, MemoryPool, MemoryReservation}; |
19 | 19 | use datafusion_common::HashMap; |
20 | 20 | use datafusion_common::{resources_datafusion_err, DataFusionError, Result}; |
21 | 21 | use log::debug; |
@@ -48,6 +48,10 @@ impl MemoryPool for UnboundedMemoryPool { |
48 | 48 | fn reserved(&self) -> usize { |
49 | 49 | self.used.load(Ordering::Relaxed) |
50 | 50 | } |
| 51 | + |
| 52 | + fn memory_limit(&self) -> MemoryLimit { |
| 53 | + MemoryLimit::Infinite |
| 54 | + } |
51 | 55 | } |
52 | 56 |
|
53 | 57 | /// A [`MemoryPool`] that implements a greedy first-come first-serve limit. |
@@ -100,6 +104,10 @@ impl MemoryPool for GreedyMemoryPool { |
100 | 104 | fn reserved(&self) -> usize { |
101 | 105 | self.used.load(Ordering::Relaxed) |
102 | 106 | } |
| 107 | + |
| 108 | + fn memory_limit(&self) -> MemoryLimit { |
| 109 | + MemoryLimit::Finite(self.pool_size) |
| 110 | + } |
103 | 111 | } |
104 | 112 |
|
105 | 113 | /// A [`MemoryPool`] that prevents spillable reservations from using more than |
@@ -233,6 +241,10 @@ impl MemoryPool for FairSpillPool { |
233 | 241 | let state = self.state.lock(); |
234 | 242 | state.spillable + state.unspillable |
235 | 243 | } |
| 244 | + |
| 245 | + fn memory_limit(&self) -> MemoryLimit { |
| 246 | + MemoryLimit::Finite(self.pool_size) |
| 247 | + } |
236 | 248 | } |
237 | 249 |
|
238 | 250 | /// Constructs a resources error based upon the individual [`MemoryReservation`]. |
@@ -408,6 +420,10 @@ impl<I: MemoryPool> MemoryPool for TrackConsumersPool<I> { |
408 | 420 | fn reserved(&self) -> usize { |
409 | 421 | self.inner.reserved() |
410 | 422 | } |
| 423 | + |
| 424 | + fn memory_limit(&self) -> MemoryLimit { |
| 425 | + self.inner.memory_limit() |
| 426 | + } |
411 | 427 | } |
412 | 428 |
|
413 | 429 | fn provide_top_memory_consumers_to_error_msg( |
|
0 commit comments