maph

Space-efficient approximate mappings using perfect hash functions

View the Project on GitHub queelius/maph

maph Documentation

Welcome to the maph (Memory-Mapped Approximate Perfect Hash) documentation!

🚀 What is maph?

maph is a high-performance key-value database that provides:

📚 Documentation Structure

Core Documentation

Tools & Integrations

Development

⚡ Performance Highlights

Metric Value Notes
GET Latency <100ns O(1) with perfect hash
SET Latency <150ns Lock-free atomic updates
Throughput 10M ops/sec Single thread
Batch Throughput 50M ops/sec SIMD optimized
Memory Overhead ~512B/entry Fixed slot size

🎯 Use Cases

maph is ideal for:

🔧 Quick Example

#include <maph.hpp>

// Create a store with 1M slots
auto store = maph::Maph::create("mystore.maph", 1000000);

// Store JSON data
store->set(R"({"user": "alice"})", R"({"score": 95, "level": 10})");

// O(1) retrieval
auto data = store->get(R"({"user": "alice"})");

📊 Comparison with Alternatives

System maph Redis RocksDB Memcached
Lookup O(1) guaranteed O(1) average O(log n) O(1) average
Persistence mmap AOF/RDB SST None
Memory Optimal 10x overhead Compressed In-memory
Concurrent Lock-free Single-thread Multi-thread Multi-thread
JSON Native String-based Binary String-based

🛠️ Getting Started

Installation

git clone https://github.com/yourusername/rd_ph_filter.git
cd rd_ph_filter
mkdir build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j$(nproc)
sudo make install

Basic Usage

// C++ API
auto store = maph::Maph::create("data.maph", 100000);
store->set("key", "value");
auto val = store->get("key");

// CLI Tool
maph_cli create mystore --slots 100000
maph_cli set mystore "key" "value"
maph_cli get mystore "key"

// REST API
curl -X POST http://localhost:8080/stores \
  -d '{"name": "mystore", "slots": 100000}'
curl -X PUT http://localhost:8080/stores/mystore/keys/"key" \
  -d '"value"'

📈 Benchmarks

Benchmarks performed on:

Single-threaded Performance

Multi-threaded Performance (16 threads)

🤝 Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

📄 License

MIT License - see LICENSE for details.