Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
74887574
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看板
提交
74887574
编写于
3月 04, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-2895] refactor.
上级
61cb98c9
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
237 addition
and
275 deletion
+237
-275
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+28
-15
src/query/inc/qFill.h
src/query/inc/qFill.h
+0
-2
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+181
-244
src/query/src/qFill.c
src/query/src/qFill.c
+25
-11
src/query/src/qUtil.c
src/query/src/qUtil.c
+3
-3
未找到文件。
src/query/inc/qExecutor.h
浏览文件 @
74887574
...
...
@@ -37,9 +37,6 @@ typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int
#define Q_STATUS_EQUAL(p, s) (((p) & (s)) != 0u)
#define QUERY_IS_ASC_QUERY(q) (GET_FORWARD_DIRECTION_FACTOR((q)->order.order) == QUERY_ASC_FORWARD_STEP)
#define SET_STABLE_QUERY_OVER(_q) ((_q)->tableIndex = (int32_t)((_q)->tableqinfoGroupInfo.numOfTables))
#define IS_STASBLE_QUERY_OVER(_q) ((_q)->tableIndex >= (int32_t)((_q)->tableqinfoGroupInfo.numOfTables))
#define GET_TABLEGROUP(q, _index) ((SArray*) taosArrayGetP((q)->tableqinfoGroupInfo.pGroupList, (_index)))
#define GET_NUM_OF_RESULTS(_r) (((_r)->outputBuf) == NULL? 0:((_r)->outputBuf)->info.rows)
...
...
@@ -241,10 +238,10 @@ struct SOperatorInfo;
typedef
struct
SQueryRuntimeEnv
{
jmp_buf
env
;
SQuery
*
pQuery
;
uint32_t
status
;
// query status
uint32_t
status
;
// query status
void
*
qinfo
;
uint16_t
scanFlag
;
// denotes reversed scan of data or not
SFillInfo
*
pFillInfo
;
// todo move to operatorInfo
//
SFillInfo* pFillInfo; // todo move to operatorInfo
void
*
pQueryHandle
;
int32_t
prevGroupId
;
// previous executed group id
...
...
@@ -262,14 +259,13 @@ typedef struct SQueryRuntimeEnv {
SArithmeticSupport
*
sasArray
;
SSDataBlock
*
outputBuf
;
int32_t
tableIndex
;
//TODO remove it
STableGroupInfo
tableqinfoGroupInfo
;
// this is a group array list, including SArray<STableQueryInfo*> structure
struct
SOperatorInfo
*
proot
;
struct
SOperatorInfo
*
pTableScanner
;
// table scan operator
SGroupResInfo
groupResInfo
;
int64_t
currentOffset
;
// dynamic offset value
SRspResultInfo
resultInfo
;
SRspResultInfo
resultInfo
;
}
SQueryRuntimeEnv
;
enum
{
...
...
@@ -278,15 +274,31 @@ enum {
OP_EXEC_DONE
=
3
,
};
enum
OPERATOR_TYPE_E
{
OP_TableScan
=
1
,
OP_DataBlocksOptScan
=
2
,
OP_TableSeqScan
=
3
,
OP_TagScan
=
4
,
OP_Aggregate
=
5
,
OP_Arithmetic
=
6
,
OP_Groupby
=
7
,
OP_Limit
=
8
,
OP_Offset
=
9
,
OP_TimeInterval
=
10
,
OP_Fill
=
11
,
OP_MultiTableAggregate
=
12
,
OP_MultiTableTimeInterval
=
13
,
};
typedef
struct
SOperatorInfo
{
uint8_t
operatorType
;
bool
blockingOptr
;
// block operator or not
uint8_t
status
;
// denote if current operator is completed
int32_t
numOfOutput
;
// number of columns of the current operator results
char
*
name
;
// name, used to show the query execution plan
void
*
info
;
// extension attribution
SExprInfo
*
pExpr
;
SQueryRuntimeEnv
*
pRuntimeEnv
;
uint8_t
operatorType
;
bool
blockingOptr
;
// block operator or not
uint8_t
status
;
// denote if current operator is completed
int32_t
numOfOutput
;
// number of columns of the current operator results
char
*
name
;
// name, used to show the query execution plan
void
*
info
;
// extension attribution
SExprInfo
*
pExpr
;
SQueryRuntimeEnv
*
pRuntimeEnv
;
struct
SOperatorInfo
*
upstream
;
__operator_fn_t
exec
;
...
...
@@ -402,6 +414,7 @@ typedef struct SOffsetOperatorInfo {
}
SOffsetOperatorInfo
;
typedef
struct
SFillOperatorInfo
{
SFillInfo
*
pFillInfo
;
SSDataBlock
*
pRes
;
int64_t
totalInputRows
;
}
SFillOperatorInfo
;
...
...
src/query/inc/qFill.h
浏览文件 @
74887574
...
...
@@ -80,8 +80,6 @@ void* taosDestroyFillInfo(SFillInfo *pFillInfo);
void
taosFillSetStartInfo
(
SFillInfo
*
pFillInfo
,
int32_t
numOfRows
,
TSKEY
endKey
);
void
taosFillSetDataBlockFromFilePage
(
SFillInfo
*
pFillInfo
,
const
tFilePage
**
pInput
);
void
taosFillSetInputDataBlock
(
SFillInfo
*
pFillInfo
,
const
struct
SSDataBlock
*
pInput
);
void
taosFillCopyInputDataFromOneFilePage
(
SFillInfo
*
pFillInfo
,
const
tFilePage
*
pInput
);
...
...
src/query/src/qExecutor.c
浏览文件 @
74887574
此差异已折叠。
点击以展开。
src/query/src/qFill.c
浏览文件 @
74887574
...
...
@@ -357,6 +357,10 @@ SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int3
pFillInfo
->
rowSize
=
setTagColumnInfo
(
pFillInfo
,
pFillInfo
->
numOfCols
,
pFillInfo
->
alloc
);
assert
(
pFillInfo
->
rowSize
>
0
);
for
(
int32_t
i
=
0
;
i
<
pFillInfo
->
numOfCols
;
++
i
)
{
pFillInfo
->
pData
[
i
]
=
malloc
(
pFillInfo
->
pFillCol
[
i
].
col
.
bytes
*
pFillInfo
->
alloc
);
}
return
pFillInfo
;
}
...
...
@@ -381,6 +385,10 @@ void* taosDestroyFillInfo(SFillInfo* pFillInfo) {
tfree
(
pFillInfo
->
pTags
[
i
].
tagVal
);
}
for
(
int32_t
i
=
0
;
i
<
pFillInfo
->
numOfCols
;
++
i
)
{
tfree
(
pFillInfo
->
pData
[
i
]);
}
tfree
(
pFillInfo
->
pTags
);
tfree
(
pFillInfo
->
pData
);
...
...
@@ -415,17 +423,19 @@ void taosFillSetStartInfo(SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey)
}
}
// copy the data into source data buffer
void
taosFillSetDataBlockFromFilePage
(
SFillInfo
*
pFillInfo
,
const
tFilePage
**
pInput
)
{
for
(
int32_t
i
=
0
;
i
<
pFillInfo
->
numOfCols
;
++
i
)
{
memcpy
(
pFillInfo
->
pData
[
i
],
pInput
[
i
]
->
data
,
pFillInfo
->
numOfRows
*
pFillInfo
->
pFillCol
[
i
].
col
.
bytes
);
}
}
void
taosFillSetInputDataBlock
(
SFillInfo
*
pFillInfo
,
const
SSDataBlock
*
pInput
)
{
for
(
int32_t
i
=
0
;
i
<
pFillInfo
->
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColData
=
taosArrayGet
(
pInput
->
pDataBlock
,
i
);
pFillInfo
->
pData
[
i
]
=
pColData
->
pData
;
// pFillInfo->pData[i] = pColData->pData;
if
(
pInput
->
info
.
rows
>
pFillInfo
->
alloc
)
{
char
*
t
=
realloc
(
pFillInfo
->
pData
[
i
],
pColData
->
info
.
bytes
*
pInput
->
info
.
rows
);
assert
(
t
!=
NULL
);
pFillInfo
->
pData
[
i
]
=
t
;
pFillInfo
->
alloc
=
pInput
->
info
.
rows
;
}
memcpy
(
pFillInfo
->
pData
[
i
],
pColData
->
pData
,
pColData
->
info
.
bytes
*
pInput
->
info
.
rows
);
}
}
...
...
@@ -436,11 +446,15 @@ void taosFillCopyInputDataFromOneFilePage(SFillInfo* pFillInfo, const tFilePage*
SFillColInfo
*
pCol
=
&
pFillInfo
->
pFillCol
[
i
];
const
char
*
data
=
pInput
->
data
+
pCol
->
col
.
offset
*
pInput
->
num
;
if
(
pFillInfo
->
pData
[
i
]
==
NULL
)
{
pFillInfo
->
pData
[
i
]
=
calloc
(
4096
,
pCol
->
col
.
bytes
);
if
(
pInput
->
num
>
pFillInfo
->
alloc
)
{
char
*
t
=
realloc
(
pFillInfo
->
pData
[
i
],
pCol
->
col
.
bytes
*
pInput
->
num
);
assert
(
t
!=
NULL
);
pFillInfo
->
pData
[
i
]
=
t
;
pFillInfo
->
alloc
=
pInput
->
num
;
}
memcpy
(
pFillInfo
->
pData
[
i
],
data
,
pCol
->
col
.
bytes
*
pInput
->
num
);
// pFillInfo->pData[i] = (char*) data;
if
(
TSDB_COL_IS_TAG
(
pCol
->
flag
))
{
// copy the tag value to tag value buffer
SFillTagColInfo
*
pTag
=
&
pFillInfo
->
pTags
[
pCol
->
tagIndex
];
...
...
src/query/src/qUtil.c
浏览文件 @
74887574
...
...
@@ -572,9 +572,9 @@ int32_t mergeIntoGroupResult(SGroupResInfo* pGroupResInfo, SQueryRuntimeEnv* pRu
incNextGroup
(
pGroupResInfo
);
}
if
(
pGroupResInfo
->
currentGroup
>=
pGroupResInfo
->
totalGroup
&&
!
hasRemainData
(
pGroupResInfo
))
{
SET_STABLE_QUERY_OVER
(
pRuntimeEnv
);
}
//
if (pGroupResInfo->currentGroup >= pGroupResInfo->totalGroup && !hasRemainData(pGroupResInfo)) {
//
SET_STABLE_QUERY_OVER(pRuntimeEnv);
//
}
int64_t
elapsedTime
=
taosGetTimestampUs
()
-
st
;
qDebug
(
"QInfo:%p merge res data into group, index:%d, total group:%d, elapsed time:%"
PRId64
"us"
,
pRuntimeEnv
->
qinfo
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录