more TDB
This commit is contained in:
parent
f4a863e52e
commit
90789973de
|
@ -40,12 +40,19 @@ typedef struct SFreeCell {
|
|||
u16 next;
|
||||
} SFreeCell;
|
||||
|
||||
typedef struct {
|
||||
u16 flags;
|
||||
SBTree *pBt;
|
||||
} SBtreeZeroPageArg;
|
||||
|
||||
static int tdbBtCursorMoveTo(SBtCursor *pCur, const void *pKey, int kLen);
|
||||
static int tdbEncodeLength(u8 *pBuf, uint32_t len);
|
||||
static int tdbBtCursorMoveToRoot(SBtCursor *pCur);
|
||||
static int tdbCompareKeyAndCell(const void *pKey, int kLen, const void *pCell);
|
||||
static int tdbDefaultKeyCmprFn(const void *pKey1, int keyLen1, const void *pKey2, int keyLen2);
|
||||
static int tdbBtreeOpenImpl(SBTree *pBt);
|
||||
static int tdbBtreeZeroPage(SPage *pPage, void *arg);
|
||||
static int tdbBtreeInitPage(SPage *pPage, void *arg);
|
||||
|
||||
int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, FKeyComparator kcmpr, SBTree **ppBt) {
|
||||
SBTree *pBt;
|
||||
|
@ -110,8 +117,8 @@ int tdbBtreeCursor(SBtCursor *pCur, SBTree *pBt) {
|
|||
}
|
||||
|
||||
int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *pVal, int vLen) {
|
||||
int ret;
|
||||
SPager * pPager;
|
||||
int ret;
|
||||
SPager *pPager;
|
||||
|
||||
ret = tdbBtCursorMoveTo(pCur, pKey, kLen);
|
||||
if (ret < 0) {
|
||||
|
@ -123,8 +130,8 @@ int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *p
|
|||
}
|
||||
|
||||
static int tdbBtCursorMoveTo(SBtCursor *pCur, const void *pKey, int kLen) {
|
||||
int ret;
|
||||
void * pCell;
|
||||
int ret;
|
||||
void *pCell;
|
||||
|
||||
// ret = tdbBtCursorMoveToRoot(pCur);
|
||||
// if (ret < 0) {
|
||||
|
@ -296,45 +303,46 @@ static int tdbBtreeOpenImpl(SBTree *pBt) {
|
|||
}
|
||||
|
||||
static int tdbBtreeZeroPage(SPage *pPage, void *arg) {
|
||||
u16 flags;
|
||||
SBTree *pBt;
|
||||
|
||||
flags = ((SBtreeZeroPageArg *)arg)->flags;
|
||||
pBt = ((SBtreeZeroPageArg *)arg)->pBt;
|
||||
|
||||
pPage->pPageHdr = (SPageHdr *)pPage->pData;
|
||||
pPage->aCellIdx = (u16 *)(&(pPage->pPageHdr[1]));
|
||||
|
||||
// Init the page header
|
||||
{
|
||||
#if 0
|
||||
pPage->pPageHdr->flags = 0;
|
||||
pPage->pPageHdr->nCells = 0;
|
||||
pPage->pPageHdr->cellCont = 0;
|
||||
pPage->pPageHdr->freeCell = 0;
|
||||
pPage->pPageHdr->nFree = 0;
|
||||
#endif
|
||||
}
|
||||
pPage->pPageHdr->flags = flags;
|
||||
pPage->pPageHdr->nCells = 0;
|
||||
pPage->pPageHdr->cellCont = 0;
|
||||
pPage->pPageHdr->freeCell = 0;
|
||||
pPage->pPageHdr->nFree = 0;
|
||||
|
||||
// Init other fields
|
||||
{
|
||||
#if 0
|
||||
pPage->kLen = pBt->keyLen;
|
||||
pPage->vLen = pBt->valLen;
|
||||
pPage->maxLocal = pBt->maxLocal;
|
||||
pPage->minLocal = pBt->minLocal;
|
||||
#endif
|
||||
}
|
||||
tdbBtreeInitPage(pPage, (void *)pBt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int tdbBtreeInitPage(SPage *pPage, void *arg) {
|
||||
SBTree *pBt;
|
||||
|
||||
pBt = (SBTree *)arg;
|
||||
|
||||
pPage->pPageHdr = (SPageHdr *)pPage->pData;
|
||||
pPage->aCellIdx = (u16 *)(&(pPage->pPageHdr[1]));
|
||||
|
||||
// Init other fields
|
||||
{
|
||||
#if 0
|
||||
pPage->kLen = pBt->keyLen;
|
||||
pPage->vLen = pBt->valLen;
|
||||
pPage->maxLocal = pBt->maxLocal;
|
||||
pPage->minLocal = pBt->minLocal;
|
||||
#endif
|
||||
if (TDB_BTREE_PAGE_IS_LEAF(pPage->pPageHdr->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;
|
||||
|
|
Loading…
Reference in New Issue