Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f54f210e
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看板
提交
f54f210e
编写于
2月 25, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-2895] refactor.
上级
b9867fab
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
13 deletion
+32
-13
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+0
-3
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+32
-10
未找到文件。
src/query/src/qAggMain.c
浏览文件 @
f54f210e
...
...
@@ -3487,9 +3487,6 @@ static void diff_function(SQLFunctionCtx *pCtx) {
int32_t
forwardStep
=
(
isFirstBlock
)
?
notNullElems
-
1
:
notNullElems
;
GET_RES_INFO
(
pCtx
)
->
numOfRes
+=
forwardStep
;
pCtx
->
pOutput
+=
forwardStep
*
pCtx
->
outputBytes
;
pCtx
->
ptsOutputBuf
=
(
char
*
)
pCtx
->
ptsOutputBuf
+
forwardStep
*
TSDB_KEYSIZE
;
}
}
...
...
src/query/src/qExecutor.c
浏览文件 @
f54f210e
...
...
@@ -324,6 +324,13 @@ int64_t getNumOfResult_rv(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx* pCtx, i
return
maxOutput
;
}
static
void
setNumOfRes
(
SQLFunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
for
(
int32_t
j
=
0
;
j
<
numOfOutput
;
++
j
)
{
SResultRowCellInfo
*
pResInfo
=
GET_RES_INFO
(
&
pCtx
[
j
]);
pResInfo
->
numOfRes
=
0
;
}
}
bool
isGroupbyColumn
(
SSqlGroupbyExpr
*
pGroupbyExpr
)
{
if
(
pGroupbyExpr
==
NULL
||
pGroupbyExpr
->
numOfGroupCols
==
0
)
{
return
false
;
...
...
@@ -3559,16 +3566,20 @@ void setDefaultOutputBuf(SQueryRuntimeEnv *pRuntimeEnv, SQLFunctionCtx* pCtx, SR
}
void
updateOutputBuf
(
SArithOperatorInfo
*
pInfo
,
int32_t
numOfInputRows
)
{
SSDataBlock
*
pDataBlock
=
pInfo
->
binfo
.
pRes
;
if
(
pInfo
->
bufCapacity
<
pDataBlock
->
info
.
rows
+
numOfInputRows
)
{
int32_t
newSize
=
pDataBlock
->
info
.
rows
+
numOfInputRows
;
SOptrBasicInfo
*
pBInfo
=
&
pInfo
->
binfo
;
SSDataBlock
*
pDataBlock
=
pBInfo
->
pRes
;
int32_t
newSize
=
pDataBlock
->
info
.
rows
+
numOfInputRows
;
if
(
pInfo
->
bufCapacity
<
newSize
)
{
for
(
int32_t
i
=
0
;
i
<
pDataBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
i
);
char
*
p
=
realloc
(
pColInfo
->
pData
,
newSize
*
pColInfo
->
info
.
bytes
);
if
(
p
!=
NULL
)
{
pColInfo
->
pData
=
p
;
// it starts from the tail of the previously generated results.
pBInfo
->
pCtx
[
i
].
pOutput
=
pColInfo
->
pData
;
pInfo
->
bufCapacity
=
newSize
;
}
else
{
// longjmp
}
...
...
@@ -3577,7 +3588,13 @@ void updateOutputBuf(SArithOperatorInfo* pInfo, int32_t numOfInputRows) {
for
(
int32_t
i
=
0
;
i
<
pDataBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
i
);
pInfo
->
binfo
.
pCtx
[
i
].
pOutput
=
pColInfo
->
pData
+
pColInfo
->
info
.
bytes
*
pDataBlock
->
info
.
rows
;
pBInfo
->
pCtx
[
i
].
pOutput
=
pColInfo
->
pData
+
pColInfo
->
info
.
bytes
*
pDataBlock
->
info
.
rows
;
// re-estabilish output buffer pointer.
int32_t
functionId
=
pBInfo
->
pCtx
[
i
].
functionId
;
if
(
functionId
==
TSDB_FUNC_TOP
||
functionId
==
TSDB_FUNC_BOTTOM
||
functionId
==
TSDB_FUNC_DIFF
)
{
pBInfo
->
pCtx
[
i
].
ptsOutputBuf
=
pBInfo
->
pCtx
[
0
].
pOutput
;
}
}
}
...
...
@@ -3697,8 +3714,6 @@ void prepareRepeatTableScan(SQueryRuntimeEnv* pRuntimeEnv) {
}
}
}
#endif
void
initCtxOutputBuf_rv
(
SQLFunctionCtx
*
pCtx
,
int32_t
size
)
{
...
...
@@ -6383,12 +6398,14 @@ static SSDataBlock* doArithmeticOperation(void* param) {
updateOutputBuf
(
pArithInfo
,
pBlock
->
info
.
rows
);
arithmeticApplyFunctions
(
pRuntimeEnv
,
pArithInfo
->
binfo
.
pCtx
,
pOperator
->
numOfOutput
);
pArithInfo
->
binfo
.
pRes
->
info
.
rows
+=
pBlock
->
info
.
rows
;
pArithInfo
->
binfo
.
pRes
->
info
.
rows
=
getNumOfResult_rv
(
pRuntimeEnv
,
pArithInfo
->
binfo
.
pCtx
,
pOperator
->
numOfOutput
)
;
if
(
pArithInfo
->
binfo
.
pRes
->
info
.
rows
>=
4096
)
{
break
;
}
}
setNumOfRes
(
pArithInfo
->
binfo
.
pCtx
,
pOperator
->
numOfOutput
);
if
(
pArithInfo
->
binfo
.
pRes
->
info
.
rows
>
0
)
{
return
pArithInfo
->
binfo
.
pRes
;
}
else
{
...
...
@@ -6414,8 +6431,12 @@ static SSDataBlock* doLimit(void* param) {
if
(
pInfo
->
total
+
pBlock
->
info
.
rows
>=
pInfo
->
limit
)
{
pBlock
->
info
.
rows
=
(
pInfo
->
limit
-
pInfo
->
total
);
pInfo
->
total
=
pInfo
->
limit
;
setQueryStatus
(
pOperator
->
pRuntimeEnv
->
pQuery
,
QUERY_COMPLETED
);
pOperator
->
completed
=
true
;
}
else
{
pInfo
->
total
+=
pBlock
->
info
.
rows
;
}
return
pBlock
;
...
...
@@ -6753,8 +6774,9 @@ SOperatorInfo* createStableAggOperatorInfo(SQueryRuntimeEnv* pRuntimeEnv, SOpera
SOperatorInfo
*
createArithOperatorInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
upstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
)
{
SArithOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SArithOperatorInfo
));
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
);
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
bufCapacity
=
4096
;
pInfo
->
binfo
.
pRes
=
createOutputBuf
(
pExpr
,
numOfOutput
);
pInfo
->
binfo
.
pCtx
=
createSQLFunctionCtx
(
pRuntimeEnv
,
pExpr
,
numOfOutput
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
,
TSDB_DATA_TYPE_INT
);
setDefaultOutputBuf
(
pRuntimeEnv
,
pInfo
->
binfo
.
pCtx
,
&
pInfo
->
binfo
.
resultRowInfo
,
pInfo
->
binfo
.
pRes
,
pInfo
->
binfo
.
rowCellInfoOffset
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录