mirror of
https://github.com/isar/libmdbx.git
synced 2025-02-01 13:58:20 +08:00
mdbx: refine/simplify MDBX_node.
Change-Id: Idb3843727a409c3ef8d1d54e226a6f578a57c32e
This commit is contained in:
parent
daddd53793
commit
8768641872
@ -59,7 +59,7 @@ static __inline unsigned mdbx_log2(size_t value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Address of node i in page p */
|
/* Address of node i in page p */
|
||||||
static __inline MDBX_node *NODEPTR(MDBX_page *p, unsigned i) {
|
static __inline MDBX_node *NODEPTR(const MDBX_page *p, unsigned i) {
|
||||||
assert(NUMKEYS(p) > (unsigned)(i));
|
assert(NUMKEYS(p) > (unsigned)(i));
|
||||||
return (MDBX_node *)((char *)(p) + (p)->mp_ptrs[i] + PAGEHDRSZ);
|
return (MDBX_node *)((char *)(p) + (p)->mp_ptrs[i] + PAGEHDRSZ);
|
||||||
}
|
}
|
||||||
@ -68,7 +68,7 @@ static __inline MDBX_node *NODEPTR(MDBX_page *p, unsigned i) {
|
|||||||
static __inline pgno_t NODEPGNO(const MDBX_node *node) {
|
static __inline pgno_t NODEPGNO(const MDBX_node *node) {
|
||||||
pgno_t pgno;
|
pgno_t pgno;
|
||||||
if (MDBX_UNALIGNED_OK) {
|
if (MDBX_UNALIGNED_OK) {
|
||||||
pgno = node->mn_ksize_and_pgno;
|
pgno = node->mn_pgno32;
|
||||||
if (sizeof(pgno_t) > 4)
|
if (sizeof(pgno_t) > 4)
|
||||||
pgno &= MAX_PAGENO;
|
pgno &= MAX_PAGENO;
|
||||||
} else {
|
} else {
|
||||||
@ -85,13 +85,13 @@ static __inline void SETPGNO(MDBX_node *node, pgno_t pgno) {
|
|||||||
|
|
||||||
if (MDBX_UNALIGNED_OK) {
|
if (MDBX_UNALIGNED_OK) {
|
||||||
if (sizeof(pgno_t) > 4)
|
if (sizeof(pgno_t) > 4)
|
||||||
pgno |= ((uint64_t)node->mn_ksize) << 48;
|
pgno |= ((uint64_t)node->mn_ksize) << 32;
|
||||||
node->mn_ksize_and_pgno = pgno;
|
node->mn_pgno32 = pgno;
|
||||||
} else {
|
} else {
|
||||||
node->mn_lo = (uint16_t)pgno;
|
node->mn_lo = (uint16_t)pgno;
|
||||||
node->mn_hi = (uint16_t)(pgno >> 16);
|
node->mn_hi = (uint16_t)(pgno >> 16);
|
||||||
if (sizeof(pgno_t) > 4)
|
if (sizeof(pgno_t) > 4)
|
||||||
node->mn_flags = (uint16_t)((uint64_t)pgno >> 32);
|
node->mn_ksize = (uint16_t)((uint64_t)pgno >> 32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1243,30 +1243,26 @@ MDBX_INTERNAL_FUNC void mdbx_rthc_thread_dtor(void *ptr);
|
|||||||
* F_DUPDATA and F_SUBDATA can be combined giving duplicate data in
|
* F_DUPDATA and F_SUBDATA can be combined giving duplicate data in
|
||||||
* a sub-page/sub-database, and named databases (just F_SUBDATA). */
|
* a sub-page/sub-database, and named databases (just F_SUBDATA). */
|
||||||
typedef struct MDBX_node {
|
typedef struct MDBX_node {
|
||||||
|
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
uint16_t mn_lo, mn_hi; /* part of data size or pgno */
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
uint16_t mn_lo, mn_hi; /* part of data size or pgno */
|
|
||||||
};
|
|
||||||
uint32_t mn_dsize;
|
|
||||||
};
|
|
||||||
uint16_t mn_flags; /* see mdbx_node */
|
|
||||||
uint16_t mn_ksize; /* key size */
|
|
||||||
#else
|
|
||||||
uint16_t mn_ksize; /* key size */
|
|
||||||
uint16_t mn_flags; /* see mdbx_node */
|
|
||||||
union {
|
|
||||||
struct {
|
|
||||||
uint16_t mn_hi, mn_lo; /* part of data size or pgno */
|
|
||||||
};
|
|
||||||
uint32_t mn_dsize;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
pgno_t mn_ksize_and_pgno;
|
uint32_t mn_dsize;
|
||||||
|
uint32_t mn_pgno32;
|
||||||
};
|
};
|
||||||
|
uint16_t mn_flags; /* see mdbx_node */
|
||||||
|
uint16_t mn_ksize; /* key size */
|
||||||
|
#else
|
||||||
|
uint16_t mn_ksize; /* key size */
|
||||||
|
uint16_t mn_flags; /* see mdbx_node */
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
uint16_t mn_hi, mn_lo; /* part of data size or pgno */
|
||||||
|
};
|
||||||
|
uint32_t mn_dsize;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
/* mdbx_node Flags */
|
/* mdbx_node Flags */
|
||||||
#define F_BIGDATA 0x01 /* data put on overflow page */
|
#define F_BIGDATA 0x01 /* data put on overflow page */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user