From 7e5dd50235ff46f219d7165e21408ea72d446035 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 8 Jun 2022 13:21:07 +0800 Subject: [PATCH] fix: add col type --- source/libs/index/src/indexCache.c | 11 +++++++---- source/libs/index/src/indexTfile.c | 4 +++- source/libs/index/test/jsonUT.cc | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/source/libs/index/src/indexCache.c b/source/libs/index/src/indexCache.c index c90cfd1f36..1e80d9c68d 100644 --- a/source/libs/index/src/indexCache.c +++ b/source/libs/index/src/indexCache.c @@ -297,12 +297,15 @@ static int32_t cacheSearchCompareFunc_JSON(void* cache, SIndexTerm* term, SIdxTR cond = MATCH; } } else { - if (0 != strncmp(c->colVal, pCt->colVal, skip)) { + if (0 != strncmp(c->colVal, pCt->colVal, skip - 1)) { break; + } else if (0 != strncmp(c->colVal, pCt->colVal, skip)) { + continue; + } else { + char* p = taosMemoryCalloc(1, strlen(c->colVal) + 1); + memcpy(p, c->colVal, strlen(c->colVal)); + cond = cmpFn(p + skip, term->colVal, dType); } - char* p = taosMemoryCalloc(1, strlen(c->colVal) + 1); - memcpy(p, c->colVal, strlen(c->colVal)); - cond = cmpFn(p + skip, term->colVal, dType); } if (cond == MATCH) { if (c->operaType == ADD_VALUE) { diff --git a/source/libs/index/src/indexTfile.c b/source/libs/index/src/indexTfile.c index 13659c06e3..c2747a7e30 100644 --- a/source/libs/index/src/indexTfile.c +++ b/source/libs/index/src/indexTfile.c @@ -492,9 +492,11 @@ static int32_t tfSearchCompareFunc_JSON(void* reader, SIndexTerm* tem, SIdxTRslt cond = MATCH; } } else { - if (0 != strncmp(ch, p, skip)) { + if (0 != strncmp(ch, p, skip - 1)) { swsResultDestroy(rt); break; + } else if (0 != strncmp(ch, p, skip)) { + continue; } cond = cmpFn(ch + skip, tem->colVal, INDEX_TYPE_GET_TYPE(tem->colType)); } diff --git a/source/libs/index/test/jsonUT.cc b/source/libs/index/test/jsonUT.cc index e0a8165b93..d6bc31a801 100644 --- a/source/libs/index/test/jsonUT.cc +++ b/source/libs/index/test/jsonUT.cc @@ -226,7 +226,7 @@ TEST_F(JsonEnv, testWriteMillonData) { SArray* result = taosArrayInit(1, sizeof(uint64_t)); indexMultiTermQueryAdd(mq, q, QUERY_GREATER_THAN); tIndexJsonSearch(index, mq, result); - assert(0 == taosArrayGetSize(result)); + EXPECT_EQ(0, taosArrayGetSize(result)); indexMultiTermQueryDestroy(mq); } {