ADS
Algorithms and Data Structures
Loading...
Searching...
No Matches
BlockStore.h File Reference

The store of blocks of section 14.1 of Morin's book, beyond the book: a disk simulated in memory, an array of blocks of type T addressed by their index, on which readBlock( i ) and writeBlock( i , b ) are the I/Os of the external memory model [see TwoLevelMemory.h], counted one each; placeBlock( b ) writes a new block where a block freed by freeBlock( i ) was, or at the end, so that the indices of the blocks in use stay below their largest number. More...

#include "ADS/Contract.h"
#include "ADS/external/TwoLevelMemory.h"
#include <cstddef>
#include <cstdint>
#include <vector>
#include "ADS/external/impl/BlockStore.tpp"

Go to the source code of this file.

Classes

class  ADS::BlockStore< T >
 a disk of blocks of type T, read and written one at a time More...

Namespaces

namespace  ADS

Detailed description

The store of blocks of section 14.1 of Morin's book, beyond the book: a disk simulated in memory, an array of blocks of type T addressed by their index, on which readBlock( i ) and writeBlock( i , b ) are the I/Os of the external memory model [see TwoLevelMemory.h], counted one each; placeBlock( b ) writes a new block where a block freed by freeBlock( i ) was, or at the end, so that the indices of the blocks in use stay below their largest number.

A block is copied when it is read and when it is written, as it would be between the disk and the memory, so that what a structure keeps of a block between two I/Os is its own copy, which a test of the internal memory can count. If a TwoLevelMemory is given, its counters count the I/Os too, so that the structures on the blocks and the algorithms on the files of DiskFile share one count.

Against the code of Morin's book: the blocks are values, where the book keeps pointers to the nodes, so that a node changed after its read is changed on the disk with no write, which hides the I/Os that a test of the model would count; the I/Os are counted; and placeBlock() writes the block also in a free place, where the code of the book takes the free index by remove( size() ), one past the last of its stack, and does not store the block there. peek() reads a block with no I/O, for the checks of the contracts only.

The contracts [see Contract.h]: a block read, written, freed or peeked is in use. The operations are defined in BlockStore.tpp.

See also
P. Morin, Open Data Structures (in C++), Edition 0.1G, 2013, https://opendatastructures.org/ods-cpp.pdf, section 14.1
A. Aggarwal, J. S. Vitter, The input/output complexity of sorting and related problems, Communications of the ACM 31(9), 1116-1127, 1988, doi:10.1145/48529.48535
Author
Donato Meoli
Dipartimento di Informatica
Università di Pisa