Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ca-streaming-storage.H File Reference

Phase 15 tile-based out-of-core storage for Aleph::CA. More...

#include <array>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <filesystem>
#include <fstream>
#include <list>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <utility>
#include <vector>
#include <ah-errors.H>
#include <ca-traits.H>
Include dependency graph for ca-streaming-storage.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Aleph::CA::Tile_Cache_Stats
 Statistics surfaced by Tile_Cache::stats(). More...
 
class  Aleph::CA::Tile_Cache< State, TileSide >
 Out-of-core 2D tile cache with LRU eviction. More...
 
struct  Aleph::CA::Tile_Cache< State, TileSide >::Tile_Entry
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::CA
 
namespace  Aleph::CA::ca_stream_detail
 

Functions

constexpr std::uint64_t Aleph::CA::ca_stream_detail::tile_key (const std::uint32_t row, const std::uint32_t col) noexcept
 Pack (row, col) into a stable 64-bit key for the tile map.
 

Detailed Description

Phase 15 tile-based out-of-core storage for Aleph::CA.

Tile_Cache<State, TileSide> exposes a logical 2D grid of any size while keeping only a bounded set of resident tiles in RAM. Tiles that fall out of the LRU cache are evicted to disk as raw little-endian binary files; subsequent accesses page them back in transparently.

The cache is intentionally simple compared to a full mmap-backed engine: it favours portability (works on any filesystem with no POSIX dependencies) and inspectability (each tile is a separate file you can examine with a hex dump). When more aggressive out-of-core performance is required, the same tile layout can be consumed by a custom mmap loader without changing client code.

Design contract:

  • Tiles are square of side TileSide (compile-time constant).
  • The grid extents must be multiples of TileSide. Out-of-bound tiles are not allocated.
  • Eviction is LRU; capacity (number of resident tiles) is set at construction.
  • Each tile lives on disk as tile_<row>_<col>.bin, with TileSide * TileSide * sizeof(State) raw bytes.
  • The cache is not thread-safe.

Typical usage:

Tile_Cache<int, 64> tiles({1024, 1024}, "/tmp/sim", 16);
tiles.set(123, 456, 1);
const int v = tiles.at(123, 456);
tiles.flush(); // persist resident tiles to disk
Author
Leandro Rabindranath Leon

Definition in file ca-streaming-storage.H.