A fast and reliable embedded key-value ACID storage engine without WAL.
Version 0.14.3.9 (2026-08-13T13:36:35+03:00)
Loading...
Searching...
No Matches
Environment, Transactions, Cursors, Key-value tables and map handles

Classes

class  mdbx::cache_entry
 Cache entry for get-cached API (initial draft). More...
struct  mdbx::map_handle
 A handle for an individual table (aka key-value space, maps or sub-database) 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...

Typedefs

using mdbx::comparator = ::MDBX_cmp_func

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::key_mode::usual = MDBX_DB_DEFAULTS , mdbx::key_mode::reverse = MDBX_REVERSEKEY , mdbx::key_mode::ordinal = MDBX_INTEGERKEY , mdbx::key_mode::msgpack = -1 }
 Kinds of the keys and corresponding modes of comparing it. More...
enum class  mdbx::value_mode {
  mdbx::value_mode::single = MDBX_DB_DEFAULTS , mdbx::value_mode::multi = MDBX_DUPSORT , mdbx::value_mode::multi_reverse = MDBX_DUPSORT | MDBX_REVERSEDUP , mdbx::value_mode::multi_samelength = MDBX_DUPSORT | MDBX_DUPFIXED ,
  mdbx::value_mode::multi_ordinal = MDBX_DUPSORT | MDBX_DUPFIXED | MDBX_INTEGERDUP , mdbx::value_mode::multi_reverse_samelength , mdbx::value_mode::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

MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_usual (key_mode mode) noexcept
MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_ordinal (key_mode mode) noexcept
MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_samelength (key_mode mode) noexcept
MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_reverse (key_mode mode) noexcept
MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_msgpack (key_mode mode) noexcept
MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_usual (value_mode mode) noexcept
MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_multi (value_mode mode) noexcept
MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_ordinal (value_mode mode) noexcept
MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_samelength (value_mode mode) noexcept
MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_reverse (value_mode mode) noexcept
MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_msgpack (value_mode mode) noexcept
comparator mdbx::default_comparator (key_mode mode) noexcept
comparator mdbx::default_comparator (value_mode mode) noexcept

Detailed Description


Class Documentation

◆ mdbx::cache_entry

class mdbx::cache_entry

Cache entry for get-cached API (initial draft).

Inherits MDBX_cache_entry_t.

Public Member Functions

