20#ifndef MMAPPED_VECTOR_H
21#define MMAPPED_VECTOR_H
64void mmap(
size_t length,
bool read_only);
83MMappedVector(
const char *filename,
bool read_only, uint64_t magic);
108void add(
const T& value);
115 return data->nb_elements;
void set(pg_uuid_t u, unsigned long i)
Unused overload kept for interface compatibility.
~MMappedVector()
Sync and unmap the file.
data_t * data
Pointer to the memory-mapped data header.
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 mmap(size_t length, bool read_only)
Map length bytes from the backing file.
int fd
File descriptor of the backing mmap file.
void grow()
Double the backing file and remap.
MMappedVector(const char *filename, bool read_only, uint64_t magic)
Open (or create) the mmap-backed vector.
const T & operator[](unsigned long k) const
Read-only element access by index.
void sync()
Flush dirty pages to the backing file with msync().
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.