1#include "duckdb/storage/buffer/block_handle.hpp"
2#include "duckdb/storage/buffer/buffer_pool.hpp"
3
4namespace duckdb {
5
6BufferPoolReservation::BufferPoolReservation(BufferPool &pool) : pool(pool) {
7}
8
9BufferPoolReservation::BufferPoolReservation(BufferPoolReservation &&src) noexcept : pool(src.pool) {
10 size = src.size;
11 src.size = 0;
12}
13
14BufferPoolReservation &BufferPoolReservation::operator=(BufferPoolReservation &&src) noexcept {
15 size = src.size;
16 src.size = 0;
17 return *this;
18}
19
20BufferPoolReservation::~BufferPoolReservation() {
21 D_ASSERT(size == 0);
22}
23
24void BufferPoolReservation::Resize(idx_t new_size) {
25 int64_t delta = (int64_t)new_size - size;
26 pool.IncreaseUsedMemory(size: delta);
27 size = new_size;
28}
29
30void BufferPoolReservation::Merge(BufferPoolReservation &&src) {
31 size += src.size;
32 src.size = 0;
33}
34
35} // namespace duckdb
36