64#ifndef __ADS_TwoLevelMemory
65 #define __ADS_TwoLevelMemory
114 [[nodiscard]] std::size_t
blocks( std::size_t n )
const;
117 [[nodiscard]] std::uint64_t
reads(
void )
const;
120 [[nodiscard]] std::uint64_t
writes(
void )
const;
123 [[nodiscard]] std::uint64_t
ios(
void )
const;
137 [[nodiscard]] std::size_t
used(
void )
const;
140 [[nodiscard]] std::size_t
peak(
void )
const;
152 std::uint64_t f_reads = 0;
153 std::uint64_t f_writes = 0;
154 std::size_t f_used = 0;
155 std::size_t f_peak = 0;
183 [[nodiscard]] std::size_t
size(
void )
const;
228 [[nodiscard]] std::
size_t size(
void ) const;
231 [[nodiscard]]
bool empty(
void ) const;
234 [[nodiscard]] std::
size_t blocks(
void ) const;
239 std::
size_t readBlock( std::
size_t b , T * dest ) const;
249 [[nodiscard]] const std::vector< T > &
contents(
void ) const;
254 std::vector< T > f_items;
310 const T &
at( std::size_t i );
315 void load( std::size_t b );
319 std::vector< T > f_buf;
321 std::size_t f_pos = 0;
362 std::vector< T > f_buf;
363 bool f_closed =
false;
375#include "ADS/external/impl/TwoLevelMemory.tpp"
The contracts of ADS: the preconditions, the postconditions and the invariants of the operations,...
a file of items on the disk of the model, in blocks of items
Definition TwoLevelMemory.h:199
TwoLevelMemory & memory(void) const
the memory of the model that the file is on
void appendBlock(const T *src, std::size_t n)
one write: the items of src appended as a new block
DiskFile(TwoLevelMemory &mem)
an empty file
DiskFile(DiskFile &&) noexcept=default
the file moved, no I/O
const std::vector< T > & contents(void) const
the items, no I/O: for the checks, not for the algorithms
std::size_t size(void) const
the number of items of the file
std::size_t size_type
the type of the sizes
Definition TwoLevelMemory.h:204
std::size_t readBlock(std::size_t b, T *dest) const
one read: the block copied to dest, which has room for items; the number of its items
T value_type
the type of the items
Definition TwoLevelMemory.h:203
bool empty(void) const
whether the file has no item
void clear(void)
empties the file, no I/O
DiskFile(TwoLevelMemory &mem, std::vector< T > items)
the file of the items, laid out with no I/O: the input of a problem
std::size_t blocks(void) const
the blocks of the file,
const T & at(std::size_t i)
the item , its block read if not in the buffer; the scan goes on from
DiskReader(const DiskReader &)=delete
no copy, since the buffer is leased from the memory
const T & peek(void)
the next item of the scan, its block read if not in the buffer
DiskReader & operator=(const DiskReader &)=delete
no copy, since the buffer is leased from the memory
DiskReader(const DiskFile< T > &f)
the reader of f, its buffer taken from the memory of f
T next(void)
the next item of the scan, and the scan moves past it
bool hasNext(void) const
whether some items are not yet scanned
std::size_t position(void) const
the place of the scan
void close(void)
writes the partial block, if any; no push() after it
DiskWriter & operator=(const DiskWriter &)=delete
no copy, since the buffer is leased from the memory
~DiskWriter()
close(), if not closed yet
DiskWriter(const DiskWriter &)=delete
no copy, since the buffer is leased from the memory
DiskWriter(DiskFile< T > &f)
the writer at the end of f, its buffer taken from the memory of f
void push(const T &x)
appends , writing the buffer when it is full
items of the internal memory, taken on construction and given back on destruction
Definition TwoLevelMemory.h:166
~MemoryLease()
gives the items back
MemoryLease & operator=(const MemoryLease &)=delete
no copy, since the items would be given back twice
MemoryLease(TwoLevelMemory &mem, std::size_t k)
the lease of items of mem
std::size_t size(void) const
, the items taken
MemoryLease(const MemoryLease &)=delete
no copy, since the items would be given back twice
the parameters and of the model, the counters of the I/Os and the occupation of the internal memory
Definition TwoLevelMemory.h:94
TwoLevelMemory(const TwoLevelMemory &)=delete
no copy, since the counters belong to one simulation
std::size_t used(void) const
the items of the internal memory in use
std::size_t memorySize(void) const
, the items of the internal memory
void resetCounters(void)
sets the counters of the I/Os to 0, and the peak to the memory in use
void countRead(void)
one more read: called by DiskFile only
std::size_t peak(void) const
the largest used() since the construction or resetCounters()
TwoLevelMemory(std::size_t B, std::size_t M)
a memory of items and blocks of items
std::size_t blocks(std::size_t n) const
, the blocks of items
TwoLevelMemory & operator=(const TwoLevelMemory &)=delete
no copy, since the counters belong to one simulation
void allocate(std::size_t k)
takes items of the internal memory
std::uint64_t writes(void) const
the writes counted so far
std::uint64_t reads(void) const
the reads counted so far
void release(std::size_t k)
gives back items of the internal memory
std::uint64_t ios(void) const
the I/Os counted so far, reads() plus writes()
void countWrite(void)
one more write: called by DiskFile only
std::size_t blockSize(void) const
, the items of a block
void load(Ar &a, T &x)
the structure read from the archive of cereal
Definition Cereal.h:238