|
|
DUCKDB_API | ArenaAllocator (Allocator &allocator, idx_t initial_capacity=ARENA_ALLOCATOR_INITIAL_CAPACITY) |
| |
| data_ptr_t | Allocate (idx_t len) |
| |
|
DUCKDB_API data_ptr_t | Reallocate (data_ptr_t pointer, idx_t old_size, idx_t size) |
| |
|
DUCKDB_API data_ptr_t | AllocateAligned (idx_t size) |
| |
|
DUCKDB_API data_ptr_t | ReallocateAligned (data_ptr_t pointer, idx_t old_size, idx_t size) |
| |
|
DUCKDB_API void | AlignNext () |
| | Increment the internal cursor (if required) so the next allocation is guaranteed to be aligned to 8 bytes.
|
| |
| DUCKDB_API void | ShrinkHead (idx_t shrink_size) const |
| |
|
DUCKDB_API void | Reset () |
| | Resets the current head and destroys all previous arena chunks.
|
| |
|
DUCKDB_API void | Destroy () |
| |
|
DUCKDB_API void | Move (ArenaAllocator &allocator) |
| |
|
DUCKDB_API ArenaChunk * | GetHead () |
| |
|
DUCKDB_API ArenaChunk * | GetTail () |
| |
|
DUCKDB_API bool | IsEmpty () const |
| |
|
DUCKDB_API idx_t | SizeInBytes () const |
| | Get the total used size (not cached)
|
| |
|
DUCKDB_API idx_t | AllocationSize () const |
| | Get the currently allocated size in bytes (cached, read from "allocated_size")
|
| |
| Allocator & | GetAllocator () |
| | Returns an "Allocator" wrapper for this arena allocator.
|
| |
| template<class T , class... ARGS> |
| T * | Make (ARGS &&... args) |
| |
| template<class T , class... ARGS> |
| arena_ptr< T > | MakePtr (ARGS &&... args) |
| |
| template<class T , class... ARGS> |
| unsafe_arena_ptr< T > | MakeUnsafePtr (ARGS &&... args) |
| |
| String | MakeString (const char *data, const size_t len) |
| |
| String | MakeString (const std::string &data) |
| |
◆ Allocate()
| data_ptr_t duckdb::ArenaAllocator::Allocate |
( |
idx_t |
len | ) |
|
|
inline |
9508 {
9509 D_ASSERT(!head || head->current_position <= head->maximum_size);
9510 if (!head || head->current_position + len > head->maximum_size) {
9511 AllocateNewBlock(len);
9512 }
9513 D_ASSERT(head->current_position + len <= head->maximum_size);
9514 auto result = head->data.get() + head->current_position;
9515 head->current_position += len;
9516 return result;
9517 }
◆ ShrinkHead()
| DUCKDB_API void duckdb::ArenaAllocator::ShrinkHead |
( |
idx_t |
shrink_size | ) |
const |
|
inline |
This shrinks the LAST allocation that was made using the allocator Note that we can ONLY safely call this method if Allocate has been called previously with a size >= shrink_size
9528 {
9529 D_ASSERT(head && head->current_position >= shrink_size);
9530 head->current_position -= shrink_size;
9531 }
◆ GetAllocator()
| Allocator & duckdb::ArenaAllocator::GetAllocator |
( |
| ) |
|
|
inline |
Returns an "Allocator" wrapper for this arena allocator.
9548 {
9550 }
Allocator arena_allocator
An allocator wrapper using this arena allocator.
Definition duckdb.hpp:9597
◆ Make()
template<
class T , class... ARGS>
| T * duckdb::ArenaAllocator::Make |
( |
ARGS &&... |
args | ) |
|
|
inline |
9553 {
9554 auto mem = AllocateAligned(sizeof(T));
9555 return new (mem) T(std::forward<ARGS>(args)...);
9556 }
◆ MakePtr()
template<
class T , class... ARGS>
| arena_ptr< T > duckdb::ArenaAllocator::MakePtr |
( |
ARGS &&... |
args | ) |
|
|
inline |
9559 {
9560 return arena_ptr<T>(Make<T>(std::forward<ARGS>(args)...));
9561 }
◆ MakeUnsafePtr()
template<
class T , class... ARGS>
9564 {
9565 return unsafe_arena_ptr<T>(Make<T>(std::forward<ARGS>(args)...));
9566 }
◆ MakeString() [1/2]
9568 {
9569 data_ptr_t mem = nullptr;
9570
9571 D_ASSERT(len < NumericLimits<uint32_t>::Maximum());
9573 if (!String::CanBeInlined(size)) {
9574
9575 mem = AllocateAligned(sizeof(char) * size + 1);
9576 memcpy(mem, data, size);
9578 }
9579
9580 return String::Reference(mem ?
reinterpret_cast<char *
>(mem) : data,
size);
9581 }
GOpaque< Size > size(const GMat &src)
◆ MakeString() [2/2]
| String duckdb::ArenaAllocator::MakeString |
( |
const std::string & |
data | ) |
|
|
inline |
9583 {
9584 return MakeString(data.c_str(), data.size());
9585 }
The documentation for this class was generated from the following file: