Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
62652aa4
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
未验证
提交
62652aa4
编写于
6月 09, 2022
作者:
G
Ganlin Zhao
提交者:
GitHub
6月 09, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #13639 from taosdata/enh/hll_split
enh(query): add hll function distributed splitting
上级
4f716560
bd4d5eca
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
97 addition
and
3 deletion
+97
-3
include/libs/function/functionMgt.h
include/libs/function/functionMgt.h
+2
-0
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+3
-0
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+47
-0
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+43
-1
tests/system-test/fulltest.bat
tests/system-test/fulltest.bat
+2
-2
未找到文件。
include/libs/function/functionMgt.h
浏览文件 @
62652aa4
...
...
@@ -129,6 +129,8 @@ typedef enum EFunctionType {
FUNCTION_TYPE_SPREAD_MERGE
,
FUNCTION_TYPE_HISTOGRAM_PARTIAL
,
FUNCTION_TYPE_HISTOGRAM_MERGE
,
FUNCTION_TYPE_HYPERLOGLOG_PARTIAL
,
FUNCTION_TYPE_HYPERLOGLOG_MERGE
,
// user defined funcion
FUNCTION_TYPE_UDF
=
10000
...
...
source/libs/function/inc/builtinsimpl.h
浏览文件 @
62652aa4
...
...
@@ -126,7 +126,10 @@ int32_t getHistogramInfoSize();
bool
getHLLFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
int32_t
hllFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
hllFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
hllFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
hllPartialFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
getHLLInfoSize
();
bool
getStateFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
stateFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
...
...
source/libs/function/src/builtins.c
浏览文件 @
62652aa4
...
...
@@ -313,6 +313,7 @@ static int32_t translateApercentileImpl(SFunctionNode* pFunc, char* pErrBuf, int
static
int32_t
translateApercentilePartial
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
return
translateApercentileImpl
(
pFunc
,
pErrBuf
,
len
,
true
);
}
static
int32_t
translateApercentileMerge
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
return
translateApercentileImpl
(
pFunc
,
pErrBuf
,
len
,
false
);
}
...
...
@@ -401,6 +402,7 @@ static int32_t translateSpreadImpl(SFunctionNode* pFunc, char* pErrBuf, int32_t
static
int32_t
translateSpreadPartial
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
return
translateSpreadImpl
(
pFunc
,
pErrBuf
,
len
,
true
);
}
static
int32_t
translateSpreadMerge
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
return
translateSpreadImpl
(
pFunc
,
pErrBuf
,
len
,
false
);
}
...
...
@@ -551,6 +553,7 @@ static int32_t translateHistogramImpl(SFunctionNode* pFunc, char* pErrBuf, int32
static
int32_t
translateHistogramPartial
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
return
translateHistogramImpl
(
pFunc
,
pErrBuf
,
len
,
true
);
}
static
int32_t
translateHistogramMerge
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
return
translateHistogramImpl
(
pFunc
,
pErrBuf
,
len
,
false
);
}
...
...
@@ -564,6 +567,28 @@ static int32_t translateHLL(SFunctionNode* pFunc, char* pErrBuf, int32_t len) {
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateHLLImpl
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
,
bool
isPartial
)
{
if
(
1
!=
LIST_LENGTH
(
pFunc
->
pParameterList
))
{
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
if
(
isPartial
)
{
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
getHistogramInfoSize
()
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
};
}
else
{
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
tDataTypes
[
TSDB_DATA_TYPE_BIGINT
].
bytes
,
.
type
=
TSDB_DATA_TYPE_BIGINT
};
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateHLLPartial
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
return
translateHLLImpl
(
pFunc
,
pErrBuf
,
len
,
true
);
}
static
int32_t
translateHLLMerge
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
return
translateHLLImpl
(
pFunc
,
pErrBuf
,
len
,
false
);
}
static
bool
validateStateOper
(
const
SValueNode
*
pVal
)
{
if
(
TSDB_DATA_TYPE_BINARY
!=
pVal
->
node
.
resType
.
type
)
{
return
false
;
...
...
@@ -1478,6 +1503,28 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
getEnvFunc
=
getHLLFuncEnv
,
.
initFunc
=
functionSetup
,
.
processFunc
=
hllFunction
,
.
finalizeFunc
=
hllFinalize
,
.
pPartialFunc
=
"_hyperloglog_partial"
,
.
pMergeFunc
=
"_hyperloglog_merge"
},
{
.
name
=
"_hyperloglog_partial"
,
.
type
=
FUNCTION_TYPE_HYPERLOGLOG_PARTIAL
,
.
classification
=
FUNC_MGT_AGG_FUNC
,
.
translateFunc
=
translateHLLPartial
,
.
getEnvFunc
=
getHLLFuncEnv
,
.
initFunc
=
functionSetup
,
.
processFunc
=
hllFunction
,
.
finalizeFunc
=
hllPartialFinalize
},
{
.
name
=
"_hyperloglog_merge"
,
.
type
=
FUNCTION_TYPE_HYPERLOGLOG_MERGE
,
.
classification
=
FUNC_MGT_AGG_FUNC
,
.
translateFunc
=
translateHLLMerge
,
.
getEnvFunc
=
getHLLFuncEnv
,
.
initFunc
=
functionSetup
,
.
processFunc
=
hllFunctionMerge
,
.
finalizeFunc
=
hllFinalize
},
{
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
62652aa4
...
...
@@ -3411,7 +3411,6 @@ int32_t histogramFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
}
int32_t
histogramPartialFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SHistoFuncInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
int32_t
resultBytes
=
getHistogramInfoSize
();
char
*
res
=
taosMemoryCalloc
(
resultBytes
+
VARSTR_HEADER_SIZE
,
sizeof
(
char
));
...
...
@@ -3428,6 +3427,10 @@ int32_t histogramPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
return
1
;
}
int32_t
getHLLInfoSize
()
{
return
(
int32_t
)
sizeof
(
SHLLInfo
);
}
bool
getHLLFuncEnv
(
SFunctionNode
*
UNUSED_PARAM
(
pFunc
),
SFuncExecEnv
*
pEnv
)
{
pEnv
->
calcMemSize
=
sizeof
(
SHLLInfo
);
return
true
;
...
...
@@ -3553,6 +3556,27 @@ int32_t hllFunction(SqlFunctionCtx *pCtx) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
hllFunctionMerge
(
SqlFunctionCtx
*
pCtx
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
ASSERT
(
pCol
->
info
.
type
==
TSDB_DATA_TYPE_BINARY
);
SHLLInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
int32_t
start
=
pInput
->
startRowIndex
;
char
*
data
=
colDataGetData
(
pCol
,
start
);
SHLLInfo
*
pInputInfo
=
(
SHLLInfo
*
)
varDataVal
(
data
);
for
(
int32_t
k
=
0
;
k
<
HLL_BUCKETS
;
++
k
)
{
if
(
pInfo
->
buckets
[
k
]
<
pInputInfo
->
buckets
[
k
])
{
pInfo
->
buckets
[
k
]
=
pInputInfo
->
buckets
[
k
];
}
}
SET_VAL
(
GET_RES_INFO
(
pCtx
),
1
,
1
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
hllFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
SResultRowEntryInfo
*
pInfo
=
GET_RES_INFO
(
pCtx
);
...
...
@@ -3565,6 +3589,24 @@ int32_t hllFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
return
functionFinalize
(
pCtx
,
pBlock
);
}
int32_t
hllPartialFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SHLLInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
int32_t
resultBytes
=
getHLLInfoSize
();
char
*
res
=
taosMemoryCalloc
(
resultBytes
+
VARSTR_HEADER_SIZE
,
sizeof
(
char
));
memcpy
(
varDataVal
(
res
),
pInfo
,
resultBytes
);
varDataSetLen
(
res
,
resultBytes
);
int32_t
slotId
=
pCtx
->
pExpr
->
base
.
resSchema
.
slotId
;
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
slotId
);
colDataAppend
(
pCol
,
pBlock
->
info
.
rows
,
res
,
false
);
taosMemoryFree
(
res
);
return
pResInfo
->
numOfRes
;
}
bool
getStateFuncEnv
(
SFunctionNode
*
UNUSED_PARAM
(
pFunc
),
SFuncExecEnv
*
pEnv
)
{
pEnv
->
calcMemSize
=
sizeof
(
SStateInfo
);
return
true
;
...
...
tests/system-test/fulltest.bat
浏览文件 @
62652aa4
...
...
@@ -3,7 +3,7 @@ python3 .\test.py -f 0-others\taosShell.py
python3
.\test.py
-f
0
-others
\taosShellError.py
python3
.\test.py
-f
0
-others
\taosShellNetChk.py
python3
.\test.py
-f
0
-others
\telemetry.py
python3
.\test.py
-f
0
-others
\taosdMonitor.py
@REM
python3 .\test.py -f 0-others\taosdMonitor.py
python3
.\test.py
-f
0
-others
\udfTest.py
python3
.\test.py
-f
0
-others
\udf_create.py
python3
.\test.py
-f
0
-others
\udf_restart_taosd.py
...
...
@@ -100,4 +100,4 @@ python3 .\test.py -f 0-others\udf_restart_taosd.py
@REM python3 .\test.py -f 7-tmq\subscribeStb2.py
@REM python3 .\test.py -f 7-tmq\subscribeStb3.py
@REM python3 .\test.py -f 7-tmq\subscribeStb4.py
@REM python3 .\test.py -f 7-tmq\db.py
\ No newline at end of file
@REM python3 .\test.py -f 7-tmq\db.py
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录