bwtree_datastore.h 1.8 KB
Newer Older
1
2
3
4
5
6
7
8
// Copyright (c) 2017, Los Alamos National Security, LLC.
// All rights reserved.
#ifndef bwtree_datastore_h
#define bwtree_datastore_h

#include "kv-config.h"
#include "bwtree.h"
#include "datastore.h"
9
#include "sdskv-common.h"
10
11
12
13
14
15
16
17

using namespace wangziqi2013::bwtree;

class BwTreeDataStore : public AbstractDataStore {
public:
  BwTreeDataStore();
  BwTreeDataStore(Duplicates duplicates, bool eraseOnGet, bool debug);
  virtual ~BwTreeDataStore();
18
  virtual bool openDatabase(const std::string& db_name, const std::string& path);
19
20
21
  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);
22
23
24
25
  virtual bool exists(const ds_bulk_t &key) {
        ds_bulk_t data;
        return get(key,data);
  }
Matthieu Dorier's avatar
Matthieu Dorier committed
26
  virtual bool erase(const ds_bulk_t &key);
27
  virtual void set_in_memory(bool enable); // a no-op
28
  virtual void set_comparison_function(comparator_fn less);
29
30
31
  virtual void set_no_overwrite() {
      _no_overwrite = true;
  }
32
protected:
33
34
35
36
37
38
39
40
  virtual std::vector<ds_bulk_t> vlist_keys(
          const ds_bulk_t &start, size_t count, const ds_bulk_t &prefix) const;
  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 &prefix) const;
  virtual std::vector<ds_bulk_t> vlist_key_range(
          const ds_bulk_t &lower_bound, const ds_bulk_t &upper_bound, size_t max_keys) const;
  virtual std::vector<std::pair<ds_bulk_t,ds_bulk_t>> vlist_keyval_range(
          const ds_bulk_t &lower_bound, const ds_bulk_t& upper_bound, size_t max_keys) const;
41
42
43
  BwTree<ds_bulk_t, ds_bulk_t, 
	 ds_bulk_less, ds_bulk_equal, ds_bulk_hash,
	 ds_bulk_equal, ds_bulk_hash> *_tree = NULL;
44
  bool _no_overwrite = false;
45
46
47
};

#endif // bwtree_datastore_h