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