20#ifndef MMAPPED_VECTOR_H
21#define MMAPPED_VECTOR_H
79MMappedVector(
const char *filename,
bool read_only, uint64_t magic);
104void add(
const T& value);
111 return data->nb_elements;
File-backed memory region with two interchangeable backends.
void set(pg_uuid_t u, unsigned long i)
Unused overload kept for interface compatibility.
~MMappedVector()
Sync and unmap the file.
data_t * data
Typed view of region.base().
unsigned long nbElements() const
Return the number of elements currently stored.
static constexpr unsigned STARTING_CAPACITY
Initial number of element slots allocated.
void add(const T &value)
Append an element to the end of the vector.
void grow()
Double the backing region and refresh data.
MMappedVector(const char *filename, bool read_only, uint64_t magic)
Open (or create) the mmap-backed vector.
MappedRegion region
Backing storage (shared mmap, or heap buffer).
const T & operator[](unsigned long k) const
Read-only element access by index.
void sync()
Flush the backing region to its file (MappedRegion::sync()).
Core types, constants, and utilities shared across ProvSQL.
On-disk layout stored at the start of the backing file.
unsigned long nb_elements
Number of elements currently stored.
T d[]
Flexible array of elements.
uint32_t _reserved
Padding to 16-byte boundary, must be 0.
uint16_t elem_size
sizeof(T) at write time
uint16_t version
Format version (currently 1).
uint64_t magic
File-type identifier.
unsigned long capacity
Maximum elements before the next grow.