update tindex reader

This commit is contained in:
yihaoDeng 2021-12-22 23:29:54 +08:00
parent 556788b634
commit 28c358c339
2 changed files with 9 additions and 1 deletions

View File

@ -66,6 +66,7 @@ typedef struct TFileWriter {
uint32_t offset; uint32_t offset;
} TFileWriter; } TFileWriter;
// multi reader and single write
typedef struct TFileReader { typedef struct TFileReader {
T_REF_DECLARE() T_REF_DECLARE()
Fst* fst; Fst* fst;

View File

@ -134,8 +134,15 @@ TFileReader* tfileCacheGet(TFileCache* tcache, TFileCacheKey* key) {
void tfileCachePut(TFileCache* tcache, TFileCacheKey* key, TFileReader* reader) { void tfileCachePut(TFileCache* tcache, TFileCacheKey* key, TFileReader* reader) {
char buf[128] = {0}; char buf[128] = {0};
tfileSerialCacheKey(key, buf); tfileSerialCacheKey(key, buf);
tfileReadRef(reader); // remove last version index reader
TFileReader** p = taosHashGet(tcache->tableCache, buf, strlen(buf));
if (*p != NULL) {
TFileReader* oldReader = *p;
taosHashRemove(tcache->tableCache, buf, strlen(buf));
tfileReadUnRef(oldReader);
}
tfileReadRef(reader);
taosHashPut(tcache->tableCache, buf, strlen(buf), &reader, sizeof(void*)); taosHashPut(tcache->tableCache, buf, strlen(buf), &reader, sizeof(void*));
return; return;
} }