MDBX Containers
Loading...
Searching...
No Matches
Config.hpp
Go to the documentation of this file.
1#pragma once
2#ifndef _MDBX_CONTAINERS_CONFIG_HPP_INCLUDED
3#define _MDBX_CONTAINERS_CONFIG_HPP_INCLUDED
4
7
8namespace mdbxc {
9
17 class Config {
18 public:
19 std::string pathname;
20 int64_t size_lower = -1;
21 int64_t size_now = -1;
22 int64_t size_upper = -1;
23 int64_t growth_step = 16 * 1024 * 1024;
24 int64_t shrink_threshold = 16 * 1024 * 1024;
25 int64_t page_size = 0;
26 int64_t max_readers = 0;
27 int64_t max_dbs = 10;
28 bool read_only = false;
29 bool readahead = true;
30 bool no_subdir = true;
31 bool sync_durable = true;
32 bool writemap_mode = false;
33 bool relative_to_exe = false;
34
37 bool validate() const {
38 const bool page_ok = (page_size == 0) || ((page_size & (page_size - 1)) == 0);
39 const bool size_ok = (size_lower <= size_now || size_now == -1) &&
40 (size_now <= size_upper || size_now == -1);
41 return !pathname.empty() && page_ok && size_ok;
42 }
43 };
44
45}; // mdbxc
46
47#endif // _MDBX_CONTAINERS_CONFIG_HPP_INCLUDED
Parameters used by Connection to create the MDBX environment.
Definition Config.hpp:17
bool validate() const
Validate the MDBX configuration.
Definition Config.hpp:37
int64_t size_now
Current size of the database.
Definition Config.hpp:21
bool no_subdir
Whether to store the database in a single file instead of a directory.
Definition Config.hpp:30
int64_t max_readers
Maximum reader slots; use 0 for the default (twice the CPU count).
Definition Config.hpp:26
int64_t shrink_threshold
Threshold for database shrinking.
Definition Config.hpp:24
bool readahead
Whether to enable OS readahead for sequential access.
Definition Config.hpp:29
bool sync_durable
Whether to enforce synchronous durable writes (MDBX_SYNC_DURABLE).
Definition Config.hpp:31
int64_t size_lower
Lower bound for database size.
Definition Config.hpp:20
bool writemap_mode
Whether to map the database with MDBX_WRITEMAP for direct modification.
Definition Config.hpp:32
std::string pathname
Path to the database file or directory containing the database.
Definition Config.hpp:19
int64_t growth_step
Step size for database growth.
Definition Config.hpp:23
int64_t page_size
Page size (must be a power of two).
Definition Config.hpp:25
int64_t size_upper
Upper bound for database size.
Definition Config.hpp:22
bool read_only
Whether to open the environment in read-only mode.
Definition Config.hpp:28
bool relative_to_exe
Whether to resolve a relative path relative to the executable directory.
Definition Config.hpp:33
int64_t max_dbs
Maximum number of named databases (DBI) in the environment.
Definition Config.hpp:27