提交 ca7ca2f1 编写于 作者: dengyihao's avatar dengyihao

refactor code

上级 9c4842ef
......@@ -462,8 +462,8 @@ Iterate* idxCacheIteratorCreate(IndexCache* cache) {
if (cache->imm == NULL) {
return NULL;
}
Iterate* iiter = taosMemoryCalloc(1, sizeof(Iterate));
if (iiter == NULL) {
Iterate* iter = taosMemoryCalloc(1, sizeof(Iterate));
if (iter == NULL) {
return NULL;
}
taosThreadMutexLock(&cache->mtx);
......@@ -471,15 +471,15 @@ Iterate* idxCacheIteratorCreate(IndexCache* cache) {
idxMemRef(cache->imm);
MemTable* tbl = cache->imm;
iiter->val.val = taosArrayInit(1, sizeof(uint64_t));
iiter->val.colVal = NULL;
iiter->iter = tbl != NULL ? tSkipListCreateIter(tbl->mem) : NULL;
iiter->next = idxCacheIteratorNext;
iiter->getValue = idxCacheIteratorGetValue;
iter->val.val = taosArrayInit(1, sizeof(uint64_t));
iter->val.colVal = NULL;
iter->iter = tbl != NULL ? tSkipListCreateIter(tbl->mem) : NULL;
iter->next = idxCacheIteratorNext;
iter->getValue = idxCacheIteratorGetValue;
taosThreadMutexUnlock(&cache->mtx);
return iiter;
return iter;
}
void idxCacheIteratorDestroy(Iterate* iter) {
if (iter == NULL) {
......@@ -564,13 +564,13 @@ int idxCachePut(void* cache, SIndexTerm* term, uint64_t uid) {
idxMemUnRef(tbl);
taosThreadMutexUnlock(&pCache->mtx);
idxCacheUnRef(pCache);
return 0;
// encode end
}
void idxCacheForceToMerge(void* cache) {
IndexCache* pCache = cache;
idxCacheRef(pCache);
taosThreadMutexLock(&pCache->mtx);
......
......@@ -292,8 +292,9 @@ class IndexEnv : public ::testing::Test {
virtual void SetUp() {
initLog();
taosRemoveDir(path);
SIndexOpts opts = {.cacheSize = 1024 * 1024 * 4};
int ret = indexOpen(&opts, path, &index);
SIndexOpts opts;
opts.cacheSize = 1024 * 1024 * 4;
int ret = indexOpen(&opts, path, &index);
assert(ret == 0);
}
virtual void TearDown() { indexClose(index); }
......@@ -697,8 +698,10 @@ class IndexObj {
taosMkDir(dir.c_str());
}
taosMkDir(dir.c_str());
SIndexOpts opts = {.cacheSize = 1024 * 1024 * 4};
int ret = indexOpen(&opts, dir.c_str(), &idx);
SIndexOpts opts;
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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册