libmdbx  0.12.2.11 (2022-11-19T23:19:30+03:00)
One of the fastest compact embeddable key-value ACID database without WAL.
C++ API

Modules

 exceptions and errors
 
 slices and buffers
 

Classes

class  mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >
 The chunk of data stored inside the buffer or located outside it. More...
 
struct  mdbx::map_handle
 A handle for an individual database (key-value spaces) in the environment. More...
 
class  mdbx::env
 Unmanaged database environment. More...
 
class  mdbx::env_managed
 Managed database environment. More...
 
class  mdbx::txn
 Unmanaged database transaction. More...
 
class  mdbx::txn_managed
 Managed database transaction. More...
 
class  mdbx::cursor
 Unmanaged cursor. More...
 
class  mdbx::cursor_managed
 Managed cursor. More...
 
struct  std::hash<::mdbx::slice >
 

Macros

#define MDBX_STD_FILESYSTEM_PATH   ::mdbx::filesystem::path
 Defined if mdbx::filesystem::path is available. More...
 

Typedefs

using mdbx::byte = char8_t
 
using mdbx::version_info = ::MDBX_version_info
 libmdbx version information More...
 
using mdbx::build_info = ::MDBX_build_info
 libmdbx build information More...
 
using mdbx::legacy_allocator = ::std::string::allocator_type
 Legacy default allocator but it is recommended to use polymorphic_allocator. More...
 
using mdbx::polymorphic_allocator = ::std::pmr::string::allocator_type
 Default polymorphic allocator for modern code. More...
 
template<class ALLOCATOR = legacy_allocator>
using mdbx::string = ::std::basic_string< char, ::std::char_traits< char >, ALLOCATOR >
 Default singe-byte string. More...
 
using mdbx::filehandle = ::mdbx_filehandle_t
 
using mdbx::path = MDBX_STD_FILESYSTEM_PATH
 

Enumerations

enum  mdbx::loop_control { mdbx::continue_loop = 0 , mdbx::exit_loop = INT32_MIN }
 Loop control constants for readers enumeration functor and other cases. More...
 
enum class  mdbx::key_mode { mdbx::usual = MDBX_DB_DEFAULTS , mdbx::reverse = MDBX_REVERSEKEY , mdbx::ordinal = MDBX_INTEGERKEY , mdbx::msgpack = -1 }
 Kinds of the keys and corresponding modes of comparing it. More...
 
enum class  mdbx::value_mode {
  mdbx::single = MDBX_DB_DEFAULTS , mdbx::multi , mdbx::multi_reverse , mdbx::multi_samelength ,
  mdbx::multi_ordinal , mdbx::multi_reverse_samelength , mdbx::msgpack = -1
}
 Kind of the values and sorted multi-values with corresponding comparison. More...
 
enum  mdbx::put_mode { mdbx::insert_unique = MDBX_NOOVERWRITE , mdbx::upsert = MDBX_UPSERT , mdbx::update = MDBX_CURRENT }
 Key-value pairs put mode. More...
 

Functions

const version_infomdbx::get_version () noexcept
 Returns libmdbx version information. More...
 
const build_infomdbx::get_build () noexcept
 Returns libmdbx build information. More...
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const slice &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const pair &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const pair_result &)
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
inline ::std::ostream & mdbx::operator<< (::std::ostream &out, const buffer< ALLOCATOR, CAPACITY_POLICY > &it)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env::geometry::size &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env::geometry &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env::operate_parameters &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env::mode &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env::durability &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env::reclaiming_options &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env::operate_options &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env_managed::create_parameters &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const MDBX_log_level_t &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const MDBX_debug_flags_t &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const error &)
 
inline ::std::ostream & mdbx::operator<< (::std::ostream &out, const MDBX_error_t &errcode)
 
bool mdbx::operator== (const error &a, const error &b) noexcept
 
bool mdbx::operator!= (const error &a, const error &b) noexcept
 
bool mdbx::operator== (const slice &a, const slice &b) noexcept
 
bool mdbx::operator< (const slice &a, const slice &b) noexcept
 
bool mdbx::operator> (const slice &a, const slice &b) noexcept
 
bool mdbx::operator<= (const slice &a, const slice &b) noexcept
 
bool mdbx::operator>= (const slice &a, const slice &b) noexcept
 
bool mdbx::operator!= (const slice &a, const slice &b) noexcept
 
bool mdbx::operator== (const env &a, const env &b) noexcept
 
bool mdbx::operator!= (const env &a, const env &b) noexcept
 
bool mdbx::operator== (const txn &a, const txn &b) noexcept
 
bool mdbx::operator!= (const txn &a, const txn &b) noexcept
 
bool mdbx::operator== (const cursor &a, const cursor &b) noexcept
 
bool mdbx::operator!= (const cursor &a, const cursor &b) noexcept
 
ptrdiff_t mdbx::estimate (const cursor &from, const cursor &to)
 
string std::to_string (const ::mdbx::slice &value)
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
string std::to_string (const ::mdbx::buffer< ALLOCATOR, CAPACITY_POLICY > &buffer)
 
string std::to_string (const ::mdbx::pair &value)
 
string std::to_string (const ::mdbx::env::geometry &value)
 
string std::to_string (const ::mdbx::env::operate_parameters &value)
 
string std::to_string (const ::mdbx::env::mode &value)
 
string std::to_string (const ::mdbx::env::durability &value)
 
string std::to_string (const ::mdbx::env::reclaiming_options &value)
 
string std::to_string (const ::mdbx::env::operate_options &value)
 
string std::to_string (const ::mdbx::env_managed::create_parameters &value)
 
string std::to_string (const ::MDBX_log_level_t &value)
 
string std::to_string (const ::MDBX_debug_flags_t &value)
 
string std::to_string (const ::mdbx::error &value)
 
string std::to_string (const ::MDBX_error_t &errcode)
 
bool mdbx::exception_thunk::is_clean () const noexcept
 
void mdbx::exception_thunk::capture () noexcept
 
void mdbx::exception_thunk::rethrow_captured () const
 
 mdbx::error::error (MDBX_error_t error_code) noexcept
 
bool mdbx::error::is_success () const noexcept
 
bool mdbx::error::is_result_true () const noexcept
 
bool mdbx::error::is_result_false () const noexcept
 
bool mdbx::error::is_failure () const noexcept
 
MDBX_error_t mdbx::error::code () const noexcept
 Returns error code. More...
 
bool mdbx::error::is_mdbx_error () const noexcept
 Returns true for MDBX's errors. More...
 
static void mdbx::error::throw_exception (int error_code)
 
void mdbx::error::throw_on_failure () const
 
void mdbx::error::success_or_throw () const
 
void mdbx::error::success_or_throw (const exception_thunk &) const
 
void mdbx::error::panic_on_failure (const char *context_where, const char *func_who) const noexcept
 
void mdbx::error::success_or_panic (const char *context_where, const char *func_who) const noexcept
 
static void mdbx::error::throw_on_nullptr (const void *ptr, MDBX_error_t error_code)
 
static void mdbx::error::throw_on_failure (int error_code)
 
static void mdbx::error::success_or_throw (MDBX_error_t error_code)
 
static bool mdbx::error::boolean_or_throw (int error_code)
 
static void mdbx::error::success_or_throw (int error_code, const exception_thunk &)
 
static void mdbx::error::panic_on_failure (int error_code, const char *context_where, const char *func_who) noexcept
 
static void mdbx::error::success_or_panic (int error_code, const char *context_where, const char *func_who) noexcept
 
 mdbx::slice::slice () noexcept
 Create an empty slice. More...
 
 mdbx::slice::slice (const void *ptr, size_t bytes)
 Create a slice that refers to [0,bytes-1] of memory bytes pointed by ptr. More...
 
 mdbx::slice::slice (const void *begin, const void *end)
 Create a slice that refers to [begin,end] of memory bytes. More...
 
 mdbx::slice::slice (const char *c_str)
 Create a slice that refers to c_str[0,strlen(c_str)-1]. More...
 
 mdbx::slice::slice (const MDBX_val &src)
 
 mdbx::slice::slice (MDBX_val &&src)
 
 mdbx::slice::slice (slice &&src) noexcept
 
slicemdbx::slice::assign (const void *ptr, size_t bytes)
 
slicemdbx::slice::assign (const slice &src) noexcept
 
slicemdbx::slice::assign (const ::MDBX_val &src)
 
slicemdbx::slice::assign (slice &&src) noexcept
 
slicemdbx::slice::assign (::MDBX_val &&src)
 
slicemdbx::slice::assign (const void *begin, const void *end)
 
slicemdbx::slice::assign (const char *c_str)
 
slicemdbx::slice::operator= (slice &&src) noexcept
 
slicemdbx::slice::operator= (::MDBX_val &&src)
 
void mdbx::slice::swap (slice &other) noexcept
 
const bytemdbx::slice::byte_ptr () const noexcept
 Returns casted to pointer to byte an address of data. More...
 
const bytemdbx::slice::end_byte_ptr () const noexcept
 Returns casted to pointer to byte an end of data. More...
 
bytemdbx::slice::byte_ptr () noexcept
 
bytemdbx::slice::end_byte_ptr () noexcept
 
const char * mdbx::slice::char_ptr () const noexcept
 Returns casted to pointer to char an address of data. More...
 
const char * mdbx::slice::end_char_ptr () const noexcept
 Returns casted to pointer to char an end of data. More...
 
char * mdbx::slice::char_ptr () noexcept
 
char * mdbx::slice::end_char_ptr () noexcept
 
const void * mdbx::slice::data () const noexcept
 Return a pointer to the beginning of the referenced data. More...
 
const void * mdbx::slice::end () const noexcept
 Return a pointer to the ending of the referenced data. More...
 
void * mdbx::slice::data () noexcept
 
void * mdbx::slice::end () noexcept
 
size_t mdbx::slice::length () const noexcept
 Returns the number of bytes. More...
 
slicemdbx::slice::set_length (size_t bytes)
 Set slice length. More...
 
slicemdbx::slice::set_end (const void *ptr)
 Sets the length by specifying the end of the slice data. More...
 
bool mdbx::slice::empty () const noexcept
 Checks whether the slice is empty. More...
 
bool mdbx::slice::is_null () const noexcept
 Checks whether the slice data pointer is nullptr. More...
 
size_t mdbx::slice::size () const noexcept
 Returns the number of bytes. More...
 
void mdbx::slice::invalidate () noexcept
 Depletes content of slice and make it invalid. More...
 
void mdbx::slice::clear () noexcept
 Makes the slice empty and referencing to nothing. More...
 
void mdbx::slice::remove_prefix (size_t n) noexcept
 Drops the first "n" bytes from this slice. More...
 
void mdbx::slice::safe_remove_prefix (size_t n)
 Drops the first "n" bytes from this slice. More...
 
void mdbx::slice::remove_suffix (size_t n) noexcept
 Drops the last "n" bytes from this slice. More...
 
void mdbx::slice::safe_remove_suffix (size_t n)
 Drops the last "n" bytes from this slice. More...
 
bool mdbx::slice::starts_with (const slice &prefix) const noexcept
 Checks if the data starts with the given prefix. More...
 
bool mdbx::slice::ends_with (const slice &suffix) const noexcept
 Checks if the data ends with the given suffix. More...
 
size_t mdbx::slice::hash_value () const noexcept
 Returns the hash value of referenced data. More...
 
byte mdbx::slice::operator[] (size_t n) const noexcept
 Returns the nth byte in the referenced data. More...
 
byte mdbx::slice::at (size_t n) const
 Returns the nth byte in the referenced data with bounds checking. More...
 
slice mdbx::slice::head (size_t n) const noexcept
 Returns the first "n" bytes of the slice. More...
 
slice mdbx::slice::tail (size_t n) const noexcept
 Returns the last "n" bytes of the slice. More...
 
slice mdbx::slice::middle (size_t from, size_t n) const noexcept
 Returns the middle "n" bytes of the slice. More...
 
slice mdbx::slice::safe_head (size_t n) const
 Returns the first "n" bytes of the slice. More...
 
slice mdbx::slice::safe_tail (size_t n) const
 Returns the last "n" bytes of the slice. More...
 
slice mdbx::slice::safe_middle (size_t from, size_t n) const
 Returns the middle "n" bytes of the slice. More...
 
static intptr_t mdbx::slice::compare_fast (const slice &a, const slice &b) noexcept
 Three-way fast non-lexicographically length-based comparison. More...
 
static intptr_t mdbx::slice::compare_lexicographically (const slice &a, const slice &b) noexcept
 Three-way lexicographically comparison. More...
 
