|
ADS
Algorithms and Data Structures
|
The two-level memory model of Aggarwal and Vitter, simulated so that the algorithms of the external memory can be run and their I/Os counted: an internal memory of \( M \) items and a disk of unbounded size, read and written by blocks of \( B \) items, an I/O moving one block. More...
#include "ADS/Contract.h"#include <algorithm>#include <cstddef>#include <cstdint>#include <utility>#include <vector>#include "ADS/external/impl/TwoLevelMemory.tpp"Go to the source code of this file.
Classes | |
| class | ADS::TwoLevelMemory |
| the parameters \( B \) and \( M \) of the model, the counters of the I/Os and the occupation of the internal memory More... | |
| class | ADS::MemoryLease |
| \( k \) items of the internal memory, taken on construction and given back on destruction More... | |
| class | ADS::DiskFile< T > |
| a file of items on the disk of the model, in blocks of \( B \) items More... | |
| class | ADS::DiskReader< T > |
| reads a file through a buffer of one block, \( B \) items of the memory More... | |
| class | ADS::DiskWriter< T > |
| appends to a file through a buffer of one block, \( B \) items of the memory; the last partial block is written by close() or by the destructor More... | |
Namespaces | |
| namespace | ADS |
The two-level memory model of Aggarwal and Vitter, simulated so that the algorithms of the external memory can be run and their I/Os counted: an internal memory of \( M \) items and a disk of unbounded size, read and written by blocks of \( B \) items, an I/O moving one block.
The time of the computation in memory is free; what is counted is the number of reads and the number of writes.
The bounds of the model are those of Ferragina's book (chapter 1, Introduction, and chapter 5, Sorting Atomic Items): a scan of \( n \) items takes \( \Theta( n / B ) \) I/Os, a sort \( \Theta( ( n / B ) \log_{M / B} ( n / M ) ) \) [see ExternalSorting.h], and an algorithm that follows pointers on the disk pays up to one I/O per pointer, which is what the external algorithms of this library avoid. The files are not containers with iterators on purpose: an iterator would read the items without paying the I/Os.
The contracts [see Contract.h]: \( B \ge 1 \) and \( M \ge 2 B \); the memory in use never exceeds \( M \); a block read exists; a block is appended only after full blocks; a file and its reader or writer share the memory. The functions are defined in TwoLevelMemory.tpp.