tdb/ofp: recycl ofps
This commit is contained in:
parent
f8921199e7
commit
a3c9b17212
|
@ -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) {
|
||||||
|
|
||||||
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) {
|
||||||
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 {
|
||||||
#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 {
|
||||||
|
|
Loading…
Reference in New Issue