Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a8da3cfd
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看板
提交
a8da3cfd
编写于
6月 08, 2022
作者:
5
54liuyao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(stream): stream state support apercentile
上级
4935b146
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
40 addition
and
12 deletion
+40
-12
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+15
-11
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
+4
-1
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+20
-0
未找到文件。
source/libs/executor/src/timewindowoperator.c
浏览文件 @
a8da3cfd
...
...
@@ -1227,7 +1227,10 @@ void doClearWindow(SAggSupporter* pSup, SOptrBasicInfo* pBinfo, char* pData, int
SET_RES_WINDOW_KEY
(
pSup
->
keyBuf
,
pData
,
bytes
,
groupId
);
SResultRowPosition
*
p1
=
(
SResultRowPosition
*
)
taosHashGet
(
pSup
->
pResultRowHashTable
,
pSup
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
ASSERT
(
p1
);
if
(
!
p1
)
{
// window has been closed
return
;
}
doClearWindowImpl
(
p1
,
pSup
->
pResultBuf
,
pBinfo
,
numOfOutput
);
}
...
...
@@ -2202,12 +2205,12 @@ void destroyStreamSessionAggOperatorInfo(void* param, int32_t numOfOutput) {
}
}
int32_t
initBiasicInfo
(
SOptrBasicInfo
*
pBasicInfo
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SDiskbasedBuf
*
pResultBuf
)
{
int32_t
initBiasicInfo
(
SOptrBasicInfo
*
pBasicInfo
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
)
{
pBasicInfo
->
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
numOfCols
,
&
pBasicInfo
->
rowCellInfoOffset
);
pBasicInfo
->
pRes
=
pResultBlock
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
pBasicInfo
->
pCtx
[
i
].
pBuf
=
pResultBuf
;
pBasicInfo
->
pCtx
[
i
].
pBuf
=
NULL
;
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2237,16 +2240,15 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SEx
initResultSizeInfo
(
pOperator
,
4096
);
code
=
init
SessionAggSupporter
(
&
pInfo
->
streamAggSup
,
"StreamSessionAggOperatorInfo"
);
code
=
init
BiasicInfo
(
&
pInfo
->
binfo
,
pExprInfo
,
numOfCols
,
pResBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
code
=
init
BiasicInfo
(
&
pInfo
->
binfo
,
pExprInfo
,
numOfCols
,
pResBlock
,
pInfo
->
streamAggSup
.
pResultBuf
);
pInfo
->
streamAggSup
.
resultRowSize
=
getResultRowSize
(
pInfo
->
binfo
.
pCtx
,
numOfCols
);
code
=
init
SessionAggSupporter
(
&
pInfo
->
streamAggSup
,
"StreamSessionAggOperatorInfo"
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
pInfo
->
streamAggSup
.
resultRowSize
=
getResultRowSize
(
pInfo
->
binfo
.
pCtx
,
numOfCols
);
pInfo
->
pDummyCtx
=
(
SqlFunctionCtx
*
)
taosMemoryCalloc
(
numOfCols
,
sizeof
(
SqlFunctionCtx
));
if
(
pInfo
->
pDummyCtx
==
NULL
)
{
...
...
@@ -3101,6 +3103,7 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pPhyNode
->
pOutputDataBlockDesc
);
int32_t
tsSlotId
=
((
SColumnNode
*
)
pStateNode
->
window
.
pTspk
)
->
slotId
;
SColumnNode
*
pColNode
=
(
SColumnNode
*
)((
STargetNode
*
)
pStateNode
->
pStateKey
)
->
pExpr
;
int32_t
code
=
TSDB_CODE_OUT_OF_MEMORY
;
SStreamStateAggOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamStateAggOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
...
...
@@ -3121,17 +3124,18 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
.
winMap
=
NULL
,
};
initExecTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pTaskInfo
->
window
);
int32_t
code
=
initStateAggSupporter
(
&
pInfo
->
streamAggSup
,
"StreamStateAggOperatorInfo"
);
code
=
initBiasicInfo
(
&
pInfo
->
binfo
,
pExprInfo
,
numOfCols
,
pResBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
code
=
initBiasicInfo
(
&
pInfo
->
binfo
,
pExprInfo
,
numOfCols
,
pResBlock
,
pInfo
->
streamAggSup
.
pResultBuf
);
pInfo
->
streamAggSup
.
resultRowSize
=
getResultRowSize
(
pInfo
->
binfo
.
pCtx
,
numOfCols
);
code
=
initStateAggSupporter
(
&
pInfo
->
streamAggSup
,
"StreamStateAggOperatorInfo"
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
pInfo
->
streamAggSup
.
resultRowSize
=
getResultRowSize
(
pInfo
->
binfo
.
pCtx
,
numOfCols
);
pInfo
->
pDummyCtx
=
(
SqlFunctionCtx
*
)
taosMemoryCalloc
(
numOfCols
,
sizeof
(
SqlFunctionCtx
));
if
(
pInfo
->
pDummyCtx
==
NULL
)
{
goto
_error
;
...
...
source/libs/function/inc/builtinsimpl.h
浏览文件 @
a8da3cfd
...
...
@@ -85,6 +85,7 @@ int32_t apercentileFunction(SqlFunctionCtx *pCtx);
int32_t
apercentileFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
apercentileFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
apercentilePartialFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
apercentileCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
bool
getDiffFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
diffFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
...
...
source/libs/function/src/builtins.c
浏览文件 @
a8da3cfd
...
...
@@ -1241,7 +1241,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
getEnvFunc
=
getPercentileFuncEnv
,
.
initFunc
=
percentileFunctionSetup
,
.
processFunc
=
percentileFunction
,
.
finalizeFunc
=
percentileFinalize
.
finalizeFunc
=
percentileFinalize
,
.
invertFunc
=
NULL
,
.
combineFunc
=
NULL
,
},
{
.
name
=
"apercentile"
,
...
...
@@ -1252,6 +1254,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
initFunc
=
apercentileFunctionSetup
,
.
processFunc
=
apercentileFunction
,
.
finalizeFunc
=
apercentileFinalize
,
.
combineFunc
=
apercentileCombine
,
.
pPartialFunc
=
"_apercentile_partial"
,
.
pMergeFunc
=
"_apercentile_merge"
},
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
a8da3cfd
...
...
@@ -2217,6 +2217,26 @@ int32_t apercentilePartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
return
pResInfo
->
numOfRes
;
}
int32_t
apercentileCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
)
{
SResultRowEntryInfo
*
pDResInfo
=
GET_RES_INFO
(
pDestCtx
);
SAPercentileInfo
*
pDBuf
=
GET_ROWCELL_INTERBUF
(
pDResInfo
);
int32_t
type
=
pDestCtx
->
input
.
pData
[
0
]
->
info
.
type
;
SResultRowEntryInfo
*
pSResInfo
=
GET_RES_INFO
(
pSourceCtx
);
SAPercentileInfo
*
pSBuf
=
GET_ROWCELL_INTERBUF
(
pSResInfo
);
ASSERT
(
pDBuf
->
algo
==
pSBuf
->
algo
);
if
(
pDBuf
->
algo
==
APERCT_ALGO_TDIGEST
)
{
tdigestMerge
(
pDBuf
->
pTDigest
,
pSBuf
->
pTDigest
);
}
else
{
SHistogramInfo
*
pTmp
=
tHistogramMerge
(
pDBuf
->
pHisto
,
pSBuf
->
pHisto
,
MAX_HISTOGRAM_BIN
);
memcpy
(
pDBuf
->
pHisto
,
pTmp
,
sizeof
(
SHistogramInfo
)
+
sizeof
(
SHistBin
)
*
(
MAX_HISTOGRAM_BIN
+
1
));
pDBuf
->
pHisto
->
elems
=
(
SHistBin
*
)
((
char
*
)
pDBuf
->
pHisto
+
sizeof
(
SHistogramInfo
));
tHistogramDestroy
(
&
pTmp
);
}
pDResInfo
->
numOfRes
=
TMAX
(
pDResInfo
->
numOfRes
,
pSResInfo
->
numOfRes
);
return
TSDB_CODE_SUCCESS
;
}
bool
getFirstLastFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
)
{
SColumnNode
*
pNode
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
pEnv
->
calcMemSize
=
pNode
->
node
.
resType
.
bytes
+
sizeof
(
int64_t
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录