fix: avoid filter failure
This commit is contained in:
parent
991b5c7b40
commit
fb389ab826
|
@ -70,9 +70,6 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
|
||||||
|
|
||||||
char * key = pTagVal->pKey;
|
char * key = pTagVal->pKey;
|
||||||
int32_t nKey = strlen(key);
|
int32_t nKey = strlen(key);
|
||||||
if (nKey == 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
SIndexTerm *term = NULL;
|
SIndexTerm *term = NULL;
|
||||||
if (type == TSDB_DATA_TYPE_NULL) {
|
if (type == TSDB_DATA_TYPE_NULL) {
|
||||||
|
@ -96,7 +93,7 @@ static int metaSaveJsonVarToIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry, const
|
||||||
} else if (type == TSDB_DATA_TYPE_BOOL) {
|
} else if (type == TSDB_DATA_TYPE_BOOL) {
|
||||||
int val = *(int *)(&pTagVal->i64);
|
int val = *(int *)(&pTagVal->i64);
|
||||||
int len = 0;
|
int len = 0;
|
||||||
term = indexTermCreate(suid, ADD_VALUE, type, key, nKey, (const char *)&val, len);
|
term = indexTermCreate(suid, ADD_VALUE, TSDB_DATA_TYPE_INT, key, nKey, (const char *)&val, len);
|
||||||
}
|
}
|
||||||
if (term != NULL) {
|
if (term != NULL) {
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
|
|
|
@ -28,6 +28,7 @@ extern char JSON_VALUE_DELIM;
|
||||||
|
|
||||||
char* indexPackJsonData(SIndexTerm* itm);
|
char* indexPackJsonData(SIndexTerm* itm);
|
||||||
char* indexPackJsonDataPrefix(SIndexTerm* itm, int32_t* skip);
|
char* indexPackJsonDataPrefix(SIndexTerm* itm, int32_t* skip);
|
||||||
|
char* indexPackJsonDataPrefixNoType(SIndexTerm* itm, int32_t* skip);
|
||||||
|
|
||||||
typedef enum { MATCH, CONTINUE, BREAK } TExeCond;
|
typedef enum { MATCH, CONTINUE, BREAK } TExeCond;
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ extern "C" {
|
||||||
#define indexTrace(...) do { if (idxDebugFlag & DEBUG_TRACE) { taosPrintLog("IDX", DEBUG_TRACE, idxDebugFlag, __VA_ARGS__);} } while (0)
|
#define indexTrace(...) do { if (idxDebugFlag & DEBUG_TRACE) { taosPrintLog("IDX", DEBUG_TRACE, idxDebugFlag, __VA_ARGS__);} } while (0)
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
typedef enum { LT, LE, GT, GE, CONTAINS } RangeType;
|
typedef enum { LT, LE, GT, GE, CONTAINS, EQ } RangeType;
|
||||||
typedef enum { kTypeValue, kTypeDeletion } STermValueType;
|
typedef enum { kTypeValue, kTypeDeletion } STermValueType;
|
||||||
|
|
||||||
typedef struct SIndexStat {
|
typedef struct SIndexStat {
|
||||||
|
|
|
@ -48,6 +48,7 @@ static int32_t cacheSearchRange(void* cache, SIndexTerm* ct, SIdxTRslt* tr, STer
|
||||||
/*comm func of compare, used in (LE/LT/GE/GT compare)*/
|
/*comm func of compare, used in (LE/LT/GE/GT compare)*/
|
||||||
static int32_t cacheSearchCompareFunc(void* cache, SIndexTerm* ct, SIdxTRslt* tr, STermValueType* s, RangeType type);
|
static int32_t cacheSearchCompareFunc(void* cache, SIndexTerm* ct, SIdxTRslt* tr, STermValueType* s, RangeType type);
|
||||||
static int32_t cacheSearchTerm_JSON(void* cache, SIndexTerm* ct, SIdxTRslt* tr, STermValueType* s);
|
static int32_t cacheSearchTerm_JSON(void* cache, SIndexTerm* ct, SIdxTRslt* tr, STermValueType* s);
|
||||||
|
static int32_t cacheSearchEqual_JSON(void* cache, SIndexTerm* ct, SIdxTRslt* tr, STermValueType* s);
|
||||||
static int32_t cacheSearchPrefix_JSON(void* cache, SIndexTerm* ct, SIdxTRslt* tr, STermValueType* s);
|
static int32_t cacheSearchPrefix_JSON(void* cache, SIndexTerm* ct, SIdxTRslt* tr, STermValueType* s);
|
||||||
static int32_t cacheSearchSuffix_JSON(void* cache, SIndexTerm* ct, SIdxTRslt* tr, STermValueType* s);
|
static int32_t cacheSearchSuffix_JSON(void* cache, SIndexTerm* ct, SIdxTRslt* tr, STermValueType* s);
|
||||||
static int32_t cacheSearchRegex_JSON(void* cache, SIndexTerm* ct, SIdxTRslt* tr, STermValueType* s);
|
static int32_t cacheSearchRegex_JSON(void* cache, SIndexTerm* ct, SIdxTRslt* tr, STermValueType* s);
|
||||||
|
@ -63,7 +64,7 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTR
|
||||||
static int32_t (*cacheSearch[][QUERY_MAX])(void* cache, SIndexTerm* ct, SIdxTRslt* tr, STermValueType* s) = {
|
static int32_t (*cacheSearch[][QUERY_MAX])(void* cache, SIndexTerm* ct, SIdxTRslt* tr, STermValueType* s) = {
|
||||||
{cacheSearchTerm, cacheSearchPrefix, cacheSearchSuffix, cacheSearchRegex, cacheSearchLessThan, cacheSearchLessEqual,
|
{cacheSearchTerm, cacheSearchPrefix, cacheSearchSuffix, cacheSearchRegex, cacheSearchLessThan, cacheSearchLessEqual,
|
||||||
cacheSearchGreaterThan, cacheSearchGreaterEqual, cacheSearchRange},
|
cacheSearchGreaterThan, cacheSearchGreaterEqual, cacheSearchRange},
|
||||||
{cacheSearchTerm_JSON, cacheSearchPrefix_JSON, cacheSearchSuffix_JSON, cacheSearchRegex_JSON,
|
{cacheSearchEqual_JSON, cacheSearchPrefix_JSON, cacheSearchSuffix_JSON, cacheSearchRegex_JSON,
|
||||||
cacheSearchLessThan_JSON, cacheSearchLessEqual_JSON, cacheSearchGreaterThan_JSON, cacheSearchGreaterEqual_JSON,
|
cacheSearchLessThan_JSON, cacheSearchLessEqual_JSON, cacheSearchGreaterThan_JSON, cacheSearchGreaterEqual_JSON,
|
||||||
cacheSearchRange_JSON}};
|
cacheSearchRange_JSON}};
|
||||||
|
|
||||||
|
@ -220,15 +221,18 @@ static int32_t cacheSearchTerm_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
static int32_t cacheSearchPrefix_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr, STermValueType* s) {
|
|
||||||
return cacheSearchCompareFunc_JSON(cache, term, tr, s, CONTAINS);
|
|
||||||
}
|
|
||||||
static int32_t cacheSearchSuffix_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr, STermValueType* s) {
|
static int32_t cacheSearchSuffix_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr, STermValueType* s) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
static int32_t cacheSearchRegex_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr, STermValueType* s) {
|
static int32_t cacheSearchRegex_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr, STermValueType* s) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
static int32_t cacheSearchEqual_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr, STermValueType* s) {
|
||||||
|
return cacheSearchCompareFunc_JSON(cache, term, tr, s, EQ);
|
||||||
|
}
|
||||||
|
static int32_t cacheSearchPrefix_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr, STermValueType* s) {
|
||||||
|
return cacheSearchCompareFunc_JSON(cache, term, tr, s, CONTAINS);
|
||||||
|
}
|
||||||
static int32_t cacheSearchLessThan_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr, STermValueType* s) {
|
static int32_t cacheSearchLessThan_JSON(void* cache, SIndexTerm* term, SIdxTRslt* tr, STermValueType* s) {
|
||||||
return cacheSearchCompareFunc_JSON(cache, term, tr, s, LT);
|
return cacheSearchCompareFunc_JSON(cache, term, tr, s, LT);
|
||||||
}
|
}
|
||||||
|
@ -272,7 +276,7 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTR
|
||||||
.colType = term->colType,
|
.colType = term->colType,
|
||||||
.colName = term->colVal,
|
.colName = term->colVal,
|
||||||
.nColName = term->nColVal};
|
.nColName = term->nColVal};
|
||||||
exBuf = indexPackJsonDataPrefix(&tm, &skip);
|
exBuf = indexPackJsonDataPrefixNoType(&tm, &skip);
|
||||||
pCt->colVal = exBuf;
|
pCt->colVal = exBuf;
|
||||||
} else {
|
} else {
|
||||||
exBuf = indexPackJsonDataPrefix(term, &skip);
|
exBuf = indexPackJsonDataPrefix(term, &skip);
|
||||||
|
@ -298,7 +302,7 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTR
|
||||||
}
|
}
|
||||||
char* p = taosMemoryCalloc(1, strlen(c->colVal) + 1);
|
char* p = taosMemoryCalloc(1, strlen(c->colVal) + 1);
|
||||||
memcpy(p, c->colVal, strlen(c->colVal));
|
memcpy(p, c->colVal, strlen(c->colVal));
|
||||||
TExeCond cond = cmpFn(p + skip, term->colVal, dType);
|
cond = cmpFn(p + skip, term->colVal, dType);
|
||||||
}
|
}
|
||||||
if (cond == MATCH) {
|
if (cond == MATCH) {
|
||||||
if (c->operaType == ADD_VALUE) {
|
if (c->operaType == ADD_VALUE) {
|
||||||
|
|
|
@ -102,6 +102,10 @@ static TExeCond tCompareContains(void* a, void* b, int8_t type) {
|
||||||
__compar_fn_t func = indexGetCompar(type);
|
__compar_fn_t func = indexGetCompar(type);
|
||||||
return tCompare(func, QUERY_TERM, a, b, type);
|
return tCompare(func, QUERY_TERM, a, b, type);
|
||||||
}
|
}
|
||||||
|
static TExeCond tCompareEqual(void* a, void* b, int8_t type) {
|
||||||
|
__compar_fn_t func = indexGetCompar(type);
|
||||||
|
return tCompare(func, QUERY_TERM, a, b, type);
|
||||||
|
}
|
||||||
TExeCond tCompare(__compar_fn_t func, int8_t cmptype, void* a, void* b, int8_t dtype) {
|
TExeCond tCompare(__compar_fn_t func, int8_t cmptype, void* a, void* b, int8_t dtype) {
|
||||||
if (dtype == TSDB_DATA_TYPE_BINARY || dtype == TSDB_DATA_TYPE_NCHAR || dtype == TSDB_DATA_TYPE_VARBINARY) {
|
if (dtype == TSDB_DATA_TYPE_BINARY || dtype == TSDB_DATA_TYPE_NCHAR || dtype == TSDB_DATA_TYPE_VARBINARY) {
|
||||||
return tDoCompare(func, cmptype, a, b);
|
return tDoCompare(func, cmptype, a, b);
|
||||||
|
@ -186,9 +190,11 @@ TExeCond tDoCompare(__compar_fn_t func, int8_t comparType, void* a, void* b) {
|
||||||
}
|
}
|
||||||
case QUERY_GREATER_EQUAL: {
|
case QUERY_GREATER_EQUAL: {
|
||||||
if (ret >= 0) return MATCH;
|
if (ret >= 0) return MATCH;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case QUERY_TERM: {
|
case QUERY_TERM: {
|
||||||
if (ret == 0) return MATCH;
|
if (ret == 0) return MATCH;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return BREAK;
|
return BREAK;
|
||||||
|
@ -197,7 +203,7 @@ TExeCond tDoCompare(__compar_fn_t func, int8_t comparType, void* a, void* b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static TExeCond (*rangeCompare[])(void* a, void* b, int8_t type) = {
|
static TExeCond (*rangeCompare[])(void* a, void* b, int8_t type) = {
|
||||||
tCompareLessThan, tCompareLessEqual, tCompareGreaterThan, tCompareGreaterEqual, tCompareContains};
|
tCompareLessThan, tCompareLessEqual, tCompareGreaterThan, tCompareGreaterEqual, tCompareContains, tCompareEqual};
|
||||||
|
|
||||||
_cache_range_compare indexGetCompare(RangeType ty) { return rangeCompare[ty]; }
|
_cache_range_compare indexGetCompare(RangeType ty) { return rangeCompare[ty]; }
|
||||||
|
|
||||||
|
@ -256,6 +262,26 @@ char* indexPackJsonDataPrefix(SIndexTerm* itm, int32_t* skip) {
|
||||||
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
char* indexPackJsonDataPrefixNoType(SIndexTerm* itm, int32_t* skip) {
|
||||||
|
/*
|
||||||
|
* |<-----colname---->|<-----dataType---->|<--------colVal---------->|
|
||||||
|
* |<-----string----->|<-----uint8_t----->|<----depend on dataType-->|
|
||||||
|
*/
|
||||||
|
uint8_t ty = INDEX_TYPE_GET_TYPE(itm->colType);
|
||||||
|
|
||||||
|
int32_t sz = itm->nColName + itm->nColVal + sizeof(uint8_t) + sizeof(JSON_VALUE_DELIM) * 2 + 1;
|
||||||
|
char* buf = (char*)taosMemoryCalloc(1, sz);
|
||||||
|
char* p = buf;
|
||||||
|
|
||||||
|
memcpy(p, itm->colName, itm->nColName);
|
||||||
|
p += itm->nColName;
|
||||||
|
|
||||||
|
memcpy(p, &JSON_VALUE_DELIM, sizeof(JSON_VALUE_DELIM));
|
||||||
|
p += sizeof(JSON_VALUE_DELIM);
|
||||||
|
*skip = p - buf;
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t indexConvertData(void* src, int8_t type, void** dst) {
|
int32_t indexConvertData(void* src, int8_t type, void** dst) {
|
||||||
int tlen = -1;
|
int tlen = -1;
|
||||||
|
|
|
@ -186,6 +186,9 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
|
||||||
SIF_ERR_RET(sifGetValueFromNode(node, ¶m->condValue));
|
SIF_ERR_RET(sifGetValueFromNode(node, ¶m->condValue));
|
||||||
param->colId = -1;
|
param->colId = -1;
|
||||||
param->colValType = (uint8_t)(vn->node.resType.type);
|
param->colValType = (uint8_t)(vn->node.resType.type);
|
||||||
|
if (vn->literal == NULL || strlen(vn->literal) == 0) {
|
||||||
|
return TSDB_CODE_QRY_INVALID_INPUT;
|
||||||
|
}
|
||||||
memcpy(param->colName, vn->literal, strlen(vn->literal));
|
memcpy(param->colName, vn->literal, strlen(vn->literal));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,14 @@ int tIndexJsonOpen(SIndexJsonOpts *opts, const char *path, SIndexJson **index) {
|
||||||
int tIndexJsonPut(SIndexJson *index, SIndexJsonMultiTerm *terms, uint64_t uid) {
|
int tIndexJsonPut(SIndexJson *index, SIndexJsonMultiTerm *terms, uint64_t uid) {
|
||||||
for (int i = 0; i < taosArrayGetSize(terms); i++) {
|
for (int i = 0; i < taosArrayGetSize(terms); i++) {
|
||||||
SIndexJsonTerm *p = taosArrayGetP(terms, i);
|
SIndexJsonTerm *p = taosArrayGetP(terms, i);
|
||||||
|
if (p->colType == TSDB_DATA_TYPE_BOOL) {
|
||||||
|
p->colType = TSDB_DATA_TYPE_INT;
|
||||||
|
} else if (p->colType == TSDB_DATA_TYPE_VARCHAR || p->colType == TSDB_DATA_TYPE_NCHAR ||
|
||||||
|
p->colType == TSDB_DATA_TYPE_BINARY) {
|
||||||
|
// p->colType = TSDB_DATA_TYPE_NCHAR;
|
||||||
|
} else {
|
||||||
|
p->colType = TSDB_DATA_TYPE_DOUBLE;
|
||||||
|
}
|
||||||
INDEX_TYPE_ADD_EXTERN_TYPE(p->colType, TSDB_DATA_TYPE_JSON);
|
INDEX_TYPE_ADD_EXTERN_TYPE(p->colType, TSDB_DATA_TYPE_JSON);
|
||||||
}
|
}
|
||||||
// handle put
|
// handle put
|
||||||
|
@ -32,6 +40,14 @@ int tIndexJsonSearch(SIndexJson *index, SIndexJsonMultiTermQuery *tq, SArray *re
|
||||||
SArray *terms = tq->query;
|
SArray *terms = tq->query;
|
||||||
for (int i = 0; i < taosArrayGetSize(terms); i++) {
|
for (int i = 0; i < taosArrayGetSize(terms); i++) {
|
||||||
SIndexJsonTerm *p = taosArrayGetP(terms, i);
|
SIndexJsonTerm *p = taosArrayGetP(terms, i);
|
||||||
|
if (p->colType == TSDB_DATA_TYPE_BOOL) {
|
||||||
|
p->colType = TSDB_DATA_TYPE_INT;
|
||||||
|
} else if (p->colType == TSDB_DATA_TYPE_VARCHAR || p->colType == TSDB_DATA_TYPE_NCHAR ||
|
||||||
|
p->colType == TSDB_DATA_TYPE_BINARY) {
|
||||||
|
// p->colType = TSDB_DATA_TYPE_NCHAR;
|
||||||
|
} else {
|
||||||
|
p->colType = TSDB_DATA_TYPE_DOUBLE;
|
||||||
|
}
|
||||||
INDEX_TYPE_ADD_EXTERN_TYPE(p->colType, TSDB_DATA_TYPE_JSON);
|
INDEX_TYPE_ADD_EXTERN_TYPE(p->colType, TSDB_DATA_TYPE_JSON);
|
||||||
}
|
}
|
||||||
// handle search
|
// handle search
|
||||||
|
|
|
@ -73,6 +73,7 @@ static int32_t tfSearchRange(void* reader, SIndexTerm* tem, SIdxTRslt* tr);
|
||||||
static int32_t tfSearchCompareFunc(void* reader, SIndexTerm* tem, SIdxTRslt* tr, RangeType ctype);
|
static int32_t tfSearchCompareFunc(void* reader, SIndexTerm* tem, SIdxTRslt* tr, RangeType ctype);
|
||||||
|
|
||||||
static int32_t tfSearchTerm_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr);
|
static int32_t tfSearchTerm_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr);
|
||||||
|
static int32_t tfSearchEqual_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr);
|
||||||
static int32_t tfSearchPrefix_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr);
|
static int32_t tfSearchPrefix_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr);
|
||||||
static int32_t tfSearchSuffix_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr);
|
static int32_t tfSearchSuffix_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr);
|
||||||
static int32_t tfSearchRegex_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr);
|
static int32_t tfSearchRegex_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr);
|
||||||
|
@ -87,7 +88,7 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTRslt
|
||||||
static int32_t (*tfSearch[][QUERY_MAX])(void* reader, SIndexTerm* tem, SIdxTRslt* tr) = {
|
static int32_t (*tfSearch[][QUERY_MAX])(void* reader, SIndexTerm* tem, SIdxTRslt* tr) = {
|
||||||
{tfSearchTerm, tfSearchPrefix, tfSearchSuffix, tfSearchRegex, tfSearchLessThan, tfSearchLessEqual,
|
{tfSearchTerm, tfSearchPrefix, tfSearchSuffix, tfSearchRegex, tfSearchLessThan, tfSearchLessEqual,
|
||||||
tfSearchGreaterThan, tfSearchGreaterEqual, tfSearchRange},
|
tfSearchGreaterThan, tfSearchGreaterEqual, tfSearchRange},
|
||||||
{tfSearchTerm_JSON, tfSearchPrefix_JSON, tfSearchSuffix_JSON, tfSearchRegex_JSON, tfSearchLessThan_JSON,
|
{tfSearchEqual_JSON, tfSearchPrefix_JSON, tfSearchSuffix_JSON, tfSearchRegex_JSON, tfSearchLessThan_JSON,
|
||||||
tfSearchLessEqual_JSON, tfSearchGreaterThan_JSON, tfSearchGreaterEqual_JSON, tfSearchRange_JSON}};
|
tfSearchLessEqual_JSON, tfSearchGreaterThan_JSON, tfSearchGreaterEqual_JSON, tfSearchRange_JSON}};
|
||||||
|
|
||||||
TFileCache* tfileCacheCreate(const char* path) {
|
TFileCache* tfileCacheCreate(const char* path) {
|
||||||
|
@ -424,6 +425,9 @@ static int32_t tfSearchTerm_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr) {
|
||||||
// deprecate api
|
// deprecate api
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
static int32_t tfSearchEqual_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr) {
|
||||||
|
return tfSearchCompareFunc_JSON(reader, tem, tr, EQ);
|
||||||
|
}
|
||||||
static int32_t tfSearchPrefix_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr) {
|
static int32_t tfSearchPrefix_JSON(void* reader, SIndexTerm* tem, SIdxTRslt* tr) {
|
||||||
return tfSearchCompareFunc_JSON(reader, tem, tr, CONTAINS);
|
return tfSearchCompareFunc_JSON(reader, tem, tr, CONTAINS);
|
||||||
}
|
}
|
||||||
|
@ -463,7 +467,7 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTRslt
|
||||||
.colType = tem->colType,
|
.colType = tem->colType,
|
||||||
.colName = tem->colVal,
|
.colName = tem->colVal,
|
||||||
.nColName = tem->nColVal};
|
.nColName = tem->nColVal};
|
||||||
p = indexPackJsonDataPrefix(&tm, &skip);
|
p = indexPackJsonDataPrefixNoType(&tm, &skip);
|
||||||
} else {
|
} else {
|
||||||
p = indexPackJsonDataPrefix(tem, &skip);
|
p = indexPackJsonDataPrefix(tem, &skip);
|
||||||
}
|
}
|
||||||
|
@ -484,7 +488,7 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTRslt
|
||||||
char* ch = (char*)fstSliceData(s, &sz);
|
char* ch = (char*)fstSliceData(s, &sz);
|
||||||
TExeCond cond = CONTINUE;
|
TExeCond cond = CONTINUE;
|
||||||
if (ctype == CONTAINS) {
|
if (ctype == CONTAINS) {
|
||||||
if (0 != strncmp(ch, p, skip)) {
|
if (0 == strncmp(ch, p, skip)) {
|
||||||
cond = MATCH;
|
cond = MATCH;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -107,41 +107,40 @@ TEST_F(JsonEnv, testWrite) {
|
||||||
{
|
{
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
std::string colVal("ab");
|
std::string colVal("ab");
|
||||||
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
for (int i = 0; i < 100; i++) {
|
||||||
colVal.c_str(), colVal.size());
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
|
colVal.c_str(), colVal.size());
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
for (size_t i = 0; i < 100; i++) {
|
|
||||||
tIndexJsonPut(index, terms, i);
|
tIndexJsonPut(index, terms, i);
|
||||||
|
indexMultiTermDestroy(terms);
|
||||||
}
|
}
|
||||||
indexMultiTermDestroy(terms);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colName("voltage");
|
std::string colName("voltage");
|
||||||
std::string colVal("ab1");
|
std::string colVal("ab1");
|
||||||
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
for (int i = 0; i < 100; i++) {
|
||||||
colVal.c_str(), colVal.size());
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
for (size_t i = 0; i < 100; i++) {
|
|
||||||
tIndexJsonPut(index, terms, i);
|
tIndexJsonPut(index, terms, i);
|
||||||
|
indexMultiTermDestroy(terms);
|
||||||
}
|
}
|
||||||
indexMultiTermDestroy(terms);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colName("voltage");
|
std::string colName("voltage");
|
||||||
std::string colVal("123");
|
std::string colVal("123");
|
||||||
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
|
||||||
colVal.c_str(), colVal.size());
|
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
|
||||||
indexMultiTermAdd(terms, term);
|
|
||||||
for (size_t i = 0; i < 100; i++) {
|
for (size_t i = 0; i < 100; i++) {
|
||||||
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
indexMultiTermAdd(terms, term);
|
||||||
tIndexJsonPut(index, terms, i);
|
tIndexJsonPut(index, terms, i);
|
||||||
|
indexMultiTermDestroy(terms);
|
||||||
}
|
}
|
||||||
indexMultiTermDestroy(terms);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
|
@ -154,7 +153,7 @@ TEST_F(JsonEnv, testWrite) {
|
||||||
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
SArray* result = taosArrayInit(1, sizeof(uint64_t));
|
||||||
indexMultiTermQueryAdd(mq, q, QUERY_TERM);
|
indexMultiTermQueryAdd(mq, q, QUERY_TERM);
|
||||||
tIndexJsonSearch(index, mq, result);
|
tIndexJsonSearch(index, mq, result);
|
||||||
assert(100 == taosArrayGetSize(result));
|
EXPECT_EQ(100, taosArrayGetSize(result));
|
||||||
indexMultiTermQueryDestroy(mq);
|
indexMultiTermQueryDestroy(mq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,44 +161,44 @@ TEST_F(JsonEnv, testWriteMillonData) {
|
||||||
{
|
{
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
std::string colVal("ab");
|
std::string colVal("ab");
|
||||||
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
|
||||||
colVal.c_str(), colVal.size());
|
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
|
||||||
indexMultiTermAdd(terms, term);
|
|
||||||
for (size_t i = 0; i < 10; i++) {
|
for (size_t i = 0; i < 10; i++) {
|
||||||
tIndexJsonPut(index, terms, i);
|
|
||||||
}
|
|
||||||
indexMultiTermDestroy(terms);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
std::string colName("voltagefdadfa");
|
|
||||||
std::string colVal("abxxxxxxxxxxxx");
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
colVal[i % colVal.size()] = '0' + i % 128;
|
|
||||||
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
colVal.c_str(), colVal.size());
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
for (size_t i = 0; i < 100; i++) {
|
tIndexJsonPut(index, terms, i);
|
||||||
tIndexJsonPut(index, terms, i);
|
|
||||||
}
|
|
||||||
indexMultiTermDestroy(terms);
|
indexMultiTermDestroy(terms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colName("voltagefdadfa");
|
std::string colName("voltagefdadfa");
|
||||||
std::string colVal("abxxxxxxxxxxxx");
|
std::string colVal("abxxxxxxxxxxxx");
|
||||||
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
for (int i = 0; i < 10; i++) {
|
||||||
colVal.c_str(), colVal.size());
|
colVal[i % colVal.size()] = '0' + i % 128;
|
||||||
|
for (size_t i = 0; i < 100; i++) {
|
||||||
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
indexMultiTermAdd(terms, term);
|
indexMultiTermAdd(terms, term);
|
||||||
for (size_t i = 0; i < 1000; i++) {
|
tIndexJsonPut(index, terms, i);
|
||||||
tIndexJsonPut(index, terms, i);
|
indexMultiTermDestroy(terms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::string colName("voltagefdadfa");
|
||||||
|
std::string colVal("abxxxxxxxxxxxx");
|
||||||
|
for (size_t i = 0; i < 1000; i++) {
|
||||||
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
indexMultiTermAdd(terms, term);
|
||||||
|
tIndexJsonPut(index, terms, i);
|
||||||
|
indexMultiTermDestroy(terms);
|
||||||
}
|
}
|
||||||
indexMultiTermDestroy(terms);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
|
@ -252,55 +251,55 @@ TEST_F(JsonEnv, testWriteJsonNumberData) {
|
||||||
{
|
{
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
// std::string colVal("10");
|
// std::string colVal("10");
|
||||||
int val = 10;
|
int val = 10;
|
||||||
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
|
||||||
(const char*)&val, sizeof(val));
|
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
|
||||||
indexMultiTermAdd(terms, term);
|
|
||||||
for (size_t i = 0; i < 1000; i++) {
|
for (size_t i = 0; i < 1000; i++) {
|
||||||
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
indexMultiTermAdd(terms, term);
|
||||||
tIndexJsonPut(index, terms, i);
|
tIndexJsonPut(index, terms, i);
|
||||||
|
indexMultiTermDestroy(terms);
|
||||||
}
|
}
|
||||||
indexMultiTermDestroy(terms);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colName("test2");
|
std::string colName("test2");
|
||||||
int val = 20;
|
int val = 20;
|
||||||
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
|
||||||
(const char*)&val, sizeof(val));
|
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
|
||||||
indexMultiTermAdd(terms, term);
|
|
||||||
for (size_t i = 0; i < 1000; i++) {
|
for (size_t i = 0; i < 1000; i++) {
|
||||||
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
indexMultiTermAdd(terms, term);
|
||||||
tIndexJsonPut(index, terms, i);
|
tIndexJsonPut(index, terms, i);
|
||||||
|
indexMultiTermDestroy(terms);
|
||||||
}
|
}
|
||||||
indexMultiTermDestroy(terms);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
int val = 15;
|
int val = 15;
|
||||||
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
|
||||||
(const char*)&val, sizeof(val));
|
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
|
||||||
indexMultiTermAdd(terms, term);
|
|
||||||
for (size_t i = 0; i < 1000; i++) {
|
for (size_t i = 0; i < 1000; i++) {
|
||||||
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
indexMultiTermAdd(terms, term);
|
||||||
tIndexJsonPut(index, terms, i);
|
tIndexJsonPut(index, terms, i);
|
||||||
|
indexMultiTermDestroy(terms);
|
||||||
}
|
}
|
||||||
indexMultiTermDestroy(terms);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colName("test2");
|
std::string colName("test2");
|
||||||
const char* val = "test";
|
const char* val = "test";
|
||||||
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
|
||||||
(const char*)val, strlen(val));
|
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
|
||||||
indexMultiTermAdd(terms, term);
|
|
||||||
for (size_t i = 0; i < 1000; i++) {
|
for (size_t i = 0; i < 1000; i++) {
|
||||||
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
|
(const char*)val, strlen(val));
|
||||||
|
|
||||||
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
indexMultiTermAdd(terms, term);
|
||||||
tIndexJsonPut(index, terms, i);
|
tIndexJsonPut(index, terms, i);
|
||||||
|
indexMultiTermDestroy(terms);
|
||||||
}
|
}
|
||||||
indexMultiTermDestroy(terms);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
|
@ -380,28 +379,28 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
{
|
{
|
||||||
std::string colName("test1");
|
std::string colName("test1");
|
||||||
int val = 10;
|
int val = 10;
|
||||||
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
|
||||||
(const char*)&val, sizeof(val));
|
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
|
||||||
indexMultiTermAdd(terms, term);
|
|
||||||
for (size_t i = 0; i < 1000; i++) {
|
for (size_t i = 0; i < 1000; i++) {
|
||||||
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
indexMultiTermAdd(terms, term);
|
||||||
tIndexJsonPut(index, terms, i);
|
tIndexJsonPut(index, terms, i);
|
||||||
|
indexMultiTermDestroy(terms);
|
||||||
}
|
}
|
||||||
indexMultiTermDestroy(terms);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colName("test");
|
std::string colName("test");
|
||||||
std::string colVal("xxxxxxxxxxxxxxxxxxx");
|
std::string colVal("xxxxxxxxxxxxxxxxxxx");
|
||||||
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
|
||||||
colVal.c_str(), colVal.size());
|
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
|
||||||
indexMultiTermAdd(terms, term);
|
|
||||||
for (size_t i = 0; i < 1000; i++) {
|
for (size_t i = 0; i < 1000; i++) {
|
||||||
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
|
||||||
|
colVal.c_str(), colVal.size());
|
||||||
|
|
||||||
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
indexMultiTermAdd(terms, term);
|
||||||
tIndexJsonPut(index, terms, i);
|
tIndexJsonPut(index, terms, i);
|
||||||
|
indexMultiTermDestroy(terms);
|
||||||
}
|
}
|
||||||
indexMultiTermDestroy(terms);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colName("test1");
|
std::string colName("test1");
|
||||||
|
@ -478,15 +477,15 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
std::string colName("other_column");
|
std::string colName("other_column");
|
||||||
int val = 100;
|
int val = 100;
|
||||||
|
|
||||||
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
|
||||||
(const char*)&val, sizeof(val));
|
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
|
||||||
indexMultiTermAdd(terms, term);
|
|
||||||
for (size_t i = 0; i < 1000; i++) {
|
for (size_t i = 0; i < 1000; i++) {
|
||||||
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
indexMultiTermAdd(terms, term);
|
||||||
tIndexJsonPut(index, terms, i);
|
tIndexJsonPut(index, terms, i);
|
||||||
|
indexMultiTermDestroy(terms);
|
||||||
}
|
}
|
||||||
indexMultiTermDestroy(terms);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colName("test1");
|
std::string colName("test1");
|
||||||
|
@ -506,15 +505,15 @@ TEST_F(JsonEnv, testWriteJsonTfileAndCache_INT) {
|
||||||
{
|
{
|
||||||
std::string colName("test1");
|
std::string colName("test1");
|
||||||
int val = 15;
|
int val = 15;
|
||||||
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
|
||||||
(const char*)&val, sizeof(val));
|
|
||||||
|
|
||||||
SIndexMultiTerm* terms = indexMultiTermCreate();
|
|
||||||
indexMultiTermAdd(terms, term);
|
|
||||||
for (size_t i = 0; i < 1000; i++) {
|
for (size_t i = 0; i < 1000; i++) {
|
||||||
|
SIndexTerm* term = indexTermCreateT(1, ADD_VALUE, TSDB_DATA_TYPE_INT, colName.c_str(), colName.size(),
|
||||||
|
(const char*)&val, sizeof(val));
|
||||||
|
|
||||||
|
SIndexMultiTerm* terms = indexMultiTermCreate();
|
||||||
|
indexMultiTermAdd(terms, term);
|
||||||
tIndexJsonPut(index, terms, i + 1000);
|
tIndexJsonPut(index, terms, i + 1000);
|
||||||
|
indexMultiTermDestroy(terms);
|
||||||
}
|
}
|
||||||
indexMultiTermDestroy(terms);
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
std::string colName("test1");
|
std::string colName("test1");
|
||||||
|
|
Loading…
Reference in New Issue