Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bitmonk8/FiksDataStore

 
 

Repository files navigation

FiksDataStore

A Modern C++ Fork of LMDB (Lightning Memory-Mapped Database)

License C++ Status

Overview

FiksDataStore is a modern C++ reimplementation of the Lightning Memory-Mapped Database (LMDB), originally created by Howard Chu at Symas Corporation. This project aims to modernize the LMDB codebase while maintaining its exceptional performance characteristics and reliability.

About FiksDataStore

FiksDataStore is a Btree-based database management library modeled loosely on the BerkeleyDB API, but much simplified. The entire database is exposed in a memory map, and all data fetches return data directly from the mapped memory, so no malloc's or memcpy's occur during data fetches. Key features include:

  • Zero-copy architecture: Data is accessed directly from memory-mapped files
  • ACID compliance: Full transactional semantics with durability guarantees
  • Multi-version concurrency: Readers never block writers, writers never block readers
  • Crash-proof: Copy-on-write strategy prevents corruption
  • Maintenance-free: No periodic checkpointing or compaction required
  • Cross-platform: Works on Windows, Linux, macOS, and other Unix systems

Project Goals

FiksDataStore aims to modernize LMDB by:

  • Modern C++ Standards: Converting from C to modern C++ (C++17/20/23)
  • Type Safety: Leveraging C++ type system for better safety
  • RAII: Proper resource management with constructors/destructors
  • STL Integration: Native support for STL containers and algorithms
  • Template-based API: Generic programming for better performance
  • Exception Safety: Modern error handling with exceptions
  • Smart Pointers: Automatic memory management where appropriate
  • Namespace Organization: Proper C++ namespace structure

Current Status

🚧 This project is currently in early development phase 🚧

The original LMDB C code is being systematically converted to modern C++. The current codebase represents the baseline LMDB 0.9.70 implementation.

Roadmap

  • Phase 1: Core API modernization
    • Convert core data structures to C++ classes
    • Implement RAII for resource management
    • Add proper exception handling
  • Phase 2: STL integration
    • STL-compatible iterators
    • Container-like interfaces
    • Algorithm compatibility
  • Phase 3: Template-based optimizations
    • Generic key/value types
    • Compile-time optimizations
    • Type-safe database handles
  • Phase 4: Advanced features
    • Async I/O support
    • Custom allocators
    • Coroutine integration

Original LMDB Features

Performance Characteristics

  • Extremely fast: Often outperforms other embedded databases
  • Memory efficient: Minimal memory overhead
  • Scalable: Handles databases larger than RAM efficiently
  • Concurrent: Multiple readers, single writer model

Key Capabilities

  • Memory-mapped I/O: Direct access to data without copying
  • B+ tree storage: Efficient key-value storage and retrieval
  • Transactions: Full ACID properties with nested transaction support
  • Multiple databases: Single environment can host multiple named databases
  • Duplicate keys: Optional support for multiple values per key
  • Cursor operations: Efficient iteration and range queries

Building

Prerequisites

  • Modern C++ compiler (GCC 9+, Clang 10+, MSVC 2019+)
  • XMake 2.5+
  • Git

Current Build

The project uses XMake as the build system:

# Build the project
xmake

# Build and run tests
xmake build tests
xmake run tests

# Clean build artifacts
xmake clean

Configuration

# Configure build options
xmake config --mode=debug    # Debug build
xmake config --mode=release  # Release build

# Show configuration
xmake show

Usage Example

Current API (C-style)

#include "fds.h"

FDS_env *env;
FDS_dbi dbi;
FDS_val key, data;
FDS_txn *txn;

// Create environment
fds_env_create(&env);
fds_env_open(env, "./testdb", 0);

// Open database
fds_txn_begin(env, NULL, 0, &txn);
fds_dbi_open(txn, NULL, 0, &dbi);

// Store data
key.mv_size = sizeof(int);
key.mv_data = &some_key;
data.mv_size = sizeof(some_data);
data.mv_data = &some_data;
fds_put(txn, dbi, &key, &data, 0);

fds_txn_commit(txn);
fds_env_close(env);

Planned API (Modern C++)

#include <fiksdatastore/database.hpp>

// Planned modern C++ API
fiksdatastore::Environment env("./testdb");
auto db = env.open_database();

// RAII transaction
{
    auto txn = env.begin_transaction();
    db.put(txn, 42, "Hello, World!");
    txn.commit();
}

// STL-style iteration
for (const auto& [key, value] : db) {
    std::cout << key << ": " << value << std::endl;
}

Testing

The project includes the original LMDB test suite:

# Build and run all tests
xmake build tests
xmake run tests

# Run individual tests
xmake run mtest
xmake run mtest2
xmake run mtest3
# ... etc

Documentation

Contributing

Contributions are welcome! This project is in active development and we're looking for:

  • C++ modernization expertise
  • Performance optimization
  • Testing and validation
  • Documentation improvements

Development Guidelines

  • Follow modern C++ best practices
  • Maintain backward compatibility during transition
  • Comprehensive testing for all changes
  • Clear documentation for new APIs
  • Adhere to Design Constraints - Mandatory design standards for the project
  • Follow Coding Conventions - Mandatory coding style and formatting standards

License

FiksDataStore maintains the same licensing as the original LMDB:

  • OpenLDAP Public License 2.8 - See LICENSE file
  • Copyright 2011-2021 Howard Chu, Symas Corp.
  • Additional modernization work: Copyright 2025 FiksDataStore contributors

Acknowledgments

  • Howard Chu and Symas Corporation for creating and maintaining LMDB
  • The OpenLDAP Project for the foundational work
  • Martin Hedenfalk for the original btree implementation
  • The LMDB community for years of testing and feedback

Related Projects

Contact


Note: This is a fork and modernization effort. For production use of the stable, battle-tested LMDB, please use the original LMDB project.

About

A fork of LMDB, converting it to C++

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 91.6%
  • C 6.1%
  • Xmake 1.9%
  • Lua 0.4%