VDB 1.0.1.0 Released: header-only embedded key-value database for modern C++

Introduction

VDB is a high-performance key-value database for embedded scenarios in the process:

  • Data runs in the same process as the application;
  • Adopt memory mapping and paginated B+ trees;
  • Support multi-reader, single-write MVCC concurrency model;
  • Write path is copied on write time to ensure that old snapshots are not affected;
  • Provide transaction commits, rollbacks, nested transactions, sublibraries, and cursors;
  • Support for overflowing pages, dirty page spills, idle page recycling, and crash recovery;
  • Optional pagination encryption and integrity checking.

The storage engine is derived from the LMDB, public interface, which is a new modern C++ design.

Design Highlights

1. A truly modern C++ interface

Public APIs use language facilities available from C++23:

  • Env,Txn,Cursor move-only RAII handle;
  • Dbi is a lightweight handle that can be copied;
  • Read the results using std::span View Expression;
  • Potentially failed operations return std::expected or std::error_code;
  • All interfaces noexcept, Does not cross API boundaries with exceptions ;
  • Compile-time bridging with stateless callbacks is supported.

Examples:

#include <vdb/vdb.hpp>

int main()
{
    auto env_result = vdb::Env::create();
    if (!env_result)
        return 1;

    auto env = std::move(*env_result);
    if (env.set_mapsize(4u << 20u))
        return 1;

    if (env.open("data",
                 vdb::env_flags::create | vdb::env_flags::writemap))
        return 1;

    auto txn_result = env.begin();
    if (!txn_result)
        return 1;

    auto txn = std::move(*txn_result);
    auto dbi_result = txn.open_dbi();
    if (!dbi_result)
        return 1;

    const auto dbi = *dbi_result;
    if (txn.put(dbi, vdb::as_bytes("hello"), vdb::as_bytes("vdb")))
        return 1;

    return txn.commit() ? 1 : 0;
}

2. Header-only , Easy to integrate

VDB has no library products that need to be compiled and linked. The easiest way to integrate is :

cp -r vdb/ /path/to/your/include/
c++ -std=c++23 -I/path/to/your/include app.cpp -lpthread

Projects using CMake can also install exported interface targets directly:

find_package(vdb CONFIG REQUIRED)
target_link_libraries(app PRIVATE vdb::vdb)

3. Retain mature engine capabilities

VDB's underlying storage engine is designed in LMDB style:

  • Pagination B+ Tree vs. Fixed Page Format;
  • Dual Page Alternating Writing and Crash Recovery;
  • MVCC Snapshot and Reader Slot Management;
  • Write Single Transactions, Nesting, and Transaction Rollback;
  • Overflow pages are used to store large values;
  • Dirty Page Budget Control and spill;
  • Delay Collecting Empty Pages;
  • Optional pagination encryption and checksums.

4. Engineering quality is built into the development process

The release includes two deterministic regressions:

  • golden byte return: The generated data file is byte-by-byte consistent with the benchmark sample;
  • Baseline behavior regression: covers five modes: writemap, prealloc, remap, enc, and spill.

Also includes:

  • ABI contract and ABI manifest;
  • Header File Self-Sufficiency Check;
  • Multi-Translation Unit ODR Check;
  • Fault Path Testing;
  • C++23 and C++26 dual standards are built and verified.

Version number description

The current version is 1.0.1.0. .

The version number adopts a four-section :

  • The first three paragraphs 1.0.1 Align upstream LMDB baselines;
  • Paragraph 4 0 Represents a modified version of the VDB itself on that baseline.

Compatibility Promise

The current version freezes the following contracts:

  • Database Page Format;
  • lock file layout;
  • Transaction Commit and Rollback Semantics;
  • Public Handle Ownership Model;
  • Common Value Type Layout;
  • Error Code Values;
  • CMake Package Name vdb::vdb. .

Regular bug fixes do not change the above.

Known limitations

The initial version still has clear boundaries:

  • Only 64-bit platforms are supported;
  • The default page size is 64KB(Configurable);
  • Currently for POSIX,Validated in Cygwin and WSL2 environments;
  • Minimum requirements C++23, Default build uses C++26;
  • Each contains vdb.hpp The translation unit will compile the full header-only implementation;
  • The library is for embedded stand-alone scenarios, It does not provide network services and distributed capabilities.

Licensing

VDB licensing is divided into two parts:

  • The storage engine section derived from LMDB follows OLDAP-2.8;
  • The project's own modern C++ interfaces, refactoring, documentation and testing follow BSD 3-Clause. .

Please keep it when redistributing LICENSE With COPYRIGHT_LMDB. .

Related links

Get started

git clone https://github.com/vecdim/vdb.git
cd vdb

cmake -S . -B build -DVDB_CXX_STANDARD=26
cmake --build buildj
ctest --test-dir build --output-on-failure

If you are looking for a key-value database that can be embedded directly into C++ services, has a modern interface, and is easy to deploy, while inheriting the semantics of the LMDB storage engine, you are welcome to try VDB.

Leave a Comment