 cache_entry () noexcept
 cache_entry (const cache_entry &) noexcept=default
cache_entryoperator= (const cache_entry &) noexcept=default
 cache_entry (cache_entry &&other) noexcept
void reset () noexcept
constexpr cache_entry (const MDBX_cache_entry_t &ce) noexcept
constexpr cache_entryoperator= (const MDBX_cache_entry_t &ce) noexcept

Additional Inherited Members

Public Attributes inherited from MDBX_cache_entry_t
uint64_t trunk_txnid
uint64_t last_confirmed_txnid
size_t offset
uint32_t length

Constructor & Destructor Documentation

◆ cache_entry() [1/4]

mdbx::cache_entry::cache_entry ( )
inlinenoexcept

◆ cache_entry() [2/4]

mdbx::cache_entry::cache_entry ( const cache_entry & )
defaultnoexcept

◆ cache_entry() [3/4]

mdbx::cache_entry::cache_entry ( cache_entry && other)
inlinenoexcept

◆ cache_entry() [4/4]

mdbx::cache_entry::cache_entry ( const MDBX_cache_entry_t & ce)
inlineconstexprnoexcept

Member Function Documentation

◆ operator=() [1/2]

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

◆ operator=() [2/2]

cache_entry & mdbx::cache_entry::operator= ( const MDBX_cache_entry_t & ce)
inlineconstexprnoexcept

◆ reset()

void mdbx::cache_entry::reset ( )
inlinenoexcept

◆ mdbx::map_handle

struct mdbx::map_handle

A handle for an individual table (aka key-value space, maps or sub-database) in the environment.

See also
txn::open_map()
txn::create_map()
txn::clear_map()
txn::drop_map()
txn::get_map_flags()
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

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

Public Attributes

MDBX_dbi dbi {0}

Friends

constexpr bool operator== (const map_handle &a, const map_handle &b) noexcept
constexpr bool operator< (const map_handle &a, const map_handle &b) noexcept
constexpr bool operator> (const map_handle &a, const map_handle &b) noexcept
constexpr bool operator<= (const map_handle &a, const map_handle &b) noexcept
constexpr bool operator>= (const map_handle &a, const map_handle &b) noexcept
constexpr bool operator!= (const map_handle &a, const map_handle &b) noexcept

Member Typedef Documentation

◆ flags

◆ state

Constructor & Destructor Documentation

◆ map_handle() [1/3]

mdbx::map_handle::map_handle ( )
inlineconstexprnoexcept

◆ map_handle() [2/3]

mdbx::map_handle::map_handle ( MDBX_dbi dbi)
inlineconstexprnoexcept

◆ map_handle() [3/3]

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

Member Function Documentation

◆ operator MDBX_dbi()

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

◆ operator=()

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

◆ operator!=

bool operator!= ( const map_handle & a,
const map_handle & b )
friend

◆ operator<

bool operator< ( const map_handle & a,
const map_handle & b )
friend

◆ operator<=

bool operator<= ( const map_handle & a,
const map_handle & b )
friend

◆ operator==

bool operator== ( const map_handle & a,
const map_handle & b )
friend

◆ operator>

bool operator> ( const map_handle & a,
const map_handle & b )
friend

◆ operator>=

bool operator>= ( const map_handle & a,
const map_handle & b )
friend

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 handles as a values, but does not manage nor destroys the represented underlying object from the own class destructor.

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

Inherited by mdbx::env_managed.

Public Types

enum  mode { readonly , write_file_io , write_mapped_io , nested_transactions = write_file_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...
enum class  extra_runtime_option {
  max_maps = MDBX_opt_max_db , max_readers = MDBX_opt_max_readers , sync_bytes = MDBX_opt_sync_bytes , sync_period = MDBX_opt_sync_period ,
  rp_augment_limit = MDBX_opt_rp_augment_limit , loose_limit = MDBX_opt_loose_limit , dp_reserve_limit = MDBX_opt_dp_reserve_limit , dp_limit = MDBX_opt_txn_dp_limit ,
  dp_initial = MDBX_opt_txn_dp_initial , spill_max_denominator = MDBX_opt_spill_max_denominator , spill_min_denominator = MDBX_opt_spill_min_denominator , spill_parent4child_denominator = MDBX_opt_spill_parent4child_denominator ,
  merge_threshold_dot16 = MDBX_opt_merge_threshold , writethrough_threshold = MDBX_opt_writethrough_threshold , prefault_write_enable = MDBX_opt_prefault_write_enable , gc_time_limit = MDBX_opt_gc_time_limit ,
  prefer_waf_insteadof_balance = MDBX_opt_prefer_waf_insteadof_balance , subpage_limit = MDBX_opt_subpage_limit , subpage_room_threshold = MDBX_opt_subpage_room_threshold , subpage_reserve_prereq = MDBX_opt_subpage_reserve_prereq ,
  subpage_reserve_limit = MDBX_opt_subpage_reserve_limit , split_reserve = MDBX_opt_split_reserve , presync_threshold = MDBX_opt_presync_threshold
}
 MDBX environment extra runtime options. More...
using stat = ::MDBX_stat
 Statistics for a database in the MDBX environment.
using info = ::MDBX_envinfo
 Information about the environment.

Public Member Functions

constexpr env () noexcept=default
 env (const env &) noexcept=default
envoperator= (const env &) noexcept=default
envoperator= (env &&) noexcept
 env (env &&) noexcept
 ~env () noexcept
constexpr operator const MDBX_env * () const noexcept
constexpr operator MDBX_env * () noexcept
constexpr const MDBX_envhandle () const noexcept
constexpr MDBX_envhandle () noexcept
env::operate_parameters get_operation_parameters () const
 Returns current operation parameters.
env::mode get_mode () const
 Returns current operation mode.
env::durability get_durability () const
 Returns current durability mode.
env::reclaiming_options get_reclaiming () const
 Returns current reclaiming options.
env::operate_options get_options () const
 Returns current operate options.
bool is_pristine () const
 Returns true for a freshly created database, but false if at least one transaction was committed.
bool is_empty () const
 Checks whether the database is empty.
size_t dbsize_min () const
 Returns the minimal database size in bytes for the environment.
size_t dbsize_max () const
 Returns the maximal database size in bytes for the environment.
size_t key_min (key_mode mode) const noexcept
 Returns the minimal key size in bytes for specified keys mode.
size_t key_max (key_mode mode) const
 Returns the maximal key size in bytes for specified keys mode.
size_t value_min (value_mode mode) const noexcept
 Returns the minimal value size in bytes for specified values mode.
size_t value_max (value_mode mode) const
 Returns the maximal value size in bytes for specified values mode.
size_t transaction_size_max () const
 Returns the maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes.
envcopy (const ::mdbx::filesystem::path &destination, bool compactify, bool force_dynamic_size=false)
 Make a copy (backup) of an existing environment to the specified path.
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.
stat get_stat () const
 Returns snapshot statistics about the MDBX environment.
size_t get_pagesize () const
 Returns pagesize of this MDBX environment.
info get_info () const
 Return snapshot information about the MDBX environment.
stat get_stat (const txn &) const
 Return statistics about the MDBX environment accordingly to the specified transaction.
info get_info (const txn &) const
 Return information about the MDBX environment accordingly to the specified transaction.
filehandle get_filehandle () const
 Returns the file descriptor for the DXB file of MDBX environment.
const path_charget_path () const
 Return the path that was used for opening the environment.
MDBX_env_flags_t get_flags () const
 Returns environment flags.
bool is_readonly () const
bool is_exclusive () const
bool is_cooperative () const
bool is_writemap () const
bool is_readwrite () const
bool is_nested_transactions_available () const
unsigned max_readers () const
 Returns the maximum number of threads/reader slots for the environment.
unsigned max_maps () const
 Returns the maximum number of named tables for the environment.
void * get_context () const noexcept
 Returns the application context associated with the environment.
envset_context (void *your_context)
 Sets the application context associated with the environment.
envset_sync_threshold (size_t bytes)
 Sets threshold to force flush the data buffers to disk, for non-sync durability modes.
size_t sync_threshold () const
 Gets threshold used to force flush the data buffers to disk, for non-sync durability modes.
envset_sync_period (const duration &period)
 Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes.
duration sync_period () const
 Gets relative period since the last unsteady commit that used to force flush the data buffers to disk, for non-sync durability modes.
envset_sync_period__seconds_16dot16 (unsigned seconds_16dot16)
 Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes.
unsigned sync_period__seconds_16dot16 () const
 Gets relative period since the last unsteady commit that used to force flush the data buffers to disk, for non-sync durability modes.
envset_sync_period__seconds_double (double seconds)
 Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes.
double sync_period__seconds_double () const
 Gets relative period since the last unsteady commit that used to force flush the data buffers to disk, for non-sync durability modes.
envset_extra_option (extra_runtime_option option, uint64_t value)
 Sets the value of a extra runtime options for an environment.
uint64_t extra_option (extra_runtime_option option) const
 Gets the value of extra runtime options from an environment.
envalter_flags (MDBX_env_flags_t flags, bool on_off)
 Alter environment flags.
envset_geometry (const geometry &size)
 Set all size-related parameters of environment.
bool sync_to_disk (bool force=true, bool nonblock=false)
 Flush the environment data buffers.
bool poll_sync_to_disk ()
 Performs non-blocking polling of sync-to-disk thresholds.
void close_map (const map_handle &)
 Close a key-value map (aka table) handle. Normally unnecessary.
template<typename VISITOR>
int enumerate_readers (VISITOR &visitor)
 Enumerate readers.
unsigned check_readers ()
 Checks for stale readers in the lock table and return number of cleared slots.
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.
MDBX_hsr_func 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.
txn_managed start_read () const
 Starts read (read-only) transaction.
txn_managed prepare_read () const
 Creates but not start read transaction.
txn_managed start_write (txn &parent)
 Starts write (read-write) transaction.
txn_managed start_write (bool dont_wait=false)
 Starts write (read-write) transaction.
txn_managed try_start_write ()
 Tries to start write (read-write) transaction without blocking.

Static Public Member Functions

static size_t default_pagesize () noexcept
 Returns default page size for current system/platform.
static bool remove (const ::mdbx::filesystem::path &pathname, const remove_mode mode=just_remove)
 Removes the environment's files in a proper and multiprocess-safe way.
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

constexpr env (MDBX_env *ptr) noexcept

Protected Attributes

MDBX_envhandle_ {nullptr}

Friends

class txn
constexpr bool operator== (const env &a, const env &b) noexcept
constexpr 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 ensures 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 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

◆ extra_runtime_option

MDBX environment extra runtime options.

See also
mdbx_env_set_option()
mdbx_env_get_option()
Enumerator
max_maps 

Controls the maximum number of named tables for the environment.

By default only unnamed key-value table could used and appropriate value should set by MDBX_opt_max_db to using any more named table(s). To reduce overhead, use the minimum sufficient value. This option may only set after mdbx_env_create() and before mdbx_env_open().

See also
mdbx_env_set_maxdbs()
mdbx_env_get_maxdbs()
max_maps()
env::operate_parameters::max_maps
max_readers 

Defines the maximum number of threads/reader slots for all processes interacting with the database.

This defines the number of slots in the lock table that is used to track readers in the environment. The default is about 100 for 4K system page size. Starting a read-only transaction normally ties a lock table slot to the current thread until the environment closes or the thread exits. If MDBX_NOSTICKYTHREADS is in use, mdbx_txn_begin() instead ties the slot to the MDBX_txn object until it or the MDBX_env object is destroyed. This option may only set after mdbx_env_create() and before mdbx_env_open(), and has an effect only when the database is opened by the first process interacts with the database.

See also
mdbx_env_set_maxreaders()
mdbx_env_get_maxreaders()
max_readers()
env::operate_parameters::max_readers
sync_bytes 

Controls interprocess/shared threshold to force flush the data buffers to disk, if MDBX_SAFE_NOSYNC is used.

See also
mdbx_env_set_syncbytes()
mdbx_env_get_syncbytes()
sync_threshold()
set_sync_threshold()
sync_period 

Controls interprocess/shared relative period since the last unsteady commit to force flush the data buffers to disk, if MDBX_SAFE_NOSYNC is used.

See also
mdbx_env_set_syncperiod()
mdbx_env_get_syncperiod()
sync_period()
set_sync_period()
rp_augment_limit 

Controls the in-process limit to grow a list of reclaimed/recycled page's numbers for finding a sequence of contiguous pages for large data items.

See also
MDBX_opt_gc_time_limit

A long values requires allocation of contiguous database pages. To find such sequences, it may be necessary to accumulate very large lists, especially when placing very long values (more than a megabyte) in a large databases (several tens of gigabytes), which is much expensive in extreme cases. This threshold allows you to avoid such costs by allocating new pages at the end of the database (with its possible growth on disk), instead of further accumulating/reclaiming Garbage Collection records.

On the other hand, too small threshold will lead to unreasonable database growth, or/and to the inability of put long values.

The MDBX_opt_rp_augment_limit controls described limit for the current process. By default this limit adjusted dynamically to 1/3 of current quantity of DB pages, which is usually enough for most cases.

loose_limit 

Controls the in-process limit to grow a cache of dirty pages for reuse in the current transaction.

A dirty page refers to a page that has been updated in memory only, the changes to a dirty page are not yet stored on disk. To reduce overhead, it is reasonable to release not all such pages immediately, but to leave some ones in cache for reuse in the current transaction.

The MDBX_opt_loose_limit allows you to set a limit for such cache inside the current process. Should be in the range 0..255, default is 64.

dp_reserve_limit 

Controls the in-process limit of a pre-allocated memory items for dirty pages.

A dirty page refers to a page that has been updated in memory only, the changes to a dirty page are not yet stored on disk. Without MDBX_WRITEMAP dirty pages are allocated from memory and released when a transaction is committed. To reduce overhead, it is reasonable to release not all ones, but to leave some allocations in reserve for reuse in the next transaction(s).

The MDBX_opt_dp_reserve_limit allows you to set a limit for such reserve inside the current process. Default is 1024.

dp_limit 

Controls the in-process limit of dirty pages for a write transaction.

A dirty page refers to a page that has been updated in memory only, the changes to a dirty page are not yet stored on disk. Without MDBX_WRITEMAP dirty pages are allocated from memory and will be busy until are written to disk. Therefore for a large transactions is reasonable to limit dirty pages collecting above an some threshold but spill to disk instead.

The MDBX_opt_txn_dp_limit controls described threshold for the current process. Default is 1/42 of the sum of whole and currently available RAM size, which the same ones are reported by mdbx_get_sysraminfo().

dp_initial 

Controls the in-process initial allocation size for dirty pages list of a write transaction. Default is 1024.

spill_max_denominator 

Controls the in-process how maximal part of the dirty pages may be spilled when necessary.

The MDBX_opt_spill_max_denominator defines the denominator for limiting from the top for part of the current dirty pages may be spilled when the free room for a new dirty pages (i.e. distance to the MDBX_opt_txn_dp_limit threshold) is not enough to perform requested operation. Exactly max_pages_to_spill = dirty_pages - dirty_pages / N, where N is the value set by MDBX_opt_spill_max_denominator.

Should be in the range 0..255, where zero means no limit, i.e. all dirty pages could be spilled. Default is 8, i.e. no more than 7/8 of the current dirty pages may be spilled when reached the condition described above.

spill_min_denominator 

Controls the in-process how minimal part of the dirty pages should be spilled when necessary.

The MDBX_opt_spill_min_denominator defines the denominator for limiting from the bottom for part of the current dirty pages should be spilled when the free room for a new dirty pages (i.e. distance to the MDBX_opt_txn_dp_limit threshold) is not enough to perform requested operation. Exactly min_pages_to_spill = dirty_pages / N, where N is the value set by MDBX_opt_spill_min_denominator.

Should be in the range 0..255, where zero means no restriction at the bottom. Default is 8, i.e. at least the 1/8 of the current dirty pages should be spilled when reached the condition described above.

spill_parent4child_denominator 

Controls the in-process how much of the parent transaction dirty pages will be spilled while start each child transaction.

The MDBX_opt_spill_parent4child_denominator defines the denominator to determine how much of parent transaction dirty pages will be spilled explicitly while start each child transaction. Exactly pages_to_spill = dirty_pages / N, where N is the value set by MDBX_opt_spill_parent4child_denominator.

For a stack of nested transactions each dirty page could be spilled only once, and parent's dirty pages couldn't be spilled while child transaction(s) are running. Therefore a child transaction could reach MDBX_TXN_FULL when parent(s) transaction has spilled too less (and child reach the limit of dirty pages), either when parent(s) has spilled too more (since child can't spill already spilled pages). So there is no universal golden ratio.

Should be in the range 0..255, where zero means no explicit spilling will be performed during starting nested transactions. Default is 0, i.e. by default no spilling performed during starting nested transactions, that correspond historically behaviour.

merge_threshold_dot16 

Controls the in-process threshold of semi-empty pages merge.

This option controls the in-process threshold of minimum page fill, as used space of percentage of a page. Neighbour pages emptier than this value are candidates for merging. The threshold value is specified in 1/65536 points of a whole page, which is equivalent to the 16-dot-16 fixed point format. The specified value must be in the range from 12.5% (almost empty page) to 50% (half empty page) which corresponds to the range from 8192 and to 32768 in units respectively.

See also
MDBX_opt_prefer_waf_insteadof_balance
writethrough_threshold 

Controls the choosing between use write-through disk writes and usual ones with followed flush by the fdatasync() syscall.

Depending on the operating system, storage subsystem characteristics and the use case, higher performance can be achieved by either using write-through or a serie of usual/lazy writes followed by the flush-to-disk.

Basically for N chunks the latency/cost of write-through is: latency = N * (emit_cost + round-trip-to-storage + storage-execution); And for serie of lazy writes with flush is: latency = N * (emit_cost + storage-execution) + flush_cost + round-trip-to-storage.

So, for large N and/or noteable round-trip-to-storage the write+flush approach is win. But for small N and/or near-zero NVMe-like latency the write-through is better.

To solve this issue libmdbx provide MDBX_opt_writethrough_threshold:

  • when N described above less or equal specified threshold, a write-through approach will be used;
  • otherwise, when N great than specified threshold, a write-and-flush approach will be used.
Note
MDBX_opt_writethrough_threshold affects only MDBX_SYNC_DURABLE mode without MDBX_WRITEMAP, and not supported on Windows. On Windows a write-through is used always but MDBX_NOMETASYNC could be used for switching to write-and-flush.
prefault_write_enable 

Controls prevention of page-faults of reclaimed and allocated pages in the MDBX_WRITEMAP mode by clearing ones through file handle before touching.

gc_time_limit 

Controls the in-process spending time limit of searching consecutive pages inside GC.

See also
MDBX_opt_rp_augment_limit

Sets the time limit in 1/65536 fractions of a second that can be spent during a writing transaction searching for page sequences inside GC/freelist after reaching the limit set by the MDBX_opt_rp_augment_limit option. Time control is not performed when searching/allocating single pages and allocating pages to the needs of the GC (when updating the GC during transaction commit).

The set time limit is calculated according to the "wall clock" and is controlled within a transaction, inherited for nested transactions and accumulated in a parent when ones are finished. Time control is performed only when the limit set by the MDBX_opt_rp_augment_limit option is reached. This allows you to flexibly control the behavior using both options.

By default, the limit is set to 0, which immediately stops the GC search when MDBX_opt_rp_augment_limit is reached in the internal state of the transaction and corresponds to the behavior until the MDBX_opt_gc_time_limit option appears. On the other hand, with the minimum value (including 0) of MDBX_opt_rp_augment_limit, GC processing will be limited mainly by a time spent.

prefer_waf_insteadof_balance 

Controls the choice between striving for uniformity of page filling/density, either for reducing the number of modified and written-to-filesystem pages.

After deletion operations, pages containing less than the minimum number of keys, or those emptied before MDBX_opt_merge_threshold, must be merged with one of the neighboring ones. If a pages to the right and left of the current one are both "dirty" (it were modified during the transaction and must be written to filesystem) or both are "clean" (it were not changed in the current transaction), then the less populated page is always chosen as the target for merging. When only one of the neighboring ones is "dirty" and the other is "clean", then two tactics of choosing a target for merging are possible:

  • If MDBX_opt_prefer_waf_insteadof_balance = True, then an already modified page will be selected, which will NOT INCREASE the number of modified pages and the amount of writing to filesystem when the current transaction is committed (aka WAF or Write Amplification Factor), but on average will INCREASE the unevenness of page filling/density. This is the default behaviour since 2026-01-04.
  • If MDBX_opt_prefer_waf_insteadof_balance = False, then a less populated page will be selected, which will INCREASE the number of modified pages and the amount of writing to filesystem when the current transaction is committed, but on average it will REDUCE the unevenness of pages filling/density.
See also
MDBX_opt_merge_threshold
subpage_limit 

Specifies the maximum size of nested pages used to accommodate a small number of multi-values associated with a single key.

Using nested pages, instead of putting values on separate pages of a nested tree, allows to reduce the amount of unused space and thereby increase the density of data placement.

On the other hand, as the size of a nested pages increases, more leaf pages of a main tree are required, which also increases the height of a main tree. In addition, changing data on nested pages requires additional copies, so the cost may be higher in many scenarios.

The option value is specified in units of 1/65536 of the page size: minimal 0% (0), maximal 100% (65535), default is 100% (65535).

subpage_room_threshold 

Sets the minimum amount of free space on a leaf page in the absence of which the nested pages are placed in a separate tree.

The option value is specified in units of 1/65536 of the page size: minimal 0, maximal 100% (65535), default is 0.

subpage_reserve_prereq 

Sets the minimum amount of free space on the main page, if available, to reserve space in the subpage.

If there is not enough free space on a leaf page, then the nested page will be the minimum size. In turn, if there is no reserve in the nested page, each addition of elements to it will require the reform of a leaf page with transfer of all data nodes.

Therefore, reserving space is usually advantageous in scenarios with intensive addition of short multi-values, such as indexing. But it reduces the density of data placement, respectively, it increases the volume of databases and I/O operations.

The option value is specified in units of 1/65536 of the page size: minimal 0, maximal 100% (65535), default is 42% (27525).

subpage_reserve_limit 

Sets the limit for reserving space on nested pages.

The option value is specified in units of 1/65536 of the page size: minimal 0, maximal 100% (65535), default is 4.2% (2753).

split_reserve 

Sets the space reservation in 1/65536 of page size when splitting page along the edge.

By default, pages are split along the edges when multiple entries are inserted strictly in ascending or descending (in reverse) order, as this leads to dense page filling in the case of mass ordered inserts and, consequently, to a smaller increase in the size of the database. For example, when loading data from a dump or an ordered external source, the most dense filling of the pages and the minimum size of the database will be ensured. However, with such dense padding, any subsequent inserts will require splitting pages immediately, which will lead to a doubling of ones, an increase in database size, and a decrease in performance. In other words, initially dense padding greatly slows down subsequent inserts, as it requires splitting each database page.

This option allows you to set additional space in % of the page size, which will be reserved when splitting the page, which helps to smooth out the effect described above of slowing down subsequent inserts:

  • with the minimum/zero value, the most densely filled pages will be formed during a mass ordered inserts;
  • with the maximum/32768 (means the 50% reservation), a pages will be split in the middle, not on the edge.

Thus this option also allows to minor manage the trade-off between volume and balance of the b-tree forming while inserting data.

The option value is specified in units of 1/65536 of the page size: minimal 0, maximal 50% (32768), default is 0.

presync_threshold 

Sets threshold in bytes for preliminary flush/sync operation without holding a transaction lock.

A preparatory data flush/sync operation could be performed if mdbx_env_sync_poll() or mdbx_env_sync_ex() from a thread that does not own the write transaction. Such a preliminary operation will push the bulk of the data to disk, which will significantly reduce the time to complete the final stage of flush/sync and update metadata that requires holding the lock.

This option sets the volume threshold in bytes of non-synced-to disk data, when exceeded, a pre-sync/flush operation is performed. A too large threshold will increase the latency spikes, but a too small will increase number of flush/sync operations and corresponding overheads.

See also
mdbx_env_sync_poll()
mdbx_env_sync_ex()
MDBX_opt_sync_bytes
MDBX_opt_sync_period

The option value is specified in bytes: minimal 1, maximal 2147483648 (2 GiB), default is 256 KiB.

◆ 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.

nested_transactions 

◆ 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 ( )
constexprdefaultnoexcept

◆ env() [2/2]

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

Member Function Documentation

◆ copy() [1/6]

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

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

◆ copy() [2/6]

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

◆ copy() [3/6]

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

◆ copy() [4/6]

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

◆ 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()

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()

const path_char * mdbx::env::get_path ( ) const

Return the path that was used for opening the environment.

◆ handle() [1/2]

const MDBX_env * mdbx::env::handle ( ) const
inlineconstexprnoexcept

◆ handle() [2/2]

MDBX_env * mdbx::env::handle ( )
inlineconstexprnoexcept

◆ is_cooperative()

bool mdbx::env::is_cooperative ( ) const
inline

◆ is_empty()

bool mdbx::env::is_empty ( ) const

Checks whether the database is empty.

◆ is_exclusive()

bool mdbx::env::is_exclusive ( ) const
inline

◆ is_nested_transactions_available()

bool mdbx::env::is_nested_transactions_available ( ) const
inline

◆ is_pristine()

bool mdbx::env::is_pristine ( ) const

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

◆ is_readonly()

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

◆ is_readwrite()

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

◆ is_writemap()

bool mdbx::env::is_writemap ( ) const
inline

◆ 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.

◆ operator const MDBX_env *()

mdbx::env::operator const MDBX_env * ( ) const
inlineconstexprnoexcept

◆ operator MDBX_env *()

mdbx::env::operator MDBX_env * ( )
inlineconstexprnoexcept

◆ operator=()

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

◆ 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]

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

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

◆ remove() [2/5]

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

◆ remove() [3/5]

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

◆ remove() [4/5]

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

◆ remove() [5/5]

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

◆ set_sync_period()

env & mdbx::env::set_sync_period ( const duration & period)
inline

Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes.

The relative period value affects all processes which operates with given environment until the last process close environment or a new value will be settled. Data is always written to disk when txn_managed::commit() is called, but the operating system may keep it buffered. MDBX always flushes the OS buffers upon commit as well, unless the environment was opened with whole_fragile, lazy_weak_tail or in part half_synchronous_weak_last. Settled period don't checked asynchronously, but only by the txn_managed::commit() and env::sync_to_disk() functions. Therefore, in cases where transactions are committed infrequently and/or irregularly, polling by env::poll_sync_to_disk() may be a reasonable solution to timeout enforcement.

The default is 0, than mean no any timeout checked, and no additional flush will be made.

See also
extra_runtime_option::sync_period

◆ sync_period()

duration mdbx::env::sync_period ( ) const
inline

Gets relative period since the last unsteady commit that used to force flush the data buffers to disk, for non-sync durability modes.

The relative period value affects all processes which operates with given environment until the last process close environment or a new value will be settled. Data is always written to disk when txn_managed::commit() is called, but the operating system may keep it buffered. MDBX always flushes the OS buffers upon commit as well, unless the environment was opened with whole_fragile, lazy_weak_tail or in part half_synchronous_weak_last. Settled period don't checked asynchronously, but only by the txn_managed::commit() and env::sync_to_disk() functions. Therefore, in cases where transactions are committed infrequently and/or irregularly, polling by env::poll_sync_to_disk() may be a reasonable solution to timeout enforcement.

The default is 0, than mean no any timeout checked, and no additional flush will be made.

See also
extra_runtime_option::sync_period
set_sync_period(const duration&)
extra_runtime_option::sync_period

◆ 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.

◆ 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 tables (aka key-value spaces or maps), all residing in the same shared-memory mapped file.

Inherits mdbx::env.

Public Member Functions

constexpr env_managed () noexcept=default
 env_managed (const ::mdbx::filesystem::path &pathname, const operate_parameters &, bool accede=true)
 Open existing database.
 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::filesystem::path &pathname, const create_parameters &, const operate_parameters &, bool accede=true)
 Create new or open existing database.
 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.
 env_managed (env_managed &&)=default
env_managed & operator= (env_managed &&other) noexcept
 env_managed (const env_managed &)=delete
env_managed & operator= (const env_managed &)=delete
virtual ~env_managed ()
Public Member Functions inherited from mdbx::env
constexpr env () noexcept=default
 env (const env &) noexcept=default
envoperator= (const env &) noexcept=default
envoperator= (env &&) noexcept
 env (env &&) noexcept
 ~env () noexcept
constexpr operator const MDBX_env * () const noexcept
constexpr operator MDBX_env * () noexcept
constexpr const MDBX_envhandle () const noexcept
constexpr MDBX_envhandle () noexcept
env::operate_parameters get_operation_parameters () const
 Returns current operation parameters.
env::mode get_mode () const
 Returns current operation mode.
env::durability get_durability () const
 Returns current durability mode.
env::reclaiming_options get_reclaiming () const
 Returns current reclaiming options.
env::operate_options get_options () const
 Returns current operate options.
bool is_pristine () const
 Returns true for a freshly created database, but false if at least one transaction was committed.
bool is_empty () const
 Checks whether the database is empty.
size_t dbsize_min () const
 Returns the minimal database size in bytes for the environment.
size_t dbsize_max () const
 Returns the maximal database size in bytes for the environment.
size_t key_min (key_mode mode) const noexcept
 Returns the minimal key size in bytes for specified keys mode.
size_t key_max (key_mode mode) const
 Returns the maximal key size in bytes for specified keys mode.
size_t value_min (value_mode mode) const noexcept
 Returns the minimal value size in bytes for specified values mode.
size_t value_max (value_mode mode) const
 Returns the maximal value size in bytes for specified values mode.
size_t transaction_size_max () const
 Returns the maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes.
envcopy (const ::mdbx::filesystem::path &destination, bool compactify, bool force_dynamic_size=false)
 Make a copy (backup) of an existing environment to the specified path.
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.
stat get_stat () const
 Returns snapshot statistics about the MDBX environment.
size_t get_pagesize () const
 Returns pagesize of this MDBX environment.
info get_info () const
 Return snapshot information about the MDBX environment.
stat get_stat (const txn &) const
 Return statistics about the MDBX environment accordingly to the specified transaction.
info get_info (const txn &) const
 Return information about the MDBX environment accordingly to the specified transaction.
filehandle get_filehandle () const
 Returns the file descriptor for the DXB file of MDBX environment.
const path_charget_path () const
 Return the path that was used for opening the environment.
MDBX_env_flags_t get_flags () const
 Returns environment flags.
bool is_readonly () const
bool is_exclusive () const
bool is_cooperative () const
bool is_writemap () const
bool is_readwrite () const
bool is_nested_transactions_available () const
unsigned max_readers () const
 Returns the maximum number of threads/reader slots for the environment.
unsigned max_maps () const
 Returns the maximum number of named tables for the environment.
void * get_context () const noexcept
 Returns the application context associated with the environment.
envset_context (void *your_context)
 Sets the application context associated with the environment.
envset_sync_threshold (size_t bytes)
 Sets threshold to force flush the data buffers to disk, for non-sync durability modes.
size_t sync_threshold () const
 Gets threshold used to force flush the data buffers to disk, for non-sync durability modes.
envset_sync_period (const duration &period)
 Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes.
duration sync_period () const
 Gets relative period since the last unsteady commit that used to force flush the data buffers to disk, for non-sync durability modes.
envset_sync_period__seconds_16dot16 (unsigned seconds_16dot16)
 Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes.
unsigned sync_period__seconds_16dot16 () const
 Gets relative period since the last unsteady commit that used to force flush the data buffers to disk, for non-sync durability modes.
envset_sync_period__seconds_double (double seconds)
 Sets relative period since the last unsteady commit to force flush the data buffers to disk, for non-sync durability modes.
double sync_period__seconds_double () const
 Gets relative period since the last unsteady commit that used to force flush the data buffers to disk, for non-sync durability modes.
envset_extra_option (extra_runtime_option option, uint64_t value)
 Sets the value of a extra runtime options for an environment.
uint64_t extra_option (extra_runtime_option option) const
 Gets the value of extra runtime options from an environment.
envalter_flags (MDBX_env_flags_t flags, bool on_off)
 Alter environment flags.
envset_geometry (const geometry &size)
 Set all size-related parameters of environment.
bool sync_to_disk (bool force=true, bool nonblock=false)
 Flush the environment data buffers.
bool poll_sync_to_disk ()
 Performs non-blocking polling of sync-to-disk thresholds.
void close_map (const map_handle &)
 Close a key-value map (aka table) handle. Normally unnecessary.
template<typename VISITOR>
int enumerate_readers (VISITOR &visitor)
 Enumerate readers.
unsigned check_readers ()
 Checks for stale readers in the lock table and return number of cleared slots.
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.
MDBX_hsr_func 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.
txn_managed start_read () const
 Starts read (read-only) transaction.
txn_managed prepare_read () const
 Creates but not start read transaction.
txn_managed start_write (txn &parent)
 Starts write (read-write) transaction.
txn_managed start_write (bool dont_wait=false)
 Starts write (read-write) transaction.
txn_managed try_start_write ()
 Tries to start write (read-write) transaction without blocking.

Additional Inherited Members

Public Types inherited from mdbx::env
enum  mode { readonly , write_file_io , write_mapped_io , nested_transactions = write_file_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...
enum class  extra_runtime_option {
  max_maps = MDBX_opt_max_db , max_readers = MDBX_opt_max_readers , sync_bytes = MDBX_opt_sync_bytes , sync_period = MDBX_opt_sync_period ,
  rp_augment_limit = MDBX_opt_rp_augment_limit , loose_limit = MDBX_opt_loose_limit , dp_reserve_limit = MDBX_opt_dp_reserve_limit , dp_limit = MDBX_opt_txn_dp_limit ,
  dp_initial = MDBX_opt_txn_dp_initial , spill_max_denominator = MDBX_opt_spill_max_denominator , spill_min_denominator = MDBX_opt_spill_min_denominator , spill_parent4child_denominator = MDBX_opt_spill_parent4child_denominator ,
  merge_threshold_dot16 = MDBX_opt_merge_threshold , writethrough_threshold = MDBX_opt_writethrough_threshold , prefault_write_enable = MDBX_opt_prefault_write_enable , gc_time_limit = MDBX_opt_gc_time_limit ,
  prefer_waf_insteadof_balance = MDBX_opt_prefer_waf_insteadof_balance , subpage_limit = MDBX_opt_subpage_limit , subpage_room_threshold = MDBX_opt_subpage_room_threshold , subpage_reserve_prereq = MDBX_opt_subpage_reserve_prereq ,
  subpage_reserve_limit = MDBX_opt_subpage_reserve_limit , split_reserve = MDBX_opt_split_reserve , presync_threshold = MDBX_opt_presync_threshold
}
 MDBX environment extra runtime options. More...
using stat = ::MDBX_stat
 Statistics for a database in the MDBX environment.
using info = ::MDBX_envinfo
 Information about the environment.
Static Public Member Functions inherited from mdbx::env
static size_t default_pagesize () noexcept
 Returns default page size for current system/platform.
static bool remove (const ::mdbx::filesystem::path &pathname, const remove_mode mode=just_remove)
 Removes the environment's files in a proper and multiprocess-safe way.
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
constexpr 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 ( )
constexprdefaultnoexcept

◆ env_managed() [2/13]

mdbx::env_managed::env_managed ( const ::mdbx::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::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 ( )
virtual

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, tables, 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)
noexcept

◆ mdbx::txn

class mdbx::txn

Unmanaged database transaction.

Like other unmanaged classes, txn allows copying and assignment for handles as a values, but does not manage nor 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

constexpr txn () noexcept=default
 txn (const txn &) noexcept=default
txnoperator= (const txn &) noexcept=default
txnoperator= (txn &&) noexcept
 txn (txn &&) noexcept
 ~txn () noexcept
constexpr operator const MDBX_txn * () const noexcept
constexpr operator MDBX_txn * () noexcept
constexpr const MDBX_txnhandle () const noexcept
constexpr MDBX_txnhandle () noexcept
inline ::mdbx::env env () const noexcept
 Returns the transaction's environment.
MDBX_txn_flags_t flags () const
 Returns transaction's flags.
uint64_t id () const
 Return the transaction's ID.
void * get_context () const noexcept
 Returns the application context associated with the transaction.
txnset_context (void *your_context)
 Sets the application context associated with the transaction.
bool is_dirty (const void *ptr) const
 Checks whether the given data is on a dirty page.
bool is_dirty (const slice &item) const
 Checks whether the given slice is on a dirty page.
bool is_readonly () const
 Checks whether the transaction is read-only.
bool is_readwrite () const
 Checks whether the transaction is read-write.
info get_info (bool scan_reader_lock_table=false) const
 Returns information about the MDBX transaction.
size_t size_max () const
 Returns maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes.
size_t size_current () const
 Returns current write transaction size (i.e.summary volume of dirty pages) in bytes.
void reset_reading ()
 Reset read-only transaction.
void renew_reading ()
 Renew read-only transaction.
txn_managed clone (void *context=nullptr) const
 Clone read transaction.
void clone (txn_managed &txn_for_renew_into_clone, void *context=nullptr) const
 Renew given read transaction into clone.
void make_broken ()
 Marks transaction as broken to prevent further operations.
void park_reading (bool autounpark=true)
 Park read-only transaction.
bool unpark_reading (bool restart_if_ousted=true)
 Resume parked read-only transaction.
txn_managed start_nested ()
 Start nested write transaction.
txn_managed start_nested (bool readonly)
 Start nested transaction.
cursor_managed open_cursor (map_handle map) const
 Opens cursor for specified key-value map handle.
size_t release_all_cursors (bool unbind) const
 Unbind or close all cursors.
size_t close_all_cursors () const
 Close all cursors.
size_t unbind_all_cursors () const
 Unbind all cursors.
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.
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.
map_handle open_map (const slice &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.
map_handle open_map_accede (const char *name) const
 Open existing key-value map.
map_handle open_map_accede (const ::std::string &name) const
 Open existing key-value map.
map_handle open_map_accede (const slice &name) const
 Open existing key-value map.
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.
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.
map_handle create_map (const slice &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.
void drop_map (map_handle map)
 Drops key-value map using handle.
bool drop_map (const char *name, bool throw_if_absent=false)
 Drops key-value map using name.
bool drop_map (const ::std::string &name, bool throw_if_absent=false)
 Drop key-value map.
bool drop_map (const slice &name, bool throw_if_absent=false)
 Drop key-value map.
void clear_map (map_handle map)
 Clear key-value map.
bool clear_map (const char *name, bool throw_if_absent=false)
bool clear_map (const ::std::string &name, bool throw_if_absent=false)
bool clear_map (const slice &name, bool throw_if_absent=false)
void rename_map (map_handle map, const char *new_name)
 Переименовывает таблицу ключ-значение.
void rename_map (map_handle map, const ::std::string &new_name)
 Переименовывает таблицу ключ-значение.
void rename_map (map_handle map, const slice &new_name)
 Переименовывает таблицу ключ-значение.
bool rename_map (const char *old_name, const char *new_name, bool throw_if_absent=false)
 Переименовывает таблицу ключ-значение.
bool rename_map (const ::std::string &old_name, const ::std::string &new_name, bool throw_if_absent=false)
 Переименовывает таблицу ключ-значение.
bool rename_map (const slice &old_name, const slice &new_name, bool throw_if_absent=false)
 Переименовывает таблицу ключ-значение.
map_handle open_map (const ::std::string_view &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.
map_handle open_map_accede (const ::std::string_view &name) const
 Open existing key-value map.
map_handle create_map (const ::std::string_view &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.
bool drop_map (const ::std::string_view &name, bool throw_if_absent=false)
 Drop key-value map.
bool clear_map (const ::std::string_view &name, bool throw_if_absent=false)
void rename_map (map_handle map, const ::std::string_view &new_name)
 Переименовывает таблицу ключ-значение.
bool rename_map (const ::std::string_view &old_name, const ::std::string_view &new_name, bool throw_if_absent=false)
 Переименовывает таблицу ключ-значение.
map_stat get_map_stat (map_handle map) const
 Returns statistics for a table.
uint32_t get_tree_deepmask (map_handle map) const
 Returns depth (bitmask) information of nested dupsort (multi-value) B+trees for given table.
map_handle::info get_map_flags (map_handle map) const
 Returns information about key-value map (aka table) handle.
txnput_canary (const canary &)
 Set integers markers (aka "canary") associated with the environment.
canary get_canary () const
 Returns fours integers markers (aka "canary") associated with the environment.
uint64_t sequence (map_handle map) const
 Reads sequence generator associated with a key-value map (aka table).
uint64_t sequence (map_handle map, uint64_t increment)
 Reads and increment sequence generator associated with a key-value map (aka table).
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 table).
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 table).
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 table).
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 table).
slice get (map_handle map, const slice &key) const
 Get value by key from a key-value map (aka table).
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 table).
slice get (map_handle map, const slice &key, const slice &value_at_absence) const
 Get value by key from a key-value map (aka table).
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 table).
pair_result get_equal_or_great (map_handle map, const slice &key) const
 Get value for equal or great key from a table.
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 table.
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)
void put (map_handle map, const pair &kv, put_mode mode)
void insert (map_handle map, const pair &kv)
value_result try_insert (map_handle map, const pair &kv)
void upsert (map_handle map, const pair &kv)
bool erase (map_handle map, const slice &key)
 Removes all values for given key.
