Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6eb6cfe2
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
6eb6cfe2
编写于
3月 30, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-14241]: concat_ws function adoption
上级
6f6d0e4a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
49 addition
and
16 deletion
+49
-16
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+13
-5
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+36
-11
未找到文件。
source/libs/function/src/builtins.c
浏览文件 @
6eb6cfe2
...
@@ -508,12 +508,19 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) {
...
@@ -508,12 +508,19 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) {
break
;
break
;
}
}
case
FUNCTION_TYPE_CONCAT
:
{
case
FUNCTION_TYPE_CONCAT
:
int32_t
paraTypeFirst
,
totalBytes
=
0
;
case
FUNCTION_TYPE_CONCAT_WS
:
{
for
(
int32_t
i
=
0
;
i
<
pFunc
->
pParameterList
->
length
;
++
i
)
{
int32_t
paraTypeFirst
,
totalBytes
=
0
,
sepBytes
=
0
;
int32_t
firstParamIndex
=
0
;
if
(
pFunc
->
funcType
==
FUNCTION_TYPE_CONCAT_WS
)
{
firstParamIndex
=
1
;
SColumnNode
*
pSep
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
sepBytes
=
pSep
->
node
.
resType
.
type
;
}
for
(
int32_t
i
=
firstParamIndex
;
i
<
pFunc
->
pParameterList
->
length
;
++
i
)
{
SColumnNode
*
pParam
=
nodesListGetNode
(
pFunc
->
pParameterList
,
i
);
SColumnNode
*
pParam
=
nodesListGetNode
(
pFunc
->
pParameterList
,
i
);
int32_t
paraType
=
pParam
->
node
.
resType
.
type
;
int32_t
paraType
=
pParam
->
node
.
resType
.
type
;
if
(
i
==
0
)
{
if
(
i
==
firstParamIndex
)
{
paraTypeFirst
=
paraType
;
paraTypeFirst
=
paraType
;
}
}
if
(
paraType
!=
paraTypeFirst
)
{
if
(
paraType
!=
paraTypeFirst
)
{
...
@@ -521,10 +528,11 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) {
...
@@ -521,10 +528,11 @@ int32_t stubCheckAndGetResultType(SFunctionNode* pFunc) {
}
}
totalBytes
+=
pParam
->
node
.
resType
.
bytes
;
totalBytes
+=
pParam
->
node
.
resType
.
bytes
;
}
}
//TODO: need to get numOfRows to decide how much space separator needed. Currently set to 100.
totalBytes
+=
sepBytes
*
(
pFunc
->
pParameterList
->
length
-
2
)
*
100
;
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
totalBytes
,
.
type
=
paraTypeFirst
};
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
totalBytes
,
.
type
=
paraTypeFirst
};
break
;
break
;
}
}
case
FUNCTION_TYPE_CONCAT_WS
:
case
FUNCTION_TYPE_LOWER
:
case
FUNCTION_TYPE_LOWER
:
case
FUNCTION_TYPE_UPPER
:
case
FUNCTION_TYPE_UPPER
:
case
FUNCTION_TYPE_LTRIM
:
case
FUNCTION_TYPE_LTRIM
:
...
...
source/libs/scalar/src/sclfunc.c
浏览文件 @
6eb6cfe2
...
@@ -374,7 +374,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
...
@@ -374,7 +374,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu
offset
+=
dataTLen
;
offset
+=
dataTLen
;
}
}
pOutput
->
numOfRows
=
pInput
->
numOfRows
;
pOutput
->
numOfRows
=
numOfRows
;
taosMemoryFree
(
input
);
taosMemoryFree
(
input
);
taosMemoryFree
(
pInputData
);
taosMemoryFree
(
pInputData
);
...
@@ -388,45 +388,70 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
...
@@ -388,45 +388,70 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p
SColumnInfoData
**
pInputData
=
taosMemoryCalloc
(
inputNum
,
sizeof
(
SColumnInfoData
*
));
SColumnInfoData
**
pInputData
=
taosMemoryCalloc
(
inputNum
,
sizeof
(
SColumnInfoData
*
));
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
SColumnInfoData
*
pOutputData
=
pOutput
->
columnData
;
char
**
input
=
taosMemoryCalloc
(
inputNum
,
POINTER_BYTES
);
char
*
output
=
NULL
;
int32_t
inputLen
=
0
;
int32_t
numOfRows
=
pInput
[
1
].
numOfRows
;
for
(
int32_t
i
=
0
;
i
<
inputNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
inputNum
;
++
i
)
{
if
(
!
IS_VAR_DATA_TYPE
(
GET_PARAM_TYPE
(
&
pInput
[
i
]))
||
if
(
!
IS_VAR_DATA_TYPE
(
GET_PARAM_TYPE
(
&
pInput
[
i
]))
||
GET_PARAM_TYPE
(
&
pInput
[
i
])
!=
GET_PARAM_TYPE
(
&
pInput
[
0
]))
{
GET_PARAM_TYPE
(
&
pInput
[
i
])
!=
GET_PARAM_TYPE
(
&
pInput
[
0
]))
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
pInputData
[
i
]
=
pInput
[
i
].
columnData
;
pInputData
[
i
]
=
pInput
[
i
].
columnData
;
if
(
i
==
0
)
{
// calculate required separator space
inputLen
+=
(
pInputData
[
0
]
->
varmeta
.
length
-
VARSTR_HEADER_SIZE
)
*
(
inputNum
-
2
);
}
else
{
inputLen
+=
pInputData
[
i
]
->
varmeta
.
length
-
numOfRows
*
VARSTR_HEADER_SIZE
;
}
input
[
i
]
=
pInputData
[
i
]
->
pData
;
}
}
for
(
int32_t
k
=
0
;
k
<
pInput
->
numOfRows
;
++
k
)
{
//allocate output buf
if
(
pOutputData
->
pData
==
NULL
)
{
int32_t
outputLen
=
inputLen
+
numOfRows
*
VARSTR_HEADER_SIZE
;
pOutputData
->
pData
=
taosMemoryCalloc
(
outputLen
,
sizeof
(
char
));
pOutputData
->
info
.
type
=
GET_PARAM_TYPE
(
pInput
);
pOutputData
->
info
.
bytes
=
outputLen
;
pOutputData
->
varmeta
.
length
=
outputLen
;
pOutputData
->
varmeta
.
allocLen
=
outputLen
;
}
output
=
pOutputData
->
pData
;
int32_t
offset
=
0
;
for
(
int32_t
k
=
0
;
k
<
numOfRows
;
++
k
)
{
char
*
sep
=
pInputData
[
0
]
->
pData
;
char
*
sep
=
pInputData
[
0
]
->
pData
;
if
(
colDataIsNull_f
(
pInputData
[
0
]
->
nullbitmap
,
k
))
{
if
(
colDataIsNull_f
(
pInputData
[
0
]
->
nullbitmap
,
k
))
{
colDataSetNull_f
(
pOutputData
->
nullbitmap
,
k
);
colDataSetNull_f
(
pOutputData
->
nullbitmap
,
k
);
continue
;
continue
;
}
}
char
*
in
=
NULL
;
char
*
out
=
pOutputData
->
pData
+
k
*
GET_PARAM_BYTES
(
pOutput
);
int16_t
dataLen
=
0
;
int16_t
dataLen
=
0
;
for
(
int32_t
i
=
1
;
i
<
inputNum
;
++
i
)
{
for
(
int32_t
i
=
1
;
i
<
inputNum
;
++
i
)
{
if
(
colDataIsNull_f
(
pInputData
[
i
]
->
nullbitmap
,
k
))
{
if
(
colDataIsNull_f
(
pInputData
[
i
]
->
nullbitmap
,
k
))
{
continue
;
continue
;
}
}
in
=
pInputData
[
i
]
->
pData
+
k
*
GET_PARAM_BYTES
(
&
pInput
[
i
]
);
memcpy
(
varDataVal
(
output
)
+
dataLen
,
varDataVal
(
input
[
i
]),
varDataLen
(
input
[
i
])
);
memcpy
(
varDataVal
(
out
)
+
dataLen
,
varDataVal
(
in
),
varDataLen
(
in
)
);
dataLen
+=
varDataLen
(
input
[
i
]
);
dataLen
+=
varDataLen
(
in
);
input
[
i
]
+=
varDataTLen
(
input
[
i
]
);
if
(
i
<
inputNum
-
1
)
{
if
(
i
<
inputNum
-
1
)
{
//insert the separator
//insert the separator
memcpy
(
varDataVal
(
out
)
+
dataLen
,
varDataVal
(
sep
),
varDataLen
(
sep
));
memcpy
(
varDataVal
(
out
put
)
+
dataLen
,
varDataVal
(
sep
),
varDataLen
(
sep
));
dataLen
+=
varDataLen
(
sep
);
dataLen
+=
varDataLen
(
sep
);
}
}
}
}
varDataSetLen
(
out
,
dataLen
);
varDataSetLen
(
output
,
dataLen
);
int32_t
dataTLen
=
varDataTLen
(
output
);
output
+=
dataTLen
;
pOutputData
->
varmeta
.
offset
[
k
]
=
offset
;
offset
+=
dataTLen
;
}
}
pOutput
->
numOfRows
=
pInput
->
numOfRows
;
pOutput
->
numOfRows
=
numOfRows
;
taosMemoryFree
(
input
);
taosMemoryFree
(
pInputData
);
taosMemoryFree
(
pInputData
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录