diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index 9cb885520a..7ecf68db93 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -461,22 +461,29 @@ static int tdbBtreeBalanceDeeper(SBTree *pBt, SPage *pRoot, SPage **ppChild) { } static int tdbBtreeBalanceStep1(SBtreeBalanceHelper *pBlh) { -#if 0 - // TODO: Find three or less sibling pages on either side + int i; + SPage *pParent; + int nDiv; + SPgno pgno; + SPage *pPage; + int ret; + + pParent = pBlh->pParent; i = pParent->pPageHdr->nCells + pParent->nOverflow; + if (i < 1) { nDiv = 0; } else { - if (idx == 0) { + if (pBlh->idx == 0) { nDiv = 0; - } else if (idx == i) { + } else if (pBlh->idx == i) { nDiv = i - 2; } else { - nDiv = idx - 1; + nDiv = pBlh->idx - 1; } i = 2; } - nOldPages = i + 1; + pBlh->nOldPages = i + 1; if (i + nDiv - pParent->nOverflow == pParent->pPageHdr->nCells) { pgno = pParent->pPageHdr->rChild; @@ -486,18 +493,18 @@ static int tdbBtreeBalanceStep1(SBtreeBalanceHelper *pBlh) { pgno = 0; } for (;;) { - ret = tdbPagerFetchPage(pBt->pPager, pgno, &pPage, tdbBtreeInitPage, pBt); + ret = tdbPagerFetchPage(pBlh->pBt->pPager, pgno, &pPage, tdbBtreeInitPage, pBlh->pBt); if (ret < 0) { ASSERT(0); return -1; } - pOldPages[i] = pPage; + pBlh->pOldPages[i] = pPage; if ((i--) == 0) break; if (pParent->nOverflow && i + nDiv == pParent->aiOvfl[0]) { - pCellDiv[i] = pParent->apOvfl[0]; + // pCellDiv[i] = pParent->apOvfl[0]; // pgno = 0; // szNew[i] = tdbPageCellSize(pPage, pCell); pParent->nOverflow = 0; @@ -512,10 +519,8 @@ static int tdbBtreeBalanceStep1(SBtreeBalanceHelper *pBlh) { // return -1; // } } - /* code */ } -#endif return 0; } diff --git a/source/libs/tdb/src/inc/tdbPCache.h b/source/libs/tdb/src/inc/tdbPCache.h index 5711963238..b5a6d1171d 100644 --- a/source/libs/tdb/src/inc/tdbPCache.h +++ b/source/libs/tdb/src/inc/tdbPCache.h @@ -20,6 +20,8 @@ extern "C" { #endif +#define TDB_PCACHE_PAGE + int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache); int tdbPCacheClose(SPCache *pCache); SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage);