Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6c4400c3
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看板
提交
6c4400c3
编写于
3月 06, 2023
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: the buf returend by the udf has a smaller size than the function bufsize
上级
44e3b115
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
16 addition
and
10 deletion
+16
-10
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+10
-7
source/libs/function/src/udfd.c
source/libs/function/src/udfd.c
+6
-3
未找到文件。
source/libs/function/src/tudf.c
浏览文件 @
6c4400c3
...
...
@@ -899,9 +899,11 @@ int32_t convertDataBlockToScalarParm(SSDataBlock *input, SScalarParam *output) {
typedef
struct
SUdfAggRes
{
int8_t
finalResNum
;
int8_t
interResNum
;
int32_t
interResBufLen
;
char
*
finalResBuf
;
char
*
interResBuf
;
}
SUdfAggRes
;
void
onUdfcPipeClose
(
uv_handle_t
*
handle
);
int32_t
udfcGetUdfTaskResultFromUvTask
(
SClientUdfTask
*
task
,
SClientUvTaskNode
*
uvTask
);
void
udfcAllocateBuffer
(
uv_handle_t
*
handle
,
size_t
suggestedSize
,
uv_buf_t
*
buf
);
...
...
@@ -1096,9 +1098,10 @@ bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResult
releaseUdfFuncHandle
(
pCtx
->
udfName
);
return
false
;
}
udfRes
->
interResNum
=
buf
.
numOfResult
;
if
(
buf
.
bufLen
<=
session
->
bufSize
)
{
memcpy
(
udfRes
->
interResBuf
,
buf
.
buf
,
buf
.
bufLen
);
udfRes
->
interResBufLen
=
buf
.
bufLen
;
udfRes
->
interResNum
=
buf
.
numOfResult
;
}
else
{
fnError
(
"udfc inter buf size %d is greater than function bufSize %d"
,
buf
.
bufLen
,
session
->
bufSize
);
releaseUdfFuncHandle
(
pCtx
->
udfName
);
...
...
@@ -1136,7 +1139,7 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) {
SSDataBlock
*
inputBlock
=
blockDataExtractBlock
(
pTempBlock
,
start
,
numOfRows
);
SUdfInterBuf
state
=
{.
buf
=
udfRes
->
interResBuf
,
.
bufLen
=
session
->
bufSize
,
.
numOfResult
=
udfRes
->
interResNum
};
SUdfInterBuf
state
=
{.
buf
=
udfRes
->
interResBuf
,
.
bufLen
=
udfRes
->
interResBufLen
,
.
numOfResult
=
udfRes
->
interResNum
};
SUdfInterBuf
newState
=
{
0
};
udfCode
=
doCallUdfAggProcess
(
session
,
inputBlock
,
&
state
,
&
newState
);
...
...
@@ -1144,17 +1147,17 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) {
fnError
(
"udfAggProcess error. code: %d"
,
udfCode
);
newState
.
numOfResult
=
0
;
}
else
{
udfRes
->
interResNum
=
newState
.
numOfResult
;
if
(
newState
.
bufLen
<=
session
->
bufSize
)
{
memcpy
(
udfRes
->
interResBuf
,
newState
.
buf
,
newState
.
bufLen
);
udfRes
->
interResBufLen
=
newState
.
bufLen
;
udfRes
->
interResNum
=
newState
.
numOfResult
;
}
else
{
fnError
(
"udfc inter buf size %d is greater than function bufSize %d"
,
newState
.
bufLen
,
session
->
bufSize
);
udfCode
=
TSDB_CODE_UDF_INVALID_BUFSIZE
;
}
}
if
(
newState
.
numOfResult
==
1
||
state
.
numOfResult
==
1
)
{
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
1
;
}
GET_RES_INFO
(
pCtx
)
->
numOfRes
=
udfRes
->
interResNum
;
blockDataDestroy
(
inputBlock
);
...
...
@@ -1180,7 +1183,7 @@ int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock) {
udfRes
->
interResBuf
=
(
char
*
)
udfRes
+
sizeof
(
SUdfAggRes
)
+
session
->
outputLen
;
SUdfInterBuf
resultBuf
=
{
0
};
SUdfInterBuf
state
=
{.
buf
=
udfRes
->
interResBuf
,
.
bufLen
=
session
->
bufSize
,
.
numOfResult
=
udfRes
->
interResNum
};
SUdfInterBuf
state
=
{.
buf
=
udfRes
->
interResBuf
,
.
bufLen
=
udfRes
->
interResBufLen
,
.
numOfResult
=
udfRes
->
interResNum
};
int32_t
udfCallCode
=
0
;
udfCallCode
=
doCallUdfAggFinalize
(
session
,
&
state
,
&
resultBuf
);
if
(
udfCallCode
!=
0
)
{
...
...
source/libs/function/src/udfd.c
浏览文件 @
6c4400c3
...
...
@@ -173,6 +173,7 @@ int32_t udfdCPluginUdfAggFinish(SUdfInterBuf *buf, SUdfInterBuf *resultData, voi
// for others, dlopen/dlsym to find function pointers
typedef
struct
SUdfScriptPlugin
{
int8_t
scriptType
;
const
char
*
scriptSuffix
;
char
libPath
[
PATH_MAX
];
bool
libLoaded
;
...
...
@@ -313,6 +314,7 @@ static void udfdConnectMnodeThreadFunc(void *args);
void
udfdInitializeCPlugin
(
SUdfScriptPlugin
*
plugin
)
{
plugin
->
scriptType
=
TSDB_FUNC_SCRIPT_BIN_LIB
;
plugin
->
scriptSuffix
=
'
.
so
'
;
plugin
->
openFunc
=
udfdCPluginOpen
;
plugin
->
closeFunc
=
udfdCPluginClose
;
plugin
->
udfInitFunc
=
udfdCPluginUdfInit
;
...
...
@@ -346,6 +348,7 @@ int32_t udfdLoadSharedLib(char *libPath, uv_lib_t *pLib, const char *funcName[],
void
udfdInitializePythonPlugin
(
SUdfScriptPlugin
*
plugin
)
{
plugin
->
scriptType
=
TSDB_FUNC_SCRIPT_PYTHON
;
plugin
->
scriptSuffix
=
"py"
;
//todo: windows support
sprintf
(
plugin
->
libPath
,
"%s"
,
"libtaospyudf.so"
);
plugin
->
libLoaded
=
false
;
...
...
@@ -776,7 +779,7 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
udf
->
outputType
=
pFuncInfo
->
outputType
;
udf
->
outputLen
=
pFuncInfo
->
outputLen
;
udf
->
bufSize
=
pFuncInfo
->
bufSize
;
char
*
suffix
=
global
.
scriptPlugins
[
udf
->
scriptType
]
->
scriptSuffix
;
if
(
!
osTempSpaceAvailable
())
{
terrno
=
TSDB_CODE_NO_AVAIL_DISK
;
msgInfo
->
code
=
terrno
;
...
...
@@ -786,9 +789,9 @@ void udfdProcessRpcRsp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
char
path
[
PATH_MAX
]
=
{
0
};
#ifdef WINDOWS
snprintf
(
path
,
sizeof
(
path
),
"%s%s
"
,
tsTempDir
,
pFuncInfo
->
name
);
snprintf
(
path
,
sizeof
(
path
),
"%s%s
.%s"
,
tsTempDir
,
pFuncInfo
->
name
,
suffix
);
#else
snprintf
(
path
,
sizeof
(
path
),
"%s/%s
"
,
tsTempDir
,
pFuncInfo
->
name
);
snprintf
(
path
,
sizeof
(
path
),
"%s/%s
.%s"
,
tsTempDir
,
pFuncInfo
->
name
,
suffix
);
#endif
TdFilePtr
file
=
taosOpenFile
(
path
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_READ
|
TD_FILE_TRUNC
);
if
(
file
==
NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录