This commit is contained in:
Hongze Cheng 2022-02-27 02:00:42 +00:00
parent 7cd83134d2
commit 2030bdabb8
1 changed files with 14 additions and 12 deletions

View File

@ -29,8 +29,8 @@ struct SBTree {
typedef struct SPgHdr { typedef struct SPgHdr {
u8 flags; u8 flags;
u8 nFree; u8 fragmentTotalSize;
u16 firstFree; u16 firstFreeCellOffset;
u16 nCells; u16 nCells;
u16 pCell; u16 pCell;
i32 kLen; i32 kLen;
@ -48,6 +48,10 @@ struct SBtCursor {
SBTree * pBt; SBTree * pBt;
i8 iPage; i8 iPage;
SBtPage *pPage; SBtPage *pPage;
u16 idx;
u16 idxStack[BTREE_MAX_DEPTH + 1];
SBtPage *pgStack[BTREE_MAX_DEPTH + 1];
void * pBuf;
}; };
typedef struct SFreeCell { typedef struct SFreeCell {
@ -72,16 +76,19 @@ int tdbBtreeClose(SBTree *pBt) {
return 0; return 0;
} }
int tdbBtreeCursor(SBTree *pBt, SBtCursor *pCur) { int tdbBtreeCursor(SBtCursor *pCur, SBTree *pBt) {
pCur->pBt = pBt; pCur->pBt = pBt;
pCur->iPage = -1; pCur->iPage = -1;
/* TODO */ pCur->pPage = NULL;
pCur->idx = 0;
return 0; return 0;
} }
int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *pVal, int vLen) { int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *pVal, int vLen) {
int ret; int ret;
SPFile *pFile; SPFile * pFile;
SBtPage *pPage;
ret = tdbBtCursorMoveTo(pCur, pKey, kLen); ret = tdbBtCursorMoveTo(pCur, pKey, kLen);
if (ret < 0) { if (ret < 0) {
@ -89,12 +96,7 @@ int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *p
return -1; return -1;
} }
pFile = pCur->pBt->pFile; pPage = pCur->pPage;
// ret = tdbPFileWrite(pFile, pCur->pPage);
// if (ret < 0) {
// // TODO: handle error
// return -1;
// }
return 0; return 0;
} }