feat: add lru to index
This commit is contained in:
parent
cace9b6be9
commit
a9e64f2938
|
@ -28,7 +28,6 @@ extern "C" {
|
|||
|
||||
typedef struct SIndex SIndex;
|
||||
typedef struct SIndexTerm SIndexTerm;
|
||||
typedef struct SIndexOpts SIndexOpts;
|
||||
typedef struct SIndexMultiTermQuery SIndexMultiTermQuery;
|
||||
typedef struct SArray SIndexMultiTerm;
|
||||
|
||||
|
@ -62,6 +61,9 @@ typedef enum {
|
|||
QUERY_MAX
|
||||
} EIndexQueryType;
|
||||
|
||||
typedef struct SIndexOpts {
|
||||
int32_t cacheSize; // MB
|
||||
} SIndexOpts;
|
||||
/*
|
||||
* create multi query
|
||||
* @param oper (input, relation between querys)
|
||||
|
|
|
@ -103,8 +103,8 @@ int metaOpen(SVnode *pVnode, SMeta **ppMeta) {
|
|||
sprintf(indexFullPath, "%s/%s", pMeta->path, "invert");
|
||||
taosMkDir(indexFullPath);
|
||||
|
||||
SIndexOpts *opts = indexOptsCreate(8 * 1024 * 1024);
|
||||
ret = indexOpen(opts, indexFullPath, (SIndex **)&pMeta->pTagIvtIdx);
|
||||
SIndexOpts opts = {.cacheSize = 8 * 1024 * 1024};
|
||||
ret = indexOpen(&opts, indexFullPath, (SIndex **)&pMeta->pTagIvtIdx);
|
||||
if (ret < 0) {
|
||||
metaError("vgId:%d, failed to open meta tag index since %s", TD_VID(pVnode), tstrerror(terrno));
|
||||
goto _err;
|
||||
|
|
Binary file not shown.
|
@ -68,12 +68,7 @@ struct SIndex {
|
|||
TdThreadMutex mtx;
|
||||
tsem_t sem;
|
||||
bool quit;
|
||||
void* opts;
|
||||
};
|
||||
|
||||
struct SIndexOpts {
|
||||
int32_t cacheSize; // MB
|
||||
int32_t cacheOpt; // MB
|
||||
SIndexOpts opts;
|
||||
};
|
||||
|
||||
struct SIndexMultiTermQuery {
|
||||
|
|
|
@ -128,7 +128,7 @@ int indexOpen(SIndexOpts* opts, const char* path, SIndex** index) {
|
|||
tsem_init(&idx->sem, 0, 0);
|
||||
|
||||
idx->refId = idxAddRef(idx);
|
||||
idx->opts = opts;
|
||||
idx->opts = *opts;
|
||||
idxAcquireRef(idx->refId);
|
||||
|
||||
*index = idx;
|
||||
|
@ -155,8 +155,6 @@ void indexDestroy(void* handle) {
|
|||
taosLRUCacheCleanup(lru);
|
||||
}
|
||||
idx->lru = NULL;
|
||||
|
||||
indexOptsDestroy(idx->opts);
|
||||
taosMemoryFree(idx);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -292,14 +292,11 @@ class IndexEnv : public ::testing::Test {
|
|||
virtual void SetUp() {
|
||||
initLog();
|
||||
taosRemoveDir(path);
|
||||
opts = indexOptsCreate(1024 * 1024 * 8);
|
||||
int ret = indexOpen(opts, path, &index);
|
||||
SIndexOpts opts = {.cacheSize = 1024 * 1024 * 4};
|
||||
int ret = indexOpen(&opts, path, &index);
|
||||
assert(ret == 0);
|
||||
}
|
||||
virtual void TearDown() {
|
||||
indexClose(index);
|
||||
indexOptsDestroy(opts);
|
||||
}
|
||||
virtual void TearDown() { indexClose(index); }
|
||||
|
||||
const char* path = TD_TMP_DIR_PATH "tindex";
|
||||
SIndexOpts* opts;
|
||||
|
@ -700,8 +697,8 @@ class IndexObj {
|
|||
taosMkDir(dir.c_str());
|
||||
}
|
||||
taosMkDir(dir.c_str());
|
||||
opts = indexOptsCreate(1024 * 1024 * 4);
|
||||
int ret = indexOpen(opts, dir.c_str(), &idx);
|
||||
SIndexOpts opts = {.cacheSize = 1024 * 1024 * 4};
|
||||
int ret = indexOpen(&opts, dir.c_str(), &idx);
|
||||
if (ret != 0) {
|
||||
// opt
|
||||
std::cout << "failed to open index: %s" << dir << std::endl;
|
||||
|
|
Loading…
Reference in New Issue