bool erase (map_handle map, const slice &key, const slice &value)
 Removes the particular multi-value entry of the key.
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.
template<class BUFFER, class ALLOCATOR = typename BUFFER::allocator_type>
BUFFER extract (map_handle map, const slice &key, const ALLOCATOR &alloc=ALLOCATOR())
 Removes and return a value of the key.
template<class BUFFER, class ALLOCATOR = typename BUFFER::allocator_type>
BUFFER replace (map_handle map, const slice &key, const slice &new_value, const ALLOCATOR &alloc=ALLOCATOR())
 Replaces and returns a value of the key with new one.
template<class BUFFER, class ALLOCATOR = typename BUFFER::allocator_type>
BUFFER replace_reserve (map_handle map, const slice &key, size_t length, slice &new_value_reservation, const ALLOCATOR &alloc=ALLOCATOR())
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.
void append (map_handle map, const pair &kv, bool multivalue_order_preserved=true)
size_t put_multiple_samelength (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>
size_t put_multiple_samelength (map_handle map, const slice &key, const VALUE *values_array, size_t values_count, put_mode mode, bool allow_partial=false)
template<typename VALUE>
void put_multiple_samelength (map_handle map, const slice &key, const ::std::vector< VALUE > &vector, put_mode mode)
ptrdiff_t estimate (map_handle map, const pair &from, const pair &to) const
ptrdiff_t estimate (map_handle map, const slice &from, const slice &to) const
ptrdiff_t estimate_from_first (map_handle map, const slice &to) const
ptrdiff_t estimate_to_last (map_handle map, const slice &from) const

Protected Member Functions

constexpr txn (MDBX_txn *ptr) noexcept

Protected Attributes

MDBX_txnhandle_ {nullptr}

Friends

class cursor
constexpr bool operator== (const txn &a, const txn &b) noexcept
constexpr 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 ( )
constexprdefaultnoexcept

◆ txn() [2/2]

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

Member Function Documentation

◆ append()

void mdbx::txn::append ( map_handle map,
const pair & kv,
bool multivalue_order_preserved = true )
inline

◆ clear_map() [1/3]

bool mdbx::txn::clear_map ( const ::std::string_view & 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/3]

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.

◆ clear_map() [3/3]

bool mdbx::txn::clear_map ( const slice & 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.

◆ close_all_cursors()

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

Close all cursors.

◆ create_map()

map_handle mdbx::txn::create_map ( const ::std::string_view & 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.

◆ drop_map() [1/3]

bool mdbx::txn::drop_map ( const ::std::string_view & 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/3]

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.

◆ drop_map() [3/3]

bool mdbx::txn::drop_map ( const slice & name,
bool throw_if_absent = false )

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.

◆ handle() [1/2]

const MDBX_txn * mdbx::txn::handle ( ) const
inlineconstexprnoexcept

◆ handle() [2/2]

MDBX_txn * mdbx::txn::handle ( )
inlineconstexprnoexcept

◆ insert()

void mdbx::txn::insert ( map_handle map,
const pair & kv )
inline

◆ is_dirty()

bool mdbx::txn::is_dirty ( const slice & item) const
inline

Checks whether the given slice is on a dirty page.

◆ 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.

◆ open_map()

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

Open existing key-value map.

◆ open_map_accede()

map_handle mdbx::txn::open_map_accede ( const ::std::string_view & name) const
inline

Open existing key-value map.

◆ operator const MDBX_txn *()

mdbx::txn::operator const MDBX_txn * ( ) const
inlineconstexprnoexcept

◆ operator MDBX_txn *()

mdbx::txn::operator MDBX_txn * ( )
inlineconstexprnoexcept

◆ operator=()

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

◆ put()

void mdbx::txn::put ( map_handle map,
const pair & kv,
put_mode mode )
inline

◆ put_multiple_samelength() [1/2]

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

◆ put_multiple_samelength() [2/2]

template<typename VALUE>
size_t mdbx::txn::put_multiple_samelength ( map_handle map,
const slice & key,
const VALUE * values_array,
size_t values_count,
put_mode mode,
bool allow_partial = false )
inline

◆ rename_map() [1/5]

bool mdbx::txn::rename_map ( const ::std::string & old_name,
const ::std::string & new_name,
bool throw_if_absent = false )

Переименовывает таблицу ключ-значение.

Returns
True если таблица существует и была переименована, либо false в случае отсутствия исходной таблицы.

◆ rename_map() [2/5]

bool mdbx::txn::rename_map ( const ::std::string_view & old_name,
const ::std::string_view & new_name,
bool throw_if_absent = false )
inline

Переименовывает таблицу ключ-значение.

Returns
True если таблица существует и была переименована, либо false в случае отсутствия исходной таблицы.

◆ rename_map() [3/5]

bool mdbx::txn::rename_map ( const char * old_name,
const char * new_name,
bool throw_if_absent = false )

Переименовывает таблицу ключ-значение.

Returns
True если таблица существует и была переименована, либо false в случае отсутствия исходной таблицы.

◆ rename_map() [4/5]

bool mdbx::txn::rename_map ( const slice & old_name,
const slice & new_name,
bool throw_if_absent = false )

Переименовывает таблицу ключ-значение.

Returns
True если таблица существует и была переименована, либо false в случае отсутствия исходной таблицы.

◆ rename_map() [5/5]

void mdbx::txn::rename_map ( map_handle map,
const ::std::string_view & new_name )
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() [1/2]

txn_managed mdbx::txn::start_nested ( )

Start nested write transaction.

◆ start_nested() [2/2]

txn_managed mdbx::txn::start_nested ( bool readonly)

Start nested transaction.

◆ try_insert()

value_result mdbx::txn::try_insert ( map_handle map,
const pair & kv )
inline

◆ unbind_all_cursors()

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

Unbind all cursors.

◆ upsert()

void mdbx::txn::upsert ( map_handle map,
const pair & kv )
inline

◆ 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 finalization_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

constexpr txn_managed () noexcept=default
 txn_managed (txn_managed &&)=default
txn_managed & operator= (txn_managed &&other) noexcept
 txn_managed (const txn_managed &)=delete
txn_managed & operator= (const txn_managed &)=delete
 ~txn_managed ()
void abort ()
 Abandon all the operations of the transaction instead of saving ones.
void abort (finalization_latency *)
 Abandon all the operations of the transaction instead of saving ones with collecting latencies information.
void abort (finalization_latency &latency)
 Abandon all the operations of the transaction instead of saving ones with collecting latencies information.
finalization_latency abort_get_latency ()
 Abandon all the operations of the transaction instead of saving ones with collecting latencies information.
void commit ()
 Commits all changes of the transaction into a database with collecting latencies information.
void commit (finalization_latency *)
 Commits all changes of the transaction into a database with collecting latencies information.
void commit (finalization_latency &latency)
 Commits all changes of the transaction into a database with collecting latencies information.
finalization_latency commit_get_latency ()
 Commits all changes of the transaction into a database and return latency information.
bool checkpoint ()
 Commits all the operations of the transaction and immediately starts next without releasing any locks.
bool checkpoint (finalization_latency *latency)
 Commits all the operations of the transaction and immediately starts next without releasing any locks.
bool checkpoint (finalization_latency &latency)
 Commits all the operations of the transaction and immediately starts next without releasing any locks.
std::pair< bool, finalization_latencycheckpoint_get_latency ()
 Commits all the operations of the transaction and immediately starts next without releasing any locks.
void commit_embark_read ()
 Commits all the operations of a transaction into the database and then start read transaction.
void commit_embark_read (finalization_latency *latency)
 Commits all the operations of a transaction into the database and then start read transaction.
void commit_embark_read (finalization_latency &latency)
 Commits all the operations of a transaction into the database and then start read transaction.
finalization_latency commit_embark_read_get_latency ()
 Commits all the operations of a transaction into the database and then start read transaction.
bool amend (bool dont_wait=false)
 Starts a writing transaction to amending data in the MVCC-snapshot used by the read-only transaction.
Public Member Functions inherited from mdbx::txn
constexpr txn () noexcept=default
 txn (const txn &) noexcept=default
txnoperator= (const txn &) noexcept=default
txnoperator= (txn &&) noexcept
 txn (txn &&) noexcept
 ~txn () noexcept
constexpr operator const MDBX_txn * () const noexcept
constexpr operator MDBX_txn * () noexcept
constexpr const MDBX_txnhandle () const noexcept
constexpr MDBX_txnhandle () noexcept
inline ::mdbx::env env () const noexcept
 Returns the transaction's environment.
MDBX_txn_flags_t flags () const
 Returns transaction's flags.
uint64_t id () const
 Return the transaction's ID.
void * get_context () const noexcept
 Returns the application context associated with the transaction.
txnset_context (void *your_context)
 Sets the application context associated with the transaction.
bool is_dirty (const void *ptr) const
 Checks whether the given data is on a dirty page.
bool is_dirty (const slice &item) const
 Checks whether the given slice is on a dirty page.
bool is_readonly () const
 Checks whether the transaction is read-only.
bool is_readwrite () const
 Checks whether the transaction is read-write.
info get_info (bool scan_reader_lock_table=false) const
 Returns information about the MDBX transaction.
size_t size_max () const
 Returns maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes.
size_t size_current () const
 Returns current write transaction size (i.e.summary volume of dirty pages) in bytes.
void reset_reading ()
 Reset read-only transaction.
void renew_reading ()
 Renew read-only transaction.
txn_managed clone (void *context=nullptr) const
 Clone read transaction.
void clone (txn_managed &txn_for_renew_into_clone, void *context=nullptr) const
 Renew given read transaction into clone.
void make_broken ()
 Marks transaction as broken to prevent further operations.
void park_reading (bool autounpark=true)
 Park read-only transaction.
bool unpark_reading (bool restart_if_ousted=true)
 Resume parked read-only transaction.
txn_managed start_nested ()
 Start nested write transaction.
txn_managed start_nested (bool readonly)
 Start nested transaction.
cursor_managed open_cursor (map_handle map) const
 Opens cursor for specified key-value map handle.
size_t release_all_cursors (bool unbind) const
 Unbind or close all cursors.
size_t close_all_cursors () const
 Close all cursors.
size_t unbind_all_cursors () const
 Unbind all cursors.
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.
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.
map_handle open_map (const slice &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.
map_handle open_map_accede (const char *name) const
 Open existing key-value map.
map_handle open_map_accede (const ::std::string &name) const
 Open existing key-value map.
map_handle open_map_accede (const slice &name) const
 Open existing key-value map.
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.
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.
map_handle create_map (const slice &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.
void drop_map (map_handle map)
 Drops key-value map using handle.
bool drop_map (const char *name, bool throw_if_absent=false)
 Drops key-value map using name.
bool drop_map (const ::std::string &name, bool throw_if_absent=false)
 Drop key-value map.
bool drop_map (const slice &name, bool throw_if_absent=false)
 Drop key-value map.
void clear_map (map_handle map)
 Clear key-value map.
bool clear_map (const char *name, bool throw_if_absent=false)
bool clear_map (const ::std::string &name, bool throw_if_absent=false)
bool clear_map (const slice &name, bool throw_if_absent=false)
void rename_map (map_handle map, const char *new_name)
 Переименовывает таблицу ключ-значение.
void rename_map (map_handle map, const ::std::string &new_name)
 Переименовывает таблицу ключ-значение.
void rename_map (map_handle map, const slice &new_name)
 Переименовывает таблицу ключ-значение.
bool rename_map (const char *old_name, const char *new_name, bool throw_if_absent=false)
 Переименовывает таблицу ключ-значение.
bool rename_map (const ::std::string &old_name, const ::std::string &new_name, bool throw_if_absent=false)
 Переименовывает таблицу ключ-значение.
bool rename_map (const slice &old_name, const slice &new_name, bool throw_if_absent=false)
 Переименовывает таблицу ключ-значение.
map_handle open_map (const ::std::string_view &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.
map_handle open_map_accede (const ::std::string_view &name) const
 Open existing key-value map.
map_handle create_map (const ::std::string_view &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.
bool drop_map (const ::std::string_view &name, bool throw_if_absent=false)
 Drop key-value map.
bool clear_map (const ::std::string_view &name, bool throw_if_absent=false)
void rename_map (map_handle map, const ::std::string_view &new_name)
 Переименовывает таблицу ключ-значение.
bool rename_map (const ::std::string_view &old_name, const ::std::string_view &new_name, bool throw_if_absent=false)
 Переименовывает таблицу ключ-значение.
map_stat get_map_stat (map_handle map) const
 Returns statistics for a table.
uint32_t get_tree_deepmask (map_handle map) const
 Returns depth (bitmask) information of nested dupsort (multi-value) B+trees for given table.
map_handle::info get_map_flags (map_handle map) const
 Returns information about key-value map (aka table) handle.
txnput_canary (const canary &)
 Set integers markers (aka "canary") associated with the environment.
canary get_canary () const
 Returns fours integers markers (aka "canary") associated with the environment.
uint64_t sequence (map_handle map) const
 Reads sequence generator associated with a key-value map (aka table).
uint64_t sequence (map_handle map, uint64_t increment)
 Reads and increment sequence generator associated with a key-value map (aka table).
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 table).
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 table).
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 table).
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 table).
slice get (map_handle map, const slice &key) const
 Get value by key from a key-value map (aka table).
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 table).
slice get (map_handle map, const slice &key, const slice &value_at_absence) const
 Get value by key from a key-value map (aka table).
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 table).
pair_result get_equal_or_great (map_handle map, const slice &key) const
 Get value for equal or great key from a table.
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 table.
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)
void put (map_handle map, const pair &kv, put_mode mode)
void insert (map_handle map, const pair &kv)
value_result try_insert (map_handle map, const pair &kv)
void upsert (map_handle map, const pair &kv)
bool erase (map_handle map, const slice &key)
 Removes all values for given key.
