Git Product home page Git Product logo

lmdbw's Introduction

lmdbw

C++ simplifying wrapper for the LMDB embedded key-value data store.

Example

Beside the example below, you may want to check test files in the tests directory.

Assume you have struct:

struct item {
    uint16_t w;
    uint16_t h;
    std::vector<uint8_t> data;
};

And map with some values:

std::unordered_map<uint32_t, item> map{
        {100, {8,  10, {1,  2,  3,  4,  5}}},
        {200, {10, 20, {11, 21, 31, 41, 51}}},
        {300, {12, 30, {12, 22, 32, 42, 52}}}
};

You could create database wrapper with a filename and environment flags (1), a database name and its flags (2) and struct fields (3):

lm::dbw<uint32_t, item> db({"./db.db", lm::flag::env::no_subdir}, // 1
                           {"test", lm::flag::dbi::create | lm::flag::dbi::reverse_key}, // 2
                           {&item::w, &item::h, &item::data}); // 3

And with the wrapper you can put, get and delete:

db.put(map);

const auto get_map = db.get(110, 200);

db.del(100, 250);

Should any operation in the above fail, an lm::exception will be thrown and terminate the program since we don't specify any exception handler. All resources will get automatically cleaned up due to RAII.

Requirements

This library requires a C++17 compiler and standard library.

lmdbw's People

Contributors

ondesly avatar

Stargazers

 avatar Ian Reinhart Geiser avatar

Watchers

James Cloos avatar  avatar Ian Reinhart Geiser avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.