check function return code
This commit is contained in:
parent
7fda2a23d1
commit
1a2acb1629
|
@ -212,6 +212,7 @@ void idxReleaseRef(int64_t ref) {
|
||||||
|
|
||||||
int32_t indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
|
int32_t indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
|
||||||
// TODO(yihao): reduce the lock range
|
// TODO(yihao): reduce the lock range
|
||||||
|
int32_t code = 0;
|
||||||
(void)taosThreadMutexLock(&index->mtx);
|
(void)taosThreadMutexLock(&index->mtx);
|
||||||
for (int i = 0; i < taosArrayGetSize(fVals); i++) {
|
for (int i = 0; i < taosArrayGetSize(fVals); i++) {
|
||||||
SIndexTerm* p = taosArrayGetP(fVals, i);
|
SIndexTerm* p = taosArrayGetP(fVals, i);
|
||||||
|
@ -223,11 +224,19 @@ int32_t indexPut(SIndex* index, SIndexMultiTerm* fVals, uint64_t uid) {
|
||||||
IndexCache** cache = taosHashGet(index->colObj, buf, sz);
|
IndexCache** cache = taosHashGet(index->colObj, buf, sz);
|
||||||
if (cache == NULL) {
|
if (cache == NULL) {
|
||||||
IndexCache* pCache = idxCacheCreate(index, p->suid, p->colName, p->colType);
|
IndexCache* pCache = idxCacheCreate(index, p->suid, p->colName, p->colType);
|
||||||
(void)taosHashPut(index->colObj, buf, sz, &pCache, sizeof(void*));
|
code = taosHashPut(index->colObj, buf, sz, &pCache, sizeof(void*));
|
||||||
|
if (code != 0) {
|
||||||
|
idxCacheDestroy(pCache);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(void)taosThreadMutexUnlock(&index->mtx);
|
(void)taosThreadMutexUnlock(&index->mtx);
|
||||||
|
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < taosArrayGetSize(fVals); i++) {
|
for (int i = 0; i < taosArrayGetSize(fVals); i++) {
|
||||||
SIndexTerm* p = taosArrayGetP(fVals, i);
|
SIndexTerm* p = taosArrayGetP(fVals, i);
|
||||||
|
|
||||||
|
|
|
@ -1366,11 +1366,18 @@ FStmBuilder* stmBuilderCreate(Fst* fst, FAutoCtx* aut) {
|
||||||
b->aut = aut;
|
b->aut = aut;
|
||||||
b->min = fstBoundStateCreate(Unbounded, NULL);
|
b->min = fstBoundStateCreate(Unbounded, NULL);
|
||||||
b->max = fstBoundStateCreate(Unbounded, NULL);
|
b->max = fstBoundStateCreate(Unbounded, NULL);
|
||||||
|
|
||||||
|
if (b->min == NULL || b->max == NULL) {
|
||||||
|
stmBuilderDestroy(b);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
void stmBuilderDestroy(FStmBuilder* b) {
|
void stmBuilderDestroy(FStmBuilder* b) {
|
||||||
fstSliceDestroy(&b->min->data);
|
if (b->min) fstSliceDestroy(&b->min->data);
|
||||||
fstSliceDestroy(&b->max->data);
|
if (b->max) fstSliceDestroy(&b->max->data);
|
||||||
|
|
||||||
taosMemoryFreeClear(b->min);
|
taosMemoryFreeClear(b->min);
|
||||||
taosMemoryFreeClear(b->max);
|
taosMemoryFreeClear(b->max);
|
||||||
taosMemoryFree(b);
|
taosMemoryFree(b);
|
||||||
|
|
|
@ -97,6 +97,11 @@ TFileCache* tfileCacheCreate(SIndex* idx, const char* path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
tcache->tableCache = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
tcache->tableCache = taosHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||||
|
if (tcache->tableCache == NULL) {
|
||||||
|
indexError("failed to open table cache since%s", tstrerror(terrno));
|
||||||
|
goto End;
|
||||||
|
}
|
||||||
|
|
||||||
tcache->capacity = 64;
|
tcache->capacity = 64;
|
||||||
|
|
||||||
SArray* files = NULL;
|
SArray* files = NULL;
|
||||||
|
@ -126,8 +131,11 @@ TFileCache* tfileCacheCreate(SIndex* idx, const char* path) {
|
||||||
|
|
||||||
char buf[128] = {0};
|
char buf[128] = {0};
|
||||||
int32_t sz = idxSerialCacheKey(&key, buf);
|
int32_t sz = idxSerialCacheKey(&key, buf);
|
||||||
(void)taosHashPut(tcache->tableCache, buf, sz, &reader, sizeof(void*));
|
code = taosHashPut(tcache->tableCache, buf, sz, &reader, sizeof(void*));
|
||||||
tfileReaderRef(reader);
|
if (code != 0) {
|
||||||
|
tfileReaderRef(reader);
|
||||||
|
goto End;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
taosArrayDestroyEx(files, tfileDestroyFileName);
|
taosArrayDestroyEx(files, tfileDestroyFileName);
|
||||||
return tcache;
|
return tcache;
|
||||||
|
@ -173,10 +181,14 @@ int32_t tfileCachePut(TFileCache* tcache, ICacheKey* key, TFileReader* reader) {
|
||||||
TFileReader** p = taosHashGet(tcache->tableCache, buf, sz);
|
TFileReader** p = taosHashGet(tcache->tableCache, buf, sz);
|
||||||
if (p != NULL && *p != NULL) {
|
if (p != NULL && *p != NULL) {
|
||||||
TFileReader* oldRdr = *p;
|
TFileReader* oldRdr = *p;
|
||||||
(void)taosHashRemove(tcache->tableCache, buf, sz);
|
if ((code = taosHashRemove(tcache->tableCache, buf, sz)) != 0) {
|
||||||
indexInfo("found %s, should remove file %s", buf, oldRdr->ctx->file.buf);
|
indexError("failed to remove old reader from cache since %s, suid:%" PRIu64 ", colName:%s", tstrerror(code),
|
||||||
oldRdr->remove = true;
|
oldRdr->header.suid, oldRdr->header.colName);
|
||||||
tfileReaderUnRef(oldRdr);
|
} else {
|
||||||
|
indexInfo("found %s, should remove file %s", buf, oldRdr->ctx->file.buf);
|
||||||
|
oldRdr->remove = true;
|
||||||
|
tfileReaderUnRef(oldRdr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code = taosHashPut(tcache->tableCache, buf, sz, &reader, sizeof(void*));
|
code = taosHashPut(tcache->tableCache, buf, sz, &reader, sizeof(void*));
|
||||||
|
@ -267,8 +279,16 @@ static int32_t tfSearchPrefix(void* reader, SIndexTerm* tem, SIdxTRslt* tr) {
|
||||||
uint64_t sz = tem->nColVal;
|
uint64_t sz = tem->nColVal;
|
||||||
|
|
||||||
SArray* offsets = taosArrayInit(16, sizeof(uint64_t));
|
SArray* offsets = taosArrayInit(16, sizeof(uint64_t));
|
||||||
|
if (offsets == NULL) {
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
FAutoCtx* ctx = automCtxCreate((void*)p, AUTOMATION_PREFIX);
|
||||||
|
if (ctx == NULL) {
|
||||||
|
taosArrayDestroy(offsets);
|
||||||
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
FAutoCtx* ctx = automCtxCreate((void*)p, AUTOMATION_PREFIX);
|
|
||||||
FStmBuilder* sb = fstSearch(((TFileReader*)reader)->fst, ctx);
|
FStmBuilder* sb = fstSearch(((TFileReader*)reader)->fst, ctx);
|
||||||
FStmSt* st = stmBuilderIntoStm(sb);
|
FStmSt* st = stmBuilderIntoStm(sb);
|
||||||
FStmStRslt* rt = NULL;
|
FStmStRslt* rt = NULL;
|
||||||
|
|
Loading…
Reference in New Issue