a disk of blocks of type T, read and written one at a time
More...
#include <ADS/external/BlockStore.h>
|
| | BlockStore (TwoLevelMemory *mem=nullptr) |
| | the empty store, whose I/Os are also counted by mem, if given
|
| T | readBlock (std::size_t i) const |
| | a copy of the block \( i \), one read
|
| void | writeBlock (std::size_t i, const T &b) |
| | \( b \) written in the block \( i \), one write
|
| std::size_t | placeBlock (const T &b) |
| | \( b \) written in a free block, one write; its index
|
| void | freeBlock (std::size_t i) |
| | the block \( i \) given back
|
| const T & | peek (std::size_t i) const |
| | the block \( i \), with no I/O, for the checks
|
| std::size_t | blocks (void) const |
| | the number of blocks in use
|
| std::uint64_t | reads (void) const |
| | the reads so far
|
| std::uint64_t | writes (void) const |
| | the writes so far
|
| void | resetCounters (void) |
| | the counters back to 0
|
template<class T>
class ADS::BlockStore< T >
a disk of blocks of type T, read and written one at a time
◆ BlockStore()
the empty store, whose I/Os are also counted by mem, if given
◆ blocks()
the number of blocks in use
◆ freeBlock()
the block \( i \) given back
- Precondition
- the block \( i \) is in use
◆ peek()
the block \( i \), with no I/O, for the checks
- Precondition
- the block \( i \) is in use
◆ placeBlock()
\( b \) written in a free block, one write; its index
In pseudocode (section 14.1 of Morin's book), \( F \) the stack of the free blocks and \( A \) the array of the blocks:
\[\class{pseudocode}{\begin{array}{r@{\quad}l}
1 & \textbf{function}\ \mathrm{placeBlock}( b ) \cr
2 & \quad \textbf{if}\ F = \emptyset\ \textbf{then}\ i \gets |A|
;\ \text{append a block to } A \cr
3 & \quad \textbf{else}\ i \gets \mathrm{pop}( F ) \cr
4 & \quad A[ i ] \gets b;\ \text{count one write} \cr
5 & \quad \textbf{return}\ i
\end{array}}
\]
◆ readBlock()
a copy of the block \( i \), one read
- Precondition
- the block \( i \) is in use
◆ reads()
◆ resetCounters()
◆ writeBlock()
\( b \) written in the block \( i \), one write
- Precondition
- the block \( i \) is in use
◆ writes()
The documentation for this class was generated from the following file: