Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
17fe1d44
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看板
未验证
提交
17fe1d44
编写于
5月 12, 2022
作者:
dengyihao
提交者:
GitHub
5月 12, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #12353 from taosdata/enh/updateIndexF
enh(index): update index filter UT
上级
4738f72c
f3bf12c7
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
270 addition
and
9 deletion
+270
-9
source/libs/executor/inc/indexoperator.h
source/libs/executor/inc/indexoperator.h
+14
-2
source/libs/executor/src/indexoperator.c
source/libs/executor/src/indexoperator.c
+3
-3
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+0
-4
source/libs/executor/test/indexexcutorTests.cpp
source/libs/executor/test/indexexcutorTests.cpp
+253
-0
未找到文件。
source/libs/executor/inc/indexoperator.h
浏览文件 @
17fe1d44
...
...
@@ -13,11 +13,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "filter.h"
#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
*
resutl
);
int32_t
doFilterTag
(
const
SNode
*
pFilterNode
,
SArray
*
result
);
#ifdef __cplusplus
}
#endif
#endif
/*INDEX_OPERATOR_*/
source/libs/executor/src/indexoperator.c
浏览文件 @
17fe1d44
...
...
@@ -583,7 +583,7 @@ int32_t doFilterTag(const SNode *pFilterNode, SArray *result) {
SFilterInfo
*
filter
=
NULL
;
// todo move to the initialization function
SIF_ERR_RET
(
filterInitFromNode
((
SNode
*
)
pFilterNode
,
&
filter
,
0
));
//
SIF_ERR_RET(filterInitFromNode((SNode *)pFilterNode, &filter, 0));
SIFParam
param
=
{
0
};
SIF_ERR_RET
(
sifCalculate
((
SNode
*
)
pFilterNode
,
&
param
));
...
...
@@ -598,9 +598,9 @@ SIdxFltStatus idxGetFltStatus(SNode *pFilterNode) {
if
(
pFilterNode
==
NULL
)
{
return
SFLT_NOT_INDEX
;
}
SFilterInfo
*
filter
=
NULL
;
//
SFilterInfo *filter = NULL;
// todo move to the initialization function
SIF_ERR_RET
(
filterInitFromNode
((
SNode
*
)
pFilterNode
,
&
filter
,
0
));
//
SIF_ERR_RET(filterInitFromNode((SNode *)pFilterNode, &filter, 0));
SIF_ERR_RET
(
sifGetFltHint
((
SNode
*
)
pFilterNode
,
&
st
));
return
st
;
...
...
source/libs/executor/test/executorTests.cpp
浏览文件 @
17fe1d44
...
...
@@ -948,10 +948,6 @@ TEST(testCase, build_executor_tree_Test) {
code
=
qCreateExecTask
(
&
handle
,
2
,
1
,
plan
,
(
void
**
)
&
pTaskInfo
,
&
sinkHandle
,
OPTR_EXEC_MODEL_BATCH
);
ASSERT_EQ
(
code
,
0
);
}
TEST
(
testCase
,
index_plan_test
)
{
// add later
EXPECT_EQ
(
0
,
0
);
}
#if 0
TEST(testCase, inMem_sort_Test) {
...
...
source/libs/executor/test/indexexcutorTests.cpp
0 → 100644
浏览文件 @
17fe1d44
/*
* 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/>.
*/
#include <gtest/gtest.h>
#include <tglobal.h>
#include <tsort.h>
#include <iostream>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wwrite-strings"
#pragma GCC diagnostic ignored "-Wunused-function"
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wsign-compare"
#include "executor.h"
#include "executorimpl.h"
#include "indexoperator.h"
#include "os.h"
#include "stub.h"
#include "taos.h"
#include "tcompare.h"
#include "tdatablock.h"
#include "tdef.h"
#include "trpc.h"
#include "tvariant.h"
namespace
{
SColumnInfo
createColumnInfo
(
int32_t
colId
,
int32_t
type
,
int32_t
bytes
)
{
SColumnInfo
info
=
{
0
};
info
.
colId
=
colId
;
info
.
type
=
type
;
info
.
bytes
=
bytes
;
return
info
;
}
int64_t
sifLeftV
=
21
,
sifRightV
=
10
;
double
sifLeftVd
=
21.0
,
sifRightVd
=
10.0
;
void
sifFreeDataBlock
(
void
*
block
)
{
blockDataDestroy
(
*
(
SSDataBlock
**
)
block
);
}
void
sifInitLogFile
()
{
const
char
*
defaultLogFileNamePrefix
=
"taoslog"
;
const
int32_t
maxLogFileNum
=
10
;
tsAsyncLog
=
0
;
qDebugFlag
=
159
;
strcpy
(
tsLogDir
,
"/tmp/sif"
);
taosRemoveDir
(
tsLogDir
);
taosMkDir
(
tsLogDir
);
if
(
taosInitLog
(
defaultLogFileNamePrefix
,
maxLogFileNum
)
<
0
)
{
printf
(
"failed to open log file in directory:%s
\n
"
,
tsLogDir
);
}
}
void
sifAppendReservedSlot
(
SArray
*
pBlockList
,
int16_t
*
dataBlockId
,
int16_t
*
slotId
,
bool
newBlock
,
int32_t
rows
,
SColumnInfo
*
colInfo
)
{
if
(
newBlock
)
{
SSDataBlock
*
res
=
(
SSDataBlock
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
res
->
info
.
numOfCols
=
1
;
res
->
info
.
rows
=
rows
;
res
->
pDataBlock
=
taosArrayInit
(
1
,
sizeof
(
SColumnInfoData
));
SColumnInfoData
idata
=
{
0
};
idata
.
info
=
*
colInfo
;
taosArrayPush
(
res
->
pDataBlock
,
&
idata
);
taosArrayPush
(
pBlockList
,
&
res
);
blockDataEnsureCapacity
(
res
,
rows
);
*
dataBlockId
=
taosArrayGetSize
(
pBlockList
)
-
1
;
res
->
info
.
blockId
=
*
dataBlockId
;
*
slotId
=
0
;
}
else
{
SSDataBlock
*
res
=
*
(
SSDataBlock
**
)
taosArrayGetLast
(
pBlockList
);
res
->
info
.
numOfCols
++
;
SColumnInfoData
idata
=
{
0
};
idata
.
info
=
*
colInfo
;
colInfoDataEnsureCapacity
(
&
idata
,
0
,
rows
);
taosArrayPush
(
res
->
pDataBlock
,
&
idata
);
*
dataBlockId
=
taosArrayGetSize
(
pBlockList
)
-
1
;
*
slotId
=
taosArrayGetSize
(
res
->
pDataBlock
)
-
1
;
}
}
void
sifMakeValueNode
(
SNode
**
pNode
,
int32_t
dataType
,
void
*
value
)
{
SNode
*
node
=
(
SNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
SValueNode
*
vnode
=
(
SValueNode
*
)
node
;
vnode
->
node
.
resType
.
type
=
dataType
;
if
(
IS_VAR_DATA_TYPE
(
dataType
))
{
vnode
->
datum
.
p
=
(
char
*
)
taosMemoryMalloc
(
varDataTLen
(
value
));
varDataCopy
(
vnode
->
datum
.
p
,
value
);
vnode
->
node
.
resType
.
bytes
=
varDataTLen
(
value
);
}
else
{
vnode
->
node
.
resType
.
bytes
=
tDataTypes
[
dataType
].
bytes
;
assignVal
((
char
*
)
nodesGetValueFromNode
(
vnode
),
(
const
char
*
)
value
,
0
,
dataType
);
}
*
pNode
=
(
SNode
*
)
vnode
;
}
void
sifMakeColumnNode
(
SNode
**
pNode
,
const
char
*
db
,
const
char
*
colName
,
EColumnType
colType
,
uint8_t
colValType
)
{
SNode
*
node
=
(
SNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
SColumnNode
*
rnode
=
(
SColumnNode
*
)
node
;
memcpy
(
rnode
->
dbName
,
db
,
strlen
(
db
));
memcpy
(
rnode
->
colName
,
colName
,
strlen
(
colName
));
rnode
->
colType
=
colType
;
rnode
->
node
.
resType
.
type
=
colValType
;
*
pNode
=
(
SNode
*
)
rnode
;
}
void
sifMakeOpNode
(
SNode
**
pNode
,
EOperatorType
opType
,
int32_t
resType
,
SNode
*
pLeft
,
SNode
*
pRight
)
{
SNode
*
node
=
(
SNode
*
)
nodesMakeNode
(
QUERY_NODE_OPERATOR
);
SOperatorNode
*
onode
=
(
SOperatorNode
*
)
node
;
onode
->
node
.
resType
.
type
=
resType
;
onode
->
node
.
resType
.
bytes
=
tDataTypes
[
resType
].
bytes
;
onode
->
opType
=
opType
;
onode
->
pLeft
=
pLeft
;
onode
->
pRight
=
pRight
;
*
pNode
=
(
SNode
*
)
onode
;
}
void
sifMakeListNode
(
SNode
**
pNode
,
SNodeList
*
list
,
int32_t
resType
)
{
SNode
*
node
=
(
SNode
*
)
nodesMakeNode
(
QUERY_NODE_NODE_LIST
);
SNodeListNode
*
lnode
=
(
SNodeListNode
*
)
node
;
lnode
->
dataType
.
type
=
resType
;
lnode
->
pNodeList
=
list
;
*
pNode
=
(
SNode
*
)
lnode
;
}
void
sifMakeLogicNode
(
SNode
**
pNode
,
ELogicConditionType
opType
,
SNode
**
nodeList
,
int32_t
nodeNum
)
{
SNode
*
node
=
(
SNode
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_CONDITION
);
SLogicConditionNode
*
onode
=
(
SLogicConditionNode
*
)
node
;
onode
->
condType
=
opType
;
onode
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_BOOL
;
onode
->
node
.
resType
.
bytes
=
sizeof
(
bool
);
onode
->
pParameterList
=
nodesMakeList
();
for
(
int32_t
i
=
0
;
i
<
nodeNum
;
++
i
)
{
nodesListAppend
(
onode
->
pParameterList
,
nodeList
[
i
]);
}
*
pNode
=
(
SNode
*
)
onode
;
}
void
sifMakeTargetNode
(
SNode
**
pNode
,
int16_t
dataBlockId
,
int16_t
slotId
,
SNode
*
snode
)
{
SNode
*
node
=
(
SNode
*
)
nodesMakeNode
(
QUERY_NODE_TARGET
);
STargetNode
*
onode
=
(
STargetNode
*
)
node
;
onode
->
pExpr
=
snode
;
onode
->
dataBlockId
=
dataBlockId
;
onode
->
slotId
=
slotId
;
*
pNode
=
(
SNode
*
)
onode
;
}
}
// namespace
#if 1
TEST
(
testCase
,
index_filter
)
{
{
SNode
*
pLeft
=
NULL
,
*
pRight
=
NULL
,
*
opNode
=
NULL
,
*
res
=
NULL
;
sifMakeColumnNode
(
&
pLeft
,
"test"
,
"col"
,
COLUMN_TYPE_TAG
,
TSDB_DATA_TYPE_INT
);
sifMakeValueNode
(
&
pRight
,
TSDB_DATA_TYPE_INT
,
&
sifRightV
);
sifMakeOpNode
(
&
opNode
,
OP_TYPE_LOWER_THAN
,
TSDB_DATA_TYPE_INT
,
pLeft
,
pRight
);
SArray
*
result
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
doFilterTag
(
opNode
,
result
);
EXPECT_EQ
(
1
,
taosArrayGetSize
(
result
));
taosArrayDestroy
(
result
);
nodesDestroyNode
(
res
);
}
{
SNode
*
pLeft
=
NULL
,
*
pRight
=
NULL
,
*
opNode
=
NULL
,
*
res
=
NULL
;
sifMakeColumnNode
(
&
pLeft
,
"test"
,
"col"
,
COLUMN_TYPE_TAG
,
TSDB_DATA_TYPE_INT
);
sifMakeValueNode
(
&
pRight
,
TSDB_DATA_TYPE_INT
,
&
sifRightV
);
sifMakeOpNode
(
&
opNode
,
OP_TYPE_LOWER_THAN
,
TSDB_DATA_TYPE_DOUBLE
,
pLeft
,
pRight
);
SArray
*
result
=
taosArrayInit
(
4
,
sizeof
(
uint64_t
));
doFilterTag
(
opNode
,
result
);
EXPECT_EQ
(
1
,
taosArrayGetSize
(
result
));
taosArrayDestroy
(
result
);
nodesDestroyNode
(
res
);
}
}
TEST
(
testCase
,
index_filter_varify
)
{
{
SNode
*
pLeft
=
NULL
,
*
pRight
=
NULL
,
*
opNode
=
NULL
,
*
res
=
NULL
;
sifMakeColumnNode
(
&
pLeft
,
"test"
,
"col"
,
COLUMN_TYPE_TAG
,
TSDB_DATA_TYPE_INT
);
sifMakeValueNode
(
&
pRight
,
TSDB_DATA_TYPE_INT
,
&
sifRightV
);
sifMakeOpNode
(
&
opNode
,
OP_TYPE_LOWER_THAN
,
TSDB_DATA_TYPE_INT
,
pLeft
,
pRight
);
nodesDestroyNode
(
res
);
SIdxFltStatus
st
=
idxGetFltStatus
(
opNode
);
EXPECT_EQ
(
st
,
SFLT_ACCURATE_INDEX
);
}
{
SNode
*
pLeft
=
NULL
,
*
pRight
=
NULL
,
*
opNode
=
NULL
,
*
res
=
NULL
;
sifMakeColumnNode
(
&
pLeft
,
"test"
,
"col"
,
COLUMN_TYPE_TAG
,
TSDB_DATA_TYPE_INT
);
sifMakeValueNode
(
&
pRight
,
TSDB_DATA_TYPE_INT
,
&
sifRightV
);
sifMakeOpNode
(
&
opNode
,
OP_TYPE_LOWER_THAN
,
TSDB_DATA_TYPE_DOUBLE
,
pLeft
,
pRight
);
SIdxFltStatus
st
=
idxGetFltStatus
(
opNode
);
EXPECT_EQ
(
st
,
SFLT_COARSE_INDEX
);
nodesDestroyNode
(
res
);
}
{
SNode
*
pLeft
=
NULL
,
*
pRight
=
NULL
,
*
opNode
=
NULL
,
*
res
=
NULL
;
sifMakeColumnNode
(
&
pLeft
,
"test"
,
"col"
,
COLUMN_TYPE_TAG
,
TSDB_DATA_TYPE_INT
);
sifMakeValueNode
(
&
pRight
,
TSDB_DATA_TYPE_INT
,
&
sifRightV
);
sifMakeOpNode
(
&
opNode
,
OP_TYPE_GREATER_THAN
,
TSDB_DATA_TYPE_INT
,
pLeft
,
pRight
);
nodesDestroyNode
(
res
);
SIdxFltStatus
st
=
idxGetFltStatus
(
opNode
);
EXPECT_EQ
(
st
,
SFLT_ACCURATE_INDEX
);
}
{
SNode
*
pLeft
=
NULL
,
*
pRight
=
NULL
,
*
opNode
=
NULL
,
*
res
=
NULL
;
sifMakeColumnNode
(
&
pLeft
,
"test"
,
"col"
,
COLUMN_TYPE_TAG
,
TSDB_DATA_TYPE_INT
);
sifMakeValueNode
(
&
pRight
,
TSDB_DATA_TYPE_INT
,
&
sifRightV
);
sifMakeOpNode
(
&
opNode
,
OP_TYPE_GREATER_THAN
,
TSDB_DATA_TYPE_DOUBLE
,
pLeft
,
pRight
);
SIdxFltStatus
st
=
idxGetFltStatus
(
opNode
);
EXPECT_EQ
(
st
,
SFLT_COARSE_INDEX
);
nodesDestroyNode
(
res
);
}
}
#endif
#pragma GCC diagnostic pop
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录