mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 22:47:16 +08:00
mdbx: добавление mdbx_env_get_pairsize4page_max()
и mdbx_env_get_valsize4page_max()
.
This commit is contained in:
parent
9cdee2adb5
commit
c3dd60fcb6
26
mdbx.h
26
mdbx.h
@ -3307,6 +3307,32 @@ mdbx_env_get_maxvalsize_ex(const MDBX_env *env, MDBX_db_flags_t flags);
|
|||||||
MDBX_DEPRECATED MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int
|
MDBX_DEPRECATED MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int
|
||||||
mdbx_env_get_maxkeysize(const MDBX_env *env);
|
mdbx_env_get_maxkeysize(const MDBX_env *env);
|
||||||
|
|
||||||
|
/** \brief Returns maximal size of key-value pair to fit in a single page
|
||||||
|
* for specified database flags.
|
||||||
|
* \ingroup c_statinfo
|
||||||
|
*
|
||||||
|
* \param [in] env An environment handle returned by \ref mdbx_env_create().
|
||||||
|
* \param [in] flags Database options (\ref MDBX_DUPSORT, \ref MDBX_INTEGERKEY
|
||||||
|
* and so on). \see db_flags
|
||||||
|
*
|
||||||
|
* \returns The maximum size of a data can write,
|
||||||
|
* or -1 if something is wrong. */
|
||||||
|
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int
|
||||||
|
mdbx_env_get_pairsize4page_max(const MDBX_env *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 database flags.
|
||||||
|
* \ingroup c_statinfo
|
||||||
|
*
|
||||||
|
* \param [in] env An environment handle returned by \ref mdbx_env_create().
|
||||||
|
* \param [in] flags Database options (\ref MDBX_DUPSORT, \ref MDBX_INTEGERKEY
|
||||||
|
* and so on). \see db_flags
|
||||||
|
*
|
||||||
|
* \returns The maximum size of a data can write,
|
||||||
|
* or -1 if something is wrong. */
|
||||||
|
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int
|
||||||
|
mdbx_env_get_valsize4page_max(const MDBX_env *env, MDBX_db_flags_t flags);
|
||||||
|
|
||||||
/** \brief Sets application information (a context pointer) associated with
|
/** \brief Sets application information (a context pointer) associated with
|
||||||
* the environment.
|
* the environment.
|
||||||
* \see mdbx_env_get_userctx()
|
* \see mdbx_env_get_userctx()
|
||||||
|
20
src/core.c
20
src/core.c
@ -546,8 +546,16 @@ __cold intptr_t mdbx_limits_pairsize4page_max(intptr_t pagesize,
|
|||||||
return LEAF_NODE_MAX(pagesize) - NODESIZE;
|
return LEAF_NODE_MAX(pagesize) - NODESIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
intptr_t mdbx_limits_valsize4page_max(intptr_t pagesize,
|
__cold int mdbx_env_get_pairsize4page_max(const MDBX_env *env,
|
||||||
MDBX_db_flags_t flags) {
|
MDBX_db_flags_t flags) {
|
||||||
|
if (unlikely(!env || env->me_signature.weak != MDBX_ME_SIGNATURE))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return (int)mdbx_limits_pairsize4page_max((intptr_t)env->me_psize, flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
__cold intptr_t mdbx_limits_valsize4page_max(intptr_t pagesize,
|
||||||
|
MDBX_db_flags_t flags) {
|
||||||
if (pagesize < 1)
|
if (pagesize < 1)
|
||||||
pagesize = (intptr_t)mdbx_default_pagesize();
|
pagesize = (intptr_t)mdbx_default_pagesize();
|
||||||
if (unlikely(pagesize < (intptr_t)MIN_PAGESIZE ||
|
if (unlikely(pagesize < (intptr_t)MIN_PAGESIZE ||
|
||||||
@ -562,6 +570,14 @@ intptr_t mdbx_limits_valsize4page_max(intptr_t pagesize,
|
|||||||
return PAGEROOM(pagesize);
|
return PAGEROOM(pagesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__cold int mdbx_env_get_valsize4page_max(const MDBX_env *env,
|
||||||
|
MDBX_db_flags_t flags) {
|
||||||
|
if (unlikely(!env || env->me_signature.weak != MDBX_ME_SIGNATURE))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return (int)mdbx_limits_valsize4page_max((intptr_t)env->me_psize, flags);
|
||||||
|
}
|
||||||
|
|
||||||
/* Calculate the size of a leaf node.
|
/* Calculate the size of a leaf node.
|
||||||
*
|
*
|
||||||
* The size depends on the environment's page size; if a data item
|
* The size depends on the environment's page size; if a data item
|
||||||
|
Loading…
x
Reference in New Issue
Block a user