refactor code
This commit is contained in:
parent
9c4842ef10
commit
ca7ca2f1e3
|
@ -462,8 +462,8 @@ Iterate* idxCacheIteratorCreate(IndexCache* cache) {
|
||||||
if (cache->imm == NULL) {
|
if (cache->imm == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
Iterate* iiter = taosMemoryCalloc(1, sizeof(Iterate));
|
Iterate* iter = taosMemoryCalloc(1, sizeof(Iterate));
|
||||||
if (iiter == NULL) {
|
if (iter == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
taosThreadMutexLock(&cache->mtx);
|
taosThreadMutexLock(&cache->mtx);
|
||||||
|
@ -471,15 +471,15 @@ Iterate* idxCacheIteratorCreate(IndexCache* cache) {
|
||||||
idxMemRef(cache->imm);
|
idxMemRef(cache->imm);
|
||||||
|
|
||||||
MemTable* tbl = cache->imm;
|
MemTable* tbl = cache->imm;
|
||||||
iiter->val.val = taosArrayInit(1, sizeof(uint64_t));
|
iter->val.val = taosArrayInit(1, sizeof(uint64_t));
|
||||||
iiter->val.colVal = NULL;
|
iter->val.colVal = NULL;
|
||||||
iiter->iter = tbl != NULL ? tSkipListCreateIter(tbl->mem) : NULL;
|
iter->iter = tbl != NULL ? tSkipListCreateIter(tbl->mem) : NULL;
|
||||||
iiter->next = idxCacheIteratorNext;
|
iter->next = idxCacheIteratorNext;
|
||||||
iiter->getValue = idxCacheIteratorGetValue;
|
iter->getValue = idxCacheIteratorGetValue;
|
||||||
|
|
||||||
taosThreadMutexUnlock(&cache->mtx);
|
taosThreadMutexUnlock(&cache->mtx);
|
||||||
|
|
||||||
return iiter;
|
return iter;
|
||||||
}
|
}
|
||||||
void idxCacheIteratorDestroy(Iterate* iter) {
|
void idxCacheIteratorDestroy(Iterate* iter) {
|
||||||
if (iter == NULL) {
|
if (iter == NULL) {
|
||||||
|
@ -564,13 +564,13 @@ int idxCachePut(void* cache, SIndexTerm* term, uint64_t uid) {
|
||||||
idxMemUnRef(tbl);
|
idxMemUnRef(tbl);
|
||||||
|
|
||||||
taosThreadMutexUnlock(&pCache->mtx);
|
taosThreadMutexUnlock(&pCache->mtx);
|
||||||
|
|
||||||
idxCacheUnRef(pCache);
|
idxCacheUnRef(pCache);
|
||||||
return 0;
|
return 0;
|
||||||
// encode end
|
// encode end
|
||||||
}
|
}
|
||||||
void idxCacheForceToMerge(void* cache) {
|
void idxCacheForceToMerge(void* cache) {
|
||||||
IndexCache* pCache = cache;
|
IndexCache* pCache = cache;
|
||||||
|
|
||||||
idxCacheRef(pCache);
|
idxCacheRef(pCache);
|
||||||
taosThreadMutexLock(&pCache->mtx);
|
taosThreadMutexLock(&pCache->mtx);
|
||||||
|
|
||||||
|
|
|
@ -292,8 +292,9 @@ class IndexEnv : public ::testing::Test {
|
||||||
virtual void SetUp() {
|
virtual void SetUp() {
|
||||||
initLog();
|
initLog();
|
||||||
taosRemoveDir(path);
|
taosRemoveDir(path);
|
||||||
SIndexOpts opts = {.cacheSize = 1024 * 1024 * 4};
|
SIndexOpts opts;
|
||||||
int ret = indexOpen(&opts, path, &index);
|
opts.cacheSize = 1024 * 1024 * 4;
|
||||||
|
int ret = indexOpen(&opts, path, &index);
|
||||||
assert(ret == 0);
|
assert(ret == 0);
|
||||||
}
|
}
|
||||||
virtual void TearDown() { indexClose(index); }
|
virtual void TearDown() { indexClose(index); }
|
||||||
|
@ -697,8 +698,10 @@ class IndexObj {
|
||||||
taosMkDir(dir.c_str());
|
taosMkDir(dir.c_str());
|
||||||
}
|
}
|
||||||
taosMkDir(dir.c_str());
|
taosMkDir(dir.c_str());
|
||||||
SIndexOpts opts = {.cacheSize = 1024 * 1024 * 4};
|
SIndexOpts opts;
|
||||||
int ret = indexOpen(&opts, dir.c_str(), &idx);
|
opts.cacheSize = 1024 * 1024 * 4;
|
||||||
|
|
||||||
|
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