fix: fix filter error result

This commit is contained in:
yihaoDeng 2023-02-13 11:40:40 +08:00
parent 75577937be
commit 0f803fca10
3 changed files with 19 additions and 7 deletions

View File

@ -59,7 +59,7 @@ void vnodePostClose(SVnode *pVnode);
void vnodeSyncCheckTimeout(SVnode *pVnode); void vnodeSyncCheckTimeout(SVnode *pVnode);
void vnodeClose(SVnode *pVnode); void vnodeClose(SVnode *pVnode);
int32_t vnodeSyncCommit(SVnode *pVnode); int32_t vnodeSyncCommit(SVnode *pVnode);
int32_t vnodeBegin(SVnode* pVnode); int32_t vnodeBegin(SVnode *pVnode);
int32_t vnodeStart(SVnode *pVnode); int32_t vnodeStart(SVnode *pVnode);
void vnodeStop(SVnode *pVnode); void vnodeStop(SVnode *pVnode);
@ -137,6 +137,7 @@ typedef struct SMetaFltParam {
int16_t type; int16_t type;
void *val; void *val;
bool reverse; bool reverse;
bool equal;
int (*filterFunc)(void *a, void *b, int16_t type); int (*filterFunc)(void *a, void *b, int16_t type);
} SMetaFltParam; } SMetaFltParam;
@ -270,8 +271,8 @@ int32_t tqReaderSetSubmitReq2(STqReader *pReader, void *msgStr, int32_t msgLen,
// int32_t tqReaderSetDataMsg(STqReader *pReader, const SSubmitReq *pMsg, int64_t ver); // int32_t tqReaderSetDataMsg(STqReader *pReader, const SSubmitReq *pMsg, int64_t ver);
bool tqNextDataBlock2(STqReader *pReader); bool tqNextDataBlock2(STqReader *pReader);
bool tqNextDataBlockFilterOut2(STqReader *pReader, SHashObj *filterOutUids); bool tqNextDataBlockFilterOut2(STqReader *pReader, SHashObj *filterOutUids);
int32_t tqRetrieveDataBlock2(SSDataBlock *pBlock, STqReader *pReader, SSubmitTbData** pSubmitTbDataRet); int32_t tqRetrieveDataBlock2(SSDataBlock *pBlock, STqReader *pReader, SSubmitTbData **pSubmitTbDataRet);
int32_t tqRetrieveTaosxBlock2(STqReader *pReader, SArray *blocks, SArray *schemas, SSubmitTbData** pSubmitTbDataRet); int32_t tqRetrieveTaosxBlock2(STqReader *pReader, SArray *blocks, SArray *schemas, SSubmitTbData **pSubmitTbDataRet);
// int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, STqReader *pReader); // int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, STqReader *pReader);
// int32_t tqRetrieveTaosxBlock(STqReader *pReader, SArray *blocks, SArray *schemas); // int32_t tqRetrieveTaosxBlock(STqReader *pReader, SArray *blocks, SArray *schemas);

View File

@ -1331,7 +1331,11 @@ int32_t metaFilterTableIds(SMeta *pMeta, SMetaFltParam *param, SArray *pUids) {
} }
taosArrayPush(pUids, &tuid); taosArrayPush(pUids, &tuid);
} else { } else {
if (count >= TRY_ERROR_LIMIT) break; if (count >= TRY_ERROR_LIMIT) {
if (param->equal == false) {
break;
}
}
} }
count++; count++;
valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur); valid = param->reverse ? tdbTbcMoveToPrev(pCursor->pCur) : tdbTbcMoveToNext(pCursor->pCur);

View File

@ -383,12 +383,18 @@ static FORCE_INLINE int sifEqual(void *a, void *b, int16_t dtype) {
//__compar_fn_t func = idxGetCompar(dtype); //__compar_fn_t func = idxGetCompar(dtype);
return (int)tDoCompare(func, QUERY_TERM, a, b); return (int)tDoCompare(func, QUERY_TERM, a, b);
} }
static FORCE_INLINE FilterFunc sifGetFilterFunc(EIndexQueryType type, bool *reverse) { static FORCE_INLINE FilterFunc sifGetFilterFunc(EIndexQueryType type, bool *reverse, bool *equal) {
if (type == QUERY_LESS_EQUAL || type == QUERY_LESS_THAN) { if (type == QUERY_LESS_EQUAL || type == QUERY_LESS_THAN) {
*reverse = true; *reverse = true;
} else { } else {
*reverse = false; *reverse = false;
} }
if (type == QUERY_LESS_EQUAL || type == QUERY_GREATER_EQUAL) {
*equal = true;
} else {
*equal = false;
}
if (type == QUERY_LESS_EQUAL) if (type == QUERY_LESS_EQUAL)
return sifLessEqual; return sifLessEqual;
else if (type == QUERY_LESS_THAN) else if (type == QUERY_LESS_THAN)
@ -474,14 +480,15 @@ static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFP
ret = indexJsonSearch(arg->ivtIdx, mtm, output->result); ret = indexJsonSearch(arg->ivtIdx, mtm, output->result);
indexMultiTermQueryDestroy(mtm); indexMultiTermQueryDestroy(mtm);
} else { } else {
bool reverse; bool reverse, equal;
FilterFunc filterFunc = sifGetFilterFunc(qtype, &reverse); FilterFunc filterFunc = sifGetFilterFunc(qtype, &reverse, &equal);
SMetaFltParam param = {.suid = arg->suid, SMetaFltParam param = {.suid = arg->suid,
.cid = left->colId, .cid = left->colId,
.type = left->colValType, .type = left->colValType,
.val = right->condValue, .val = right->condValue,
.reverse = reverse, .reverse = reverse,
.equal = equal,
.filterFunc = filterFunc}; .filterFunc = filterFunc};
char buf[128] = {0}; char buf[128] = {0};