active
library
Maph - Memory-Mapped Approximate Perfect Hash
Space-efficient approximate mappings using perfect hash functions
Resources & Distribution
Maph is a high-performance, memory-mapped database and framework for space-efficient approximate data structures with O(1) lookups. Built on perfect hash functions, it provides sub-microsecond access to arbitrary mappings (X→Y) with configurable storage and accuracy trade-offs.
Core Features
- O(1) Lookups: Guaranteed constant-time operations with perfect hash optimization
- Memory-Mapped Storage: Zero-copy access via mmap for minimal memory overhead
- Lock-Free Operations: Atomic operations for thread-safe concurrent access
- Configurable Storage: 8/16/32/64-bit options for space/accuracy trade-offs
- JSON Database: Built-in daemon with REST API for key-value storage
Performance
- GET: 10M ops/sec (<100ns latency)
- SET: 8M ops/sec (<150ns latency)
- Batch operations: 50M ops/sec with SIMD optimization
Usage Example
#include <maph.hpp>
// Create a new maph store
auto store = maph::Maph::create("mystore.maph", 1000000);
// Store JSON key-value pairs
store->set(R"({"user": "alice"})", R"({"score": 95})");
// Retrieve with O(1) lookup
auto value = store->get(R"({"user": "alice"})");
// Batch operations for high throughput
std::vector<std::pair<JsonView, JsonView>> batch = {
{R"({"id": 1})", R"({"name": "item1"})"},
{R"({"id": 2})", R"({"name": "item2"})"}
};
store->mset(batch);
Applications
- High-performance caching with sub-microsecond lookups
- ML feature stores with guaranteed latency
- Bloom filter alternative with configurable accuracy
- Rate limiting with O(1) token bucket checks