maph 1.0.0 High-Performance Memory-Mapped Key-Value Database with O(1) Lookups

Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
maph Namespace Reference

## Classes
class | FastMaph
struct | FastSlot
struct | Hash
| Hash function implementation for key distribution. More...
struct | Header
| Database file header containing metadata. More...
struct | HybridHeader
class | HybridMaph
struct | HybridSlot
class | Maph
| Main maph class - lean and fast. More...
class | MaphBuilder
struct | PerfectHashWithHash
| Perfect hash that RETURNS BOTH hash and index This way we compute hash once and reuse it. More...
struct | Result
| Operation result containing error code and message. More...
struct | Slot
| Storage slot for key-value pairs. More...

## Typedefs
using | JsonView = std::string_view

## Enumerations
enum class | ErrorCode { SUCCESS = 0 , FILE_OPEN_FAILED , FILE_TRUNCATE_FAILED , MMAP_FAILED , INVALID_MAGIC , VERSION_MISMATCH , VALUE_TOO_LARGE , TABLE_FULL , KEY_NOT_FOUND , READONLY_STORE }
| Error codes returned by maph operations. More...

## Functions
auto | create (const std::string &path, uint64_t slots)
auto | open (const std::string &path)
auto | open_readonly (const std::string &path)
std::unique_ptr< Maph > | create (const std::string &path, size_t slots)
void | benchmark_hash_reuse ()

## Variables
static constexpr uint32_t | MAGIC_NUMBER = 0x4D415048
static constexpr uint32_t | CURRENT_VERSION = 1
static constexpr size_t | SLOT_SIZE = 512
static constexpr size_t | HEADER_SIZE = 512
static constexpr size_t | SLOT_DATA_SIZE = 496
static constexpr size_t | MAX_PROBE_DISTANCE = 10
static constexpr double | DEFAULT_STATIC_RATIO = 0.8

## Class Documentation

## ◆ maph::Header

struct maph::Header

Database file header containing metadata.

The header is exactly 512 bytes and contains database configuration and runtime statistics. It's placed at the beginning of the mmap'd file.

Definition at line 196 of file maph.hpp.

Collaboration diagram for maph::Header:

Class Members
atomic< uint64_t > | generation {0} | Global generation counter (incremented on modifications)
uint32_t | magic {MAGIC_NUMBER} | Magic number for file validation ("MAPH")
uint64_t | num_slots {0} |
char | padding[488] {} |
char | reserved[480] {} | Reserved space for future extensions.
uint64_t | slot_size {sizeof(Slot)} |
uint64_t | static_slots {0} | Number of slots using perfect hashing (no collisions)
uint64_t | total_slots {0} | Total number of slots in database.
uint32_t | version {CURRENT_VERSION} | Database format version.

## ◆ maph::HybridHeader

struct maph::HybridHeader

Definition at line 49 of file maph_hybrid.hpp.

Collaboration diagram for maph::HybridHeader:

Class Members
atomic< uint64_t > | generation {0} |
uint32_t | magic {0x4D415048} |
double | max_load_factor {0.75} |
atomic< uint64_t > | num_dynamic {0} |
uint64_t | num_slots {0} |
uint64_t | num_static {0} |
char | padding[464] {} |
uint32_t | version {2} |

## Typedef Documentation

## ◆ JsonView

using maph::JsonView = typedef std::string_view

Definition at line 48 of file maph.hpp.

## Enumeration Type Documentation

## ◆ ErrorCode

enum class maph::ErrorCode
| strong

Error codes returned by maph operations.

Enumerator
SUCCESS | Operation completed successfully.
FILE_OPEN_FAILED | Failed to open database file.
FILE_TRUNCATE_FAILED | Failed to resize database file.
MMAP_FAILED | Memory mapping failed.
INVALID_MAGIC | File has invalid magic number (not a maph database)
VERSION_MISMATCH | Database version incompatible with library.
VALUE_TOO_LARGE | Value exceeds maximum slot size (496 bytes)
TABLE_FULL | Hash table is full in probe region.
KEY_NOT_FOUND | Key does not exist in database.
READONLY_STORE | Attempted write operation on read-only database.

Definition at line 66 of file maph.hpp.

## Function Documentation

## ◆ benchmark_hash_reuse()

void maph::benchmark_hash_reuse | ( |  | ) |
| inline

Definition at line 233 of file maph_fast.hpp.

References maph::FastMaph::create().

Here is the call graph for this function:

## ◆ create() [1/2]

std::unique_ptr< Maph > maph::create | ( | const std::string & | path,
|  | size_t | slots
| ) |  |
| inline

Definition at line 352 of file maph.hpp.

References maph::Maph::create().

Here is the call graph for this function:

## ◆ create() [2/2]

auto maph::create | ( | const std::string & | path,
|  | uint64_t | slots
| ) |  |
| inline

Definition at line 954 of file maph.hpp.

References create().

Referenced by create().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ open()

std::unique_ptr< Maph > maph::open | ( | const std::string & | path | ) |
| inline

Definition at line 958 of file maph.hpp.

References open().

Referenced by maph::FastMaph::create(), maph::HybridMaph::create(), and open().

Here is the call graph for this function:
Here is the caller graph for this function:

## ◆ open_readonly()

auto maph::open_readonly | ( | const std::string & | path | ) |
| inline

Definition at line 962 of file maph.hpp.

References open_readonly().

Referenced by open_readonly().

Here is the call graph for this function:
Here is the caller graph for this function:

## Variable Documentation

## ◆ CURRENT_VERSION

constexpr uint32_t maph::CURRENT_VERSION = 1
| static constexpr

Definition at line 53 of file maph.hpp.

## ◆ DEFAULT_STATIC_RATIO

constexpr double maph::DEFAULT_STATIC_RATIO = 0.8
| static constexpr

Definition at line 58 of file maph.hpp.

Referenced by maph::Maph::create().

## ◆ HEADER_SIZE

constexpr size_t maph::HEADER_SIZE = 512
| static constexpr

Definition at line 55 of file maph.hpp.

## ◆ MAGIC_NUMBER

constexpr uint32_t maph::MAGIC_NUMBER = 0x4D415048
| static constexpr

Definition at line 52 of file maph.hpp.

## ◆ MAX_PROBE_DISTANCE

constexpr size_t maph::MAX_PROBE_DISTANCE = 10
| static constexpr

Definition at line 57 of file maph.hpp.

Referenced by maph::Maph::get(), maph::Maph::remove(), and maph::Maph::set().

## ◆ SLOT_DATA_SIZE

constexpr size_t maph::SLOT_DATA_SIZE = 496
| static constexpr

Definition at line 56 of file maph.hpp.

## ◆ SLOT_SIZE

constexpr size_t maph::SLOT_SIZE = 512
| static constexpr

Definition at line 54 of file maph.hpp.