Class mdbx::env_managed
ClassList > mdbx > env_managed
Managed database environment. More...
#include <mdbx.h++>
Inherits the following classes: mdbx::env
Classes
| Type | Name |
|---|---|
| struct | create_parameters Additional parameters for creating a new database. |
Public Types inherited from mdbx::env
See mdbx::env
| Type | Name |
|---|---|
| enum int | defrag_control Control values returned by the defragmentation progress visitor. |
| typedef ::MDBX_defrag_result_t | defrag_result The result of database defragmentation, see MDBX_defrag_result_t . |
| enum unsigned | durability Durability level. |
| enum | extra_runtime_option MDBX environment extra runtime options. |
| typedef ::MDBX_envinfo | info Information about the environment. |
| enum unsigned | mode Operation mode. |
| enum | remove_mode Deletion modes for remove() . |
| typedef ::MDBX_stat | stat Statistics for a database in the MDBX environment. |
Public Static Attributes inherited from mdbx::env
See mdbx::env
| Type | Name |
|---|---|
| durability | half_synchronous_weak_last = durability::half\_synchronous\_weak\_last |
| durability | lazy_weak_tail = /* multi line expression */ |
| mode | nested_transactions = /* multi line expression */ |
| mode | readonly = mode::readonly |
| durability | robust_synchronous = /* multi line expression */ |
| durability | whole_fragile = /* multi line expression */ |
| mode | write_file_io = /* multi line expression */ |
| mode | write_mapped_io = /* multi line expression */ |
Public Functions
| Type | Name |
|---|---|
| void | close (bool dont_sync=false) Explicitly closes the environment and release the memory map. |
| constexpr | env_managed () noexcept Constructs an empty (not opened) managed environment. |
| env_managed (const ::mdbx::filesystem::path & pathname, const operate_parameters & params, bool accede=true) Open existing database. |
|
| env_managed (const ::std::wstring & pathname, const operate_parameters & params, bool accede=true) Open existing database (the operate_parameters overload for a wide-string path). |
|
| env_managed (const wchar_t * pathname, const operate_parameters & params, bool accede=true) Open existing database (the operate_parameters overload for a wide-string path). |
|
| env_managed (const ::std::string & pathname, const operate_parameters & params, bool accede=true) Open existing database (the operate_parameters overload for a narrow-string path). |
|
| env_managed (const char * pathname, const operate_parameters & params, bool accede=true) Open existing database (the operate_parameters overload for a C-string path). |
|
| env_managed (const ::mdbx::filesystem::path & pathname, const create_parameters & create_params, const operate_parameters & operate_params, bool accede=true) Create new or open existing database. |
|
| env_managed (const ::std::wstring & pathname, const create_parameters & create_params, const operate_parameters & operate_params, bool accede=true) Create new or open existing database (wide-string path overload). |
|
| env_managed (const wchar_t * pathname, const create_parameters & create_params, const operate_parameters & operate_params, bool accede=true) Create new or open existing database (wide-string path overload). |
|
| env_managed (const ::std::string & pathname, const create_parameters & create_params, const operate_parameters & operate_params, bool accede=true) Create new or open existing database (narrow-string path overload). |
|
| env_managed (const char * pathname, const create_parameters & create_params, const operate_parameters & operate_params, bool accede=true) Create new or open existing database (C-string path overload). |
|
| env_managed (env_managed &&) = default Move constructor. |
|
| env_managed (const env_managed &) = delete |
|
| env_managed & | operator= (env_managed && other) noexcept Move assignment operator. |
| env_managed & | operator= (const env_managed &) = delete |
| virtual | ~env_managed () |
Public Functions inherited from mdbx::env
See mdbx::env
| Type | Name |
|---|---|
| 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. |
| env & | copy (const ::std::wstring & destination, bool compactify, bool force_dynamic_size=false) Make a copy (backup) of an existing environment to the specified path. |
| env & | copy (const wchar_t * destination, bool compactify, bool force_dynamic_size=false) Make a copy (backup) of an existing environment to the specified path. |
| env & | copy (const ::std::string & destination, bool compactify, bool force_dynamic_size=false) Make a copy (backup) of an existing environment to the specified path. |
| env & | copy (const char * destination, bool compactify, bool force_dynamic_size=false) Make a copy (backup) of an existing environment to the specified path. |
| env & | copy (filehandle fd, bool compactify, bool force_dynamic_size=false) Copy an environment to the specified file descriptor. |
| size_t | dbsize_max () const Returns the maximal database size in bytes for the environment. |
| size_t | dbsize_min () const Returns the minimal database size in bytes for the environment. |
| constexpr | env () noexcept Constructs an empty (null) environment. |
| env (const env &) noexcept Copy constructor. |
|
| env (env_managed &&) = delete |
|
| size_t | get_pagesize () const Returns pagesize of this MDBX environment. |
| const path_char * | get_path () const Return the path that was used for opening the environment. |
| const MDBX_env * | handle () noexcept const Returns the underlying C handle (read-only). |
| MDBX_env * | handle () noexcept Returns the underlying C handle. |
| bool | is_cooperative () const Checks whether the environment is cooperative, i.e. not exclusive. |
| bool | is_empty () const Checks whether the database is empty. |
| bool | is_exclusive () const Checks whether the environment is exclusive. |
| bool | is_nested_transactions_available () const Checks whether nested transactions are available. |
| bool | is_pristine () const Returns true for a freshly created database, butfalse if at least one transaction was committed. |
| bool | is_readonly () const Checks whether the environment is read-only. |
| bool | is_readwrite () const Checks whether the environment is read-write. |
| bool | is_writemap () const Checks whether the environment uses memory-mapped I/O for writes. |
| size_t | key_max (key_mode mode) const Returns the maximal key size in bytes for specified keys mode. |
| size_t | key_min (key_mode mode) noexcept const Returns the minimal key size in bytes for specified keys mode. |
| constexpr | operator MDBX_env * () noexcept Returns the underlying C handle. |
| constexpr | operator const MDBX_env * () noexcept const Returns the underlying C handle (read-only). |
| env & | operator= (const env &) noexcept Copy assignment operator. |
| env & | operator= (env_managed &&) = delete |
| bool | poll_sync_to_disk () Performs non-blocking polling of sync-to-disk thresholds. |
| env & | set_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. |
| size_t | transaction_size_max () const Returns the maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes. |
| size_t | value_max (value_mode mode) const Returns the maximal value size in bytes for specified values mode. |
| size_t | value_min (value_mode mode) noexcept const Returns the minimal value size in bytes for specified values mode. |
Public Static Functions
| Type | Name |
|---|---|
| env_managed | open_for_recovery (const char * pathname, unsigned target_meta, bool writeable, unsigned max_maps=2) Opens an environment instance using a specific meta-page for checking and recovery. |
| env_managed | open_for_recovery (const ::std::string & pathname, unsigned target_meta, bool writeable, unsigned max_maps=2) Opens an environment instance using a specific meta-page for checking and recovery. |
| env_managed | open_for_recovery (const ::mdbx::filesystem::path & pathname, unsigned target_meta, bool writeable, unsigned max_maps=2) Opens an environment instance using a specific meta-page for checking and recovery. |
| env_managed | open_for_recovery (const wchar_t * pathname, unsigned target_meta, bool writeable, unsigned max_maps=2) Opens an environment instance using a specific meta-page for checking and recovery. |
| env_managed | open_for_recovery (const ::std::wstring & pathname, unsigned target_meta, bool writeable, unsigned max_maps=2) Opens an environment instance using a specific meta-page for checking and recovery. |
Public Static Functions inherited from mdbx::env
See mdbx::env
| Type | Name |
|---|---|
| size_t | default_pagesize () noexcept Returns default page size for current system/platform. |
| MDBX_NODISCARD info | get_preopen_snapinfo (const ::std::wstring & pathname, MDBX_preopen_flags mode=MDBX_PREOPEN_PROPERLY) Provides information about a database, including meta-page and geometry, without opening it. |
| MDBX_NODISCARD info | get_preopen_snapinfo (const wchar_t * pathname, MDBX_preopen_flags mode=MDBX_PREOPEN_PROPERLY) Provides information about a database, including meta-page and geometry, without opening it. |
| 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. |
| bool | remove (const ::std::wstring & pathname, const remove_mode mode=just_remove) Removes the environment's files in a proper and multiprocess-safe way. |
| bool | remove (const wchar_t * pathname, const remove_mode mode=just_remove) Removes the environment's files in a proper and multiprocess-safe way. |
| bool | remove (const ::std::string & pathname, const remove_mode mode=just_remove) Removes the environment's files in a proper and multiprocess-safe way. |
| bool | remove (const char * pathname, const remove_mode mode=just_remove) Removes the environment's files in a proper and multiprocess-safe way. |
Protected Attributes inherited from mdbx::env
See mdbx::env
| Type | Name |
|---|---|
| MDBX_env * | handle_ = {nullptr}The underlying C environment handle, null for an empty instance. |
Detailed Description
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.
Public Functions Documentation
function close
Explicitly closes the environment and release the memory map.
void mdbx::env_managed::close (
bool dont_sync=false
)
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:
dont_syncThe dont_sync flag, if non-zero the last checkpoint will be kept "as is" and may be still "weak" in the env::durability::lazy_weak_tail or env::durability::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.
function env_managed [2/14]
Constructs an empty (not opened) managed environment.
constexpr mdbx::env_managed::env_managed () noexcept
function env_managed [3/14]
Open existing database.
mdbx::env_managed::env_managed (
const ::mdbx::filesystem::path & pathname,
const operate_parameters & params,
bool accede=true
)
Parameters:
pathnameThe path to the database.paramsThe operate parameters, see operate_parameters.accedeOpen with the parameters the database was created with, instead of failing on a mismatch.
Exception:
- mdbx::error on failure.
function env_managed [4/14]
Open existing database (the operate_parameters overload for a wide-string path).
mdbx::env_managed::env_managed (
const ::std::wstring & pathname,
const operate_parameters & params,
bool accede=true
)
Parameters:
pathnameThe path to the database.paramsThe operate parameters, see operate_parameters.accedeOpen with the parameters the database was created with.
Exception:
- mdbx::error on failure.
function env_managed [5/14]
Open existing database (the operate_parameters overload for a wide-string path).
explicit mdbx::env_managed::env_managed (
const wchar_t * pathname,
const operate_parameters & params,
bool accede=true
)
Parameters:
pathnameThe path to the database.paramsThe operate parameters, see operate_parameters.accedeOpen with the parameters the database was created with.
Exception:
- mdbx::error on failure.
function env_managed [6/14]
Open existing database (the operate_parameters overload for a narrow-string path).
mdbx::env_managed::env_managed (
const ::std::string & pathname,
const operate_parameters & params,
bool accede=true
)
Parameters:
pathnameThe path to the database.paramsThe operate parameters, see operate_parameters.accedeOpen with the parameters the database was created with.
Exception:
- mdbx::error on failure.
function env_managed [7/14]
Open existing database (the operate_parameters overload for a C-string path).
explicit mdbx::env_managed::env_managed (
const char * pathname,
const operate_parameters & params,
bool accede=true
)
Parameters:
pathnameThe path to the database.paramsThe operate parameters, see operate_parameters.accedeOpen with the parameters the database was created with.
Exception:
- mdbx::error on failure.
function env_managed [8/14]
Create new or open existing database.
mdbx::env_managed::env_managed (
const ::mdbx::filesystem::path & pathname,
const create_parameters & create_params,
const operate_parameters & operate_params,
bool accede=true
)
Parameters:
pathnameThe path to the database.create_paramsThe create parameters, see create_parameters.operate_paramsThe operate parameters, see operate_parameters.accedeOpen with the parameters the database was created with, instead of failing on a mismatch.
Exception:
- mdbx::error on failure.
function env_managed [9/14]
Create new or open existing database (wide-string path overload).
mdbx::env_managed::env_managed (
const ::std::wstring & pathname,
const create_parameters & create_params,
const operate_parameters & operate_params,
bool accede=true
)
Parameters:
pathnameThe path to the database.create_paramsThe create parameters, see create_parameters.operate_paramsThe operate parameters, see operate_parameters.accedeOpen with the parameters the database was created with.
Exception:
- mdbx::error on failure.
function env_managed [10/14]
Create new or open existing database (wide-string path overload).
explicit mdbx::env_managed::env_managed (
const wchar_t * pathname,
const create_parameters & create_params,
const operate_parameters & operate_params,
bool accede=true
)
Parameters:
pathnameThe path to the database.create_paramsThe create parameters, see create_parameters.operate_paramsThe operate parameters, see operate_parameters.accedeOpen with the parameters the database was created with.
Exception:
- mdbx::error on failure.
function env_managed [11/14]
Create new or open existing database (narrow-string path overload).
mdbx::env_managed::env_managed (
const ::std::string & pathname,
const create_parameters & create_params,
const operate_parameters & operate_params,
bool accede=true
)
Parameters:
pathnameThe path to the database.create_paramsThe create parameters, see create_parameters.operate_paramsThe operate parameters, see operate_parameters.accedeOpen with the parameters the database was created with.
Exception:
- mdbx::error on failure.
function env_managed [12/14]
Create new or open existing database (C-string path overload).
explicit mdbx::env_managed::env_managed (
const char * pathname,
const create_parameters & create_params,
const operate_parameters & operate_params,
bool accede=true
)
Parameters:
pathnameThe path to the database.create_paramsThe create parameters, see create_parameters.operate_paramsThe operate parameters, see operate_parameters.accedeOpen with the parameters the database was created with.
Exception:
- mdbx::error on failure.
function env_managed [13/14]
Move constructor.
mdbx::env_managed::env_managed (
env_managed &&
) = default
function env_managed [14/14]
mdbx::env_managed::env_managed (
const env_managed &
) = delete
function operator=
Move assignment operator.
env_managed & mdbx::env_managed::operator= (
env_managed && other
) noexcept
Parameters:
otherThe source managed environment to be moved from.
Returns:
A reference to this instance.
function operator=
env_managed & mdbx::env_managed::operator= (
const env_managed &
) = delete
function ~env_managed
virtual mdbx::env_managed::~env_managed ()
Public Static Functions Documentation
function open_for_recovery [1/5]
Opens an environment instance using a specific meta-page for checking and recovery.
static env_managed mdbx::env_managed::open_for_recovery (
const char * pathname,
unsigned target_meta,
bool writeable,
unsigned max_maps=2
)
Creates a new environment and opens it in the recovery mode, bypassing the regular consistency checks. Mostly an internal API for the mdbx_chk utility and subject to change; use only when you know what you are doing. The opened environment may be used e.g. with env::chk() and env::turn_for_recovery().
Parameters:
pathnameThe path to the database file.target_metaThe number of the meta-page to use (0..2), or any value for the default behavior.writeableWhether to open in read-write mode.max_mapsThe maximum number of named tables/maps, must be set before opening; zero means the library default. The recovery tooling uses 2 (MainDB+GC).
Returns:
The opened managed environment.
See also: mdbx_env_open_for_recovery()
function open_for_recovery [2/5]
Opens an environment instance using a specific meta-page for checking and recovery.
static env_managed mdbx::env_managed::open_for_recovery (
const ::std::string & pathname,
unsigned target_meta,
bool writeable,
unsigned max_maps=2
)
Parameters:
pathnameThe path to the database file.target_metaThe number of the meta-page to use (0..2), or any value for the default behavior.writeableWhether to open in read-write mode.max_mapsThe maximum number of named tables/maps.
Returns:
The opened managed environment.
function open_for_recovery [3/5]
Opens an environment instance using a specific meta-page for checking and recovery.
static env_managed mdbx::env_managed::open_for_recovery (
const ::mdbx::filesystem::path & pathname,
unsigned target_meta,
bool writeable,
unsigned max_maps=2
)
Parameters:
pathnameThe path to the database file.target_metaThe number of the meta-page to use (0..2), or any value for the default behavior.writeableWhether to open in read-write mode.max_mapsThe maximum number of named tables/maps.
Returns:
The opened managed environment.
function open_for_recovery [4/5]
Opens an environment instance using a specific meta-page for checking and recovery.
static env_managed mdbx::env_managed::open_for_recovery (
const wchar_t * pathname,
unsigned target_meta,
bool writeable,
unsigned max_maps=2
)
Parameters:
pathnameThe path to the database file.target_metaThe number of the meta-page to use (0..2), or any value for the default behavior.writeableWhether to open in read-write mode.max_mapsThe maximum number of named tables/maps.
Returns:
The opened managed environment.
function open_for_recovery [5/5]
Opens an environment instance using a specific meta-page for checking and recovery.
static env_managed mdbx::env_managed::open_for_recovery (
const ::std::wstring & pathname,
unsigned target_meta,
bool writeable,
unsigned max_maps=2
)
Parameters:
pathnameThe path to the database file.target_metaThe number of the meta-page to use (0..2), or any value for the default behavior.writeableWhether to open in read-write mode.max_mapsThe maximum number of named tables/maps.
Returns:
The opened managed environment.
The documentation for this class was generated from the following file mdbx.h++