refact
This commit is contained in:
parent
d622916529
commit
f4a863e52e
|
@ -112,7 +112,6 @@ int tdbBtreeCursor(SBtCursor *pCur, SBTree *pBt) {
|
||||||
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;
|
||||||
SPager * pPager;
|
SPager * pPager;
|
||||||
SBtPage *pPage;
|
|
||||||
|
|
||||||
ret = tdbBtCursorMoveTo(pCur, pKey, kLen);
|
ret = tdbBtCursorMoveTo(pCur, pKey, kLen);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -120,20 +119,17 @@ int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *p
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pPage = pCur->pPage;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tdbBtCursorMoveTo(SBtCursor *pCur, const void *pKey, int kLen) {
|
static int tdbBtCursorMoveTo(SBtCursor *pCur, const void *pKey, int kLen) {
|
||||||
int ret;
|
int ret;
|
||||||
SBtPage *pBtPage;
|
|
||||||
void * pCell;
|
void * pCell;
|
||||||
|
|
||||||
ret = tdbBtCursorMoveToRoot(pCur);
|
// ret = tdbBtCursorMoveToRoot(pCur);
|
||||||
if (ret < 0) {
|
// if (ret < 0) {
|
||||||
return -1;
|
// return -1;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// if (pCur->pPage->pHdr->nCells == 0) {
|
// if (pCur->pPage->pHdr->nCells == 0) {
|
||||||
// // Tree is empty
|
// // Tree is empty
|
||||||
|
@ -220,10 +216,9 @@ static int tdbEncodeLength(u8 *pBuf, uint32_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tdbBtCursorMoveToRoot(SBtCursor *pCur) {
|
static int tdbBtCursorMoveToRoot(SBtCursor *pCur) {
|
||||||
SBTree * pBt;
|
SBTree *pBt;
|
||||||
SPager * pPager;
|
SPager *pPager;
|
||||||
SPage * pPage;
|
SPage * pPage;
|
||||||
SBtPage *pBtPage;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pBt = pCur->pBt;
|
pBt = pCur->pBt;
|
||||||
|
|
|
@ -22,15 +22,14 @@ extern "C" {
|
||||||
|
|
||||||
typedef struct SBTree SBTree;
|
typedef struct SBTree SBTree;
|
||||||
typedef struct SBtCursor SBtCursor;
|
typedef struct SBtCursor SBtCursor;
|
||||||
typedef struct SBtPage SBtPage;
|
|
||||||
|
|
||||||
struct SBtCursor {
|
struct SBtCursor {
|
||||||
SBTree * pBt;
|
SBTree *pBt;
|
||||||
i8 iPage;
|
i8 iPage;
|
||||||
SBtPage *pPage;
|
SPage * pPage;
|
||||||
u16 idx;
|
u16 idx;
|
||||||
u16 idxStack[BTREE_MAX_DEPTH + 1];
|
u16 idxStack[BTREE_MAX_DEPTH + 1];
|
||||||
SBtPage *pgStack[BTREE_MAX_DEPTH + 1];
|
SPage * pgStack[BTREE_MAX_DEPTH + 1];
|
||||||
void * pBuf;
|
void * pBuf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue