20
20
#include < ripple/basics/contract.h>
21
21
#include < ripple/nodestore/Factory.h>
22
22
#include < ripple/nodestore/Manager.h>
23
+ #include < ripple/nodestore/impl/BatchWriter.h>
23
24
#include < ripple/nodestore/impl/DecodedBlob.h>
24
25
#include < ripple/nodestore/impl/EncodedBlob.h>
25
26
#include < ripple/nodestore/impl/codec.h>
35
36
namespace ripple {
36
37
namespace NodeStore {
37
38
38
- class NuDBBackend : public Backend
39
+ class NuDBBackend : public Backend , public BatchWriter ::Callback
39
40
{
40
41
public:
41
42
static constexpr std::uint64_t currentType = 1 ;
@@ -46,6 +47,7 @@ class NuDBBackend : public Backend
46
47
47
48
beast::Journal const j_;
48
49
size_t const keyBytes_;
50
+ BatchWriter batch_;
49
51
std::size_t const burstSize_;
50
52
std::string const name_;
51
53
nudb::store db_;
@@ -60,6 +62,7 @@ class NuDBBackend : public Backend
60
62
beast::Journal journal)
61
63
: j_(journal)
62
64
, keyBytes_(keyBytes)
65
+ , batch_(*this , scheduler)
63
66
, burstSize_(burstSize)
64
67
, name_(get(keyValues, " path" ))
65
68
, deletePath_(false )
@@ -79,6 +82,7 @@ class NuDBBackend : public Backend
79
82
beast::Journal journal)
80
83
: j_(journal)
81
84
, keyBytes_(keyBytes)
85
+ , batch_(*this , scheduler)
82
86
, burstSize_(burstSize)
83
87
, name_(get(keyValues, " path" ))
84
88
, db_(context)
@@ -262,13 +266,7 @@ class NuDBBackend : public Backend
262
266
void
263
267
store (std::shared_ptr<NodeObject> const & no) override
264
268
{
265
- BatchWriteReport report;
266
- report.writeCount = 1 ;
267
- auto const start = std::chrono::steady_clock::now ();
268
- do_insert (no);
269
- report.elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(
270
- std::chrono::steady_clock::now () - start);
271
- scheduler_.onBatchWrite (report);
269
+ batch_.store (no);
272
270
}
273
271
274
272
void
@@ -329,7 +327,7 @@ class NuDBBackend : public Backend
329
327
int
330
328
getWriteLoad () override
331
329
{
332
- return 0 ;
330
+ return batch_. getWriteLoad () ;
333
331
}
334
332
335
333
void
@@ -357,6 +355,12 @@ class NuDBBackend : public Backend
357
355
Throw<nudb::system_error>(ec);
358
356
}
359
357
358
+ void
359
+ writeBatch (Batch const & batch) override
360
+ {
361
+ storeBatch (batch);
362
+ }
363
+
360
364
int
361
365
fdRequired () const override
362
366
{
0 commit comments