3#include <xrpl/basics/Blob.h>
4#include <xrpl/basics/ByteUtilities.h>
5#include <xrpl/basics/FileUtilities.h>
6#include <xrpl/basics/base_uint.h>
7#include <xrpl/basics/safe_cast.h>
8#include <xrpl/beast/utility/Journal.h>
9#include <xrpl/beast/xor_shift_engine.h>
10#include <xrpl/config/BasicConfig.h>
11#include <xrpl/nodestore/Backend.h>
12#include <xrpl/nodestore/Database.h>
13#include <xrpl/nodestore/DummyScheduler.h>
14#include <xrpl/nodestore/Manager.h>
15#include <xrpl/nodestore/NodeObject.h>
16#include <xrpl/nodestore/Scheduler.h>
17#include <xrpl/nodestore/Types.h>
19#include <boost/algorithm/string/classification.hpp>
20#include <boost/algorithm/string/split.hpp>
39template <
class Generator>
43 using result_type =
typename Generator::result_type;
47 auto const chunk =
std::min(bytes,
sizeof(result_type));
49 buffer =
reinterpret_cast<std::uint8_t*
>(buffer) + chunk;
120 while ((size--) != 0u)
131 boost::split(values, s, boost::algorithm::is_any_of(
","));
144 for (
auto i = 0uz; i < count; ++i)
157 for (
auto i = 0uz; i < count; ++i)
169 for (
auto const& obj : pool)
170 total += obj->getData().size();
171 return total / pool.
size();
205 std::ranges::iota(v, 0uz);
302 {.name =
"nudb", .config =
"type=nudb"},
303#if XRPL_ROCKSDB_AVAILABLE
304 {.name =
"rocksdb", .config =
"type=rocksdb"},
A generic endpoint for log messages.
static Sink & getNullSink()
Returns a Sink which does nothing.
static constexpr std::size_t size()
static std::shared_ptr< NodeObject > createObject(NodeObjectType type, Blob &&data, uint256 const &hash)
Create an object from fields.
Holds a collection of configuration values.
void set(std::string const &key, std::string const &value)
Set a key/value pair.
void append(std::vector< std::string > const &lines)
Append a set of lines to this section.
RAII temporary directory.
A backend used for the NodeStore.
virtual void storeBatch(Batch const &batch)=0
Store a group of objects.
Simple NodeStore Scheduler that just performs the tasks synchronously.
virtual std::unique_ptr< Backend > makeBackend(Section const ¶meters, std::size_t burstSize, Scheduler &scheduler, beast::Journal journal)=0
Create a backend.
virtual std::unique_ptr< Database > makeDatabase(std::size_t burstSize, Scheduler &scheduler, int readThreads, Section const &backendParameters, beast::Journal journal)=0
Construct a NodeStore database.
static Manager & instance()
Returns the instance of the manager singleton.
Deterministic generator of a reproducible sequence of random NodeObjects.
beast::xor_shift_engine gen_
void batch(std::size_t n, Batch &b, std::size_t size)
uint256 key(std::size_t n)
std::uniform_int_distribution< std::uint32_t > dSize_
std::discrete_distribution< std::uint32_t > dType_
static constexpr auto kMaxSize
std::shared_ptr< NodeObject > obj(std::size_t n)
Sequence(std::uint8_t prefix)
static constexpr auto kMinSize
T emplace_back(T... args)
detail::XorShiftEngine<> xor_shift_engine
XOR-shift Generator.
Section parseConfig(std::string const &s)
std::vector< std::size_t > makeShuffle(std::size_t size, std::uint64_t seed)
std::vector< Batch > sliceFixedBatches(Batch const &pool, std::size_t batchSize)
std::vector< BackendConfig > const & backendConfigs()
void prepopulate(Backend &backend, Batch const &objects)
void rngcpy(void *buffer, std::size_t bytes, Generator &g)
std::vector< uint256 > makeMissingKeys(std::size_t count)
static constexpr auto kBatchWriteLimitSize
std::vector< std::shared_ptr< NodeObject > > Batch
A batch of NodeObjects to write at once.
Batch makePool(std::uint8_t prefix, std::size_t count, std::size_t start=0)
std::size_t averagePayload(Batch const &pool)
constexpr Dest safeCast(Src s) noexcept
constexpr auto megabytes(T value) noexcept
std::vector< unsigned char > Blob
Storage for linear binary data.
std::unique_ptr< Backend > backend
TempDir tempDir
Declared first so it is destroyed last.
BackendHarness(std::string const &configString)
std::unique_ptr< Database > db
DatabaseHarness(std::string const &configString, int readThreads)