Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e9e6b1fa
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看板
提交
e9e6b1fa
编写于
4月 26, 2022
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sync home office
上级
22a97ca0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
99 addition
and
3 deletion
+99
-3
include/libs/function/tudf.h
include/libs/function/tudf.h
+1
-1
source/libs/function/CMakeLists.txt
source/libs/function/CMakeLists.txt
+15
-0
source/libs/function/test/udf1.c
source/libs/function/test/udf1.c
+2
-2
source/libs/function/test/udf2.c
source/libs/function/test/udf2.c
+81
-0
未找到文件。
include/libs/function/tudf.h
浏览文件 @
e9e6b1fa
...
...
@@ -137,8 +137,8 @@ typedef int32_t (*TUdfTeardownFunc)();
//typedef int32_t addVariableLengthColumnData(SColumnData *columnData, int rowIndex, bool isNull, int32_t dataLen, char * data);
typedef
int32_t
(
*
TUdfFreeUdfColumnFunc
)(
SUdfColumn
*
column
);
typedef
int32_t
(
*
TUdfScalarProcFunc
)(
SUdfDataBlock
block
,
SUdfColumn
*
resultCol
);
typedef
int32_t
(
*
TUdfAggInitFunc
)(
SUdfInterBuf
*
buf
);
typedef
int32_t
(
*
TUdfAggProcessFunc
)(
SUdfDataBlock
block
,
SUdfInterBuf
*
interBuf
);
typedef
int32_t
(
*
TUdfAggFinalizeFunc
)(
SUdfInterBuf
buf
,
SUdfInterBuf
*
resultData
);
...
...
source/libs/function/CMakeLists.txt
浏览文件 @
e9e6b1fa
...
...
@@ -51,6 +51,21 @@ target_link_libraries(
udf1 PUBLIC os
)
add_library
(
udf2 MODULE test/udf2.c
)
target_include_directories
(
udf1
PUBLIC
"
${
TD_SOURCE_DIR
}
/include/libs/function"
"
${
TD_SOURCE_DIR
}
/include/util"
"
${
TD_SOURCE_DIR
}
/include/common"
"
${
TD_SOURCE_DIR
}
/include/client"
"
${
TD_SOURCE_DIR
}
/include/os"
PRIVATE
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/inc"
)
target_link_libraries
(
udf2 PUBLIC os
)
#SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/bin)
add_executable
(
udfd src/udfd.c
)
target_include_directories
(
...
...
source/libs/function/test/udf1.c
浏览文件 @
e9e6b1fa
...
...
@@ -9,11 +9,11 @@
#undef free
#define free free
int32_t
udf1_
setup
()
{
int32_t
udf1_
init
()
{
return
0
;
}
int32_t
udf1_
teardown
()
{
int32_t
udf1_
destroy
()
{
return
0
;
}
...
...
source/libs/function/test/udf2.c
0 → 100644
浏览文件 @
e9e6b1fa
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "tudf.h"
#undef malloc
#define malloc malloc
#undef free
#define free free
int32_t
udf2_init
()
{
return
0
;
}
int32_t
udf2_destroy
()
{
return
0
;
}
int32_t
udf2_start
(
SUdfInterBuf
*
buf
)
{
}
int32_t
udf2
(
SUdfDataBlock
block
,
SUdfInterBuf
*
interBuf
)
{
}
int32_t
udf2_finish
(
SUdfInterBuf
buf
,
SUdfInterBuf
*
resultData
)
{
}
int32_t
udf2
(
SUdfDataBlock
block
,
SUdfColumn
*
resultCol
)
{
SUdfColumnData
*
resultData
=
&
resultCol
->
colData
;
resultData
->
numOfRows
=
block
.
numOfRows
;
SUdfColumnData
*
srcData
=
&
block
.
udfCols
[
0
]
->
colData
;
resultData
->
varLengthColumn
=
srcData
->
varLengthColumn
;
if
(
resultData
->
varLengthColumn
)
{
resultData
->
varLenCol
.
varOffsetsLen
=
srcData
->
varLenCol
.
varOffsetsLen
;
resultData
->
varLenCol
.
varOffsets
=
malloc
(
resultData
->
varLenCol
.
varOffsetsLen
);
memcpy
(
resultData
->
varLenCol
.
varOffsets
,
srcData
->
varLenCol
.
varOffsets
,
srcData
->
varLenCol
.
varOffsetsLen
);
resultData
->
varLenCol
.
payloadLen
=
srcData
->
varLenCol
.
payloadLen
;
resultData
->
varLenCol
.
payload
=
malloc
(
resultData
->
varLenCol
.
payloadLen
);
memcpy
(
resultData
->
varLenCol
.
payload
,
srcData
->
varLenCol
.
payload
,
srcData
->
varLenCol
.
payloadLen
);
}
else
{
resultData
->
fixLenCol
.
nullBitmapLen
=
srcData
->
fixLenCol
.
nullBitmapLen
;
resultData
->
fixLenCol
.
nullBitmap
=
malloc
(
resultData
->
fixLenCol
.
nullBitmapLen
);
memcpy
(
resultData
->
fixLenCol
.
nullBitmap
,
srcData
->
fixLenCol
.
nullBitmap
,
srcData
->
fixLenCol
.
nullBitmapLen
);
resultData
->
fixLenCol
.
dataLen
=
srcData
->
fixLenCol
.
dataLen
;
resultData
->
fixLenCol
.
data
=
malloc
(
resultData
->
fixLenCol
.
dataLen
);
memcpy
(
resultData
->
fixLenCol
.
data
,
srcData
->
fixLenCol
.
data
,
srcData
->
fixLenCol
.
dataLen
);
for
(
int32_t
i
=
0
;
i
<
resultData
->
numOfRows
;
++
i
)
{
*
(
resultData
->
fixLenCol
.
data
+
i
*
sizeof
(
int32_t
))
=
88
;
}
}
SUdfColumnMeta
*
meta
=
&
resultCol
->
colMeta
;
meta
->
bytes
=
4
;
meta
->
type
=
TSDB_DATA_TYPE_INT
;
meta
->
scale
=
0
;
meta
->
precision
=
0
;
return
0
;
}
int32_t
udf2_free
(
SUdfColumn
*
col
)
{
SUdfColumnData
*
data
=
&
col
->
colData
;
if
(
data
->
varLengthColumn
)
{
free
(
data
->
varLenCol
.
varOffsets
);
data
->
varLenCol
.
varOffsets
=
NULL
;
free
(
data
->
varLenCol
.
payload
);
data
->
varLenCol
.
payload
=
NULL
;
}
else
{
free
(
data
->
fixLenCol
.
nullBitmap
);
data
->
fixLenCol
.
nullBitmap
=
NULL
;
free
(
data
->
fixLenCol
.
data
);
data
->
fixLenCol
.
data
=
NULL
;
}
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录