Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
7da509b2
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
7da509b2
编写于
5月 23, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: index filter interface
上级
0122fd12
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
30 addition
and
53 deletion
+30
-53
include/libs/index/index.h
include/libs/index/index.h
+8
-0
source/libs/executor/inc/indexoperator.h
source/libs/executor/inc/indexoperator.h
+0
-35
source/libs/index/CMakeLists.txt
source/libs/index/CMakeLists.txt
+3
-0
source/libs/index/src/indexFilter.c
source/libs/index/src/indexFilter.c
+19
-18
source/libs/index/test/index_executor_tests.cpp
source/libs/index/test/index_executor_tests.cpp
+0
-0
未找到文件。
include/libs/index/index.h
浏览文件 @
7da509b2
...
...
@@ -16,9 +16,11 @@
#ifndef _TD_INDEX_H_
#define _TD_INDEX_H_
#include "nodes.h"
#include "os.h"
#include "taoserror.h"
#include "tarray.h"
#include "tglobal.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -189,6 +191,12 @@ void indexTermDestroy(SIndexTerm* p);
*/
void
indexInit
();
/* index filter */
typedef
enum
{
SFLT_NOT_INDEX
,
SFLT_COARSE_INDEX
,
SFLT_ACCURATE_INDEX
}
SIdxFltStatus
;
SIdxFltStatus
idxGetFltStatus
(
SNode
*
pFilterNode
);
int32_t
doFilterTag
(
const
SNode
*
pFilterNode
,
SArray
*
result
);
/*
* destory index env
*
...
...
source/libs/executor/inc/indexoperator.h
已删除
100644 → 0
浏览文件 @
0122fd12
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _INDEX_OPERATOR_H
#define _INDEX_OPERATOR_H
#ifdef __cplusplus
extern
"C"
{
#endif
#include "nodes.h"
#include "tglobal.h"
typedef
enum
{
SFLT_NOT_INDEX
,
SFLT_COARSE_INDEX
,
SFLT_ACCURATE_INDEX
}
SIdxFltStatus
;
SIdxFltStatus
idxGetFltStatus
(
SNode
*
pFilterNode
);
// construct tag filter operator later
int32_t
doFilterTag
(
const
SNode
*
pFilterNode
,
SArray
*
result
);
#ifdef __cplusplus
}
#endif
#endif
/*INDEX_OPERATOR_*/
source/libs/index/CMakeLists.txt
浏览文件 @
7da509b2
...
...
@@ -12,6 +12,9 @@ target_link_libraries(
PUBLIC os
PUBLIC util
PUBLIC common
PUBLIC nodes
PUBLIC scalar
PUBLIC function
)
if
(
${
BUILD_WITH_LUCENE
}
)
...
...
source/libs/
executor/src/indexoperato
r.c
→
source/libs/
index/src/indexFilte
r.c
浏览文件 @
7da509b2
...
...
@@ -13,10 +13,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "indexoperator.h"
#include "executorimpl.h"
#include "index.h"
#include "indexInt.h"
#include "nodes.h"
#include "querynodes.h"
#include "scalar.h"
#include "tdatablock.h"
// clang-format off
...
...
@@ -69,9 +70,9 @@ typedef int32_t (*sif_func_t)(SIFParam *left, SIFParam *rigth, SIFParam *output)
static
sif_func_t
sifNullFunc
=
NULL
;
// typedef struct SIFWalkParm
// construct tag filter operator later
static
void
destroyTagFilterOperatorInfo
(
void
*
param
)
{
STagFilterOperatorInfo
*
pInfo
=
(
STagFilterOperatorInfo
*
)
param
;
}
//
static void destroyTagFilterOperatorInfo(void *param) {
//
STagFilterOperatorInfo *pInfo = (STagFilterOperatorInfo *)param;
//
}
static
void
sifFreeParam
(
SIFParam
*
param
)
{
if
(
param
==
NULL
)
return
;
...
...
@@ -178,13 +179,13 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
case
QUERY_NODE_NODE_LIST
:
{
SNodeListNode
*
nl
=
(
SNodeListNode
*
)
node
;
if
(
LIST_LENGTH
(
nl
->
pNodeList
)
<=
0
)
{
q
Error
(
"invalid length for node:%p, length: %d"
,
node
,
LIST_LENGTH
(
nl
->
pNodeList
));
index
Error
(
"invalid length for node:%p, length: %d"
,
node
,
LIST_LENGTH
(
nl
->
pNodeList
));
SIF_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
SIF_ERR_RET
(
scalarGenerateSetFromList
((
void
**
)
&
param
->
pFilter
,
node
,
nl
->
dataType
.
type
));
if
(
taosHashPut
(
ctx
->
pRes
,
&
node
,
POINTER_BYTES
,
param
,
sizeof
(
*
param
)))
{
taosHashCleanup
(
param
->
pFilter
);
q
Error
(
"taosHashPut nodeList failed, size:%d"
,
(
int32_t
)
sizeof
(
*
param
));
index
Error
(
"taosHashPut nodeList failed, size:%d"
,
(
int32_t
)
sizeof
(
*
param
));
SIF_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
break
;
...
...
@@ -194,7 +195,7 @@ static int32_t sifInitParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
case
QUERY_NODE_LOGIC_CONDITION
:
{
SIFParam
*
res
=
(
SIFParam
*
)
taosHashGet
(
ctx
->
pRes
,
&
node
,
POINTER_BYTES
);
if
(
NULL
==
res
)
{
q
Error
(
"no result for node, type:%d, node:%p"
,
nodeType
(
node
),
node
);
index
Error
(
"no result for node, type:%d, node:%p"
,
nodeType
(
node
),
node
);
SIF_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
*
param
=
*
res
;
...
...
@@ -210,7 +211,7 @@ static int32_t sifInitOperParams(SIFParam **params, SOperatorNode *node, SIFCtx
int32_t
code
=
0
;
int32_t
nParam
=
sifGetOperParamNum
(
node
->
opType
);
if
(
NULL
==
node
->
pLeft
||
(
nParam
==
2
&&
NULL
==
node
->
pRight
))
{
q
Error
(
"invalid operation node, left: %p, rigth: %p"
,
node
->
pLeft
,
node
->
pRight
);
index
Error
(
"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
));
...
...
@@ -232,7 +233,7 @@ static int32_t sifInitParamList(SIFParam **params, SNodeList *nodeList, SIFCtx *
int32_t
code
=
0
;
SIFParam
*
tParams
=
taosMemoryCalloc
(
nodeList
->
length
,
sizeof
(
SIFParam
));
if
(
tParams
==
NULL
)
{
q
Error
(
"failed to calloc, nodeList: %p"
,
nodeList
);
index
Error
(
"failed to calloc, nodeList: %p"
,
nodeList
);
SIF_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
...
...
@@ -252,7 +253,7 @@ _return:
SIF_RET
(
code
);
}
static
int32_t
sifExecFunction
(
SFunctionNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
q
Error
(
"index-filter not support buildin function"
);
index
Error
(
"index-filter not support buildin function"
);
return
TSDB_CODE_QRY_INVALID_INPUT
;
}
static
int32_t
sifDoIndex
(
SIFParam
*
left
,
SIFParam
*
right
,
int8_t
operType
,
SIFParam
*
output
)
{
...
...
@@ -390,8 +391,8 @@ _return:
static
int32_t
sifExecLogic
(
SLogicConditionNode
*
node
,
SIFCtx
*
ctx
,
SIFParam
*
output
)
{
if
(
NULL
==
node
->
pParameterList
||
node
->
pParameterList
->
length
<=
0
)
{
q
Error
(
"invalid logic parameter list, list:%p, paramNum:%d"
,
node
->
pParameterList
,
node
->
pParameterList
?
node
->
pParameterList
->
length
:
0
);
index
Error
(
"invalid logic parameter list, list:%p, paramNum:%d"
,
node
->
pParameterList
,
node
->
pParameterList
?
node
->
pParameterList
->
length
:
0
);
return
TSDB_CODE_QRY_INVALID_INPUT
;
}
...
...
@@ -485,7 +486,7 @@ EDealRes sifCalcWalker(SNode *node, void *context) {
return
sifWalkOper
(
node
,
ctx
);
}
q
Error
(
"invalid node type for index filter calculating, type:%d"
,
nodeType
(
node
));
index
Error
(
"invalid node type for index filter calculating, type:%d"
,
nodeType
(
node
));
ctx
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
DEAL_RES_ERROR
;
}
...
...
@@ -509,7 +510,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
SIFCtx
ctx
=
{.
code
=
0
,
.
noExec
=
false
};
ctx
.
pRes
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
if
(
NULL
==
ctx
.
pRes
)
{
q
Error
(
"index-filter failed to taosHashInit"
);
index
Error
(
"index-filter failed to taosHashInit"
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
...
...
@@ -519,7 +520,7 @@ static int32_t sifCalculate(SNode *pNode, SIFParam *pDst) {
if
(
pDst
)
{
SIFParam
*
res
=
(
SIFParam
*
)
taosHashGet
(
ctx
.
pRes
,
(
void
*
)
&
pNode
,
POINTER_BYTES
);
if
(
res
==
NULL
)
{
q
Error
(
"no valid res in hash, node:(%p), type(%d)"
,
(
void
*
)
&
pNode
,
nodeType
(
pNode
));
index
Error
(
"no valid res in hash, node:(%p), type(%d)"
,
(
void
*
)
&
pNode
,
nodeType
(
pNode
));
SIF_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
taosArrayAddAll
(
pDst
->
result
,
res
->
result
);
...
...
@@ -539,7 +540,7 @@ static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status) {
SIFCtx
ctx
=
{.
code
=
0
,
.
noExec
=
true
};
ctx
.
pRes
=
taosHashInit
(
4
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
if
(
NULL
==
ctx
.
pRes
)
{
q
Error
(
"index-filter failed to taosHashInit"
);
index
Error
(
"index-filter failed to taosHashInit"
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
...
...
@@ -549,7 +550,7 @@ static int32_t sifGetFltHint(SNode *pNode, SIdxFltStatus *status) {
SIFParam
*
res
=
(
SIFParam
*
)
taosHashGet
(
ctx
.
pRes
,
(
void
*
)
&
pNode
,
POINTER_BYTES
);
if
(
res
==
NULL
)
{
q
Error
(
"no valid res in hash, node:(%p), type(%d)"
,
(
void
*
)
&
pNode
,
nodeType
(
pNode
));
index
Error
(
"no valid res in hash, node:(%p), type(%d)"
,
(
void
*
)
&
pNode
,
nodeType
(
pNode
));
SIF_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
*
status
=
res
->
status
;
...
...
source/libs/
executor
/test/index_executor_tests.cpp
→
source/libs/
index
/test/index_executor_tests.cpp
浏览文件 @
7da509b2
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录