bool erase (map_handle map, const slice &key, const slice &value)
 Removes the particular multi-value entry of the key.
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.
template<class BUFFER, class ALLOCATOR = typename BUFFER::allocator_type>
BUFFER extract (map_handle map, const slice &key, const ALLOCATOR &alloc=ALLOCATOR())
 Removes and return a value of the key.
template<class BUFFER, class ALLOCATOR = typename BUFFER::allocator_type>
BUFFER replace (map_handle map, const slice &key, const slice &new_value, const ALLOCATOR &alloc=ALLOCATOR())
 Replaces and returns a value of the key with new one.
template<class BUFFER, class ALLOCATOR = typename BUFFER::allocator_type>
BUFFER replace_reserve (map_handle map, const slice &key, size_t length, slice &new_value_reservation, const ALLOCATOR &alloc=ALLOCATOR())
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.
void append (map_handle map, const pair &kv, bool multivalue_order_preserved=true)
size_t put_multiple_samelength (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>
size_t put_multiple_samelength (map_handle map, const slice &key, const VALUE *values_array, size_t values_count, put_mode mode, bool allow_partial=false)
template<typename VALUE>
void put_multiple_samelength (map_handle map, const slice &key, const ::std::vector< VALUE > &vector, put_mode mode)
ptrdiff_t estimate (map_handle map, const pair &from, const pair &to) const
ptrdiff_t estimate (map_handle map, const slice &from, const slice &to) const
ptrdiff_t estimate_from_first (map_handle map, const slice &to) const
ptrdiff_t estimate_to_last (map_handle map, const slice &from) const

Friends

class env
class txn

Additional Inherited Members

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

Member Typedef Documentation

◆ finalization_latency

Constructor & Destructor Documentation

◆ txn_managed() [1/3]

mdbx::txn_managed::txn_managed ( )
constexprdefaultnoexcept

◆ 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 ( )

Member Function Documentation

◆ abort() [1/3]

void mdbx::txn_managed::abort ( )

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

◆ abort() [2/3]

void mdbx::txn_managed::abort ( finalization_latency & latency)
inline

Abandon all the operations of the transaction instead of saving ones with collecting latencies information.

◆ abort() [3/3]

void mdbx::txn_managed::abort ( finalization_latency * )

Abandon all the operations of the transaction instead of saving ones with collecting latencies information.

◆ abort_get_latency()

finalization_latency mdbx::txn_managed::abort_get_latency ( )
inline

Abandon all the operations of the transaction instead of saving ones with collecting latencies information.

Returns
latency information of abort stages.

◆ amend()

bool mdbx::txn_managed::amend ( bool dont_wait = false)

Starts a writing transaction to amending data in the MVCC-snapshot used by the read-only transaction.

Returns
The true if writing transaction successfully started and false if read-only one still continue.

◆ checkpoint() [1/3]

bool mdbx::txn_managed::checkpoint ( )

Commits all the operations of the transaction and immediately starts next without releasing any locks.

◆ checkpoint() [2/3]

bool mdbx::txn_managed::checkpoint ( finalization_latency & latency)
inline

Commits all the operations of the transaction and immediately starts next without releasing any locks.

◆ checkpoint() [3/3]

bool mdbx::txn_managed::checkpoint ( finalization_latency * latency)

Commits all the operations of the transaction and immediately starts next without releasing any locks.

◆ checkpoint_get_latency()

std::pair< bool, finalization_latency > mdbx::txn_managed::checkpoint_get_latency ( )
inline

Commits all the operations of the transaction and immediately starts next without releasing any locks.

Returns
latency information of commit stages.

◆ commit() [1/3]

void mdbx::txn_managed::commit ( )

Commits all changes of the transaction into a database with collecting latencies information.

◆ commit() [2/3]

void mdbx::txn_managed::commit ( finalization_latency & latency)
inline

Commits all changes of the transaction into a database with collecting latencies information.

◆ commit() [3/3]

void mdbx::txn_managed::commit ( finalization_latency * )

Commits all changes of the transaction into a database with collecting latencies information.

◆ commit_embark_read() [1/3]

void mdbx::txn_managed::commit_embark_read ( )

Commits all the operations of a transaction into the database and then start read transaction.

◆ commit_embark_read() [2/3]

void mdbx::txn_managed::commit_embark_read ( finalization_latency & latency)
inline

Commits all the operations of a transaction into the database and then start read transaction.

◆ commit_embark_read() [3/3]

void mdbx::txn_managed::commit_embark_read ( finalization_latency * latency)

Commits all the operations of a transaction into the database and then start read transaction.

◆ commit_embark_read_get_latency()

finalization_latency mdbx::txn_managed::commit_embark_read_get_latency ( )
inline

Commits all the operations of a transaction into the database and then start read transaction.

Returns
latency information of commit stages.

◆ commit_get_latency()

finalization_latency mdbx::txn_managed::commit_get_latency ( )
inline

Commits all changes of the transaction into a 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)
noexcept

