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

tdb/ofp: recycl ofps

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