The FileBuffer represents a buffer that can be read or written to a Direct IO FileHandle.
More...
#include <duckdb.hpp>
|
| | FileBuffer (BlockAllocator &allocator, FileBufferType type, uint64_t user_size, idx_t block_header_size) |
| |
| | FileBuffer (BlockAllocator &allocator, FileBufferType type, BlockManager &block_manager) |
| |
| | FileBuffer (FileBuffer &source, FileBufferType type, idx_t block_header_size) |
| |
| void | Read (QueryContext context, FileHandle &handle, uint64_t location) |
| | Read into the FileBuffer from the location.
|
| |
| void | Write (QueryContext context, FileHandle &handle, const uint64_t location) |
| | Write the FileBuffer to the location.
|
| |
| void | Clear () |
| |
| FileBufferType | GetBufferType () const |
| |
| void | Resize (uint64_t user_size, idx_t block_header_size) |
| |
| void | Resize (BlockManager &block_manager) |
| |
| idx_t | GetHeaderSize () const |
| |
| uint64_t | AllocSize () const |
| |
| uint64_t | Size () const |
| |
| data_ptr_t | InternalBuffer () |
| |
| MemoryRequirement | CalculateMemory (uint64_t user_size, uint64_t block_header_size) const |
| |
| void | Initialize (DebugInitialize info) |
| |
The FileBuffer represents a buffer that can be read or written to a Direct IO FileHandle.
◆ FileBuffer() [1/3]
Allocates a buffer of the specified size, with room for additional header bytes (typically 8 bytes). On return, this->AllocSize() >= this->size >= user_size. Our allocation size will always be page-aligned, which is necessary to support DIRECT_IO
72798 : allocator(allocator),
type(
type) {
72799 Init();
72800 if (user_size) {
72801 ResizeInternal(user_size, block_header_size);
72802 }
72803}
FileBufferType type
The type of the buffer.
Definition duckdb.hpp:7659
◆ FileBuffer() [2/3]
72806 : allocator(allocator),
type(
type) {
72807 Init();
72808 Resize(block_manager);
72809}
◆ FileBuffer() [3/3]
| duckdb::FileBuffer::FileBuffer |
( |
FileBuffer & |
source, |
|
|
FileBufferType |
type, |
|
|
idx_t |
block_header_size |
|
) |
| |
72819 : allocator(source.allocator),
type(type_p) {
72820
72821 buffer = source.internal_buffer + block_header_size;
72822 size = source.internal_size - block_header_size;
72825
72826 source.Init();
72827}
data_ptr_t buffer
The buffer that users can write to.
Definition duckdb.hpp:7613
uint64_t size
Definition duckdb.hpp:7616
data_ptr_t internal_buffer
Definition duckdb.hpp:7662
uint64_t internal_size
Definition duckdb.hpp:7665
◆ ~FileBuffer()
| duckdb::FileBuffer::~FileBuffer |
( |
| ) |
|
|
virtual |
72829 {
72831 return;
72832 }
72834}
◆ Read()
Read into the FileBuffer from the location.
72888 {
72889 D_ASSERT(
type != FileBufferType::TINY_BUFFER);
72891}
◆ Write()
Write the FileBuffer to the location.
72893 {
72894 D_ASSERT(
type != FileBufferType::TINY_BUFFER);
72896}
◆ Clear()
| void duckdb::FileBuffer::Clear |
( |
| ) |
|
◆ GetBufferType()
| FileBufferType duckdb::FileBuffer::GetBufferType |
( |
| ) |
const |
|
inline |
◆ Resize() [1/2]
72880 {
72881 ResizeInternal(new_size, block_header_size);
72882}
◆ Resize() [2/2]
72884 {
72885 ResizeInternal(block_manager.GetBlockSize(), block_manager.GetBlockHeaderSize());
72886}
◆ GetHeaderSize()
| idx_t duckdb::FileBuffer::GetHeaderSize |
( |
| ) |
const |
|
inline |
◆ AllocSize()
| uint64_t duckdb::FileBuffer::AllocSize |
( |
| ) |
const |
|
inline |
◆ Size()
| uint64_t duckdb::FileBuffer::Size |
( |
| ) |
const |
|
inline |
◆ InternalBuffer()
| data_ptr_t duckdb::FileBuffer::InternalBuffer |
( |
| ) |
|
|
inline |
◆ CalculateMemory()
72857 {
72858 FileBuffer::MemoryRequirement result;
72859 if (
type == FileBufferType::TINY_BUFFER) {
72860
72861 result.header_size = 0;
72862 result.alloc_size = user_size;
72863 } else {
72864 result.header_size = block_header_size;
72865 result.alloc_size = AlignValue<idx_t, Storage::SECTOR_SIZE>(result.header_size + user_size);
72866 }
72867 return result;
72868}
◆ Initialize()
| void duckdb::FileBuffer::Initialize |
( |
DebugInitialize |
info | ) |
|
72902 {
72903 if (initialize == DebugInitialize::NO_INITIALIZE) {
72904 return;
72905 }
72906 uint8_t value = initialize == DebugInitialize::DEBUG_ZERO_INITIALIZE ? 0 : 0xFF;
72908}
◆ ReallocBuffer()
| void duckdb::FileBuffer::ReallocBuffer |
( |
idx_t |
new_size | ) |
|
|
protected |
72836 {
72837 data_ptr_t new_buffer;
72840 } else {
72842 }
72843
72844
72845 if (!new_buffer) {
72846 throw std::bad_alloc();
72847 }
72848
72851
72852
72855}
data_ptr_t AllocateData(idx_t size) const
Allocation functions (same API as Allocator)
◆ Init()
| void duckdb::FileBuffer::Init |
( |
| ) |
|
|
protected |
◆ ResizeInternal()
72870 {
72871 auto req = CalculateMemory(new_size, block_header_size);
72872 ReallocBuffer(req.alloc_size);
72873
72874 if (new_size > 0) {
72877 }
72878}
◆ size
The user-facing size of the buffer. This is equivalent to internal_size - block_header_size.
◆ internal_buffer
| data_ptr_t duckdb::FileBuffer::internal_buffer |
|
protected |
The pointer to the internal buffer that will be read from or written to. This includes the buffer header.
◆ internal_size
| uint64_t duckdb::FileBuffer::internal_size |
|
protected |
The aligned size as passed to the constructor. This is the size that is read from or written to disk.
The documentation for this class was generated from the following files:
- external/duckdb/duckdb.hpp
- external/duckdb/duckdb.cpp