◆ 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 handles as a values, but does not manage nor 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 , seek_key = MDBX_SET , key_exact = MDBX_SET_KEY , key_lowerbound = MDBX_SET_RANGE ,
  key_lesser_than = MDBX_TO_KEY_LESSER_THAN , key_lesser_or_equal = MDBX_TO_KEY_LESSER_OR_EQUAL , key_equal = MDBX_TO_KEY_EQUAL , key_greater_or_equal = MDBX_TO_KEY_GREATER_OR_EQUAL ,
  key_greater_than = MDBX_TO_KEY_GREATER_THAN , multi_exactkey_value_lesser_than = MDBX_TO_EXACT_KEY_VALUE_LESSER_THAN , multi_exactkey_value_lesser_or_equal = MDBX_TO_EXACT_KEY_VALUE_LESSER_OR_EQUAL , multi_exactkey_value_equal = MDBX_TO_EXACT_KEY_VALUE_EQUAL ,
  multi_exactkey_value_greater_or_equal = MDBX_TO_EXACT_KEY_VALUE_GREATER_OR_EQUAL , multi_exactkey_value_greater = MDBX_TO_EXACT_KEY_VALUE_GREATER_THAN , pair_lesser_than = MDBX_TO_PAIR_LESSER_THAN , pair_lesser_or_equal = MDBX_TO_PAIR_LESSER_OR_EQUAL ,
  pair_equal = MDBX_TO_PAIR_EQUAL , pair_exact = pair_equal , pair_greater_or_equal = MDBX_TO_PAIR_GREATER_OR_EQUAL , pair_greater_than = MDBX_TO_PAIR_GREATER_THAN ,
  batch_samelength = MDBX_GET_MULTIPLE , batch_samelength_next = MDBX_NEXT_MULTIPLE , batch_samelength_previous = MDBX_PREV_MULTIPLE , seek_and_batch_samelength = MDBX_SEEK_AND_GET_MULTIPLE
}

