From 25ab65b470b953b0fc688158fd37ffa502f05452 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Mon, 10 Oct 2022 16:37:59 +0300 Subject: [PATCH] =?UTF-8?q?mdbx++:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20`env::limits::pairsize4page=5Fmax()`?= =?UTF-8?q?=20=D0=B8=20`env::limits::valsize4page=5Fmax()`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mdbx.h++ | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/mdbx.h++ b/mdbx.h++ index 473def91..dddc1880 100644 --- a/mdbx.h++ +++ b/mdbx.h++ @@ -3177,6 +3177,7 @@ public: /// \brief Returns the minimal values size in bytes for specified values /// mode. static inline size_t value_min(value_mode) noexcept; + /// \brief Returns the maximal value size in bytes for specified page size /// and database flags. static inline size_t value_max(intptr_t pagesize, MDBX_db_flags_t flags); @@ -3189,6 +3190,35 @@ public: /// \brief Returns the maximal value size in bytes for specified page size /// and values mode. static inline size_t value_max(const env &, value_mode); + + /// \brief Returns maximal size of key-value pair to fit in a single page + /// for specified size and database flags. + static inline size_t pairsize4page_max(intptr_t pagesize, + MDBX_db_flags_t flags); + /// \brief Returns maximal size of key-value pair to fit in a single page + /// for specified page size and values mode. + static inline size_t pairsize4page_max(intptr_t pagesize, value_mode); + /// \brief Returns maximal size of key-value pair to fit in a single page + /// for given environment and database flags. + static inline size_t pairsize4page_max(const env &, MDBX_db_flags_t flags); + /// \brief Returns maximal size of key-value pair to fit in a single page + /// for specified page size and values mode. + static inline size_t pairsize4page_max(const env &, value_mode); + + /// \brief Returns maximal data size in bytes to fit in a leaf-page or + /// single overflow/large-page for specified size and database flags. + static inline size_t valsize4page_max(intptr_t pagesize, + MDBX_db_flags_t flags); + /// \brief Returns maximal data size in bytes to fit in a leaf-page or + /// single overflow/large-page for specified page size and values mode. + static inline size_t valsize4page_max(intptr_t pagesize, value_mode); + /// \brief Returns maximal data size in bytes to fit in a leaf-page or + /// single overflow/large-page for given environment and database flags. + static inline size_t valsize4page_max(const env &, MDBX_db_flags_t flags); + /// \brief Returns maximal data size in bytes to fit in a leaf-page or + /// single overflow/large-page for specified page size and values mode. + static inline size_t valsize4page_max(const env &, value_mode); + /// \brief Returns the maximal write transaction size (i.e. limit for /// summary volume of dirty pages) in bytes for specified page size. static inline size_t transaction_size_max(intptr_t pagesize); @@ -4882,6 +4912,56 @@ inline size_t env::limits::value_max(const env &env, value_mode mode) { return value_max(env, MDBX_db_flags_t(mode)); } +inline size_t env::limits::pairsize4page_max(intptr_t pagesize, + MDBX_db_flags_t flags) { + const intptr_t result = mdbx_limits_pairsize4page_max(pagesize, flags); + if (result < 0) + MDBX_CXX20_UNLIKELY error::throw_exception(MDBX_EINVAL); + return static_cast(result); +} + +inline size_t env::limits::pairsize4page_max(intptr_t pagesize, + value_mode mode) { + return pairsize4page_max(pagesize, MDBX_db_flags_t(mode)); +} + +inline size_t env::limits::pairsize4page_max(const env &env, + MDBX_db_flags_t flags) { + const intptr_t result = mdbx_env_get_pairsize4page_max(env, flags); + if (result < 0) + MDBX_CXX20_UNLIKELY error::throw_exception(MDBX_EINVAL); + return static_cast(result); +} + +inline size_t env::limits::pairsize4page_max(const env &env, value_mode mode) { + return pairsize4page_max(env, MDBX_db_flags_t(mode)); +} + +inline size_t env::limits::valsize4page_max(intptr_t pagesize, + MDBX_db_flags_t flags) { + const intptr_t result = mdbx_limits_valsize4page_max(pagesize, flags); + if (result < 0) + MDBX_CXX20_UNLIKELY error::throw_exception(MDBX_EINVAL); + return static_cast(result); +} + +inline size_t env::limits::valsize4page_max(intptr_t pagesize, + value_mode mode) { + return valsize4page_max(pagesize, MDBX_db_flags_t(mode)); +} + +inline size_t env::limits::valsize4page_max(const env &env, + MDBX_db_flags_t flags) { + const intptr_t result = mdbx_env_get_valsize4page_max(env, flags); + if (result < 0) + MDBX_CXX20_UNLIKELY error::throw_exception(MDBX_EINVAL); + return static_cast(result); +} + +inline size_t env::limits::valsize4page_max(const env &env, value_mode mode) { + return valsize4page_max(env, MDBX_db_flags_t(mode)); +} + inline size_t env::limits::transaction_size_max(intptr_t pagesize) { const intptr_t result = mdbx_limits_txnsize_max(pagesize); if (result < 0)