enh(query): avoid repeatly load del file.
This commit is contained in:
parent
392fe988a0
commit
803762c4e0
|
@ -170,7 +170,9 @@ struct STsdbReader {
|
||||||
SIOCostSummary cost;
|
SIOCostSummary cost;
|
||||||
STSchema* pSchema; // the newest version schema
|
STSchema* pSchema; // the newest version schema
|
||||||
STSchema* pMemSchema; // the previous schema for in-memory data, to avoid load schema too many times
|
STSchema* pMemSchema; // the previous schema for in-memory data, to avoid load schema too many times
|
||||||
SDataFReader* pFileReader;
|
SDataFReader* pFileReader; // the file reader
|
||||||
|
SDelFReader* pDelFReader; // the del file reader
|
||||||
|
SArray* pDelIdx; // del file block index;
|
||||||
SVersionRange verRange;
|
SVersionRange verRange;
|
||||||
SBlockInfoBuf blockInfoBuf;
|
SBlockInfoBuf blockInfoBuf;
|
||||||
int32_t step;
|
int32_t step;
|
||||||
|
@ -2531,42 +2533,17 @@ int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader*
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
STsdb* pTsdb = pReader->pTsdb;
|
|
||||||
|
|
||||||
SArray* pDelData = taosArrayInit(4, sizeof(SDelData));
|
SArray* pDelData = taosArrayInit(4, sizeof(SDelData));
|
||||||
|
|
||||||
SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile;
|
SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile;
|
||||||
if (pDelFile) {
|
if (pDelFile && taosArrayGetSize(pReader->pDelIdx) > 0) {
|
||||||
SDelFReader* pDelFReader = NULL;
|
|
||||||
code = tsdbDelFReaderOpen(&pDelFReader, pDelFile, pTsdb);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
SArray* aDelIdx = taosArrayInit(4, sizeof(SDelIdx));
|
|
||||||
if (aDelIdx == NULL) {
|
|
||||||
tsdbDelFReaderClose(&pDelFReader);
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: opt the perf of read del index
|
|
||||||
code = tsdbReadDelIdx(pDelFReader, aDelIdx);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
taosArrayDestroy(aDelIdx);
|
|
||||||
tsdbDelFReaderClose(&pDelFReader);
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
SDelIdx idx = {.suid = pReader->suid, .uid = pBlockScanInfo->uid};
|
SDelIdx idx = {.suid = pReader->suid, .uid = pBlockScanInfo->uid};
|
||||||
SDelIdx* pIdx = taosArraySearch(aDelIdx, &idx, tCmprDelIdx, TD_EQ);
|
SDelIdx* pIdx = taosArraySearch(pReader->pDelIdx, &idx, tCmprDelIdx, TD_EQ);
|
||||||
|
|
||||||
if (pIdx != NULL) {
|
if (pIdx != NULL) {
|
||||||
code = tsdbReadDelData(pDelFReader, pIdx, pDelData);
|
code = tsdbReadDelData(pReader->pDelFReader, pIdx, pDelData);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(aDelIdx);
|
|
||||||
tsdbDelFReaderClose(&pDelFReader);
|
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
@ -2662,6 +2639,27 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pIndexList);
|
taosArrayDestroy(pIndexList);
|
||||||
|
|
||||||
|
SDelFile* pDelFile = pReader->pReadSnap->fs.pDelFile;
|
||||||
|
if (pReader->pDelFReader == NULL && pDelFile != NULL) {
|
||||||
|
int32_t code = tsdbDelFReaderOpen(&pReader->pDelFReader, pDelFile, pReader->pTsdb);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
pReader->pDelIdx = taosArrayInit(4, sizeof(SDelIdx));
|
||||||
|
if (pReader->pDelIdx == NULL) {
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
code = tsdbReadDelIdx(pReader->pDelFReader, pReader->pDelIdx);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
taosArrayDestroy(pReader->pDelIdx);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3912,6 +3910,15 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
||||||
tsdbDataFReaderClose(&pReader->pFileReader);
|
tsdbDataFReaderClose(&pReader->pFileReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pReader->pDelFReader != NULL) {
|
||||||
|
tsdbDelFReaderClose(&pReader->pDelFReader);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pReader->pDelIdx != NULL) {
|
||||||
|
taosArrayDestroy(pReader->pDelIdx);
|
||||||
|
pReader->pDelIdx = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
tsdbUntakeReadSnap(pReader->pTsdb, pReader->pReadSnap, pReader->idStr);
|
tsdbUntakeReadSnap(pReader->pTsdb, pReader->pReadSnap, pReader->idStr);
|
||||||
|
|
||||||
taosMemoryFree(pReader->status.uidCheckInfo.tableUidList);
|
taosMemoryFree(pReader->status.uidCheckInfo.tableUidList);
|
||||||
|
|
|
@ -1477,9 +1477,8 @@ int32_t tsdbDelFReaderClose(SDelFReader **ppReader) {
|
||||||
}
|
}
|
||||||
taosMemoryFree(pReader);
|
taosMemoryFree(pReader);
|
||||||
}
|
}
|
||||||
*ppReader = NULL;
|
|
||||||
|
|
||||||
_exit:
|
*ppReader = NULL;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue