Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0ff775c4
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
0ff775c4
编写于
7月 29, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): keep order info in fill operator.
上级
547ab702
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
51 addition
and
54 deletion
+51
-54
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+3
-4
source/libs/executor/inc/tfill.h
source/libs/executor/inc/tfill.h
+1
-2
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+4
-5
source/libs/executor/src/joinoperator.c
source/libs/executor/src/joinoperator.c
+4
-4
source/libs/executor/src/tfill.c
source/libs/executor/src/tfill.c
+2
-1
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+37
-38
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
0ff775c4
...
...
@@ -523,8 +523,8 @@ typedef struct SIntervalAggOperatorInfo {
STimeWindow
win
;
// query time range
bool
timeWindowInterpo
;
// interpolation needed or not
SArray
*
pInterpCols
;
// interpolation columns
int32_t
order
;
// current SSDataBlock scan order
int32_t
resultTsOrder
;
// result timestamp order
int32_t
inputOrder
;
// input data ts order
EOPTR_EXEC_MODEL
execModel
;
// operator execution model [batch model|stream model]
STimeWindowAggSupp
twAggSup
;
bool
invertible
;
...
...
@@ -534,8 +534,7 @@ typedef struct SIntervalAggOperatorInfo {
SArray
*
pDelWins
;
// SWinRes
int32_t
delIndex
;
SSDataBlock
*
pDelRes
;
SNode
*
pCondition
;
SNode
*
pCondition
;
}
SIntervalAggOperatorInfo
;
typedef
struct
SMergeAlignedIntervalAggOperatorInfo
{
...
...
@@ -805,7 +804,7 @@ typedef struct STagFilterOperatorInfo {
typedef
struct
SJoinOperatorInfo
{
SSDataBlock
*
pRes
;
int32_t
joinType
;
int32_t
input
Ts
Order
;
int32_t
inputOrder
;
SSDataBlock
*
pLeft
;
int32_t
leftPos
;
...
...
source/libs/executor/inc/tfill.h
浏览文件 @
0ff775c4
...
...
@@ -76,10 +76,9 @@ bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
SFillInfo
*
taosCreateFillInfo
(
TSKEY
skey
,
int32_t
numOfTags
,
int32_t
capacity
,
int32_t
numOfCols
,
SInterval
*
pInterval
,
int32_t
fillType
,
struct
SFillColInfo
*
pCol
,
int32_t
slotId
,
const
char
*
id
);
int32_t
order
,
const
char
*
id
);
void
*
taosDestroyFillInfo
(
struct
SFillInfo
*
pFillInfo
);
void
taosFillSetDataOrderInfo
(
SFillInfo
*
pFillInfo
,
int32_t
order
);
int64_t
taosFillResultDataBlock
(
struct
SFillInfo
*
pFillInfo
,
SSDataBlock
*
p
,
int32_t
capacity
);
int64_t
getFillInfoStart
(
struct
SFillInfo
*
pFillInfo
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
0ff775c4
...
...
@@ -3234,8 +3234,6 @@ static SSDataBlock* doFillImpl(SOperatorInfo* pOperator) {
return
pResBlock
;
}
taosFillSetDataOrderInfo
(
pInfo
->
pFillInfo
,
TSDB_ORDER_ASC
);
SOperatorInfo
*
pDownstream
=
pOperator
->
pDownstream
[
0
];
while
(
1
)
{
SSDataBlock
*
pBlock
=
pDownstream
->
fpSet
.
getNextFn
(
pDownstream
);
...
...
@@ -3588,14 +3586,14 @@ void doDestroyExchangeOperatorInfo(void* param) {
}
static
int32_t
initFillInfo
(
SFillOperatorInfo
*
pInfo
,
SExprInfo
*
pExpr
,
int32_t
numOfCols
,
SNodeListNode
*
pValNode
,
STimeWindow
win
,
int32_t
capacity
,
const
char
*
id
,
SInterval
*
pInterval
,
int32_t
fillType
)
{
STimeWindow
win
,
int32_t
capacity
,
const
char
*
id
,
SInterval
*
pInterval
,
int32_t
fillType
,
int32_t
order
)
{
SFillColInfo
*
pColInfo
=
createFillColInfo
(
pExpr
,
numOfCols
,
pValNode
);
STimeWindow
w
=
getAlignQueryTimeWindow
(
pInterval
,
pInterval
->
precision
,
win
.
skey
);
w
=
getFirstQualifiedTimeWindow
(
win
.
skey
,
&
w
,
pInterval
,
TSDB_ORDER_ASC
);
pInfo
->
pFillInfo
=
taosCreateFillInfo
(
w
.
skey
,
0
,
capacity
,
numOfCols
,
pInterval
,
fillType
,
pColInfo
,
pInfo
->
primaryTsCol
,
id
);
taosCreateFillInfo
(
w
.
skey
,
0
,
capacity
,
numOfCols
,
pInterval
,
fillType
,
pColInfo
,
pInfo
->
primaryTsCol
,
order
,
id
);
pInfo
->
win
=
win
;
pInfo
->
p
=
taosMemoryCalloc
(
numOfCols
,
POINTER_BYTES
);
...
...
@@ -3625,6 +3623,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
?
&
((
SMergeAlignedIntervalAggOperatorInfo
*
)
downstream
->
info
)
->
intervalAggOperatorInfo
->
interval
:
&
((
SIntervalAggOperatorInfo
*
)
downstream
->
info
)
->
interval
;
int32_t
order
=
(
pPhyFillNode
->
inputTsOrder
==
ORDER_ASC
)
?
TSDB_ORDER_ASC
:
TSDB_ORDER_DESC
;
int32_t
type
=
convertFillType
(
pPhyFillNode
->
mode
);
SResultInfo
*
pResultInfo
=
&
pOperator
->
resultInfo
;
...
...
@@ -3636,7 +3635,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
&
numOfOutputCols
,
COL_MATCH_FROM_SLOT_ID
);
int32_t
code
=
initFillInfo
(
pInfo
,
pExprInfo
,
num
,
(
SNodeListNode
*
)
pPhyFillNode
->
pValues
,
pPhyFillNode
->
timeRange
,
pResultInfo
->
capacity
,
pTaskInfo
->
id
.
str
,
pInterval
,
type
);
pResultInfo
->
capacity
,
pTaskInfo
->
id
.
str
,
pInterval
,
type
,
order
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
source/libs/executor/src/joinoperator.c
浏览文件 @
0ff775c4
...
...
@@ -77,11 +77,11 @@ SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t
pInfo
->
pCondAfterMerge
=
NULL
;
}
pInfo
->
input
Ts
Order
=
TSDB_ORDER_ASC
;
pInfo
->
inputOrder
=
TSDB_ORDER_ASC
;
if
(
pJoinNode
->
inputTsOrder
==
ORDER_ASC
)
{
pInfo
->
input
Ts
Order
=
TSDB_ORDER_ASC
;
pInfo
->
inputOrder
=
TSDB_ORDER_ASC
;
}
else
if
(
pJoinNode
->
inputTsOrder
==
ORDER_DESC
)
{
pInfo
->
input
Ts
Order
=
TSDB_ORDER_DESC
;
pInfo
->
inputOrder
=
TSDB_ORDER_DESC
;
}
pOperator
->
fpSet
=
...
...
@@ -312,7 +312,7 @@ static void doMergeJoinImpl(struct SOperatorInfo* pOperator, SSDataBlock* pRes)
int32_t
nrows
=
pRes
->
info
.
rows
;
bool
asc
=
(
pJoinInfo
->
input
Ts
Order
==
TSDB_ORDER_ASC
)
?
true
:
false
;
bool
asc
=
(
pJoinInfo
->
inputOrder
==
TSDB_ORDER_ASC
)
?
true
:
false
;
while
(
1
)
{
int64_t
leftTs
=
0
;
...
...
source/libs/executor/src/tfill.c
浏览文件 @
0ff775c4
...
...
@@ -435,7 +435,7 @@ static int32_t taosNumOfRemainRows(SFillInfo* pFillInfo) {
struct
SFillInfo
*
taosCreateFillInfo
(
TSKEY
skey
,
int32_t
numOfTags
,
int32_t
capacity
,
int32_t
numOfCols
,
SInterval
*
pInterval
,
int32_t
fillType
,
struct
SFillColInfo
*
pCol
,
int32_t
primaryTsSlotId
,
const
char
*
id
)
{
int32_t
primaryTsSlotId
,
int32_t
order
,
const
char
*
id
)
{
if
(
fillType
==
TSDB_FILL_NONE
)
{
return
NULL
;
}
...
...
@@ -446,6 +446,7 @@ struct SFillInfo* taosCreateFillInfo(TSKEY skey, int32_t numOfTags, int32_t capa
return
NULL
;
}
pFillInfo
->
order
=
order
;
pFillInfo
->
tsSlotId
=
primaryTsSlotId
;
taosResetFillInfo
(
pFillInfo
,
skey
);
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
0ff775c4
...
...
@@ -362,7 +362,7 @@ static void setNotInterpoWindowKey(SqlFunctionCtx* pCtx, int32_t numOfOutput, in
static
bool
setTimeWindowInterpolationStartTs
(
SIntervalAggOperatorInfo
*
pInfo
,
int32_t
pos
,
SSDataBlock
*
pBlock
,
const
TSKEY
*
tsCols
,
STimeWindow
*
win
,
SExprSupp
*
pSup
)
{
bool
ascQuery
=
(
pInfo
->
o
rder
==
TSDB_ORDER_ASC
);
bool
ascQuery
=
(
pInfo
->
inputO
rder
==
TSDB_ORDER_ASC
);
TSKEY
curTs
=
tsCols
[
pos
];
...
...
@@ -392,7 +392,7 @@ static bool setTimeWindowInterpolationStartTs(SIntervalAggOperatorInfo* pInfo, i
static
bool
setTimeWindowInterpolationEndTs
(
SIntervalAggOperatorInfo
*
pInfo
,
SExprSupp
*
pSup
,
int32_t
endRowIndex
,
SArray
*
pDataBlock
,
const
TSKEY
*
tsCols
,
TSKEY
blockEkey
,
STimeWindow
*
win
)
{
int32_t
order
=
pInfo
->
o
rder
;
int32_t
order
=
pInfo
->
inputO
rder
;
TSKEY
actualEndKey
=
tsCols
[
endRowIndex
];
TSKEY
key
=
(
order
==
TSDB_ORDER_ASC
)
?
win
->
ekey
:
win
->
skey
;
...
...
@@ -550,7 +550,7 @@ static void doWindowBorderInterpolation(SIntervalAggOperatorInfo* pInfo, SSDataB
if
(
!
done
)
{
int32_t
endRowIndex
=
startPos
+
forwardRows
-
1
;
TSKEY
endKey
=
(
pInfo
->
o
rder
==
TSDB_ORDER_ASC
)
?
pBlock
->
info
.
window
.
ekey
:
pBlock
->
info
.
window
.
skey
;
TSKEY
endKey
=
(
pInfo
->
inputO
rder
==
TSDB_ORDER_ASC
)
?
pBlock
->
info
.
window
.
ekey
:
pBlock
->
info
.
window
.
skey
;
bool
interp
=
setTimeWindowInterpolationEndTs
(
pInfo
,
pSup
,
endRowIndex
,
pBlock
->
pDataBlock
,
tsCols
,
endKey
,
win
);
if
(
interp
)
{
setResultRowInterpo
(
pResult
,
RESULT_ROW_END_INTERP
);
...
...
@@ -639,7 +639,7 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
setNotInterpoWindowKey
(
pSup
->
pCtx
,
numOfExprs
,
RESULT_ROW_START_INTERP
);
doApplyFunctions
(
pTaskInfo
,
pSup
->
pCtx
,
&
w
,
&
pInfo
->
twAggSup
.
timeWindowData
,
startPos
,
0
,
tsCols
,
pBlock
->
info
.
rows
,
numOfExprs
,
pInfo
->
o
rder
);
numOfExprs
,
pInfo
->
inputO
rder
);
if
(
isResultRowInterpolated
(
pResult
,
RESULT_ROW_END_INTERP
))
{
closeResultRow
(
pr
);
...
...
@@ -924,11 +924,11 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
int32_t
numOfOutput
=
pSup
->
numOfExprs
;
int64_t
*
tsCols
=
extractTsCol
(
pBlock
,
pInfo
);
uint64_t
tableGroupId
=
pBlock
->
info
.
groupId
;
bool
ascScan
=
(
pInfo
->
o
rder
==
TSDB_ORDER_ASC
);
bool
ascScan
=
(
pInfo
->
inputO
rder
==
TSDB_ORDER_ASC
);
TSKEY
ts
=
getStartTsKey
(
&
pBlock
->
info
.
window
,
tsCols
);
SResultRow
*
pResult
=
NULL
;
STimeWindow
win
=
getActiveTimeWindow
(
pInfo
->
aggSup
.
pResultBuf
,
pResultRowInfo
,
ts
,
&
pInfo
->
interval
,
pInfo
->
o
rder
);
STimeWindow
win
=
getActiveTimeWindow
(
pInfo
->
aggSup
.
pResultBuf
,
pResultRowInfo
,
ts
,
&
pInfo
->
interval
,
pInfo
->
inputO
rder
);
int32_t
ret
=
TSDB_CODE_SUCCESS
;
if
((
!
pInfo
->
ignoreExpiredData
||
!
isCloseWindow
(
&
win
,
&
pInfo
->
twAggSup
))
&&
inSlidingWindow
(
&
pInfo
->
interval
,
&
win
,
&
pBlock
->
info
))
{
...
...
@@ -946,7 +946,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
TSKEY
ekey
=
ascScan
?
win
.
ekey
:
win
.
skey
;
int32_t
forwardRows
=
getNumOfRowsInTimeWindow
(
&
pBlock
->
info
,
tsCols
,
startPos
,
ekey
,
binarySearchForKey
,
NULL
,
pInfo
->
o
rder
);
getNumOfRowsInTimeWindow
(
&
pBlock
->
info
,
tsCols
,
startPos
,
ekey
,
binarySearchForKey
,
NULL
,
pInfo
->
inputO
rder
);
ASSERT
(
forwardRows
>
0
);
// prev time window not interpolation yet.
...
...
@@ -969,7 +969,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
inSlidingWindow
(
&
pInfo
->
interval
,
&
win
,
&
pBlock
->
info
))
{
updateTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
win
,
true
);
doApplyFunctions
(
pTaskInfo
,
pSup
->
pCtx
,
&
win
,
&
pInfo
->
twAggSup
.
timeWindowData
,
startPos
,
forwardRows
,
tsCols
,
pBlock
->
info
.
rows
,
numOfOutput
,
pInfo
->
o
rder
);
pBlock
->
info
.
rows
,
numOfOutput
,
pInfo
->
inputO
rder
);
}
doCloseWindow
(
pResultRowInfo
,
pInfo
,
pResult
);
...
...
@@ -977,14 +977,14 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
STimeWindow
nextWin
=
win
;
while
(
1
)
{
int32_t
prevEndPos
=
forwardRows
-
1
+
startPos
;
startPos
=
getNextQualifiedWindow
(
&
pInfo
->
interval
,
&
nextWin
,
&
pBlock
->
info
,
tsCols
,
prevEndPos
,
pInfo
->
o
rder
);
startPos
=
getNextQualifiedWindow
(
&
pInfo
->
interval
,
&
nextWin
,
&
pBlock
->
info
,
tsCols
,
prevEndPos
,
pInfo
->
inputO
rder
);
if
(
startPos
<
0
)
{
break
;
}
if
(
pInfo
->
ignoreExpiredData
&&
isCloseWindow
(
&
nextWin
,
&
pInfo
->
twAggSup
))
{
ekey
=
ascScan
?
nextWin
.
ekey
:
nextWin
.
skey
;
forwardRows
=
getNumOfRowsInTimeWindow
(
&
pBlock
->
info
,
tsCols
,
startPos
,
ekey
,
binarySearchForKey
,
NULL
,
pInfo
->
o
rder
);
getNumOfRowsInTimeWindow
(
&
pBlock
->
info
,
tsCols
,
startPos
,
ekey
,
binarySearchForKey
,
NULL
,
pInfo
->
inputO
rder
);
continue
;
}
...
...
@@ -1002,14 +1002,14 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
ekey
=
ascScan
?
nextWin
.
ekey
:
nextWin
.
skey
;
forwardRows
=
getNumOfRowsInTimeWindow
(
&
pBlock
->
info
,
tsCols
,
startPos
,
ekey
,
binarySearchForKey
,
NULL
,
pInfo
->
o
rder
);
getNumOfRowsInTimeWindow
(
&
pBlock
->
info
,
tsCols
,
startPos
,
ekey
,
binarySearchForKey
,
NULL
,
pInfo
->
inputO
rder
);
// window start(end) key interpolation
doWindowBorderInterpolation
(
pInfo
,
pBlock
,
pResult
,
&
nextWin
,
startPos
,
forwardRows
,
pSup
);
updateTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
nextWin
,
true
);
doApplyFunctions
(
pTaskInfo
,
pSup
->
pCtx
,
&
nextWin
,
&
pInfo
->
twAggSup
.
timeWindowData
,
startPos
,
forwardRows
,
tsCols
,
pBlock
->
info
.
rows
,
numOfOutput
,
pInfo
->
o
rder
);
pBlock
->
info
.
rows
,
numOfOutput
,
pInfo
->
inputO
rder
);
doCloseWindow
(
pResultRowInfo
,
pInfo
,
pResult
);
}
...
...
@@ -1082,7 +1082,7 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
break
;
}
getTableScanInfo
(
pOperator
,
&
pInfo
->
o
rder
,
&
scanFlag
);
getTableScanInfo
(
pOperator
,
&
pInfo
->
inputO
rder
,
&
scanFlag
);
if
(
pInfo
->
scalarSupp
.
pExprInfo
!=
NULL
)
{
SExprSupp
*
pExprSup
=
&
pInfo
->
scalarSupp
;
...
...
@@ -1090,7 +1090,7 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
}
// the pDataBlock are always the same one, no need to call this again
setInputDataBlock
(
pOperator
,
pSup
->
pCtx
,
pBlock
,
pInfo
->
o
rder
,
scanFlag
,
true
);
setInputDataBlock
(
pOperator
,
pSup
->
pCtx
,
pBlock
,
pInfo
->
inputO
rder
,
scanFlag
,
true
);
blockDataUpdateTsWindow
(
pBlock
,
pInfo
->
primaryTsIndex
);
hashIntervalAgg
(
pOperator
,
&
pInfo
->
binfo
.
resultRowInfo
,
pBlock
,
scanFlag
,
NULL
);
...
...
@@ -1549,7 +1549,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
SIntervalAggOperatorInfo
*
pInfo
=
pOperator
->
info
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
pInfo
->
o
rder
=
TSDB_ORDER_ASC
;
pInfo
->
inputO
rder
=
TSDB_ORDER_ASC
;
SExprSupp
*
pSup
=
&
pOperator
->
exprSupp
;
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
...
...
@@ -1609,7 +1609,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
// The timewindow that overlaps the timestamps of the input pBlock need to be recalculated and return to the
// caller. Note that all the time window are not close till now.
// the pDataBlock are always the same one, no need to call this again
setInputDataBlock
(
pOperator
,
pSup
->
pCtx
,
pBlock
,
pInfo
->
o
rder
,
MAIN_SCAN
,
true
);
setInputDataBlock
(
pOperator
,
pSup
->
pCtx
,
pBlock
,
pInfo
->
inputO
rder
,
MAIN_SCAN
,
true
);
if
(
pInfo
->
invertible
)
{
setInverFunction
(
pSup
->
pCtx
,
pOperator
->
exprSupp
.
numOfExprs
,
pBlock
->
info
.
type
);
}
...
...
@@ -1789,8 +1789,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
}
pInfo
->
win
=
pTaskInfo
->
window
;
pInfo
->
order
=
TSDB_ORDER_A
SC
;
pInfo
->
resultTsOrder
=
TSDB_ORDER_A
SC
;
pInfo
->
inputOrder
=
(
pPhyNode
->
window
.
inputTsOrder
==
ORDER_ASC
)
?
TSDB_ORDER_ASC
:
TSDB_ORDER_DE
SC
;
pInfo
->
resultTsOrder
=
(
pPhyNode
->
window
.
outputTsOrder
==
ORDER_ASC
)
?
TSDB_ORDER_ASC
:
TSDB_ORDER_DE
SC
;
pInfo
->
interval
=
*
pInterval
;
pInfo
->
execModel
=
pTaskInfo
->
execModel
;
pInfo
->
twAggSup
=
*
pTwAggSupp
;
...
...
@@ -1878,7 +1878,7 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SExpr
goto
_error
;
}
pInfo
->
o
rder
=
TSDB_ORDER_ASC
;
pInfo
->
inputO
rder
=
TSDB_ORDER_ASC
;
pInfo
->
interval
=
*
pInterval
;
pInfo
->
execModel
=
OPTR_EXEC_MODEL_STREAM
;
pInfo
->
win
=
pTaskInfo
->
window
;
...
...
@@ -4563,7 +4563,7 @@ static int32_t outputMergeAlignedIntervalResult(SOperatorInfo* pOperatorInfo, ui
SExecTaskInfo
*
pTaskInfo
=
pOperatorInfo
->
pTaskInfo
;
SExprSupp
*
pSup
=
&
pOperatorInfo
->
exprSupp
;
bool
ascScan
=
(
iaInfo
->
o
rder
==
TSDB_ORDER_ASC
);
bool
ascScan
=
(
iaInfo
->
inputO
rder
==
TSDB_ORDER_ASC
);
SET_RES_WINDOW_KEY
(
iaInfo
->
aggSup
.
keyBuf
,
&
wstartTs
,
TSDB_KEYSIZE
,
tableGroupId
);
SResultRowPosition
*
p1
=
(
SResultRowPosition
*
)
taosHashGet
(
iaInfo
->
aggSup
.
pResultRowHashTable
,
iaInfo
->
aggSup
.
keyBuf
,
...
...
@@ -4617,7 +4617,7 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR
}
else
{
updateTimeWindowInfo
(
&
iaInfo
->
twAggSup
.
timeWindowData
,
&
currWin
,
true
);
doApplyFunctions
(
pTaskInfo
,
pSup
->
pCtx
,
&
currWin
,
&
iaInfo
->
twAggSup
.
timeWindowData
,
startPos
,
currPos
-
startPos
,
tsCols
,
pBlock
->
info
.
rows
,
numOfOutput
,
iaInfo
->
o
rder
);
tsCols
,
pBlock
->
info
.
rows
,
numOfOutput
,
iaInfo
->
inputO
rder
);
outputMergeAlignedIntervalResult
(
pOperatorInfo
,
tableGroupId
,
pResultBlock
,
currTs
);
...
...
@@ -4636,7 +4636,7 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR
}
updateTimeWindowInfo
(
&
iaInfo
->
twAggSup
.
timeWindowData
,
&
currWin
,
true
);
doApplyFunctions
(
pTaskInfo
,
pSup
->
pCtx
,
&
currWin
,
&
iaInfo
->
twAggSup
.
timeWindowData
,
startPos
,
currPos
-
startPos
,
tsCols
,
pBlock
->
info
.
rows
,
numOfOutput
,
iaInfo
->
o
rder
);
tsCols
,
pBlock
->
info
.
rows
,
numOfOutput
,
iaInfo
->
inputO
rder
);
outputMergeAlignedIntervalResult
(
pOperatorInfo
,
tableGroupId
,
pResultBlock
,
currTs
);
}
...
...
@@ -4681,8 +4681,8 @@ static SSDataBlock* doMergeAlignedIntervalAgg(SOperatorInfo* pOperator) {
break
;
}
getTableScanInfo
(
pOperator
,
&
iaInfo
->
o
rder
,
&
scanFlag
);
setInputDataBlock
(
pOperator
,
pSup
->
pCtx
,
pBlock
,
iaInfo
->
o
rder
,
scanFlag
,
true
);
getTableScanInfo
(
pOperator
,
&
iaInfo
->
inputO
rder
,
&
scanFlag
);
setInputDataBlock
(
pOperator
,
pSup
->
pCtx
,
pBlock
,
iaInfo
->
inputO
rder
,
scanFlag
,
true
);
doMergeAlignedIntervalAggImpl
(
pOperator
,
&
iaInfo
->
binfo
.
resultRowInfo
,
pBlock
,
scanFlag
,
pRes
);
doFilter
(
miaInfo
->
pCondition
,
pRes
,
NULL
);
if
(
pRes
->
info
.
rows
>=
pOperator
->
resultInfo
.
capacity
)
{
...
...
@@ -4723,7 +4723,7 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
miaInfo
->
pCondition
=
pCondition
;
iaInfo
->
win
=
pTaskInfo
->
window
;
iaInfo
->
o
rder
=
TSDB_ORDER_ASC
;
iaInfo
->
inputO
rder
=
TSDB_ORDER_ASC
;
iaInfo
->
interval
=
*
pInterval
;
iaInfo
->
execModel
=
pTaskInfo
->
execModel
;
iaInfo
->
primaryTsIndex
=
primaryTsSlotId
;
...
...
@@ -4805,7 +4805,7 @@ static int32_t finalizeWindowResult(SOperatorInfo* pOperatorInfo, uint64_t table
SMergeIntervalAggOperatorInfo
*
miaInfo
=
pOperatorInfo
->
info
;
SIntervalAggOperatorInfo
*
iaInfo
=
&
miaInfo
->
intervalAggOperatorInfo
;
SExecTaskInfo
*
pTaskInfo
=
pOperatorInfo
->
pTaskInfo
;
bool
ascScan
=
(
iaInfo
->
o
rder
==
TSDB_ORDER_ASC
);
bool
ascScan
=
(
iaInfo
->
inputO
rder
==
TSDB_ORDER_ASC
);
SExprSupp
*
pExprSup
=
&
pOperatorInfo
->
exprSupp
;
SET_RES_WINDOW_KEY
(
iaInfo
->
aggSup
.
keyBuf
,
&
win
->
skey
,
TSDB_KEYSIZE
,
tableGroupId
);
...
...
@@ -4823,7 +4823,7 @@ static int32_t outputPrevIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t t
SMergeIntervalAggOperatorInfo
*
miaInfo
=
pOperatorInfo
->
info
;
SIntervalAggOperatorInfo
*
iaInfo
=
&
miaInfo
->
intervalAggOperatorInfo
;
SExecTaskInfo
*
pTaskInfo
=
pOperatorInfo
->
pTaskInfo
;
bool
ascScan
=
(
iaInfo
->
o
rder
==
TSDB_ORDER_ASC
);
bool
ascScan
=
(
iaInfo
->
inputO
rder
==
TSDB_ORDER_ASC
);
SExprSupp
*
pExprSup
=
&
pOperatorInfo
->
exprSupp
;
SGroupTimeWindow
groupTimeWindow
=
{.
groupId
=
tableGroupId
,
.
window
=
*
newWin
};
...
...
@@ -4859,12 +4859,12 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
int32_t
numOfOutput
=
pExprSup
->
numOfExprs
;
int64_t
*
tsCols
=
extractTsCol
(
pBlock
,
iaInfo
);
uint64_t
tableGroupId
=
pBlock
->
info
.
groupId
;
bool
ascScan
=
(
iaInfo
->
o
rder
==
TSDB_ORDER_ASC
);
bool
ascScan
=
(
iaInfo
->
inputO
rder
==
TSDB_ORDER_ASC
);
TSKEY
blockStartTs
=
getStartTsKey
(
&
pBlock
->
info
.
window
,
tsCols
);
SResultRow
*
pResult
=
NULL
;
STimeWindow
win
=
getActiveTimeWindow
(
iaInfo
->
aggSup
.
pResultBuf
,
pResultRowInfo
,
blockStartTs
,
&
iaInfo
->
interval
,
iaInfo
->
o
rder
);
getActiveTimeWindow
(
iaInfo
->
aggSup
.
pResultBuf
,
pResultRowInfo
,
blockStartTs
,
&
iaInfo
->
interval
,
iaInfo
->
inputO
rder
);
int32_t
ret
=
setTimeWindowOutputBuf
(
pResultRowInfo
,
&
win
,
(
scanFlag
==
MAIN_SCAN
),
&
pResult
,
tableGroupId
,
pExprSup
->
pCtx
,
...
...
@@ -4875,7 +4875,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
TSKEY
ekey
=
ascScan
?
win
.
ekey
:
win
.
skey
;
int32_t
forwardRows
=
getNumOfRowsInTimeWindow
(
&
pBlock
->
info
,
tsCols
,
startPos
,
ekey
,
binarySearchForKey
,
NULL
,
iaInfo
->
o
rder
);
getNumOfRowsInTimeWindow
(
&
pBlock
->
info
,
tsCols
,
startPos
,
ekey
,
binarySearchForKey
,
NULL
,
iaInfo
->
inputO
rder
);
ASSERT
(
forwardRows
>
0
);
// prev time window not interpolation yet.
...
...
@@ -4896,7 +4896,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
updateTimeWindowInfo
(
&
iaInfo
->
twAggSup
.
timeWindowData
,
&
win
,
true
);
doApplyFunctions
(
pTaskInfo
,
pExprSup
->
pCtx
,
&
win
,
&
iaInfo
->
twAggSup
.
timeWindowData
,
startPos
,
forwardRows
,
tsCols
,
pBlock
->
info
.
rows
,
numOfOutput
,
iaInfo
->
o
rder
);
pBlock
->
info
.
rows
,
numOfOutput
,
iaInfo
->
inputO
rder
);
doCloseWindow
(
pResultRowInfo
,
iaInfo
,
pResult
);
// output previous interval results after this interval (&win) is closed
...
...
@@ -4905,7 +4905,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
STimeWindow
nextWin
=
win
;
while
(
1
)
{
int32_t
prevEndPos
=
forwardRows
-
1
+
startPos
;
startPos
=
getNextQualifiedWindow
(
&
iaInfo
->
interval
,
&
nextWin
,
&
pBlock
->
info
,
tsCols
,
prevEndPos
,
iaInfo
->
o
rder
);
startPos
=
getNextQualifiedWindow
(
&
iaInfo
->
interval
,
&
nextWin
,
&
pBlock
->
info
,
tsCols
,
prevEndPos
,
iaInfo
->
inputO
rder
);
if
(
startPos
<
0
)
{
break
;
}
...
...
@@ -4920,14 +4920,14 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
ekey
=
ascScan
?
nextWin
.
ekey
:
nextWin
.
skey
;
forwardRows
=
getNumOfRowsInTimeWindow
(
&
pBlock
->
info
,
tsCols
,
startPos
,
ekey
,
binarySearchForKey
,
NULL
,
iaInfo
->
o
rder
);
getNumOfRowsInTimeWindow
(
&
pBlock
->
info
,
tsCols
,
startPos
,
ekey
,
binarySearchForKey
,
NULL
,
iaInfo
->
inputO
rder
);
// window start(end) key interpolation
doWindowBorderInterpolation
(
iaInfo
,
pBlock
,
pResult
,
&
nextWin
,
startPos
,
forwardRows
,
pExprSup
);
updateTimeWindowInfo
(
&
iaInfo
->
twAggSup
.
timeWindowData
,
&
nextWin
,
true
);
doApplyFunctions
(
pTaskInfo
,
pExprSup
->
pCtx
,
&
nextWin
,
&
iaInfo
->
twAggSup
.
timeWindowData
,
startPos
,
forwardRows
,
tsCols
,
pBlock
->
info
.
rows
,
numOfOutput
,
iaInfo
->
o
rder
);
tsCols
,
pBlock
->
info
.
rows
,
numOfOutput
,
iaInfo
->
inputO
rder
);
doCloseWindow
(
pResultRowInfo
,
iaInfo
,
pResult
);
// output previous interval results after this interval (&nextWin) is closed
...
...
@@ -4981,8 +4981,8 @@ static SSDataBlock* doMergeIntervalAgg(SOperatorInfo* pOperator) {
break
;
}
getTableScanInfo
(
pOperator
,
&
iaInfo
->
o
rder
,
&
scanFlag
);
setInputDataBlock
(
pOperator
,
pExpSupp
->
pCtx
,
pBlock
,
iaInfo
->
o
rder
,
scanFlag
,
true
);
getTableScanInfo
(
pOperator
,
&
iaInfo
->
inputO
rder
,
&
scanFlag
);
setInputDataBlock
(
pOperator
,
pExpSupp
->
pCtx
,
pBlock
,
iaInfo
->
inputO
rder
,
scanFlag
,
true
);
doMergeIntervalAggImpl
(
pOperator
,
&
iaInfo
->
binfo
.
resultRowInfo
,
pBlock
,
scanFlag
,
pRes
);
if
(
pRes
->
info
.
rows
>=
pOperator
->
resultInfo
.
threshold
)
{
...
...
@@ -5024,9 +5024,8 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SExprI
miaInfo
->
groupIntervals
=
tdListNew
(
sizeof
(
SGroupTimeWindow
));
SIntervalAggOperatorInfo
*
iaInfo
=
&
miaInfo
->
intervalAggOperatorInfo
;
iaInfo
->
win
=
pTaskInfo
->
window
;
iaInfo
->
o
rder
=
TSDB_ORDER_ASC
;
iaInfo
->
inputO
rder
=
TSDB_ORDER_ASC
;
iaInfo
->
interval
=
*
pInterval
;
iaInfo
->
execModel
=
pTaskInfo
->
execModel
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录