1
1
#include " Ycsb.hpp"
2
+ #include " leanstore-c/StoreOption.h"
2
3
#include " leanstore/KVInterface.hpp"
3
4
#include " leanstore/LeanStore.hpp"
4
- #include " leanstore/StoreOption.hpp"
5
5
#include " leanstore/btree/BasicKV.hpp"
6
6
#include " leanstore/btree/TransactionKV.hpp"
7
7
#include " leanstore/concurrency/CRManager.hpp"
@@ -38,16 +38,18 @@ class YcsbLeanStore : public YcsbExecutor {
38
38
public:
39
39
YcsbLeanStore (bool benchTransactionKv, bool createFromScratch)
40
40
: mBenchTransactionKv (benchTransactionKv) {
41
- auto res = LeanStore::Open (StoreOption{
42
- .mCreateFromScratch = createFromScratch,
43
- .mStoreDir = FLAGS_ycsb_data_dir + " /leanstore" ,
44
- .mWorkerThreads = FLAGS_ycsb_threads,
45
- .mBufferPoolSize = FLAGS_ycsb_mem_kb * 1024 ,
46
- .mEnableMetrics = true ,
47
- .mMetricsPort = 8080 ,
48
- });
41
+ auto dataDirStr = FLAGS_ycsb_data_dir + std::string (" /leanstore" );
42
+ StoreOption* option = CreateStoreOption (dataDirStr.c_str ());
43
+ option->mCreateFromScratch = createFromScratch;
44
+ option->mWorkerThreads = FLAGS_ycsb_threads;
45
+ option->mBufferPoolSize = FLAGS_ycsb_mem_kb * 1024 ;
46
+ option->mEnableMetrics = true ;
47
+ option->mMetricsPort = 8080 ;
48
+
49
+ auto res = LeanStore::Open (option);
49
50
if (!res) {
50
51
std::cerr << " Failed to open leanstore: " << res.error ().ToString () << std::endl;
52
+ DestroyStoreOption (option);
51
53
exit (res.error ().Code ());
52
54
}
53
55
@@ -112,7 +114,7 @@ class YcsbLeanStore : public YcsbExecutor {
112
114
std::cout << summary << std::endl;
113
115
});
114
116
115
- auto numWorkers = mStore ->mStoreOption . mWorkerThreads ;
117
+ auto numWorkers = mStore ->mStoreOption -> mWorkerThreads ;
116
118
auto avg = FLAGS_ycsb_record_count / numWorkers;
117
119
auto rem = FLAGS_ycsb_record_count % numWorkers;
118
120
for (auto workerId = 0u , begin = 0u ; workerId < numWorkers;) {
@@ -151,8 +153,8 @@ class YcsbLeanStore : public YcsbExecutor {
151
153
auto zipfRandom =
152
154
utils::ScrambledZipfGenerator (0 , FLAGS_ycsb_record_count, FLAGS_ycsb_zipf_factor);
153
155
std::atomic<bool > keepRunning = true ;
154
- std::vector<std::atomic<uint64_t >> threadCommitted (mStore ->mStoreOption . mWorkerThreads );
155
- std::vector<std::atomic<uint64_t >> threadAborted (mStore ->mStoreOption . mWorkerThreads );
156
+ std::vector<std::atomic<uint64_t >> threadCommitted (mStore ->mStoreOption -> mWorkerThreads );
157
+ std::vector<std::atomic<uint64_t >> threadAborted (mStore ->mStoreOption -> mWorkerThreads );
156
158
// init counters
157
159
for (auto & c : threadCommitted) {
158
160
c = 0 ;
@@ -161,7 +163,7 @@ class YcsbLeanStore : public YcsbExecutor {
161
163
a = 0 ;
162
164
}
163
165
164
- for (uint64_t workerId = 0 ; workerId < mStore ->mStoreOption . mWorkerThreads ; workerId++) {
166
+ for (uint64_t workerId = 0 ; workerId < mStore ->mStoreOption -> mWorkerThreads ; workerId++) {
165
167
mStore ->ExecAsync (workerId, [&]() {
166
168
uint8_t key[FLAGS_ycsb_key_size];
167
169
std::string valRead;
@@ -236,7 +238,7 @@ class YcsbLeanStore : public YcsbExecutor {
236
238
a = 0 ;
237
239
}
238
240
239
- printTpsSummary (1 , FLAGS_ycsb_run_for_seconds, mStore ->mStoreOption . mWorkerThreads ,
241
+ printTpsSummary (1 , FLAGS_ycsb_run_for_seconds, mStore ->mStoreOption -> mWorkerThreads ,
240
242
threadCommitted, threadAborted);
241
243
242
244
// Shutdown threads
0 commit comments