X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11concurrency-benchmarks.git;a=blobdiff_plain;f=silo%2Fbenchmarks%2Fbdb_wrapper.h;fp=silo%2Fbenchmarks%2Fbdb_wrapper.h;h=f80e9a6c3f345928f3638f81fa4d61ece6b2c56a;hp=0000000000000000000000000000000000000000;hb=19b84c667216ff74f1b747e18b5542444dc54716;hpb=72045f68e6d1ad46133bdc507b409b676ce64957 diff --git a/silo/benchmarks/bdb_wrapper.h b/silo/benchmarks/bdb_wrapper.h new file mode 100644 index 0000000..f80e9a6 --- /dev/null +++ b/silo/benchmarks/bdb_wrapper.h @@ -0,0 +1,95 @@ +#ifndef _BDB_WRAPPER_H_ +#define _BDB_WRAPPER_H_ + +#include +#include + +#include "abstract_db.h" +#include "../macros.h" + +class bdb_wrapper : public abstract_db { +public: + bdb_wrapper(const std::string &envdir, + const std::string &dbfile); + ~bdb_wrapper(); + + /** + * BDB has small txn sizes + */ + virtual ssize_t txn_max_batch_size() const { return 1000; } + + virtual void *new_txn( + uint64_t txn_flags, + str_arena &arena, + void *buf, + TxnProfileHint hint); + virtual bool commit_txn(void *txn); + virtual void abort_txn(void *txn); + + virtual abstract_ordered_index * + open_index(const std::string &name, + size_t value_size_hint, + bool mostly_append); + + virtual void + close_index(abstract_ordered_index *idx); + +private: + DbEnv *env; +}; + +class bdb_ordered_index : public abstract_ordered_index { +public: + + // takes ownership of db + bdb_ordered_index(Db *db) : db(db) {} + ~bdb_ordered_index(); + + virtual bool get( + void *txn, + const std::string &key, + std::string &value, + size_t max_bytes_read); + + virtual const char * put( + void *txn, + const std::string &key, + const std::string &value); + + virtual void scan( + void *txn, + const std::string &key, + const std::string *value, + scan_callback &callback, + str_arena *arena) + { + NDB_UNIMPLEMENTED("scan"); + } + + virtual void rscan( + void *txn, + const std::string &start_key, + const std::string *end_key, + scan_callback &callback, + str_arena *arena) + { + NDB_UNIMPLEMENTED("rscan"); + } + + virtual size_t + size() const + { + NDB_UNIMPLEMENTED("size"); + } + + virtual std::map + clear() + { + NDB_UNIMPLEMENTED("clear"); + } + +private: + Db *db; +}; + +#endif /* _BDB_WRAPPER_H_ */