STXXL
1.4-dev
|
Cache of blocks contained in an external memory hash map. Uses the stxxl::lru_pager as eviction algorithm.
Definition at line 118 of file block_cache.h.
Classes | |
struct | bid_eq |
struct | bid_hash |
Public Types | |
typedef block_type::bid_type | bid_type |
typedef BlockType | block_type |
typedef subblock_type::bid_type | subblock_bid_type |
typedef block_type::value_type | subblock_type |
Public Member Functions | |
block_cache (unsigned_type cache_size) | |
Construct a new block-cache. More... | |
~block_cache () | |
void | clear () |
Empty cache; don't write back dirty blocks. More... | |
void | flush () |
Write all dirty blocks back to disk. More... | |
subblock_type * | get_subblock (const bid_type &bid, unsigned_type i_subblock) |
Retrieve a subblock from the cache. If not yet cached, only the subblock will be loaded. More... | |
bool | make_dirty (const bid_type &bid) |
Set given block's dirty-flag. Note: If the given block was only partially loaded, it will be completely reloaded. More... | |
void | prefetch_block (const bid_type &bid) |
Load a block in advance. More... | |
void | print_statistics (std::ostream &o=std::cout) const |
Print statistics: Number of hits/misses, blocks forced from cache or written back. More... | |
bool | release_block (const bid_type &bid) |
Release a block (decrement retain-count). If the retain-count reaches 0, a block may be kicked again. More... | |
void | reset_statistics () |
Reset all counters to zero. More... | |
bool | retain_block (const bid_type &bid) |
Retain a block in cache. Blocks, that are retained by at least one client, won't get kicked. Make sure to release all retained blocks again. More... | |
unsigned_type | size () const |
Return cache-size. More... | |
void | swap (block_cache &obj) |
Exchange contents of two caches. More... | |
Protected Types | |
enum | { valid_all = block_type::size } |
typedef compat_hash_map < bid_type, unsigned_type, bid_hash >::result | bid_map_type |
typedef stxxl::lru_pager | pager_type |
typedef block_cache_write_buffer < block_type > | write_buffer_type |
Protected Member Functions | |
void | kick_block () |
Force a block from the cache; write back to disk if dirty. More... | |
Protected Attributes | |
bid_map_type | bid_map_ |
std::vector< bid_type > | bids_ |
bids of cached blocks More... | |
std::vector< block_type * > | blocks_ |
cached blocks More... | |
std::vector< unsigned char > | dirty_ |
true iff block has been altered while in cache More... | |
std::vector< unsigned_type > | free_blocks_ |
free blocks as indices to blocks_-vector More... | |
int64 | n_clean_forced |
int64 | n_found |
int64 | n_not_found |
int64 | n_read |
int64 | n_written |
int64 | n_wrong_subblock |
pager_type | pager_ |
std::vector< request_ptr > | reqs_ |
std::vector< unsigned_type > | retain_count_ |
std::vector< unsigned_type > | valid_subblock_ |
valid_all or the actually loaded subblock's index More... | |
write_buffer_type | write_buffer_ |
Additional Inherited Members | |
Private Member Functions inherited from stxxl::noncopyable | |
noncopyable () | |
|
protected |
Definition at line 159 of file block_cache.h.
typedef block_type::bid_type stxxl::hash_map::block_cache< BlockType >::bid_type |
Definition at line 122 of file block_cache.h.
typedef BlockType stxxl::hash_map::block_cache< BlockType >::block_type |
Definition at line 121 of file block_cache.h.
|
protected |
Definition at line 155 of file block_cache.h.
typedef subblock_type::bid_type stxxl::hash_map::block_cache< BlockType >::subblock_bid_type |
Definition at line 124 of file block_cache.h.
typedef block_type::value_type stxxl::hash_map::block_cache< BlockType >::subblock_type |
Definition at line 123 of file block_cache.h.
|
protected |
Definition at line 156 of file block_cache.h.
|
protected |
Enumerator | |
---|---|
valid_all |
Definition at line 161 of file block_cache.h.
|
inline |
Construct a new block-cache.
cache_size | cache-size in number of blocks |
Definition at line 195 of file block_cache.h.
|
inline |
Definition at line 225 of file block_cache.h.
|
inline |
Empty cache; don't write back dirty blocks.
Definition at line 490 of file block_cache.h.
Referenced by stxxl::hash_map::hash_map< KeyType, MappedType, HashType, CompareType, SubBlockSize, SubBlocksPerBlock, AllocType >::_rebuild_buckets(), stxxl::hash_map::hash_map< KeyType, MappedType, HashType, CompareType, SubBlockSize, SubBlocksPerBlock, AllocType >::clear(), and stxxl::hash_map::hash_map< KeyType, MappedType, HashType, CompareType, SubBlockSize, SubBlocksPerBlock, AllocType >::insert().
|
inline |
Write all dirty blocks back to disk.
Definition at line 472 of file block_cache.h.
Referenced by stxxl::hash_map::hash_map< KeyType, MappedType, HashType, CompareType, SubBlockSize, SubBlocksPerBlock, AllocType >::clear().
|
inline |
Retrieve a subblock from the cache. If not yet cached, only the subblock will be loaded.
bid | block, to which the requested subblock belongs |
i_subblock | index of requested subblock |
Definition at line 361 of file block_cache.h.
Referenced by stxxl::hash_map::hash_map< KeyType, MappedType, HashType, CompareType, SubBlockSize, SubBlocksPerBlock, AllocType >::_load_subblock().
|
inlineprotected |
Force a block from the cache; write back to disk if dirty.
Definition at line 250 of file block_cache.h.
|
inline |
Set given block's dirty-flag. Note: If the given block was only partially loaded, it will be completely reloaded.
Definition at line 331 of file block_cache.h.
|
inline |
Load a block in advance.
bid | Identifier of the block to load |
Definition at line 433 of file block_cache.h.
|
inline |
Print statistics: Number of hits/misses, blocks forced from cache or written back.
Definition at line 507 of file block_cache.h.
Referenced by stxxl::hash_map::hash_map< KeyType, MappedType, HashType, CompareType, SubBlockSize, SubBlocksPerBlock, AllocType >::print_statistics().
|
inline |
Release a block (decrement retain-count). If the retain-count reaches 0, a block may be kicked again.
bid | block, whose retain-count is to be decremented |
Definition at line 313 of file block_cache.h.
|
inline |
Reset all counters to zero.
Definition at line 518 of file block_cache.h.
Referenced by stxxl::hash_map::hash_map< KeyType, MappedType, HashType, CompareType, SubBlockSize, SubBlocksPerBlock, AllocType >::reset_statistics().
|
inline |
Retain a block in cache. Blocks, that are retained by at least one client, won't get kicked. Make sure to release all retained blocks again.
bid | block, whose retain-count is to be increased |
Definition at line 296 of file block_cache.h.
|
inline |
Return cache-size.
Definition at line 220 of file block_cache.h.
|
inline |
Exchange contents of two caches.
obj | cache to swap contents with |
Definition at line 530 of file block_cache.h.
|
protected |
Definition at line 181 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().
|
protected |
bids of cached blocks
Definition at line 168 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().
|
protected |
cached blocks
Definition at line 166 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().
|
protected |
true iff block has been altered while in cache
Definition at line 172 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().
|
protected |
free blocks as indices to blocks_-vector
Definition at line 178 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().
|
protected |
Definition at line 189 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().
|
protected |
Definition at line 185 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().
|
protected |
Definition at line 186 of file block_cache.h.
|
protected |
Definition at line 187 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().
|
protected |
Definition at line 188 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().
|
protected |
Definition at line 190 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().
|
protected |
Definition at line 182 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().
|
protected |
Definition at line 179 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().
|
protected |
Definition at line 169 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().
|
protected |
valid_all or the actually loaded subblock's index
Definition at line 175 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().
|
protected |
Definition at line 163 of file block_cache.h.
Referenced by stxxl::hash_map::block_cache< block_type >::swap().