Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
41c99c02
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看板
提交
41c99c02
编写于
10月 30, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: do some internal refactor.
上级
52c37778
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
100 addition
and
62 deletion
+100
-62
source/libs/executor/src/cachescanoperator.c
source/libs/executor/src/cachescanoperator.c
+13
-9
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+1
-9
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+8
-8
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+78
-36
未找到文件。
source/libs/executor/src/cachescanoperator.c
浏览文件 @
41c99c02
...
...
@@ -62,7 +62,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
pInfo
->
pUidList
=
taosArrayInit
(
4
,
sizeof
(
int64_t
));
// partition by tbname
if
(
taosArrayGetSize
(
pTableList
->
pGroupList
)
==
taosArrayGetSize
(
pTableList
->
pTableList
))
{
if
(
oneTableForEachGroup
(
pTableList
)
||
(
getTotalTables
(
pTableList
)
==
1
))
{
pInfo
->
retrieveType
=
CACHESCAN_RETRIEVE_TYPE_ALL
|
(
pScanNode
->
ignoreNull
?
CACHESCAN_RETRIEVE_LAST
:
CACHESCAN_RETRIEVE_LAST_ROW
);
code
=
tsdbCacherowsReaderOpen
(
pInfo
->
readHandle
.
vnode
,
pInfo
->
retrieveType
,
pTableList
->
pTableList
,
...
...
@@ -175,12 +175,18 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
return
NULL
;
}
}
else
{
size_t
totalGroups
=
taosArrayGetSize
(
pTableList
->
pGroupList
);
while
(
pInfo
->
currentGroupIndex
<
totalGroups
)
{
SArray
*
pGroupTableList
=
taosArrayGetP
(
pTableList
->
pGroupList
,
pInfo
->
currentGroupIndex
);
size_t
num
=
getNumOfOutputGroups
(
pTableList
);
while
(
pInfo
->
currentGroupIndex
<
num
)
{
STableKeyInfo
*
p
=
NULL
;
int32_t
s
=
0
;
getTablesOfGroup
(
pTableList
,
pInfo
->
currentGroupIndex
,
&
p
,
&
s
);
SArray
*
x
=
taosArrayInit
(
4
,
sizeof
(
STableKeyInfo
));
for
(
int32_t
i
=
0
;
i
<
s
;
++
i
)
{
taosArrayPush
(
x
,
&
p
[
i
]);
}
tsdbCacherowsReaderOpen
(
pInfo
->
readHandle
.
vnode
,
pInfo
->
retrieveType
,
pGroupTableList
,
tsdbCacherowsReaderOpen
(
pInfo
->
readHandle
.
vnode
,
pInfo
->
retrieveType
,
x
,
taosArrayGetSize
(
pInfo
->
matchInfo
.
pList
),
pTableList
->
suid
,
&
pInfo
->
pLastrowReader
);
taosArrayClear
(
pInfo
->
pUidList
);
...
...
@@ -195,9 +201,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
if
(
pInfo
->
pRes
->
info
.
rows
>
0
)
{
if
(
pInfo
->
pseudoExprSup
.
numOfExprs
>
0
)
{
SExprSupp
*
pSup
=
&
pInfo
->
pseudoExprSup
;
STableKeyInfo
*
pKeyInfo
=
taosArrayGet
(
pGroupTableList
,
0
);
pInfo
->
pRes
->
info
.
groupId
=
pKeyInfo
->
groupId
;
pInfo
->
pRes
->
info
.
groupId
=
p
->
groupId
;
if
(
taosArrayGetSize
(
pInfo
->
pUidList
)
>
0
)
{
ASSERT
((
pInfo
->
retrieveType
&
CACHESCAN_RETRIEVE_LAST_ROW
)
==
CACHESCAN_RETRIEVE_LAST_ROW
);
...
...
source/libs/executor/src/executil.c
浏览文件 @
41c99c02
...
...
@@ -997,14 +997,6 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
}
taosArrayDestroy
(
res
);
pListInfo
->
pGroupList
=
taosArrayInit
(
4
,
POINTER_BYTES
);
if
(
pListInfo
->
pGroupList
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
// put into list as default group, remove it if grouping sorting is required later
taosArrayPush
(
pListInfo
->
pGroupList
,
&
pListInfo
->
pTableList
);
return
code
;
}
...
...
@@ -1698,7 +1690,7 @@ int32_t getTablesOfGroup(const STableListInfo* pTableList, int32_t ordinalGroupI
// 1. only one group exists, and 2. one table exists for each group.
if
(
total
==
1
)
{
*
size
=
getTotalTables
(
pTableList
);
*
pKeyInfo
=
taosArrayGet
(
pTableList
->
pTableList
,
0
);
*
pKeyInfo
=
(
*
size
==
0
)
?
NULL
:
taosArrayGet
(
pTableList
->
pTableList
,
0
);
return
TSDB_CODE_SUCCESS
;
}
else
if
(
total
==
getTotalTables
(
pTableList
))
{
*
size
=
1
;
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
41c99c02
...
...
@@ -4026,15 +4026,15 @@ void doDestroyTableList(STableListInfo* pTableqinfoList) {
taosArrayDestroy
(
pTableqinfoList
->
pTableList
);
taosHashCleanup
(
pTableqinfoList
->
map
);
if
(
pTableqinfoList
->
needSortTableByGroupId
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pTableqinfoList
->
pGroupList
);
i
++
)
{
SArray
*
tmp
=
taosArrayGetP
(
pTableqinfoList
->
pGroupList
,
i
);
if
(
tmp
==
pTableqinfoList
->
pTableList
)
{
continue
;
}
taosArrayDestroy
(
tmp
);
}
//
for (int32_t i = 0; i < taosArrayGetSize(pTableqinfoList->pGroupList); i++) {
//
SArray* tmp = taosArrayGetP(pTableqinfoList->pGroupList, i);
//
if (tmp == pTableqinfoList->pTableList) {
//
continue;
//
}
//
taosArrayDestroy(tmp);
//
}
}
taosArrayDestroy
(
pTableqinfoList
->
pGroupList
);
//
taosArrayDestroy(pTableqinfoList->pGroupList);
pTableqinfoList
->
pTableList
=
NULL
;
pTableqinfoList
->
map
=
NULL
;
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
41c99c02
...
...
@@ -749,20 +749,28 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
if
(
pInfo
->
currentGroupId
==
-
1
)
{
pInfo
->
currentGroupId
++
;
qDebug
(
"number:------------------------%d, %d"
,
(
int
)
taosArrayGetSize
(
pTaskInfo
->
tableqinfoList
.
pGroupList
),
getNumOfOutputGroups
(
&
pTaskInfo
->
tableqinfoList
));
//
qDebug("number:------------------------%d, %d", (int)taosArrayGetSize(pTaskInfo->tableqinfoList.pGroupList),
//
getNumOfOutputGroups(&pTaskInfo->tableqinfoList));
if
(
pInfo
->
currentGroupId
>=
getNumOfOutputGroups
(
&
pTaskInfo
->
tableqinfoList
)
/*taosArrayGetSize(pTaskInfo->tableqinfoList.pGroupList)*/
)
{
// if (pInfo->currentGroupId >= taosArrayGetSize(pTaskInfo->tableqinfoList.pGroupList)) {
// setTaskStatus(pTaskInfo, TASK_COMPLETED);
doSetOperatorCompleted
(
pOperator
);
return
NULL
;
}
SArray
*
tableList
=
taosArrayGetP
(
pTaskInfo
->
tableqinfoList
.
pGroupList
,
pInfo
->
currentGroupId
);
SArray
*
p
=
taosArrayInit
(
4
,
sizeof
(
STableKeyInfo
)
);
tsdbReaderClose
(
pInfo
->
dataReader
);
int32_t
code
=
tsdbReaderOpen
(
pInfo
->
readHandle
.
vnode
,
&
pInfo
->
cond
,
tableList
,
(
STsdbReader
**
)
&
pInfo
->
dataReader
,
STableKeyInfo
*
x
=
NULL
;
int32_t
num
=
0
;
getTablesOfGroup
(
&
pTaskInfo
->
tableqinfoList
,
pInfo
->
currentGroupId
,
&
x
,
&
num
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
taosArrayPush
(
p
,
&
x
[
i
]);
}
int32_t
code
=
tsdbReaderOpen
(
pInfo
->
readHandle
.
vnode
,
&
pInfo
->
cond
,
p
,
(
STsdbReader
**
)
&
pInfo
->
dataReader
,
GET_TASKID
(
pTaskInfo
));
taosArrayDestroy
(
p
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
T_LONG_JMP
(
pTaskInfo
->
env
,
code
);
return
NULL
;
...
...
@@ -775,11 +783,16 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
}
pInfo
->
currentGroupId
++
;
if
(
pInfo
->
currentGroupId
>=
taosArrayGetSize
(
pTaskInfo
->
tableqinfoList
.
pGroup
List
))
{
setTaskStatus
(
pTaskInfo
,
TASK_COMPLETED
);
if
(
pInfo
->
currentGroupId
>=
getNumOfOutputGroups
(
&
pTaskInfo
->
tableqinfo
List
))
{
doSetOperatorCompleted
(
pOperator
);
return
NULL
;
}
// reset value for the next group data output
pOperator
->
status
=
OP_OPENED
;
pInfo
->
limitInfo
.
numOfOutputRows
=
0
;
pInfo
->
limitInfo
.
remainOffset
=
pInfo
->
limitInfo
.
limit
.
offset
;
tsdbReaderReset
(
pInfo
->
dataReader
,
&
pInfo
->
cond
);
pInfo
->
scanTimes
=
0
;
...
...
@@ -1075,39 +1088,59 @@ void resetTableScanInfo(STableScanInfo* pTableScanInfo, STimeWindow* pWin) {
pTableScanInfo
->
cond
.
twindows
=
*
pWin
;
pTableScanInfo
->
scanTimes
=
0
;
pTableScanInfo
->
currentGroupId
=
-
1
;
}
static
void
freeArray
(
void
*
array
)
{
taosArrayDestroy
(
array
);
}
static
void
resetTableScanOperator
(
SOperatorInfo
*
pTableScanOp
)
{
STableScanInfo
*
pTableScanInfo
=
pTableScanOp
->
info
;
pTableScanInfo
->
cond
.
startVersion
=
-
1
;
pTableScanInfo
->
cond
.
endVersion
=
-
1
;
SArray
*
gpTbls
=
pTableScanOp
->
pTaskInfo
->
tableqinfoList
.
pGroupList
;
SArray
*
allTbls
=
pTableScanOp
->
pTaskInfo
->
tableqinfoList
.
pTableList
;
taosArrayClearP
(
gpTbls
,
freeArray
);
taosArrayPush
(
gpTbls
,
&
allTbls
);
STimeWindow
win
=
{.
skey
=
INT64_MIN
,
.
ekey
=
INT64_MAX
};
resetTableScanInfo
(
pTableScanOp
->
info
,
&
win
);
tsdbReaderClose
(
pTableScanInfo
->
dataReader
);
pTableScanInfo
->
dataReader
=
NULL
;
}
static
SSDataBlock
*
readPreVersionData
(
SOperatorInfo
*
pTableScanOp
,
uint64_t
tbUid
,
TSKEY
startTs
,
TSKEY
endTs
,
int64_t
maxVersion
)
{
SArray
*
gpTbls
=
pTableScanOp
->
pTaskInfo
->
tableqinfoList
.
pGroupList
;
taosArrayClear
(
gpTbls
);
STableKeyInfo
tblInfo
=
{.
uid
=
tbUid
,
.
groupId
=
0
};
SArray
*
tbls
=
taosArrayInit
(
1
,
sizeof
(
STableKeyInfo
));
taosArrayPush
(
tbls
,
&
tblInfo
);
taosArrayPush
(
gpTbls
,
&
tbls
);
STimeWindow
win
=
{.
skey
=
startTs
,
.
ekey
=
endTs
};
STableScanInfo
*
pTableScanInfo
=
pTableScanOp
->
info
;
pTableScanInfo
->
cond
.
startVersion
=
-
1
;
pTableScanInfo
->
cond
.
endVersion
=
maxVersion
;
resetTableScanInfo
(
pTableScanOp
->
info
,
&
win
);
SSDataBlock
*
pRes
=
doTableScan
(
pTableScanOp
);
resetTableScanOperator
(
pTableScanOp
);
return
pRes
;
STableScanInfo
*
pTableScanInfo
=
pTableScanOp
->
info
;
SQueryTableDataCond
cond
=
pTableScanInfo
->
cond
;
cond
.
startVersion
=
-
1
;
cond
.
endVersion
=
maxVersion
;
cond
.
twindows
=
(
STimeWindow
){.
skey
=
startTs
,
.
ekey
=
endTs
};
SExecTaskInfo
*
pTaskInfo
=
pTableScanOp
->
pTaskInfo
;
SSDataBlock
*
pBlock
=
pTableScanInfo
->
pResBlock
;
blockDataCleanup
(
pBlock
);
SArray
*
p
=
taosArrayInit
(
1
,
sizeof
(
STableKeyInfo
));
taosArrayPush
(
p
,
&
tblInfo
);
STsdbReader
*
pReader
=
NULL
;
int32_t
code
=
tsdbReaderOpen
(
pTableScanInfo
->
readHandle
.
vnode
,
&
cond
,
p
,
(
STsdbReader
**
)
&
pReader
,
GET_TASKID
(
pTaskInfo
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
return
NULL
;
}
bool
hasBlock
=
tsdbNextDataBlock
(
pReader
);
if
(
hasBlock
)
{
SDataBlockInfo
binfo
=
{
0
};
tsdbRetrieveDataBlockInfo
(
pReader
,
&
binfo
);
SArray
*
pCols
=
tsdbRetrieveDataBlock
(
pReader
,
NULL
);
blockDataEnsureCapacity
(
pBlock
,
binfo
.
rows
);
pBlock
->
info
.
window
=
binfo
.
window
;
pBlock
->
info
.
uid
=
binfo
.
uid
;
pBlock
->
info
.
rows
=
binfo
.
rows
;
relocateColumnData
(
pBlock
,
pTableScanInfo
->
matchInfo
.
pList
,
pCols
,
true
);
doSetTagColumnData
(
pTableScanInfo
,
pBlock
,
pTaskInfo
);
pBlock
->
info
.
groupId
=
getTableGroupId
(
&
pTaskInfo
->
tableqinfoList
,
binfo
.
uid
);
}
tsdbReaderClose
(
pReader
);
qDebug
(
"retrieve prev rows:%d, skey:%"
PRId64
", ekey:%"
PRId64
" uid:%"
PRIu64
", max ver:%"
PRId64
", suid:%"
PRIu64
,
pBlock
->
info
.
rows
,
startTs
,
endTs
,
tbUid
,
maxVersion
,
cond
.
suid
);
return
pBlock
->
info
.
rows
>
0
?
pBlock
:
NULL
;
}
static
uint64_t
getGroupIdByCol
(
SStreamScanInfo
*
pInfo
,
uint64_t
uid
,
TSKEY
ts
,
int64_t
maxVersion
)
{
...
...
@@ -2329,11 +2362,20 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
pTSInfo
->
cond
.
endVersion
=
pHandle
->
version
;
}
SArray
*
tableList
=
taosArrayGetP
(
pTaskInfo
->
tableqinfoList
.
pGroupList
,
0
);
// SArray* tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, 0);
STableKeyInfo
*
pList
=
NULL
;
int32_t
num
=
0
;
getTablesOfGroup
(
&
pTaskInfo
->
tableqinfoList
,
0
,
&
pList
,
&
num
);
SArray
*
p
=
taosArrayInit
(
4
,
sizeof
(
STableKeyInfo
));
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
taosArrayPush
(
p
,
&
pList
[
i
]);
}
if
(
pHandle
->
initTableReader
)
{
pTSInfo
->
scanMode
=
TABLE_SCAN__TABLE_ORDER
;
pTSInfo
->
dataReader
=
NULL
;
if
(
tsdbReaderOpen
(
pHandle
->
vnode
,
&
pTSInfo
->
cond
,
tableList
,
&
pTSInfo
->
dataReader
,
NULL
)
<
0
)
{
if
(
tsdbReaderOpen
(
pHandle
->
vnode
,
&
pTSInfo
->
cond
,
p
,
&
pTSInfo
->
dataReader
,
NULL
)
<
0
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_error
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录