Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
487d45c0
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
487d45c0
编写于
4月 17, 2022
作者:
dengyihao
提交者:
GitHub
4月 17, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #11561 from taosdata/feature/tag_filter_oper
enh: add tag index filter impl
上级
1ca66a41
25837faf
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
246 addition
and
10 deletion
+246
-10
source/libs/executor/src/indexoperator.c
source/libs/executor/src/indexoperator.c
+246
-10
未找到文件。
source/libs/executor/src/indexoperator.c
浏览文件 @
487d45c0
...
@@ -22,38 +22,275 @@ typedef struct SIFCtx {
...
@@ -22,38 +22,275 @@ typedef struct SIFCtx {
SHashObj
*
pRes
;
/* element is SScalarParam */
SHashObj
*
pRes
;
/* element is SScalarParam */
}
SIFCtx
;
}
SIFCtx
;
#define SIF_ERR_RET(c) \
do { \
int32_t _code = c; \
if (_code != TSDB_CODE_SUCCESS) { \
terrno = _code; \
return _code; \
} \
} while (0)
#define SIF_RET(c) \
do { \
int32_t _code = c; \
if (_code != TSDB_CODE_SUCCESS) { \
terrno = _code; \
} \
return _code; \
} while (0)
#define SIF_ERR_JRET(c) \
do { \
code = c; \
if (code != TSDB_CODE_SUCCESS) { \
terrno = code; \
goto _return; \
} \
} while (0)
typedef
struct
SIFParam
{
typedef
struct
SIFParam
{
SArray
*
result
;
SArray
*
result
;
SHashObj
*
pFilter
;
SHashObj
*
pFilter
;
}
SIFParam
;
}
SIFParam
;
typedef
int32_t
(
*
sif_func_t
)(
SNode
*
left
,
SNode
*
rigth
,
SIFParam
*
output
);
// construct tag filter operator later
// construct tag filter operator later
static
void
destroyTagFilterOperatorInfo
(
void
*
param
)
{
static
void
destroyTagFilterOperatorInfo
(
void
*
param
)
{
STagFilterOperatorInfo
*
pInfo
=
(
STagFilterOperatorInfo
*
)
param
;
}
STagFilterOperatorInfo
*
pInfo
=
(
STagFilterOperatorInfo
*
)
param
;
}
static
void
sifFreeParam
(
SIFParam
*
param
)
{
static
void
sifFreeParam
(
SIFParam
*
param
)
{
if
(
param
==
NULL
)
return
;
if
(
param
==
NULL
)
return
;
taosArrayDestroy
(
param
->
result
);
taosArrayDestroy
(
param
->
result
);
}
}
int32_t
sifInitOperParams
(
SIFParam
*
params
,
SOperatorNode
*
node
,
SIFCtx
*
ctx
)
{
static
int32_t
sifGetOperParamNum
(
EOperatorType
ty
)
{
if
(
OP_TYPE_IS_NULL
==
ty
||
OP_TYPE_IS_NOT_NULL
==
ty
||
OP_TYPE_IS_TRUE
==
ty
||
OP_TYPE_IS_NOT_TRUE
==
ty
||
OP_TYPE_IS_FALSE
==
ty
||
OP_TYPE_IS_NOT_FALSE
==
ty
||
OP_TYPE_IS_UNKNOWN
==
ty
||
OP_TYPE_IS_NOT_UNKNOWN
==
ty
||
OP_TYPE_MINUS
==
ty
)
{
return
1
;
}
return
2
;
}
static
int32_t
sifInitParam
(
SNode
*
node
,
SIFParam
*
param
,
SIFCtx
*
ctx
)
{
switch
(
nodeType
(
node
))
{
case
QUERY_NODE_VALUE
:
{
SValueNode
*
vn
=
(
SValueNode
*
)
node
;
break
;
}
case
QUERY_NODE_COLUMN
:
{
SColumnNode
*
cn
=
(
SColumnNode
*
)
node
;
break
;
}
case
QUERY_NODE_NODE_LIST
:
{
SNodeListNode
*
nl
=
(
SNodeListNode
*
)
node
;
if
(
LIST_LENGTH
(
nl
->
pNodeList
)
<=
0
)
{
qError
(
"invalid length for node:%p, length: %d"
,
node
,
LIST_LENGTH
(
nl
->
pNodeList
));
SIF_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
if
(
taosHashPut
(
ctx
->
pRes
,
&
node
,
POINTER_BYTES
,
param
,
sizeof
(
*
param
)))
{
taosHashCleanup
(
param
->
pFilter
);
qError
(
"taosHashPut nodeList failed, size:%d"
,
(
int32_t
)
sizeof
(
*
param
));
SIF_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
break
;
}
case
QUERY_NODE_FUNCTION
:
case
QUERY_NODE_OPERATOR
:
case
QUERY_NODE_LOGIC_CONDITION
:
{
SIFParam
*
res
=
(
SIFParam
*
)
taosHashGet
(
ctx
->
pRes
,
&
node
,
POINTER_BYTES
);
if
(
NULL
==
res
)
{
qError
(
"no result for node, type:%d, node:%p"
,
nodeType
(
node
),
node
);
SIF_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
*
param
=
*
res
;
break
;
}
default:
break
;
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sifInitOperParams
(
SIFParam
**
params
,
SOperatorNode
*
node
,
SIFCtx
*
ctx
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
return
code
;
int32_t
nParam
=
sifGetOperParamNum
(
node
->
opType
);
if
(
NULL
==
node
->
pLeft
||
(
nParam
==
2
&&
NULL
==
node
->
pRight
))
{
qError
(
"invalid operation node, left: %p, rigth: %p"
,
node
->
pLeft
,
node
->
pRight
);
SIF_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
SIFParam
*
paramList
=
taosMemoryCalloc
(
nParam
,
sizeof
(
SIFParam
));
if
(
NULL
==
paramList
)
{
SIF_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
SIF_ERR_JRET
(
sifInitParam
(
node
->
pLeft
,
&
paramList
[
0
],
ctx
));
if
(
nParam
>
1
)
{
SIF_ERR_JRET
(
sifInitParam
(
node
->
pRight
,
&
paramList
[
1
],
ctx
));
}
*
params
=
paramList
;
return
TSDB_CODE_SUCCESS
;
_return:
taosMemoryFree
(
paramList
);
SIF_RET
(
code
);
}
static
int32_t
sifInitParamList
(
SIFParam
**
params
,
SNodeList
*
nodeList
,
SIFCtx
*
ctx
)
{
int32_t
code
=
0
;
SIFParam
*
tParams
=
taosMemoryCalloc
(
nodeList
->
length
,
sizeof
(
SIFParam
));
if
(
tParams
==
NULL
)
{
qError
(
"failed to calloc, nodeList: %p"
,
nodeList
);
SIF_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
SListCell
*
cell
=
nodeList
->
pHead
;
for
(
int32_t
i
=
0
;
i
<
nodeList
->
length
;
i
++
)
{
if
(
NULL
==
cell
||
NULL
==
cell
->
pNode
)
{
SIF_ERR_JRET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
SIF_ERR_JRET
(
sifInitParam
(
cell
->
pNode
,
&
tParams
[
i
],
ctx
));
cell
=
cell
->
pNext
;
}
*
params
=
tParams
;
return
TSDB_CODE_SUCCESS
;
_return:
taosMemoryFree
(
tParams
);
SIF_RET
(
code
);
}
}
static
int32_t
sifExecFunction
(
SFunctionNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
static
int32_t
sifExecFunction
(
SFunctionNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
qError
(
"index-filter not support buildin function"
);
qError
(
"index-filter not support buildin function"
);
return
TSDB_CODE_QRY_INVALID_INPUT
;
}
static
int32_t
sifLessThanFunc
(
SNode
*
left
,
SNode
*
rigth
,
SIFParam
*
output
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sifLessEqualFunc
(
SNode
*
left
,
SNode
*
rigth
,
SIFParam
*
output
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sifGreaterThanFunc
(
SNode
*
left
,
SNode
*
rigth
,
SIFParam
*
output
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sifGreaterEqualFunc
(
SNode
*
left
,
SNode
*
rigth
,
SIFParam
*
output
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
sifEqualFunc
(
SNode
*
left
,
SNode
*
rigth
,
SIFParam
*
output
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sifNotEqualFunc
(
SNode
*
left
,
SNode
*
rigth
,
SIFParam
*
output
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sifInFunc
(
SNode
*
left
,
SNode
*
rigth
,
SIFParam
*
output
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sifNotInFunc
(
SNode
*
left
,
SNode
*
right
,
SIFParam
*
output
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sifLikeFunc
(
SNode
*
left
,
SNode
*
right
,
SIFParam
*
output
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sifNotLikeFunc
(
SNode
*
left
,
SNode
*
right
,
SIFParam
*
output
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sifMatchFunc
(
SNode
*
left
,
SNode
*
rigth
,
SIFParam
*
output
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sifNotMatchFunc
(
SNode
*
left
,
SNode
*
rigth
,
SIFParam
*
output
)
{
// impl later
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sifDefaultFunc
(
SNode
*
left
,
SNode
*
rigth
,
SIFParam
*
output
)
{
// add more except
return
TSDB_CODE_QRY_INVALID_INPUT
;
}
static
sif_func_t
sifGetOperFn
(
int32_t
funcId
)
{
// impl later
switch
(
funcId
)
{
case
OP_TYPE_GREATER_THAN
:
return
sifGreaterThanFunc
;
case
OP_TYPE_GREATER_EQUAL
:
return
sifGreaterEqualFunc
;
case
OP_TYPE_LOWER_THAN
:
return
sifLessThanFunc
;
case
OP_TYPE_LOWER_EQUAL
:
return
sifLessEqualFunc
;
case
OP_TYPE_EQUAL
:
return
sifEqualFunc
;
case
OP_TYPE_NOT_EQUAL
:
return
sifNotEqualFunc
;
case
OP_TYPE_IN
:
return
sifInFunc
;
case
OP_TYPE_NOT_IN
:
return
sifNotInFunc
;
case
OP_TYPE_LIKE
:
return
sifLikeFunc
;
case
OP_TYPE_NOT_LIKE
:
return
sifNotLikeFunc
;
case
OP_TYPE_MATCH
:
return
sifMatchFunc
;
case
OP_TYPE_NMATCH
:
return
sifNotMatchFunc
;
default:
return
sifDefaultFunc
;
}
return
sifDefaultFunc
;
}
static
int32_t
sifExecOper
(
SOperatorNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
static
int32_t
sifExecOper
(
SOperatorNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
int32_t
code
=
0
;
SIFParam
*
params
=
NULL
;
SIFParam
*
params
=
NULL
;
SIF_ERR_RET
(
sifInitOperParams
(
&
params
,
node
,
ctx
));
return
TSDB_CODE_SUCCESS
;
int32_t
nParam
=
sifGetOperParamNum
(
node
->
opType
);
if
(
nParam
<=
1
)
{
SIF_ERR_JRET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
sif_func_t
operFn
=
sifGetOperFn
(
node
->
opType
);
return
operFn
(
node
->
pLeft
,
node
->
pRight
,
output
);
_return:
taosMemoryFree
(
params
);
SIF_RET
(
code
);
}
}
static
int32_t
sifExecLogic
(
SLogicConditionNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
sifExecLogic
(
SLogicConditionNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
if
(
NULL
==
node
->
pParameterList
||
node
->
pParameterList
->
length
<=
0
)
{
qError
(
"invalid logic parameter list, list:%p, paramNum:%d"
,
node
->
pParameterList
,
node
->
pParameterList
?
node
->
pParameterList
->
length
:
0
);
return
TSDB_CODE_QRY_INVALID_INPUT
;
}
int32_t
code
;
SIFParam
*
params
=
NULL
;
SIF_ERR_RET
(
sifInitParamList
(
&
params
,
node
->
pParameterList
,
ctx
));
for
(
int32_t
m
=
0
;
m
<
node
->
pParameterList
->
length
;
m
++
)
{
// add impl later
if
(
node
->
condType
==
LOGIC_COND_TYPE_AND
)
{
taosArrayAddAll
(
output
->
result
,
params
[
m
].
result
);
}
else
if
(
node
->
condType
==
LOGIC_COND_TYPE_OR
)
{
taosArrayAddAll
(
output
->
result
,
params
[
m
].
result
);
}
else
if
(
node
->
condType
==
LOGIC_COND_TYPE_NOT
)
{
taosArrayAddAll
(
output
->
result
,
params
[
m
].
result
);
}
}
_return:
taosMemoryFree
(
params
);
SIF_RET
(
code
);
}
static
EDealRes
sifWalkFunction
(
SNode
*
pNode
,
void
*
context
)
{
static
EDealRes
sifWalkFunction
(
SNode
*
pNode
,
void
*
context
)
{
// impl later
SFunctionNode
*
node
=
(
SFunctionNode
*
)
pNode
;
SFunctionNode
*
node
=
(
SFunctionNode
*
)
pNode
;
SIFParam
output
=
{
0
};
SIFParam
output
=
{
0
};
...
@@ -104,8 +341,7 @@ static EDealRes sifWalkOper(SNode *pNode, void *context) {
...
@@ -104,8 +341,7 @@ static EDealRes sifWalkOper(SNode *pNode, void *context) {
}
}
EDealRes
sifCalcWalker
(
SNode
*
node
,
void
*
context
)
{
EDealRes
sifCalcWalker
(
SNode
*
node
,
void
*
context
)
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
node
)
||
QUERY_NODE_NODE_LIST
==
nodeType
(
node
)
||
if
(
QUERY_NODE_VALUE
==
nodeType
(
node
)
||
QUERY_NODE_NODE_LIST
==
nodeType
(
node
)
||
QUERY_NODE_COLUMN
==
nodeType
(
node
))
{
QUERY_NODE_COLUMN
==
nodeType
(
node
))
{
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
SIFCtx
*
ctx
=
(
SIFCtx
*
)
context
;
SIFCtx
*
ctx
=
(
SIFCtx
*
)
context
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录