Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
562a736d
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看板
未验证
提交
562a736d
编写于
11月 19, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
11月 19, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #18255 from taosdata/fix/liao_cov
refactor: do some internal refactor.
上级
5da721b2
5c60bf9a
变更
5
展开全部
隐藏空白更改
内联
并排
Showing
5 changed file
with
191 addition
and
373 deletion
+191
-373
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+31
-51
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+11
-11
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+9
-64
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+138
-245
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+2
-2
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
562a736d
...
...
@@ -163,7 +163,7 @@ typedef struct {
SArray
*
pStopInfo
;
}
STaskStopInfo
;
typedef
struct
SExecTaskInfo
{
struct
SExecTaskInfo
{
STaskIdInfo
id
;
uint32_t
status
;
STimeWindow
window
;
...
...
@@ -182,7 +182,7 @@ typedef struct SExecTaskInfo {
struct
SOperatorInfo
*
pRoot
;
SLocalFetch
localFetch
;
STaskStopInfo
stopInfo
;
}
SExecTaskInfo
;
};
enum
{
OP_NOT_OPENED
=
0x0
,
...
...
@@ -315,37 +315,39 @@ typedef struct STableMetaCacheInfo {
uint64_t
cacheHit
;
}
STableMetaCacheInfo
;
typedef
struct
STableScan
Info
{
typedef
struct
STableScan
Base
{
STsdbReader
*
dataReader
;
SReadHandle
readHandle
;
SLimitInfo
limitInfo
;
SFileBlockLoadRecorder
readRecorder
;
SScanInfo
scanInfo
;
int32_t
scanTimes
;
SSDataBlock
*
pResBlock
;
SQueryTableDataCond
cond
;
SAggOptrPushDownInfo
pdInfo
;
SColMatchInfo
matchInfo
;
SReadHandle
readHandle
;
SExprSupp
pseudoSup
;
S
QueryTableDataCond
cond
;
S
TableMetaCacheInfo
metaCache
;
int32_t
scanFlag
;
// table scan flag to denote if it is a repeat/reverse/main scan
int32_t
dataBlockLoadFlag
;
SLimitInfo
limitInfo
;
}
STableScanBase
;
typedef
struct
STableScanInfo
{
STableScanBase
base
;
SScanInfo
scanInfo
;
int32_t
scanTimes
;
SSDataBlock
*
pResBlock
;
SSampleExecInfo
sample
;
// sample execution info
int32_t
currentGroupId
;
int32_t
currentTable
;
int8_t
scanMode
;
SAggOptrPushDownInfo
pdInfo
;
int8_t
assignBlockUid
;
STableMetaCacheInfo
metaCache
;
}
STableScanInfo
;
typedef
struct
STableMergeScanInfo
{
STableListInfo
*
tableListInfo
;
int32_t
tableStartIndex
;
int32_t
tableEndIndex
;
bool
hasGroupId
;
uint64_t
groupId
;
SArray
*
queryConds
;
// array of queryTableDataCond
STsdbReader
*
pReader
;
SReadHandle
readHandle
;
STableScanBase
base
;
int32_t
bufPageSize
;
uint32_t
sortBufSize
;
// max buffer size for in-memory sort
SArray
*
pSortInfo
;
...
...
@@ -354,27 +356,12 @@ typedef struct STableMergeScanInfo {
int64_t
startTs
;
// sort start time
SArray
*
sortSourceParams
;
SLimitInfo
limitInfo
;
SFileBlockLoadRecorder
readRecorder
;
int64_t
numOfRows
;
SScanInfo
scanInfo
;
int32_t
scanTimes
;
SqlFunctionCtx
*
pCtx
;
// which belongs to the direct upstream operator operator query context
SResultRowInfo
*
pResultRowInfo
;
int32_t
*
rowEntryInfoOffset
;
SExprInfo
*
pExpr
;
SSDataBlock
*
pResBlock
;
SColMatchInfo
matchInfo
;
int32_t
numOfOutput
;
SExprSupp
pseudoSup
;
SQueryTableDataCond
cond
;
int32_t
scanFlag
;
// table scan flag to denote if it is a repeat/reverse/main scan
int32_t
dataBlockLoadFlag
;
// if the upstream is an interval operator, the interval info is also kept here to get the time
// window to check if current data block needs to be loaded.
SInterval
interval
;
SSampleExecInfo
sample
;
// sample execution info
SSortExecInfo
sortExecInfo
;
SSampleExecInfo
sample
;
// sample execution info
SSortExecInfo
sortExecInfo
;
}
STableMergeScanInfo
;
typedef
struct
STagScanInfo
{
...
...
@@ -387,17 +374,17 @@ typedef struct STagScanInfo {
}
STagScanInfo
;
typedef
struct
SLastrowScanInfo
{
SSDataBlock
*
pRes
;
SReadHandle
readHandle
;
void
*
pLastrowReader
;
SColMatchInfo
matchInfo
;
int32_t
*
pSlotIds
;
SExprSupp
pseudoExprSup
;
int32_t
retrieveType
;
int32_t
currentGroupIndex
;
SSDataBlock
*
pBufferredRes
;
SArray
*
pUidList
;
int32_t
indexOfBufferedRes
;
SSDataBlock
*
pRes
;
SReadHandle
readHandle
;
void
*
pLastrowReader
;
SColMatchInfo
matchInfo
;
int32_t
*
pSlotIds
;
SExprSupp
pseudoExprSup
;
int32_t
retrieveType
;
int32_t
currentGroupIndex
;
SSDataBlock
*
pBufferredRes
;
SArray
*
pUidList
;
int32_t
indexOfBufferedRes
;
}
SLastrowScanInfo
;
typedef
enum
EStreamScanMode
{
...
...
@@ -414,13 +401,6 @@ enum {
PROJECT_RETRIEVE_DONE
=
0x2
,
};
typedef
struct
SCatchSupporter
{
SHashObj
*
pWindowHashTable
;
// quick locate the window object for each window
SDiskbasedBuf
*
pDataBuf
;
// buffer based on blocked-wised disk file
int32_t
keySize
;
int64_t
*
pKeyBuf
;
}
SCatchSupporter
;
typedef
struct
SStreamAggSupporter
{
int32_t
resultRowSize
;
// the result buffer size for each result row, with the meta data size for each row
SSDataBlock
*
pScanBlock
;
...
...
@@ -1042,8 +1022,8 @@ int32_t finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPos
SOperatorInfo
*
createGroupSortOperatorInfo
(
SOperatorInfo
*
downstream
,
SGroupSortPhysiNode
*
pSortPhyNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableMergeScanOperatorInfo
(
STableScanPhysiNode
*
pTableScanNode
,
S
TableListInfo
*
pTableListInfo
,
S
ReadHandle
*
readHandle
,
S
ExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableMergeScanOperatorInfo
(
STableScanPhysiNode
*
pTableScanNode
,
S
ReadHandle
*
readHandle
,
SExecTaskInfo
*
pTaskInfo
);
void
copyUpdateDataBlock
(
SSDataBlock
*
pDest
,
SSDataBlock
*
pSource
,
int32_t
tsColIndex
);
...
...
source/libs/executor/src/executor.c
浏览文件 @
562a736d
...
...
@@ -1026,8 +1026,8 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
SStreamScanInfo
*
pInfo
=
pOperator
->
info
;
if
(
pOffset
->
type
==
TMQ_OFFSET__LOG
)
{
STableScanInfo
*
pTSInfo
=
pInfo
->
pTableScanOp
->
info
;
tsdbReaderClose
(
pTSInfo
->
dataReader
);
pTSInfo
->
dataReader
=
NULL
;
tsdbReaderClose
(
pTSInfo
->
base
.
dataReader
);
pTSInfo
->
base
.
dataReader
=
NULL
;
#if 0
if (tOffsetEqual(pOffset, &pTaskInfo->streamInfo.lastStatus) &&
pInfo->tqReader->pWalReader->curVersion != pOffset->version) {
...
...
@@ -1079,23 +1079,23 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
// TODO after dropping table, table may not found
ASSERT
(
found
);
if
(
pTableScanInfo
->
dataReader
==
NULL
)
{
if
(
pTableScanInfo
->
base
.
dataReader
==
NULL
)
{
STableKeyInfo
*
pList
=
tableListGetInfo
(
pTaskInfo
->
pTableInfoList
,
0
);
int32_t
num
=
tableListGetSize
(
pTaskInfo
->
pTableInfoList
);
if
(
tsdbReaderOpen
(
pTableScanInfo
->
readHandle
.
vnode
,
&
pTableScanInfo
->
cond
,
pList
,
num
,
&
pTableScanInfo
->
dataReader
,
NULL
)
<
0
||
pTableScanInfo
->
dataReader
==
NULL
)
{
if
(
tsdbReaderOpen
(
pTableScanInfo
->
base
.
readHandle
.
vnode
,
&
pTableScanInfo
->
base
.
cond
,
pList
,
num
,
&
pTableScanInfo
->
base
.
dataReader
,
NULL
)
<
0
||
pTableScanInfo
->
base
.
dataReader
==
NULL
)
{
ASSERT
(
0
);
}
}
STableKeyInfo
tki
=
{.
uid
=
uid
};
tsdbSetTableList
(
pTableScanInfo
->
dataReader
,
&
tki
,
1
);
int64_t
oldSkey
=
pTableScanInfo
->
cond
.
twindows
.
skey
;
pTableScanInfo
->
cond
.
twindows
.
skey
=
ts
+
1
;
tsdbReaderReset
(
pTableScanInfo
->
dataReader
,
&
pTableScanInfo
->
cond
);
pTableScanInfo
->
cond
.
twindows
.
skey
=
oldSkey
;
tsdbSetTableList
(
pTableScanInfo
->
base
.
dataReader
,
&
tki
,
1
);
int64_t
oldSkey
=
pTableScanInfo
->
base
.
cond
.
twindows
.
skey
;
pTableScanInfo
->
base
.
cond
.
twindows
.
skey
=
ts
+
1
;
tsdbReaderReset
(
pTableScanInfo
->
base
.
dataReader
,
&
pTableScanInfo
->
base
.
cond
);
pTableScanInfo
->
base
.
cond
.
twindows
.
skey
=
oldSkey
;
pTableScanInfo
->
scanTimes
=
0
;
qDebug
(
"tsdb reader offset seek to uid %"
PRId64
" ts %"
PRId64
", table cur set to %d , all table num %d"
,
uid
,
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
562a736d
...
...
@@ -1000,12 +1000,6 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
return
TSDB_CODE_SUCCESS
;
}
static
void
updateTableQueryInfoForReverseScan
(
STableQueryInfo
*
pTableQueryInfo
)
{
if
(
pTableQueryInfo
==
NULL
)
{
return
;
}
}
void
setTaskStatus
(
SExecTaskInfo
*
pTaskInfo
,
int8_t
status
)
{
if
(
status
==
TASK_NOT_COMPLETED
)
{
pTaskInfo
->
status
=
status
;
...
...
@@ -1652,55 +1646,6 @@ int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t
static
int32_t
doInitAggInfoSup
(
SAggSupporter
*
pAggSup
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
size_t
keyBufSize
,
const
char
*
pKey
);
static
bool
needToMerge
(
SSDataBlock
*
pBlock
,
SArray
*
groupInfo
,
char
**
buf
,
int32_t
rowIndex
)
{
size_t
size
=
taosArrayGetSize
(
groupInfo
);
if
(
size
==
0
)
{
return
true
;
}
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
int32_t
*
index
=
taosArrayGet
(
groupInfo
,
i
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
*
index
);
bool
isNull
=
colDataIsNull
(
pColInfo
,
rowIndex
,
pBlock
->
info
.
rows
,
NULL
);
if
((
isNull
&&
buf
[
i
]
!=
NULL
)
||
(
!
isNull
&&
buf
[
i
]
==
NULL
))
{
return
false
;
}
char
*
pCell
=
colDataGetData
(
pColInfo
,
rowIndex
);
if
(
IS_VAR_DATA_TYPE
(
pColInfo
->
info
.
type
))
{
if
(
varDataLen
(
pCell
)
!=
varDataLen
(
buf
[
i
]))
{
return
false
;
}
else
{
if
(
memcmp
(
varDataVal
(
pCell
),
varDataVal
(
buf
[
i
]),
varDataLen
(
pCell
))
!=
0
)
{
return
false
;
}
}
}
else
{
if
(
memcmp
(
pCell
,
buf
[
i
],
pColInfo
->
info
.
bytes
)
!=
0
)
{
return
false
;
}
}
}
return
0
;
}
static
bool
saveCurrentTuple
(
char
**
rowColData
,
SArray
*
pColumnList
,
SSDataBlock
*
pBlock
,
int32_t
rowIndex
)
{
int32_t
size
=
(
int32_t
)
taosArrayGetSize
(
pColumnList
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
int32_t
*
index
=
taosArrayGet
(
pColumnList
,
i
);
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
*
index
);
char
*
data
=
colDataGetData
(
pColInfo
,
rowIndex
);
memcpy
(
rowColData
[
i
],
data
,
colDataGetLength
(
pColInfo
,
rowIndex
));
}
return
true
;
}
int32_t
getTableScanInfo
(
SOperatorInfo
*
pOperator
,
int32_t
*
order
,
int32_t
*
scanFlag
)
{
// todo add more information about exchange operation
int32_t
type
=
pOperator
->
operatorType
;
...
...
@@ -1712,13 +1657,13 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan
return
TSDB_CODE_SUCCESS
;
}
else
if
(
type
==
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
)
{
STableScanInfo
*
pTableScanInfo
=
pOperator
->
info
;
*
order
=
pTableScanInfo
->
cond
.
order
;
*
scanFlag
=
pTableScanInfo
->
scanFlag
;
*
order
=
pTableScanInfo
->
base
.
cond
.
order
;
*
scanFlag
=
pTableScanInfo
->
base
.
scanFlag
;
return
TSDB_CODE_SUCCESS
;
}
else
if
(
type
==
QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN
)
{
STableMergeScanInfo
*
pTableScanInfo
=
pOperator
->
info
;
*
order
=
pTableScanInfo
->
cond
.
order
;
*
scanFlag
=
pTableScanInfo
->
scanFlag
;
*
order
=
pTableScanInfo
->
base
.
cond
.
order
;
*
scanFlag
=
pTableScanInfo
->
base
.
scanFlag
;
return
TSDB_CODE_SUCCESS
;
}
else
{
if
(
pOperator
->
pDownstream
==
NULL
||
pOperator
->
pDownstream
[
0
]
==
NULL
)
{
...
...
@@ -2365,8 +2310,8 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN
if
(
downstream
->
operatorType
==
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
)
{
STableScanInfo
*
pTableScanInfo
=
downstream
->
info
;
pTableScanInfo
->
pdInfo
.
pExprSup
=
&
pOperator
->
exprSupp
;
pTableScanInfo
->
pdInfo
.
pAggSup
=
&
pInfo
->
aggSup
;
pTableScanInfo
->
base
.
pdInfo
.
pExprSup
=
&
pOperator
->
exprSupp
;
pTableScanInfo
->
base
.
pdInfo
.
pAggSup
=
&
pInfo
->
aggSup
;
}
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
...
...
@@ -2731,7 +2676,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
}
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
base
.
readRecorder
;
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN
==
type
)
{
STableMergeScanPhysiNode
*
pTableScanNode
=
(
STableMergeScanPhysiNode
*
)
pPhyNode
;
...
...
@@ -2749,14 +2694,14 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
return
NULL
;
}
pOperator
=
createTableMergeScanOperatorInfo
(
pTableScanNode
,
p
TableListInfo
,
p
Handle
,
pTaskInfo
);
pOperator
=
createTableMergeScanOperatorInfo
(
pTableScanNode
,
pHandle
,
pTaskInfo
);
if
(
NULL
==
pOperator
)
{
pTaskInfo
->
code
=
terrno
;
return
NULL
;
}
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
base
.
readRecorder
;
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
==
type
)
{
pOperator
=
createExchangeOperatorInfo
(
pHandle
?
pHandle
->
pMsgCb
->
clientRpc
:
NULL
,
(
SExchangePhysiNode
*
)
pPhyNode
,
pTaskInfo
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
562a736d
此差异已折叠。
点击以展开。
source/libs/executor/src/timewindowoperator.c
浏览文件 @
562a736d
...
...
@@ -2547,8 +2547,8 @@ SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode
if
(
downstream
->
operatorType
==
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
)
{
STableScanInfo
*
pScanInfo
=
(
STableScanInfo
*
)
downstream
->
info
;
pScanInfo
->
cond
.
twindows
=
pInfo
->
win
;
pScanInfo
->
cond
.
type
=
TIMEWINDOW_RANGE_EXTERNAL
;
pScanInfo
->
base
.
cond
.
twindows
=
pInfo
->
win
;
pScanInfo
->
base
.
cond
.
type
=
TIMEWINDOW_RANGE_EXTERNAL
;
}
setOperatorInfo
(
pOperator
,
"TimeSliceOperator"
,
QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC
,
false
,
OP_NOT_OPENED
,
pInfo
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录