提交 cfa925dd 编写于 作者: W wpan

support range filter

上级 8ed28fd8
......@@ -22,6 +22,7 @@ extern "C" {
#include "texpr.h"
#include "hash.h"
#include "tname.h"
#define FILTER_DEFAULT_GROUP_SIZE 4
#define FILTER_DEFAULT_UNIT_SIZE 4
......@@ -91,14 +92,14 @@ typedef struct SFilterColRange {
SFilterRange ra;
} SFilterColRange;
typedef bool (*rangeCompFunc) (const void *, const void *, const void *, const void *, __compar_fn_t);
typedef struct SFilterRangeCompare {
int64_t s;
int64_t e;
rangeCompFunc func;
} SFilterRangeCompare;
typedef bool (*rangeCompFunc) (const void *, const void *, const void *, const void *, __compar_fn_t);
typedef struct SFilterRangeNode {
struct SFilterRangeNode* prev;
struct SFilterRangeNode* next;
......@@ -294,6 +295,7 @@ extern int32_t filterConverNcharColumns(SFilterInfo* pFilterInfo, int32_t rows,
extern int32_t filterFreeNcharColumns(SFilterInfo* pFilterInfo);
extern void filterFreeInfo(SFilterInfo *info);
extern bool filterIsEmptyRes(SFilterInfo *info);
extern bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t numOfCols, int32_t numOfRows);
#ifdef __cplusplus
}
......
......@@ -2402,7 +2402,7 @@ static FORCE_INLINE bool doFilterByBlockStatistics(SQueryRuntimeEnv* pRuntimeEnv
return true;
}
return filterRangeExecute(pQueryAttr->pFilters, pDataStatis, numOfRows);
return filterRangeExecute(pQueryAttr->pFilters, pDataStatis, pQueryAttr->numOfCols, numOfRows);
}
static bool overlapWithTimeWindow(SQueryAttr* pQueryAttr, SDataBlockInfo* pBlockInfo) {
......
......@@ -57,28 +57,28 @@ filter_desc_compare_func gDescCompare [FLD_TYPE_MAX] = {
filterFieldValDescCompare
};
bool filterRangeCompGi (const char *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
bool filterRangeCompGi (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
return cfunc(maxv, minr) >= 0;
}
bool filterRangeCompGe (const char *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
bool filterRangeCompGe (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
return cfunc(maxv, minr) > 0;
}
bool filterRangeCompLi (const char *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
bool filterRangeCompLi (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
return cfunc(minv, maxr) <= 0;
}
bool filterRangeCompLe (const char *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
bool filterRangeCompLe (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
return cfunc(minv, maxr) < 0;
}
bool filterRangeCompii (const char *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
bool filterRangeCompii (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
return cfunc(maxv, minr) >= 0 && cfunc(minv, maxr) <= 0;
}
bool filterRangeCompee (const char *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
bool filterRangeCompee (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
return cfunc(maxv, minr) > 0 && cfunc(minv, maxr) < 0;
}
bool filterRangeCompei (const char *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
bool filterRangeCompei (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
return cfunc(maxv, minr) > 0 && cfunc(minv, maxr) <= 0;
}
bool filterRangeCompie (const char *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
bool filterRangeCompie (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) {
return cfunc(maxv, minr) >= 0 && cfunc(minv, maxr) < 0;
}
......@@ -1823,6 +1823,7 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum
}
SFilterInfo oinfo = *info;
SArray* group = taosArrayInit(FILTER_DEFAULT_GROUP_SIZE, sizeof(SFilterGroup));
SFilterGroupCtx *res = NULL;
SFilterColInfo *colInfo = NULL;
......@@ -1830,6 +1831,10 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum
uint16_t uidx = 0;
memset(info, 0, sizeof(*info));
info->colRangeNum = oinfo.colRangeNum;
info->colRange = oinfo.colRange;
oinfo.colRangeNum = 0;
oinfo.colRange = NULL;
FILTER_SET_FLAG(info->options, FI_OPTION_NEED_UNIQE);
......@@ -1993,14 +1998,14 @@ int32_t filterPreprocess(SFilterInfo *info) {
return TSDB_CODE_SUCCESS;
}
filterRewrite(info, gRes, gResNum);
filterGenerateColRange(info, gRes, gResNum);
filterDumpInfoToString(info, "Final", 1);
filterPostProcessRange(info);
filterRewrite(info, gRes, gResNum);
return TSDB_CODE_SUCCESS;
}
......@@ -2179,7 +2184,7 @@ bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t num
}
// not support pre-filter operation on binary/nchar data type
if (!IS_PREFILTER_TYPE(ctx->type)) {
if (FILTER_NO_MERGE_DATA_TYPE(ctx->type)) {
return true;
}
......@@ -2200,7 +2205,7 @@ bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t num
SDataStatis* pDataBlockst = &pDataStatis[index];
SFilterRangeNode r = ctx->rs;
SFilterRangeNode *r = ctx->rs;
if (ctx->type == TSDB_DATA_TYPE_FLOAT) {
float minv = (float)(*(double *)(&pDataBlockst->min));
......@@ -2215,10 +2220,13 @@ bool filterRangeExecute(SFilterInfo *info, SDataStatis *pDataStatis, int32_t num
while (r) {
ret = r->rc.func(minVal, maxVal, &r->rc.s, &r->rc.e, ctx->pCompareFunc);
CHK_RET(!ret, ret);
if (ret) {
break;
}
r = r->next;
}
CHK_RET(!ret, ret);
}
return ret;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册