diff --git a/src/query/src/qExecutor.c b/src/query/src/qExecutor.c index 7bf5f9bba7..b00f003adb 100644 --- a/src/query/src/qExecutor.c +++ b/src/query/src/qExecutor.c @@ -2287,7 +2287,7 @@ static bool doFilterByBlockStatistics(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis if (pDataStatis == NULL || pQueryAttr->numOfFilterCols == 0) { return true; } - + bool ret = true; for (int32_t k = 0; k < pQueryAttr->numOfFilterCols; ++k) { SSingleColumnFilterInfo *pFilterInfo = &pQueryAttr->pFilterInfo[k]; @@ -2324,26 +2324,34 @@ static bool doFilterByBlockStatistics(SQueryRuntimeEnv* pRuntimeEnv, SDataStatis } SDataStatis* pDataBlockst = &pDataStatis[index]; - + if (pFilterInfo->info.type == TSDB_DATA_TYPE_FLOAT) { float minval = (float)(*(double *)(&pDataBlockst->min)); float maxval = (float)(*(double *)(&pDataBlockst->max)); - + for (int32_t i = 0; i < pFilterInfo->numOfFilters; ++i) { - if (pFilterInfo->pFilters[i].fp(&pFilterInfo->pFilters[i], (char *)&minval, (char *)&maxval, TSDB_DATA_TYPE_FLOAT)) { - return true; + if (pFilterInfo->pFilters[i].filterInfo.lowerRelOptr == TSDB_RELATION_IN) { + continue; + } + ret &= pFilterInfo->pFilters[i].fp(&pFilterInfo->pFilters[i], (char *)&minval, (char *)&maxval, TSDB_DATA_TYPE_FLOAT); + if (ret == false) { + return false; } } } else { for (int32_t i = 0; i < pFilterInfo->numOfFilters; ++i) { - if (pFilterInfo->pFilters[i].fp(&pFilterInfo->pFilters[i], (char *)&pDataBlockst->min, (char *)&pDataBlockst->max, pFilterInfo->info.type)) { - return true; + if (pFilterInfo->pFilters[i].filterInfo.lowerRelOptr == TSDB_RELATION_IN) { + continue; + } + ret &= pFilterInfo->pFilters[i].fp(&pFilterInfo->pFilters[i], (char *)&pDataBlockst->min, (char *)&pDataBlockst->max, pFilterInfo->info.type); + if (ret == false) { + return false; } } } } - return false; + return ret; } static bool overlapWithTimeWindow(SQueryAttr* pQueryAttr, SDataBlockInfo* pBlockInfo) { diff --git a/src/util/src/thashutil.c b/src/util/src/thashutil.c index 15519143ba..ffe167977b 100644 --- a/src/util/src/thashutil.c +++ b/src/util/src/thashutil.c @@ -90,11 +90,12 @@ uint32_t taosFloatHash(const char *key, uint32_t UNUSED_PARAM(len)) { if (FLT_EQUAL(f, 0.0)) { return 0; } - if (f >= (FLT_MAX/BASE - DLT) || f <= (FLT_MIN/BASE - DLT)){ - return 0x7fc00000; + if (fabs(f) < FLT_MAX/BASE - DLT) { + int t = (int)(round(BASE * (f + DLT))); + return (uint32_t)t; + } else { + return 0x7fc00000; } - int t = (int)round(BASE * (f + DLT)); - return (uint32_t)t; } uint32_t taosDoubleHash(const char *key, uint32_t UNUSED_PARAM(len)) { double f = GET_DOUBLE_VAL(key); @@ -105,11 +106,12 @@ uint32_t taosDoubleHash(const char *key, uint32_t UNUSED_PARAM(len)) { if (FLT_EQUAL(f, 0.0)) { return 0; } - if (f >= (DBL_MAX/BASE - DLT) || f <= (DBL_MIN/BASE - DLT)){ - return 0x7fc00000; - } - int t = (int)(round(BASE * (f + DLT))); - return (uint32_t)t; + if (fabs(f) < DBL_MAX/BASE - DLT) { + int t = (int)(round(BASE * (f + DLT))); + return (uint32_t)t; + } else { + return 0x7fc00000; + } } uint32_t taosIntHash_64(const char *key, uint32_t UNUSED_PARAM(len)) { uint64_t val = *(uint64_t *)key;