Thrill  0.1

Detailed Description

This class manages allocation of blocks onto a single disk.

It contains a map of all currently allocated blocks. The block_manager selects which of the disk_block_allocator objects blocks are drawn from.

Definition at line 45 of file disk_block_allocator.hpp.

+ Collaboration diagram for disk_block_allocator:

#include <disk_block_allocator.hpp>

Public Member Functions

 disk_block_allocator (file *storage, const disk_config &cfg)
 
 disk_block_allocator (const disk_block_allocator &)=delete
 non-copyable: delete copy-constructor More...
 
 ~disk_block_allocator ()
 
bool autogrow () const
 Returns autogrow. More...
 
template<size_t BlockSize>
void delete_block (const BID< BlockSize > &bid)
 
template<size_t BlockSize>
void delete_blocks (const BIDArray< BlockSize > &bids)
 
uint64_t free_bytes () const
 
bool has_available_space (uint64_t bytes) const
 
template<size_t BlockSize>
void new_blocks (BIDArray< BlockSize > &bids)
 
disk_block_allocatoroperator= (const disk_block_allocator &)=delete
 non-copyable: delete assignment operator More...
 
uint64_t total_bytes () const
 
uint64_t used_bytes () const
 
template<typename BIDIterator >
void new_blocks (BIDIterator begin, BIDIterator end)
 

Private Types

using place = std::pair< uint64_t, uint64_t >
 pair (offset, size) used for free space calculation More...
 
using space_map_type = std::map< uint64_t, uint64_t >
 

Private Member Functions

void add_free_region (uint64_t block_pos, uint64_t block_size)
 
void deallocation_error (uint64_t block_pos, uint64_t block_size, const space_map_type::iterator &pred, const space_map_type::iterator &succ) const
 
void dump () const
 
void grow_file (uint64_t extend_bytes)
 

Private Attributes

bool autogrow_
 
uint64_t cfg_bytes_
 
uint64_t disk_bytes_ = 0
 
uint64_t free_bytes_ = 0
 
space_map_type free_space_
 map of free space as places More...
 
std::mutex mutex_
 
filestorage_
 

Static Private Attributes

static constexpr bool debug = false
 

Member Typedef Documentation

◆ place

using place = std::pair<uint64_t, uint64_t>
private

pair (offset, size) used for free space calculation

Definition at line 124 of file disk_block_allocator.hpp.

◆ space_map_type

using space_map_type = std::map<uint64_t, uint64_t>
private

Definition at line 125 of file disk_block_allocator.hpp.

Constructor & Destructor Documentation

◆ disk_block_allocator() [1/2]

◆ disk_block_allocator() [2/2]

non-copyable: delete copy-constructor

◆ ~disk_block_allocator()

Member Function Documentation

◆ add_free_region()

void add_free_region ( uint64_t  block_pos,
uint64_t  block_size 
)
private

◆ autogrow()

bool autogrow ( ) const
inline

Returns autogrow.

Definition at line 72 of file disk_block_allocator.hpp.

References disk_block_allocator::autogrow_.

◆ deallocation_error()

void deallocation_error ( uint64_t  block_pos,
uint64_t  block_size,
const space_map_type::iterator &  pred,
const space_map_type::iterator &  succ 
) const
private

◆ delete_block()

◆ delete_blocks()

void delete_blocks ( const BIDArray< BlockSize > &  bids)
inline

◆ dump()

void dump ( ) const
private

◆ free_bytes()

uint64_t free_bytes ( ) const
inline

Definition at line 79 of file disk_block_allocator.hpp.

References disk_block_allocator::free_bytes_.

◆ grow_file()

void grow_file ( uint64_t  extend_bytes)
inlineprivate

◆ has_available_space()

bool has_available_space ( uint64_t  bytes) const
inline

◆ new_blocks() [1/2]

void new_blocks ( BIDArray< BlockSize > &  bids)
inline

◆ new_blocks() [2/2]

◆ operator=()

disk_block_allocator& operator= ( const disk_block_allocator )
delete

non-copyable: delete assignment operator

Referenced by disk_block_allocator::disk_block_allocator().

◆ total_bytes()

uint64_t total_bytes ( ) const
inline

Definition at line 89 of file disk_block_allocator.hpp.

References disk_block_allocator::disk_bytes_.

◆ used_bytes()

uint64_t used_bytes ( ) const
inline

Member Data Documentation

◆ autogrow_

◆ cfg_bytes_

uint64_t cfg_bytes_
private

◆ debug

constexpr bool debug = false
staticprivate

Definition at line 47 of file disk_block_allocator.hpp.

◆ disk_bytes_

◆ free_bytes_

◆ free_space_

◆ mutex_

std::mutex mutex_
private

◆ storage_

file* storage_
private

The documentation for this class was generated from the following files: