benchmark silo added
[c11concurrency-benchmarks.git] / silo / new-benchmarks / abstract_db.h
1 #ifndef _ABSTRACT_DB_H_
2 #define _ABSTRACT_DB_H_
3
4 #include <stddef.h>
5 #include <stdint.h>
6 #include <sys/types.h>
7
8 #include <map>
9 #include <string>
10
11 #include "abstract_ordered_index.h"
12
13 class abstract_db {
14 public:
15
16   // dtor should close db
17   virtual ~abstract_db() {}
18
19   /**
20    * an approximate max batch size for updates in a transaction.
21    *
22    * A return value of -1 indicates no maximum
23    */
24   virtual ssize_t txn_max_batch_size() const { return -1; }
25
26   /**
27    * XXX(stephentu): hack
28    */
29   virtual void do_txn_epoch_sync() const {}
30
31   /**
32    * XXX(stephentu): hack
33    */
34   virtual void do_txn_finish() const {}
35
36   /** loader should be used as a performance hint, not for correctness */
37   virtual void thread_init(bool loader) {}
38
39   virtual void thread_end() {}
40
41   // [ntxns_persisted, ntxns_committed, avg latency]
42   virtual std::tuple<uint64_t, uint64_t, double>
43     get_ntxn_persisted() const { return std::make_tuple(0, 0, 0.0); }
44
45   virtual void reset_ntxn_persisted() { }
46
47   enum TxnProfileHint {
48     HINT_DEFAULT,
49
50     // ycsb profiles
51     HINT_KV_GET_PUT, // KV workloads over a single key
52     HINT_KV_RMW, // get/put over a single key
53     HINT_KV_SCAN, // KV scan workloads (~100 keys)
54
55     // tpcc profiles
56     HINT_TPCC_NEW_ORDER,
57     HINT_TPCC_PAYMENT,
58     HINT_TPCC_DELIVERY,
59     HINT_TPCC_ORDER_STATUS,
60     HINT_TPCC_ORDER_STATUS_READ_ONLY,
61     HINT_TPCC_STOCK_LEVEL,
62     HINT_TPCC_STOCK_LEVEL_READ_ONLY,
63   };
64
65   ///**
66   // * Initializes a new txn object the space pointed to by buf
67   // *
68   // * Flags is only for the ndb protocol for now
69   // *
70   // * [buf, buf + sizeof_txn_object(txn_flags)) is a valid ptr
71   // */
72   //virtual void *new_txn(uint64_t txn_flags, void *buf,
73   //    TxnProfileHint hint = HINT_DEFAULT) = 0;
74
75   typedef std::map<std::string, uint64_t> counter_map;
76   typedef std::map<std::string, counter_map> txn_counter_map;
77
78   /**
79    * Reports things like read/write set sizes
80    */
81   virtual counter_map
82   get_txn_counters(void *txn) const
83   {
84     return counter_map();
85   }
86
87   ///**
88   // * Returns true on successful commit.
89   // *
90   // * On failure, can either throw abstract_abort_exception, or
91   // * return false- caller should be prepared to deal with both cases
92   // */
93   //virtual bool commit_txn(void *txn) = 0;
94
95   ///**
96   // * XXX
97   // */
98   //virtual void abort_txn(void *txn) = 0;
99
100   //virtual void print_txn_debug(void *txn) const {}
101
102   //virtual abstract_ordered_index *
103   //open_index(const std::string &name,
104   //           size_t value_size_hint,
105   //           bool mostly_append = false) = 0;
106
107   //virtual void
108   //close_index(abstract_ordered_index *idx) = 0;
109 };
110
111 #endif /* _ABSTRACT_DB_H_ */