Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
66ec6e1a
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看板
未验证
提交
66ec6e1a
编写于
5月 19, 2023
作者:
D
dapan1121
提交者:
GitHub
5月 19, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21384 from taosdata/szhou/fix-eq-column
fix: join eq conditions optimization work on not only for tag
上级
8eacc51a
d77eefdc
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
84 addition
and
87 deletion
+84
-87
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+8
-8
source/libs/executor/src/joinoperator.c
source/libs/executor/src/joinoperator.c
+33
-33
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+2
-2
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+8
-8
source/libs/nodes/src/nodesMsgFuncs.c
source/libs/nodes/src/nodesMsgFuncs.c
+4
-4
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+7
-7
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+19
-22
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+3
-3
未找到文件。
include/libs/nodes/plannodes.h
浏览文件 @
66ec6e1a
...
...
@@ -112,7 +112,7 @@ typedef struct SJoinLogicNode {
SNode
*
pOnConditions
;
bool
isSingleTableJoin
;
EOrder
inputTsOrder
;
SNode
*
p
TagEqual
Conditions
;
SNode
*
p
ColEqualOn
Conditions
;
}
SJoinLogicNode
;
typedef
struct
SAggLogicNode
{
...
...
@@ -406,7 +406,7 @@ typedef struct SSortMergeJoinPhysiNode {
SNode
*
pOnConditions
;
SNodeList
*
pTargets
;
EOrder
inputTsOrder
;
SNode
*
p
TagEqualCond
tions
;
SNode
*
p
ColEqualOnCondi
tions
;
}
SSortMergeJoinPhysiNode
;
typedef
struct
SAggPhysiNode
{
...
...
@@ -448,7 +448,7 @@ typedef struct SMergePhysiNode {
bool
groupSort
;
}
SMergePhysiNode
;
typedef
struct
SWin
od
wPhysiNode
{
typedef
struct
SWin
do
wPhysiNode
{
SPhysiNode
node
;
SNodeList
*
pExprs
;
// these are expression list of parameter expression of function
SNodeList
*
pFuncs
;
...
...
@@ -461,10 +461,10 @@ typedef struct SWinodwPhysiNode {
EOrder
inputTsOrder
;
EOrder
outputTsOrder
;
bool
mergeDataBlock
;
}
SWin
od
wPhysiNode
;
}
SWin
do
wPhysiNode
;
typedef
struct
SIntervalPhysiNode
{
SWin
od
wPhysiNode
window
;
SWin
do
wPhysiNode
window
;
int64_t
interval
;
int64_t
offset
;
int64_t
sliding
;
...
...
@@ -497,7 +497,7 @@ typedef struct SMultiTableIntervalPhysiNode {
}
SMultiTableIntervalPhysiNode
;
typedef
struct
SSessionWinodwPhysiNode
{
SWin
od
wPhysiNode
window
;
SWin
do
wPhysiNode
window
;
int64_t
gap
;
}
SSessionWinodwPhysiNode
;
...
...
@@ -506,14 +506,14 @@ typedef SSessionWinodwPhysiNode SStreamSemiSessionWinodwPhysiNode;
typedef
SSessionWinodwPhysiNode
SStreamFinalSessionWinodwPhysiNode
;
typedef
struct
SStateWinodwPhysiNode
{
SWin
od
wPhysiNode
window
;
SWin
do
wPhysiNode
window
;
SNode
*
pStateKey
;
}
SStateWinodwPhysiNode
;
typedef
SStateWinodwPhysiNode
SStreamStateWinodwPhysiNode
;
typedef
struct
SEventWinodwPhysiNode
{
SWin
od
wPhysiNode
window
;
SWin
do
wPhysiNode
window
;
SNode
*
pStartCond
;
SNode
*
pEndCond
;
}
SEventWinodwPhysiNode
;
...
...
source/libs/executor/src/joinoperator.c
浏览文件 @
66ec6e1a
...
...
@@ -52,15 +52,15 @@ typedef struct SJoinOperatorInfo {
int32_t
rightPos
;
SColumnInfo
rightCol
;
SNode
*
pCondAfterMerge
;
SNode
*
p
TagEqual
Conditions
;
SNode
*
p
ColEqualOn
Conditions
;
SArray
*
left
Tag
Cols
;
char
*
left
Tag
KeyBuf
;
int32_t
left
Tag
KeyLen
;
SArray
*
left
EqOnCond
Cols
;
char
*
left
EqOnCond
KeyBuf
;
int32_t
left
EqOnCond
KeyLen
;
SArray
*
right
Tag
Cols
;
char
*
right
Tag
KeyBuf
;
int32_t
right
Tag
KeyLen
;
SArray
*
right
EqOnCond
Cols
;
char
*
right
EqOnCond
KeyBuf
;
int32_t
right
EqOnCond
KeyLen
;
SSHashObj
*
rightBuildTable
;
SJoinRowCtx
rowCtx
;
...
...
@@ -104,7 +104,7 @@ static void extractTimeCondition(SJoinOperatorInfo* pInfo, SOperatorInfo** pDown
setJoinColumnInfo
(
&
pInfo
->
rightCol
,
rightTsCol
);
}
static
void
extract
TagEqual
ColsFromOper
(
SJoinOperatorInfo
*
pInfo
,
SOperatorInfo
**
pDownstreams
,
SOperatorNode
*
pOperNode
,
static
void
extract
EqualOnCond
ColsFromOper
(
SJoinOperatorInfo
*
pInfo
,
SOperatorInfo
**
pDownstreams
,
SOperatorNode
*
pOperNode
,
SColumn
*
pLeft
,
SColumn
*
pRight
)
{
SColumnNode
*
pLeftNode
=
(
SColumnNode
*
)
pOperNode
->
pLeft
;
SColumnNode
*
pRightNode
=
(
SColumnNode
*
)
pOperNode
->
pRight
;
...
...
@@ -117,24 +117,24 @@ static void extractTagEqualColsFromOper(SJoinOperatorInfo* pInfo, SOperatorInfo*
}
}
static
void
extract
TagEqualCondCols
(
SJoinOperatorInfo
*
pInfo
,
SOperatorInfo
**
pDownStream
,
SNode
*
pTagEqual
Node
,
static
void
extract
EqualOnCondCols
(
SJoinOperatorInfo
*
pInfo
,
SOperatorInfo
**
pDownStream
,
SNode
*
pEqualOnCond
Node
,
SArray
*
leftTagEqCols
,
SArray
*
rightTagEqCols
)
{
SColumn
left
=
{
0
};
SColumn
right
=
{
0
};
if
(
nodeType
(
p
TagEqualNode
)
==
QUERY_NODE_LOGIC_CONDITION
&&
((
SLogicConditionNode
*
)
pTagEqual
Node
)
->
condType
==
LOGIC_COND_TYPE_AND
)
{
if
(
nodeType
(
p
EqualOnCondNode
)
==
QUERY_NODE_LOGIC_CONDITION
&&
((
SLogicConditionNode
*
)
pEqualOnCond
Node
)
->
condType
==
LOGIC_COND_TYPE_AND
)
{
SNode
*
pNode
=
NULL
;
FOREACH
(
pNode
,
((
SLogicConditionNode
*
)
p
TagEqual
Node
)
->
pParameterList
)
{
FOREACH
(
pNode
,
((
SLogicConditionNode
*
)
p
EqualOnCond
Node
)
->
pParameterList
)
{
SOperatorNode
*
pOperNode
=
(
SOperatorNode
*
)
pNode
;
extract
TagEqual
ColsFromOper
(
pInfo
,
pDownStream
,
pOperNode
,
&
left
,
&
right
);
extract
EqualOnCond
ColsFromOper
(
pInfo
,
pDownStream
,
pOperNode
,
&
left
,
&
right
);
taosArrayPush
(
leftTagEqCols
,
&
left
);
taosArrayPush
(
rightTagEqCols
,
&
right
);
}
return
;
}
if
(
nodeType
(
p
TagEqual
Node
)
==
QUERY_NODE_OPERATOR
)
{
SOperatorNode
*
pOperNode
=
(
SOperatorNode
*
)
p
TagEqual
Node
;
extract
TagEqual
ColsFromOper
(
pInfo
,
pDownStream
,
pOperNode
,
&
left
,
&
right
);
if
(
nodeType
(
p
EqualOnCond
Node
)
==
QUERY_NODE_OPERATOR
)
{
SOperatorNode
*
pOperNode
=
(
SOperatorNode
*
)
p
EqualOnCond
Node
;
extract
EqualOnCond
ColsFromOper
(
pInfo
,
pDownStream
,
pOperNode
,
&
left
,
&
right
);
taosArrayPush
(
leftTagEqCols
,
&
left
);
taosArrayPush
(
rightTagEqCols
,
&
right
);
}
...
...
@@ -259,13 +259,13 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
pInfo
->
inputOrder
=
TSDB_ORDER_DESC
;
}
pInfo
->
p
TagEqualConditions
=
pJoinNode
->
pTagEqualCond
tions
;
if
(
pInfo
->
p
TagEqual
Conditions
!=
NULL
)
{
pInfo
->
left
Tag
Cols
=
taosArrayInit
(
4
,
sizeof
(
SColumn
));
pInfo
->
right
Tag
Cols
=
taosArrayInit
(
4
,
sizeof
(
SColumn
));
extract
TagEqualCondCols
(
pInfo
,
pDownstream
,
pInfo
->
pTagEqualConditions
,
pInfo
->
leftTagCols
,
pInfo
->
rightTag
Cols
);
initTagColskeyBuf
(
&
pInfo
->
left
TagKeyLen
,
&
pInfo
->
leftTagKeyBuf
,
pInfo
->
leftTag
Cols
);
initTagColskeyBuf
(
&
pInfo
->
right
TagKeyLen
,
&
pInfo
->
rightTagKeyBuf
,
pInfo
->
rightTag
Cols
);
pInfo
->
p
ColEqualOnConditions
=
pJoinNode
->
pColEqualOnCondi
tions
;
if
(
pInfo
->
p
ColEqualOn
Conditions
!=
NULL
)
{
pInfo
->
left
EqOnCond
Cols
=
taosArrayInit
(
4
,
sizeof
(
SColumn
));
pInfo
->
right
EqOnCond
Cols
=
taosArrayInit
(
4
,
sizeof
(
SColumn
));
extract
EqualOnCondCols
(
pInfo
,
pDownstream
,
pInfo
->
pColEqualOnConditions
,
pInfo
->
leftEqOnCondCols
,
pInfo
->
rightEqOnCond
Cols
);
initTagColskeyBuf
(
&
pInfo
->
left
EqOnCondKeyLen
,
&
pInfo
->
leftEqOnCondKeyBuf
,
pInfo
->
leftEqOnCond
Cols
);
initTagColskeyBuf
(
&
pInfo
->
right
EqOnCondKeyLen
,
&
pInfo
->
rightEqOnCondKeyBuf
,
pInfo
->
rightEqOnCond
Cols
);
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
pInfo
->
rightBuildTable
=
tSimpleHashInit
(
256
,
hashFn
);
}
...
...
@@ -309,13 +309,13 @@ static void mergeJoinDestoryBuildTable(SSHashObj* pBuildTable) {
void
destroyMergeJoinOperator
(
void
*
param
)
{
SJoinOperatorInfo
*
pJoinOperator
=
(
SJoinOperatorInfo
*
)
param
;
if
(
pJoinOperator
->
p
TagEqual
Conditions
!=
NULL
)
{
if
(
pJoinOperator
->
p
ColEqualOn
Conditions
!=
NULL
)
{
mergeJoinDestoryBuildTable
(
pJoinOperator
->
rightBuildTable
);
taosMemoryFreeClear
(
pJoinOperator
->
right
Tag
KeyBuf
);
taosArrayDestroy
(
pJoinOperator
->
right
Tag
Cols
);
taosMemoryFreeClear
(
pJoinOperator
->
right
EqOnCond
KeyBuf
);
taosArrayDestroy
(
pJoinOperator
->
right
EqOnCond
Cols
);
taosMemoryFreeClear
(
pJoinOperator
->
left
Tag
KeyBuf
);
taosArrayDestroy
(
pJoinOperator
->
left
Tag
Cols
);
taosMemoryFreeClear
(
pJoinOperator
->
left
EqOnCond
KeyBuf
);
taosArrayDestroy
(
pJoinOperator
->
left
EqOnCond
Cols
);
}
nodesDestroyNode
(
pJoinOperator
->
pCondAfterMerge
);
...
...
@@ -439,12 +439,12 @@ static int32_t mergeJoinGetDownStreamRowsEqualTimeStamp(SOperatorInfo* pOperator
static
int32_t
mergeJoinFillBuildTable
(
SJoinOperatorInfo
*
pInfo
,
SArray
*
rightRowLocations
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
rightRowLocations
);
++
i
)
{
SRowLocation
*
rightRow
=
taosArrayGet
(
rightRowLocations
,
i
);
int32_t
keyLen
=
fillKeyBufFromTagCols
(
pInfo
->
right
TagCols
,
rightRow
->
pDataBlock
,
rightRow
->
pos
,
pInfo
->
rightTag
KeyBuf
);
SArray
**
ppRows
=
tSimpleHashGet
(
pInfo
->
rightBuildTable
,
pInfo
->
right
Tag
KeyBuf
,
keyLen
);
int32_t
keyLen
=
fillKeyBufFromTagCols
(
pInfo
->
right
EqOnCondCols
,
rightRow
->
pDataBlock
,
rightRow
->
pos
,
pInfo
->
rightEqOnCond
KeyBuf
);
SArray
**
ppRows
=
tSimpleHashGet
(
pInfo
->
rightBuildTable
,
pInfo
->
right
EqOnCond
KeyBuf
,
keyLen
);
if
(
!
ppRows
)
{
SArray
*
rows
=
taosArrayInit
(
4
,
sizeof
(
SRowLocation
));
taosArrayPush
(
rows
,
rightRow
);
tSimpleHashPut
(
pInfo
->
rightBuildTable
,
pInfo
->
right
Tag
KeyBuf
,
keyLen
,
&
rows
,
POINTER_BYTES
);
tSimpleHashPut
(
pInfo
->
rightBuildTable
,
pInfo
->
right
EqOnCond
KeyBuf
,
keyLen
,
&
rows
,
POINTER_BYTES
);
}
else
{
taosArrayPush
(
*
ppRows
,
rightRow
);
}
...
...
@@ -466,8 +466,8 @@ static int32_t mergeJoinLeftRowsRightRows(SOperatorInfo* pOperator, SSDataBlock*
SRowLocation
*
leftRow
=
taosArrayGet
(
leftRowLocations
,
i
);
SArray
*
pRightRows
=
NULL
;
if
(
useBuildTableTSRange
)
{
int32_t
keyLen
=
fillKeyBufFromTagCols
(
pJoinInfo
->
left
TagCols
,
leftRow
->
pDataBlock
,
leftRow
->
pos
,
pJoinInfo
->
leftTag
KeyBuf
);
SArray
**
ppRightRows
=
tSimpleHashGet
(
pJoinInfo
->
rightBuildTable
,
pJoinInfo
->
left
Tag
KeyBuf
,
keyLen
);
int32_t
keyLen
=
fillKeyBufFromTagCols
(
pJoinInfo
->
left
EqOnCondCols
,
leftRow
->
pDataBlock
,
leftRow
->
pos
,
pJoinInfo
->
leftEqOnCond
KeyBuf
);
SArray
**
ppRightRows
=
tSimpleHashGet
(
pJoinInfo
->
rightBuildTable
,
pJoinInfo
->
left
EqOnCond
KeyBuf
,
keyLen
);
if
(
!
ppRightRows
)
{
continue
;
}
...
...
@@ -567,7 +567,7 @@ static int32_t mergeJoinJoinDownstreamTsRanges(SOperatorInfo* pOperator, int64_t
pJoinInfo
->
leftPos
,
timestamp
,
leftRowLocations
,
leftCreatedBlocks
);
mergeJoinGetDownStreamRowsEqualTimeStamp
(
pOperator
,
1
,
pJoinInfo
->
rightCol
.
slotId
,
pJoinInfo
->
pRight
,
pJoinInfo
->
rightPos
,
timestamp
,
rightRowLocations
,
rightCreatedBlocks
);
if
(
pJoinInfo
->
p
TagEqual
Conditions
!=
NULL
&&
taosArrayGetSize
(
rightRowLocations
)
>
16
)
{
if
(
pJoinInfo
->
p
ColEqualOn
Conditions
!=
NULL
&&
taosArrayGetSize
(
rightRowLocations
)
>
16
)
{
mergeJoinFillBuildTable
(
pJoinInfo
,
rightRowLocations
);
rightUseBuildTable
=
true
;
taosArrayDestroy
(
rightRowLocations
);
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
66ec6e1a
...
...
@@ -401,7 +401,7 @@ static int32_t logicJoinCopy(const SJoinLogicNode* pSrc, SJoinLogicNode* pDst) {
COPY_SCALAR_FIELD
(
joinType
);
CLONE_NODE_FIELD
(
pMergeCondition
);
CLONE_NODE_FIELD
(
pOnConditions
);
CLONE_NODE_FIELD
(
p
TagEqual
Conditions
);
CLONE_NODE_FIELD
(
p
ColEqualOn
Conditions
);
COPY_SCALAR_FIELD
(
isSingleTableJoin
);
COPY_SCALAR_FIELD
(
inputTsOrder
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -588,7 +588,7 @@ static int32_t physiSysTableScanCopy(const SSystemTableScanPhysiNode* pSrc, SSys
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
physiWindowCopy
(
const
SWin
odwPhysiNode
*
pSrc
,
SWinod
wPhysiNode
*
pDst
)
{
static
int32_t
physiWindowCopy
(
const
SWin
dowPhysiNode
*
pSrc
,
SWindo
wPhysiNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
physiNodeCopy
);
CLONE_NODE_LIST_FIELD
(
pExprs
);
CLONE_NODE_LIST_FIELD
(
pFuncs
);
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
66ec6e1a
...
...
@@ -1416,7 +1416,7 @@ static int32_t jsonToLogicPlan(const SJson* pJson, void* pObj) {
static
const
char
*
jkJoinLogicPlanJoinType
=
"JoinType"
;
static
const
char
*
jkJoinLogicPlanOnConditions
=
"OnConditions"
;
static
const
char
*
jkJoinLogicPlanMergeCondition
=
"MergeConditions"
;
static
const
char
*
jkJoinLogicPlan
TagEqualConditions
=
"TagEqual
Conditions"
;
static
const
char
*
jkJoinLogicPlan
ColEqualOnConditions
=
"ColumnEqualOn
Conditions"
;
static
int32_t
logicJoinNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SJoinLogicNode
*
pNode
=
(
const
SJoinLogicNode
*
)
pObj
;
...
...
@@ -1432,7 +1432,7 @@ static int32_t logicJoinNodeToJson(const void* pObj, SJson* pJson) {
code
=
tjsonAddObject
(
pJson
,
jkJoinLogicPlanOnConditions
,
nodeToJson
,
pNode
->
pOnConditions
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkJoinLogicPlan
TagEqualConditions
,
nodeToJson
,
pNode
->
pTagEqual
Conditions
);
code
=
tjsonAddObject
(
pJson
,
jkJoinLogicPlan
ColEqualOnConditions
,
nodeToJson
,
pNode
->
pColEqualOn
Conditions
);
}
return
code
;
}
...
...
@@ -1451,7 +1451,7 @@ static int32_t jsonToLogicJoinNode(const SJson* pJson, void* pObj) {
code
=
jsonToNodeObject
(
pJson
,
jkJoinLogicPlanOnConditions
,
&
pNode
->
pOnConditions
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkJoinLogicPlan
TagEqualConditions
,
&
pNode
->
pTagEqual
Conditions
);
code
=
jsonToNodeObject
(
pJson
,
jkJoinLogicPlan
ColEqualOnConditions
,
&
pNode
->
pColEqualOn
Conditions
);
}
return
code
;
}
...
...
@@ -1883,7 +1883,7 @@ static const char* jkJoinPhysiPlanInputTsOrder = "InputTsOrder";
static
const
char
*
jkJoinPhysiPlanMergeCondition
=
"MergeCondition"
;
static
const
char
*
jkJoinPhysiPlanOnConditions
=
"OnConditions"
;
static
const
char
*
jkJoinPhysiPlanTargets
=
"Targets"
;
static
const
char
*
jkJoinPhysiPlan
TagEqualConditions
=
"TagEqual
Conditions"
;
static
const
char
*
jkJoinPhysiPlan
ColEqualOnConditions
=
"ColumnEqualOn
Conditions"
;
static
int32_t
physiJoinNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SSortMergeJoinPhysiNode
*
pNode
=
(
const
SSortMergeJoinPhysiNode
*
)
pObj
;
...
...
@@ -1905,7 +1905,7 @@ static int32_t physiJoinNodeToJson(const void* pObj, SJson* pJson) {
code
=
nodeListToJson
(
pJson
,
jkJoinPhysiPlanTargets
,
pNode
->
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkJoinPhysiPlan
TagEqualConditions
,
nodeToJson
,
pNode
->
pTagEqualCond
tions
);
code
=
tjsonAddObject
(
pJson
,
jkJoinPhysiPlan
ColEqualOnConditions
,
nodeToJson
,
pNode
->
pColEqualOnCondi
tions
);
}
return
code
;
}
...
...
@@ -1930,7 +1930,7 @@ static int32_t jsonToPhysiJoinNode(const SJson* pJson, void* pObj) {
code
=
jsonToNodeList
(
pJson
,
jkJoinPhysiPlanTargets
,
&
pNode
->
pTargets
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkJoinPhysiPlan
TagEqualConditions
,
&
pNode
->
pTagEqualCond
tions
);
code
=
jsonToNodeObject
(
pJson
,
jkJoinPhysiPlan
ColEqualOnConditions
,
&
pNode
->
pColEqualOnCondi
tions
);
}
return
code
;
}
...
...
@@ -2135,7 +2135,7 @@ static const char* jkWindowPhysiPlanOutputTsOrder = "outputTsOrder";
static
const
char
*
jkWindowPhysiPlanMergeDataBlock
=
"MergeDataBlock"
;
static
int32_t
physiWindowNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SWin
odwPhysiNode
*
pNode
=
(
const
SWinod
wPhysiNode
*
)
pObj
;
const
SWin
dowPhysiNode
*
pNode
=
(
const
SWindo
wPhysiNode
*
)
pObj
;
int32_t
code
=
physicPlanNodeToJson
(
pObj
,
pJson
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -2176,7 +2176,7 @@ static int32_t physiWindowNodeToJson(const void* pObj, SJson* pJson) {
}
static
int32_t
jsonToPhysiWindowNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SWin
odwPhysiNode
*
pNode
=
(
SWinod
wPhysiNode
*
)
pObj
;
SWin
dowPhysiNode
*
pNode
=
(
SWindo
wPhysiNode
*
)
pObj
;
int32_t
code
=
jsonToPhysicPlanNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
source/libs/nodes/src/nodesMsgFuncs.c
浏览文件 @
66ec6e1a
...
...
@@ -2341,7 +2341,7 @@ static int32_t physiJoinNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
code
=
tlvEncodeEnum
(
pEncoder
,
PHY_SORT_MERGE_JOIN_CODE_INPUT_TS_ORDER
,
pNode
->
inputTsOrder
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tlvEncodeObj
(
pEncoder
,
PHY_SORT_MERGE_JOIN_CODE_TAG_EQUAL_CONDITIONS
,
nodeToMsg
,
pNode
->
p
TagEqualCond
tions
);
code
=
tlvEncodeObj
(
pEncoder
,
PHY_SORT_MERGE_JOIN_CODE_TAG_EQUAL_CONDITIONS
,
nodeToMsg
,
pNode
->
p
ColEqualOnCondi
tions
);
}
return
code
;
}
...
...
@@ -2372,7 +2372,7 @@ static int32_t msgToPhysiJoinNode(STlvDecoder* pDecoder, void* pObj) {
code
=
tlvDecodeEnum
(
pTlv
,
&
pNode
->
inputTsOrder
,
sizeof
(
pNode
->
inputTsOrder
));
break
;
case
PHY_SORT_MERGE_JOIN_CODE_TAG_EQUAL_CONDITIONS
:
code
=
msgToNodeFromTlv
(
pTlv
,
(
void
**
)
&
pNode
->
p
TagEqualCond
tions
);
code
=
msgToNodeFromTlv
(
pTlv
,
(
void
**
)
&
pNode
->
p
ColEqualOnCondi
tions
);
break
;
default:
break
;
...
...
@@ -2639,7 +2639,7 @@ enum {
};
static
int32_t
physiWindowNodeToMsg
(
const
void
*
pObj
,
STlvEncoder
*
pEncoder
)
{
const
SWin
odwPhysiNode
*
pNode
=
(
const
SWinod
wPhysiNode
*
)
pObj
;
const
SWin
dowPhysiNode
*
pNode
=
(
const
SWindo
wPhysiNode
*
)
pObj
;
int32_t
code
=
tlvEncodeObj
(
pEncoder
,
PHY_WINDOW_CODE_BASE_NODE
,
physiNodeToMsg
,
&
pNode
->
node
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
@@ -2680,7 +2680,7 @@ static int32_t physiWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
}
static
int32_t
msgToPhysiWindowNode
(
STlvDecoder
*
pDecoder
,
void
*
pObj
)
{
SWin
odwPhysiNode
*
pNode
=
(
SWinod
wPhysiNode
*
)
pObj
;
SWin
dowPhysiNode
*
pNode
=
(
SWindo
wPhysiNode
*
)
pObj
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
STlv
*
pTlv
=
NULL
;
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
66ec6e1a
...
...
@@ -599,7 +599,7 @@ static void destroyPhysiNode(SPhysiNode* pNode) {
nodesDestroyNode
(
pNode
->
pSlimit
);
}
static
void
destroyWinodwPhysiNode
(
SWin
od
wPhysiNode
*
pNode
)
{
static
void
destroyWinodwPhysiNode
(
SWin
do
wPhysiNode
*
pNode
)
{
destroyPhysiNode
((
SPhysiNode
*
)
pNode
);
nodesDestroyList
(
pNode
->
pExprs
);
nodesDestroyList
(
pNode
->
pFuncs
);
...
...
@@ -1072,7 +1072,7 @@ void nodesDestroyNode(SNode* pNode) {
destroyLogicNode
((
SLogicNode
*
)
pLogicNode
);
nodesDestroyNode
(
pLogicNode
->
pMergeCondition
);
nodesDestroyNode
(
pLogicNode
->
pOnConditions
);
nodesDestroyNode
(
pLogicNode
->
p
TagEqual
Conditions
);
nodesDestroyNode
(
pLogicNode
->
p
ColEqualOn
Conditions
);
break
;
}
case
QUERY_NODE_LOGIC_PLAN_AGG
:
{
...
...
@@ -1205,7 +1205,7 @@ void nodesDestroyNode(SNode* pNode) {
nodesDestroyNode
(
pPhyNode
->
pMergeCondition
);
nodesDestroyNode
(
pPhyNode
->
pOnConditions
);
nodesDestroyList
(
pPhyNode
->
pTargets
);
nodesDestroyNode
(
pPhyNode
->
p
TagEqualCond
tions
);
nodesDestroyNode
(
pPhyNode
->
p
ColEqualOnCondi
tions
);
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_HASH_AGG
:
{
...
...
@@ -1243,7 +1243,7 @@ void nodesDestroyNode(SNode* pNode) {
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL
:
destroyWinodwPhysiNode
((
SWin
od
wPhysiNode
*
)
pNode
);
destroyWinodwPhysiNode
((
SWin
do
wPhysiNode
*
)
pNode
);
break
;
case
QUERY_NODE_PHYSICAL_PLAN_FILL
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_FILL
:
{
...
...
@@ -1259,19 +1259,19 @@ void nodesDestroyNode(SNode* pNode) {
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION
:
destroyWinodwPhysiNode
((
SWin
od
wPhysiNode
*
)
pNode
);
destroyWinodwPhysiNode
((
SWin
do
wPhysiNode
*
)
pNode
);
break
;
case
QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE
:
{
SStateWinodwPhysiNode
*
pPhyNode
=
(
SStateWinodwPhysiNode
*
)
pNode
;
destroyWinodwPhysiNode
((
SWin
od
wPhysiNode
*
)
pPhyNode
);
destroyWinodwPhysiNode
((
SWin
do
wPhysiNode
*
)
pPhyNode
);
nodesDestroyNode
(
pPhyNode
->
pStateKey
);
break
;
}
case
QUERY_NODE_PHYSICAL_PLAN_MERGE_EVENT
:
case
QUERY_NODE_PHYSICAL_PLAN_STREAM_EVENT
:
{
SEventWinodwPhysiNode
*
pPhyNode
=
(
SEventWinodwPhysiNode
*
)
pNode
;
destroyWinodwPhysiNode
((
SWin
od
wPhysiNode
*
)
pPhyNode
);
destroyWinodwPhysiNode
((
SWin
do
wPhysiNode
*
)
pPhyNode
);
nodesDestroyNode
(
pPhyNode
->
pStartCond
);
nodesDestroyNode
(
pPhyNode
->
pEndCond
);
break
;
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
66ec6e1a
...
...
@@ -740,18 +740,15 @@ static int32_t pushDownCondOptJoinExtractMergeCond(SOptimizeContext* pCxt, SJoin
return
code
;
}
static
bool
pushDownCondOptIsTa
g
(
SNode
*
pNode
,
SNodeList
*
pTableCols
)
{
static
bool
pushDownCondOptIsTa
bleColumn
(
SNode
*
pNode
,
SNodeList
*
pTableCols
)
{
if
(
QUERY_NODE_COLUMN
!=
nodeType
(
pNode
))
{
return
false
;
}
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
if
(
COLUMN_TYPE_TAG
!=
pCol
->
colType
)
{
return
false
;
}
return
pushDownCondOptBelongThisTable
(
pNode
,
pTableCols
);
}
static
bool
pushDownCondOptIs
TagEqual
Cond
(
SJoinLogicNode
*
pJoin
,
SNode
*
pCond
)
{
static
bool
pushDownCondOptIs
ColEqualOn
Cond
(
SJoinLogicNode
*
pJoin
,
SNode
*
pCond
)
{
if
(
QUERY_NODE_OPERATOR
!=
nodeType
(
pCond
))
{
return
false
;
}
...
...
@@ -770,53 +767,53 @@ static bool pushDownCondOptIsTagEqualCond(SJoinLogicNode* pJoin, SNode* pCond) {
}
SNodeList
*
pLeftCols
=
((
SLogicNode
*
)
nodesListGetNode
(
pJoin
->
node
.
pChildren
,
0
))
->
pTargets
;
SNodeList
*
pRightCols
=
((
SLogicNode
*
)
nodesListGetNode
(
pJoin
->
node
.
pChildren
,
1
))
->
pTargets
;
if
(
pushDownCondOptIsTa
g
(
pOper
->
pLeft
,
pLeftCols
))
{
return
pushDownCondOptIsTa
g
(
pOper
->
pRight
,
pRightCols
);
}
else
if
(
pushDownCondOptIsTa
g
(
pOper
->
pLeft
,
pRightCols
))
{
return
pushDownCondOptIsTa
g
(
pOper
->
pRight
,
pLeftCols
);
if
(
pushDownCondOptIsTa
bleColumn
(
pOper
->
pLeft
,
pLeftCols
))
{
return
pushDownCondOptIsTa
bleColumn
(
pOper
->
pRight
,
pRightCols
);
}
else
if
(
pushDownCondOptIsTa
bleColumn
(
pOper
->
pLeft
,
pRightCols
))
{
return
pushDownCondOptIsTa
bleColumn
(
pOper
->
pRight
,
pLeftCols
);
}
return
false
;
}
static
int32_t
pushDownCondOptJoinExtract
TagEqual
LogicCond
(
SJoinLogicNode
*
pJoin
)
{
static
int32_t
pushDownCondOptJoinExtract
ColEqualOn
LogicCond
(
SJoinLogicNode
*
pJoin
)
{
SLogicConditionNode
*
pLogicCond
=
(
SLogicConditionNode
*
)(
pJoin
->
pOnConditions
);
int32_t
code
=
TSDB_CODE_SUCCESS
;
SNodeList
*
p
TagEqual
Conds
=
NULL
;
SNodeList
*
p
EqualOn
Conds
=
NULL
;
SNode
*
pCond
=
NULL
;
FOREACH
(
pCond
,
pLogicCond
->
pParameterList
)
{
if
(
pushDownCondOptIs
TagEqual
Cond
(
pJoin
,
pCond
))
{
code
=
nodesListMakeAppend
(
&
p
TagEqual
Conds
,
nodesCloneNode
(
pCond
));
if
(
pushDownCondOptIs
ColEqualOn
Cond
(
pJoin
,
pCond
))
{
code
=
nodesListMakeAppend
(
&
p
EqualOn
Conds
,
nodesCloneNode
(
pCond
));
}
}
SNode
*
pTempTagEqCond
=
NULL
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesMergeConds
(
&
pTempTagEqCond
,
&
p
TagEqual
Conds
);
code
=
nodesMergeConds
(
&
pTempTagEqCond
,
&
p
EqualOn
Conds
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pJoin
->
p
TagEqual
Conditions
=
pTempTagEqCond
;
pJoin
->
p
ColEqualOn
Conditions
=
pTempTagEqCond
;
return
TSDB_CODE_SUCCESS
;
}
else
{
nodesDestroyList
(
p
TagEqual
Conds
);
nodesDestroyList
(
p
EqualOn
Conds
);
return
TSDB_CODE_PLAN_INTERNAL_ERROR
;
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
pushDownCondOptJoinExtract
TagEqual
Cond
(
SOptimizeContext
*
pCxt
,
SJoinLogicNode
*
pJoin
)
{
static
int32_t
pushDownCondOptJoinExtract
ColEqualOn
Cond
(
SOptimizeContext
*
pCxt
,
SJoinLogicNode
*
pJoin
)
{
if
(
NULL
==
pJoin
->
pOnConditions
)
{
pJoin
->
p
TagEqual
Conditions
=
NULL
;
pJoin
->
p
ColEqualOn
Conditions
=
NULL
;
return
TSDB_CODE_SUCCESS
;
}
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
pJoin
->
pOnConditions
)
&&
LOGIC_COND_TYPE_AND
==
((
SLogicConditionNode
*
)(
pJoin
->
pOnConditions
))
->
condType
)
{
return
pushDownCondOptJoinExtract
TagEqual
LogicCond
(
pJoin
);
return
pushDownCondOptJoinExtract
ColEqualOn
LogicCond
(
pJoin
);
}
if
(
pushDownCondOptIs
TagEqual
Cond
(
pJoin
,
pJoin
->
pOnConditions
))
{
pJoin
->
p
TagEqual
Conditions
=
nodesCloneNode
(
pJoin
->
pOnConditions
);
if
(
pushDownCondOptIs
ColEqualOn
Cond
(
pJoin
,
pJoin
->
pOnConditions
))
{
pJoin
->
p
ColEqualOn
Conditions
=
nodesCloneNode
(
pJoin
->
pOnConditions
);
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -857,7 +854,7 @@ static int32_t pushDownCondOptDealJoin(SOptimizeContext* pCxt, SJoinLogicNode* p
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
pushDownCondOptJoinExtract
TagEqual
Cond
(
pCxt
,
pJoin
);
code
=
pushDownCondOptJoinExtract
ColEqualOn
Cond
(
pCxt
,
pJoin
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
66ec6e1a
...
...
@@ -705,8 +705,8 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
pJoinLogicNode
->
pOnConditions
,
&
pJoin
->
pOnConditions
);
}
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pJoinLogicNode
->
p
TagEqual
Conditions
)
{
code
=
setNodeSlotId
(
pCxt
,
pLeftDesc
->
dataBlockId
,
pRightDesc
->
dataBlockId
,
pJoinLogicNode
->
p
TagEqualConditions
,
&
pJoin
->
pTagEqualCond
tions
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pJoinLogicNode
->
p
ColEqualOn
Conditions
)
{
code
=
setNodeSlotId
(
pCxt
,
pLeftDesc
->
dataBlockId
,
pRightDesc
->
dataBlockId
,
pJoinLogicNode
->
p
ColEqualOnConditions
,
&
pJoin
->
pColEqualOnCondi
tions
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
setConditionsSlotId
(
pCxt
,
(
const
SLogicNode
*
)
pJoinLogicNode
,
(
SPhysiNode
*
)
pJoin
);
...
...
@@ -1150,7 +1150,7 @@ static int32_t createExchangePhysiNode(SPhysiPlanContext* pCxt, SExchangeLogicNo
}
}
static
int32_t
createWindowPhysiNodeFinalize
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWin
od
wPhysiNode
*
pWindow
,
static
int32_t
createWindowPhysiNodeFinalize
(
SPhysiPlanContext
*
pCxt
,
SNodeList
*
pChildren
,
SWin
do
wPhysiNode
*
pWindow
,
SWindowLogicNode
*
pWindowLogicNode
)
{
pWindow
->
triggerType
=
pWindowLogicNode
->
triggerType
;
pWindow
->
watermark
=
pWindowLogicNode
->
watermark
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录