提交 b5b522d6 编写于 作者: H Hongze Cheng

more TDB

上级 1075c230
......@@ -690,7 +690,6 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
int nNews = 0;
int cntNews[5] = {0}; // TODO: maybe 5 is not enough
int szNews[5] = {0};
int maxPageCapacity; // TODO
{ // Get how many new pages are needed and the new distribution
......@@ -699,11 +698,12 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) {
SPage *pPage = pOlds[i];
SCell *pCell;
int cellBytes;
for (int cIdx = 0; cIdx < TDB_PAGE_TOTAL_CELLS(pPage); cIdx++) {
pCell = tdbPageGetCell(pPage, cIdx);
cellBytes = TDB_BYTES_CELL_TAKEN(pPage, pCell);
if (szNews[nNews] + cellBytes > maxPageCapacity) {
if (szNews[nNews] + cellBytes > TDB_PAGE_USABLE_SIZE(pPage)) {
nNews++;
}
cntNews[nNews]++;
......
......@@ -99,6 +99,7 @@ struct SPage {
// APIs
#define TDB_PAGE_TOTAL_CELLS(pPage) ((pPage)->nOverflow + (pPage)->pPageMethods->getCellNum(pPage))
#define TDB_PAGE_USABLE_SIZE(pPage) ((u8 *)(pPage)->pPageFtr - (pPage)->pCellIdx)
#define TDB_BYTES_CELL_TAKEN(pPage, pCell) ((*(pPage)->xCellSize)(pPage, pCell) + (pPage)->pPageMethods->szOffset)
int tdbPageCreate(int pageSize, SPage **ppPage, void *(*xMalloc)(void *, size_t), void *arg);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册