Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
c121f5b7
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c121f5b7
编写于
12月 02, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-225] refactor codes.
上级
81036205
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
48 deletion
+48
-48
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+4
-4
src/query/inc/qUtil.h
src/query/inc/qUtil.h
+9
-9
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+25
-25
src/query/src/qUtil.c
src/query/src/qUtil.c
+10
-10
未找到文件。
src/query/inc/qExecutor.h
浏览文件 @
c121f5b7
...
...
@@ -83,7 +83,7 @@ typedef struct SResultRec {
int32_t
threshold
;
// result size threshold in rows.
}
SResultRec
;
typedef
struct
S
WindowRes
Info
{
typedef
struct
S
ResultRow
Info
{
SResultRow
**
pResult
;
// result list
int16_t
type
:
8
;
// data type for hash key
int32_t
size
:
24
;
// number of result set
...
...
@@ -91,7 +91,7 @@ typedef struct SWindowResInfo {
int32_t
curIndex
;
// current start active index
int64_t
startTime
;
// start time of the first time window for sliding query
int64_t
prevSKey
;
// previous (not completed) sliding window start key
}
S
WindowRes
Info
;
}
S
ResultRow
Info
;
typedef
struct
SColumnFilterElem
{
int16_t
bytes
;
// column length
...
...
@@ -114,7 +114,7 @@ typedef struct STableQueryInfo {
STimeWindow
win
;
STSCursor
cur
;
void
*
pTable
;
// for retrieve the page id list
S
WindowRes
Info
windowResInfo
;
S
ResultRow
Info
windowResInfo
;
}
STableQueryInfo
;
typedef
struct
SQueryCostInfo
{
...
...
@@ -178,7 +178,7 @@ typedef struct SQueryRuntimeEnv {
uint16_t
*
offset
;
uint16_t
scanFlag
;
// denotes reversed scan of data or not
SFillInfo
*
pFillInfo
;
S
WindowRes
Info
windowResInfo
;
S
ResultRow
Info
windowResInfo
;
STSBuf
*
pTSBuf
;
STSCursor
cur
;
SQueryCostInfo
summary
;
...
...
src/query/inc/qUtil.h
浏览文件 @
c121f5b7
...
...
@@ -30,19 +30,19 @@ void clearResultRow(SQueryRuntimeEnv* pRuntimeEnv, SResultRow* pRow, int16_t typ
void
copyResultRow
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
dst
,
const
SResultRow
*
src
,
int16_t
type
);
SResultRowCellInfo
*
getResultCell
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
const
SResultRow
*
pRow
,
int32_t
index
);
int32_t
initWindowResInfo
(
S
WindowRes
Info
*
pWindowResInfo
,
int32_t
size
,
int16_t
type
);
int32_t
initWindowResInfo
(
S
ResultRow
Info
*
pWindowResInfo
,
int32_t
size
,
int16_t
type
);
void
cleanupTimeWindowInfo
(
S
WindowRes
Info
*
pWindowResInfo
);
void
resetTimeWindowInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
S
WindowRes
Info
*
pWindowResInfo
);
void
cleanupTimeWindowInfo
(
S
ResultRow
Info
*
pWindowResInfo
);
void
resetTimeWindowInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
S
ResultRow
Info
*
pWindowResInfo
);
void
clearFirstNWindowRes
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
int32_t
num
);
void
clearClosedTimeWindow
(
SQueryRuntimeEnv
*
pRuntimeEnv
);
int32_t
numOfClosedTimeWindow
(
S
WindowRes
Info
*
pWindowResInfo
);
void
closeTimeWindow
(
S
WindowRes
Info
*
pWindowResInfo
,
int32_t
slot
);
void
closeAllTimeWindow
(
S
WindowRes
Info
*
pWindowResInfo
);
void
removeRedundantWindow
(
S
WindowRes
Info
*
pWindowResInfo
,
TSKEY
lastKey
,
int32_t
order
);
int32_t
numOfClosedTimeWindow
(
S
ResultRow
Info
*
pWindowResInfo
);
void
closeTimeWindow
(
S
ResultRow
Info
*
pWindowResInfo
,
int32_t
slot
);
void
closeAllTimeWindow
(
S
ResultRow
Info
*
pWindowResInfo
);
void
removeRedundantWindow
(
S
ResultRow
Info
*
pWindowResInfo
,
TSKEY
lastKey
,
int32_t
order
);
static
FORCE_INLINE
SResultRow
*
getResultRow
(
S
WindowRes
Info
*
pWindowResInfo
,
int32_t
slot
)
{
static
FORCE_INLINE
SResultRow
*
getResultRow
(
S
ResultRow
Info
*
pWindowResInfo
,
int32_t
slot
)
{
assert
(
pWindowResInfo
!=
NULL
&&
slot
>=
0
&&
slot
<
pWindowResInfo
->
size
);
return
pWindowResInfo
->
pResult
[
slot
];
}
...
...
@@ -50,7 +50,7 @@ static FORCE_INLINE SResultRow *getResultRow(SWindowResInfo *pWindowResInfo, int
#define curTimeWindowIndex(_winres) ((_winres)->curIndex)
#define GET_ROW_PARAM_FOR_MULTIOUTPUT(_q, tbq, sq) (((tbq) && (!sq))? (_q)->pExpr1[1].base.arg->argValue.i64:1)
bool
isWindowResClosed
(
S
WindowRes
Info
*
pWindowResInfo
,
int32_t
slot
);
bool
isWindowResClosed
(
S
ResultRow
Info
*
pWindowResInfo
,
int32_t
slot
);
int32_t
initResultRow
(
SResultRow
*
pResultRow
);
...
...
src/query/src/qExecutor.c
浏览文件 @
c121f5b7
...
...
@@ -461,7 +461,7 @@ static bool hasNullValue(SColIndex* pColIndex, SDataStatis *pStatis, SDataStatis
return
true
;
}
static
SResultRow
*
doPrepareResultRowFromKey
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
S
WindowRes
Info
*
pWindowResInfo
,
char
*
pData
,
static
SResultRow
*
doPrepareResultRowFromKey
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
S
ResultRow
Info
*
pWindowResInfo
,
char
*
pData
,
int16_t
bytes
,
bool
masterscan
,
uint64_t
uid
)
{
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
pData
,
bytes
,
uid
);
int32_t
*
p1
=
...
...
@@ -518,7 +518,7 @@ static SResultRow *doPrepareResultRowFromKey(SQueryRuntimeEnv *pRuntimeEnv, SWin
}
// get the correct time window according to the handled timestamp
static
STimeWindow
getActiveTimeWindow
(
S
WindowRes
Info
*
pWindowResInfo
,
int64_t
ts
,
SQuery
*
pQuery
)
{
static
STimeWindow
getActiveTimeWindow
(
S
ResultRow
Info
*
pWindowResInfo
,
int64_t
ts
,
SQuery
*
pQuery
)
{
STimeWindow
w
=
{
0
};
if
(
pWindowResInfo
->
curIndex
==
-
1
)
{
// the first window, from the previous stored value
...
...
@@ -611,7 +611,7 @@ static int32_t addNewWindowResultBuf(SResultRow *pWindowRes, SDiskbasedResultBuf
return
0
;
}
static
int32_t
setWindowOutputBufByKey
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
S
WindowRes
Info
*
pWindowResInfo
,
SDataBlockInfo
*
pBockInfo
,
static
int32_t
setWindowOutputBufByKey
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
S
ResultRow
Info
*
pWindowResInfo
,
SDataBlockInfo
*
pBockInfo
,
STimeWindow
*
win
,
bool
masterscan
,
bool
*
newWind
,
SResultRow
**
pResult
)
{
assert
(
win
->
skey
<=
win
->
ekey
);
SDiskbasedResultBuf
*
pResultBuf
=
pRuntimeEnv
->
pResultBuf
;
...
...
@@ -644,7 +644,7 @@ static int32_t setWindowOutputBufByKey(SQueryRuntimeEnv *pRuntimeEnv, SWindowRes
return
TSDB_CODE_SUCCESS
;
}
static
bool
getResultRowStatus
(
S
WindowRes
Info
*
pWindowResInfo
,
int32_t
slot
)
{
static
bool
getResultRowStatus
(
S
ResultRow
Info
*
pWindowResInfo
,
int32_t
slot
)
{
assert
(
slot
>=
0
&&
slot
<
pWindowResInfo
->
size
);
return
pWindowResInfo
->
pResult
[
slot
]
->
closed
;
}
...
...
@@ -703,7 +703,7 @@ static FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_se
/**
* NOTE: the query status only set for the first scan of master scan.
*/
static
int32_t
doCheckQueryCompleted
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
TSKEY
lastKey
,
S
WindowRes
Info
*
pWindowResInfo
)
{
static
int32_t
doCheckQueryCompleted
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
TSKEY
lastKey
,
S
ResultRow
Info
*
pWindowResInfo
)
{
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
if
(
pRuntimeEnv
->
scanFlag
!=
MASTER_SCAN
)
{
return
pWindowResInfo
->
size
;
...
...
@@ -1157,7 +1157,7 @@ static TSKEY getStartTsKey(SQuery* pQuery, SDataBlockInfo* pDataBlockInfo, TSKEY
* such as count/min/max etc.
*/
static
void
blockwiseApplyFunctions
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SDataStatis
*
pStatis
,
SDataBlockInfo
*
pDataBlockInfo
,
S
WindowRes
Info
*
pWindowResInfo
,
__block_search_fn_t
searchFn
,
SArray
*
pDataBlock
)
{
S
ResultRow
Info
*
pWindowResInfo
,
__block_search_fn_t
searchFn
,
SArray
*
pDataBlock
)
{
SQLFunctionCtx
*
pCtx
=
pRuntimeEnv
->
pCtx
;
bool
masterScan
=
IS_MASTER_SCAN
(
pRuntimeEnv
);
...
...
@@ -1575,7 +1575,7 @@ static void setTimeWindowEKeyInterp(SQueryRuntimeEnv* pRuntimeEnv, SArray* pData
}
static
void
rowwiseApplyFunctions
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
SDataStatis
*
pStatis
,
SDataBlockInfo
*
pDataBlockInfo
,
S
WindowRes
Info
*
pWindowResInfo
,
SArray
*
pDataBlock
)
{
S
ResultRow
Info
*
pWindowResInfo
,
SArray
*
pDataBlock
)
{
SQLFunctionCtx
*
pCtx
=
pRuntimeEnv
->
pCtx
;
bool
masterScan
=
IS_MASTER_SCAN
(
pRuntimeEnv
);
...
...
@@ -1781,7 +1781,7 @@ static int32_t tableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBl
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
STableQueryInfo
*
pTableQInfo
=
pQuery
->
current
;
S
WindowRes
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
if
(
pQuery
->
numOfFilterCols
>
0
||
pRuntimeEnv
->
pTSBuf
!=
NULL
||
pRuntimeEnv
->
groupbyNormalCol
)
{
rowwiseApplyFunctions
(
pRuntimeEnv
,
pStatis
,
pDataBlockInfo
,
pWindowResInfo
,
pDataBlock
);
...
...
@@ -2605,7 +2605,7 @@ static bool overlapWithTimeWindow(SQuery* pQuery, SDataBlockInfo* pBlockInfo) {
return
false
;
}
int32_t
loadDataBlockOnDemand
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
S
WindowRes
Info
*
pWindowResInfo
,
void
*
pQueryHandle
,
SDataBlockInfo
*
pBlockInfo
,
SDataStatis
**
pStatis
,
SArray
**
pDataBlock
,
uint32_t
*
status
)
{
int32_t
loadDataBlockOnDemand
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
S
ResultRow
Info
*
pWindowResInfo
,
void
*
pQueryHandle
,
SDataBlockInfo
*
pBlockInfo
,
SDataStatis
**
pStatis
,
SArray
**
pDataBlock
,
uint32_t
*
status
)
{
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
*
status
=
BLK_DATA_NO_NEEDED
;
...
...
@@ -2828,7 +2828,7 @@ static void doSetInitialTimewindow(SQueryRuntimeEnv* pRuntimeEnv, SDataBlockInfo
if
(
QUERY_IS_INTERVAL_QUERY
(
pQuery
)
&&
pRuntimeEnv
->
windowResInfo
.
prevSKey
==
TSKEY_INITIAL_VAL
)
{
STimeWindow
w
=
TSWINDOW_INITIALIZER
;
S
WindowRes
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
if
(
QUERY_IS_ASC_QUERY
(
pQuery
))
{
getAlignQueryTimeWindow
(
pQuery
,
pBlockInfo
->
window
.
skey
,
pBlockInfo
->
window
.
skey
,
pQuery
->
window
.
ekey
,
&
w
);
...
...
@@ -3192,14 +3192,14 @@ int32_t tableResultComparFn(const void *pLeft, const void *pRight, void *param)
return
-
1
;
}
S
WindowRes
Info
*
pWindowResInfo1
=
&
supporter
->
pTableQueryInfo
[
left
]
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo1
=
&
supporter
->
pTableQueryInfo
[
left
]
->
windowResInfo
;
SResultRow
*
pWindowRes1
=
getResultRow
(
pWindowResInfo1
,
leftPos
);
tFilePage
*
page1
=
getResBufPage
(
pRuntimeEnv
->
pResultBuf
,
pWindowRes1
->
pageId
);
char
*
b1
=
getPosInResultPage
(
pRuntimeEnv
,
PRIMARYKEY_TIMESTAMP_COL_INDEX
,
pWindowRes1
,
page1
);
TSKEY
leftTimestamp
=
GET_INT64_VAL
(
b1
);
S
WindowRes
Info
*
pWindowResInfo2
=
&
supporter
->
pTableQueryInfo
[
right
]
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo2
=
&
supporter
->
pTableQueryInfo
[
right
]
->
windowResInfo
;
SResultRow
*
pWindowRes2
=
getResultRow
(
pWindowResInfo2
,
rightPos
);
tFilePage
*
page2
=
getResBufPage
(
pRuntimeEnv
->
pResultBuf
,
pWindowRes2
->
pageId
);
...
...
@@ -3439,7 +3439,7 @@ int32_t mergeIntoGroupResultImpl(SQInfo *pQInfo, SArray *pGroup) {
int32_t
pos
=
pTree
->
pNode
[
0
].
index
;
S
WindowRes
Info
*
pWindowResInfo
=
&
pTableList
[
pos
]
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo
=
&
pTableList
[
pos
]
->
windowResInfo
;
SResultRow
*
pWindowRes
=
getResultRow
(
pWindowResInfo
,
cs
.
position
[
pos
]);
tFilePage
*
page
=
getResBufPage
(
pRuntimeEnv
->
pResultBuf
,
pWindowRes
->
pageId
);
...
...
@@ -3603,7 +3603,7 @@ static void updateTableQueryInfoForReverseScan(SQuery *pQuery, STableQueryInfo *
pTableQueryInfo
->
windowResInfo
.
curIndex
=
pTableQueryInfo
->
windowResInfo
.
size
-
1
;
}
static
void
disableFuncInReverseScanImpl
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
S
WindowRes
Info
*
pWindowResInfo
,
int32_t
order
)
{
static
void
disableFuncInReverseScanImpl
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
S
ResultRow
Info
*
pWindowResInfo
,
int32_t
order
)
{
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
for
(
int32_t
i
=
0
;
i
<
pWindowResInfo
->
size
;
++
i
)
{
...
...
@@ -3635,7 +3635,7 @@ void disableFuncInReverseScan(SQInfo *pQInfo) {
int32_t
order
=
pQuery
->
order
.
order
;
// group by normal columns and interval query on normal table
S
WindowRes
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
if
(
pRuntimeEnv
->
groupbyNormalCol
||
QUERY_IS_INTERVAL_QUERY
(
pQuery
))
{
disableFuncInReverseScanImpl
(
pRuntimeEnv
,
pWindowResInfo
,
order
);
}
else
{
// for simple result of table query,
...
...
@@ -3826,7 +3826,7 @@ bool needScanDataBlocksAgain(SQueryRuntimeEnv *pRuntimeEnv) {
bool
toContinue
=
false
;
if
(
pRuntimeEnv
->
groupbyNormalCol
||
QUERY_IS_INTERVAL_QUERY
(
pQuery
))
{
// for each group result, call the finalize function for each column
S
WindowRes
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
for
(
int32_t
i
=
0
;
i
<
pWindowResInfo
->
size
;
++
i
)
{
SResultRow
*
pResult
=
getResultRow
(
pWindowResInfo
,
i
);
...
...
@@ -4038,7 +4038,7 @@ void finalizeQueryResult(SQueryRuntimeEnv *pRuntimeEnv) {
if
(
pRuntimeEnv
->
groupbyNormalCol
||
QUERY_IS_INTERVAL_QUERY
(
pQuery
))
{
// for each group result, call the finalize function for each column
S
WindowRes
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
if
(
pRuntimeEnv
->
groupbyNormalCol
)
{
closeAllTimeWindow
(
pWindowResInfo
);
}
...
...
@@ -4122,7 +4122,7 @@ void destroyTableQueryInfoImpl(STableQueryInfo *pTableQueryInfo) {
void
setExecutionContext
(
SQInfo
*
pQInfo
,
int32_t
groupIndex
,
TSKEY
nextKey
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
STableQueryInfo
*
pTableQueryInfo
=
pRuntimeEnv
->
pQuery
->
current
;
S
WindowRes
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
// lastKey needs to be updated
pTableQueryInfo
->
lastKey
=
nextKey
;
...
...
@@ -4290,7 +4290,7 @@ void setIntervalQueryRange(SQInfo *pQInfo, TSKEY key) {
* operations involve.
*/
STimeWindow
w
=
TSWINDOW_INITIALIZER
;
S
WindowRes
Info
*
pWindowResInfo
=
&
pTableQueryInfo
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo
=
&
pTableQueryInfo
->
windowResInfo
;
TSKEY
sk
=
MIN
(
win
.
skey
,
win
.
ekey
);
TSKEY
ek
=
MAX
(
win
.
skey
,
win
.
ekey
);
...
...
@@ -4334,7 +4334,7 @@ bool needPrimaryTimestampCol(SQuery *pQuery, SDataBlockInfo *pDataBlockInfo) {
return
loadPrimaryTS
;
}
static
int32_t
doCopyToSData
(
SQInfo
*
pQInfo
,
S
WindowRes
Info
*
pResultInfo
,
int32_t
orderType
)
{
static
int32_t
doCopyToSData
(
SQInfo
*
pQInfo
,
S
ResultRow
Info
*
pResultInfo
,
int32_t
orderType
)
{
SQueryRuntimeEnv
*
pRuntimeEnv
=
&
pQInfo
->
runtimeEnv
;
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
...
...
@@ -4411,7 +4411,7 @@ static int32_t doCopyToSData(SQInfo *pQInfo, SWindowResInfo *pResultInfo, int32_
* @param pQInfo
* @param result
*/
void
copyFromWindowResToSData
(
SQInfo
*
pQInfo
,
S
WindowRes
Info
*
pResultInfo
)
{
void
copyFromWindowResToSData
(
SQInfo
*
pQInfo
,
S
ResultRow
Info
*
pResultInfo
)
{
SQuery
*
pQuery
=
pQInfo
->
runtimeEnv
.
pQuery
;
int32_t
orderType
=
(
pQuery
->
pGroupbyExpr
!=
NULL
)
?
pQuery
->
pGroupbyExpr
->
orderType
:
TSDB_ORDER_ASC
;
...
...
@@ -4450,7 +4450,7 @@ static void stableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBloc
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
STableQueryInfo
*
pTableQueryInfo
=
pQuery
->
current
;
S
WindowRes
Info
*
pWindowResInfo
=
&
pTableQueryInfo
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo
=
&
pTableQueryInfo
->
windowResInfo
;
pQuery
->
pos
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
0
:
pDataBlockInfo
->
rows
-
1
;
if
(
pQuery
->
numOfFilterCols
>
0
||
pRuntimeEnv
->
pTSBuf
!=
NULL
||
pRuntimeEnv
->
groupbyNormalCol
)
{
...
...
@@ -4698,7 +4698,7 @@ void skipBlocks(SQueryRuntimeEnv *pRuntimeEnv) {
static
TSKEY
doSkipIntervalProcess
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
STimeWindow
*
win
,
SDataBlockInfo
*
pBlockInfo
,
STableQueryInfo
*
pTableQueryInfo
)
{
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
S
WindowRes
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
assert
(
pQuery
->
limit
.
offset
==
0
);
STimeWindow
tw
=
*
win
;
...
...
@@ -4764,7 +4764,7 @@ static bool skipTimeInterval(SQueryRuntimeEnv *pRuntimeEnv, TSKEY* start) {
STimeWindow
w
=
TSWINDOW_INITIALIZER
;
S
WindowRes
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
STableQueryInfo
*
pTableQueryInfo
=
pQuery
->
current
;
SDataBlockInfo
blockInfo
=
SDATA_BLOCK_INITIALIZER
;
...
...
@@ -5403,7 +5403,7 @@ static void sequentialTableProcess(SQInfo *pQInfo) {
scanMultiTableDataBlocks
(
pQInfo
);
pQInfo
->
groupIndex
+=
1
;
S
WindowRes
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
// no results generated for current group, continue to try the next group
taosArrayDestroy
(
s
);
...
...
src/query/src/qUtil.c
浏览文件 @
c121f5b7
...
...
@@ -43,7 +43,7 @@ int32_t getOutputInterResultBufSize(SQuery* pQuery) {
return
size
;
}
int32_t
initWindowResInfo
(
S
WindowRes
Info
*
pWindowResInfo
,
int32_t
size
,
int16_t
type
)
{
int32_t
initWindowResInfo
(
S
ResultRow
Info
*
pWindowResInfo
,
int32_t
size
,
int16_t
type
)
{
pWindowResInfo
->
capacity
=
size
;
pWindowResInfo
->
type
=
type
;
...
...
@@ -59,7 +59,7 @@ int32_t initWindowResInfo(SWindowResInfo *pWindowResInfo, int32_t size, int16_t
return
TSDB_CODE_SUCCESS
;
}
void
cleanupTimeWindowInfo
(
S
WindowRes
Info
*
pWindowResInfo
)
{
void
cleanupTimeWindowInfo
(
S
ResultRow
Info
*
pWindowResInfo
)
{
if
(
pWindowResInfo
==
NULL
)
{
return
;
}
...
...
@@ -77,7 +77,7 @@ void cleanupTimeWindowInfo(SWindowResInfo *pWindowResInfo) {
tfree
(
pWindowResInfo
->
pResult
);
}
void
resetTimeWindowInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
S
WindowRes
Info
*
pWindowResInfo
)
{
void
resetTimeWindowInfo
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
S
ResultRow
Info
*
pWindowResInfo
)
{
if
(
pWindowResInfo
==
NULL
||
pWindowResInfo
->
capacity
==
0
)
{
return
;
}
...
...
@@ -101,7 +101,7 @@ void resetTimeWindowInfo(SQueryRuntimeEnv *pRuntimeEnv, SWindowResInfo *pWindowR
}
void
clearFirstNWindowRes
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
int32_t
num
)
{
S
WindowRes
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
if
(
pWindowResInfo
==
NULL
||
pWindowResInfo
->
capacity
==
0
||
pWindowResInfo
->
size
==
0
||
num
==
0
)
{
return
;
}
...
...
@@ -160,7 +160,7 @@ void clearFirstNWindowRes(SQueryRuntimeEnv *pRuntimeEnv, int32_t num) {
}
void
clearClosedTimeWindow
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
S
WindowRes
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
S
ResultRow
Info
*
pWindowResInfo
=
&
pRuntimeEnv
->
windowResInfo
;
if
(
pWindowResInfo
==
NULL
||
pWindowResInfo
->
capacity
==
0
||
pWindowResInfo
->
size
==
0
)
{
return
;
}
...
...
@@ -169,7 +169,7 @@ void clearClosedTimeWindow(SQueryRuntimeEnv *pRuntimeEnv) {
clearFirstNWindowRes
(
pRuntimeEnv
,
numOfClosed
);
}
int32_t
numOfClosedTimeWindow
(
S
WindowRes
Info
*
pWindowResInfo
)
{
int32_t
numOfClosedTimeWindow
(
S
ResultRow
Info
*
pWindowResInfo
)
{
int32_t
i
=
0
;
while
(
i
<
pWindowResInfo
->
size
&&
pWindowResInfo
->
pResult
[
i
]
->
closed
)
{
++
i
;
...
...
@@ -178,7 +178,7 @@ int32_t numOfClosedTimeWindow(SWindowResInfo *pWindowResInfo) {
return
i
;
}
void
closeAllTimeWindow
(
S
WindowRes
Info
*
pWindowResInfo
)
{
void
closeAllTimeWindow
(
S
ResultRow
Info
*
pWindowResInfo
)
{
assert
(
pWindowResInfo
->
size
>=
0
&&
pWindowResInfo
->
capacity
>=
pWindowResInfo
->
size
);
for
(
int32_t
i
=
0
;
i
<
pWindowResInfo
->
size
;
++
i
)
{
...
...
@@ -195,7 +195,7 @@ void closeAllTimeWindow(SWindowResInfo *pWindowResInfo) {
* the last qualified time stamp in case of sliding query, which the sliding time is not equalled to the interval time.
* NOTE: remove redundant, only when the result set order equals to traverse order
*/
void
removeRedundantWindow
(
S
WindowRes
Info
*
pWindowResInfo
,
TSKEY
lastKey
,
int32_t
order
)
{
void
removeRedundantWindow
(
S
ResultRow
Info
*
pWindowResInfo
,
TSKEY
lastKey
,
int32_t
order
)
{
assert
(
pWindowResInfo
->
size
>=
0
&&
pWindowResInfo
->
capacity
>=
pWindowResInfo
->
size
);
if
(
pWindowResInfo
->
size
<=
1
)
{
return
;
...
...
@@ -224,11 +224,11 @@ void removeRedundantWindow(SWindowResInfo *pWindowResInfo, TSKEY lastKey, int32_
}
}
bool
isWindowResClosed
(
S
WindowRes
Info
*
pWindowResInfo
,
int32_t
slot
)
{
bool
isWindowResClosed
(
S
ResultRow
Info
*
pWindowResInfo
,
int32_t
slot
)
{
return
(
getResultRow
(
pWindowResInfo
,
slot
)
->
closed
==
true
);
}
void
closeTimeWindow
(
S
WindowRes
Info
*
pWindowResInfo
,
int32_t
slot
)
{
void
closeTimeWindow
(
S
ResultRow
Info
*
pWindowResInfo
,
int32_t
slot
)
{
getResultRow
(
pWindowResInfo
,
slot
)
->
closed
=
true
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录