compare return
This commit is contained in:
parent
90d9784984
commit
a7da6a7d51
|
@ -30,7 +30,7 @@ char* idxPackJsonData(SIndexTerm* itm);
|
||||||
char* idxPackJsonDataPrefix(SIndexTerm* itm, int32_t* skip);
|
char* idxPackJsonDataPrefix(SIndexTerm* itm, int32_t* skip);
|
||||||
char* idxPackJsonDataPrefixNoType(SIndexTerm* itm, int32_t* skip);
|
char* idxPackJsonDataPrefixNoType(SIndexTerm* itm, int32_t* skip);
|
||||||
|
|
||||||
typedef enum { MATCH, CONTINUE, BREAK } TExeCond;
|
typedef enum { MATCH, CONTINUE, BREAK, ERROR } TExeCond;
|
||||||
|
|
||||||
typedef TExeCond (*_cache_range_compare)(void* a, void* b, int8_t type);
|
typedef TExeCond (*_cache_range_compare)(void* a, void* b, int8_t type);
|
||||||
|
|
||||||
|
|
|
@ -153,9 +153,8 @@ static int32_t cacheSearchCompareFunc(void* cache, SIndexTerm* term, SIdxTRslt*
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
CacheTerm* c = (CacheTerm*)SL_GET_NODE_DATA(node);
|
CacheTerm* c = (CacheTerm*)SL_GET_NODE_DATA(node);
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
|
||||||
TExeCond cond = cmpFn(c->colVal, pCt->colVal, pCt->colType);
|
TExeCond cond = cmpFn(c->colVal, pCt->colVal, pCt->colType);
|
||||||
if (terrno != TSDB_CODE_SUCCESS) {
|
if (cond == ERROR) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
@ -335,10 +334,9 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTR
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
memcpy(p, c->colVal, strlen(c->colVal));
|
memcpy(p, c->colVal, strlen(c->colVal));
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
|
||||||
cond = cmpFn(p + skip, term->colVal, dType);
|
cond = cmpFn(p + skip, term->colVal, dType);
|
||||||
taosMemoryFree(p);
|
taosMemoryFree(p);
|
||||||
if (terrno != TSDB_CODE_SUCCESS) {
|
if (cond == ERROR) {
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,14 @@ static FORCE_INLINE TExeCond tCompareContains(void* a, void* b, int8_t type) {
|
||||||
}
|
}
|
||||||
return tCompare(func, QUERY_TERM, a, b, type);
|
return tCompare(func, QUERY_TERM, a, b, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define CHECKCOMERROR(expr) \
|
||||||
|
do { \
|
||||||
|
if ((expr) != 0) { \
|
||||||
|
return ERROR; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
static FORCE_INLINE TExeCond tCompareEqual(void* a, void* b, int8_t type) {
|
static FORCE_INLINE TExeCond tCompareEqual(void* a, void* b, int8_t type) {
|
||||||
__compar_fn_t func = idxGetCompar(type);
|
__compar_fn_t func = idxGetCompar(type);
|
||||||
if (func == NULL) {
|
if (func == NULL) {
|
||||||
|
@ -133,51 +141,51 @@ TExeCond tCompare(__compar_fn_t func, int8_t cmptype, void* a, void* b, int8_t d
|
||||||
#if 1
|
#if 1
|
||||||
if (dtype == TSDB_DATA_TYPE_TIMESTAMP) {
|
if (dtype == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
int64_t va;
|
int64_t va;
|
||||||
taosStr2int64(a, &va);
|
CHECKCOMERROR(taosStr2int64(a, &va));
|
||||||
int64_t vb;
|
int64_t vb;
|
||||||
taosStr2int64(b, &vb);
|
CHECKCOMERROR(taosStr2int64(b, &vb));
|
||||||
return tDoCompare(func, cmptype, &va, &vb);
|
return tDoCompare(func, cmptype, &va, &vb);
|
||||||
} else if (dtype == TSDB_DATA_TYPE_BOOL || dtype == TSDB_DATA_TYPE_UTINYINT) {
|
} else if (dtype == TSDB_DATA_TYPE_BOOL || dtype == TSDB_DATA_TYPE_UTINYINT) {
|
||||||
uint8_t va;
|
uint8_t va;
|
||||||
taosStr2int8(a, &va);
|
CHECKCOMERROR(taosStr2int8(a, &va));
|
||||||
uint8_t vb;
|
uint8_t vb;
|
||||||
taosStr2int8(b, &vb);
|
CHECKCOMERROR(taosStr2int8(b, &vb));
|
||||||
return tDoCompare(func, cmptype, &va, &vb);
|
return tDoCompare(func, cmptype, &va, &vb);
|
||||||
} else if (dtype == TSDB_DATA_TYPE_TINYINT) {
|
} else if (dtype == TSDB_DATA_TYPE_TINYINT) {
|
||||||
int8_t va;
|
int8_t va;
|
||||||
taosStr2int8(a, &va);
|
CHECKCOMERROR(taosStr2int8(a, &va));
|
||||||
int8_t vb;
|
int8_t vb;
|
||||||
taosStr2int8(b, &vb);
|
CHECKCOMERROR(taosStr2int8(b, &vb));
|
||||||
return tDoCompare(func, cmptype, &va, &vb);
|
return tDoCompare(func, cmptype, &va, &vb);
|
||||||
} else if (dtype == TSDB_DATA_TYPE_SMALLINT) {
|
} else if (dtype == TSDB_DATA_TYPE_SMALLINT) {
|
||||||
int16_t va;
|
int16_t va;
|
||||||
taosStr2int16(a, &va);
|
CHECKCOMERROR(taosStr2int16(a, &va));
|
||||||
int16_t vb;
|
int16_t vb;
|
||||||
taosStr2int16(b, &vb);
|
CHECKCOMERROR(taosStr2int16(b, &vb));
|
||||||
return tDoCompare(func, cmptype, &va, &vb);
|
return tDoCompare(func, cmptype, &va, &vb);
|
||||||
} else if (dtype == TSDB_DATA_TYPE_USMALLINT) {
|
} else if (dtype == TSDB_DATA_TYPE_USMALLINT) {
|
||||||
uint16_t va;
|
uint16_t va;
|
||||||
taosStr2int16(a, &va);
|
CHECKCOMERROR(taosStr2int16(a, &va));
|
||||||
uint16_t vb;
|
uint16_t vb;
|
||||||
taosStr2int16(b, &vb);
|
CHECKCOMERROR(taosStr2int16(b, &vb));
|
||||||
return tDoCompare(func, cmptype, &va, &vb);
|
return tDoCompare(func, cmptype, &va, &vb);
|
||||||
} else if (dtype == TSDB_DATA_TYPE_INT) {
|
} else if (dtype == TSDB_DATA_TYPE_INT) {
|
||||||
int32_t va;
|
int32_t va;
|
||||||
taosStr2int32(a, &va);
|
CHECKCOMERROR(taosStr2int32(a, &va));
|
||||||
int32_t vb;
|
int32_t vb;
|
||||||
taosStr2int32(b, &vb);
|
CHECKCOMERROR(taosStr2int32(b, &vb));
|
||||||
return tDoCompare(func, cmptype, &va, &vb);
|
return tDoCompare(func, cmptype, &va, &vb);
|
||||||
} else if (dtype == TSDB_DATA_TYPE_UINT) {
|
} else if (dtype == TSDB_DATA_TYPE_UINT) {
|
||||||
uint32_t va;
|
uint32_t va;
|
||||||
taosStr2int32(a, &va);
|
CHECKCOMERROR(taosStr2int32(a, &va));
|
||||||
uint32_t vb;
|
uint32_t vb;
|
||||||
taosStr2int32(b, &vb);
|
CHECKCOMERROR(taosStr2int32(b, &vb));
|
||||||
return tDoCompare(func, cmptype, &va, &vb);
|
return tDoCompare(func, cmptype, &va, &vb);
|
||||||
} else if (dtype == TSDB_DATA_TYPE_BIGINT) {
|
} else if (dtype == TSDB_DATA_TYPE_BIGINT) {
|
||||||
int64_t va;
|
int64_t va;
|
||||||
taosStr2int64(a, &va);
|
CHECKCOMERROR(taosStr2int64(a, &va));
|
||||||
int64_t vb;
|
int64_t vb;
|
||||||
taosStr2int64(b, &vb);
|
CHECKCOMERROR(taosStr2int64(b, &vb));
|
||||||
return tDoCompare(func, cmptype, &va, &vb);
|
return tDoCompare(func, cmptype, &va, &vb);
|
||||||
} else if (dtype == TSDB_DATA_TYPE_UBIGINT) {
|
} else if (dtype == TSDB_DATA_TYPE_UBIGINT) {
|
||||||
uint64_t va, vb;
|
uint64_t va, vb;
|
||||||
|
|
|
@ -367,9 +367,8 @@ static int32_t tfSearchCompareFunc(void* reader, SIndexTerm* tem, SIdxTRslt* tr,
|
||||||
FstSlice* s = &rt->data;
|
FstSlice* s = &rt->data;
|
||||||
char* ch = (char*)fstSliceData(s, NULL);
|
char* ch = (char*)fstSliceData(s, NULL);
|
||||||
|
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
|
||||||
TExeCond cond = cmpFn(ch, p, tem->colType);
|
TExeCond cond = cmpFn(ch, p, tem->colType);
|
||||||
if (TSDB_CODE_SUCCESS != terrno) {
|
if (ERROR == cond) {
|
||||||
swsResultDestroy(rt);
|
swsResultDestroy(rt);
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _return;
|
goto _return;
|
||||||
|
@ -520,10 +519,9 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTRslt
|
||||||
goto _return;
|
goto _return;
|
||||||
}
|
}
|
||||||
memcpy(tBuf, ch, sz);
|
memcpy(tBuf, ch, sz);
|
||||||
terrno = TSDB_CODE_SUCCESS;
|
|
||||||
cond = cmpFn(tBuf + skip, tem->colVal, IDX_TYPE_GET_TYPE(tem->colType));
|
cond = cmpFn(tBuf + skip, tem->colVal, IDX_TYPE_GET_TYPE(tem->colType));
|
||||||
taosMemoryFree(tBuf);
|
taosMemoryFree(tBuf);
|
||||||
if (TSDB_CODE_SUCCESS != terrno) {
|
if (ERROR == cond) {
|
||||||
swsResultDestroy(rt);
|
swsResultDestroy(rt);
|
||||||
code = terrno;
|
code = terrno;
|
||||||
goto _return;
|
goto _return;
|
||||||
|
|
|
@ -104,7 +104,7 @@ void taosRemoveDir(const char *dirname) {
|
||||||
if (taosDirEntryIsDir(de)) {
|
if (taosDirEntryIsDir(de)) {
|
||||||
taosRemoveDir(filename);
|
taosRemoveDir(filename);
|
||||||
} else {
|
} else {
|
||||||
(void)taosRemoveFile(filename);
|
TAOS_UNUSED(taosRemoveFile(filename));
|
||||||
// printf("file:%s is removed\n", filename);
|
// printf("file:%s is removed\n", filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -315,7 +315,7 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays) {
|
||||||
if (fileSec <= 100) continue;
|
if (fileSec <= 100) continue;
|
||||||
int32_t days = (int32_t)(TABS(sec - fileSec) / 86400 + 1);
|
int32_t days = (int32_t)(TABS(sec - fileSec) / 86400 + 1);
|
||||||
if (days > keepDays) {
|
if (days > keepDays) {
|
||||||
(void)taosRemoveFile(filename);
|
TAOS_UNUSED(taosRemoveFile(filename));
|
||||||
uInfo("file:%s is removed, days:%d keepDays:%d, sed:%"PRId64, filename, days, keepDays, fileSec);
|
uInfo("file:%s is removed, days:%d keepDays:%d, sed:%"PRId64, filename, days, keepDays, fileSec);
|
||||||
} else {
|
} else {
|
||||||
// printf("file:%s won't be removed, days:%d keepDays:%d", filename, days, keepDays);
|
// printf("file:%s won't be removed, days:%d keepDays:%d", filename, days, keepDays);
|
||||||
|
|
Loading…
Reference in New Issue