提交 28d3a1db 编写于 作者: H Hongze Cheng

more TDB

上级 0e30b760
...@@ -36,6 +36,7 @@ struct SBTree { ...@@ -36,6 +36,7 @@ struct SBTree {
int minLocal; int minLocal;
int maxLeaf; int maxLeaf;
int minLeaf; int minLeaf;
u8 *pTmp;
}; };
typedef struct __attribute__((__packed__)) { typedef struct __attribute__((__packed__)) {
...@@ -125,6 +126,7 @@ int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *p ...@@ -125,6 +126,7 @@ int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *p
SCell *pCell; SCell *pCell;
int szCell; int szCell;
int cret; int cret;
SBTree *pBt;
ret = tdbBtCursorMoveTo(pCur, pKey, kLen, &cret); ret = tdbBtCursorMoveTo(pCur, pKey, kLen, &cret);
if (ret < 0) { if (ret < 0) {
...@@ -146,6 +148,17 @@ int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *p ...@@ -146,6 +148,17 @@ int tdbBtCursorInsert(SBtCursor *pCur, const void *pKey, int kLen, const void *p
} }
} }
// TODO: refact code here
pBt = pCur->pBt;
if (!pBt->pTmp) {
pBt->pTmp = (u8 *)malloc(pBt->pageSize);
if (pBt->pTmp == NULL) {
return -1;
}
}
pCell = pBt->pTmp;
// Encode the cell // Encode the cell
ret = tdbBtreeEncodeCell(pCur->pPage, pKey, kLen, pVal, vLen, pCell, &szCell); ret = tdbBtreeEncodeCell(pCur->pPage, pKey, kLen, pVal, vLen, pCell, &szCell);
if (ret < 0) { if (ret < 0) {
...@@ -349,6 +362,9 @@ static int tdbBtreeInitPage(SPage *pPage, void *arg) { ...@@ -349,6 +362,9 @@ static int tdbBtreeInitPage(SPage *pPage, void *arg) {
pPage->minLocal = pBt->minLocal; pPage->minLocal = pBt->minLocal;
} }
// TODO: need to update the SPage.nFree
pPage->nFree = pPage->pFreeEnd - pPage->pFreeStart;
return 0; return 0;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册