1 #ifndef _KVDB_WRAPPER_H_
2 #define _KVDB_WRAPPER_H_
4 #include "abstract_db.h"
5 #include "../btree_choice.h"
8 template <bool UseConcurrencyControl>
9 class kvdb_wrapper : public abstract_db {
12 virtual ssize_t txn_max_batch_size() const OVERRIDE { return 100; }
14 virtual void do_txn_epoch_sync() const { }
16 virtual void do_txn_finish() const { }
19 sizeof_txn_object(uint64_t txn_flags) const
21 return sizeof(scoped_rcu_region);
25 new_txn(uint64_t txn_flags, str_arena &arena, void *buf, TxnProfileHint hint)
27 return new (buf) scoped_rcu_region;
33 ((scoped_rcu_region *) txn)->~scoped_rcu_region();
37 virtual void abort_txn(void *txn) { ALWAYS_ASSERT(false); } // txn should never abort
38 virtual void print_txn_debug(void *txn) const { }
40 virtual abstract_ordered_index *
41 open_index(const std::string &name,
42 size_t value_size_hint,
46 close_index(abstract_ordered_index *idx)
52 template <bool UseConcurrencyControl>
53 class kvdb_ordered_index : public abstract_ordered_index {
55 kvdb_ordered_index(const std::string &name)
59 const std::string &key,
60 std::string &value, size_t max_bytes_read);
61 virtual const char * put(
63 const std::string &key,
64 const std::string &value);
67 const std::string &key,
68 const std::string &value);
71 const std::string &start_key,
72 const std::string *end_key,
73 scan_callback &callback,
77 const std::string &start_key,
78 const std::string *end_key,
79 scan_callback &callback,
83 const std::string &key);
84 virtual size_t size() const;
85 virtual std::map<std::string, uint64_t> clear();
89 typename std::conditional<
90 UseConcurrencyControl,
92 single_threaded_btree>::type
94 typedef typename my_btree::key_type key_type;
98 #endif /* _KVDB_WRAPPER_H_ */