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

Loading...
Searching...
No Matches
Classes | Static Public Member Functions | List of all members
maph::Hash Struct Reference

Hash function implementation for key distribution. More...

`#include <maph.hpp>`

Collaboration diagram for maph::Hash:

## Classes
struct | Result
| Hash computation result. More...

## Static Public Member Functions
static Result | compute (JsonView key, uint64_t num_slots)
| Compute hash and slot index for a key.
static void | compute_batch (const std::vector< JsonView > &keys, uint64_t num_slots, std::vector< Result > &results)

## Detailed Description

Hash function implementation for key distribution.

Uses FNV-1a hash algorithm for good distribution and speed. Supports both scalar and SIMD (AVX2) implementations for batch operations.

Definition at line 216 of file maph.hpp.

## Class Documentation

## ◆ maph::Hash::Result

struct maph::Hash::Result

Hash computation result.

Definition at line 221 of file maph.hpp.

Collaboration diagram for maph::Hash::Result:

Class Members
uint32_t | hash | Full 32-bit hash value.
uint32_t | index | Slot index (hash % num_slots)

## Member Function Documentation

## ◆ compute()

static Result maph::Hash::compute | ( | JsonView | key,
|  | uint64_t | num_slots
| ) |  |
| inline static

Compute hash and slot index for a key.

Uses FNV-1a algorithm:

1. Start with offset basis (2166136261)
2. For each byte: XOR with hash, multiply by FNV prime (16777619)
3. Never returns 0 (reserved for empty slots)

Parameters

  key | Key to hash
  num_slots | Total number of slots (for modulo operation)

Returns
  Hash result containing full hash and slot index

Definition at line 238 of file maph.hpp.

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

Here is the caller graph for this function:

## ◆ compute_batch()

static void maph::Hash::compute_batch | ( | const std::vector< JsonView > & | keys,
|  | uint64_t | num_slots,
|  | std::vector< Result > & | results
| ) |  |
| inline static

Definition at line 308 of file maph.hpp.

References compute().

Here is the call graph for this function:

The documentation for this struct was generated from the following file:

- include/maph.hpp