Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3f62f8a3
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3f62f8a3
编写于
4月 13, 2022
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sync home and office
上级
6f5f6896
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
570 addition
and
312 deletion
+570
-312
source/libs/function/inc/tudf.h
source/libs/function/inc/tudf.h
+58
-46
source/libs/function/inc/tudfInt.h
source/libs/function/inc/tudfInt.h
+25
-17
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+486
-248
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+1
-1
未找到文件。
source/libs/function/inc/tudf.h
浏览文件 @
3f62f8a3
...
...
@@ -22,6 +22,8 @@ extern "C" {
//======================================================================================
//begin API to taosd and qworker
#define TSDB_UDF_MAX_COLUMNS 4
enum
{
UDFC_CODE_STOPPING
=
-
1
,
UDFC_CODE_RESTARTING
=
-
2
,
...
...
@@ -49,15 +51,22 @@ enum {
TSDB_UDF_SCRIPT_LUA
=
1
,
};
typedef
struct
SUdfColumnMeta
{
int16_t
type
;
int32_t
bytes
;
// <0 var length, others fixed length bytes
uint8_t
precision
;
uint8_t
scale
;
}
SUdfColumnMeta
;
typedef
struct
SUdfInfo
{
char
*
udfName
;
// function name
int32_t
udfType
;
// scalar function or aggregate function
int8_t
scriptType
;
char
*
path
;
int8_t
resType
;
// result type
int16_t
resBytes
;
// result byte
int32_t
bufSize
;
//interbuf size
// known info between qworker and udf
// struct SUdfColumnMeta resultMeta;
//
int32_t bufSize; //interbuf size
}
SUdfInfo
;
...
...
@@ -72,33 +81,50 @@ typedef void *UdfHandle;
int32_t
setupUdf
(
SUdfInfo
*
udf
,
UdfHandle
*
handle
);
enum
{
TSDB_UDF_STEP_NORMAL
=
0
,
TSDB_UDF_STEP_MERGE
,
TSDb_UDF_STEP_FINALIZE
,
TSDB_UDF_STEP_MAX_NUM
};
/**
* call udf
* @param handle udf handle
* @param step
* @param state
* @param stateSize
* @param input
* @param newstate
* @param newStateSize
* @param output
* @return error code
*/
typedef
struct
SUdfColumnData
{
int32_t
numOfRows
;
bool
varLengthColumn
;
union
{
int32_t
nullBitmapLen
;
char
*
nullBitmap
;
int32_t
dataLen
;
char
*
data
;
};
union
{
int32_t
varOffsetsLen
;
char
*
varOffsets
;
int32_t
payloadLen
;
char
*
payload
;
};
}
SUdfColumnData
;
typedef
struct
SUdfColumn
{
SUdfColumnMeta
colMeta
;
SUdfColumnData
colData
;
}
SUdfColumn
;
//TODO: must change the following after metadata flow and data flow between qworker and udfd is well defined
typedef
struct
SUdfDataBlock
{
char
*
data
;
int32_t
size
;
int32_t
numOfRows
;
int32_t
numOfCols
;
SUdfColumn
udfCols
[
TSDB_UDF_MAX_COLUMNS
];
}
SUdfDataBlock
;
int32_t
callUdf
(
UdfHandle
handle
,
int8_t
step
,
char
*
state
,
int32_t
stateSize
,
SUdfDataBlock
input
,
char
**
newstate
,
int32_t
*
newStateSize
,
SUdfDataBlock
*
output
);
typedef
struct
SUdfInterBuf
{
int32_t
bufLen
;
char
*
buf
;
}
SUdfInterBuf
;
// input: block, initFirst
// output: interbuf
int32_t
callUdfAggProcess
(
SUdfDataBlock
block
,
SUdfInterBuf
*
interBuf
,
bool
initFirst
);
// input: interBuf
// output: resultData
int32_t
callUdfAggFinalize
(
SUdfInterBuf
interBuf
,
SUdfColumnData
*
resultData
);
// input: block
// output: resultData
int32_t
callUdfScalaProcess
(
SUdfDataBlock
block
,
SUdfColumnData
*
resultData
);
/**
* tearn down udf
...
...
@@ -109,30 +135,16 @@ int32_t teardownUdf(UdfHandle handle);
// end API to taosd and qworker
//=============================================================================================================================
// TODO: Must change
// begin API to UDF writer.
// script
//typedef int32_t (*scriptInitFunc)(void* pCtx);
//typedef void (*scriptNormalFunc)(void* pCtx, char* data, int16_t iType, int16_t iBytes, int32_t numOfRows,
// int64_t* ptList, int64_t key, char* dataOutput, char* tsOutput, int32_t* numOfOutput,
// int16_t oType, int16_t oBytes);
//typedef void (*scriptFinalizeFunc)(void* pCtx, int64_t key, char* dataOutput, int32_t* numOfOutput);
//typedef void (*scriptMergeFunc)(void* pCtx, char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput);
//typedef void (*scriptDestroyFunc)(void* pCtx);
// dynamic lib
// dynamic lib init and destroy
typedef
int32_t
(
*
TUdfInitFunc
)();
typedef
void
(
*
TUdfDestroyFunc
)();
typedef
void
(
*
TUdfFunc
)(
int8_t
step
,
char
*
state
,
int32_t
stateSize
,
SUdfDataBlock
input
,
char
**
newstate
,
int32_t
*
newStateSize
,
SUdfDataBlock
*
output
);
//typedef void (*udfMergeFunc)(char *data, int32_t numOfRows, char *dataOutput, int32_t* numOfOutput);
//typedef void (*udfFinalizeFunc)(char* state, int32_t stateSize, SUdfDataBlock *output);
typedef
int32_t
(
*
TUdfDestroyFunc
)();
typedef
int32_t
(
*
TUdfScalarProcFunc
)(
SUdfDataBlock
block
,
SUdfColumnData
*
resultData
);
typedef
int32_t
(
*
TUdfAggInit
)(
SUdfInterBuf
*
buf
);
typedef
int32_t
(
*
TUdfAggProcess
)(
SUdfDataBlock
block
,
SUdfInterBuf
*
interBuf
);
typedef
int32_t
(
*
TUdfAggFinalize
)(
SUdfInterBuf
buf
,
SUdfColumnData
*
resultData
);
// end API to UDF writer
//=======================================================================================================================
...
...
source/libs/function/inc/tudfInt.h
浏览文件 @
3f62f8a3
...
...
@@ -30,6 +30,12 @@ enum {
};
enum
{
TSDB_UDF_CALL_AGG_PROC
=
0
,
TSDb_UDF_CALL_AGG_FIN
,
TSDB_UDF_CALL_SCALA_PROC
,
};
typedef
struct
SUdfSetupRequest
{
char
udfName
[
16
];
//
int8_t
scriptType
;
// 0:c, 1: lua, 2:js
...
...
@@ -42,24 +48,18 @@ typedef struct SUdfSetupResponse {
int64_t
udfHandle
;
}
SUdfSetupResponse
;
typedef
struct
SUdfCallRequest
{
int64_t
udfHandle
;
int8_t
step
;
int8_t
callType
;
int32_t
inputBytes
;
char
*
input
;
int32_t
stateBytes
;
char
*
state
;
SUdfDataBlock
block
;
SUdfInterBuf
interBuf
;
bool
initFirst
;
}
SUdfCallRequest
;
typedef
struct
SUdfCallResponse
{
int32_t
outputBytes
;
char
*
output
;
int32_t
newStateBytes
;
char
*
newState
;
SUdfColumnData
resultData
;
SUdfInterBuf
interBuf
;
}
SUdfCallResponse
;
...
...
@@ -76,7 +76,11 @@ typedef struct SUdfRequest {
int64_t
seqNum
;
int8_t
type
;
void
*
subReq
;
union
{
SUdfSetupRequest
setup
;
SUdfCallRequest
call
;
SUdfTeardownRequest
teardown
;
};
}
SUdfRequest
;
typedef
struct
SUdfResponse
{
...
...
@@ -85,13 +89,17 @@ typedef struct SUdfResponse {
int8_t
type
;
int32_t
code
;
void
*
subRsp
;
union
{
SUdfSetupResponse
setupRsp
;
SUdfCallResponse
callRsp
;
SUdfTeardownResponse
teardownRsp
;
};
}
SUdfResponse
;
int32_t
decodeRequest
(
char
*
buf
,
int32_t
bufLen
,
SUdfRequest
**
pRequest
);
int32_t
encodeResponse
(
char
**
buf
,
int32_t
*
bufLen
,
SUdfResponse
*
response
);
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
decodeResponse
(
char
*
buf
,
int32_t
bufLen
,
SUdfResponse
*
pResponse
);
int32_t
encodeResponse
(
char
**
buf
,
int32_t
*
bufLen
,
SUdfResponse
*
response
);
#ifdef __cplusplus
}
...
...
source/libs/function/src/tudf.c
浏览文件 @
3f62f8a3
此差异已折叠。
点击以展开。
source/libs/function/src/udfd.c
浏览文件 @
3f62f8a3
...
...
@@ -44,7 +44,7 @@ typedef struct SUdf {
int8_t
type
;
uv_lib_t
lib
;
TUdfFunc
normalFunc
;
TUdf
ScalarProc
Func
normalFunc
;
}
SUdf
;
//TODO: low priority: change name onxxx to xxxCb, and udfc or udfd as prefix
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录