template<class ALLOCATOR = legacy_allocator>
string< ALLOCATOR > mdbx::slice::as_hex_string (bool uppercase=false, unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
 Returns a string with a hexadecimal dump of the slice content. More...
 
template<class ALLOCATOR = legacy_allocator>
string< ALLOCATOR > mdbx::slice::as_base58_string (unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
 Returns a string with a Base58 dump of the slice content. More...
 
template<class ALLOCATOR = legacy_allocator>
string< ALLOCATOR > mdbx::slice::as_base64_string (unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
 Returns a string with a Base58 dump of the slice content. More...
 
template<class ALLOCATOR = legacy_allocator, class CAPACITY_POLICY = default_capacity_policy>
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::encode_hex (bool uppercase=false, unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
 Returns a buffer with a hexadecimal dump of the slice content. More...
 
template<class ALLOCATOR = legacy_allocator, class CAPACITY_POLICY = default_capacity_policy>
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::encode_base58 (unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
 Returns a buffer with a Base58 dump of the slice content. More...
 
template<class ALLOCATOR = legacy_allocator, class CAPACITY_POLICY = default_capacity_policy>
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::encode_base64 (unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
 Returns a buffer with a Base64 dump of the slice content. More...
 
template<class ALLOCATOR = legacy_allocator, class CAPACITY_POLICY = default_capacity_policy>
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::hex_decode (bool ignore_spaces=false, const ALLOCATOR &allocator=ALLOCATOR()) const
 Decodes hexadecimal dump from the slice content to returned buffer. More...
 
template<class ALLOCATOR = legacy_allocator, class CAPACITY_POLICY = default_capacity_policy>
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::base58_decode (bool ignore_spaces=false, const ALLOCATOR &allocator=ALLOCATOR()) const
 Decodes Base58 dump from the slice content to returned buffer. More...
 
template<class ALLOCATOR = legacy_allocator, class CAPACITY_POLICY = default_capacity_policy>
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::base64_decode (bool ignore_spaces=false, const ALLOCATOR &allocator=ALLOCATOR()) const
 Decodes Base64 dump from the slice content to returned buffer. More...
 
bool mdbx::slice::is_hex (bool ignore_spaces=false) const noexcept
 Checks whether the content of the slice is a hexadecimal dump. More...
 
bool mdbx::slice::is_base58 (bool ignore_spaces=false) const noexcept
 Checks whether the content of the slice is a Base58 dump. More...
 
bool mdbx::slice::is_base64 (bool ignore_spaces=false) const noexcept
 Checks whether the content of the slice is a Base64 dump. More...
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
 mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer (const txn &txn, const struct slice &src, const allocator_type &allocator)
 
 mdbx::map_handle::info::info (map_handle::flags flags, map_handle::state state) noexcept
 
::mdbx::key_mode mdbx::map_handle::info::key_mode () const noexcept
 
::mdbx::value_mode mdbx::map_handle::info::value_mode () const noexcept
 
 mdbx::env::env (MDBX_env *ptr) noexcept
 
envmdbx::env::operator= (env &&other) noexcept
 
 mdbx::env::env (env &&other) noexcept
 
 mdbx::env::~env () noexcept
 
 mdbx::env::operator const MDBX_env * () const
 
 mdbx::env::operator MDBX_env * ()
 
geometrymdbx::env::geometry::make_fixed (intptr_t size) noexcept
 
geometrymdbx::env::geometry::make_dynamic (intptr_t lower=minimal_value, intptr_t upper=maximal_value) noexcept
 
static env::reclaiming_options mdbx::env::operate_parameters::reclaiming_from_flags (MDBX_env_flags_t flags) noexcept
 
static env::operate_options mdbx::env::operate_parameters::options_from_flags (MDBX_env_flags_t flags) noexcept
 
static size_t mdbx::env::limits::pagesize_min () noexcept
 Returns the minimal database page size in bytes. More...
 
static size_t mdbx::env::limits::pagesize_max () noexcept
 Returns the maximal database page size in bytes. More...
 
static size_t mdbx::env::limits::dbsize_min (intptr_t pagesize)
 Returns the minimal database size in bytes for specified page size. More...
 
static size_t mdbx::env::limits::dbsize_max (intptr_t pagesize)
 Returns the maximal database size in bytes for specified page size. More...
 
static size_t mdbx::env::limits::key_min (MDBX_db_flags_t flags) noexcept
 Returns the minimal key size in bytes for specified database flags. More...
 
static size_t mdbx::env::limits::key_min (key_mode mode) noexcept
 Returns the minimal key size in bytes for specified keys mode. More...
 
static size_t mdbx::env::limits::key_max (intptr_t pagesize, MDBX_db_flags_t flags)
 Returns the maximal key size in bytes for specified page size and database flags. More...
 
static size_t mdbx::env::limits::key_max (intptr_t pagesize, key_mode mode)
 Returns the maximal key size in bytes for specified page size and keys mode. More...
 
static size_t mdbx::env::limits::key_max (const env &, MDBX_db_flags_t flags)
 Returns the maximal key size in bytes for given environment and database flags. More...
 
static size_t mdbx::env::limits::key_max (const env &, key_mode mode)
 Returns the maximal key size in bytes for given environment and keys mode. More...
 
static size_t mdbx::env::limits::value_min (MDBX_db_flags_t flags) noexcept
 Returns the minimal values size in bytes for specified database flags. More...
 
static size_t mdbx::env::limits::value_min (value_mode) noexcept
 Returns the minimal values size in bytes for specified values mode. More...
 
static size_t mdbx::env::limits::value_max (intptr_t pagesize, MDBX_db_flags_t flags)
 Returns the maximal value size in bytes for specified page size and database flags. More...
 
static size_t mdbx::env::limits::value_max (intptr_t pagesize, value_mode)
 Returns the maximal value size in bytes for specified page size and values mode. More...
 
static size_t mdbx::env::limits::value_max (const env &, MDBX_db_flags_t flags)
 Returns the maximal value size in bytes for given environment and database flags. More...
 
static size_t mdbx::env::limits::value_max (const env &, value_mode)
 Returns the maximal value size in bytes for specified page size and values mode. More...
 
static size_t mdbx::env::limits::pairsize4page_max (intptr_t pagesize, MDBX_db_flags_t flags)
 Returns maximal size of key-value pair to fit in a single page for specified size and database flags. More...
 
static size_t mdbx::env::limits::pairsize4page_max (intptr_t pagesize, value_mode)
 Returns maximal size of key-value pair to fit in a single page for specified page size and values mode. More...
 
static size_t mdbx::env::limits::pairsize4page_max (const env &, MDBX_db_flags_t flags)
 Returns maximal size of key-value pair to fit in a single page for given environment and database flags. More...
 
static size_t mdbx::env::limits::pairsize4page_max (const env &, value_mode)
 Returns maximal size of key-value pair to fit in a single page for specified page size and values mode. More...
 
static size_t mdbx::env::limits::valsize4page_max (intptr_t pagesize, MDBX_db_flags_t flags)
 Returns maximal data size in bytes to fit in a leaf-page or single overflow/large-page for specified size and database flags. More...
 
static size_t mdbx::env::limits::valsize4page_max (intptr_t pagesize, value_mode)
 Returns maximal data size in bytes to fit in a leaf-page or single overflow/large-page for specified page size and values mode. More...
 
static size_t mdbx::env::limits::valsize4page_max (const env &, MDBX_db_flags_t flags)
 Returns maximal data size in bytes to fit in a leaf-page or single overflow/large-page for given environment and database flags. More...
 
static size_t mdbx::env::limits::valsize4page_max (const env &, value_mode)
 Returns maximal data size in bytes to fit in a leaf-page or single overflow/large-page for specified page size and values mode. More...
 
static size_t mdbx::env::limits::transaction_size_max (intptr_t pagesize)
 Returns the maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes for specified page size. More...
 
env::operate_parameters mdbx::env::get_operation_parameters () const
 Returns current operation parameters. More...
 
env::mode mdbx::env::get_mode () const
 Returns current operation mode. More...
 
env::durability mdbx::env::get_durability () const
 Returns current durability mode. More...
 
env::reclaiming_options mdbx::env::get_reclaiming () const
 Returns current reclaiming options. More...
 
env::operate_options mdbx::env::get_options () const
 Returns current operate options. More...
 
stat mdbx::env::get_stat () const
 Returns snapshot statistics about the MDBX environment. More...
 
stat mdbx::env::get_stat (const txn &) const
 Return statistics about the MDBX environment accordingly to the specified transaction. More...
 
info mdbx::env::get_info () const
 Return snapshot information about the MDBX environment. More...
 
info mdbx::env::get_info (const txn &) const
 Return information about the MDBX environment accordingly to the specified transaction. More...
 
filehandle mdbx::env::get_filehandle () const
 Returns the file descriptor for the DXB file of MDBX environment. More...
 
MDBX_env_flags_t mdbx::env::get_flags () const
 Returns environment flags. More...
 
unsigned mdbx::env::max_readers () const
 Returns the maximum number of threads/reader slots for the environment. More...
 
unsigned mdbx::env::max_maps () const
 Returns the maximum number of named databases for the environment. More...
 
void * mdbx::env::get_context () const noexcept
 Returns the application context associated with the environment. More...
 
envmdbx::env::set_context (void *)
 Sets the application context associated with the environment. More...
 
envmdbx::env::set_sync_threshold (size_t bytes)
 Sets threshold to force flush the data buffers to disk, for non-sync durability modes. More...
 
envmdbx::env::set_sync_period (unsigned seconds_16dot16)
 Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes. More...
 
envmdbx::env::set_sync_period (double seconds)
 Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes. More...
 
envmdbx::env::alter_flags (MDBX_env_flags_t flags, bool on_off)
 Alter environment flags. More...
 
envmdbx::env::set_geometry (const geometry &size)
 Set all size-related parameters of environment. More...
 
bool mdbx::env::sync_to_disk (bool force=true, bool nonblock=false)
 Flush the environment data buffers. More...
 
void mdbx::env::close_map (const map_handle &)
 Close a key-value map (aka sub-database) handle. Normally unnecessary. More...
 
 mdbx::env::reader_info::reader_info (int slot, mdbx_pid_t pid, mdbx_tid_t thread, uint64_t txnid, uint64_t lag, size_t used, size_t retained) noexcept
 
template<typename VISITOR >
int mdbx::env::enumerate_readers (VISITOR &visitor)
 Enumerate readers. More...
 
unsigned mdbx::env::check_readers ()
 Checks for stale readers in the lock table and return number of cleared slots. More...
 
envmdbx::env::set_HandleSlowReaders (MDBX_hsr_func *)
 Sets a Handle-Slow-Readers callback to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled. More...
 
MDBX_hsr_funcmdbx::env::get_HandleSlowReaders () const noexcept
 Returns the current Handle-Slow-Readers callback used to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled. More...
 
txn_managed mdbx::env::start_read () const
 Starts read (read-only) transaction. More...
 
txn_managed mdbx::env::prepare_read () const
 Creates but not start read transaction. More...
 
txn_managed mdbx::env::start_write (bool dont_wait=false)
 Starts write (read-write) transaction. More...
 
txn_managed mdbx::env::try_start_write ()
 Tries to start write (read-write) transaction without blocking. More...
 
 mdbx::txn::txn (MDBX_txn *ptr) noexcept
 
txnmdbx::txn::operator= (txn &&other) noexcept
 
 mdbx::txn::txn (txn &&other) noexcept
 
 mdbx::txn::~txn () noexcept
 
 mdbx::txn::operator const MDBX_txn * () const
 
 mdbx::txn::operator MDBX_txn * ()
 
bool mdbx::txn::is_dirty (const void *ptr) const
 Checks whether the given data is on a dirty page. More...
 
inline ::mdbx::env mdbx::txn::env () const noexcept
 Returns the transaction's environment. More...
 
MDBX_txn_flags_t mdbx::txn::flags () const
 Returns transaction's flags. More...
 
uint64_t mdbx::txn::id () const
 Return the transaction's ID. More...
 
void mdbx::txn::reset_reading ()
 Reset a read-only transaction. More...
 
void mdbx::txn::renew_reading ()
 Renew a read-only transaction. More...
 
info mdbx::txn::get_info (bool scan_reader_lock_table=false) const
 Returns information about the MDBX transaction. More...
 
cursor_managed mdbx::txn::open_cursor (map_handle map)
 Opens cursor for specified key-value map handle. More...
 
map_handle mdbx::txn::open_map (const char *name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single) const
 Open existing key-value map. More...
 
map_handle mdbx::txn::open_map (const ::std::string &name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single) const
 Open existing key-value map. More...
 
map_handle mdbx::txn::create_map (const char *name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single)
 Create new or open existing key-value map. More...
 
map_handle mdbx::txn::create_map (const ::std::string &name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single)
 Create new or open existing key-value map. More...
 
void mdbx::txn::drop_map (map_handle map)
 Drops key-value map using handle. More...
 
bool mdbx::txn::drop_map (const ::std::string &name, bool throw_if_absent=false)
 Drop key-value map. More...
 
void mdbx::txn::clear_map (map_handle map)
 Clear key-value map. More...
 
bool mdbx::txn::clear_map (const ::std::string &name, bool throw_if_absent=false)
 
map_stat mdbx::txn::get_map_stat (map_handle map) const
 Returns statistics for a sub-database. More...
 
uint32_t mdbx::txn::get_tree_deepmask (map_handle map) const
 Returns depth (bitmask) information of nested dupsort (multi-value) B+trees for given database. More...
 
map_handle::info mdbx::txn::get_handle_info (map_handle map) const
 Returns information about key-value map (aka sub-database) handle. More...
 
txnmdbx::txn::put_canary (const canary &)
 Set integers markers (aka "canary") associated with the environment. More...
 
canary mdbx::txn::get_canary () const
 Returns fours integers markers (aka "canary") associated with the environment. More...
 
uint64_t mdbx::txn::sequence (map_handle map) const
 
uint64_t mdbx::txn::sequence (map_handle map, uint64_t increment)
 Reads and increment sequence generator associated with a key-value map (aka sub-database). More...
 
int mdbx::txn::compare_keys (map_handle map, const slice &a, const slice &b) const noexcept
 Compare two keys according to a particular key-value map (aka sub-database). More...
 
int mdbx::txn::compare_values (map_handle map, const slice &a, const slice &b) const noexcept
 Compare two values according to a particular key-value map (aka sub-database). More...
 
int mdbx::txn::compare_keys (map_handle map, const pair &a, const pair &b) const noexcept
 Compare keys of two pairs according to a particular key-value map (aka sub-database). More...
 
int mdbx::txn::compare_values (map_handle map, const pair &a, const pair &b) const noexcept
 Compare values of two pairs according to a particular key-value map (aka sub-database). More...
 
slice mdbx::txn::get (map_handle map, const slice &key) const
 Get value by key from a key-value map (aka sub-database). More...
 
slice mdbx::txn::get (map_handle map, slice key, size_t &values_count) const
 Get first of multi-value and values count by key from a key-value multimap (aka sub-database). More...
 
slice mdbx::txn::get (map_handle map, const slice &key, const slice &value_at_absence) const
 Get value by key from a key-value map (aka sub-database). More...
 
slice mdbx::txn::get (map_handle map, slice key, size_t &values_count, const slice &value_at_absence) const
 Get first of multi-value and values count by key from a key-value multimap (aka sub-database). More...
 
pair_result mdbx::txn::get_equal_or_great (map_handle map, const slice &key) const
 Get value for equal or great key from a database. More...
 
pair_result mdbx::txn::get_equal_or_great (map_handle map, const slice &key, const slice &value_at_absence) const
 Get value for equal or great key from a database. More...
 
MDBX_error_t mdbx::txn::put (map_handle map, const slice &key, slice *value, MDBX_put_flags_t flags) noexcept
 
void mdbx::txn::put (map_handle map, const slice &key, slice value, put_mode mode)
 
void mdbx::txn::insert (map_handle map, const slice &key, slice value)
 
value_result mdbx::txn::try_insert (map_handle map, const slice &key, slice value)
 
slice mdbx::txn::insert_reserve (map_handle map, const slice &key, size_t value_length)
 
value_result mdbx::txn::try_insert_reserve (map_handle map, const slice &key, size_t value_length)
 
void mdbx::txn::upsert (map_handle map, const slice &key, const slice &value)
 
slice mdbx::txn::upsert_reserve (map_handle map, const slice &key, size_t value_length)
 
void mdbx::txn::update (map_handle map, const slice &key, const slice &value)
 
bool mdbx::txn::try_update (map_handle map, const slice &key, const slice &value)
 
slice mdbx::txn::update_reserve (map_handle map, const slice &key, size_t value_length)
 
value_result mdbx::txn::try_update_reserve (map_handle map, const slice &key, size_t value_length)
 
bool mdbx::txn::erase (map_handle map, const slice &key)
 Removes all values for given key. More...
 
bool mdbx::txn::erase (map_handle map, const slice &key, const slice &value)
 Removes the particular multi-value entry of the key. More...
 
void mdbx::txn::replace (map_handle map, const slice &key, slice old_value, const slice &new_value)
 Replaces the particular multi-value of the key with a new value. More...
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::txn::extract (map_handle map, const slice &key, const typename buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type &allocator=buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type())
 Removes and return a value of the key. More...
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::txn::replace (map_handle map, const slice &key, const slice &new_value, const typename buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type &allocator=buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type())
 Replaces and returns a value of the key with new one. More...
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::txn::replace_reserve (map_handle map, const slice &key, slice &new_value, const typename buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type &allocator=buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type())
 
void mdbx::txn::append (map_handle map, const slice &key, const slice &value, bool multivalue_order_preserved=true)
 Adding a key-value pair, provided that ascending order of the keys and (optionally) values are preserved. More...
 
size_t mdbx::txn::put_multiple (map_handle map, const slice &key, const size_t value_length, const void *values_array, size_t values_count, put_mode mode, bool allow_partial=false)
 
ptrdiff_t mdbx::txn::estimate (map_handle map, pair from, pair to) const
 
ptrdiff_t mdbx::txn::estimate (map_handle map, slice from, slice to) const
 
ptrdiff_t mdbx::txn::estimate_from_first (map_handle map, slice to) const
 
ptrdiff_t mdbx::txn::estimate_to_last (map_handle map, slice from) const
 
 mdbx::cursor::cursor (MDBX_cursor *ptr) noexcept
 
cursormdbx::cursor::operator= (cursor &&other) noexcept
 
 mdbx::cursor::cursor (cursor &&other) noexcept
 
 mdbx::cursor::~cursor () noexcept
 
 mdbx::cursor::operator const MDBX_cursor * () const
 
 mdbx::cursor::operator MDBX_cursor * ()
 
 mdbx::cursor::move_result::move_result (const cursor &cursor, bool throw_notfound)
 
 mdbx::cursor::move_result::move_result (cursor &cursor, move_operation operation, bool throw_notfound)
 
 mdbx::cursor::move_result::move_result (cursor &cursor, move_operation operation, const slice &key, bool throw_notfound)
 
 mdbx::cursor::move_result::move_result (cursor &cursor, move_operation operation, const slice &key, const slice &value, bool throw_notfound)
 
bool mdbx::cursor::move (move_operation operation, MDBX_val *key, MDBX_val *value, bool throw_notfound) const
 
ptrdiff_t mdbx::cursor::estimate (move_operation operation, MDBX_val *key, MDBX_val *value) const
 
move_result mdbx::cursor::move (move_operation operation, bool throw_notfound)
 
move_result mdbx::cursor::to_first (bool throw_notfound=true)
 
move_result mdbx::cursor::to_previous (bool throw_notfound=true)
 
move_result mdbx::cursor::to_previous_last_multi (bool throw_notfound=true)
 
move_result mdbx::cursor::to_current_first_multi (bool throw_notfound=true)
 
move_result mdbx::cursor::to_current_prev_multi (bool throw_notfound=true)
 
move_result mdbx::cursor::current (bool throw_notfound=true) const
 
move_result mdbx::cursor::to_current_next_multi (bool throw_notfound=true)
 
move_result mdbx::cursor::to_current_last_multi (bool throw_notfound=true)
 
move_result mdbx::cursor::to_next_first_multi (bool throw_notfound=true)
 
move_result mdbx::cursor::to_next (bool throw_notfound=true)
 
move_result mdbx::cursor::to_last (bool throw_notfound=true)
 
move_result mdbx::cursor::move (move_operation operation, const slice &key, bool throw_notfound)
 
move_result mdbx::cursor::find (const slice &key, bool throw_notfound=true)
 
move_result mdbx::cursor::lower_bound (const slice &key, bool throw_notfound=true)
 
move_result mdbx::cursor::move (move_operation operation, const slice &key, const slice &value, bool throw_notfound)
 
move_result mdbx::cursor::find_multivalue (const slice &key, const slice &value, bool throw_notfound=true)
 
move_result mdbx::cursor::lower_bound_multivalue (const slice &key, const slice &value, bool throw_notfound=false)
 
bool mdbx::cursor::seek (const slice &key)
 
bool mdbx::cursor::move (move_operation operation, slice &key, slice &value, bool throw_notfound)
 
size_t mdbx::cursor::count_multivalue () const
 Return count of duplicates for current key. More...
 
bool mdbx::cursor::eof () const
 
bool mdbx::cursor::on_first () const
 
bool mdbx::cursor::on_last () const
 
ptrdiff_t mdbx::cursor::estimate (slice key, slice value) const
 
ptrdiff_t mdbx::cursor::estimate (slice key) const
 
ptrdiff_t mdbx::cursor::estimate (move_operation operation) const
 
void mdbx::cursor::renew (::mdbx::txn &txn)
 Renew/bind a cursor with a new transaction and previously used key-value map handle. More...
 
void mdbx::cursor::bind (::mdbx::txn &txn, ::mdbx::map_handle map_handle)
 Bind/renew a cursor with a new transaction and specified key-value map handle. More...
 
inline ::mdbx::txn mdbx::cursor::txn () const
 Returns the cursor's transaction. More...
 
map_handle mdbx::cursor::map () const
 
MDBX_error_t mdbx::cursor::put (const slice &key, slice *value, MDBX_put_flags_t flags) noexcept
 
void mdbx::cursor::insert (const slice &key, slice value)
 
value_result mdbx::cursor::try_insert (const slice &key, slice value)
 
slice mdbx::cursor::insert_reserve (const slice &key, size_t value_length)
 
value_result mdbx::cursor::try_insert_reserve (const slice &key, size_t value_length)
 
void mdbx::cursor::upsert (const slice &key, const slice &value)
 
slice mdbx::cursor::upsert_reserve (const slice &key, size_t value_length)
 
void mdbx::cursor::update (const slice &key, const slice &value)
 
bool mdbx::cursor::try_update (const slice &key, const slice &value)
 
slice mdbx::cursor::update_reserve (const slice &key, size_t value_length)
 
value_result mdbx::cursor::try_update_reserve (const slice &key, size_t value_length)
 
bool mdbx::cursor::erase (bool whole_multivalue=false)
 Removes single key-value pair or all multi-values at the current cursor position. More...
 
bool mdbx::cursor::erase (const slice &key, bool whole_multivalue=true)
 Seeks and removes first value or whole multi-value of the given key. More...
 
bool mdbx::cursor::erase (const slice &key, const slice &value)
 Seeks and removes the particular multi-value entry of the key. More...
 

Detailed Description


Class Documentation

◆ mdbx::buffer

class mdbx::buffer

template<class ALLOCATOR, typename CAPACITY_POLICY>
class mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >

The chunk of data stored inside the buffer or located outside it.

Public Types

enum  : size_t { max_length = MDBX_MAXDATASIZE , max_capacity = (max_length / 3u * 4u + 1023u) & ~size_t(1023) , extra_inplace_storage = reservation_policy::extra_inplace_storage , pettiness_threshold = reservation_policy::pettiness_threshold }
 
using allocator_type = typename ::std::allocator_traits< ALLOCATOR >::template rebind_alloc< uint64_t >
 
using allocator_traits = ::std::allocator_traits< allocator_type >
 
using reservation_policy = CAPACITY_POLICY
 

Public Member Functions

allocator_type get_allocator () const
 Returns the associated allocator. More...
 
bool is_freestanding () const noexcept
 Checks whether data chunk stored inside the buffer, otherwise buffer just refers to data located outside the buffer. More...
 
bool is_reference () const noexcept
 Checks whether the buffer just refers to data located outside the buffer, rather than stores it. More...
 
size_t capacity () const noexcept
 Returns the number of bytes that can be held in currently allocated storage. More...
 
size_t headroom () const noexcept
 Returns the number of bytes that available in currently allocated storage ahead the currently beginning of data. More...
 
size_t tailroom () const noexcept
 Returns the number of bytes that available in currently allocated storage after the currently data end. More...
 
const bytebyte_ptr () const noexcept
 Returns casted to const pointer to byte an address of data. More...
 
const byteend_byte_ptr () const noexcept
 Returns casted to const pointer to byte an end of data. More...
 
bytebyte_ptr () noexcept
 Returns casted to pointer to byte an address of data. More...
 
byteend_byte_ptr () noexcept
 Returns casted to pointer to byte an end of data. More...
 
const char * char_ptr () const noexcept
 Returns casted to const pointer to char an address of data. More...
 
const char * end_char_ptr () const noexcept
 Returns casted to const pointer to char an end of data. More...
 
char * char_ptr () noexcept
 Returns casted to pointer to char an address of data. More...
 
char * end_char_ptr () noexcept
 Returns casted to pointer to char an end of data. More...
 
const void * data () const noexcept
 Return a const pointer to the beginning of the referenced data. More...
 
const void * end () const noexcept
 Return a const pointer to the end of the referenced data. More...
 
void * data () noexcept
 Return a pointer to the beginning of the referenced data. More...
 
void * end () noexcept
 Return a pointer to the end of the referenced data. More...
 
size_t length () const noexcept
 Returns the number of bytes. More...
 
bufferset_length (size_t bytes)
 Set length of data. More...
 
bufferset_end (const void *ptr)
 Sets the length by specifying the end of the data. More...
 
void make_freestanding ()
 Makes buffer owning the data. More...
 
 buffer () noexcept=default
 
 buffer (const allocator_type &allocator) noexcept
 
 buffer (const struct slice &src, bool make_reference, const allocator_type &allocator=allocator_type())
 
 buffer (const buffer &src, bool make_reference, const allocator_type &allocator=allocator_type())
 
 buffer (const void *ptr, size_t bytes, bool make_reference, const allocator_type &allocator=allocator_type())
 
template<class CHAR , class T , class A >
 buffer (const ::std::basic_string< CHAR, T, A > &)=delete
 
template<class CHAR , class T , class A >
 buffer (const ::std::basic_string< CHAR, T, A > &&)=delete
 
 buffer (const char *c_str, bool make_reference, const allocator_type &allocator=allocator_type())
 
template<class CHAR , class T >
 buffer (const ::std::basic_string_view< CHAR, T > &view, bool make_reference, const allocator_type &allocator=allocator_type())
 
 buffer (const struct slice &src, const allocator_type &allocator=allocator_type())
 
 buffer (const buffer &src, const allocator_type &allocator=allocator_type())
 
 buffer (const void *ptr, size_t bytes, const allocator_type &allocator=allocator_type())
 
template<class CHAR , class T , class A >
 buffer (const ::std::basic_string< CHAR, T, A > &str, const allocator_type &allocator=allocator_type())
 
 buffer (const char *c_str, const allocator_type &allocator=allocator_type())
 
template<class CHAR , class T >
 buffer (const ::std::basic_string_view< CHAR, T > &view, const allocator_type &allocator=allocator_type())
 
 buffer (size_t head_room, size_t tail_room, const allocator_type &allocator=allocator_type())
 
 buffer (size_t capacity, const allocator_type &allocator=allocator_type())
 
 buffer (size_t head_room, const struct slice &src, size_t tail_room, const allocator_type &allocator=allocator_type())
 
 buffer (size_t head_room, const buffer &src, size_t tail_room, const allocator_type &allocator=allocator_type())
 
 buffer (const ::mdbx::txn &txn, const struct slice &src, const allocator_type &allocator=allocator_type())
 
 buffer (buffer &&src) noexcept(move_assign_alloc::is_nothrow())
 
const struct sliceslice () const noexcept
 
 operator const struct slice & () const noexcept
 
void reserve (size_t wanna_headroom, size_t wanna_tailroom)
 Reserves storage space. More...
 
void reserve_headroom (size_t wanna_headroom)
 Reserves space before the payload. More...
 
void reserve_tailroom (size_t wanna_tailroom)
 Reserves space after the payload. More...
 
bufferassign_reference (const void *ptr, size_t bytes)
 
bufferassign_freestanding (const void *ptr, size_t bytes)
 
void swap (buffer &other) noexcept(swap_alloc::is_nothrow())
 
bufferassign (const buffer &src, bool make_reference=false)
 
bufferassign (const void *ptr, size_t bytes, bool make_reference=false)
 
bufferassign (const struct slice &src, bool make_reference=false)
 
bufferassign (const ::MDBX_val &src, bool make_reference=false)
 
bufferassign (struct slice &&src, bool make_reference=false)
 
bufferassign (::MDBX_val &&src, bool make_reference=false)
 
bufferassign (const void *begin, const void *end, bool make_reference=false)
 
template<class CHAR , class T , class A >
bufferassign (const ::std::basic_string< CHAR, T, A > &str, bool make_reference=false)
 
bufferassign (const char *c_str, bool make_reference=false)
 
bufferoperator= (const buffer &src)
 
bufferoperator= (buffer &&src) noexcept(move_assign_alloc::is_nothrow())
 
bufferoperator= (const struct slice &src)
 
bufferoperator= (struct slice &&src)
 
template<class CHAR , class T >
bufferoperator= (const ::std::basic_string_view< CHAR, T > &view) noexcept
 
template<class CHAR = char, class T = ::std::char_traits<CHAR>>
::std::basic_string_view< CHAR, T > string_view () const noexcept
 Return a string_view that references the data of this buffer. More...
 
template<class CHAR , class T >
 operator::std::basic_string_view () const noexcept
 Return a string_view that references the data of this buffer. More...
 
bool empty () const noexcept
 Checks whether the string is empty. More...
 
bool is_null () const noexcept
 Checks whether the data pointer of the buffer is nullptr. More...
 
size_t size () const noexcept
 Returns the number of bytes. More...
 
size_t hash_value () const noexcept
 Returns the hash value of the data. More...
 
template<class CHAR = char, class T = ::std::char_traits<CHAR>, class A = legacy_allocator>
::std::basic_string< CHAR, T, A > as_string (const A &allocator=A()) const
 
template<class CHAR , class T , class A >
 operator::std::basic_string () const
 
bool starts_with (const struct slice &prefix) const noexcept
 Checks if the data starts with the given prefix. More...
 
bool ends_with (const struct slice &suffix) const noexcept
 Checks if the data ends with the given suffix. More...
 
void clear () noexcept
 Clears the contents and storage. More...
 
void shrink_to_fit ()
 Reduces memory usage by freeing unused storage space. More...
 
void remove_prefix (size_t n) noexcept
 Drops the first "n" bytes from the data chunk. More...
 
void remove_suffix (size_t n) noexcept
 Drops the last "n" bytes from the data chunk. More...
 
void safe_remove_prefix (size_t n)
 Drops the first "n" bytes from the data chunk. More...
 
void safe_remove_suffix (size_t n)
 Drops the last "n" bytes from the data chunk. More...
 
byte operator[] (size_t n) const noexcept
 Accesses the specified byte of data chunk. More...
 
byteoperator[] (size_t n) noexcept
 Accesses the specified byte of data chunk. More...
 
byte at (size_t n) const
 Accesses the specified byte of data chunk with bounds checking. More...
 
byteat (size_t n)
 Accesses the specified byte of data chunk with bounds checking. More...
 
struct slice head (size_t n) const noexcept
 Returns the first "n" bytes of the data chunk. More...
 
struct slice tail (size_t n) const noexcept
 Returns the last "n" bytes of the data chunk. More...
 
struct slice middle (size_t from, size_t n) const noexcept
 Returns the middle "n" bytes of the data chunk. More...
 
struct slice safe_head (size_t n) const
 Returns the first "n" bytes of the data chunk. More...
 
struct slice safe_tail (size_t n) const
 Returns the last "n" bytes of the data chunk. More...
 
struct slice safe_middle (size_t from, size_t n) const
 Returns the middle "n" bytes of the data chunk. More...
 
bufferappend (const void *src, size_t bytes)
 
bufferappend (const struct slice &chunk)
 
bufferadd_header (const void *src, size_t bytes)
 
bufferadd_header (const struct slice &chunk)
 
template<MDBX_CXX20_CONCEPT(MutableByteProducer, PRODUCER) >
bufferappend_producer (PRODUCER &producer)
 
template<MDBX_CXX20_CONCEPT(ImmutableByteProducer, PRODUCER) >
bufferappend_producer (const PRODUCER &producer)
 
bufferappend_hex (const struct slice &data, bool uppercase=false, unsigned wrap_width=0)
 
bufferappend_base58 (const struct slice &data, unsigned wrap_width=0)
 
bufferappend_base64 (const struct slice &data, unsigned wrap_width=0)
 
bufferappend_decoded_hex (const struct slice &data, bool ignore_spaces=false)
 
bufferappend_decoded_base58 (const struct slice &data, bool ignore_spaces=false)
 
bufferappend_decoded_base64 (const struct slice &data, bool ignore_spaces=false)
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
 buffer (const txn &txn, const struct slice &src, const allocator_type &allocator)
 

Static Public Member Functions

template<typename POD >
static buffer wrap (const POD &pod, bool make_reference=false, const allocator_type &allocator=allocator_type())
 
static buffer clone (const buffer &src, const allocator_type &allocator=allocator_type())
 
template<size_t SIZE>
static buffer key_from (const char(&text)[SIZE], bool make_reference=true)
 
template<class CHAR , class T >
static buffer key_from (const ::std::basic_string_view< CHAR, T > &src, bool make_reference=false)
 
static buffer key_from (const char *src, bool make_reference=false)
 
template<class CHAR , class T , class A >
static buffer key_from (const ::std::basic_string< CHAR, T, A > &src, bool make_reference=false)
 
static buffer key_from (const silo &&src) noexcept
 
static buffer key_from (const double ieee754_64bit)
 
static buffer key_from (const double *ieee754_64bit)
 
static buffer key_from (const uint64_t unsigned_int64)
 
static buffer key_from (const int64_t signed_int64)
 
static buffer key_from_jsonInteger (const int64_t json_integer)
 
static buffer key_from (const float ieee754_32bit)
 
static buffer key_from (const float *ieee754_32bit)
 
static buffer key_from (const uint32_t unsigned_int32)
 
static buffer key_from (const int32_t signed_int32)
 

Friends

class txn
 

Member Typedef Documentation

◆ allocator_traits

template<class ALLOCATOR , typename CAPACITY_POLICY >
using mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_traits = ::std::allocator_traits<allocator_type>

◆ allocator_type

template<class ALLOCATOR , typename CAPACITY_POLICY >
using mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type = typename ::std::allocator_traits< ALLOCATOR>::template rebind_alloc<uint64_t>

◆ reservation_policy

template<class ALLOCATOR , typename CAPACITY_POLICY >
using mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::reservation_policy = CAPACITY_POLICY

Member Enumeration Documentation

◆ anonymous enum

template<class ALLOCATOR , typename CAPACITY_POLICY >
anonymous enum : size_t
Enumerator
max_length 
max_capacity 
extra_inplace_storage 
pettiness_threshold 

Constructor & Destructor Documentation

◆ buffer() [1/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( )
defaultnoexcept

◆ buffer() [2/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const allocator_type allocator)
inlinenoexcept

◆ buffer() [3/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const struct slice src,
bool  make_reference,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [4/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const buffer< ALLOCATOR, CAPACITY_POLICY > &  src,
bool  make_reference,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [5/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const void *  ptr,
size_t  bytes,
bool  make_reference,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [6/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<class CHAR , class T , class A >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const ::std::basic_string< CHAR, T, A > &  )
delete

◆ buffer() [7/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<class CHAR , class T , class A >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const ::std::basic_string< CHAR, T, A > &&  )
delete

◆ buffer() [8/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const char *  c_str,
bool  make_reference,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [9/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<class CHAR , class T >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const ::std::basic_string_view< CHAR, T > &  view,
bool  make_reference,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [10/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const struct slice src,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [11/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const buffer< ALLOCATOR, CAPACITY_POLICY > &  src,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [12/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const void *  ptr,
size_t  bytes,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [13/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<class CHAR , class T , class A >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const ::std::basic_string< CHAR, T, A > &  str,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [14/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const char *  c_str,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [15/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<class CHAR , class T >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const ::std::basic_string_view< CHAR, T > &  view,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [16/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( size_t  head_room,
size_t  tail_room,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [17/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( size_t  capacity,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [18/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( size_t  head_room,
const struct slice src,
size_t  tail_room,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [19/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( size_t  head_room,
const buffer< ALLOCATOR, CAPACITY_POLICY > &  src,
size_t  tail_room,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [20/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const ::mdbx::txn txn,
const struct slice src,
const allocator_type allocator = allocator_type() 
)
inline

◆ buffer() [21/21]

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( buffer< ALLOCATOR, CAPACITY_POLICY > &&  src)
inlinenoexcept

Member Function Documentation

◆ add_header() [1/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::add_header ( const struct slice chunk)
inline

◆ add_header() [2/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::add_header ( const void *  src,
size_t  bytes 
)
inline

◆ append() [1/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::append ( const struct slice chunk)
inline

◆ append() [2/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::append ( const void *  src,
size_t  bytes 
)
inline

◆ append_base58()

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::append_base58 ( const struct slice data,
unsigned  wrap_width = 0 
)
inline

◆ append_base64()

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::append_base64 ( const struct slice data,
unsigned  wrap_width = 0 
)
inline

◆ append_decoded_base58()

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::append_decoded_base58 ( const struct slice data,
bool  ignore_spaces = false 
)
inline

◆ append_decoded_base64()

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::append_decoded_base64 ( const struct slice data,
bool  ignore_spaces = false 
)
inline

◆ append_decoded_hex()

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::append_decoded_hex ( const struct slice data,
bool  ignore_spaces = false 
)
inline

◆ append_hex()

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::append_hex ( const struct slice data,
bool  uppercase = false,
unsigned  wrap_width = 0 
)
inline

◆ append_producer() [1/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<MDBX_CXX20_CONCEPT(ImmutableByteProducer, PRODUCER) >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::append_producer ( const PRODUCER &  producer)
inline

◆ append_producer() [2/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<MDBX_CXX20_CONCEPT(MutableByteProducer, PRODUCER) >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::append_producer ( PRODUCER &  producer)
inline

◆ as_string()

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<class CHAR = char, class T = ::std::char_traits<CHAR>, class A = legacy_allocator>
::std::basic_string<CHAR, T, A> mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::as_string ( const A &  allocator = A()) const
inline

◆ assign() [1/9]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::assign ( ::MDBX_val &&  src,
bool  make_reference = false 
)
inline

◆ assign() [2/9]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::assign ( const ::MDBX_val src,
bool  make_reference = false 
)
inline

◆ assign() [3/9]

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<class CHAR , class T , class A >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::assign ( const ::std::basic_string< CHAR, T, A > &  str,
bool  make_reference = false 
)
inline

◆ assign() [4/9]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::assign ( const buffer< ALLOCATOR, CAPACITY_POLICY > &  src,
bool  make_reference = false 
)
inline

◆ assign() [5/9]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::assign ( const char *  c_str,
bool  make_reference = false 
)
inline

◆ assign() [6/9]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::assign ( const struct slice src,
bool  make_reference = false 
)
inline

◆ assign() [7/9]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::assign ( const void *  begin,
const void *  end,
bool  make_reference = false 
)
inline

◆ assign() [8/9]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::assign ( const void *  ptr,
size_t  bytes,
bool  make_reference = false 
)
inline

◆ assign() [9/9]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::assign ( struct slice &&  src,
bool  make_reference = false 
)
inline

◆ assign_freestanding()

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::assign_freestanding ( const void *  ptr,
size_t  bytes 
)
inline

◆ assign_reference()

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::assign_reference ( const void *  ptr,
size_t  bytes 
)
inline

◆ at() [1/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
byte& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::at ( size_t  n)
inline

Accesses the specified byte of data chunk with bounds checking.

Exceptions
std::out_of_rangeif n >= size()

◆ at() [2/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
byte mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::at ( size_t  n) const
inline

Accesses the specified byte of data chunk with bounds checking.

Exceptions
std::out_of_rangeif n >= size()

◆ byte_ptr() [1/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
const byte* mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::byte_ptr ( ) const
inlinenoexcept

Returns casted to const pointer to byte an address of data.

◆ byte_ptr() [2/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
byte* mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::byte_ptr ( )
inlinenoexcept

Returns casted to pointer to byte an address of data.

Precondition
REQUIRES: The buffer should store data chunk, but not referenced to an external one.

◆ capacity()

template<class ALLOCATOR , typename CAPACITY_POLICY >
size_t mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::capacity ( ) const
inlinenoexcept

Returns the number of bytes that can be held in currently allocated storage.

◆ char_ptr() [1/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
const char* mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::char_ptr ( ) const
inlinenoexcept

Returns casted to const pointer to char an address of data.

◆ char_ptr() [2/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
char* mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::char_ptr ( )
inlinenoexcept

Returns casted to pointer to char an address of data.

Precondition
REQUIRES: The buffer should store data chunk, but not referenced to an external one.

◆ clear()

template<class ALLOCATOR , typename CAPACITY_POLICY >
void mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::clear ( )
inlinenoexcept

Clears the contents and storage.

◆ clone()

template<class ALLOCATOR , typename CAPACITY_POLICY >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::clone ( const buffer< ALLOCATOR, CAPACITY_POLICY > &  src,
const allocator_type allocator = allocator_type() 
)
inlinestatic

◆ data() [1/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
const void* mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::data ( ) const
inlinenoexcept

Return a const pointer to the beginning of the referenced data.

◆ data() [2/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
void* mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::data ( )
inlinenoexcept

Return a pointer to the beginning of the referenced data.

Precondition
REQUIRES: The buffer should store data chunk, but not referenced to an external one.

◆ empty()

template<class ALLOCATOR , typename CAPACITY_POLICY >
bool mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::empty ( ) const
inlinenoexcept

Checks whether the string is empty.

◆ end() [1/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
const void* mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::end ( ) const
inlinenoexcept

Return a const pointer to the end of the referenced data.

◆ end() [2/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
void* mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::end ( )
inlinenoexcept

Return a pointer to the end of the referenced data.

Precondition
REQUIRES: The buffer should store data chunk, but not referenced to an external one.

◆ end_byte_ptr() [1/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
const byte* mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::end_byte_ptr ( ) const
inlinenoexcept

Returns casted to const pointer to byte an end of data.

◆ end_byte_ptr() [2/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
byte* mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::end_byte_ptr ( )
inlinenoexcept

Returns casted to pointer to byte an end of data.

Precondition
REQUIRES: The buffer should store data chunk, but not referenced to an external one.

◆ end_char_ptr() [1/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
const char* mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::end_char_ptr ( ) const
inlinenoexcept

Returns casted to const pointer to char an end of data.

◆ end_char_ptr() [2/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
char* mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::end_char_ptr ( )
inlinenoexcept

Returns casted to pointer to char an end of data.

Precondition
REQUIRES: The buffer should store data chunk, but not referenced to an external one.

◆ ends_with()

template<class ALLOCATOR , typename CAPACITY_POLICY >
bool mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::ends_with ( const struct slice suffix) const
inlinenoexcept

Checks if the data ends with the given suffix.

◆ get_allocator()

template<class ALLOCATOR , typename CAPACITY_POLICY >
allocator_type mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::get_allocator ( ) const
inline

Returns the associated allocator.

◆ hash_value()

template<class ALLOCATOR , typename CAPACITY_POLICY >
size_t mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::hash_value ( ) const
inlinenoexcept

Returns the hash value of the data.

Attention
Function implementation and returned hash values may changed version to version, and in future the t1ha3 will be used here. Therefore values obtained from this function shouldn't be persisted anywhere.

◆ head()

template<class ALLOCATOR , typename CAPACITY_POLICY >
struct slice mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::head ( size_t  n) const
inlinenoexcept

Returns the first "n" bytes of the data chunk.

Precondition
REQUIRES: n <= size()

◆ headroom()

template<class ALLOCATOR , typename CAPACITY_POLICY >
size_t mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::headroom ( ) const
inlinenoexcept

Returns the number of bytes that available in currently allocated storage ahead the currently beginning of data.

◆ is_freestanding()

template<class ALLOCATOR , typename CAPACITY_POLICY >
bool mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::is_freestanding ( ) const
inlinenoexcept

Checks whether data chunk stored inside the buffer, otherwise buffer just refers to data located outside the buffer.

◆ is_null()

template<class ALLOCATOR , typename CAPACITY_POLICY >
bool mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::is_null ( ) const
inlinenoexcept

Checks whether the data pointer of the buffer is nullptr.

◆ is_reference()

template<class ALLOCATOR , typename CAPACITY_POLICY >
bool mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::is_reference ( ) const
inlinenoexcept

Checks whether the buffer just refers to data located outside the buffer, rather than stores it.

◆ key_from() [1/13]

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<class CHAR , class T , class A >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::key_from ( const ::std::basic_string< CHAR, T, A > &  src,
bool  make_reference = false 
)
inlinestatic

◆ key_from() [2/13]

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<class CHAR , class T >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::key_from ( const ::std::basic_string_view< CHAR, T > &  src,
bool  make_reference = false 
)
inlinestatic

◆ key_from() [3/13]

template<class ALLOCATOR , typename CAPACITY_POLICY >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::key_from ( const char *  src,
bool  make_reference = false 
)
inlinestatic

◆ key_from() [4/13]

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<size_t SIZE>
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::key_from ( const char(&)  text[SIZE],
bool  make_reference = true 
)
inlinestatic

◆ key_from() [5/13]

template<class ALLOCATOR , typename CAPACITY_POLICY >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::key_from ( const double *  ieee754_64bit)
inlinestatic

◆ key_from() [6/13]

template<class ALLOCATOR , typename CAPACITY_POLICY >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::key_from ( const double  ieee754_64bit)
inlinestatic

◆ key_from() [7/13]

template<class ALLOCATOR , typename CAPACITY_POLICY >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::key_from ( const float *  ieee754_32bit)
inlinestatic

◆ key_from() [8/13]

template<class ALLOCATOR , typename CAPACITY_POLICY >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::key_from ( const float  ieee754_32bit)
inlinestatic

◆ key_from() [9/13]

template<class ALLOCATOR , typename CAPACITY_POLICY >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::key_from ( const int32_t  signed_int32)
inlinestatic

◆ key_from() [10/13]

template<class ALLOCATOR , typename CAPACITY_POLICY >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::key_from ( const int64_t  signed_int64)
inlinestatic

◆ key_from() [11/13]

template<class ALLOCATOR , typename CAPACITY_POLICY >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::key_from ( const silo &&  src)
inlinestaticnoexcept

◆ key_from() [12/13]

template<class ALLOCATOR , typename CAPACITY_POLICY >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::key_from ( const uint32_t  unsigned_int32)
inlinestatic

◆ key_from() [13/13]

template<class ALLOCATOR , typename CAPACITY_POLICY >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::key_from ( const uint64_t  unsigned_int64)
inlinestatic

◆ key_from_jsonInteger()

template<class ALLOCATOR , typename CAPACITY_POLICY >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::key_from_jsonInteger ( const int64_t  json_integer)
inlinestatic

◆ length()

template<class ALLOCATOR , typename CAPACITY_POLICY >
size_t mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::length ( ) const
inlinenoexcept

Returns the number of bytes.

◆ make_freestanding()

template<class ALLOCATOR , typename CAPACITY_POLICY >
void mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::make_freestanding ( )
inline

Makes buffer owning the data.

If buffer refers to an external data, then makes it the owner of clone by allocating storage and copying the data.

◆ middle()

template<class ALLOCATOR , typename CAPACITY_POLICY >
struct slice mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::middle ( size_t  from,
size_t  n 
) const
inlinenoexcept

Returns the middle "n" bytes of the data chunk.

Precondition
REQUIRES: from + n <= size()

◆ operator const struct slice &()

template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::operator const struct slice & ( ) const
inlinenoexcept

◆ operator::std::basic_string()

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<class CHAR , class T , class A >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::operator::std::basic_string ( ) const
inlineexplicit

◆ operator::std::basic_string_view()

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<class CHAR , class T >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::operator::std::basic_string_view ( ) const
inlinenoexcept

Return a string_view that references the data of this buffer.

◆ operator=() [1/5]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::operator= ( buffer< ALLOCATOR, CAPACITY_POLICY > &&  src)
inlinenoexcept

◆ operator=() [2/5]

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<class CHAR , class T >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::operator= ( const ::std::basic_string_view< CHAR, T > &  view)
inlinenoexcept

◆ operator=() [3/5]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::operator= ( const buffer< ALLOCATOR, CAPACITY_POLICY > &  src)
inline

◆ operator=() [4/5]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::operator= ( const struct slice src)
inline

◆ operator=() [5/5]

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::operator= ( struct slice &&  src)
inline

◆ operator[]() [1/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
byte mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::operator[] ( size_t  n) const
inlinenoexcept

Accesses the specified byte of data chunk.

Precondition
REQUIRES: n < size()

◆ operator[]() [2/2]

template<class ALLOCATOR , typename CAPACITY_POLICY >
byte& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::operator[] ( size_t  n)
inlinenoexcept

Accesses the specified byte of data chunk.

Precondition
REQUIRES: n < size()

◆ remove_prefix()

template<class ALLOCATOR , typename CAPACITY_POLICY >
void mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::remove_prefix ( size_t  n)
inlinenoexcept

Drops the first "n" bytes from the data chunk.

Precondition
REQUIRES: n <= size()

◆ remove_suffix()

template<class ALLOCATOR , typename CAPACITY_POLICY >
void mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::remove_suffix ( size_t  n)
inlinenoexcept

Drops the last "n" bytes from the data chunk.

Precondition
REQUIRES: n <= size()

◆ reserve()

template<class ALLOCATOR , typename CAPACITY_POLICY >
void mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::reserve ( size_t  wanna_headroom,
size_t  wanna_tailroom 
)
inline

Reserves storage space.

◆ reserve_headroom()

template<class ALLOCATOR , typename CAPACITY_POLICY >
void mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::reserve_headroom ( size_t  wanna_headroom)
inline

Reserves space before the payload.

◆ reserve_tailroom()

template<class ALLOCATOR , typename CAPACITY_POLICY >
void mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::reserve_tailroom ( size_t  wanna_tailroom)
inline

Reserves space after the payload.

◆ safe_head()

template<class ALLOCATOR , typename CAPACITY_POLICY >
struct slice mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::safe_head ( size_t  n) const
inline

Returns the first "n" bytes of the data chunk.

Exceptions
std::out_of_rangeif n >= size()

◆ safe_middle()

template<class ALLOCATOR , typename CAPACITY_POLICY >
struct slice mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::safe_middle ( size_t  from,
size_t  n 
) const
inline

Returns the middle "n" bytes of the data chunk.

Exceptions
std::out_of_rangeif from + n >= size()

◆ safe_remove_prefix()

template<class ALLOCATOR , typename CAPACITY_POLICY >
void mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::safe_remove_prefix ( size_t  n)
inline

Drops the first "n" bytes from the data chunk.

Exceptions
std::out_of_rangeif n > size()

◆ safe_remove_suffix()

template<class ALLOCATOR , typename CAPACITY_POLICY >
void mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::safe_remove_suffix ( size_t  n)
inline

Drops the last "n" bytes from the data chunk.

Exceptions
std::out_of_rangeif n > size()

◆ safe_tail()

template<class ALLOCATOR , typename CAPACITY_POLICY >
struct slice mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::safe_tail ( size_t  n) const
inline

Returns the last "n" bytes of the data chunk.

Exceptions
std::out_of_rangeif n >= size()

◆ set_end()

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::set_end ( const void *  ptr)
inline

Sets the length by specifying the end of the data.

◆ set_length()

template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::set_length ( size_t  bytes)
inline

Set length of data.

◆ shrink_to_fit()

template<class ALLOCATOR , typename CAPACITY_POLICY >
void mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::shrink_to_fit ( )
inline

Reduces memory usage by freeing unused storage space.

◆ size()

template<class ALLOCATOR , typename CAPACITY_POLICY >
size_t mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::size ( ) const
inlinenoexcept

Returns the number of bytes.

◆ slice()

template<class ALLOCATOR , typename CAPACITY_POLICY >
const struct slice& mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::slice ( ) const
inlinenoexcept

◆ starts_with()

template<class ALLOCATOR , typename CAPACITY_POLICY >
bool mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::starts_with ( const struct slice prefix) const
inlinenoexcept

Checks if the data starts with the given prefix.

◆ string_view()

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<class CHAR = char, class T = ::std::char_traits<CHAR>>
::std::basic_string_view<CHAR, T> mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::string_view ( ) const
inlinenoexcept

Return a string_view that references the data of this buffer.

◆ swap()

template<class ALLOCATOR , typename CAPACITY_POLICY >
void mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::swap ( buffer< ALLOCATOR, CAPACITY_POLICY > &  other)
inlinenoexcept

◆ tail()

template<class ALLOCATOR , typename CAPACITY_POLICY >
struct slice mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::tail ( size_t  n) const
inlinenoexcept

Returns the last "n" bytes of the data chunk.

Precondition
REQUIRES: n <= size()

◆ tailroom()

template<class ALLOCATOR , typename CAPACITY_POLICY >
size_t mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::tailroom ( ) const
inlinenoexcept

Returns the number of bytes that available in currently allocated storage after the currently data end.

◆ wrap()

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<typename POD >
static buffer mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::wrap ( const POD &  pod,
bool  make_reference = false,
const allocator_type allocator = allocator_type() 
)
inlinestatic

Friends And Related Function Documentation

◆ txn

template<class ALLOCATOR , typename CAPACITY_POLICY >
friend class txn
friend

◆ mdbx::map_handle

struct mdbx::map_handle

A handle for an individual database (key-value spaces) in the environment.

See also
txn::open_map()
txn::create_map()
txn::clear_map()
txn::drop_map()
txn::get_handle_info()
txn::get_map_stat()
env::close_map()
cursor::map()

Public Types

using flags = ::MDBX_db_flags_t
 
using state = ::MDBX_dbi_state_t
 

Public Member Functions

 map_handle () noexcept
 
 map_handle (MDBX_dbi dbi) noexcept
 
 map_handle (const map_handle &) noexcept=default
 
map_handleoperator= (const map_handle &) noexcept=default
 

Public Attributes

MDBX_dbi dbi {0}
 

Member Typedef Documentation

◆ flags

◆ state

Constructor & Destructor Documentation

◆ map_handle() [1/3]

mdbx::map_handle::map_handle ( )
inlinenoexcept

◆ map_handle() [2/3]

mdbx::map_handle::map_handle ( MDBX_dbi  dbi)
inlinenoexcept

◆ map_handle() [3/3]

mdbx::map_handle::map_handle ( const map_handle )
defaultnoexcept

Member Function Documentation

◆ operator=()

map_handle& mdbx::map_handle::operator= ( const map_handle )
defaultnoexcept

Member Data Documentation

◆ dbi

MDBX_dbi mdbx::map_handle::dbi {0}

◆ mdbx::env

class mdbx::env

Unmanaged database environment.

Like other unmanaged classes, env allows copying and assignment for instances, but does not destroys the represented underlying object from the own class destructor.

An environment supports multiple key-value sub-databases (aka key-value spaces or tables), all residing in the same shared-memory map.

Inherited by mdbx::env_managed.

Public Types

enum  mode { readonly , write_file_io , write_mapped_io }
 Operation mode. More...
 
enum  durability { robust_synchronous , half_synchronous_weak_last , lazy_weak_tail , whole_fragile }
 Durability level. More...
 
enum  remove_mode { just_remove = MDBX_ENV_JUST_DELETE , ensure_unused = MDBX_ENV_ENSURE_UNUSED , wait_for_unused = MDBX_ENV_WAIT_FOR_UNUSED }
 Deletion modes for remove(). More...
 
using stat = ::MDBX_stat
 Statistics for a database in the MDBX environment. More...
 
using info = ::MDBX_envinfo
 Information about the environment. More...
 

Public Member Functions

 env () noexcept=default
 
 env (const env &) noexcept=default
 
envoperator= (env &&other) noexcept
 
 env (env &&other) noexcept
 
 ~env () noexcept
 
 operator const MDBX_env * () const
 
 operator MDBX_env * ()
 
env::operate_parameters get_operation_parameters () const
 Returns current operation parameters. More...
 
env::mode get_mode () const
 Returns current operation mode. More...
 
env::durability get_durability () const
 Returns current durability mode. More...
 
env::reclaiming_options get_reclaiming () const
 Returns current reclaiming options. More...
 
env::operate_options get_options () const
 Returns current operate options. More...
 
bool is_pristine () const
 Returns true for a freshly created database, but false if at least one transaction was committed. More...
 
bool is_empty () const
 Checks whether the database is empty. More...
 
size_t dbsize_min () const
 Returns the minimal database size in bytes for the environment. More...
 
size_t dbsize_max () const
 Returns the maximal database size in bytes for the environment. More...
 
size_t key_min (key_mode mode) const noexcept
 Returns the minimal key size in bytes for specified keys mode. More...
 
size_t key_max (key_mode mode) const
 Returns the maximal key size in bytes for specified keys mode. More...
 
size_t value_min (value_mode mode) const noexcept
 Returns the minimal value size in bytes for specified values mode. More...
 
size_t value_max (value_mode mode) const
 Returns the maximal value size in bytes for specified values mode. More...
 
size_t transaction_size_max () const
 Returns the maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes. More...
 
envcopy (const MDBX_STD_FILESYSTEM_PATH &destination, bool compactify, bool force_dynamic_size=false)
 Make a copy (backup) of an existing environment to the specified path. More...
 
envcopy (const ::std::wstring &destination, bool compactify, bool force_dynamic_size=false)
 
envcopy (const wchar_t *destination, bool compactify, bool force_dynamic_size=false)
 
envcopy (const ::std::string &destination, bool compactify, bool force_dynamic_size=false)
 
envcopy (const char *destination, bool compactify, bool force_dynamic_size=false)
 
envcopy (filehandle fd, bool compactify, bool force_dynamic_size=false)
 Copy an environment to the specified file descriptor. More...
 
stat get_stat () const
 Returns snapshot statistics about the MDBX environment. More...
 
size_t get_pagesize () const
 Returns pagesize of this MDBX environment. More...
 
info get_info () const
 Return snapshot information about the MDBX environment. More...
 
stat get_stat (const txn &) const
 Return statistics about the MDBX environment accordingly to the specified transaction. More...
 
info get_info (const txn &) const
 Return information about the MDBX environment accordingly to the specified transaction. More...
 
filehandle get_filehandle () const
 Returns the file descriptor for the DXB file of MDBX environment. More...
 
path get_path () const
 Return the path that was used for opening the environment. More...
 
MDBX_env_flags_t get_flags () const
 Returns environment flags. More...
 
unsigned max_readers () const
 Returns the maximum number of threads/reader slots for the environment. More...
 
unsigned max_maps () const
 Returns the maximum number of named databases for the environment. More...
 
void * get_context () const noexcept
 Returns the application context associated with the environment. More...
 
envset_context (void *)
 Sets the application context associated with the environment. More...
 
envset_sync_threshold (size_t bytes)
 Sets threshold to force flush the data buffers to disk, for non-sync durability modes. More...
 
envset_sync_period (unsigned seconds_16dot16)
 Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes. More...
 
envset_sync_period (double seconds)
 Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes. More...
 
envalter_flags (MDBX_env_flags_t flags, bool on_off)
 Alter environment flags. More...
 
envset_geometry (const geometry &size)
 Set all size-related parameters of environment. More...
 
bool sync_to_disk (bool force=true, bool nonblock=false)
 Flush the environment data buffers. More...
 
bool poll_sync_to_disk ()
 Performs non-blocking polling of sync-to-disk thresholds. More...
 
void close_map (const map_handle &)
 Close a key-value map (aka sub-database) handle. Normally unnecessary. More...
 
template<typename VISITOR >
int enumerate_readers (VISITOR &visitor)
 Enumerate readers. More...
 
unsigned check_readers ()
 Checks for stale readers in the lock table and return number of cleared slots. More...
 
envset_HandleSlowReaders (MDBX_hsr_func *)
 Sets a Handle-Slow-Readers callback to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled. More...
 
MDBX_hsr_funcget_HandleSlowReaders () const noexcept
 Returns the current Handle-Slow-Readers callback used to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled. More...
 
txn_managed start_read () const
 Starts read (read-only) transaction. More...
 
txn_managed prepare_read () const
 Creates but not start read transaction. More...
 
txn_managed start_write (bool dont_wait=false)
 Starts write (read-write) transaction. More...
 
txn_managed try_start_write ()
 Tries to start write (read-write) transaction without blocking. More...
 

Static Public Member Functions

static size_t default_pagesize () noexcept
 Returns default page size for current system/platform. More...
 
static bool remove (const MDBX_STD_FILESYSTEM_PATH &pathname, const remove_mode mode=just_remove)
 Removes the environment's files in a proper and multiprocess-safe way. More...
 
static bool remove (const ::std::wstring &pathname, const remove_mode mode=just_remove)
 
static bool remove (const wchar_t *pathname, const remove_mode mode=just_remove)
 
static bool remove (const ::std::string &pathname, const remove_mode mode=just_remove)
 
static bool remove (const char *pathname, const remove_mode mode=just_remove)
 

Protected Member Functions

 env (MDBX_env *ptr) noexcept
 

Protected Attributes

MDBX_envhandle_ {nullptr}
 

Friends

class txn
 
bool operator== (const env &a, const env &b) noexcept
 
bool operator!= (const env &a, const env &b) noexcept
 

Member Typedef Documentation

◆ info

Information about the environment.

◆ stat

Statistics for a database in the MDBX environment.

Member Enumeration Documentation

◆ durability

Durability level.

Enumerator
robust_synchronous 

Default robust and durable sync mode.

Metadata is written and flushed to disk after a data is written and flushed, which guarantees the integrity of the database in the event of a crash at any time.

Attention
Please do not use other modes until you have studied all the details and are sure. Otherwise, you may lose your users' data, as happens in Miranda NG messenger.
half_synchronous_weak_last 

Don't sync the meta-page after commit.

Flush system buffers to disk only once per transaction commit, omit the metadata flush. Defer that until the system flushes files to disk, or next non-MDBX_RDONLY commit or mdbx_env_sync(). Depending on the platform and hardware, with MDBX_NOMETASYNC you may get a doubling of write performance.

This trade-off maintains database integrity, but a system crash may undo the last committed transaction. I.e. it preserves the ACI (atomicity, consistency, isolation) but not D (durability) database property.

MDBX_NOMETASYNC flag may be changed at any time using mdbx_env_set_flags() or by passing to mdbx_txn_begin() for particular write transaction.

See also
SYNC MODES
lazy_weak_tail 

Don't sync anything but keep previous steady commits.

Like MDBX_UTTERLY_NOSYNC the MDBX_SAFE_NOSYNC flag disable similarly flush system buffers to disk when committing a transaction. But there is a huge difference in how are recycled the MVCC snapshots corresponding to previous "steady" transactions (see below).

With MDBX_WRITEMAP the MDBX_SAFE_NOSYNC instructs MDBX to use asynchronous mmap-flushes to disk. Asynchronous mmap-flushes means that actually all writes will scheduled and performed by operation system on it own manner, i.e. unordered. MDBX itself just notify operating system that it would be nice to write data to disk, but no more.

Depending on the platform and hardware, with MDBX_SAFE_NOSYNC you may get a multiple increase of write performance, even 10 times or more.

In contrast to MDBX_UTTERLY_NOSYNC mode, with MDBX_SAFE_NOSYNC flag MDBX will keeps untouched pages within B-tree of the last transaction "steady" which was synced to disk completely. This has big implications for both data durability and (unfortunately) performance:

  • a system crash can't corrupt the database, but you will lose the last transactions; because MDBX will rollback to last steady commit since it kept explicitly.
  • the last steady transaction makes an effect similar to "long-lived" read transaction (see above in the Restrictions & Caveats section) since prevents reuse of pages freed by newer write transactions, thus the any data changes will be placed in newly allocated pages.
  • to avoid rapid database growth, the system will sync data and issue a steady commit-point to resume reuse pages, each time there is insufficient space and before increasing the size of the file on disk.

In other words, with MDBX_SAFE_NOSYNC flag MDBX insures you from the whole database corruption, at the cost increasing database size and/or number of disk IOPs. So, MDBX_SAFE_NOSYNC flag could be used with mdbx_env_sync() as alternatively for batch committing or nested transaction (in some cases). As well, auto-sync feature exposed by mdbx_env_set_syncbytes() and mdbx_env_set_syncperiod() functions could be very useful with MDBX_SAFE_NOSYNC flag.

The number and volume of of disk IOPs with MDBX_SAFE_NOSYNC flag will exactly the as without any no-sync flags. However, you should expect a larger process's work set and significantly worse a locality of reference, due to the more intensive allocation of previously unused pages and increase the size of the database.

MDBX_SAFE_NOSYNC flag may be changed at any time using mdbx_env_set_flags() or by passing to mdbx_txn_begin() for particular write transaction.

whole_fragile 

Don't sync anything and wipe previous steady commits.

Don't flush system buffers to disk when committing a transaction. This optimization means a system crash can corrupt the database, if buffers are not yet flushed to disk. Depending on the platform and hardware, with MDBX_UTTERLY_NOSYNC you may get a multiple increase of write performance, even 100 times or more.

If the filesystem preserves write order (which is rare and never provided unless explicitly noted) and the MDBX_WRITEMAP and MDBX_LIFORECLAIM flags are not used, then a system crash can't corrupt the database, but you can lose the last transactions, if at least one buffer is not yet flushed to disk. The risk is governed by how often the system flushes dirty buffers to disk and how often mdbx_env_sync() is called. So, transactions exhibit ACI (atomicity, consistency, isolation) properties and only lose D (durability). I.e. database integrity is maintained, but a system crash may undo the final transactions.

Otherwise, if the filesystem not preserves write order (which is typically) or MDBX_WRITEMAP or MDBX_LIFORECLAIM flags are used, you should expect the corrupted database after a system crash.

So, most important thing about MDBX_UTTERLY_NOSYNC:

  • a system crash immediately after commit the write transaction high likely lead to database corruption.
  • successful completion of mdbx_env_sync(force = true) after one or more committed transactions guarantees consistency and durability.
  • BUT by committing two or more transactions you back database into a weak state, in which a system crash may lead to database corruption! In case single transaction after mdbx_env_sync, you may lose transaction itself, but not a whole database.

Nevertheless, MDBX_UTTERLY_NOSYNC provides "weak" durability in case of an application crash (but no durability on system failure), and therefore may be very useful in scenarios where data durability is not required over a system failure (e.g for short-lived data), or if you can take such risk.

MDBX_UTTERLY_NOSYNC flag may be changed at any time using mdbx_env_set_flags(), but don't has effect if passed to mdbx_txn_begin() for particular write transaction.

See also
SYNC MODES

◆ mode

Operation mode.

Enumerator
readonly 

Read only mode.

Open the environment in read-only mode. No write operations will be allowed. MDBX will still modify the lock file - except on read-only filesystems, where MDBX does not use locks.

  • with MDBX_RDONLY = open environment in read-only mode. MDBX supports pure read-only mode (i.e. without opening LCK-file) only when environment directory and/or both files are not writable (and the LCK-file may be missing). In such case allowing file(s) to be placed on a network read-only share.
  • without MDBX_RDONLY = open environment in read-write mode.

This flag affects only at environment opening but can't be changed after.

write_file_io 
write_mapped_io 

Map data into memory with write permission.

Use a writeable memory map unless MDBX_RDONLY is set. This uses fewer mallocs and requires much less work for tracking database pages, but loses protection from application bugs like wild pointer writes and other bad updates into the database. This may be slightly faster for DBs that fit entirely in RAM, but is slower for DBs larger than RAM. Also adds the possibility for stray application writes thru pointers to silently corrupt the database.

  • with MDBX_WRITEMAP = all data will be mapped into memory in the read-write mode. This offers a significant performance benefit, since the data will be modified directly in mapped memory and then flushed to disk by single system call, without any memory management nor copying.
  • without MDBX_WRITEMAP = data will be mapped into memory in the read-only mode. This requires stocking all modified database pages in memory and then writing them to disk through file operations.
Warning
On the other hand, MDBX_WRITEMAP adds the possibility for stray application writes thru pointers to silently corrupt the database.
Note
The MDBX_WRITEMAP mode is incompatible with nested transactions, since this is unreasonable. I.e. nested transactions requires mallocation of database pages and more work for tracking ones, which neuters a performance boost caused by the MDBX_WRITEMAP mode.

This flag affects only at environment opening but can't be changed after.

◆ remove_mode

Deletion modes for remove().

Enumerator
just_remove 

Just delete the environment's files and directory if any.

Note
On POSIX systems, processes already working with the database will continue to work without interference until it close the environment.
On Windows, the behavior of just_remove is different because the system does not support deleting files that are currently memory mapped.
ensure_unused 

Make sure that the environment is not being used by other processes, or return an error otherwise.

wait_for_unused 

Wait until other processes closes the environment before deletion.

Constructor & Destructor Documentation

◆ env() [1/2]

mdbx::env::env ( )
defaultnoexcept

◆ env() [2/2]

mdbx::env::env ( const env )
defaultnoexcept

Member Function Documentation

◆ copy() [1/6]

env& mdbx::env::copy ( const ::std::string &  destination,
bool  compactify,
bool  force_dynamic_size = false 
)

◆ copy() [2/6]

env& mdbx::env::copy ( const ::std::wstring &  destination,
bool  compactify,
bool  force_dynamic_size = false 
)

◆ copy() [3/6]

env& mdbx::env::copy ( const char *  destination,
bool  compactify,
bool  force_dynamic_size = false 
)

◆ copy() [4/6]

env& mdbx::env::copy ( const MDBX_STD_FILESYSTEM_PATH destination,
bool  compactify,
bool  force_dynamic_size = false 
)

Make a copy (backup) of an existing environment to the specified path.

◆ copy() [5/6]

env& mdbx::env::copy ( const wchar_t *  destination,
bool  compactify,
bool  force_dynamic_size = false 
)

◆ copy() [6/6]

env& mdbx::env::copy ( filehandle  fd,
bool  compactify,
bool  force_dynamic_size = false 
)

Copy an environment to the specified file descriptor.

◆ dbsize_max()

size_t mdbx::env::dbsize_max ( ) const
inline

Returns the maximal database size in bytes for the environment.

◆ dbsize_min()

size_t mdbx::env::dbsize_min ( ) const
inline

Returns the minimal database size in bytes for the environment.

◆ default_pagesize()

static size_t mdbx::env::default_pagesize ( )
inlinestaticnoexcept

Returns default page size for current system/platform.

◆ get_pagesize()

size_t mdbx::env::get_pagesize ( ) const
inline

Returns pagesize of this MDBX environment.

◆ get_path()

path mdbx::env::get_path ( ) const

Return the path that was used for opening the environment.

◆ is_empty()

bool mdbx::env::is_empty ( ) const

Checks whether the database is empty.

◆ is_pristine()

bool mdbx::env::is_pristine ( ) const

Returns true for a freshly created database, but false if at least one transaction was committed.

◆ key_max()

size_t mdbx::env::key_max ( key_mode  mode) const
inline

Returns the maximal key size in bytes for specified keys mode.

◆ key_min()

size_t mdbx::env::key_min ( key_mode  mode) const
inlinenoexcept

Returns the minimal key size in bytes for specified keys mode.

◆ poll_sync_to_disk()

bool mdbx::env::poll_sync_to_disk ( )
inline

Performs non-blocking polling of sync-to-disk thresholds.

Returns
True if sync done or no data to sync, or false if the environment is busy by other thread or none of the thresholds are reached.

◆ remove() [1/5]

static bool mdbx::env::remove ( const ::std::string &  pathname,
const remove_mode  mode = just_remove 
)
static

◆ remove() [2/5]

static bool mdbx::env::remove ( const ::std::wstring &  pathname,
const remove_mode  mode = just_remove 
)
static

◆ remove() [3/5]

static bool mdbx::env::remove ( const char *  pathname,
const remove_mode  mode = just_remove 
)
static

◆ remove() [4/5]

static bool mdbx::env::remove ( const MDBX_STD_FILESYSTEM_PATH pathname,
const remove_mode  mode = just_remove 
)
static

Removes the environment's files in a proper and multiprocess-safe way.

◆ remove() [5/5]

static bool mdbx::env::remove ( const wchar_t *  pathname,
const remove_mode  mode = just_remove 
)
static

◆ transaction_size_max()

size_t mdbx::env::transaction_size_max ( ) const
inline

Returns the maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes.

◆ value_max()

size_t mdbx::env::value_max ( value_mode  mode) const
inline

Returns the maximal value size in bytes for specified values mode.

◆ value_min()

size_t mdbx::env::value_min ( value_mode  mode) const
inlinenoexcept

Returns the minimal value size in bytes for specified values mode.

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const env a,
const env b 
)
friend

◆ operator==

bool operator== ( const env a,
const env b 
)
friend

◆ txn

friend class txn
friend

Member Data Documentation

◆ handle_

MDBX_env* mdbx::env::handle_ {nullptr}
protected

◆ mdbx::env_managed

class mdbx::env_managed

Managed database environment.

As other managed classes, env_managed destroys the represented underlying object from the own class destructor, but disallows copying and assignment for instances.

An environment supports multiple key-value databases (aka key-value spaces or tables), all residing in the same shared-memory map.

Inherits mdbx::env.

Public Member Functions

 env_managed () noexcept=default
 
 env_managed (const MDBX_STD_FILESYSTEM_PATH &pathname, const operate_parameters &, bool accede=true)
 Open existing database. More...
 
 env_managed (const ::std::wstring &pathname, const operate_parameters &, bool accede=true)
 
 env_managed (const wchar_t *pathname, const operate_parameters &, bool accede=true)
 
 env_managed (const ::std::string &pathname, const operate_parameters &, bool accede=true)
 
 env_managed (const char *pathname, const operate_parameters &, bool accede=true)
 
 env_managed (const MDBX_STD_FILESYSTEM_PATH &pathname, const create_parameters &, const operate_parameters &, bool accede=true)
 Create new or open existing database. More...
 
 env_managed (const ::std::wstring &pathname, const create_parameters &, const operate_parameters &, bool accede=true)
 
 env_managed (const wchar_t *pathname, const create_parameters &, const operate_parameters &, bool accede=true)
 
 env_managed (const ::std::string &pathname, const create_parameters &, const operate_parameters &, bool accede=true)
 
 env_managed (const char *pathname, const create_parameters &, const operate_parameters &, bool accede=true)
 
void close (bool dont_sync=false)
 Explicitly closes the environment and release the memory map. More...
 
 env_managed (env_managed &&)=default
 
env_managedoperator= (env_managed &&other)
 
 env_managed (const env_managed &)=delete
 
env_managedoperator= (const env_managed &)=delete
 
virtual ~env_managed () noexcept
 
- Public Member Functions inherited from mdbx::env
 env () noexcept=default
 
 env (const env &) noexcept=default
 
envoperator= (env &&other) noexcept
 
 env (env &&other) noexcept
 
 ~env () noexcept
 
 operator const MDBX_env * () const
 
 operator MDBX_env * ()
 
env::operate_parameters get_operation_parameters () const
 Returns current operation parameters. More...
 
env::mode get_mode () const
 Returns current operation mode. More...
 
env::durability get_durability () const
 Returns current durability mode. More...
 
env::reclaiming_options get_reclaiming () const
 Returns current reclaiming options. More...
 
env::operate_options get_options () const
 Returns current operate options. More...
 
bool is_pristine () const
 Returns true for a freshly created database, but false if at least one transaction was committed. More...
 
bool is_empty () const
 Checks whether the database is empty. More...
 
size_t dbsize_min () const
 Returns the minimal database size in bytes for the environment. More...
 
size_t dbsize_max () const
 Returns the maximal database size in bytes for the environment. More...
 
size_t key_min (key_mode mode) const noexcept
 Returns the minimal key size in bytes for specified keys mode. More...
 
size_t key_max (key_mode mode) const
 Returns the maximal key size in bytes for specified keys mode. More...
 
size_t value_min (value_mode mode) const noexcept
 Returns the minimal value size in bytes for specified values mode. More...
 
size_t value_max (value_mode mode) const
 Returns the maximal value size in bytes for specified values mode. More...
 
size_t transaction_size_max () const
 Returns the maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes. More...
 
envcopy (const MDBX_STD_FILESYSTEM_PATH &destination, bool compactify, bool force_dynamic_size=false)
 Make a copy (backup) of an existing environment to the specified path. More...
 
envcopy (const ::std::wstring &destination, bool compactify, bool force_dynamic_size=false)
 
envcopy (const wchar_t *destination, bool compactify, bool force_dynamic_size=false)
 
envcopy (const ::std::string &destination, bool compactify, bool force_dynamic_size=false)
 
envcopy (const char *destination, bool compactify, bool force_dynamic_size=false)
 
envcopy (filehandle fd, bool compactify, bool force_dynamic_size=false)
 Copy an environment to the specified file descriptor. More...
 
stat get_stat () const
 Returns snapshot statistics about the MDBX environment. More...
 
size_t get_pagesize () const
 Returns pagesize of this MDBX environment. More...
 
info get_info () const
 Return snapshot information about the MDBX environment. More...
 
stat get_stat (const txn &) const
 Return statistics about the MDBX environment accordingly to the specified transaction. More...
 
info get_info (const txn &) const
 Return information about the MDBX environment accordingly to the specified transaction. More...
 
filehandle get_filehandle () const
 Returns the file descriptor for the DXB file of MDBX environment. More...
 
path get_path () const
 Return the path that was used for opening the environment. More...
 
MDBX_env_flags_t get_flags () const
 Returns environment flags. More...
 
unsigned max_readers () const
 Returns the maximum number of threads/reader slots for the environment. More...
 
unsigned max_maps () const
 Returns the maximum number of named databases for the environment. More...
 
void * get_context () const noexcept
 Returns the application context associated with the environment. More...
 
envset_context (void *)
 Sets the application context associated with the environment. More...
 
envset_sync_threshold (size_t bytes)
 Sets threshold to force flush the data buffers to disk, for non-sync durability modes. More...
 
envset_sync_period (unsigned seconds_16dot16)
 Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes. More...
 
envset_sync_period (double seconds)
 Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes. More...
 
envalter_flags (MDBX_env_flags_t flags, bool on_off)
 Alter environment flags. More...
 
envset_geometry (const geometry &size)
 Set all size-related parameters of environment. More...
 
bool sync_to_disk (bool force=true, bool nonblock=false)
 Flush the environment data buffers. More...
 
bool poll_sync_to_disk ()
 Performs non-blocking polling of sync-to-disk thresholds. More...
 
void close_map (const map_handle &)
 Close a key-value map (aka sub-database) handle. Normally unnecessary. More...
 
template<typename VISITOR >
int enumerate_readers (VISITOR &visitor)
 Enumerate readers. More...
 
unsigned check_readers ()
 Checks for stale readers in the lock table and return number of cleared slots. More...
 
envset_HandleSlowReaders (MDBX_hsr_func *)
 Sets a Handle-Slow-Readers callback to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled. More...
 
MDBX_hsr_funcget_HandleSlowReaders () const noexcept
 Returns the current Handle-Slow-Readers callback used to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled. More...
 
txn_managed start_read () const
 Starts read (read-only) transaction. More...
 
txn_managed prepare_read () const
 Creates but not start read transaction. More...
 
txn_managed start_write (bool dont_wait=false)
 Starts write (read-write) transaction. More...
 
txn_managed try_start_write ()
 Tries to start write (read-write) transaction without blocking. More...
 

Additional Inherited Members

- Public Types inherited from mdbx::env
enum  mode { readonly , write_file_io , write_mapped_io }
 Operation mode. More...
 
enum  durability { robust_synchronous , half_synchronous_weak_last , lazy_weak_tail , whole_fragile }
 Durability level. More...
 
enum  remove_mode { just_remove = MDBX_ENV_JUST_DELETE , ensure_unused = MDBX_ENV_ENSURE_UNUSED , wait_for_unused = MDBX_ENV_WAIT_FOR_UNUSED }
 Deletion modes for remove(). More...
 
using stat = ::MDBX_stat
 Statistics for a database in the MDBX environment. More...
 
using info = ::MDBX_envinfo
 Information about the environment. More...
 
- Static Public Member Functions inherited from mdbx::env
static size_t default_pagesize () noexcept
 Returns default page size for current system/platform. More...
 
static bool remove (const MDBX_STD_FILESYSTEM_PATH &pathname, const remove_mode mode=just_remove)
 Removes the environment's files in a proper and multiprocess-safe way. More...
 
static bool remove (const ::std::wstring &pathname, const remove_mode mode=just_remove)
 
static bool remove (const wchar_t *pathname, const remove_mode mode=just_remove)
 
static bool remove (const ::std::string &pathname, const remove_mode mode=just_remove)
 
static bool remove (const char *pathname, const remove_mode mode=just_remove)
 
- Protected Member Functions inherited from mdbx::env
 env (MDBX_env *ptr) noexcept
 
- Protected Attributes inherited from mdbx::env
MDBX_envhandle_ {nullptr}
 

Constructor & Destructor Documentation

◆ env_managed() [1/13]

mdbx::env_managed::env_managed ( )
defaultnoexcept

◆ env_managed() [2/13]

mdbx::env_managed::env_managed ( const MDBX_STD_FILESYSTEM_PATH pathname,
const operate_parameters ,
bool  accede = true 
)

Open existing database.

◆ env_managed() [3/13]

mdbx::env_managed::env_managed ( const ::std::wstring &  pathname,
const operate_parameters ,
bool  accede = true 
)

◆ env_managed() [4/13]

mdbx::env_managed::env_managed ( const wchar_t *  pathname,
const operate_parameters ,
bool  accede = true 
)
explicit

◆ env_managed() [5/13]

mdbx::env_managed::env_managed ( const ::std::string &  pathname,
const operate_parameters ,
bool  accede = true 
)

◆ env_managed() [6/13]

mdbx::env_managed::env_managed ( const char *  pathname,
const operate_parameters ,
bool  accede = true 
)
explicit

◆ env_managed() [7/13]

mdbx::env_managed::env_managed ( const MDBX_STD_FILESYSTEM_PATH pathname,
const create_parameters ,
const operate_parameters ,
bool  accede = true 
)

Create new or open existing database.

◆ env_managed() [8/13]

mdbx::env_managed::env_managed ( const ::std::wstring &  pathname,
const create_parameters ,
const operate_parameters ,
bool  accede = true 
)

◆ env_managed() [9/13]

mdbx::env_managed::env_managed ( const wchar_t *  pathname,
const create_parameters ,
const operate_parameters ,
bool  accede = true 
)
explicit

◆ env_managed() [10/13]

mdbx::env_managed::env_managed ( const ::std::string &  pathname,
const create_parameters ,
const operate_parameters ,
bool  accede = true 
)

◆ env_managed() [11/13]

mdbx::env_managed::env_managed ( const char *  pathname,
const create_parameters ,
const operate_parameters ,
bool  accede = true 
)
explicit

◆ env_managed() [12/13]

mdbx::env_managed::env_managed ( env_managed &&  )
default

◆ env_managed() [13/13]

mdbx::env_managed::env_managed ( const env_managed )
delete

◆ ~env_managed()

virtual mdbx::env_managed::~env_managed ( )
virtualnoexcept

Member Function Documentation

◆ close()

void mdbx::env_managed::close ( bool  dont_sync = false)

Explicitly closes the environment and release the memory map.

Only a single thread may call this function. All transactions, databases, and cursors must already be closed before calling this function. Attempts to use any such handles after calling this function will cause a SIGSEGV. The environment handle will be freed and must not be used again after this call.

Parameters
[in]dont_syncA dont'sync flag, if non-zero the last checkpoint will be kept "as is" and may be still "weak" in the lazy_weak_tail or whole_fragile modes. Such "weak" checkpoint will be ignored on opening next time, and transactions since the last non-weak checkpoint (meta-page update) will rolledback for consistency guarantee.

◆ operator=() [1/2]

env_managed& mdbx::env_managed::operator= ( const env_managed )
delete

◆ operator=() [2/2]

env_managed& mdbx::env_managed::operator= ( env_managed &&  other)
inline

◆ mdbx::txn

class mdbx::txn

Unmanaged database transaction.

Like other unmanaged classes, txn allows copying and assignment for instances, but does not destroys the represented underlying object from the own class destructor.

All database operations require a transaction handle. Transactions may be read-only or read-write.

Inherited by mdbx::txn_managed.

Public Types

using info = ::MDBX_txn_info
 
using map_stat = ::MDBX_stat
 
using canary = ::MDBX_canary
 

Public Member Functions

 txn () noexcept=default
 
 txn (const txn &) noexcept=default
 
txnoperator= (txn &&other) noexcept
 
 txn (txn &&other) noexcept
 
 ~txn () noexcept
 
 operator const MDBX_txn * () const
 
 operator MDBX_txn * ()
 
inline ::mdbx::env env () const noexcept
 Returns the transaction's environment. More...
 
MDBX_txn_flags_t flags () const
 Returns transaction's flags. More...
 
uint64_t id () const
 Return the transaction's ID. More...
 
bool is_dirty (const void *ptr) const
 Checks whether the given data is on a dirty page. More...
 
bool is_readonly () const
 Checks whether the transaction is read-only. More...
 
bool is_readwrite () const
 Checks whether the transaction is read-write. More...
 
info get_info (bool scan_reader_lock_table=false) const
 Returns information about the MDBX transaction. More...
 
size_t size_max () const
 Returns maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes. More...
 
size_t size_current () const
 Returns current write transaction size (i.e.summary volume of dirty pages) in bytes. More...
 
void reset_reading ()
 Reset a read-only transaction. More...
 
void renew_reading ()
 Renew a read-only transaction. More...
 
txn_managed start_nested ()
 Start nested write transaction. More...
 
cursor_managed open_cursor (map_handle map)
 Opens cursor for specified key-value map handle. More...
 
map_handle open_map (const char *name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single) const
 Open existing key-value map. More...
 
map_handle open_map (const ::std::string &name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single) const
 Open existing key-value map. More...
 
map_handle create_map (const char *name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single)
 Create new or open existing key-value map. More...
 
map_handle create_map (const ::std::string &name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single)
 Create new or open existing key-value map. More...
 
void drop_map (map_handle map)
 Drops key-value map using handle. More...
 
bool drop_map (const char *name, bool throw_if_absent=false)
 Drops key-value map using name. More...
 
bool drop_map (const ::std::string &name, bool throw_if_absent=false)
 Drop key-value map. More...
 
void clear_map (map_handle map)
 Clear key-value map. More...
 
bool clear_map (const char *name, bool throw_if_absent=false)
 
bool clear_map (const ::std::string &name, bool throw_if_absent=false)
 
map_stat get_map_stat (map_handle map) const
 Returns statistics for a sub-database. More...
 
uint32_t get_tree_deepmask (map_handle map) const
 Returns depth (bitmask) information of nested dupsort (multi-value) B+trees for given database. More...
 
map_handle::info get_handle_info (map_handle map) const
 Returns information about key-value map (aka sub-database) handle. More...
 
txnput_canary (const canary &)
 Set integers markers (aka "canary") associated with the environment. More...
 
canary get_canary () const
 Returns fours integers markers (aka "canary") associated with the environment. More...
 
uint64_t sequence (map_handle map) const
 
uint64_t sequence (map_handle map, uint64_t increment)
 Reads and increment sequence generator associated with a key-value map (aka sub-database). More...
 
int compare_keys (map_handle map, const slice &a, const slice &b) const noexcept
 Compare two keys according to a particular key-value map (aka sub-database). More...
 
int compare_values (map_handle map, const slice &a, const slice &b) const noexcept
 Compare two values according to a particular key-value map (aka sub-database). More...
 
int compare_keys (map_handle map, const pair &a, const pair &b) const noexcept
 Compare keys of two pairs according to a particular key-value map (aka sub-database). More...
 
int compare_values (map_handle map, const pair &a, const pair &b) const noexcept
 Compare values of two pairs according to a particular key-value map (aka sub-database). More...
 
slice get (map_handle map, const slice &key) const
 Get value by key from a key-value map (aka sub-database). More...
 
slice get (map_handle map, slice key, size_t &values_count) const
 Get first of multi-value and values count by key from a key-value multimap (aka sub-database). More...
 
slice get (map_handle map, const slice &key, const slice &value_at_absence) const
 Get value by key from a key-value map (aka sub-database). More...
 
slice get (map_handle map, slice key, size_t &values_count, const slice &value_at_absence) const
 Get first of multi-value and values count by key from a key-value multimap (aka sub-database). More...
 
pair_result get_equal_or_great (map_handle map, const slice &key) const
 Get value for equal or great key from a database. More...
 
pair_result get_equal_or_great (map_handle map, const slice &key, const slice &value_at_absence) const
 Get value for equal or great key from a database. More...
 
MDBX_error_t put (map_handle map, const slice &key, slice *value, MDBX_put_flags_t flags) noexcept
 
void put (map_handle map, const slice &key, slice value, put_mode mode)
 
void insert (map_handle map, const slice &key, slice value)
 
value_result try_insert (map_handle map, const slice &key, slice value)
 
slice insert_reserve (map_handle map, const slice &key, size_t value_length)
 
value_result try_insert_reserve (map_handle map, const slice &key, size_t value_length)
 
void upsert (map_handle map, const slice &key, const slice &value)
 
slice upsert_reserve (map_handle map, const slice &key, size_t value_length)
 
void update (map_handle map, const slice &key, const slice &value)
 
bool try_update (map_handle map, const slice &key, const slice &value)
 
slice update_reserve (map_handle map, const slice &key, size_t value_length)
 
value_result try_update_reserve (map_handle map, const slice &key, size_t value_length)
 
bool erase (map_handle map, const slice &key)
 Removes all values for given key. More...
 
bool erase (map_handle map, const slice &key, const slice &value)
 Removes the particular multi-value entry of the key. More...
 
void replace (map_handle map, const slice &key, slice old_value, const slice &new_value)
 Replaces the particular multi-value of the key with a new value. More...
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > extract (map_handle map, const slice &key, const typename buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type &allocator=buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type())
 Removes and return a value of the key. More...
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > replace (map_handle map, const slice &key, const slice &new_value, const typename buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type &allocator=buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type())
 Replaces and returns a value of the key with new one. More...
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > replace_reserve (map_handle map, const slice &key, slice &new_value, const typename buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type &allocator=buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type())
 
void append (map_handle map, const slice &key, const slice &value, bool multivalue_order_preserved=true)
 Adding a key-value pair, provided that ascending order of the keys and (optionally) values are preserved. More...
 
size_t put_multiple (map_handle map, const slice &key, const size_t value_length, const void *values_array, size_t values_count, put_mode mode, bool allow_partial=false)
 
template<typename VALUE >
void put_multiple (map_handle map, const slice &key, const ::std::vector< VALUE > &vector, put_mode mode)
 
ptrdiff_t estimate (map_handle map, pair from, pair to) const
 
ptrdiff_t estimate (map_handle map, slice from, slice to) const
 
ptrdiff_t estimate_from_first (map_handle map, slice to) const
 
ptrdiff_t estimate_to_last (map_handle map, slice from) const
 

Protected Member Functions

 txn (MDBX_txn *ptr) noexcept
 

Protected Attributes

MDBX_txnhandle_ {nullptr}
 

Friends

class cursor
 
bool operator== (const txn &a, const txn &b) noexcept
 
bool operator!= (const txn &a, const txn &b) noexcept
 

Member Typedef Documentation

◆ canary

◆ info

◆ map_stat

Constructor & Destructor Documentation

◆ txn() [1/2]

mdbx::txn::txn ( )
defaultnoexcept

◆ txn() [2/2]

mdbx::txn::txn ( const txn )
defaultnoexcept

Member Function Documentation

◆ clear_map()

bool mdbx::txn::clear_map ( const char *  name,
bool  throw_if_absent = false 
)
Returns
True if the key-value map existed and was cleared, either false if the key-value map did not exist and there is nothing to clear.

◆ drop_map()

bool mdbx::txn::drop_map ( const char *  name,
bool  throw_if_absent = false 
)

Drops key-value map using name.

Returns
True if the key-value map existed and was deleted, either false if the key-value map did not exist and there is nothing to delete.

◆ is_readonly()

bool mdbx::txn::is_readonly ( ) const
inline

Checks whether the transaction is read-only.

◆ is_readwrite()

bool mdbx::txn::is_readwrite ( ) const
inline

Checks whether the transaction is read-write.

◆ put_multiple()

template<typename VALUE >
void mdbx::txn::put_multiple ( map_handle  map,
const slice key,
const ::std::vector< VALUE > &  vector,
put_mode  mode 
)
inline

◆ size_current()

size_t mdbx::txn::size_current ( ) const
inline

Returns current write transaction size (i.e.summary volume of dirty pages) in bytes.

◆ size_max()

size_t mdbx::txn::size_max ( ) const
inline

Returns maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes.

◆ start_nested()

txn_managed mdbx::txn::start_nested ( )

Start nested write transaction.

Friends And Related Function Documentation

◆ cursor

friend class cursor
friend

◆ operator!=

bool operator!= ( const txn a,
const txn b 
)
friend

◆ operator==

bool operator== ( const txn a,
const txn b 
)
friend

Member Data Documentation

◆ handle_

MDBX_txn* mdbx::txn::handle_ {nullptr}
protected

◆ mdbx::txn_managed

class mdbx::txn_managed

Managed database transaction.

As other managed classes, txn_managed destroys the represented underlying object from the own class destructor, but disallows copying and assignment for instances.

All database operations require a transaction handle. Transactions may be read-only or read-write.

Inherits mdbx::txn.

Public Types

using commit_latency = MDBX_commit_latency
 
- Public Types inherited from mdbx::txn
using info = ::MDBX_txn_info
 
using map_stat = ::MDBX_stat
 
using canary = ::MDBX_canary
 

Public Member Functions

 txn_managed () noexcept=default
 
 txn_managed (txn_managed &&)=default
 
txn_managedoperator= (txn_managed &&other)
 
 txn_managed (const txn_managed &)=delete
 
txn_managedoperator= (const txn_managed &)=delete
 
 ~txn_managed () noexcept
 
void abort ()
 Abandon all the operations of the transaction instead of saving ones. More...
 
void commit ()
 Commit all the operations of a transaction into the database. More...
 
void commit (commit_latency *)
 Commit all the operations of a transaction into the database and collect latency information. More...
 
void commit (commit_latency &latency)
 Commit all the operations of a transaction into the database and collect latency information. More...
 
commit_latency commit_get_latency ()
 Commit all the operations of a transaction into the database and return latency information. More...
 
- Public Member Functions inherited from mdbx::txn
 txn () noexcept=default
 
 txn (const txn &) noexcept=default
 
txnoperator= (txn &&other) noexcept
 
 txn (txn &&other) noexcept
 
 ~txn () noexcept
 
 operator const MDBX_txn * () const
 
 operator MDBX_txn * ()
 
inline ::mdbx::env env () const noexcept
 Returns the transaction's environment. More...
 
MDBX_txn_flags_t flags () const
 Returns transaction's flags. More...
 
uint64_t id () const
 Return the transaction's ID. More...
 
bool is_dirty (const void *ptr) const
 Checks whether the given data is on a dirty page. More...
 
bool is_readonly () const
 Checks whether the transaction is read-only. More...
 
bool is_readwrite () const
 Checks whether the transaction is read-write. More...
 
info get_info (bool scan_reader_lock_table=false) const
 Returns information about the MDBX transaction. More...
 
size_t size_max () const
 Returns maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes. More...
 
size_t size_current () const
 Returns current write transaction size (i.e.summary volume of dirty pages) in bytes. More...
 
void reset_reading ()
 Reset a read-only transaction. More...
 
void renew_reading ()
 Renew a read-only transaction. More...
 
txn_managed start_nested ()
 Start nested write transaction. More...
 
cursor_managed open_cursor (map_handle map)
 Opens cursor for specified key-value map handle. More...
 
map_handle open_map (const char *name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single) const
 Open existing key-value map. More...
 
map_handle open_map (const ::std::string &name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single) const
 Open existing key-value map. More...
 
map_handle create_map (const char *name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single)
 Create new or open existing key-value map. More...
 
map_handle create_map (const ::std::string &name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single)
 Create new or open existing key-value map. More...
 
void drop_map (map_handle map)
 Drops key-value map using handle. More...
 
bool drop_map (const char *name, bool throw_if_absent=false)
 Drops key-value map using name. More...
 
bool drop_map (const ::std::string &name, bool throw_if_absent=false)
 Drop key-value map. More...
 
void clear_map (map_handle map)
 Clear key-value map. More...
 
bool clear_map (const char *name, bool throw_if_absent=false)
 
bool clear_map (const ::std::string &name, bool throw_if_absent=false)
 
map_stat get_map_stat (map_handle map) const
 Returns statistics for a sub-database. More...
 
uint32_t get_tree_deepmask (map_handle map) const
 Returns depth (bitmask) information of nested dupsort (multi-value) B+trees for given database. More...
 
map_handle::info get_handle_info (map_handle map) const
 Returns information about key-value map (aka sub-database) handle. More...
 
txnput_canary (const canary &)
 Set integers markers (aka "canary") associated with the environment. More...
 
canary get_canary () const
 Returns fours integers markers (aka "canary") associated with the environment. More...
 
uint64_t sequence (map_handle map) const
 
uint64_t sequence (map_handle map, uint64_t increment)
 Reads and increment sequence generator associated with a key-value map (aka sub-database). More...
 
int compare_keys (map_handle map, const slice &a, const slice &b) const noexcept
 Compare two keys according to a particular key-value map (aka sub-database). More...
 
int compare_values (map_handle map, const slice &a, const slice &b) const noexcept
 Compare two values according to a particular key-value map (aka sub-database). More...
 
int compare_keys (map_handle map, const pair &a, const pair &b) const noexcept
 Compare keys of two pairs according to a particular key-value map (aka sub-database). More...
 
int compare_values (map_handle map, const pair &a, const pair &b) const noexcept
 Compare values of two pairs according to a particular key-value map (aka sub-database). More...
 
slice get (map_handle map, const slice &key) const
 Get value by key from a key-value map (aka sub-database). More...
 
slice get (map_handle map, slice key, size_t &values_count) const
 Get first of multi-value and values count by key from a key-value multimap (aka sub-database). More...
 
slice get (map_handle map, const slice &key, const slice &value_at_absence) const
 Get value by key from a key-value map (aka sub-database). More...
 
slice get (map_handle map, slice key, size_t &values_count, const slice &value_at_absence) const
 Get first of multi-value and values count by key from a key-value multimap (aka sub-database). More...
 
pair_result get_equal_or_great (map_handle map, const slice &key) const
 Get value for equal or great key from a database. More...
 
pair_result get_equal_or_great (map_handle map, const slice &key, const slice &value_at_absence) const
 Get value for equal or great key from a database. More...
 
MDBX_error_t put (map_handle map, const slice &key, slice *value, MDBX_put_flags_t flags) noexcept
 
void put (map_handle map, const slice &key, slice value, put_mode mode)
 
void insert (map_handle map, const slice &key, slice value)
 
value_result try_insert (map_handle map, const slice &key, slice value)
 
slice insert_reserve (map_handle map, const slice &key, size_t value_length)
 
value_result try_insert_reserve (map_handle map, const slice &key, size_t value_length)
 
void upsert (map_handle map, const slice &key, const slice &value)
 
slice upsert_reserve (map_handle map, const slice &key, size_t value_length)
 
void update (map_handle map, const slice &key, const slice &value)
 
bool try_update (map_handle map, const slice &key, const slice &value)
 
slice update_reserve (map_handle map, const slice &key, size_t value_length)
 
value_result try_update_reserve (map_handle map, const slice &key, size_t value_length)
 
bool erase (map_handle map, const slice &key)
 Removes all values for given key. More...
 
bool erase (map_handle map, const slice &key, const slice &value)
 Removes the particular multi-value entry of the key. More...
 
void replace (map_handle map, const slice &key, slice old_value, const slice &new_value)
 Replaces the particular multi-value of the key with a new value. More...
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > extract (map_handle map, const slice &key, const typename buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type &allocator=buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type())
 Removes and return a value of the key. More...
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > replace (map_handle map, const slice &key, const slice &new_value, const typename buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type &allocator=buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type())
 Replaces and returns a value of the key with new one. More...
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > replace_reserve (map_handle map, const slice &key, slice &new_value, const typename buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type &allocator=buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type())
 
void append (map_handle map, const slice &key, const slice &value, bool multivalue_order_preserved=true)
 Adding a key-value pair, provided that ascending order of the keys and (optionally) values are preserved. More...
 
size_t put_multiple (map_handle map, const slice &key, const size_t value_length, const void *values_array, size_t values_count, put_mode mode, bool allow_partial=false)
 
template<typename VALUE >
void put_multiple (map_handle map, const slice &key, const ::std::vector< VALUE > &vector, put_mode mode)
 
ptrdiff_t estimate (map_handle map, pair from, pair to) const
 
ptrdiff_t estimate (map_handle map, slice from, slice to) const
 
ptrdiff_t estimate_from_first (map_handle map, slice to) const
 
ptrdiff_t estimate_to_last (map_handle map, slice from) const
 

Friends

class env
 
class txn
 

Additional Inherited Members

- Protected Member Functions inherited from mdbx::txn
 txn (MDBX_txn *ptr) noexcept
 
- Protected Attributes inherited from mdbx::txn
MDBX_txnhandle_ {nullptr}
 

Member Typedef Documentation

◆ commit_latency

Constructor & Destructor Documentation

◆ txn_managed() [1/3]

mdbx::txn_managed::txn_managed ( )
defaultnoexcept

◆ txn_managed() [2/3]

mdbx::txn_managed::txn_managed ( txn_managed &&  )
default

◆ txn_managed() [3/3]

mdbx::txn_managed::txn_managed ( const txn_managed )
delete

◆ ~txn_managed()

mdbx::txn_managed::~txn_managed ( )
noexcept

Member Function Documentation

◆ abort()

void mdbx::txn_managed::abort ( )

Abandon all the operations of the transaction instead of saving ones.

◆ commit() [1/3]

void mdbx::txn_managed::commit ( )

Commit all the operations of a transaction into the database.

◆ commit() [2/3]

void mdbx::txn_managed::commit ( commit_latency latency)
inline

Commit all the operations of a transaction into the database and collect latency information.

◆ commit() [3/3]

void mdbx::txn_managed::commit ( commit_latency )

Commit all the operations of a transaction into the database and collect latency information.

◆ commit_get_latency()

commit_latency mdbx::txn_managed::commit_get_latency ( )
inline

Commit all the operations of a transaction into the database and return latency information.

Returns
latency information of commit stages.

◆ operator=() [1/2]

txn_managed& mdbx::txn_managed::operator= ( const txn_managed )
delete

◆ operator=() [2/2]

txn_managed& mdbx::txn_managed::operator= ( txn_managed &&  other)
inline

Friends And Related Function Documentation

◆ env

friend class env
friend

◆ txn

friend class txn
friend

◆ mdbx::cursor

class mdbx::cursor

Unmanaged cursor.

Like other unmanaged classes, cursor allows copying and assignment for instances, but does not destroys the represented underlying object from the own class destructor.

See also
mdbx_cursor_create()
mdbx_cursor_bind()
mdbx_cursor_close()

Inherited by mdbx::cursor_managed.

Public Types

enum  move_operation {
  first = MDBX_FIRST , last = MDBX_LAST , next = MDBX_NEXT , previous = MDBX_PREV ,
  get_current = MDBX_GET_CURRENT , multi_prevkey_lastvalue = MDBX_PREV_NODUP , multi_currentkey_firstvalue = MDBX_FIRST_DUP , multi_currentkey_prevvalue = MDBX_PREV_DUP ,
  multi_currentkey_nextvalue = MDBX_NEXT_DUP , multi_currentkey_lastvalue = MDBX_LAST_DUP , multi_nextkey_firstvalue = MDBX_NEXT_NODUP , multi_find_pair = MDBX_GET_BOTH ,
  multi_exactkey_lowerboundvalue = MDBX_GET_BOTH_RANGE , find_key = MDBX_SET , key_exact = MDBX_SET_KEY , key_lowerbound = MDBX_SET_RANGE
}
 

Public Member Functions

 cursor () noexcept=default
 
 cursor (const cursor &) noexcept=default
 
cursoroperator= (cursor &&other) noexcept
 
 cursor (cursor &&other) noexcept
 
 ~cursor () noexcept
 
 operator const MDBX_cursor * () const
 
 operator MDBX_cursor * ()
 
move_result move (move_operation operation, bool throw_notfound)
 
move_result to_first (bool throw_notfound=true)
 
move_result to_previous (bool throw_notfound=true)
 
move_result to_previous_last_multi (bool throw_notfound=true)
 
move_result to_current_first_multi (bool throw_notfound=true)
 
move_result to_current_prev_multi (bool throw_notfound=true)
 
move_result current (bool throw_notfound=true) const
 
move_result to_current_next_multi (bool throw_notfound=true)
 
move_result to_current_last_multi (bool throw_notfound=true)
 
move_result to_next_first_multi (bool throw_notfound=true)
 
move_result to_next (bool throw_notfound=true)
 
move_result to_last (bool throw_notfound=true)
 
move_result move (move_operation operation, const slice &key, bool throw_notfound)
 
move_result find (const slice &key, bool throw_notfound=true)
 
move_result lower_bound (const slice &key, bool throw_notfound=true)
 
move_result move (move_operation operation, const slice &key, const slice &value, bool throw_notfound)
 
move_result find_multivalue (const slice &key, const slice &value, bool throw_notfound=true)
 
move_result lower_bound_multivalue (const slice &key, const slice &value, bool throw_notfound=false)
 
bool seek (const slice &key)
 
bool move (move_operation operation, slice &key, slice &value, bool throw_notfound)
 
size_t count_multivalue () const
 Return count of duplicates for current key. More...
 
bool eof () const
 
bool on_first () const
 
bool on_last () const
 
ptrdiff_t estimate (slice key, slice value) const
 
ptrdiff_t estimate (slice key) const
 
ptrdiff_t estimate (move_operation operation) const
 
void renew (::mdbx::txn &txn)
 Renew/bind a cursor with a new transaction and previously used key-value map handle. More...
 
void bind (::mdbx::txn &txn, ::mdbx::map_handle map_handle)
 Bind/renew a cursor with a new transaction and specified key-value map handle. More...
 
inline ::mdbx::txn txn () const
 Returns the cursor's transaction. More...
 
map_handle map () const
 
 operator::mdbx::txn () const
 
 operator::mdbx::map_handle () const
 
MDBX_error_t put (const slice &key, slice *value, MDBX_put_flags_t flags) noexcept
 
void insert (const slice &key, slice value)
 
value_result try_insert (const slice &key, slice value)
 
slice insert_reserve (const slice &key, size_t value_length)
 
value_result try_insert_reserve (const slice &key, size_t value_length)
 
void upsert (const slice &key, const slice &value)
 
slice upsert_reserve (const slice &key, size_t value_length)
 
void update (const slice &key, const slice &value)
 
bool try_update (const slice &key, const slice &value)
 
slice update_reserve (const slice &key, size_t value_length)
 
value_result try_update_reserve (const slice &key, size_t value_length)
 
bool erase (bool whole_multivalue=false)
 Removes single key-value pair or all multi-values at the current cursor position. More...
 
bool erase (const slice &key, bool whole_multivalue=true)
 Seeks and removes first value or whole multi-value of the given key. More...
 
bool erase (const slice &key, const slice &value)
 Seeks and removes the particular multi-value entry of the key. More...
 

Protected Member Functions

 cursor (MDBX_cursor *ptr) noexcept
 
bool move (move_operation operation, MDBX_val *key, MDBX_val *value, bool throw_notfound) const
 
ptrdiff_t estimate (move_operation operation, MDBX_val *key, MDBX_val *value) const
 

Protected Attributes

MDBX_cursorhandle_ {nullptr}
 

Friends

bool operator== (const cursor &a, const cursor &b) noexcept
 
bool operator!= (const cursor &a, const cursor &b) noexcept
 

Member Enumeration Documentation

◆ move_operation

Enumerator
first 
last 
next 
previous 
get_current 
multi_prevkey_lastvalue 
multi_currentkey_firstvalue 
multi_currentkey_prevvalue 
multi_currentkey_nextvalue 
multi_currentkey_lastvalue 
multi_nextkey_firstvalue 
multi_find_pair 
multi_exactkey_lowerboundvalue 
find_key 
key_exact 
key_lowerbound 

Constructor & Destructor Documentation

◆ cursor() [1/2]

mdbx::cursor::cursor ( )
defaultnoexcept

◆ cursor() [2/2]

mdbx::cursor::cursor ( const cursor )
defaultnoexcept

Member Function Documentation

◆ operator::mdbx::map_handle()

mdbx::cursor::operator::mdbx::map_handle ( ) const
inline

◆ operator::mdbx::txn()

mdbx::cursor::operator::mdbx::txn ( ) const
inline

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const cursor a,
const cursor b 
)
friend

◆ operator==

bool operator== ( const cursor a,
const cursor b 
)
friend

Member Data Documentation

◆ handle_

MDBX_cursor* mdbx::cursor::handle_ {nullptr}
protected

◆ mdbx::cursor_managed

class mdbx::cursor_managed

Managed cursor.

As other managed classes, cursor_managed destroys the represented underlying object from the own class destructor, but disallows copying and assignment for instances.

See also
mdbx_cursor_create()
mdbx_cursor_bind()
mdbx_cursor_close()

Inherits mdbx::cursor.

Public Member Functions

 cursor_managed ()
 Creates a new managed cursor with underlying object. More...
 
void close ()
 Explicitly closes the cursor. More...
 
 cursor_managed (cursor_managed &&)=default
 
cursor_managedoperator= (cursor_managed &&other)
 
 cursor_managed (const cursor_managed &)=delete
 
cursor_managedoperator= (const cursor_managed &)=delete
 
 ~cursor_managed () noexcept
 
- Public Member Functions inherited from mdbx::cursor
 cursor () noexcept=default
 
 cursor (const cursor &) noexcept=default
 
cursoroperator= (cursor &&other) noexcept
 
 cursor (cursor &&other) noexcept
 
 ~cursor () noexcept
 
 operator const MDBX_cursor * () const
 
 operator MDBX_cursor * ()
 
move_result move (move_operation operation, bool throw_notfound)
 
move_result to_first (bool throw_notfound=true)
 
move_result to_previous (bool throw_notfound=true)
 
move_result to_previous_last_multi (bool throw_notfound=true)
 
move_result to_current_first_multi (bool throw_notfound=true)
 
move_result to_current_prev_multi (bool throw_notfound=true)
 
move_result current (bool throw_notfound=true) const
 
move_result to_current_next_multi (bool throw_notfound=true)
 
move_result to_current_last_multi (bool throw_notfound=true)
 
move_result to_next_first_multi (bool throw_notfound=true)
 
move_result to_next (bool throw_notfound=true)
 
move_result to_last (bool throw_notfound=true)
 
move_result move (move_operation operation, const slice &key, bool throw_notfound)
 
move_result find (const slice &key, bool throw_notfound=true)
 
move_result lower_bound (const slice &key, bool throw_notfound=true)
 
move_result move (move_operation operation, const slice &key, const slice &value, bool throw_notfound)
 
move_result find_multivalue (const slice &key, const slice &value, bool throw_notfound=true)
 
move_result lower_bound_multivalue (const slice &key, const slice &value, bool throw_notfound=false)
 
bool seek (const slice &key)
 
bool move (move_operation operation, slice &key, slice &value, bool throw_notfound)
 
size_t count_multivalue () const
 Return count of duplicates for current key. More...
 
bool eof () const
 
bool on_first () const
 
bool on_last () const
 
ptrdiff_t estimate (slice key, slice value) const
 
ptrdiff_t estimate (slice key) const
 
ptrdiff_t estimate (move_operation operation) const
 
void renew (::mdbx::txn &txn)
 Renew/bind a cursor with a new transaction and previously used key-value map handle. More...
 
void bind (::mdbx::txn &txn, ::mdbx::map_handle map_handle)
 Bind/renew a cursor with a new transaction and specified key-value map handle. More...
 
inline ::mdbx::txn txn () const
 Returns the cursor's transaction. More...
 
map_handle map () const
 
 operator::mdbx::txn () const
 
 operator::mdbx::map_handle () const
 
MDBX_error_t put (const slice &key, slice *value, MDBX_put_flags_t flags) noexcept
 
void insert (const slice &key, slice value)
 
value_result try_insert (const slice &key, slice value)
 
slice insert_reserve (const slice &key, size_t value_length)
 
value_result try_insert_reserve (const slice &key, size_t value_length)
 
void upsert (const slice &key, const slice &value)
 
slice upsert_reserve (const slice &key, size_t value_length)
 
void update (const slice &key, const slice &value)
 
bool try_update (const slice &key, const slice &value)
 
slice update_reserve (const slice &key, size_t value_length)
 
value_result try_update_reserve (const slice &key, size_t value_length)
 
bool erase (bool whole_multivalue=false)
 Removes single key-value pair or all multi-values at the current cursor position. More...
 
bool erase (const slice &key, bool whole_multivalue=true)
 Seeks and removes first value or whole multi-value of the given key. More...
 
bool erase (const slice &key, const slice &value)
 Seeks and removes the particular multi-value entry of the key. More...
 

Friends

class txn
 

Additional Inherited Members

- Public Types inherited from mdbx::cursor
enum  move_operation {
  first = MDBX_FIRST , last = MDBX_LAST , next = MDBX_NEXT , previous = MDBX_PREV ,
  get_current = MDBX_GET_CURRENT , multi_prevkey_lastvalue = MDBX_PREV_NODUP , multi_currentkey_firstvalue = MDBX_FIRST_DUP , multi_currentkey_prevvalue = MDBX_PREV_DUP ,
  multi_currentkey_nextvalue = MDBX_NEXT_DUP , multi_currentkey_lastvalue = MDBX_LAST_DUP , multi_nextkey_firstvalue = MDBX_NEXT_NODUP , multi_find_pair = MDBX_GET_BOTH ,
  multi_exactkey_lowerboundvalue = MDBX_GET_BOTH_RANGE , find_key = MDBX_SET , key_exact = MDBX_SET_KEY , key_lowerbound = MDBX_SET_RANGE
}
 
- Protected Member Functions inherited from mdbx::cursor
 cursor (MDBX_cursor *ptr) noexcept
 
bool move (move_operation operation, MDBX_val *key, MDBX_val *value, bool throw_notfound) const
 
ptrdiff_t estimate (move_operation operation, MDBX_val *key, MDBX_val *value) const
 
- Protected Attributes inherited from mdbx::cursor
MDBX_cursorhandle_ {nullptr}
 

Constructor & Destructor Documentation

◆ cursor_managed() [1/3]

mdbx::cursor_managed::cursor_managed ( )
inline

Creates a new managed cursor with underlying object.

◆ cursor_managed() [2/3]

mdbx::cursor_managed::cursor_managed ( cursor_managed &&  )
default

◆ cursor_managed() [3/3]

mdbx::cursor_managed::cursor_managed ( const cursor_managed )
delete

◆ ~cursor_managed()

mdbx::cursor_managed::~cursor_managed ( )
inlinenoexcept

Member Function Documentation

◆ close()

void mdbx::cursor_managed::close ( )

Explicitly closes the cursor.

◆ operator=() [1/2]

cursor_managed& mdbx::cursor_managed::operator= ( const cursor_managed )
delete

◆ operator=() [2/2]

cursor_managed& mdbx::cursor_managed::operator= ( cursor_managed &&  other)
inline

Friends And Related Function Documentation

◆ txn

friend class txn
friend

◆ std::hash<::mdbx::slice >

struct std::hash<::mdbx::slice >

Public Member Functions

size_t operator() (::mdbx::slice const &slice) const noexcept
 

Member Function Documentation

◆ operator()()

size_t std::hash<::mdbx::slice >::operator() ( ::mdbx::slice const &  slice) const
inlinenoexcept

Macro Definition Documentation

◆ MDBX_STD_FILESYSTEM_PATH

#define MDBX_STD_FILESYSTEM_PATH   ::mdbx::filesystem::path

Defined if mdbx::filesystem::path is available.

If defined, it is always mdbx::filesystem::path, which in turn can be refs to std::filesystem::path or std::experimental::filesystem::path. Nonetheless MDBX_STD_FILESYSTEM_PATH not defined if the mdbx::path is fallbacked to c std::string or std::wstring.

Typedef Documentation

◆ build_info

using mdbx::build_info = typedef ::MDBX_build_info

libmdbx build information

Attention
Some strings could be NULL in case no corresponding information was provided at build time (i.e. flags).

◆ byte

using mdbx::byte = typedef char8_t

◆ filehandle

◆ legacy_allocator

using mdbx::legacy_allocator = typedef ::std::string::allocator_type

Legacy default allocator but it is recommended to use polymorphic_allocator.

◆ path

◆ polymorphic_allocator

using mdbx::polymorphic_allocator = typedef ::std::pmr::string::allocator_type

Default polymorphic allocator for modern code.

◆ string

template<class ALLOCATOR = legacy_allocator>
using mdbx::string = typedef ::std::basic_string<char, ::std::char_traits<char>, ALLOCATOR>

Default singe-byte string.

◆ version_info

libmdbx version information

Enumeration Type Documentation

◆ key_mode

enum mdbx::key_mode
strong

Kinds of the keys and corresponding modes of comparing it.

Enumerator
usual 

Usual variable length keys with byte-by-byte lexicographic comparison like std::memcmp().

reverse 

Variable length keys with byte-by-byte lexicographic comparison in reverse order, from the end of the keys to the beginning.

ordinal 

Keys are binary integers in native byte order, either uint32_t or uint64_t, and will be sorted as such. The keys must all be of the same size and must be aligned while passing as arguments.

msgpack 

Keys are in MessagePack format with appropriate comparison.

Note
Not yet implemented and PRs are welcome.

◆ loop_control

Loop control constants for readers enumeration functor and other cases.

See also
env::enumerate_readers()
Enumerator
continue_loop 
exit_loop 

◆ put_mode

Key-value pairs put mode.

Enumerator
insert_unique 

Insert only unique keys.

upsert 

Insert or update.

update 

Update existing, don't insert new.

◆ value_mode

enum mdbx::value_mode
strong

Kind of the values and sorted multi-values with corresponding comparison.

Enumerator
single 

Usual single value for each key. In terms of keys, they are unique.

multi 

A more than one data value could be associated with each key. Internally each key is stored once, and the corresponding data values are sorted by byte-by-byte lexicographic comparison like std::memcmp(). In terms of keys, they are not unique, i.e. has duplicates which are sorted by associated data values.

multi_reverse 

A more than one data value could be associated with each key. Internally each key is stored once, and the corresponding data values are sorted by byte-by-byte lexicographic comparison in reverse order, from the end of the keys to the beginning. In terms of keys, they are not unique, i.e. has duplicates which are sorted by associated data values.

multi_samelength 

A more than one data value could be associated with each key, and all data values must be same length. Internally each key is stored once, and the corresponding data values are sorted by byte-by-byte lexicographic comparison like std::memcmp(). In terms of keys, they are not unique, i.e. has duplicates which are sorted by associated data values.

multi_ordinal 

A more than one data value could be associated with each key, and all data values are binary integers in native byte order, either uint32_t or uint64_t, and will be sorted as such. Internally each key is stored once, and the corresponding data values are sorted. In terms of keys, they are not unique, i.e. has duplicates which are sorted by associated data values.

multi_reverse_samelength 

A more than one data value could be associated with each key, and all data values must be same length. Internally each key is stored once, and the corresponding data values are sorted by byte-by-byte lexicographic comparison in reverse order, from the end of the keys to the beginning. In terms of keys, they are not unique, i.e. has duplicates which are sorted by associated data values.

msgpack 

A more than one data value could be associated with each key. Values are in MessagePack format with appropriate comparison. Internally each key is stored once, and the corresponding data values are sorted. In terms of keys, they are not unique, i.e. has duplicates which are sorted by associated data values.

Note
Not yet implemented and PRs are welcome.

Function Documentation

◆ buffer()

template<class ALLOCATOR , typename CAPACITY_POLICY >
template<class ALLOCATOR , typename CAPACITY_POLICY >
mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::buffer ( const txn txn,
const struct slice src,
const allocator_type allocator 
)
inline

◆ cursor() [1/2]

mdbx::cursor::cursor ( cursor &&  other)
inlinenoexcept

◆ cursor() [2/2]

mdbx::cursor::cursor ( MDBX_cursor ptr)
protectednoexcept

◆ env() [1/3]

mdbx::env::env ( env &&  other)
inlinenoexcept

◆ env() [2/3]

mdbx::env::env ( MDBX_env ptr)
protectednoexcept

◆ error()

mdbx::error::error ( MDBX_error_t  error_code)
noexcept

◆ info()

mdbx::map_handle::info::info ( map_handle::flags  flags,
map_handle::state  state 
)
noexcept

◆ move_result() [1/4]

mdbx::cursor::move_result::move_result ( const cursor cursor,
bool  throw_notfound 
)
inline

◆ move_result() [2/4]

mdbx::cursor::move_result::move_result ( cursor cursor,
move_operation  operation,
bool  throw_notfound 
)
inline

◆ move_result() [3/4]

mdbx::cursor::move_result::move_result ( cursor cursor,
move_operation  operation,
const slice key,
bool  throw_notfound 
)
inline

◆ move_result() [4/4]

mdbx::cursor::move_result::move_result ( cursor cursor,
move_operation  operation,
const slice key,
const slice value,
bool  throw_notfound 
)
inline

◆ reader_info()

mdbx::env::reader_info::reader_info ( int  slot,
mdbx_pid_t  pid,
mdbx_tid_t  thread,
uint64_t  txnid,
uint64_t  lag,
size_t  used,
size_t  retained 
)
noexcept

◆ slice() [1/7]

mdbx::slice::slice ( )
noexcept

Create an empty slice.

◆ slice() [2/7]

mdbx::slice::slice ( const char *  c_str)
explicit

Create a slice that refers to c_str[0,strlen(c_str)-1].

◆ slice() [3/7]

mdbx::slice::slice ( const MDBX_val src)

◆ slice() [4/7]

mdbx::slice::slice ( const void *  begin,
const void *  end 
)

Create a slice that refers to [begin,end] of memory bytes.

◆ slice() [5/7]

mdbx::slice::slice ( const void *  ptr,
size_t  bytes 
)

Create a slice that refers to [0,bytes-1] of memory bytes pointed by ptr.

◆ slice() [6/7]

mdbx::slice::slice ( MDBX_val &&  src)

◆ slice() [7/7]

mdbx::slice::slice ( slice &&  src)
noexcept

◆ txn() [1/3]

mdbx::txn::txn ( MDBX_txn ptr)
protectednoexcept

◆ txn() [2/3]

mdbx::txn::txn ( txn &&  other)
inlinenoexcept

◆ ~cursor()

mdbx::cursor::~cursor ( )
inlinenoexcept

◆ ~env()

mdbx::env::~env ( )
inlinenoexcept

◆ ~txn()

mdbx::txn::~txn ( )
inlinenoexcept

◆ alter_flags()

env & mdbx::env::alter_flags ( MDBX_env_flags_t  flags,
bool  on_off 
)
inline

Alter environment flags.

◆ append()

void mdbx::txn::append ( map_handle  map,
const slice key,
const slice value,
bool  multivalue_order_preserved = true 
)
inline

Adding a key-value pair, provided that ascending order of the keys and (optionally) values are preserved.

Instead of splitting the full b+tree pages, the data will be placed on new ones. Thus appending is about two times faster than insertion, and the pages will be filled in completely mostly but not half as after splitting ones. On the other hand, any subsequent insertion or update with an increase in the length of the value will be twice as slow, since it will require splitting already filled pages.

Parameters
[in]mapA map handle to append
[in]keyA key to be append
[in]valueA value to store with the key
[in]multivalue_order_preservedIf multivalue_order_preserved == true then the same rules applied for to pages of nested b+tree of multimap's values.

◆ as_base58_string()

template<class ALLOCATOR >
string< ALLOCATOR > mdbx::slice::as_base58_string ( unsigned  wrap_width = 0,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

Returns a string with a Base58 dump of the slice content.

◆ as_base64_string()

template<class ALLOCATOR >
string< ALLOCATOR > mdbx::slice::as_base64_string ( unsigned  wrap_width = 0,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

Returns a string with a Base58 dump of the slice content.

◆ as_hex_string()

template<class ALLOCATOR >
string< ALLOCATOR > mdbx::slice::as_hex_string ( bool  uppercase = false,
unsigned  wrap_width = 0,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

Returns a string with a hexadecimal dump of the slice content.

◆ assign() [1/7]

slice & mdbx::slice::assign ( ::MDBX_val &&  src)
inline

◆ assign() [2/7]

slice & mdbx::slice::assign ( const ::MDBX_val src)
inline

◆ assign() [3/7]

slice & mdbx::slice::assign ( const char *  c_str)
inline

◆ assign() [4/7]

slice & mdbx::slice::assign ( const slice src)
inlinenoexcept

◆ assign() [5/7]

slice & mdbx::slice::assign ( const void *  begin,
const void *  end 
)
inline

◆ assign() [6/7]

slice & mdbx::slice::assign ( const void *  ptr,
size_t  bytes 
)
inline

◆ assign() [7/7]

slice & mdbx::slice::assign ( slice &&  src)
inlinenoexcept

◆ at()

byte mdbx::slice::at ( size_t  n) const

Returns the nth byte in the referenced data with bounds checking.

Exceptions
std::out_of_rangeif n >= size()

◆ base58_decode()

template<class ALLOCATOR , class CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::base58_decode ( bool  ignore_spaces = false,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

Decodes Base58 dump from the slice content to returned buffer.

◆ base64_decode()

template<class ALLOCATOR , class CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::base64_decode ( bool  ignore_spaces = false,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

Decodes Base64 dump from the slice content to returned buffer.

◆ bind()

void mdbx::cursor::bind ( ::mdbx::txn txn,
::mdbx::map_handle  map_handle 
)
inline

Bind/renew a cursor with a new transaction and specified key-value map handle.

◆ boolean_or_throw()

bool mdbx::error::boolean_or_throw ( int  error_code)
inlinestatic

◆ byte_ptr() [1/2]

const ::mdbx::byte * mdbx::slice::byte_ptr ( ) const
noexcept

Returns casted to pointer to byte an address of data.

◆ byte_ptr() [2/2]

mdbx::byte * mdbx::slice::byte_ptr ( )
noexcept

◆ capture()

void mdbx::exception_thunk::capture ( )
inlinenoexcept

◆ char_ptr() [1/2]

const char * mdbx::slice::char_ptr ( ) const
noexcept

Returns casted to pointer to char an address of data.

◆ char_ptr() [2/2]

char * mdbx::slice::char_ptr ( )
noexcept

◆ check_readers()

unsigned mdbx::env::check_readers ( )
inline

Checks for stale readers in the lock table and return number of cleared slots.

◆ clear()

void mdbx::slice::clear ( )
noexcept

Makes the slice empty and referencing to nothing.

◆ clear_map() [1/2]

bool mdbx::txn::clear_map ( const ::std::string &  name,
bool  throw_if_absent = false 
)
inline
Returns
True if the key-value map existed and was cleared, either false if the key-value map did not exist and there is nothing to clear.

◆ clear_map() [2/2]

void mdbx::txn::clear_map ( map_handle  map)
inline

Clear key-value map.

◆ close_map()

void mdbx::env::close_map ( const map_handle handle)
inline

Close a key-value map (aka sub-database) handle. Normally unnecessary.

Closing a database handle is not necessary, but lets txn::open_map() reuse the handle value. Usually it's better to set a bigger env::operate_parameters::max_maps, unless that value would be large.

Note
Use with care. This call is synchronized via mutex with other calls close_map(), but NOT with other transactions running by other threads. The "next" version of libmdbx (MithrilDB) will solve this issue.

Handles should only be closed if no other threads are going to reference the database handle or one of its cursors any further. Do not close a handle if an existing transaction has modified its database. Doing so can cause misbehavior from database corruption to errors like MDBX_BAD_DBI (since the DB name is gone).

◆ code()

MDBX_error_t mdbx::error::code ( ) const
noexcept

Returns error code.

◆ compare_fast()

intptr_t mdbx::slice::compare_fast ( const slice a,
const slice b 
)
staticnoexcept

Three-way fast non-lexicographically length-based comparison.

Firstly compares length and if it equal then compare content lexicographically.

Returns
value: == 0 if a the same as b; < 0 if a shorter than b, or the same length and lexicographically less than b; > 0 if a longer than b, or the same length and lexicographically great than b.

◆ compare_keys() [1/2]

int mdbx::txn::compare_keys ( map_handle  map,
const pair a,
const pair b 
) const
inlinenoexcept

Compare keys of two pairs according to a particular key-value map (aka sub-database).

◆ compare_keys() [2/2]

int mdbx::txn::compare_keys ( map_handle  map,
const slice a,
const slice b 
) const
inlinenoexcept

Compare two keys according to a particular key-value map (aka sub-database).

◆ compare_lexicographically()

intptr_t mdbx::slice::compare_lexicographically ( const slice a,
const slice b 
)
staticnoexcept

Three-way lexicographically comparison.

Returns
value: == 0 if a lexicographically equal b; < 0 if a lexicographically less than b; > 0 if a lexicographically great than b.

◆ compare_values() [1/2]

int mdbx::txn::compare_values ( map_handle  map,
const pair a,
const pair b 
) const
inlinenoexcept

Compare values of two pairs according to a particular key-value map (aka sub-database).

◆ compare_values() [2/2]

int mdbx::txn::compare_values ( map_handle  map,
const slice a,
const slice b 
) const
inlinenoexcept

Compare two values according to a particular key-value map (aka sub-database).

◆ count_multivalue()

size_t mdbx::cursor::count_multivalue ( ) const
inline

Return count of duplicates for current key.

◆ create_map() [1/2]

mdbx::map_handle mdbx::txn::create_map ( const ::std::string &  name,
const ::mdbx::key_mode  key_mode = ::mdbx::key_mode::usual,
const ::mdbx::value_mode  value_mode = ::mdbx::value_mode::single 
)
inline

Create new or open existing key-value map.

◆ create_map() [2/2]

mdbx::map_handle mdbx::txn::create_map ( const char *  name,
const ::mdbx::key_mode  key_mode = ::mdbx::key_mode::usual,
const ::mdbx::value_mode  value_mode = ::mdbx::value_mode::single 
)
inline

Create new or open existing key-value map.

◆ current()

cursor::move_result mdbx::cursor::current ( bool  throw_notfound = true) const
inline

◆ data() [1/2]

const void * mdbx::slice::data ( ) const
noexcept

Return a pointer to the beginning of the referenced data.

◆ data() [2/2]

void * mdbx::slice::data ( )
noexcept

◆ dbsize_max()

size_t mdbx::env::limits::dbsize_max ( intptr_t  pagesize)
inlinestatic

Returns the maximal database size in bytes for specified page size.

◆ dbsize_min()

size_t mdbx::env::limits::dbsize_min ( intptr_t  pagesize)
inlinestatic

Returns the minimal database size in bytes for specified page size.

◆ drop_map() [1/2]

bool mdbx::txn::drop_map ( const ::std::string &  name,
bool  throw_if_absent = false 
)
inline

Drop key-value map.

Returns
True if the key-value map existed and was deleted, either false if the key-value map did not exist and there is nothing to delete.

◆ drop_map() [2/2]

void mdbx::txn::drop_map ( map_handle  map)
inline

Drops key-value map using handle.

◆ empty()

bool mdbx::slice::empty ( ) const
noexcept

Checks whether the slice is empty.

◆ encode_base58()

template<class ALLOCATOR , class CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::encode_base58 ( unsigned  wrap_width = 0,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

Returns a buffer with a Base58 dump of the slice content.

◆ encode_base64()

template<class ALLOCATOR , class CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::encode_base64 ( unsigned  wrap_width = 0,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

Returns a buffer with a Base64 dump of the slice content.

◆ encode_hex()

template<class ALLOCATOR , class CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::encode_hex ( bool  uppercase = false,
unsigned  wrap_width = 0,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

Returns a buffer with a hexadecimal dump of the slice content.

◆ end() [1/2]

const void * mdbx::slice::end ( ) const
noexcept

Return a pointer to the ending of the referenced data.

◆ end() [2/2]

void * mdbx::slice::end ( )
noexcept

◆ end_byte_ptr() [1/2]

const ::mdbx::byte * mdbx::slice::end_byte_ptr ( ) const
noexcept

Returns casted to pointer to byte an end of data.

◆ end_byte_ptr() [2/2]

mdbx::byte * mdbx::slice::end_byte_ptr ( )
noexcept

◆ end_char_ptr() [1/2]

const char * mdbx::slice::end_char_ptr ( ) const
noexcept

Returns casted to pointer to char an end of data.

◆ end_char_ptr() [2/2]

char * mdbx::slice::end_char_ptr ( )
noexcept

◆ ends_with()

bool mdbx::slice::ends_with ( const slice suffix) const
noexcept

Checks if the data ends with the given suffix.

◆ enumerate_readers()

template<typename VISITOR >
int mdbx::env::enumerate_readers ( VISITOR &  visitor)
inline

Enumerate readers.

The VISITOR class must have int operator(const reader_info&, int serial) which should return continue_loop (zero) to continue enumeration, or any non-zero value to exit.

Returns
The last value returned from visitor' functor.

◆ env() [3/3]

mdbx::env mdbx::txn::env ( ) const
inlinenoexcept

Returns the transaction's environment.

◆ eof()

bool mdbx::cursor::eof ( ) const
inline

◆ erase() [1/5]

bool mdbx::cursor::erase ( bool  whole_multivalue = false)
inline

Removes single key-value pair or all multi-values at the current cursor position.

◆ erase() [2/5]

bool mdbx::cursor::erase ( const slice key,
bool  whole_multivalue = true 
)
inline

Seeks and removes first value or whole multi-value of the given key.

Returns
True if the key is found and a value(s) is removed.

◆ erase() [3/5]

bool mdbx::cursor::erase ( const slice key,
const slice value 
)
inline

Seeks and removes the particular multi-value entry of the key.

Returns
True if the given key-value pair is found and removed.

◆ erase() [4/5]

bool mdbx::txn::erase ( map_handle  map,
const slice key 
)
inline

Removes all values for given key.

◆ erase() [5/5]

bool mdbx::txn::erase (