Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
34b2f7b8
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
34b2f7b8
编写于
4月 07, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix compile error
上级
00109279
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
96 addition
and
7 deletion
+96
-7
deps/lua/src/lauxlib.c
deps/lua/src/lauxlib.c
+1
-1
src/query/src/qScript.c
src/query/src/qScript.c
+2
-2
tests/script/sh/demo.c
tests/script/sh/demo.c
+72
-0
tests/script/sh/sum_double.c
tests/script/sh/sum_double.c
+21
-4
未找到文件。
deps/lua/src/lauxlib.c
浏览文件 @
34b2f7b8
src/query/src/qScript.c
浏览文件 @
34b2f7b8
...
@@ -107,7 +107,7 @@ int taosLoadScriptInit(SUdfInit* pInit) {
...
@@ -107,7 +107,7 @@ int taosLoadScriptInit(SUdfInit* pInit) {
pInit
->
destroyCtxFunc
=
destroyScriptCtx
;
pInit
->
destroyCtxFunc
=
destroyScriptCtx
;
ScriptCtx
*
pCtx
=
pInit
->
script_ctx
;
ScriptCtx
*
pCtx
=
pInit
->
script_ctx
;
char
funcName
[
MAX_FUNC_NAME
]
=
{
0
};
char
funcName
[
MAX_FUNC_NAME
+
10
]
=
{
0
};
sprintf
(
funcName
,
"%s_init"
,
pCtx
->
funcName
);
sprintf
(
funcName
,
"%s_init"
,
pCtx
->
funcName
);
lua_State
*
lua
=
pCtx
->
pEnv
->
lua_state
;
lua_State
*
lua
=
pCtx
->
pEnv
->
lua_state
;
...
@@ -129,7 +129,7 @@ int taosLoadScriptNormal(char *pInput, int16_t iType, int16_t iBytes, int32_t nu
...
@@ -129,7 +129,7 @@ int taosLoadScriptNormal(char *pInput, int16_t iType, int16_t iBytes, int32_t nu
int16_t
oType
,
int16_t
oBytes
,
SUdfInit
*
pInit
)
{
int16_t
oType
,
int16_t
oBytes
,
SUdfInit
*
pInit
)
{
ScriptCtx
*
pCtx
=
pInit
->
script_ctx
;
ScriptCtx
*
pCtx
=
pInit
->
script_ctx
;
char
funcName
[
MAX_FUNC_NAME
]
=
{
0
};
char
funcName
[
MAX_FUNC_NAME
+
10
]
=
{
0
};
sprintf
(
funcName
,
"%s_add"
,
pCtx
->
funcName
);
sprintf
(
funcName
,
"%s_add"
,
pCtx
->
funcName
);
lua_State
*
lua
=
pCtx
->
pEnv
->
lua_state
;
lua_State
*
lua
=
pCtx
->
pEnv
->
lua_state
;
lua_getglobal
(
lua
,
funcName
);
lua_getglobal
(
lua
,
funcName
);
...
...
tests/script/sh/demo.c
0 → 100644
浏览文件 @
34b2f7b8
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef
struct
SUdfInit
{
int
maybe_null
;
/* 1 if function can return NULL */
int
decimals
;
/* for real functions */
long
long
length
;
/* For string functions */
char
*
ptr
;
/* free pointer for function data */
int
const_item
;
/* 0 if result is independent of arguments */
}
SUdfInit
;
typedef
struct
SDemo
{
double
sum
;
int
num
;
short
otype
;
}
SDemo
;
void
demo
(
char
*
data
,
short
itype
,
short
ibytes
,
int
numOfRows
,
long
long
*
ts
,
char
*
dataOutput
,
char
*
tsOutput
,
int
*
numOfOutput
,
short
otype
,
short
obytes
,
SUdfInit
*
buf
)
{
int
i
;
double
r
=
0
;
SDemo
*
p
=
(
SDemo
*
)
buf
->
ptr
;
printf
(
"demo input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p
\n
"
,
data
,
itype
,
numOfRows
,
ts
,
*
ts
,
dataOutput
,
tsOutput
,
numOfOutput
,
buf
);
for
(
i
=
0
;
i
<
numOfRows
;
++
i
)
{
if
(
itype
==
6
)
{
r
=*
((
float
*
)
data
+
i
);
}
else
if
(
itype
==
7
)
{
r
=*
((
double
*
)
data
+
i
);
}
p
->
sum
+=
r
*
r
;
}
p
->
otype
=
otype
;
p
->
num
+=
numOfRows
;
*
numOfOutput
=
1
;
printf
(
"demo out, dataoutput:%d, numOfOutput:%d
\n
"
,
*
(
int
*
)
dataOutput
,
*
numOfOutput
);
}
void
demo_finalize
(
char
*
dataOutput
,
int
*
numOfOutput
,
SUdfInit
*
buf
)
{
SDemo
*
p
=
(
SDemo
*
)
buf
->
ptr
;
printf
(
"demo_finalize dataoutput:%p, numOfOutput:%p, buf:%p
\n
"
,
dataOutput
,
numOfOutput
,
buf
);
if
(
p
->
otype
==
6
)
{
*
(
float
*
)
dataOutput
=
(
float
)(
p
->
sum
/
p
->
num
);
}
else
if
(
p
->
otype
==
7
)
{
*
(
double
*
)
dataOutput
=
(
double
)(
p
->
sum
/
p
->
num
);
}
*
numOfOutput
=
1
;
printf
(
"demo finalize, dataoutput:%d, numOfOutput:%d
\n
"
,
*
(
int
*
)
dataOutput
,
*
numOfOutput
);
}
int
demo_init
(
SUdfInit
*
buf
)
{
buf
->
ptr
=
calloc
(
1
,
sizeof
(
SDemo
));
printf
(
"demo init
\n
"
);
return
0
;
}
void
demo_destroy
(
SUdfInit
*
buf
)
{
free
(
buf
->
ptr
);
printf
(
"demo destroy
\n
"
);
}
tests/script/sh/sum_double.c
浏览文件 @
34b2f7b8
...
@@ -10,12 +10,12 @@ typedef struct SUdfInit{
...
@@ -10,12 +10,12 @@ typedef struct SUdfInit{
int
const_item
;
/* 0 if result is independent of arguments */
int
const_item
;
/* 0 if result is independent of arguments */
}
SUdfInit
;
}
SUdfInit
;
void
sum_double
(
char
*
data
,
char
type
,
int
numOfRows
,
long
long
*
ts
,
char
*
dataOutput
,
char
*
tsOutput
,
void
sum_double
(
char
*
data
,
short
itype
,
short
ibytes
,
int
numOfRows
,
long
long
*
ts
,
char
*
dataOutput
,
char
*
tsOutput
,
int
*
numOfOutput
,
SUdfInit
*
buf
)
{
int
*
numOfOutput
,
short
otype
,
short
obytes
,
SUdfInit
*
buf
)
{
int
i
;
int
i
;
int
r
=
0
;
int
r
=
0
;
printf
(
"sum_double input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p
\n
"
,
data
,
type
,
numOfRows
,
ts
,
*
ts
,
dataOutput
,
tsOutput
,
numOfOutput
,
buf
);
printf
(
"sum_double input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p
\n
"
,
data
,
i
type
,
numOfRows
,
ts
,
*
ts
,
dataOutput
,
tsOutput
,
numOfOutput
,
buf
);
if
(
type
==
4
)
{
if
(
i
type
==
4
)
{
r
=*
(
int
*
)
dataOutput
;
r
=*
(
int
*
)
dataOutput
;
for
(
i
=
0
;
i
<
numOfRows
;
++
i
)
{
for
(
i
=
0
;
i
<
numOfRows
;
++
i
)
{
r
+=*
((
int
*
)
data
+
i
);
r
+=*
((
int
*
)
data
+
i
);
...
@@ -42,6 +42,23 @@ void sum_double_finalize(char* dataOutput, int* numOfOutput, SUdfInit* buf) {
...
@@ -42,6 +42,23 @@ void sum_double_finalize(char* dataOutput, int* numOfOutput, SUdfInit* buf) {
printf
(
"sum_double finalize, dataoutput:%d, numOfOutput:%d
\n
"
,
*
(
int
*
)
dataOutput
,
*
numOfOutput
);
printf
(
"sum_double finalize, dataoutput:%d, numOfOutput:%d
\n
"
,
*
(
int
*
)
dataOutput
,
*
numOfOutput
);
}
}
void
sum_double_merge
(
char
*
dataOutput
,
int
*
numOfOutput
,
SUdfInit
*
buf
)
{
int
r
=
0
;
int
sum
=
0
;
printf
(
"sum_double_merge dataoutput:%p, numOfOutput:%p, buf:%p
\n
"
,
dataOutput
,
numOfOutput
,
buf
);
for
(
int
i
=
0
;
i
<
*
numOfOutput
;
++
i
)
{
printf
(
"sum_double_merge %d - %d
\n
"
,
i
,
*
((
int
*
)
dataOutput
+
i
));
sum
+=*
((
int
*
)
dataOutput
+
i
);
}
*
(
int
*
)
dataOutput
=
sum
;
*
numOfOutput
=
1
;
printf
(
"sum_double sum_double_merge, dataoutput:%d, numOfOutput:%d
\n
"
,
*
(
int
*
)
dataOutput
,
*
numOfOutput
);
}
int
sum_double_init
(
SUdfInit
*
buf
)
{
int
sum_double_init
(
SUdfInit
*
buf
)
{
buf
->
maybe_null
=
1
;
buf
->
maybe_null
=
1
;
buf
->
ptr
=
malloc
(
sizeof
(
int
));
buf
->
ptr
=
malloc
(
sizeof
(
int
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录