Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
61153b76
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看板
提交
61153b76
编写于
6月 17, 2022
作者:
5
54liuyao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(stream): distribute stream session plan
上级
21e9ef32
变更
11
显示空白变更内容
内联
并排
Showing
11 changed file
with
103 addition
and
48 deletion
+103
-48
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+1
-0
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+9
-3
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+4
-2
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+7
-12
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+19
-19
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+10
-1
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+8
-0
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+5
-0
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+2
-1
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+12
-5
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+26
-5
未找到文件。
include/libs/nodes/nodes.h
浏览文件 @
61153b76
...
...
@@ -227,6 +227,7 @@ typedef enum ENodeType {
QUERY_NODE_PHYSICAL_PLAN_FILL
,
QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION
,
QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE
,
...
...
include/libs/nodes/plannodes.h
浏览文件 @
61153b76
...
...
@@ -130,13 +130,17 @@ typedef struct SMergeLogicNode {
typedef
enum
EWindowType
{
WINDOW_TYPE_INTERVAL
=
1
,
WINDOW_TYPE_SESSION
,
WINDOW_TYPE_STATE
}
EWindowType
;
typedef
enum
E
Interval
Algorithm
{
typedef
enum
E
Window
Algorithm
{
INTERVAL_ALGO_HASH
=
1
,
INTERVAL_ALGO_MERGE
,
INTERVAL_ALGO_STREAM_FINAL
,
INTERVAL_ALGO_STREAM_SEMI
,
INTERVAL_ALGO_STREAM_SINGLE
,
}
EIntervalAlgorithm
;
SESSION_ALGO_STREAM_SEMI
,
SESSION_ALGO_STREAM_FINAL
,
SESSION_ALGO_STREAM_SINGLE
,
SESSION_ALGO_MERGE
,
}
EWindowAlgorithm
;
typedef
struct
SWindowLogicNode
{
SLogicNode
node
;
...
...
@@ -153,7 +157,7 @@ typedef struct SWindowLogicNode {
int8_t
triggerType
;
int64_t
watermark
;
double
filesFactor
;
E
IntervalAlgorithm
interval
Algo
;
E
WindowAlgorithm
window
Algo
;
}
SWindowLogicNode
;
typedef
struct
SFillLogicNode
{
...
...
@@ -371,6 +375,8 @@ typedef struct SSessionWinodwPhysiNode {
}
SSessionWinodwPhysiNode
;
typedef
SSessionWinodwPhysiNode
SStreamSessionWinodwPhysiNode
;
typedef
SSessionWinodwPhysiNode
SStreamSemiSessionWinodwPhysiNode
;
typedef
SSessionWinodwPhysiNode
SStreamFinalSessionWinodwPhysiNode
;
typedef
struct
SStateWinodwPhysiNode
{
SWinodwPhysiNode
window
;
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
61153b76
...
...
@@ -845,8 +845,10 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SExprInfo*
SOperatorInfo
*
createMergeJoinOperatorInfo
(
SOperatorInfo
**
pDownstream
,
int32_t
numOfDownstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SNode
*
pOnCondition
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createStreamSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
int64_t
gap
,
int32_t
tsSlotId
,
STimeWindowAggSupp
*
pTwAggSupp
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createStreamSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createStreamFinalSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
int32_t
numOfChild
);
SOperatorInfo
*
createStreamStateAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
61153b76
...
...
@@ -4728,18 +4728,13 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
pOptr
=
createSessionAggOperatorInfo
(
ops
[
0
],
pExprInfo
,
num
,
pResBlock
,
pSessionNode
->
gap
,
tsSlotId
,
&
as
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION
==
type
)
{
SSessionWinodwPhysiNode
*
pSessionNode
=
(
SSessionWinodwPhysiNode
*
)
pPhyNode
;
STimeWindowAggSupp
as
=
{.
waterMark
=
pSessionNode
->
window
.
watermark
,
.
calTrigger
=
pSessionNode
->
window
.
triggerType
};
SExprInfo
*
pExprInfo
=
createExprInfo
(
pSessionNode
->
window
.
pFuncs
,
NULL
,
&
num
);
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pPhyNode
->
pOutputDataBlockDesc
);
int32_t
tsSlotId
=
((
SColumnNode
*
)
pSessionNode
->
window
.
pTspk
)
->
slotId
;
pOptr
=
createStreamSessionAggOperatorInfo
(
ops
[
0
],
pExprInfo
,
num
,
pResBlock
,
pSessionNode
->
gap
,
tsSlotId
,
&
as
,
pTaskInfo
);
pOptr
=
createStreamSessionAggOperatorInfo
(
ops
[
0
],
pPhyNode
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION
==
type
)
{
int32_t
children
=
0
;
pOptr
=
createStreamFinalSessionAggOperatorInfo
(
ops
[
0
],
pPhyNode
,
pTaskInfo
,
children
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION
==
type
)
{
int32_t
children
=
1
;
pOptr
=
createStreamFinalSessionAggOperatorInfo
(
ops
[
0
],
pPhyNode
,
pTaskInfo
,
children
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_PARTITION
==
type
)
{
pOptr
=
createPartitionOperatorInfo
(
ops
[
0
],
(
SPartitionPhysiNode
*
)
pPhyNode
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE
==
type
)
{
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
61153b76
...
...
@@ -2425,9 +2425,12 @@ int32_t initSessionAggSupporter(SStreamAggSupporter* pSup, const char* pKey, Sql
return
initStreamAggSupporter
(
pSup
,
pKey
,
pCtx
,
numOfOutput
,
sizeof
(
SResultWindowInfo
));
}
SOperatorInfo
*
createStreamSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
int64_t
gap
,
int32_t
tsSlotId
,
STimeWindowAggSupp
*
pTwAggSupp
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createStreamSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
)
{
SSessionWinodwPhysiNode
*
pSessionNode
=
(
SSessionWinodwPhysiNode
*
)
pPhyNode
;
int32_t
numOfCols
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pSessionNode
->
window
.
pFuncs
,
NULL
,
&
numOfCols
);
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pPhyNode
->
pOutputDataBlockDesc
);
int32_t
tsSlotId
=
((
SColumnNode
*
)
pSessionNode
->
window
.
pTspk
)
->
slotId
;
int32_t
code
=
TSDB_CODE_OUT_OF_MEMORY
;
SStreamSessionAggOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamSessionAggOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
...
...
@@ -2453,12 +2456,14 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SEx
}
initDummyFunction
(
pInfo
->
pDummyCtx
,
pInfo
->
binfo
.
pCtx
,
numOfCols
);
pInfo
->
twAggSup
=
*
pTwAggSupp
;
pInfo
->
twAggSup
=
(
STimeWindowAggSupp
)
{.
waterMark
=
pSessionNode
->
window
.
watermark
,
.
calTrigger
=
pSessionNode
->
window
.
triggerType
,
.
maxTs
=
INT64_MIN
};
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
,
8
);
initExecTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pTaskInfo
->
window
);
pInfo
->
primaryTsIndex
=
tsSlotId
;
pInfo
->
gap
=
gap
;
pInfo
->
gap
=
pSessionNode
->
gap
;
pInfo
->
binfo
.
pRes
=
pResBlock
;
pInfo
->
order
=
TSDB_ORDER_ASC
;
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
...
...
@@ -2960,25 +2965,20 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
return
pBInfo
->
pRes
->
info
.
rows
==
0
?
NULL
:
pBInfo
->
pRes
;
}
SOperatorInfo
*
createStreamFinalSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
int64_t
gap
,
int32_t
tsSlotId
,
STimeWindowAggSupp
*
pTwAggSupp
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createStreamFinalSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
int32_t
numOfChild
)
{
int32_t
code
=
TSDB_CODE_OUT_OF_MEMORY
;
SStreamSessionAggOperatorInfo
*
pInfo
=
NULL
;
SOperatorInfo
*
pOperator
=
createStreamSessionAggOperatorInfo
(
downstream
,
pExprInfo
,
numOfCols
,
pResBlock
,
gap
,
tsSlotId
,
pTwAggSupp
,
pTaskInfo
);
SOperatorInfo
*
pOperator
=
createStreamSessionAggOperatorInfo
(
downstream
,
pPhyNode
,
pTaskInfo
);
if
(
pOperator
==
NULL
)
{
goto
_error
;
}
pOperator
->
name
=
"StreamFinalSessionWindowAggOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION
;
int32_t
numOfChild
=
1
;
// Todo(liuyao) get it from phy plan
pInfo
=
pOperator
->
info
;
SStreamSessionAggOperatorInfo
*
pInfo
=
pOperator
->
info
;
pInfo
->
pChildren
=
taosArrayInit
(
8
,
sizeof
(
void
*
));
for
(
int32_t
i
=
0
;
i
<
numOfChild
;
i
++
)
{
SOperatorInfo
*
pChild
=
createStreamSessionAggOperatorInfo
(
NULL
,
p
ExprInfo
,
numOfCols
,
NULL
,
gap
,
tsSlotId
,
pTwAggSupp
,
pTaskInfo
);
createStreamSessionAggOperatorInfo
(
NULL
,
p
PhyNode
,
pTaskInfo
);
if
(
pChild
==
NULL
)
{
goto
_error
;
}
...
...
@@ -2988,7 +2988,7 @@ SOperatorInfo* createStreamFinalSessionAggOperatorInfo(SOperatorInfo* downstream
_error:
if
(
pInfo
!=
NULL
)
{
destroyStreamSessionAggOperatorInfo
(
pInfo
,
numOfCol
s
);
destroyStreamSessionAggOperatorInfo
(
pInfo
,
pOperator
->
numOfExpr
s
);
}
taosMemoryFreeClear
(
pInfo
);
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
61153b76
...
...
@@ -427,7 +427,7 @@ static SNode* logicWindowCopy(const SWindowLogicNode* pSrc, SWindowLogicNode* pD
COPY_SCALAR_FIELD
(
triggerType
);
COPY_SCALAR_FIELD
(
watermark
);
COPY_SCALAR_FIELD
(
filesFactor
);
COPY_SCALAR_FIELD
(
interval
Algo
);
COPY_SCALAR_FIELD
(
window
Algo
);
return
(
SNode
*
)
pDst
;
}
...
...
@@ -538,6 +538,12 @@ static SNode* physiIntervalCopy(const SIntervalPhysiNode* pSrc, SIntervalPhysiNo
return
(
SNode
*
)
pDst
;
}
static
SNode
*
physiSessionCopy
(
const
SSessionWinodwPhysiNode
*
pSrc
,
SSessionWinodwPhysiNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
window
,
physiWindowCopy
);
COPY_SCALAR_FIELD
(
gap
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
dataBlockDescCopy
(
const
SDataBlockDescNode
*
pSrc
,
SDataBlockDescNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
dataBlockId
);
CLONE_NODE_LIST_FIELD
(
pSlots
);
...
...
@@ -678,6 +684,9 @@ SNode* nodesCloneNode(const SNode* pNode) {
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL
:
return
physiIntervalCopy
((
const
SIntervalPhysiNode
*
)
pNode
,
(
SIntervalPhysiNode
*
)
pDst
);
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION
:
return
physiSessionCopy
((
const
SSessionWinodwPhysiNode
*
)
pNode
,
(
SSessionWinodwPhysiNode
*
)
pDst
);
default:
break
;
}
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
61153b76
...
...
@@ -246,6 +246,10 @@ const char* nodesNodeName(ENodeType type) {
return
"PhysiSessionWindow"
;
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION
:
return
"PhysiStreamSessionWindow"
;
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION
:
return
"PhysiStreamSemiSessionWindow"
;
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION
:
return
"PhysiStreamFinalSessionWindow"
;
case
QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE
:
return
"PhysiStateWindow"
;
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE
:
...
...
@@ -3998,6 +4002,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
return
physiFillNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION
:
return
physiSessionWindowNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE
:
...
...
@@ -4131,6 +4137,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return
jsonToPhysiFillNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION
:
return
jsonToPhysiSessionWindowNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE
:
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
61153b76
...
...
@@ -287,6 +287,10 @@ SNode* nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SSessionWinodwPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION
:
return
makeNode
(
type
,
sizeof
(
SStreamSessionWinodwPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION
:
return
makeNode
(
type
,
sizeof
(
SStreamSemiSessionWinodwPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION
:
return
makeNode
(
type
,
sizeof
(
SStreamFinalSessionWinodwPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE
:
return
makeNode
(
type
,
sizeof
(
SStateWinodwPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE
:
...
...
@@ -804,6 +808,7 @@ void nodesDestroyNode(SNode* pNode) {
}
case
QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION
:
destroyWinodwPhysiNode
((
SWinodwPhysiNode
*
)
pNode
);
break
;
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
61153b76
...
...
@@ -548,6 +548,7 @@ static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionW
pWindow
->
winType
=
WINDOW_TYPE_SESSION
;
pWindow
->
sessionGap
=
((
SValueNode
*
)
pSession
->
pGap
)
->
datum
.
i
;
pWindow
->
windowAlgo
=
pCxt
->
pPlanCxt
->
streamQuery
?
SESSION_ALGO_STREAM_SINGLE
:
SESSION_ALGO_MERGE
;
pWindow
->
pTspk
=
nodesCloneNode
((
SNode
*
)
pSession
->
pCol
);
if
(
NULL
==
pWindow
->
pTspk
)
{
...
...
@@ -572,7 +573,7 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva
pWindow
->
sliding
=
(
NULL
!=
pInterval
->
pSliding
?
((
SValueNode
*
)
pInterval
->
pSliding
)
->
datum
.
i
:
pWindow
->
interval
);
pWindow
->
slidingUnit
=
(
NULL
!=
pInterval
->
pSliding
?
((
SValueNode
*
)
pInterval
->
pSliding
)
->
unit
:
pWindow
->
intervalUnit
);
pWindow
->
interval
Algo
=
pCxt
->
pPlanCxt
->
streamQuery
?
INTERVAL_ALGO_STREAM_SINGLE
:
INTERVAL_ALGO_HASH
;
pWindow
->
window
Algo
=
pCxt
->
pPlanCxt
->
streamQuery
?
INTERVAL_ALGO_STREAM_SINGLE
:
INTERVAL_ALGO_HASH
;
pWindow
->
pTspk
=
nodesCloneNode
(
pInterval
->
pCol
);
if
(
NULL
==
pWindow
->
pTspk
)
{
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
61153b76
...
...
@@ -977,8 +977,8 @@ static int32_t createWindowPhysiNodeFinalize(SPhysiPlanContext* pCxt, SNodeList*
return
code
;
}
static
ENodeType
getIntervalOperatorType
(
E
IntervalAlgorithm
interval
Algo
)
{
switch
(
interval
Algo
)
{
static
ENodeType
getIntervalOperatorType
(
E
WindowAlgorithm
window
Algo
)
{
switch
(
window
Algo
)
{
case
INTERVAL_ALGO_HASH
:
return
QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL
;
case
INTERVAL_ALGO_MERGE
:
...
...
@@ -989,6 +989,14 @@ static ENodeType getIntervalOperatorType(EIntervalAlgorithm intervalAlgo) {
return
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL
;
case
INTERVAL_ALGO_STREAM_SINGLE
:
return
QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL
;
case
SESSION_ALGO_STREAM_FINAL
:
return
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION
;
case
SESSION_ALGO_STREAM_SEMI
:
return
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION
;
case
SESSION_ALGO_STREAM_SINGLE
:
return
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION
;
case
SESSION_ALGO_MERGE
:
return
QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION
;
default:
break
;
}
...
...
@@ -998,7 +1006,7 @@ static ENodeType getIntervalOperatorType(EIntervalAlgorithm intervalAlgo) {
static
int32_t
createIntervalPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWindowLogicNode
*
pWindowLogicNode
,
SPhysiNode
**
pPhyNode
)
{
SIntervalPhysiNode
*
pInterval
=
(
SIntervalPhysiNode
*
)
makePhysiNode
(
pCxt
,
(
SLogicNode
*
)
pWindowLogicNode
,
getIntervalOperatorType
(
pWindowLogicNode
->
interval
Algo
));
pCxt
,
(
SLogicNode
*
)
pWindowLogicNode
,
getIntervalOperatorType
(
pWindowLogicNode
->
window
Algo
));
if
(
NULL
==
pInterval
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
...
...
@@ -1015,8 +1023,7 @@ static int32_t createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChil
static
int32_t
createSessionWindowPhysiNode
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWindowLogicNode
*
pWindowLogicNode
,
SPhysiNode
**
pPhyNode
)
{
SSessionWinodwPhysiNode
*
pSession
=
(
SSessionWinodwPhysiNode
*
)
makePhysiNode
(
pCxt
,
(
SLogicNode
*
)
pWindowLogicNode
,
(
pCxt
->
pPlanCxt
->
streamQuery
?
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION
:
QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION
));
pCxt
,
(
SLogicNode
*
)
pWindowLogicNode
,
getIntervalOperatorType
(
pWindowLogicNode
->
windowAlgo
));
if
(
NULL
==
pSession
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
61153b76
...
...
@@ -376,8 +376,8 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo
SLogicNode
*
pPartWindow
=
NULL
;
int32_t
code
=
stbSplCreatePartWindowNode
((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
,
&
pPartWindow
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
((
SWindowLogicNode
*
)
pPartWindow
)
->
interval
Algo
=
INTERVAL_ALGO_HASH
;
((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
interval
Algo
=
INTERVAL_ALGO_MERGE
;
((
SWindowLogicNode
*
)
pPartWindow
)
->
window
Algo
=
INTERVAL_ALGO_HASH
;
((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
window
Algo
=
INTERVAL_ALGO_MERGE
;
SNodeList
*
pMergeKeys
=
NULL
;
code
=
stbSplCreateMergeKeysByPrimaryKey
(((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
pTspk
,
&
pMergeKeys
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -400,8 +400,8 @@ static int32_t stbSplSplitIntervalForStream(SSplitContext* pCxt, SStableSplitInf
SLogicNode
*
pPartWindow
=
NULL
;
int32_t
code
=
stbSplCreatePartWindowNode
((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
,
&
pPartWindow
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
((
SWindowLogicNode
*
)
pPartWindow
)
->
interval
Algo
=
INTERVAL_ALGO_STREAM_SEMI
;
((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
interval
Algo
=
INTERVAL_ALGO_STREAM_FINAL
;
((
SWindowLogicNode
*
)
pPartWindow
)
->
window
Algo
=
INTERVAL_ALGO_STREAM_SEMI
;
((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
window
Algo
=
INTERVAL_ALGO_STREAM_FINAL
;
code
=
stbSplCreateExchangeNode
(
pCxt
,
pInfo
->
pSplitNode
,
pPartWindow
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -421,8 +421,29 @@ static int32_t stbSplSplitInterval(SSplitContext* pCxt, SStableSplitInfo* pInfo)
}
}
static
int32_t
stbSplSplitSessionForStream
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
SLogicNode
*
pPartWindow
=
NULL
;
int32_t
code
=
stbSplCreatePartWindowNode
((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
,
&
pPartWindow
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
((
SWindowLogicNode
*
)
pPartWindow
)
->
windowAlgo
=
SESSION_ALGO_STREAM_SEMI
;
((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
windowAlgo
=
SESSION_ALGO_STREAM_FINAL
;
code
=
stbSplCreateExchangeNode
(
pCxt
,
pInfo
->
pSplitNode
,
pPartWindow
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeStrictAppend
(
&
pInfo
->
pSubplan
->
pChildren
,
(
SNode
*
)
splCreateScanSubplan
(
pCxt
,
pPartWindow
,
SPLIT_FLAG_STABLE_SPLIT
));
}
pInfo
->
pSubplan
->
subplanType
=
SUBPLAN_TYPE_MERGE
;
++
(
pCxt
->
groupId
);
return
code
;
}
static
int32_t
stbSplSplitSession
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
if
(
pCxt
->
pPlanCxt
->
streamQuery
)
{
return
stbSplSplitSessionForStream
(
pCxt
,
pInfo
);
}
else
{
return
TSDB_CODE_PLAN_INTERNAL_ERROR
;
}
}
static
int32_t
stbSplSplitWindowNode
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录