Public Member Functions

constexpr cursor (MDBX_cursor *ptr) noexcept
constexpr cursor () noexcept=default
 cursor (const cursor &) noexcept=default
cursoroperator= (const cursor &) noexcept=default
cursoroperator= (cursor &&) noexcept
 cursor (cursor &&) noexcept
 ~cursor () noexcept
cursor_managed clone (void *your_context=nullptr) const
cursorassign (const cursor &)
constexpr operator const MDBX_cursor * () const noexcept
constexpr operator MDBX_cursor * () noexcept
constexpr const MDBX_cursorhandle () const noexcept
constexpr MDBX_cursorhandle () noexcept
bool is_before_than (const cursor &other, bool ignore_nested=false) const
bool is_same_or_before_than (const cursor &other, bool ignore_nested=false) const
bool is_same_position (const cursor &other, bool ignore_nested=false) const
bool is_after_than (const cursor &other, bool ignore_nested=false) const
bool is_same_or_after_than (const cursor &other, bool ignore_nested=false) const
void * get_context () const noexcept
 Returns the application context associated with the cursor.
cursorset_context (void *your_context)
 Sets the application context associated with the cursor.
template<typename CALLABLE_PREDICATE>
bool scan_until (CALLABLE_PREDICATE predicate, move_operation start=first, move_operation turn=next)
template<typename CALLABLE_PREDICATE>
bool fullscan (CALLABLE_PREDICATE predicate, bool backward=false)
template<typename CALLABLE_PREDICATE>
bool scan_until_from (CALLABLE_PREDICATE predicate, slice &from, move_operation start=key_greater_or_equal, move_operation turn=next)
template<typename CALLABLE_PREDICATE>
bool scan_until_from (CALLABLE_PREDICATE predicate, pair &from, move_operation start=pair_greater_or_equal, move_operation turn=next)
move_result move (move_operation operation, bool throw_notfound)
move_result move (move_operation operation, const slice &key, bool throw_notfound)
move_result move (move_operation operation, const slice &key, const slice &value, bool throw_notfound)
bool move (move_operation operation, slice &key, slice &value, 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 to_key_lesser_than (const slice &key, bool throw_notfound=true)
move_result to_key_lesser_or_equal (const slice &key, bool throw_notfound=true)
move_result to_key_equal (const slice &key, bool throw_notfound=true)
move_result to_key_exact (const slice &key, bool throw_notfound=true)
move_result to_key_greater_or_equal (const slice &key, bool throw_notfound=true)
move_result to_key_greater_than (const slice &key, bool throw_notfound=true)
move_result to_exact_key_value_lesser_than (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_exact_key_value_lesser_or_equal (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_exact_key_value_equal (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_exact_key_value_greater_or_equal (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_exact_key_value_greater_than (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_pair_lesser_than (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_pair_lesser_or_equal (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_pair_equal (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_pair_exact (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_pair_greater_or_equal (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_pair_greater_than (const slice &key, const slice &value, bool throw_notfound=true)
bool seek (const slice &key)
move_result find (const slice &key, bool throw_notfound=true)
move_result lower_bound (const slice &key, bool throw_notfound=false)
move_result upper_bound (const slice &key, bool throw_notfound=false)
size_t count_multivalue () const
 Return count of duplicates for current key.
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)
move_result upper_bound_multivalue (const slice &key, const slice &value, bool throw_notfound=false)
move_result seek_multiple_samelength (const slice &key, bool throw_notfound=true)
move_result get_multiple_samelength (bool throw_notfound=false)
move_result next_multiple_samelength (bool throw_notfound=false)
move_result previous_multiple_samelength (bool throw_notfound=false)
bool eof () const
bool on_first () const
bool on_last () const
bool on_first_multival () const
bool on_last_multival () const
estimate_result estimate (const slice &key, const slice &value) const
estimate_result estimate (const slice &key) const
estimate_result estimate (move_operation operation) const
estimate_result estimate (move_operation operation, const slice &key) const
ptrdiff_t distance_from (const cursor from, unsigned deepness=42) const
ptrdiff_t distance_to (const cursor to, unsigned deepness=42) const
ptrdiff_t distance_from_first (unsigned deepness=42) const
ptrdiff_t distance_to_end (unsigned deepness=42) const
bool scroll (intptr_t distable, unsigned deepness=42, bool throw_notfound=true)
void renew (::mdbx::txn &txn)
 Renew/bind a cursor with a new transaction and previously used key-value map handle.
void bind (::mdbx::txn &txn, ::mdbx::map_handle map_handle)
 Bind/renew a cursor with a new transaction and specified key-value map handle.
void unbind ()
 Unbind cursor from a transaction.
inline ::mdbx::txn txn () const
 Returns the cursor's transaction.
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 put (const slice &key, slice value, put_mode mode)
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_current (const slice &value)
 Updates value associated with a key at the current cursor position.
slice reverse_current (size_t value_length)
 Reserves and returns the space to storing a value associated with a key at the current cursor position.
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)
void put (const pair &kv, put_mode mode)
void insert (const pair &kv)
value_result try_insert (const pair &kv)
void upsert (const pair &kv)
bool erase (bool whole_multivalue=false)
 Removes single key-value pair or all multi-values at the current cursor position.
bool erase (const slice &key, bool whole_multivalue=true)
 Seeks and removes first value or whole multi-value of the given key.
bool erase (const slice &key, const slice &value)
 Seeks and removes the particular multi-value entry of the key.
size_t put_multiple_samelength (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>
size_t put_multiple_samelength (const slice &key, const VALUE *values_array, size_t values_count, put_mode mode, bool allow_partial=false)
template<typename VALUE>
void put_multiple_samelength (const slice &key, const ::std::vector< VALUE > &vector, put_mode mode)

Static Public Member Functions

static ptrdiff_t distance_between (const cursor from, const cursor to, unsigned deepness=42)
static bool distribute (const cursor from, const cursor to, cursor *cursors_array, intptr_t cursors_array_size, unsigned deepness=42)
static bool distribute (const cursor from, const cursor to, const std::vector< cursor > &cursors, unsigned deepness=42)
static bool distribute (const cursor from, const cursor to, const std::vector< cursor_managed > &cursors, unsigned deepness=42)

Protected Member Functions

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

constexpr bool operator== (const cursor &a, const cursor &b) noexcept
constexpr bool operator!= (const cursor &a, const cursor &b) noexcept
int compare_position_nothrow (const cursor &left, const cursor &right, bool ignore_nested=false)
int compare_position (const cursor &left, const cursor &right, bool ignore_nested=false)

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 
seek_key 
key_exact 
key_lowerbound 
key_lesser_than 
key_lesser_or_equal 
key_equal 
key_greater_or_equal 
key_greater_than 
multi_exactkey_value_lesser_than 
multi_exactkey_value_lesser_or_equal 
multi_exactkey_value_equal 
multi_exactkey_value_greater_or_equal 
multi_exactkey_value_greater 
pair_lesser_than 
pair_lesser_or_equal 
pair_equal 
pair_exact 
pair_greater_or_equal 
pair_greater_than 
batch_samelength 
batch_samelength_next 
batch_samelength_previous 
seek_and_batch_samelength 

Constructor & Destructor Documentation

◆ cursor() [1/2]

mdbx::cursor::cursor ( )
constexprdefaultnoexcept

◆ cursor() [2/2]

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

Member Function Documentation

◆ clone()

cursor_managed mdbx::cursor::clone ( void * your_context = nullptr) const

◆ current()

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

◆ distance_from()

ptrdiff_t mdbx::cursor::distance_from ( const cursor from,
unsigned deepness = 42 ) const
inline

◆ distance_from_first()

ptrdiff_t mdbx::cursor::distance_from_first ( unsigned deepness = 42) const
inline

◆ distance_to()

ptrdiff_t mdbx::cursor::distance_to ( const cursor to,
unsigned deepness = 42 ) const
inline

◆ distance_to_end()

ptrdiff_t mdbx::cursor::distance_to_end ( unsigned deepness = 42) const
inline

◆ fullscan()

template<typename CALLABLE_PREDICATE>
bool mdbx::cursor::fullscan ( CALLABLE_PREDICATE predicate,
bool backward = false )
inline

◆ get_multiple_samelength()

move_result mdbx::cursor::get_multiple_samelength ( bool throw_notfound = false)
inline

◆ handle() [1/2]

const MDBX_cursor * mdbx::cursor::handle ( ) const
inlineconstexprnoexcept

◆ handle() [2/2]

MDBX_cursor * mdbx::cursor::handle ( )
inlineconstexprnoexcept

◆ insert()

void mdbx::cursor::insert ( const pair & kv)
inline

◆ is_after_than()

bool mdbx::cursor::is_after_than ( const cursor & other,
bool ignore_nested = false ) const
inline

◆ is_before_than()

bool mdbx::cursor::is_before_than ( const cursor & other,
bool ignore_nested = false ) const
inline

◆ is_same_or_after_than()

bool mdbx::cursor::is_same_or_after_than ( const cursor & other,
bool ignore_nested = false ) const
inline

◆ is_same_or_before_than()

bool mdbx::cursor::is_same_or_before_than ( const cursor & other,
bool ignore_nested = false ) const
inline

◆ is_same_position()

bool mdbx::cursor::is_same_position ( const cursor & other,
bool ignore_nested = false ) const
inline

◆ move() [1/4]

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

◆ move() [2/4]

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

◆ move() [3/4]

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

◆ move() [4/4]

bool mdbx::cursor::move ( move_operation operation,
slice & key,
slice & value,
bool throw_notfound )
inline

◆ next_multiple_samelength()

move_result mdbx::cursor::next_multiple_samelength ( bool throw_notfound = false)
inline

◆ operator const MDBX_cursor *()

mdbx::cursor::operator const MDBX_cursor * ( ) const
inlineconstexprnoexcept

◆ operator MDBX_cursor *()

mdbx::cursor::operator MDBX_cursor * ( )
inlineconstexprnoexcept

◆ operator::mdbx::map_handle()

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

◆ operator::mdbx::txn()

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

◆ operator=()

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

◆ previous_multiple_samelength()

move_result mdbx::cursor::previous_multiple_samelength ( bool throw_notfound = false)
inline

◆ put()

void mdbx::cursor::put ( const pair & kv,
put_mode mode )
inline

◆ put_multiple_samelength() [1/2]

template<typename VALUE>
void mdbx::cursor::put_multiple_samelength ( const slice & key,
const ::std::vector< VALUE > & vector,
put_mode mode )
inline

◆ put_multiple_samelength() [2/2]

template<typename VALUE>
size_t mdbx::cursor::put_multiple_samelength ( const slice & key,
const VALUE * values_array,
size_t values_count,
put_mode mode,
bool allow_partial = false )
inline

◆ reverse_current()

slice mdbx::cursor::reverse_current ( size_t value_length)

Reserves and returns the space to storing a value associated with a key at the current cursor position.

◆ scan_until()

template<typename CALLABLE_PREDICATE>
bool mdbx::cursor::scan_until ( CALLABLE_PREDICATE predicate,
move_operation start = first,
move_operation turn = next )
inline

◆ scan_until_from() [1/2]

template<typename CALLABLE_PREDICATE>
bool mdbx::cursor::scan_until_from ( CALLABLE_PREDICATE predicate,
pair & from,
move_operation start = pair_greater_or_equal,
move_operation turn = next )
inline

◆ scan_until_from() [2/2]

template<typename CALLABLE_PREDICATE>
bool mdbx::cursor::scan_until_from ( CALLABLE_PREDICATE predicate,
slice & from,
move_operation start = key_greater_or_equal,
move_operation turn = next )
inline

◆ seek_multiple_samelength()

move_result mdbx::cursor::seek_multiple_samelength ( const slice & key,
bool throw_notfound = true )
inline

◆ to_current_first_multi()

move_result mdbx::cursor::to_current_first_multi ( bool throw_notfound = true)
inline

◆ to_current_last_multi()

move_result mdbx::cursor::to_current_last_multi ( bool throw_notfound = true)
inline

◆ to_current_next_multi()

move_result mdbx::cursor::to_current_next_multi ( bool throw_notfound = true)
inline

◆ to_current_prev_multi()

move_result mdbx::cursor::to_current_prev_multi ( bool throw_notfound = true)
inline

◆ to_exact_key_value_equal()

move_result mdbx::cursor::to_exact_key_value_equal ( const slice & key,
const slice & value,
bool throw_notfound = true )
inline

◆ to_exact_key_value_greater_or_equal()

move_result mdbx::cursor::to_exact_key_value_greater_or_equal ( const slice & key,
const slice & value,
bool throw_notfound = true )
inline

◆ to_exact_key_value_greater_than()

move_result mdbx::cursor::to_exact_key_value_greater_than ( const slice & key,
const slice & value,
bool throw_notfound = true )
inline

◆ to_exact_key_value_lesser_or_equal()

move_result mdbx::cursor::to_exact_key_value_lesser_or_equal ( const slice & key,
const slice & value,
bool throw_notfound = true )
inline

◆ to_exact_key_value_lesser_than()

move_result mdbx::cursor::to_exact_key_value_lesser_than ( const slice & key,
const slice & value,
bool throw_notfound = true )
inline

◆ to_first()

move_result mdbx::cursor::to_first ( bool throw_notfound = true)
inline

◆ to_key_equal()

move_result mdbx::cursor::to_key_equal ( const slice & key,
bool throw_notfound = true )
inline

◆ to_key_exact()

move_result mdbx::cursor::to_key_exact ( const slice & key,
bool throw_notfound = true )
inline

◆ to_key_greater_or_equal()

move_result mdbx::cursor::to_key_greater_or_equal ( const slice & key,
bool throw_notfound = true )
inline

◆ to_key_greater_than()

move_result mdbx::cursor::to_key_greater_than ( const slice & key,
bool throw_notfound = true )
inline

◆ to_key_lesser_or_equal()

move_result mdbx::cursor::to_key_lesser_or_equal ( const slice & key,
bool throw_notfound = true )
inline

◆ to_key_lesser_than()

move_result mdbx::cursor::to_key_lesser_than ( const slice & key,
bool throw_notfound = true )
inline

◆ to_last()

move_result mdbx::cursor::to_last ( bool throw_notfound = true)
inline

◆ to_next()

move_result mdbx::cursor::to_next ( bool throw_notfound = true)
inline

◆ to_next_first_multi()

move_result mdbx::cursor::to_next_first_multi ( bool throw_notfound = true)
inline

◆ to_pair_equal()

move_result mdbx::cursor::to_pair_equal ( const slice & key,
const slice & value,
bool throw_notfound = true )
inline

◆ to_pair_exact()

move_result mdbx::cursor::to_pair_exact ( const slice & key,
const slice & value,
bool throw_notfound = true )
inline

◆ to_pair_greater_or_equal()

move_result mdbx::cursor::to_pair_greater_or_equal ( const slice & key,
const slice & value,
bool throw_notfound = true )
inline

◆ to_pair_greater_than()

move_result mdbx::cursor::to_pair_greater_than ( const slice & key,
const slice & value,
bool throw_notfound = true )
inline

◆ to_pair_lesser_or_equal()

move_result mdbx::cursor::to_pair_lesser_or_equal ( const slice & key,
const slice & value,
bool throw_notfound = true )
inline

◆ to_pair_lesser_than()

move_result mdbx::cursor::to_pair_lesser_than ( const slice & key,
const slice & value,
bool throw_notfound = true )
inline

◆ to_previous()

move_result mdbx::cursor::to_previous ( bool throw_notfound = true)
inline

◆ to_previous_last_multi()

move_result mdbx::cursor::to_previous_last_multi ( bool throw_notfound = true)
inline

◆ try_insert()

value_result mdbx::cursor::try_insert ( const pair & kv)
inline

◆ update_current()

void mdbx::cursor::update_current ( const slice & value)

Updates value associated with a key at the current cursor position.

◆ upsert()

void mdbx::cursor::upsert ( const pair & kv)
inline

◆ compare_position

int compare_position ( const cursor & left,
const cursor & right,
bool ignore_nested = false )
friend

◆ compare_position_nothrow

int compare_position_nothrow ( const cursor & left,
const cursor & right,
bool ignore_nested = false )
friend

◆ 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 (void *your_context=nullptr)
 Creates a new managed cursor with underlying object.
void close ()
 Explicitly closes the cursor.
 cursor_managed (cursor_managed &&)=default
cursor_managed & operator= (cursor_managed &&other) noexcept
MDBX_cursorwithdraw_handle () noexcept
 cursor_managed (const cursor_managed &)=delete
cursor_managed & operator= (const cursor_managed &)=delete
 ~cursor_managed ()
Public Member Functions inherited from mdbx::cursor
constexpr cursor (MDBX_cursor *ptr) noexcept
constexpr cursor () noexcept=default
 cursor (const cursor &) noexcept=default
cursoroperator= (const cursor &) noexcept=default
cursoroperator= (cursor &&) noexcept
 cursor (cursor &&) noexcept
 ~cursor () noexcept
cursor_managed clone (void *your_context=nullptr) const
cursorassign (const cursor &)
constexpr operator const MDBX_cursor * () const noexcept
constexpr operator MDBX_cursor * () noexcept
constexpr const MDBX_cursorhandle () const noexcept
constexpr MDBX_cursorhandle () noexcept
bool is_before_than (const cursor &other, bool ignore_nested=false) const
bool is_same_or_before_than (const cursor &other, bool ignore_nested=false) const
bool is_same_position (const cursor &other, bool ignore_nested=false) const
bool is_after_than (const cursor &other, bool ignore_nested=false) const
bool is_same_or_after_than (const cursor &other, bool ignore_nested=false) const
void * get_context () const noexcept
 Returns the application context associated with the cursor.
cursorset_context (void *your_context)
 Sets the application context associated with the cursor.
template<typename CALLABLE_PREDICATE>
bool scan_until (CALLABLE_PREDICATE predicate, move_operation start=first, move_operation turn=next)
template<typename CALLABLE_PREDICATE>
bool fullscan (CALLABLE_PREDICATE predicate, bool backward=false)
template<typename CALLABLE_PREDICATE>
bool scan_until_from (CALLABLE_PREDICATE predicate, slice &from, move_operation start=key_greater_or_equal, move_operation turn=next)
template<typename CALLABLE_PREDICATE>
bool scan_until_from (CALLABLE_PREDICATE predicate, pair &from, move_operation start=pair_greater_or_equal, move_operation turn=next)
move_result move (move_operation operation, bool throw_notfound)
move_result move (move_operation operation, const slice &key, bool throw_notfound)
move_result move (move_operation operation, const slice &key, const slice &value, bool throw_notfound)
bool move (move_operation operation, slice &key, slice &value, 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 to_key_lesser_than (const slice &key, bool throw_notfound=true)
move_result to_key_lesser_or_equal (const slice &key, bool throw_notfound=true)
move_result to_key_equal (const slice &key, bool throw_notfound=true)
move_result to_key_exact (const slice &key, bool throw_notfound=true)
move_result to_key_greater_or_equal (const slice &key, bool throw_notfound=true)
move_result to_key_greater_than (const slice &key, bool throw_notfound=true)
move_result to_exact_key_value_lesser_than (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_exact_key_value_lesser_or_equal (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_exact_key_value_equal (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_exact_key_value_greater_or_equal (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_exact_key_value_greater_than (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_pair_lesser_than (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_pair_lesser_or_equal (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_pair_equal (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_pair_exact (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_pair_greater_or_equal (const slice &key, const slice &value, bool throw_notfound=true)
move_result to_pair_greater_than (const slice &key, const slice &value, bool throw_notfound=true)
bool seek (const slice &key)
move_result find (const slice &key, bool throw_notfound=true)
move_result lower_bound (const slice &key, bool throw_notfound=false)
move_result upper_bound (const slice &key, bool throw_notfound=false)
size_t count_multivalue () const
 Return count of duplicates for current key.
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)
move_result upper_bound_multivalue (const slice &key, const slice &value, bool throw_notfound=false)
move_result seek_multiple_samelength (const slice &key, bool throw_notfound=true)
move_result get_multiple_samelength (bool throw_notfound=false)
move_result next_multiple_samelength (bool throw_notfound=false)
move_result previous_multiple_samelength (bool throw_notfound=false)
bool eof () const
bool on_first () const
bool on_last () const
bool on_first_multival () const
bool on_last_multival () const
estimate_result estimate (const slice &key, const slice &value) const
estimate_result estimate (const slice &key) const
estimate_result estimate (move_operation operation) const
estimate_result estimate (move_operation operation, const slice &key) const
ptrdiff_t distance_from (const cursor from, unsigned deepness=42) const
ptrdiff_t distance_to (const cursor to, unsigned deepness=42) const
ptrdiff_t distance_from_first (unsigned deepness=42) const
ptrdiff_t distance_to_end (unsigned deepness=42) const
bool scroll (intptr_t distable, unsigned deepness=42, bool throw_notfound=true)
void renew (::mdbx::txn &txn)
 Renew/bind a cursor with a new transaction and previously used key-value map handle.
void bind (::mdbx::txn &txn, ::mdbx::map_handle map_handle)
 Bind/renew a cursor with a new transaction and specified key-value map handle.
void unbind ()
 Unbind cursor from a transaction.
inline ::mdbx::txn txn () const
 Returns the cursor's transaction.
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 put (const slice &key, slice value, put_mode mode)
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_current (const slice &value)
 Updates value associated with a key at the current cursor position.
slice reverse_current (size_t value_length)
 Reserves and returns the space to storing a value associated with a key at the current cursor position.
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)
void put (const pair &kv, put_mode mode)
void insert (const pair &kv)
value_result try_insert (const pair &kv)
void upsert (const pair &kv)
bool erase (bool whole_multivalue=false)
 Removes single key-value pair or all multi-values at the current cursor position.
bool erase (const slice &key, bool whole_multivalue=true)
 Seeks and removes first value or whole multi-value of the given key.
bool erase (const slice &key, const slice &value)
 Seeks and removes the particular multi-value entry of the key.
size_t put_multiple_samelength (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>
size_t put_multiple_samelength (const slice &key, const VALUE *values_array, size_t values_count, put_mode mode, bool allow_partial=false)
template<typename VALUE>
void put_multiple_samelength (const slice &key, const ::std::vector< VALUE > &vector, put_mode mode)

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 , seek_key = MDBX_SET , key_exact = MDBX_SET_KEY , key_lowerbound = MDBX_SET_RANGE ,
  key_lesser_than = MDBX_TO_KEY_LESSER_THAN , key_lesser_or_equal = MDBX_TO_KEY_LESSER_OR_EQUAL , key_equal = MDBX_TO_KEY_EQUAL , key_greater_or_equal = MDBX_TO_KEY_GREATER_OR_EQUAL ,
  key_greater_than = MDBX_TO_KEY_GREATER_THAN , multi_exactkey_value_lesser_than = MDBX_TO_EXACT_KEY_VALUE_LESSER_THAN , multi_exactkey_value_lesser_or_equal = MDBX_TO_EXACT_KEY_VALUE_LESSER_OR_EQUAL , multi_exactkey_value_equal = MDBX_TO_EXACT_KEY_VALUE_EQUAL ,
  multi_exactkey_value_greater_or_equal = MDBX_TO_EXACT_KEY_VALUE_GREATER_OR_EQUAL , multi_exactkey_value_greater = MDBX_TO_EXACT_KEY_VALUE_GREATER_THAN , pair_lesser_than = MDBX_TO_PAIR_LESSER_THAN , pair_lesser_or_equal = MDBX_TO_PAIR_LESSER_OR_EQUAL ,
  pair_equal = MDBX_TO_PAIR_EQUAL , pair_exact = pair_equal , pair_greater_or_equal = MDBX_TO_PAIR_GREATER_OR_EQUAL , pair_greater_than = MDBX_TO_PAIR_GREATER_THAN ,
  batch_samelength = MDBX_GET_MULTIPLE , batch_samelength_next = MDBX_NEXT_MULTIPLE , batch_samelength_previous = MDBX_PREV_MULTIPLE , seek_and_batch_samelength = MDBX_SEEK_AND_GET_MULTIPLE
}
Static Public Member Functions inherited from mdbx::cursor
static ptrdiff_t distance_between (const cursor from, const cursor to, unsigned deepness=42)
static bool distribute (const cursor from, const cursor to, cursor *cursors_array, intptr_t cursors_array_size, unsigned deepness=42)
static bool distribute (const cursor from, const cursor to, const std::vector< cursor > &cursors, unsigned deepness=42)
static bool distribute (const cursor from, const cursor to, const std::vector< cursor_managed > &cursors, unsigned deepness=42)
Protected Member Functions inherited from mdbx::cursor
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 ( void * your_context = nullptr)
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 ( )

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)
noexcept

◆ withdraw_handle()

MDBX_cursor * mdbx::cursor_managed::withdraw_handle ( )
inlinenoexcept

◆ txn

friend class txn
friend

Typedef Documentation

◆ comparator

Enumeration Type Documentation

◆ key_mode

enum class 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 class 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

◆ default_comparator() [1/2]

comparator mdbx::default_comparator ( key_mode mode)
inlinenoexcept

◆ default_comparator() [2/2]

comparator mdbx::default_comparator ( value_mode mode)
inlinenoexcept

◆ is_msgpack() [1/2]

MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_msgpack ( key_mode mode)
noexcept

◆ is_msgpack() [2/2]

MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_msgpack ( value_mode mode)
noexcept

◆ is_multi()

MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_multi ( value_mode mode)
noexcept

◆ is_ordinal() [1/2]

MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_ordinal ( key_mode mode)
noexcept

◆ is_ordinal() [2/2]

MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_ordinal ( value_mode mode)
noexcept

◆ is_reverse() [1/2]

MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_reverse ( key_mode mode)
noexcept

◆ is_reverse() [2/2]

MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_reverse ( value_mode mode)
noexcept

◆ is_samelength() [1/2]

MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_samelength ( key_mode mode)
noexcept

◆ is_samelength() [2/2]

MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_samelength ( value_mode mode)
noexcept

◆ is_usual() [1/2]

MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_usual ( key_mode mode)
noexcept

◆ is_usual() [2/2]

MDBX_CXX01_CONSTEXPR_ENUM bool mdbx::is_usual ( value_mode mode)
noexcept