Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cdcb1a36
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看板
提交
cdcb1a36
编写于
7月 26, 2022
作者:
S
shenglian zhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add input ts order for join operator
上级
b870b638
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
47 addition
and
29 deletion
+47
-29
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-0
source/libs/executor/src/joinoperator.c
source/libs/executor/src/joinoperator.c
+46
-29
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
cdcb1a36
...
@@ -804,6 +804,7 @@ typedef struct STagFilterOperatorInfo {
...
@@ -804,6 +804,7 @@ typedef struct STagFilterOperatorInfo {
typedef
struct
SJoinOperatorInfo
{
typedef
struct
SJoinOperatorInfo
{
SSDataBlock
*
pRes
;
SSDataBlock
*
pRes
;
int32_t
joinType
;
int32_t
joinType
;
int32_t
inputTsOrder
;
SSDataBlock
*
pLeft
;
SSDataBlock
*
pLeft
;
int32_t
leftPos
;
int32_t
leftPos
;
...
...
source/libs/executor/src/joinoperator.c
浏览文件 @
cdcb1a36
...
@@ -77,6 +77,15 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
...
@@ -77,6 +77,15 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
pInfo
->
pCondAfterMerge
=
NULL
;
pInfo
->
pCondAfterMerge
=
NULL
;
}
}
pInfo
->
inputTsOrder
=
TSDB_ORDER_ASC
;
if
(
pJoinNode
->
inputTsOrder
==
ORDER_ASC
)
{
pInfo
->
inputTsOrder
=
TSDB_ORDER_ASC
;
}
else
if
(
pJoinNode
->
inputTsOrder
==
ORDER_DESC
)
{
pInfo
->
inputTsOrder
=
TSDB_ORDER_DESC
;
}
//TODO: remove this when JoinNode inputTsOrder is ready
pInfo
->
inputTsOrder
=
TSDB_ORDER_ASC
;
pOperator
->
fpSet
=
pOperator
->
fpSet
=
createOperatorFpSet
(
operatorDummyOpenFn
,
doMergeJoin
,
NULL
,
NULL
,
destroyMergeJoinOperator
,
NULL
,
NULL
,
NULL
);
createOperatorFpSet
(
operatorDummyOpenFn
,
doMergeJoin
,
NULL
,
NULL
,
destroyMergeJoinOperator
,
NULL
,
NULL
,
NULL
);
int32_t
code
=
appendDownstream
(
pOperator
,
pDownstream
,
numOfDownstream
);
int32_t
code
=
appendDownstream
(
pOperator
,
pDownstream
,
numOfDownstream
);
...
@@ -107,11 +116,42 @@ void destroyMergeJoinOperator(void* param, int32_t numOfOutput) {
...
@@ -107,11 +116,42 @@ void destroyMergeJoinOperator(void* param, int32_t numOfOutput) {
taosMemoryFreeClear
(
param
);
taosMemoryFreeClear
(
param
);
}
}
static
void
doJoinOneRow
(
struct
SOperatorInfo
*
pOperator
,
SSDataBlock
*
pRes
,
int32_t
currRow
)
{
SJoinOperatorInfo
*
pJoinInfo
=
pOperator
->
info
;
for
(
int32_t
i
=
0
;
i
<
pOperator
->
exprSupp
.
numOfExprs
;
++
i
)
{
SColumnInfoData
*
pDst
=
taosArrayGet
(
pRes
->
pDataBlock
,
i
);
SExprInfo
*
pExprInfo
=
&
pOperator
->
exprSupp
.
pExprInfo
[
i
];
int32_t
blockId
=
pExprInfo
->
base
.
pParam
[
0
].
pCol
->
dataBlockId
;
int32_t
slotId
=
pExprInfo
->
base
.
pParam
[
0
].
pCol
->
slotId
;
int32_t
rowIndex
=
-
1
;
SColumnInfoData
*
pSrc
=
NULL
;
if
(
pJoinInfo
->
pLeft
->
info
.
blockId
==
blockId
)
{
pSrc
=
taosArrayGet
(
pJoinInfo
->
pLeft
->
pDataBlock
,
slotId
);
rowIndex
=
pJoinInfo
->
leftPos
;
}
else
{
pSrc
=
taosArrayGet
(
pJoinInfo
->
pRight
->
pDataBlock
,
slotId
);
rowIndex
=
pJoinInfo
->
rightPos
;
}
if
(
colDataIsNull_s
(
pSrc
,
rowIndex
))
{
colDataAppendNULL
(
pDst
,
currRow
);
}
else
{
char
*
p
=
colDataGetData
(
pSrc
,
rowIndex
);
colDataAppend
(
pDst
,
currRow
,
p
,
false
);
}
}
}
static
void
doMergeJoinImpl
(
struct
SOperatorInfo
*
pOperator
,
SSDataBlock
*
pRes
)
{
static
void
doMergeJoinImpl
(
struct
SOperatorInfo
*
pOperator
,
SSDataBlock
*
pRes
)
{
SJoinOperatorInfo
*
pJoinInfo
=
pOperator
->
info
;
SJoinOperatorInfo
*
pJoinInfo
=
pOperator
->
info
;
int32_t
nrows
=
0
;
int32_t
nrows
=
pRes
->
info
.
rows
;
bool
asc
=
(
pJoinInfo
->
inputTsOrder
==
TSDB_ORDER_ASC
)
?
true
:
false
;
while
(
1
)
{
while
(
1
)
{
// todo extract method
// todo extract method
...
@@ -146,43 +186,20 @@ static void doMergeJoinImpl(struct SOperatorInfo* pOperator, SSDataBlock* pRes)
...
@@ -146,43 +186,20 @@ static void doMergeJoinImpl(struct SOperatorInfo* pOperator, SSDataBlock* pRes)
// only the timestamp match support for ordinary table
// only the timestamp match support for ordinary table
ASSERT
(
pLeftCol
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
ASSERT
(
pLeftCol
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
if
(
*
(
int64_t
*
)
pLeftVal
==
*
(
int64_t
*
)
pRightVal
)
{
if
(
*
(
int64_t
*
)
pLeftVal
==
*
(
int64_t
*
)
pRightVal
)
{
for
(
int32_t
i
=
0
;
i
<
pOperator
->
exprSupp
.
numOfExprs
;
++
i
)
{
doJoinOneRow
(
pOperator
,
pRes
,
nrows
);
SColumnInfoData
*
pDst
=
taosArrayGet
(
pRes
->
pDataBlock
,
i
);
SExprInfo
*
pExprInfo
=
&
pOperator
->
exprSupp
.
pExprInfo
[
i
];
int32_t
blockId
=
pExprInfo
->
base
.
pParam
[
0
].
pCol
->
dataBlockId
;
int32_t
slotId
=
pExprInfo
->
base
.
pParam
[
0
].
pCol
->
slotId
;
int32_t
rowIndex
=
-
1
;
SColumnInfoData
*
pSrc
=
NULL
;
if
(
pJoinInfo
->
pLeft
->
info
.
blockId
==
blockId
)
{
pSrc
=
taosArrayGet
(
pJoinInfo
->
pLeft
->
pDataBlock
,
slotId
);
rowIndex
=
pJoinInfo
->
leftPos
;
}
else
{
pSrc
=
taosArrayGet
(
pJoinInfo
->
pRight
->
pDataBlock
,
slotId
);
rowIndex
=
pJoinInfo
->
rightPos
;
}
if
(
colDataIsNull_s
(
pSrc
,
rowIndex
))
{
colDataAppendNULL
(
pDst
,
nrows
);
}
else
{
char
*
p
=
colDataGetData
(
pSrc
,
rowIndex
);
colDataAppend
(
pDst
,
nrows
,
p
,
false
);
}
}
pJoinInfo
->
leftPos
+=
1
;
pJoinInfo
->
leftPos
+=
1
;
pJoinInfo
->
rightPos
+=
1
;
pJoinInfo
->
rightPos
+=
1
;
nrows
+=
1
;
nrows
+=
1
;
}
else
if
(
*
(
int64_t
*
)
pLeftVal
<
*
(
int64_t
*
)
pRightVal
)
{
}
else
if
(
asc
&&
*
(
int64_t
*
)
pLeftVal
<
*
(
int64_t
*
)
pRightVal
||
!
asc
&&
*
(
int64_t
*
)
pLeftVal
>
*
(
int64_t
*
)
pRightVal
)
{
pJoinInfo
->
leftPos
+=
1
;
pJoinInfo
->
leftPos
+=
1
;
if
(
pJoinInfo
->
leftPos
>=
pJoinInfo
->
pLeft
->
info
.
rows
)
{
if
(
pJoinInfo
->
leftPos
>=
pJoinInfo
->
pLeft
->
info
.
rows
)
{
continue
;
continue
;
}
}
}
else
if
(
*
(
int64_t
*
)
pLeftVal
>
*
(
int64_t
*
)
pRightVal
)
{
}
else
if
(
asc
&&
*
(
int64_t
*
)
pLeftVal
>
*
(
int64_t
*
)
pRightVal
||
!
asc
&&
*
(
int64_t
*
)
pLeftVal
<
*
(
int64_t
*
)
pRightVal
)
{
pJoinInfo
->
rightPos
+=
1
;
pJoinInfo
->
rightPos
+=
1
;
if
(
pJoinInfo
->
rightPos
>=
pJoinInfo
->
pRight
->
info
.
rows
)
{
if
(
pJoinInfo
->
rightPos
>=
pJoinInfo
->
pRight
->
info
.
rows
)
{
continue
;
continue
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录