berkeleydb_datastore.h 1.17 KB
Newer Older
1
2
3
4
5
6
// Copyright (c) 2017, Los Alamos National Security, LLC.
// All rights reserved.
#ifndef bdb_datastore_h
#define bdb_datastore_h

#include "kv-config.h"
7
#include "datastore/datastore.h"
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <db_cxx.h>
#include <dbstl_map.h>

// may want to implement some caching for persistent stores like BerkeleyDB
class BerkeleyDBDataStore : public AbstractDataStore {
public:
  BerkeleyDBDataStore();
  BerkeleyDBDataStore(Duplicates duplicates, bool eraseOnGet, bool debug);
  virtual ~BerkeleyDBDataStore();
  virtual void createDatabase(std::string db_name);
  virtual bool put(const ds_bulk_t &key, const ds_bulk_t &data);
  virtual bool get(const ds_bulk_t &key, ds_bulk_t &data);
  virtual bool get(const ds_bulk_t &key, std::vector<ds_bulk_t> &data);
Matthieu Dorier's avatar
Matthieu Dorier committed
21
  virtual bool erase(const ds_bulk_t &key);
22
23
  virtual void set_in_memory(bool enable); // enable/disable in-memory mode
protected:
24
25
  virtual std::vector<ds_bulk_t> vlist_keys(const ds_bulk_t &start, size_t count, const ds_bulk_t &prefix);
  virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyvals(const ds_bulk_t &start_key, size_t count, const ds_bulk_t &);
26
27
28
29
30
  DbEnv *_dbenv = NULL;
  Db *_dbm = NULL;
};

#endif // bdb_datastore_h