未验证 提交 a7dad151 编写于 作者: X Xiaoyu Wang 提交者: GitHub

Merge pull request #20004 from taosdata/fix/TS-2625

fix(tsdb/cache): use block index cache with last/last_row
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
static int32_t tsdbOpenBICache(STsdb *pTsdb) { static int32_t tsdbOpenBICache(STsdb *pTsdb) {
int32_t code = 0; int32_t code = 0;
SLRUCache *pCache = taosLRUCacheInit(5 * 1024 * 1024, 1, .5); SLRUCache *pCache = taosLRUCacheInit(10 * 1024 * 1024, 0, .5);
if (pCache == NULL) { if (pCache == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY; code = TSDB_CODE_OUT_OF_MEMORY;
goto _err; goto _err;
...@@ -644,6 +644,7 @@ typedef struct SFSNextRowIter { ...@@ -644,6 +644,7 @@ typedef struct SFSNextRowIter {
SArray *aDFileSet; SArray *aDFileSet;
SDataFReader **pDataFReader; SDataFReader **pDataFReader;
SArray *aBlockIdx; SArray *aBlockIdx;
LRUHandle *aBlockIdxHandle;
SBlockIdx *pBlockIdx; SBlockIdx *pBlockIdx;
SMapData blockMap; SMapData blockMap;
int32_t nBlock; int32_t nBlock;
...@@ -697,6 +698,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) { ...@@ -697,6 +698,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
} }
// tMapDataReset(&state->blockIdxMap); // tMapDataReset(&state->blockIdxMap);
/*
if (!state->aBlockIdx) { if (!state->aBlockIdx) {
state->aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx)); state->aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
} else { } else {
...@@ -704,6 +706,13 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) { ...@@ -704,6 +706,13 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
} }
code = tsdbReadBlockIdx(*state->pDataFReader, state->aBlockIdx); code = tsdbReadBlockIdx(*state->pDataFReader, state->aBlockIdx);
if (code) goto _err; if (code) goto _err;
*/
int32_t code =
tsdbCacheGetBlockIdx((*state->pDataFReader)->pTsdb->biCache, *state->pDataFReader, &state->aBlockIdxHandle);
if (code != TSDB_CODE_SUCCESS || state->aBlockIdxHandle == NULL) {
goto _err;
}
state->aBlockIdx = (SArray *)taosLRUCacheValue((*state->pDataFReader)->pTsdb->biCache, state->aBlockIdxHandle);
/* if (state->pBlockIdx) { */ /* if (state->pBlockIdx) { */
/* } */ /* } */
...@@ -772,7 +781,10 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) { ...@@ -772,7 +781,10 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
// resetLastBlockLoadInfo(state->pLoadInfo); // resetLastBlockLoadInfo(state->pLoadInfo);
if (state->aBlockIdx) { if (state->aBlockIdx) {
taosArrayDestroy(state->aBlockIdx); // taosArrayDestroy(state->aBlockIdx);
tsdbBICacheRelease((*state->pDataFReader)->pTsdb->biCache, state->aBlockIdxHandle);
state->aBlockIdxHandle = NULL;
state->aBlockIdx = NULL; state->aBlockIdx = NULL;
} }
...@@ -795,7 +807,10 @@ _err: ...@@ -795,7 +807,10 @@ _err:
resetLastBlockLoadInfo(state->pLoadInfo); resetLastBlockLoadInfo(state->pLoadInfo);
}*/ }*/
if (state->aBlockIdx) { if (state->aBlockIdx) {
taosArrayDestroy(state->aBlockIdx); // taosArrayDestroy(state->aBlockIdx);
tsdbBICacheRelease((*state->pDataFReader)->pTsdb->biCache, state->aBlockIdxHandle);
state->aBlockIdxHandle = NULL;
state->aBlockIdx = NULL; state->aBlockIdx = NULL;
} }
if (state->pBlockData) { if (state->pBlockData) {
...@@ -821,7 +836,10 @@ int32_t clearNextRowFromFS(void *iter) { ...@@ -821,7 +836,10 @@ int32_t clearNextRowFromFS(void *iter) {
state->pDataFReader = NULL; state->pDataFReader = NULL;
}*/ }*/
if (state->aBlockIdx) { if (state->aBlockIdx) {
taosArrayDestroy(state->aBlockIdx); // taosArrayDestroy(state->aBlockIdx);
tsdbBICacheRelease((*state->pDataFReader)->pTsdb->biCache, state->aBlockIdxHandle);
state->aBlockIdxHandle = NULL;
state->aBlockIdx = NULL; state->aBlockIdx = NULL;
} }
if (state->pBlockData) { if (state->pBlockData) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册