TPIE

2362a60
tpie::blocks::block_collection_cache Class Reference

A class to manage writing and reading of block to disk. More...

#include <tpie/blocks/block_collection_cache.h>

Public Member Functions

 block_collection_cache (std::string fileName, memory_size_type blockSize, memory_size_type maxSize, bool writeable)
 Create a block collection. More...
 
block_handle get_free_block ()
 Allocates a new block. More...
 
void free_block (block_handle handle)
 frees a block More...
 
blockread_block (block_handle handle)
 Reads the content of a block from disk. More...
 
void write_block (block_handle handle)
 Writes the content of a block to disk. More...
 

Detailed Description

A class to manage writing and reading of block to disk.

Blocks are stored in an internal cache with a static size.

Definition at line 43 of file block_collection_cache.h.

Constructor & Destructor Documentation

tpie::blocks::block_collection_cache::block_collection_cache ( std::string  fileName,
memory_size_type  blockSize,
memory_size_type  maxSize,
bool  writeable 
)

Create a block collection.

Parameters
fileNamethe file in which blocks are saved
blockSizethe size of blocks constructed
writeableindicates whether the collection is writeable
maxSizethe size of the cache given in number of blocks

Member Function Documentation

void tpie::blocks::block_collection_cache::free_block ( block_handle  handle)

frees a block

Parameters
handlethe handle of the block to be freed
block_handle tpie::blocks::block_collection_cache::get_free_block ( )

Allocates a new block.

Returns
the handle of the new block
block* tpie::blocks::block_collection_cache::read_block ( block_handle  handle)

Reads the content of a block from disk.

Parameters
handlethe handle of the block to read
Returns
a pointer to the block with the given handle
void tpie::blocks::block_collection_cache::write_block ( block_handle  handle)

Writes the content of a block to disk.

Parameters
handlethe handle of the block to write
Precondition
the block has been previously read and not flushed from the cache

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