more TDB
This commit is contained in:
parent
1cee13b0e7
commit
3bda636ba0
|
@ -343,40 +343,6 @@ static int tdbBtreeOpenImpl(SBTree *pBt) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tdbBtreeZeroPage(SPage *pPage, void *arg) {
|
|
||||||
u16 flags;
|
|
||||||
SBTree *pBt;
|
|
||||||
|
|
||||||
flags = ((SBtreeZeroPageArg *)arg)->flags;
|
|
||||||
pBt = ((SBtreeZeroPageArg *)arg)->pBt;
|
|
||||||
|
|
||||||
pPage->pPageHdr = pPage->pData;
|
|
||||||
pPage->pCellIdx = (u8 *)(&(pPage->pPageHdr[1]));
|
|
||||||
|
|
||||||
// Init the page header
|
|
||||||
TDB_PAGE_FLAGS_SET(pPage, flags);
|
|
||||||
TDB_PAGE_NCELLS_SET(pPage, 0);
|
|
||||||
TDB_PAGE_CCELLS_SET(pPage, pBt->pageSize);
|
|
||||||
TDB_PAGE_FCELL_SET(pPage, 0);
|
|
||||||
TDB_PAGE_NFREE_SET(pPage, 0);
|
|
||||||
|
|
||||||
TDB_BTREE_ASSERT_FLAG(flags);
|
|
||||||
|
|
||||||
if (TDB_BTREE_PAGE_IS_LEAF(flags)) {
|
|
||||||
pPage->kLen = pBt->keyLen;
|
|
||||||
pPage->vLen = pBt->valLen;
|
|
||||||
pPage->maxLocal = pBt->maxLeaf;
|
|
||||||
pPage->minLocal = pBt->minLeaf;
|
|
||||||
} else {
|
|
||||||
pPage->kLen = pBt->keyLen;
|
|
||||||
pPage->vLen = sizeof(SPgno);
|
|
||||||
pPage->maxLocal = pBt->maxLocal;
|
|
||||||
pPage->minLocal = pBt->minLocal;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int tdbBtreeInitPage(SPage *pPage, void *arg) {
|
static int tdbBtreeInitPage(SPage *pPage, void *arg) {
|
||||||
SBTree *pBt;
|
SBTree *pBt;
|
||||||
u16 flags;
|
u16 flags;
|
||||||
|
@ -384,8 +350,17 @@ static int tdbBtreeInitPage(SPage *pPage, void *arg) {
|
||||||
pBt = (SBTree *)arg;
|
pBt = (SBTree *)arg;
|
||||||
|
|
||||||
flags = TDB_PAGE_FLAGS(pPage);
|
flags = TDB_PAGE_FLAGS(pPage);
|
||||||
|
if (TDB_BTREE_PAGE_IS_LEAF(flags)) {
|
||||||
|
pPage->szAmHdr = 0;
|
||||||
|
} else {
|
||||||
|
pPage->szAmHdr = sizeof(SBtPageHdr);
|
||||||
|
}
|
||||||
pPage->pPageHdr = pPage->pData;
|
pPage->pPageHdr = pPage->pData;
|
||||||
pPage->pCellIdx = pPage->pPageHdr + pPage->szPageHdr;
|
pPage->pAmHdr = pPage->pPageHdr + pPage->szPageHdr;
|
||||||
|
pPage->pCellIdx = pPage->pAmHdr + pPage->szAmHdr;
|
||||||
|
pPage->pFreeStart = pPage->pCellIdx + pPage->szOffset * TDB_PAGE_NCELLS(pPage);
|
||||||
|
pPage->pFreeEnd = pPage->pData + TDB_PAGE_CCELLS(pPage);
|
||||||
|
pPage->pPageFtr = (SPageFtr *)(pPage->pData + pPage->pageSize - sizeof(SPageFtr));
|
||||||
|
|
||||||
TDB_BTREE_ASSERT_FLAG(flags);
|
TDB_BTREE_ASSERT_FLAG(flags);
|
||||||
|
|
||||||
|
@ -405,6 +380,28 @@ static int tdbBtreeInitPage(SPage *pPage, void *arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int tdbBtreeZeroPage(SPage *pPage, void *arg) {
|
||||||
|
u16 flags;
|
||||||
|
SBTree *pBt;
|
||||||
|
|
||||||
|
flags = ((SBtreeZeroPageArg *)arg)->flags;
|
||||||
|
pBt = ((SBtreeZeroPageArg *)arg)->pBt;
|
||||||
|
|
||||||
|
pPage->pPageHdr = pPage->pData;
|
||||||
|
|
||||||
|
// Init the page header
|
||||||
|
TDB_PAGE_FLAGS_SET(pPage, flags);
|
||||||
|
TDB_PAGE_NCELLS_SET(pPage, 0);
|
||||||
|
TDB_PAGE_CCELLS_SET(pPage, pBt->pageSize - sizeof(SPageFtr));
|
||||||
|
TDB_PAGE_FCELL_SET(pPage, 0);
|
||||||
|
TDB_PAGE_NFREE_SET(pPage, 0);
|
||||||
|
|
||||||
|
tdbBtreeInitPage(pPage, (void *)pBt);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef TDB_BTREE_BALANCE
|
#ifndef TDB_BTREE_BALANCE
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SBTree *pBt;
|
SBTree *pBt;
|
||||||
|
|
|
@ -46,13 +46,14 @@ typedef struct __attribute__((__packed__)) {
|
||||||
} SPageFtr;
|
} SPageFtr;
|
||||||
|
|
||||||
struct SPage {
|
struct SPage {
|
||||||
|
pthread_spinlock_t lock;
|
||||||
u8 *pData;
|
u8 *pData;
|
||||||
int pageSize;
|
int pageSize;
|
||||||
u8 szOffset;
|
u8 szOffset;
|
||||||
u8 szPageHdr;
|
u8 szPageHdr;
|
||||||
u8 szFreeCell;
|
u8 szFreeCell;
|
||||||
pthread_spinlock_t lock;
|
|
||||||
// Fields below used by pager and am
|
// Fields below used by pager and am
|
||||||
|
u8 szAmHdr;
|
||||||
u8 *pPageHdr;
|
u8 *pPageHdr;
|
||||||
u8 *pAmHdr;
|
u8 *pAmHdr;
|
||||||
u8 *pCellIdx;
|
u8 *pCellIdx;
|
||||||
|
|
Loading…
Reference in New Issue