Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a3343377
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看板
提交
a3343377
编写于
6月 27, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: merge and merge scan add group sort field
上级
732a91c9
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
77 addition
and
38 deletion
+77
-38
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+6
-3
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+2
-2
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+3
-2
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+20
-6
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+2
-2
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+7
-7
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+4
-2
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+33
-14
未找到文件。
include/libs/nodes/plannodes.h
浏览文件 @
a3343377
...
...
@@ -76,8 +76,8 @@ typedef struct SScanLogicNode {
int16_t
tsColId
;
double
filesFactor
;
SArray
*
pSmaIndexes
;
SNodeList
*
p
Part
Tags
;
bool
part
Sort
;
SNodeList
*
p
Group
Tags
;
bool
group
Sort
;
}
SScanLogicNode
;
typedef
struct
SJoinLogicNode
{
...
...
@@ -141,6 +141,7 @@ typedef struct SMergeLogicNode {
SNodeList
*
pInputs
;
int32_t
numOfChannels
;
int32_t
srcGroupId
;
bool
groupSort
;
}
SMergeLogicNode
;
typedef
enum
EWindowType
{
WINDOW_TYPE_INTERVAL
=
1
,
WINDOW_TYPE_SESSION
,
WINDOW_TYPE_STATE
}
EWindowType
;
...
...
@@ -284,7 +285,8 @@ typedef struct STableScanPhysiNode {
double
ratio
;
int32_t
dataRequired
;
SNodeList
*
pDynamicScanFuncs
;
SNodeList
*
pPartitionTags
;
SNodeList
*
pGroupTags
;
bool
groupSort
;
int64_t
interval
;
int64_t
offset
;
int64_t
sliding
;
...
...
@@ -358,6 +360,7 @@ typedef struct SMergePhysiNode {
SNodeList
*
pTargets
;
int32_t
numOfChannels
;
int32_t
srcGroupId
;
bool
groupSort
;
}
SMergePhysiNode
;
typedef
struct
SWinodwPhysiNode
{
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
a3343377
...
...
@@ -2051,7 +2051,7 @@ int32_t createScanTableListInfo(STableScanPhysiNode* pTableScanNode, SReadHandle
qDebug
(
"no table qualified for query, TID:0x%"
PRIx64
", QID:0x%"
PRIx64
,
taskId
,
queryId
);
return
TSDB_CODE_SUCCESS
;
}
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
pTableScanNode
->
p
Partition
Tags
);
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
pTableScanNode
->
p
Group
Tags
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -2455,7 +2455,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
goto
_error
;
}
if
(
pTableScanNode
->
p
Partition
Tags
)
{
if
(
pTableScanNode
->
p
Group
Tags
)
{
taosArraySort
(
pTableListInfo
->
pTableList
,
compareTableKeyInfoByGid
);
}
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
a3343377
...
...
@@ -351,7 +351,7 @@ static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) {
COPY_SCALAR_FIELD
(
watermark
);
COPY_SCALAR_FIELD
(
tsColId
);
COPY_SCALAR_FIELD
(
filesFactor
);
CLONE_NODE_LIST_FIELD
(
p
Part
Tags
);
CLONE_NODE_LIST_FIELD
(
p
Group
Tags
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -401,6 +401,7 @@ static int32_t logicMergeCopy(const SMergeLogicNode* pSrc, SMergeLogicNode* pDst
CLONE_NODE_LIST_FIELD
(
pInputs
);
COPY_SCALAR_FIELD
(
numOfChannels
);
COPY_SCALAR_FIELD
(
srcGroupId
);
COPY_SCALAR_FIELD
(
groupSort
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -501,7 +502,7 @@ static int32_t physiTableScanCopy(const STableScanPhysiNode* pSrc, STableScanPhy
COPY_SCALAR_FIELD
(
ratio
);
COPY_SCALAR_FIELD
(
dataRequired
);
CLONE_NODE_LIST_FIELD
(
pDynamicScanFuncs
);
CLONE_NODE_LIST_FIELD
(
p
Partition
Tags
);
CLONE_NODE_LIST_FIELD
(
p
Group
Tags
);
COPY_SCALAR_FIELD
(
interval
);
COPY_SCALAR_FIELD
(
offset
);
COPY_SCALAR_FIELD
(
sliding
);
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
a3343377
...
...
@@ -541,7 +541,7 @@ static const char* jkScanLogicPlanScanPseudoCols = "ScanPseudoCols";
static
const
char
*
jkScanLogicPlanTableId
=
"TableId"
;
static
const
char
*
jkScanLogicPlanTableType
=
"TableType"
;
static
const
char
*
jkScanLogicPlanTagCond
=
"TagCond"
;
static
const
char
*
jkScanLogicPlan
PartTags
=
"Part
Tags"
;
static
const
char
*
jkScanLogicPlan
GroupTags
=
"Group
Tags"
;
static
int32_t
logicScanNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SScanLogicNode
*
pNode
=
(
const
SScanLogicNode
*
)
pObj
;
...
...
@@ -563,7 +563,7 @@ static int32_t logicScanNodeToJson(const void* pObj, SJson* pJson) {
code
=
tjsonAddObject
(
pJson
,
jkScanLogicPlanTagCond
,
nodeToJson
,
pNode
->
pTagCond
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkScanLogicPlan
PartTags
,
pNode
->
pPart
Tags
);
code
=
nodeListToJson
(
pJson
,
jkScanLogicPlan
GroupTags
,
pNode
->
pGroup
Tags
);
}
return
code
;
...
...
@@ -590,7 +590,7 @@ static int32_t jsonToLogicScanNode(const SJson* pJson, void* pObj) {
code
=
jsonToNodeObject
(
pJson
,
jkScanLogicPlanTagCond
,
&
pNode
->
pTagCond
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkScanLogicPlan
PartTags
,
&
pNode
->
pPart
Tags
);
code
=
jsonToNodeList
(
pJson
,
jkScanLogicPlan
GroupTags
,
&
pNode
->
pGroup
Tags
);
}
return
code
;
...
...
@@ -1432,7 +1432,8 @@ static const char* jkTableScanPhysiPlanTriggerType = "triggerType";
static
const
char
*
jkTableScanPhysiPlanWatermark
=
"watermark"
;
static
const
char
*
jkTableScanPhysiPlanTsColId
=
"tsColId"
;
static
const
char
*
jkTableScanPhysiPlanFilesFactor
=
"FilesFactor"
;
static
const
char
*
jkTableScanPhysiPlanPartitionTags
=
"PartitionTags"
;
static
const
char
*
jkTableScanPhysiPlanGroupTags
=
"GroupTags"
;
static
const
char
*
jkTableScanPhysiPlanGroupSort
=
"GroupSort"
;
static
int32_t
physiTableScanNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
STableScanPhysiNode
*
pNode
=
(
const
STableScanPhysiNode
*
)
pObj
;
...
...
@@ -1487,7 +1488,10 @@ static int32_t physiTableScanNodeToJson(const void* pObj, SJson* pJson) {
code
=
tjsonAddDoubleToObject
(
pJson
,
jkTableScanPhysiPlanFilesFactor
,
pNode
->
filesFactor
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkTableScanPhysiPlanPartitionTags
,
pNode
->
pPartitionTags
);
code
=
nodeListToJson
(
pJson
,
jkTableScanPhysiPlanGroupTags
,
pNode
->
pGroupTags
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddBoolToObject
(
pJson
,
jkTableScanPhysiPlanGroupSort
,
pNode
->
groupSort
);
}
return
code
;
...
...
@@ -1546,7 +1550,10 @@ static int32_t jsonToPhysiTableScanNode(const SJson* pJson, void* pObj) {
code
=
tjsonGetDoubleValue
(
pJson
,
jkTableScanPhysiPlanFilesFactor
,
&
pNode
->
filesFactor
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkTableScanPhysiPlanPartitionTags
,
&
pNode
->
pPartitionTags
);
code
=
jsonToNodeList
(
pJson
,
jkTableScanPhysiPlanGroupTags
,
&
pNode
->
pGroupTags
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBoolValue
(
pJson
,
jkTableScanPhysiPlanGroupSort
,
&
pNode
->
groupSort
);
}
return
code
;
...
...
@@ -1727,6 +1734,7 @@ static const char* jkMergePhysiPlanMergeKeys = "MergeKeys";
static
const
char
*
jkMergePhysiPlanTargets
=
"Targets"
;
static
const
char
*
jkMergePhysiPlanNumOfChannels
=
"NumOfChannels"
;
static
const
char
*
jkMergePhysiPlanSrcGroupId
=
"SrcGroupId"
;
static
const
char
*
jkMergePhysiPlanGroupSort
=
"GroupSort"
;
static
int32_t
physiMergeNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SMergePhysiNode
*
pNode
=
(
const
SMergePhysiNode
*
)
pObj
;
...
...
@@ -1744,6 +1752,9 @@ static int32_t physiMergeNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkMergePhysiPlanSrcGroupId
,
pNode
->
srcGroupId
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddBoolToObject
(
pJson
,
jkMergePhysiPlanGroupSort
,
pNode
->
groupSort
);
}
return
code
;
}
...
...
@@ -1764,6 +1775,9 @@ static int32_t jsonToPhysiMergeNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetIntValue
(
pJson
,
jkMergePhysiPlanSrcGroupId
,
&
pNode
->
srcGroupId
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBoolValue
(
pJson
,
jkMergePhysiPlanGroupSort
,
&
pNode
->
groupSort
);
}
return
code
;
}
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
a3343377
...
...
@@ -711,7 +711,7 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyNode
(
pLogicNode
->
pTagCond
);
nodesDestroyNode
(
pLogicNode
->
pTagIndexCond
);
taosArrayDestroy
(
pLogicNode
->
pSmaIndexes
);
nodesDestroyList
(
pLogicNode
->
p
Part
Tags
);
nodesDestroyList
(
pLogicNode
->
p
Group
Tags
);
break
;
}
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
{
...
...
@@ -815,7 +815,7 @@ void nodesDestroyNode(SNode* pNode) {
STableScanPhysiNode
*
pPhyNode
=
(
STableScanPhysiNode
*
)
pNode
;
destroyScanPhysiNode
((
SScanPhysiNode
*
)
pNode
);
nodesDestroyList
(
pPhyNode
->
pDynamicScanFuncs
);
nodesDestroyList
(
pPhyNode
->
p
Partition
Tags
);
nodesDestroyList
(
pPhyNode
->
p
Group
Tags
);
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_PROJECT
:
{
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
a3343377
...
...
@@ -20,7 +20,7 @@
#define OPTIMIZE_FLAG_MASK(n) (1 << n)
#define OPTIMIZE_FLAG_
OSD
OPTIMIZE_FLAG_MASK(0)
#define OPTIMIZE_FLAG_
SCAN_PATH
OPTIMIZE_FLAG_MASK(0)
#define OPTIMIZE_FLAG_PUSH_DOWN_CONDE OPTIMIZE_FLAG_MASK(1)
#define OPTIMIZE_FLAG_SET_MASK(val, mask) (val) |= (mask)
...
...
@@ -91,7 +91,7 @@ static bool scanPathOptHaveNormalCol(SNodeList* pList) {
}
static
bool
scanPathOptMayBeOptimized
(
SLogicNode
*
pNode
)
{
if
(
OPTIMIZE_FLAG_TEST_MASK
(
pNode
->
optimizedFlag
,
OPTIMIZE_FLAG_
OSD
))
{
if
(
OPTIMIZE_FLAG_TEST_MASK
(
pNode
->
optimizedFlag
,
OPTIMIZE_FLAG_
SCAN_PATH
))
{
return
false
;
}
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
!=
nodeType
(
pNode
))
{
...
...
@@ -241,7 +241,7 @@ static int32_t scanPathOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
if
(
TSDB_CODE_SUCCESS
==
code
&&
(
NULL
!=
info
.
pDsoFuncs
||
NULL
!=
info
.
pSdrFuncs
))
{
info
.
pScan
->
dataRequired
=
scanPathOptGetDataRequired
(
info
.
pSdrFuncs
);
info
.
pScan
->
pDynamicScanFuncs
=
info
.
pDsoFuncs
;
OPTIMIZE_FLAG_SET_MASK
(
info
.
pScan
->
node
.
optimizedFlag
,
OPTIMIZE_FLAG_
OSD
);
OPTIMIZE_FLAG_SET_MASK
(
info
.
pScan
->
node
.
optimizedFlag
,
OPTIMIZE_FLAG_
SCAN_PATH
);
pCxt
->
optimized
=
true
;
}
nodesDestroyList
(
info
.
pSdrFuncs
);
...
...
@@ -1073,7 +1073,7 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
int32_t
code
=
TSDB_CODE_SUCCESS
;
SScanLogicNode
*
pScan
=
(
SScanLogicNode
*
)
nodesListGetNode
(
pNode
->
pChildren
,
0
);
if
(
QUERY_NODE_LOGIC_PLAN_PARTITION
==
nodeType
(
pNode
))
{
TSWAP
(((
SPartitionLogicNode
*
)
pNode
)
->
pPartitionKeys
,
pScan
->
p
Part
Tags
);
TSWAP
(((
SPartitionLogicNode
*
)
pNode
)
->
pPartitionKeys
,
pScan
->
p
Group
Tags
);
int32_t
code
=
replaceLogicNode
(
pLogicSubplan
,
pNode
,
(
SLogicNode
*
)
pScan
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
NODES_CLEAR_LIST
(
pNode
->
pChildren
);
...
...
@@ -1083,7 +1083,7 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
SNode
*
pGroupKey
=
NULL
;
FOREACH
(
pGroupKey
,
((
SAggLogicNode
*
)
pNode
)
->
pGroupKeys
)
{
code
=
nodesListMakeStrictAppend
(
&
pScan
->
p
Part
Tags
,
nodesCloneNode
(
nodesListGetNode
(((
SGroupingSetNode
*
)
pGroupKey
)
->
pParameterList
,
0
)));
&
pScan
->
p
Group
Tags
,
nodesCloneNode
(
nodesListGetNode
(((
SGroupingSetNode
*
)
pGroupKey
)
->
pParameterList
,
0
)));
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
...
...
@@ -1091,7 +1091,7 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
NODES_DESTORY_LIST
(((
SAggLogicNode
*
)
pNode
)
->
pGroupKeys
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
partTagsOptRebuildTbanme
(
pScan
->
p
Part
Tags
);
code
=
partTagsOptRebuildTbanme
(
pScan
->
p
Group
Tags
);
}
return
code
;
}
...
...
@@ -1212,7 +1212,7 @@ static bool rewriteTailOptNeedGroupSort(SIndefRowsFuncLogicNode* pIndef) {
}
SNode
*
pChild
=
nodesListGetNode
(
pIndef
->
node
.
pChildren
,
0
);
return
QUERY_NODE_LOGIC_PLAN_PARTITION
==
nodeType
(
pChild
)
||
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pChild
)
&&
NULL
!=
((
SScanLogicNode
*
)
pChild
)
->
p
Part
Tags
);
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pChild
)
&&
NULL
!=
((
SScanLogicNode
*
)
pChild
)
->
p
Group
Tags
);
}
static
int32_t
rewriteTailOptCreateSort
(
SIndefRowsFuncLogicNode
*
pIndef
,
SLogicNode
**
pOutput
)
{
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
a3343377
...
...
@@ -520,12 +520,13 @@ static int32_t createTableScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubp
tNameGetFullDbName
(
&
pScanLogicNode
->
tableName
,
pSubplan
->
dbFName
);
pTableScan
->
dataRequired
=
pScanLogicNode
->
dataRequired
;
pTableScan
->
pDynamicScanFuncs
=
nodesCloneList
(
pScanLogicNode
->
pDynamicScanFuncs
);
pTableScan
->
p
PartitionTags
=
nodesCloneList
(
pScanLogicNode
->
pPart
Tags
);
pTableScan
->
p
GroupTags
=
nodesCloneList
(
pScanLogicNode
->
pGroup
Tags
);
if
((
NULL
!=
pScanLogicNode
->
pDynamicScanFuncs
&&
NULL
==
pTableScan
->
pDynamicScanFuncs
)
||
(
NULL
!=
pScanLogicNode
->
p
PartTags
&&
NULL
==
pTableScan
->
pPartition
Tags
))
{
(
NULL
!=
pScanLogicNode
->
p
GroupTags
&&
NULL
==
pTableScan
->
pGroup
Tags
))
{
nodesDestroyNode
((
SNode
*
)
pTableScan
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pTableScan
->
groupSort
=
pScanLogicNode
->
groupSort
;
pTableScan
->
interval
=
pScanLogicNode
->
interval
;
pTableScan
->
offset
=
pScanLogicNode
->
offset
;
pTableScan
->
sliding
=
pScanLogicNode
->
sliding
;
...
...
@@ -1330,6 +1331,7 @@ static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SMergeLogicNode* pM
pMerge
->
numOfChannels
=
pMergeLogicNode
->
numOfChannels
;
pMerge
->
srcGroupId
=
pMergeLogicNode
->
srcGroupId
;
pMerge
->
groupSort
=
pMergeLogicNode
->
groupSort
;
int32_t
code
=
addDataBlockSlots
(
pCxt
,
pMergeLogicNode
->
pInputs
,
pMerge
->
node
.
pOutputDataBlockDesc
);
...
...
source/libs/planner/src/planSpliter.c
浏览文件 @
a3343377
...
...
@@ -362,7 +362,7 @@ static int32_t stbSplGetNumOfVgroups(SLogicNode* pNode) {
}
static
int32_t
stbSplCreateMergeNode
(
SSplitContext
*
pCxt
,
SLogicSubplan
*
pSubplan
,
SLogicNode
*
pSplitNode
,
SNodeList
*
pMergeKeys
,
SLogicNode
*
pPartChild
)
{
SNodeList
*
pMergeKeys
,
SLogicNode
*
pPartChild
,
bool
groupSort
)
{
SMergeLogicNode
*
pMerge
=
(
SMergeLogicNode
*
)
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_MERGE
);
if
(
NULL
==
pMerge
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
@@ -371,6 +371,7 @@ static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubpla
pMerge
->
srcGroupId
=
pCxt
->
groupId
;
pMerge
->
node
.
precision
=
pPartChild
->
precision
;
pMerge
->
pMergeKeys
=
pMergeKeys
;
pMerge
->
groupSort
=
groupSort
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
pMerge
->
pInputs
=
nodesCloneList
(
pPartChild
->
pTargets
);
...
...
@@ -430,7 +431,7 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo
SNodeList
*
pMergeKeys
=
NULL
;
code
=
stbSplCreateMergeKeysByPrimaryKey
(((
SWindowLogicNode
*
)
pInfo
->
pSplitNode
)
->
pTspk
,
&
pMergeKeys
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbSplCreateMergeNode
(
pCxt
,
NULL
,
pInfo
->
pSplitNode
,
pMergeKeys
,
pPartWindow
);
code
=
stbSplCreateMergeNode
(
pCxt
,
NULL
,
pInfo
->
pSplitNode
,
pMergeKeys
,
pPartWindow
,
false
);
}
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyList
(
pMergeKeys
);
...
...
@@ -497,12 +498,16 @@ static int32_t stbSplSplitSessionForStream(SSplitContext* pCxt, SStableSplitInfo
return
code
;
}
static
void
s
plSetTableScanType
(
SLogicNode
*
pNode
,
EScanType
scanTyp
e
)
{
static
void
s
tbSplSetTableMergeScan
(
SLogicNode
*
pNod
e
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
))
{
((
SScanLogicNode
*
)
pNode
)
->
scanType
=
scanType
;
SScanLogicNode
*
pScan
=
(
SScanLogicNode
*
)
pNode
;
pScan
->
scanType
=
SCAN_TYPE_TABLE_MERGE
;
if
(
NULL
!=
pScan
->
pGroupTags
)
{
pScan
->
groupSort
=
true
;
}
}
else
{
if
(
1
==
LIST_LENGTH
(
pNode
->
pChildren
))
{
s
plSetTableScanType
((
SLogicNode
*
)
nodesListGetNode
(
pNode
->
pChildren
,
0
),
scanType
);
s
tbSplSetTableMergeScan
((
SLogicNode
*
)
nodesListGetNode
(
pNode
->
pChildren
,
0
)
);
}
}
}
...
...
@@ -515,7 +520,7 @@ static int32_t stbSplSplitSessionOrStateForBatch(SSplitContext* pCxt, SStableSpl
int32_t
code
=
stbSplCreateMergeKeysByPrimaryKey
(((
SWindowLogicNode
*
)
pWindow
)
->
pTspk
,
&
pMergeKeys
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbSplCreateMergeNode
(
pCxt
,
pInfo
->
pSubplan
,
pChild
,
pMergeKeys
,
(
SLogicNode
*
)
pChild
);
code
=
stbSplCreateMergeNode
(
pCxt
,
pInfo
->
pSubplan
,
pChild
,
pMergeKeys
,
(
SLogicNode
*
)
pChild
,
true
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -524,13 +529,10 @@ static int32_t stbSplSplitSessionOrStateForBatch(SSplitContext* pCxt, SStableSpl
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
splSetTableScanType
(
pChild
,
SCAN_TYPE_TABLE_MERGE
);
++
(
pCxt
->
groupId
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
stbSplSetTableMergeScan
(
pChild
);
pInfo
->
pSubplan
->
subplanType
=
SUBPLAN_TYPE_MERGE
;
SPLIT_FLAG_SET_MASK
(
pInfo
->
pSubplan
->
splitFlag
,
SPLIT_FLAG_STABLE_SPLIT
);
++
(
pCxt
->
groupId
);
}
else
{
nodesDestroyList
(
pMergeKeys
);
}
...
...
@@ -560,7 +562,7 @@ static int32_t stbSplSplitState(SSplitContext* pCxt, SStableSplitInfo* pInfo) {
static
SNodeList
*
stbSplGetPartKeys
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
))
{
return
((
SScanLogicNode
*
)
pNode
)
->
p
Part
Tags
;
return
((
SScanLogicNode
*
)
pNode
)
->
p
Group
Tags
;
}
else
if
(
QUERY_NODE_LOGIC_PLAN_PARTITION
==
nodeType
(
pNode
))
{
return
((
SPartitionLogicNode
*
)
pNode
)
->
pPartitionKeys
;
}
else
{
...
...
@@ -790,12 +792,29 @@ static int32_t stbSplCreatePartSortNode(SSortLogicNode* pSort, SLogicNode** pOut
return
code
;
}
static
void
stbSplSetScanPartSort
(
SLogicNode
*
pNode
)
{
if
(
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
pNode
))
{
SScanLogicNode
*
pScan
=
(
SScanLogicNode
*
)
pNode
;
if
(
NULL
!=
pScan
->
pGroupTags
)
{
pScan
->
groupSort
=
true
;
}
}
else
{
if
(
1
==
LIST_LENGTH
(
pNode
->
pChildren
))
{
stbSplSetScanPartSort
((
SLogicNode
*
)
nodesListGetNode
(
pNode
->
pChildren
,
0
));
}
}
}
static
int32_t
stbSplSplitSortNode
(
SSplitContext
*
pCxt
,
SStableSplitInfo
*
pInfo
)
{
SLogicNode
*
pPartSort
=
NULL
;
SNodeList
*
pMergeKeys
=
NULL
;
bool
groupSort
=
((
SSortLogicNode
*
)
pInfo
->
pSplitNode
)
->
groupSort
;
int32_t
code
=
stbSplCreatePartSortNode
((
SSortLogicNode
*
)
pInfo
->
pSplitNode
,
&
pPartSort
,
&
pMergeKeys
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbSplCreateMergeNode
(
pCxt
,
pInfo
->
pSubplan
,
pInfo
->
pSplitNode
,
pMergeKeys
,
pPartSort
);
code
=
stbSplCreateMergeNode
(
pCxt
,
pInfo
->
pSubplan
,
pInfo
->
pSplitNode
,
pMergeKeys
,
pPartSort
,
groupSort
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
groupSort
)
{
stbSplSetScanPartSort
(
pPartSort
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeStrictAppend
(
&
pInfo
->
pSubplan
->
pChildren
,
...
...
@@ -830,7 +849,7 @@ static int32_t stbSplSplitScanNodeForJoin(SSplitContext* pCxt, SLogicSubplan* pS
SNodeList
*
pMergeKeys
=
NULL
;
int32_t
code
=
stbSplCreateMergeKeysByPrimaryKey
(
stbSplFindPrimaryKeyFromScan
(
pScan
),
&
pMergeKeys
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
stbSplCreateMergeNode
(
pCxt
,
pSubplan
,
(
SLogicNode
*
)
pScan
,
pMergeKeys
,
(
SLogicNode
*
)
pScan
);
code
=
stbSplCreateMergeNode
(
pCxt
,
pSubplan
,
(
SLogicNode
*
)
pScan
,
pMergeKeys
,
(
SLogicNode
*
)
pScan
,
false
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListMakeStrictAppend
(
&
pSubplan
->
pChildren
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录