Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ac7f492c
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看板
提交
ac7f492c
编写于
4月 26, 2022
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
udaf has result processing
上级
38f43f5a
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
28 addition
and
20 deletion
+28
-20
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+28
-20
未找到文件。
source/libs/function/src/tudf.c
浏览文件 @
ac7f492c
...
...
@@ -1253,8 +1253,8 @@ bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo* pResult
if
(
callUdfAggInit
(
handle
,
&
buf
)
!=
0
)
{
return
false
;
}
memcpy
(
udfRes
->
interResBuf
,
buf
.
buf
,
buf
.
bufLen
);
udfRes
->
interResNum
=
buf
.
numOfResult
;
memcpy
(
udfRes
->
interResBuf
,
buf
.
buf
,
buf
.
bufLen
);
return
true
;
}
...
...
@@ -1263,14 +1263,14 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) {
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
int32_t
numOfCols
=
pInput
->
numOfInputCols
;
char
*
udfRes
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SUdfAggRes
*
udfRes
=
(
SUdfAggRes
*
)
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SUdfUvSession
*
session
=
udfRes
->
session
;
udfRes
->
finalResBuf
=
(
char
*
)
udfRes
+
sizeof
(
SUdfAggRes
);
udfRes
->
interResBuf
=
(
char
*
)
udfRes
+
sizeof
(
SUdfAggRes
)
+
session
->
outputLen
;
int32_t
start
=
pInput
->
startRowIndex
;
int32_t
numOfRows
=
pInput
->
numOfRows
;
UdfcFuncHandle
handle
=
(
UdfcFuncHandle
)(
*
(
int64_t
*
)(
udfRes
));
SUdfUvSession
*
session
=
(
SUdfUvSession
*
)
handle
;
SSDataBlock
tempBlock
=
{
0
};
tempBlock
.
info
.
numOfCols
=
numOfCols
;
...
...
@@ -1290,16 +1290,20 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) {
SSDataBlock
*
inputBlock
=
blockDataExtractBlock
(
&
tempBlock
,
start
,
numOfRows
);
SUdfInterBuf
state
=
{.
buf
=
udfRes
+
sizeof
(
int64_t
)
+
session
->
outputLen
,
SUdfInterBuf
state
=
{.
buf
=
udfRes
->
interResBuf
,
.
bufLen
=
session
->
bufSize
,
.
numOfResult
=
GET_RES_INFO
(
pCtx
)
->
numOfRes
};
.
numOfResult
=
udfRes
->
interResNum
};
SUdfInterBuf
newState
=
{
0
};
callUdfAggProcess
(
handle
,
inputBlock
,
&
state
,
&
newState
);
callUdfAggProcess
(
session
,
inputBlock
,
&
state
,
&
newState
);
memcpy
(
state
.
buf
,
newState
.
buf
,
newState
.
bufLen
);
udfRes
->
interResNum
=
newState
.
numOfResult
;
memcpy
(
udfRes
->
interResBuf
,
newState
.
buf
,
newState
.
bufLen
);
if
(
newState
.
numOfResult
==
1
||
state
.
numOfResult
==
1
)
{
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
1
;
}
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
(
newState
.
numOfResult
==
1
?
1
:
0
);
blockDataDestroy
(
inputBlock
);
taosArrayDestroy
(
tempBlock
.
pDataBlock
);
...
...
@@ -1309,22 +1313,26 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) {
}
int32_t
udfAggFinalize
(
struct
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
char
*
udfRes
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SUdfAggRes
*
udfRes
=
(
SUdfAggRes
*
)
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
SUdfUvSession
*
session
=
udfRes
->
session
;
udfRes
->
finalResBuf
=
(
char
*
)
udfRes
+
sizeof
(
SUdfAggRes
);
udfRes
->
interResBuf
=
(
char
*
)
udfRes
+
sizeof
(
SUdfAggRes
)
+
session
->
outputLen
;
UdfcFuncHandle
handle
=
(
UdfcFuncHandle
)(
*
(
int64_t
*
)(
udfRes
));
SUdfUvSession
*
session
=
(
SUdfUvSession
*
)
handle
;
SUdfInterBuf
resultBuf
=
{.
buf
=
udfRes
+
sizeof
(
int64_t
),
.
bufLen
=
session
->
outputLen
};
SUdfInterBuf
state
=
{.
buf
=
udfRes
+
sizeof
(
int64_t
)
+
session
->
outputLen
,
SUdfInterBuf
resultBuf
=
{.
buf
=
udfRes
->
finalResBuf
,
.
bufLen
=
session
->
outputLen
,
.
numOfResult
=
udfRes
->
finalResNum
};
SUdfInterBuf
state
=
{.
buf
=
udfRes
->
interResBuf
,
.
bufLen
=
session
->
bufSize
,
.
numOfResult
=
GET_RES_INFO
(
pCtx
)
->
numOfRes
};
callUdfAggFinalize
(
handle
,
&
state
,
&
resultBuf
);
.
numOfResult
=
udfRes
->
interResNum
};
callUdfAggFinalize
(
session
,
&
state
,
&
resultBuf
);
teardownUdf
(
session
);
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
(
resultBuf
.
numOfResult
==
1
?
1
:
0
);
if
(
resultBuf
.
numOfResult
==
1
)
{
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
1
;
}
functionFinalize
(
pCtx
,
pBlock
);
teardownUdf
(
handle
);
return
0
;
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录