提交 a3c9b172 编写于 作者: M Minglei Jin

tdb/ofp: recycl ofps

上级 f8921199
......@@ -1317,6 +1317,11 @@ static int tdbBtreeDecodePayload(SPage *pPage, const SCell *pCell, int nHeader,
return -1;
}
if (!pDecoder->ofps) {
pDecoder->ofps = taosArrayInit(8, sizeof(SPgno));
}
taosArrayPush(pDecoder->ofps, &pgno);
ofpCell = tdbPageGetCell(ofp, 0);
if (nLeft <= ofp->maxLocal - sizeof(SPgno)) {
......@@ -2075,6 +2080,14 @@ int tdbBtcDelete(SBTC *pBtc) {
tdbPageDropCell(pBtc->pPage, idx, pBtc->pTxn, pBtc->pBt);
// recycle ofps if any
if (pBtc->coder.ofps) {
for (int i = 0; i < TARRAY_SIZE(pBtc->coder.ofps); ++i) {
SPgno *pgno = taosArrayGet(pBtc->coder.ofps, i);
tdbPagerInsertFreePage(pBtc->pBt->pPager, *pgno, pBtc->pTxn);
}
}
// update interior page or do balance
if (idx == nCells - 1) {
if (idx) {
......@@ -2370,6 +2383,10 @@ int tdbBtcClose(SBTC *pBtc) {
tdbTxnClose(pBtc->pTxn);
}
if (pBtc->coder.ofps) {
taosArrayDestroy(pBtc->coder.ofps);
}
return 0;
}
......
......@@ -131,13 +131,14 @@ typedef struct SBtInfo {
#define TDB_CELLDECODER_FREE_VAL(pCellDecoder) ((pCellDecoder)->freeKV & TDB_CELLD_F_VAL)
typedef struct {
int kLen;
u8 *pKey;
int vLen;
u8 *pVal;
SPgno pgno;
u8 *pBuf;
u8 freeKV;
int kLen;
u8 *pKey;
int vLen;
u8 *pVal;
SPgno pgno;
u8 *pBuf;
u8 freeKV;
SArray *ofps;
} SCellDecoder;
struct SBTC {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册