refact
This commit is contained in:
parent
488d44a555
commit
b8ac2d30d5
|
@ -67,7 +67,7 @@ typedef struct {
|
||||||
u8 *pTmpSpace;
|
u8 *pTmpSpace;
|
||||||
} SCellDecoder;
|
} SCellDecoder;
|
||||||
|
|
||||||
static int tdbBtCursorMoveTo(SBtCursor *pCur, const void *pKey, int kLen, int *pCRst);
|
static int tdbBtCursorMoveTo(SBTC *pCur, const void *pKey, int kLen, int *pCRst);
|
||||||
static int tdbDefaultKeyCmprFn(const void *pKey1, int keyLen1, const void *pKey2, int keyLen2);
|
static int tdbDefaultKeyCmprFn(const void *pKey1, int keyLen1, const void *pKey2, int keyLen2);
|
||||||
static int tdbBtreeOpenImpl(SBTree *pBt);
|
static int tdbBtreeOpenImpl(SBTree *pBt);
|
||||||
static int tdbBtreeZeroPage(SPage *pPage, void *arg);
|
static int tdbBtreeZeroPage(SPage *pPage, void *arg);
|
||||||
|
@ -75,7 +75,7 @@ static int tdbBtreeInitPage(SPage *pPage, void *arg);
|
||||||
static int tdbBtreeEncodeCell(SPage *pPage, const void *pKey, int kLen, const void *pVal, int vLen, SCell *pCell,
|
static int tdbBtreeEncodeCell(SPage *pPage, const void *pKey, int kLen, const void *pVal, int vLen, SCell *pCell,
|
||||||
int *szCell);
|
int *szCell);
|
||||||
static int tdbBtreeDecodeCell(SPage *pPage, const SCell *pCell, SCellDecoder *pDecoder);
|
static int tdbBtreeDecodeCell(SPage *pPage, const SCell *pCell, SCellDecoder *pDecoder);
|
||||||
static int tdbBtreeBalance(SBtCursor *pCur);
|
static int tdbBtreeBalance(SBTC *pCur);
|
||||||
static int tdbBtreeCellSize(const SPage *pPage, SCell *pCell);
|
static int tdbBtreeCellSize(const SPage *pPage, SCell *pCell);
|
||||||
|
|
||||||
int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, FKeyComparator kcmpr, SBTree **ppBt) {
|
int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, FKeyComparator kcmpr, SBTree **ppBt) {
|
||||||
|
@ -131,7 +131,7 @@ int tdbBtreeClose(SBTree *pBt) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbBtreeCursor(SBtCursor *pCur, SBTree *pBt) {
|
int tdbBtreeCursor(SBTC *pCur, SBTree *pBt) {
|
||||||
pCur->pBt = pBt;
|
pCur->pBt = pBt;
|
||||||
pCur->iPage = -1;
|
pCur->iPage = -1;
|
||||||
pCur->pPage = NULL;
|
pCur->pPage = NULL;
|
||||||
|
@ -140,7 +140,7 @@ int tdbBtreeCursor(SBtCursor *pCur, SBTree *pBt) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *pVal, int vLen) {
|
int tdbBtCursorInsert(SBTC *pCur, const void *pKey, int kLen, const void *pVal, int vLen) {
|
||||||
int ret;
|
int ret;
|
||||||
int idx;
|
int idx;
|
||||||
SPager *pPager;
|
SPager *pPager;
|
||||||
|
@ -204,7 +204,7 @@ int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *p
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbBtreeGet(SBTree *pBt, const void *pKey, int kLen, void **ppVal, int *vLen) {
|
int tdbBtreeGet(SBTree *pBt, const void *pKey, int kLen, void **ppVal, int *vLen) {
|
||||||
SBtCursor btc;
|
SBTC btc;
|
||||||
SCell *pCell;
|
SCell *pCell;
|
||||||
int cret;
|
int cret;
|
||||||
SCellDecoder cd;
|
SCellDecoder cd;
|
||||||
|
@ -231,7 +231,7 @@ int tdbBtreeGet(SBTree *pBt, const void *pKey, int kLen, void **ppVal, int *vLen
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tdbBtCursorMoveToChild(SBtCursor *pCur, SPgno pgno) {
|
static int tdbBtCursorMoveToChild(SBTC *pCur, SPgno pgno) {
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pCur->pgStack[pCur->iPage] = pCur->pPage;
|
pCur->pgStack[pCur->iPage] = pCur->pPage;
|
||||||
|
@ -248,7 +248,7 @@ static int tdbBtCursorMoveToChild(SBtCursor *pCur, SPgno pgno) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tdbBtCursorMoveTo(SBtCursor *pCur, const void *pKey, int kLen, int *pCRst) {
|
static int tdbBtCursorMoveTo(SBTC *pCur, const void *pKey, int kLen, int *pCRst) {
|
||||||
int ret;
|
int ret;
|
||||||
SBTree *pBt;
|
SBTree *pBt;
|
||||||
SPager *pPager;
|
SPager *pPager;
|
||||||
|
@ -827,7 +827,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tdbBtreeBalance(SBtCursor *pCur) {
|
static int tdbBtreeBalance(SBTC *pCur) {
|
||||||
int iPage;
|
int iPage;
|
||||||
SPage *pParent;
|
SPage *pParent;
|
||||||
SPage *pPage;
|
SPage *pPage;
|
||||||
|
|
|
@ -70,9 +70,9 @@ int tdbDbDrop(STDb *pDb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int tdbDbInsert(STDb *pDb, const void *pKey, int keyLen, const void *pVal, int valLen) {
|
int tdbDbInsert(STDb *pDb, const void *pKey, int keyLen, const void *pVal, int valLen) {
|
||||||
SBtCursor btc;
|
SBTC btc;
|
||||||
SBtCursor *pCur;
|
SBTC *pCur;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
pCur = &btc;
|
pCur = &btc;
|
||||||
ret = tdbBtreeCursor(pCur, pDb->pBt);
|
ret = tdbBtreeCursor(pCur, pDb->pBt);
|
||||||
|
|
|
@ -20,10 +20,15 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct SBTree SBTree;
|
typedef struct SBTree SBTree;
|
||||||
typedef struct SBtCursor SBtCursor;
|
typedef struct SBTC SBTC;
|
||||||
|
typedef struct SBtInfo {
|
||||||
|
SPgno root;
|
||||||
|
int nLevel;
|
||||||
|
int nData;
|
||||||
|
} SBtInfo;
|
||||||
|
|
||||||
struct SBtCursor {
|
struct SBTC {
|
||||||
SBTree *pBt;
|
SBTree *pBt;
|
||||||
i8 iPage;
|
i8 iPage;
|
||||||
SPage *pPage;
|
SPage *pPage;
|
||||||
|
@ -35,8 +40,8 @@ struct SBtCursor {
|
||||||
|
|
||||||
int tdbBtreeOpen(int keyLen, int valLen, SPager *pFile, FKeyComparator kcmpr, SBTree **ppBt);
|
int tdbBtreeOpen(int keyLen, int valLen, SPager *pFile, FKeyComparator kcmpr, SBTree **ppBt);
|
||||||
int tdbBtreeClose(SBTree *pBt);
|
int tdbBtreeClose(SBTree *pBt);
|
||||||
int tdbBtreeCursor(SBtCursor *pCur, SBTree *pBt);
|
int tdbBtreeCursor(SBTC *pCur, SBTree *pBt);
|
||||||
int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *pVal, int vLen);
|
int tdbBtCursorInsert(SBTC *pCur, const void *pKey, int kLen, const void *pVal, int vLen);
|
||||||
int tdbBtreeGet(SBTree *pBt, const void *pKey, int kLen, void **ppVal, int *vLen);
|
int tdbBtreeGet(SBTree *pBt, const void *pKey, int kLen, void **ppVal, int *vLen);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
Loading…
Reference in New Issue