Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4817f54a
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看板
提交
4817f54a
编写于
4月 16, 2022
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SSDataBlock and SUdfInterBuf message passing between taosd/udfd
上级
3526c0d4
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
246 addition
and
485 deletion
+246
-485
source/libs/function/inc/tudf.h
source/libs/function/inc/tudf.h
+7
-3
source/libs/function/inc/tudfInt.h
source/libs/function/inc/tudfInt.h
+12
-9
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+211
-461
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+16
-12
未找到文件。
source/libs/function/inc/tudf.h
浏览文件 @
4817f54a
...
...
@@ -20,6 +20,7 @@
#include <stdint.h>
#include <stdbool.h>
#include "tmsg.h"
#include "tcommon.h"
#ifdef __cplusplus
extern
"C"
{
...
...
@@ -97,18 +98,20 @@ typedef struct SUdfInterBuf {
char
*
buf
;
}
SUdfInterBuf
;
//TODO: translate these calls to callUdf
int32_t
callUdfAggInit
(
SUdfInterBuf
*
interBuf
);
// input: block, initFirst
// output: interbuf
int32_t
callUdfAggProcess
(
S
UdfDataBlock
*
block
,
SUdfInterBuf
*
interBuf
,
bool
initFirst
);
int32_t
callUdfAggProcess
(
S
SDataBlock
*
block
,
SUdfInterBuf
*
interBuf
);
// input: interBuf
// output: resultData
int32_t
callUdfAggFinalize
(
SUdfInterBuf
*
interBuf
,
S
UdfColumnData
*
resultData
);
int32_t
callUdfAggFinalize
(
SUdfInterBuf
*
interBuf
,
S
SDataBlock
*
resultData
);
// input: interbuf1, interbuf2
// output: resultBuf
int32_t
callUdfAggMerge
(
SUdfInterBuf
*
interBuf1
,
SUdfInterBuf
*
interBuf2
,
SUdfInterBuf
*
resultBuf
);
// input: block
// output: resultData
int32_t
callUdfScalaProcess
(
S
UdfDataBlock
*
block
,
SUdfColumnData
*
resultData
);
int32_t
callUdfScalaProcess
(
S
SDataBlock
*
block
,
SSDataBlock
*
resultData
);
/**
* tearn down udf
...
...
@@ -125,6 +128,7 @@ int32_t teardownUdf(UdfHandle handle);
typedef
int32_t
(
*
TUdfSetupFunc
)();
typedef
int32_t
(
*
TUdfTeardownFunc
)();
//TODO: add API to check function arguments type, number etc.
//TODO: another way to manage memory is provide api for UDF to add data to SUdfColumnData and UDF framework will allocate memory.
// then UDF framework will free the memory
//typedef int32_t addFixedLengthColumnData(SColumnData *columnData, int rowIndex, bool isNull, int32_t colBytes, char* data);
...
...
source/libs/function/inc/tudfInt.h
浏览文件 @
4817f54a
...
...
@@ -30,9 +30,10 @@ enum {
};
enum
{
TSDB_UDF_CALL_AGG_PROC
=
0
,
TSDB_UDF_CALL_AGG_INIT
=
0
,
TSDB_UDF_CALL_AGG_PROC
,
TSDB_UDF_CALL_AGG_MERGE
,
TSD
b
_UDF_CALL_AGG_FIN
,
TSD
B
_UDF_CALL_AGG_FIN
,
TSDB_UDF_CALL_SCALA_PROC
,
};
...
...
@@ -49,14 +50,15 @@ typedef struct SUdfCallRequest {
int64_t
udfHandle
;
int8_t
callType
;
S
Udf
DataBlock
block
;
S
S
DataBlock
block
;
SUdfInterBuf
interBuf
;
SUdfInterBuf
interBuf2
;
bool
initFirst
;
int8_t
initFirst
;
}
SUdfCallRequest
;
typedef
struct
SUdfCallResponse
{
SUdfColumnData
resultData
;
int8_t
callType
;
SSDataBlock
resultData
;
SUdfInterBuf
interBuf
;
}
SUdfCallResponse
;
...
...
@@ -94,10 +96,11 @@ typedef struct SUdfResponse {
};
}
SUdfResponse
;
int32_t
decodeRequest
(
char
*
buf
,
int32_t
bufLen
,
SUdfRequest
*
pRequest
);
int32_t
encodeRequest
(
char
**
buf
,
int32_t
*
bufLen
,
SUdfRequest
*
request
);
int32_t
decodeResponse
(
char
*
buf
,
int32_t
bufLen
,
SUdfResponse
*
pResponse
);
int32_t
encodeResponse
(
char
**
buf
,
int32_t
*
bufLen
,
SUdfResponse
*
response
);
int32_t
encodeUdfRequest
(
void
**
buf
,
const
SUdfRequest
*
request
);
void
*
decodeUdfRequest
(
const
void
*
buf
,
SUdfRequest
*
request
);
int32_t
encodeUdfResponse
(
void
**
buf
,
const
SUdfResponse
*
response
);
void
*
decodeUdfResponse
(
const
void
*
buf
,
SUdfResponse
*
response
);
void
freeUdfColumnData
(
SUdfColumnData
*
data
);
void
freeUdfColumn
(
SUdfColumn
*
col
);
...
...
source/libs/function/src/tudf.c
浏览文件 @
4817f54a
此差异已折叠。
点击以展开。
source/libs/function/src/udfd.c
浏览文件 @
4817f54a
...
...
@@ -62,7 +62,7 @@ typedef struct SUdfHandle {
void
udfdProcessRequest
(
uv_work_t
*
req
)
{
SUvUdfWork
*
uvUdf
=
(
SUvUdfWork
*
)
(
req
->
data
);
SUdfRequest
request
=
{
0
};
decode
Request
(
uvUdf
->
input
.
base
,
uvUdf
->
input
.
len
,
&
request
);
decode
UdfRequest
(
uvUdf
->
input
.
base
,
&
request
);
switch
(
request
.
type
)
{
case
UDF_TASK_SETUP
:
{
...
...
@@ -94,9 +94,10 @@ void udfdProcessRequest(uv_work_t *req) {
rsp
.
type
=
request
.
type
;
rsp
.
code
=
0
;
rsp
.
setupRsp
.
udfHandle
=
(
int64_t
)
(
handle
);
char
*
buf
;
int32_t
len
;
encodeResponse
(
&
buf
,
&
len
,
&
rsp
);
int32_t
len
=
encodeUdfResponse
(
NULL
,
&
rsp
);
rsp
.
msgLen
=
len
;
void
*
buf
=
taosMemoryMalloc
(
len
);
encodeUdfResponse
(
&
buf
,
&
rsp
);
uvUdf
->
output
=
uv_buf_init
(
buf
,
len
);
...
...
@@ -110,7 +111,8 @@ void udfdProcessRequest(uv_work_t *req) {
SUdfHandle
*
handle
=
(
SUdfHandle
*
)
(
call
->
udfHandle
);
SUdf
*
udf
=
handle
->
udf
;
SUdfDataBlock
input
=
call
->
block
;
SUdfDataBlock
input
=
{
0
};
//TODO: convertSDataBlockToUdfDataBlock(call->block, &input);
SUdfColumnData
output
;
//TODO: call different functions according to call type, for now just calar
if
(
call
->
callType
==
TSDB_UDF_CALL_SCALA_PROC
)
{
...
...
@@ -124,12 +126,13 @@ void udfdProcessRequest(uv_work_t *req) {
rsp
->
type
=
request
.
type
;
rsp
->
code
=
0
;
SUdfCallResponse
*
subRsp
=
&
rsp
->
callRsp
;
subRsp
->
resultData
=
output
;
//TODO: convertSUdfColumnDataToSSDataBlock(output, &subRsp->resultData)
;
}
char
*
buf
;
int32_t
len
;
encodeResponse
(
&
buf
,
&
len
,
rsp
);
int32_t
len
=
encodeUdfResponse
(
NULL
,
rsp
);
rsp
->
msgLen
=
len
;
void
*
buf
=
taosMemoryMalloc
(
len
);
encodeUdfResponse
(
&
buf
,
rsp
);
uvUdf
->
output
=
uv_buf_init
(
buf
,
len
);
//TODO: free
...
...
@@ -158,9 +161,10 @@ void udfdProcessRequest(uv_work_t *req) {
rsp
->
type
=
request
.
type
;
rsp
->
code
=
0
;
SUdfTeardownResponse
*
subRsp
=
&
response
.
teardownRsp
;
char
*
buf
;
int32_t
len
;
encodeResponse
(
&
buf
,
&
len
,
rsp
);
int32_t
len
=
encodeUdfResponse
(
NULL
,
rsp
);
void
*
buf
=
taosMemoryMalloc
(
len
);
rsp
->
msgLen
=
len
;
encodeUdfResponse
(
&
buf
,
rsp
);
uvUdf
->
output
=
uv_buf_init
(
buf
,
len
);
taosMemoryFree
(
uvUdf
->
input
.
base
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录