Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
4036d971
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
4036d971
编写于
6月 13, 2022
作者:
G
Ganlin Zhao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add bottom function distribution splitting
上级
ca222157
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
66 addition
and
18 deletion
+66
-18
include/libs/function/functionMgt.h
include/libs/function/functionMgt.h
+2
-0
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+1
-0
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+25
-1
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+38
-17
未找到文件。
include/libs/function/functionMgt.h
浏览文件 @
4036d971
...
...
@@ -136,6 +136,8 @@ typedef enum EFunctionType {
FUNCTION_TYPE_ELAPSED_MERGE
,
FUNCTION_TYPE_TOP_PARTIAL
,
FUNCTION_TYPE_TOP_MERGE
,
FUNCTION_TYPE_BOTTOM_PARTIAL
,
FUNCTION_TYPE_BOTTOM_MERGE
,
// user defined funcion
FUNCTION_TYPE_UDF
=
10000
...
...
source/libs/function/inc/builtinsimpl.h
浏览文件 @
4036d971
...
...
@@ -104,6 +104,7 @@ bool topBotFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo)
int32_t
topFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
topFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
bottomFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
bottomFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
topBotFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
topBotPartialFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
topBotMergeFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
...
...
source/libs/function/src/builtins.c
浏览文件 @
4036d971
...
...
@@ -1574,10 +1574,34 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_INDEFINITE_ROWS_FUNC
,
.
translateFunc
=
translateTopBot
,
.
getEnvFunc
=
getTopBotFuncEnv
,
.
initFunc
=
f
unctionSetup
,
.
initFunc
=
topBotF
unctionSetup
,
.
processFunc
=
bottomFunction
,
.
finalizeFunc
=
topBotFinalize
,
.
combineFunc
=
bottomCombine
,
.
pPartialFunc
=
"_bottom_partial"
,
.
pMergeFunc
=
"_bottom_merge"
},
{
.
name
=
"_bottom_partial"
,
.
type
=
FUNCTION_TYPE_BOTTOM_PARTIAL
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_INDEFINITE_ROWS_FUNC
,
.
translateFunc
=
translateTopBotPartial
,
.
getEnvFunc
=
getTopBotFuncEnv
,
.
initFunc
=
topBotFunctionSetup
,
.
processFunc
=
bottomFunction
,
.
finalizeFunc
=
topBotPartialFinalize
,
.
combineFunc
=
bottomCombine
,
},
{
.
name
=
"_bottom_merge"
,
.
type
=
FUNCTION_TYPE_BOTTOM_MERGE
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_INDEFINITE_ROWS_FUNC
,
.
translateFunc
=
translateTopBotMerge
,
.
getEnvFunc
=
getTopBotMergeFuncEnv
,
.
initFunc
=
functionSetup
,
.
processFunc
=
bottomFunctionMerge
,
.
finalizeFunc
=
topBotMergeFinalize
,
.
combineFunc
=
bottomCombine
,
},
{
.
name
=
"spread"
,
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
4036d971
...
...
@@ -2716,9 +2716,33 @@ int32_t topFunction(SqlFunctionCtx* pCtx) {
return
TSDB_CODE_SUCCESS
;
}
static
void
topTransferInfo
(
SqlFunctionCtx
*
pCtx
,
STopBotRes
*
pInput
)
{
int32_t
bottomFunction
(
SqlFunctionCtx
*
pCtx
)
{
int32_t
numOfElems
=
0
;
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
STopBotRes
*
pRes
=
getTopBotOutputInfo
(
pCtx
);
pRes
->
type
=
pInput
->
pData
[
0
]
->
info
.
type
;
int32_t
start
=
pInput
->
startRowIndex
;
for
(
int32_t
i
=
start
;
i
<
pInput
->
numOfRows
+
start
;
++
i
)
{
if
(
pCol
->
hasNull
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
continue
;
}
numOfElems
++
;
char
*
data
=
colDataGetData
(
pCol
,
i
);
doAddIntoResult
(
pCtx
,
data
,
i
,
pCtx
->
pSrcBlock
,
pRes
->
type
,
pInput
->
uid
,
pResInfo
,
false
);
}
return
TSDB_CODE_SUCCESS
;
}
static
void
topBotTransferInfo
(
SqlFunctionCtx
*
pCtx
,
STopBotRes
*
pInput
,
bool
isTopQuery
)
{
for
(
int32_t
i
=
0
;
i
<
pInput
->
numOfItems
;
i
++
)
{
addResult
(
pCtx
,
&
pInput
->
pItems
[
i
],
pInput
->
type
,
true
);
addResult
(
pCtx
,
&
pInput
->
pItems
[
i
],
pInput
->
type
,
isTopQuery
);
}
}
...
...
@@ -2735,31 +2759,28 @@ int32_t topFunctionMerge(SqlFunctionCtx* pCtx) {
pInfo
->
maxSize
=
pInputInfo
->
maxSize
;
pInfo
->
type
=
pInputInfo
->
type
;
top
TransferInfo
(
pCtx
,
pInputInfo
);
top
BotTransferInfo
(
pCtx
,
pInputInfo
,
true
);
SET_VAL
(
GET_RES_INFO
(
pCtx
),
pEntryInfo
->
numOfRes
,
pEntryInfo
->
numOfRes
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
bottomFunction
(
SqlFunctionCtx
*
pCtx
)
{
int32_t
numOfElems
=
0
;
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
int32_t
bottomFunctionMerge
(
SqlFunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pEntryInfo
=
GET_RES_INFO
(
pCtx
);
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
int32_t
type
=
pInput
->
pData
[
0
]
->
info
.
type
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
int32_t
start
=
pInput
->
startRowIndex
;
for
(
int32_t
i
=
start
;
i
<
pInput
->
numOfRows
+
start
;
++
i
)
{
if
(
pCol
->
hasNull
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
continue
;
}
char
*
data
=
colDataGetData
(
pCol
,
start
);
STopBotRes
*
pInputInfo
=
(
STopBotRes
*
)
varDataVal
(
data
);
STopBotRes
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
numOfElems
++
;
char
*
data
=
colDataGetData
(
pCol
,
i
)
;
doAddIntoResult
(
pCtx
,
data
,
i
,
pCtx
->
pSrcBlock
,
type
,
pInput
->
uid
,
pRes
Info
,
false
);
}
pInfo
->
maxSize
=
pInputInfo
->
maxSize
;
pInfo
->
type
=
pInputInfo
->
type
;
topBotTransferInfo
(
pCtx
,
pInput
Info
,
false
);
SET_VAL
(
GET_RES_INFO
(
pCtx
),
pEntryInfo
->
numOfRes
,
pEntryInfo
->
numOfRes
);
return
TSDB_CODE_SUCCESS
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录