version 1.15, 2007/02/03 23:46:09 |
version 1.16, 2008/08/26 21:18:38 |
Line 78 typedef struct _page { |
|
Line 78 typedef struct _page { |
|
#define P_RLEAF 0x10 /* leaf page */ |
#define P_RLEAF 0x10 /* leaf page */ |
#define P_TYPE 0x1f /* type mask */ |
#define P_TYPE 0x1f /* type mask */ |
#define P_PRESERVE 0x20 /* never delete this chain of pages */ |
#define P_PRESERVE 0x20 /* never delete this chain of pages */ |
u_int32_t flags; |
uint32_t flags; |
|
|
indx_t lower; /* lower bound of free space on page */ |
indx_t lower; /* lower bound of free space on page */ |
indx_t upper; /* upper bound of free space on page */ |
indx_t upper; /* upper bound of free space on page */ |
Line 88 typedef struct _page { |
|
Line 88 typedef struct _page { |
|
/* First and next index. */ |
/* First and next index. */ |
#define BTDATAOFF \ |
#define BTDATAOFF \ |
(sizeof(pgno_t) + sizeof(pgno_t) + sizeof(pgno_t) + \ |
(sizeof(pgno_t) + sizeof(pgno_t) + sizeof(pgno_t) + \ |
sizeof(u_int32_t) + sizeof(indx_t) + sizeof(indx_t)) |
sizeof(uint32_t) + sizeof(indx_t) + sizeof(indx_t)) |
|
|
#define _NEXTINDEX(p) (((p)->lower - BTDATAOFF) / sizeof(indx_t)) |
#define _NEXTINDEX(p) (((p)->lower - BTDATAOFF) / sizeof(indx_t)) |
#ifdef _DIAGNOSTIC |
#ifdef _DIAGNOSTIC |
Line 119 NEXTINDEX(const PAGE *p) { |
|
Line 119 NEXTINDEX(const PAGE *p) { |
|
* manipulated on this system.) |
* manipulated on this system.) |
*/ |
*/ |
#define BTLALIGN(n) (((n) + sizeof(pgno_t) - 1) & ~(sizeof(pgno_t) - 1)) |
#define BTLALIGN(n) (((n) + sizeof(pgno_t) - 1) & ~(sizeof(pgno_t) - 1)) |
#define NOVFLSIZE (sizeof(pgno_t) + sizeof(u_int32_t)) |
#define NOVFLSIZE (sizeof(pgno_t) + sizeof(uint32_t)) |
|
|
/* |
/* |
* For the btree internal pages, the item is a key. BINTERNALs are {key, pgno} |
* For the btree internal pages, the item is a key. BINTERNALs are {key, pgno} |
Line 131 NEXTINDEX(const PAGE *p) { |
|
Line 131 NEXTINDEX(const PAGE *p) { |
|
* some minor modifications of the above rule. |
* some minor modifications of the above rule. |
*/ |
*/ |
typedef struct _binternal { |
typedef struct _binternal { |
u_int32_t ksize; /* key size */ |
uint32_t ksize; /* key size */ |
pgno_t pgno; /* page number stored on */ |
pgno_t pgno; /* page number stored on */ |
#define P_BIGDATA 0x01 /* overflow data */ |
#define P_BIGDATA 0x01 /* overflow data */ |
#define P_BIGKEY 0x02 /* overflow key */ |
#define P_BIGKEY 0x02 /* overflow key */ |
u_char flags; |
uint8_t flags; |
char bytes[1]; /* data */ |
char bytes[1]; /* data */ |
} BINTERNAL; |
} BINTERNAL; |
|
|
Line 145 typedef struct _binternal { |
|
Line 145 typedef struct _binternal { |
|
|
|
/* Get the number of bytes in the entry. */ |
/* Get the number of bytes in the entry. */ |
#define _NBINTERNAL(len) \ |
#define _NBINTERNAL(len) \ |
BTLALIGN(sizeof(u_int32_t) + sizeof(pgno_t) + sizeof(u_char) + (len)) |
BTLALIGN(sizeof(uint32_t) + sizeof(pgno_t) + sizeof(uint8_t) + (len)) |
#ifdef _DIAGNOSTIC |
#ifdef _DIAGNOSTIC |
static __inline u_int32_t |
static __inline uint32_t |
NBINTERNAL(u_int32_t len) { |
NBINTERNAL(uint32_t len) { |
size_t x = _NBINTERNAL(len); |
size_t x = _NBINTERNAL(len); |
_DBFIT(x, u_int32_t); |
_DBFIT(x, uint32_t); |
return (u_int32_t)x; |
return (uint32_t)x; |
} |
} |
#else |
#else |
#define NBINTERNAL(len) (u_int32_t)_NBINTERNAL(len) |
#define NBINTERNAL(len) (uint32_t)_NBINTERNAL(len) |
#endif |
#endif |
|
|
/* Copy a BINTERNAL entry to the page. */ |
/* Copy a BINTERNAL entry to the page. */ |
#define WR_BINTERNAL(p, size, pgno, flags) do { \ |
#define WR_BINTERNAL(p, size, pgno, flags) do { \ |
_DBFIT(size, u_int32_t); \ |
_DBFIT(size, uint32_t); \ |
*(u_int32_t *)(void *)p = (u_int32_t)size; \ |
*(uint32_t *)(void *)p = (uint32_t)size; \ |
p += sizeof(u_int32_t); \ |
p += sizeof(uint32_t); \ |
*(pgno_t *)(void *)p = pgno; \ |
*(pgno_t *)(void *)p = pgno; \ |
p += sizeof(pgno_t); \ |
p += sizeof(pgno_t); \ |
*(u_char *)(void *)p = flags; \ |
*(uint8_t *)(void *)p = flags; \ |
p += sizeof(u_char); \ |
p += sizeof(uint8_t); \ |
} while (/*CONSTCOND*/0) |
} while (/*CONSTCOND*/0) |
|
|
/* |
/* |
Line 194 typedef struct _rinternal { |
|
Line 194 typedef struct _rinternal { |
|
|
|
/* For the btree leaf pages, the item is a key and data pair. */ |
/* For the btree leaf pages, the item is a key and data pair. */ |
typedef struct _bleaf { |
typedef struct _bleaf { |
u_int32_t ksize; /* size of key */ |
uint32_t ksize; /* size of key */ |
u_int32_t dsize; /* size of data */ |
uint32_t dsize; /* size of data */ |
u_char flags; /* P_BIGDATA, P_BIGKEY */ |
uint8_t flags; /* P_BIGDATA, P_BIGKEY */ |
char bytes[1]; /* data */ |
char bytes[1]; /* data */ |
} BLEAF; |
} BLEAF; |
|
|
Line 207 typedef struct _bleaf { |
|
Line 207 typedef struct _bleaf { |
|
|
|
/* Get the number of bytes in the user's key/data pair. */ |
/* Get the number of bytes in the user's key/data pair. */ |
#define _NBLEAFDBT(ksize, dsize) \ |
#define _NBLEAFDBT(ksize, dsize) \ |
BTLALIGN(sizeof(u_int32_t) + sizeof(u_int32_t) + sizeof(u_char) + \ |
BTLALIGN(sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint8_t) + \ |
(ksize) + (dsize)) |
(ksize) + (dsize)) |
#ifdef _DIAGNOSTIC |
#ifdef _DIAGNOSTIC |
static __inline u_int32_t |
static __inline uint32_t |
NBLEAFDBT(size_t k, size_t d) { |
NBLEAFDBT(size_t k, size_t d) { |
size_t x = _NBLEAFDBT(k, d); |
size_t x = _NBLEAFDBT(k, d); |
_DBFIT(x, u_int32_t); |
_DBFIT(x, uint32_t); |
return (u_int32_t)x; |
return (uint32_t)x; |
} |
} |
#else |
#else |
#define NBLEAFDBT(p, q) (u_int32_t)_NBLEAFDBT(p, q) |
#define NBLEAFDBT(p, q) (uint32_t)_NBLEAFDBT(p, q) |
#endif |
#endif |
|
|
/* Get the number of bytes in the entry. */ |
/* Get the number of bytes in the entry. */ |
Line 225 NBLEAFDBT(size_t k, size_t d) { |
|
Line 225 NBLEAFDBT(size_t k, size_t d) { |
|
|
|
/* Copy a BLEAF entry to the page. */ |
/* Copy a BLEAF entry to the page. */ |
#define WR_BLEAF(p, key, data, flags) do { \ |
#define WR_BLEAF(p, key, data, flags) do { \ |
_DBFIT(key->size, u_int32_t); \ |
_DBFIT(key->size, uint32_t); \ |
*(u_int32_t *)(void *)p = (u_int32_t)key->size; \ |
*(uint32_t *)(void *)p = (uint32_t)key->size; \ |
p += sizeof(u_int32_t); \ |
p += sizeof(uint32_t); \ |
_DBFIT(data->size, u_int32_t); \ |
_DBFIT(data->size, uint32_t); \ |
*(u_int32_t *)(void *)p = (u_int32_t)data->size; \ |
*(uint32_t *)(void *)p = (uint32_t)data->size; \ |
p += sizeof(u_int32_t); \ |
p += sizeof(uint32_t); \ |
*(u_char *)(void *)p = flags; \ |
*(uint8_t *)(void *)p = flags; \ |
p += sizeof(u_char); \ |
p += sizeof(uint8_t); \ |
(void)memmove(p, key->data, key->size); \ |
(void)memmove(p, key->data, key->size); \ |
p += key->size; \ |
p += key->size; \ |
(void)memmove(p, data->data, data->size); \ |
(void)memmove(p, data->data, data->size); \ |
Line 240 NBLEAFDBT(size_t k, size_t d) { |
|
Line 240 NBLEAFDBT(size_t k, size_t d) { |
|
|
|
/* For the recno leaf pages, the item is a data entry. */ |
/* For the recno leaf pages, the item is a data entry. */ |
typedef struct _rleaf { |
typedef struct _rleaf { |
u_int32_t dsize; /* size of data */ |
uint32_t dsize; /* size of data */ |
u_char flags; /* P_BIGDATA */ |
uint8_t flags; /* P_BIGDATA */ |
char bytes[1]; |
char bytes[1]; |
} RLEAF; |
} RLEAF; |
|
|
Line 250 typedef struct _rleaf { |
|
Line 250 typedef struct _rleaf { |
|
((RLEAF *)(void *)((char *)(void *)(pg) + (pg)->linp[indx])) |
((RLEAF *)(void *)((char *)(void *)(pg) + (pg)->linp[indx])) |
|
|
#define _NRLEAFDBT(dsize) \ |
#define _NRLEAFDBT(dsize) \ |
BTLALIGN(sizeof(u_int32_t) + sizeof(u_char) + (dsize)) |
BTLALIGN(sizeof(uint32_t) + sizeof(uint8_t) + (dsize)) |
|
|
#ifdef _DIAGNOSTIC |
#ifdef _DIAGNOSTIC |
static __inline u_int32_t |
static __inline uint32_t |
NRLEAFDBT(size_t d) { |
NRLEAFDBT(size_t d) { |
size_t x = _NRLEAFDBT(d); |
size_t x = _NRLEAFDBT(d); |
_DBFIT(x, u_int32_t); |
_DBFIT(x, uint32_t); |
return (u_int32_t)x; |
return (uint32_t)x; |
} |
} |
#else |
#else |
#define NRLEAFDBT(d) (u_int32_t)_NRLEAFDBT(d) |
#define NRLEAFDBT(d) (uint32_t)_NRLEAFDBT(d) |
#endif |
#endif |
|
|
/* Get the number of bytes in the entry. */ |
/* Get the number of bytes in the entry. */ |
Line 270 NRLEAFDBT(size_t d) { |
|
Line 270 NRLEAFDBT(size_t d) { |
|
|
|
/* Copy a RLEAF entry to the page. */ |
/* Copy a RLEAF entry to the page. */ |
#define WR_RLEAF(p, data, flags) do { \ |
#define WR_RLEAF(p, data, flags) do { \ |
_DBFIT(data->size, u_int32_t); \ |
_DBFIT(data->size, uint32_t); \ |
*(u_int32_t *)(void *)p = (u_int32_t)data->size; \ |
*(uint32_t *)(void *)p = (uint32_t)data->size; \ |
p += sizeof(u_int32_t); \ |
p += sizeof(uint32_t); \ |
*(u_char *)(void *)p = flags; \ |
*(uint8_t *)(void *)p = flags; \ |
p += sizeof(u_char); \ |
p += sizeof(uint8_t); \ |
memmove(p, data->data, data->size); \ |
memmove(p, data->data, data->size); \ |
} while (/*CONSTCOND*/0) |
} while (/*CONSTCOND*/0) |
|
|
Line 331 typedef struct _cursor { |
|
Line 331 typedef struct _cursor { |
|
#define CURS_AFTER 0x02 /* B: Unreturned cursor after key. */ |
#define CURS_AFTER 0x02 /* B: Unreturned cursor after key. */ |
#define CURS_BEFORE 0x04 /* B: Unreturned cursor before key. */ |
#define CURS_BEFORE 0x04 /* B: Unreturned cursor before key. */ |
#define CURS_INIT 0x08 /* RB: Cursor initialized. */ |
#define CURS_INIT 0x08 /* RB: Cursor initialized. */ |
u_int8_t flags; |
uint8_t flags; |
} CURSOR; |
} CURSOR; |
|
|
/* |
/* |
Line 340 typedef struct _cursor { |
|
Line 340 typedef struct _cursor { |
|
* put or delete call modify the metadata. |
* put or delete call modify the metadata. |
*/ |
*/ |
typedef struct _btmeta { |
typedef struct _btmeta { |
u_int32_t magic; /* magic number */ |
uint32_t magic; /* magic number */ |
u_int32_t version; /* version */ |
uint32_t version; /* version */ |
u_int32_t psize; /* page size */ |
uint32_t psize; /* page size */ |
u_int32_t free; /* page number of first free page */ |
uint32_t free; /* page number of first free page */ |
u_int32_t nrecs; /* R: number of records */ |
uint32_t nrecs; /* R: number of records */ |
|
|
#define SAVEMETA (B_NODUPS | R_RECNO) |
#define SAVEMETA (B_NODUPS | R_RECNO) |
u_int32_t flags; /* bt_flags & SAVEMETA */ |
uint32_t flags; /* bt_flags & SAVEMETA */ |
} BTMETA; |
} BTMETA; |
|
|
/* The in-memory btree/recno data structure. */ |
/* The in-memory btree/recno data structure. */ |
Line 377 typedef struct _btree { |
|
Line 377 typedef struct _btree { |
|
int bt_fd; /* tree file descriptor */ |
int bt_fd; /* tree file descriptor */ |
|
|
pgno_t bt_free; /* next free page */ |
pgno_t bt_free; /* next free page */ |
u_int32_t bt_psize; /* page size */ |
uint32_t bt_psize; /* page size */ |
indx_t bt_ovflsize; /* cut-off for key/data overflow */ |
indx_t bt_ovflsize; /* cut-off for key/data overflow */ |
int bt_lorder; /* byte order */ |
int bt_lorder; /* byte order */ |
/* sorted order */ |
/* sorted order */ |
Line 401 typedef struct _btree { |
|
Line 401 typedef struct _btree { |
|
|
|
recno_t bt_nrecs; /* R: number of records */ |
recno_t bt_nrecs; /* R: number of records */ |
size_t bt_reclen; /* R: fixed record length */ |
size_t bt_reclen; /* R: fixed record length */ |
u_char bt_bval; /* R: delimiting byte/pad character */ |
uint8_t bt_bval; /* R: delimiting byte/pad character */ |
|
|
/* |
/* |
* NB: |
* NB: |
Line 427 typedef struct _btree { |
|
Line 427 typedef struct _btree { |
|
#define B_DB_LOCK 0x04000 /* DB_LOCK specified. */ |
#define B_DB_LOCK 0x04000 /* DB_LOCK specified. */ |
#define B_DB_SHMEM 0x08000 /* DB_SHMEM specified. */ |
#define B_DB_SHMEM 0x08000 /* DB_SHMEM specified. */ |
#define B_DB_TXN 0x10000 /* DB_TXN specified. */ |
#define B_DB_TXN 0x10000 /* DB_TXN specified. */ |
u_int32_t flags; |
uint32_t flags; |
} BTREE; |
} BTREE; |
|
|
#include "extern.h" |
#include "extern.h" |