Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
e4de7322
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看板
提交
e4de7322
编写于
10月 29, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): always build hash map from uid to keyinfo
上级
4cd14c41
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
43 addition
and
55 deletion
+43
-55
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-1
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+18
-16
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+1
-0
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+11
-11
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+12
-27
未找到文件。
source/libs/executor/inc/executorimpl.h
浏览文件 @
e4de7322
...
...
@@ -1077,7 +1077,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
void
copyUpdateDataBlock
(
SSDataBlock
*
pDest
,
SSDataBlock
*
pSource
,
int32_t
tsColIndex
);
bool
groupbyTbname
(
SNodeList
*
pGroupList
);
int32_t
generateGroupIdMap
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
SNodeList
*
group
,
bool
groupSort
);
int32_t
setGroupIdMapForAllTables
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
SNodeList
*
group
,
bool
groupSort
);
void
*
destroySqlFunctionCtx
(
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
);
int32_t
buildDataBlockFromGroupRes
(
SOperatorInfo
*
pOperator
,
SStreamState
*
pState
,
SSDataBlock
*
pBlock
,
SExprSupp
*
pSup
,
SGroupResInfo
*
pGroupResInfo
);
...
...
source/libs/executor/src/executil.c
浏览文件 @
e4de7322
...
...
@@ -741,7 +741,8 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
int32_t
len
=
(
int32_t
)(
pStart
-
(
char
*
)
keyBuf
);
info
->
groupId
=
calcGroupId
(
keyBuf
,
len
);
taosHashPut
(
pTableListInfo
->
map
,
&
(
info
->
uid
),
sizeof
(
uint64_t
),
&
info
->
groupId
,
sizeof
(
uint64_t
));
taosHashPut
(
pTableListInfo
->
map
,
&
(
info
->
uid
),
sizeof
(
uint64_t
),
&
i
,
sizeof
(
int32_t
));
}
// int64_t st2 = taosGetTimestampUs();
...
...
@@ -1665,29 +1666,29 @@ uint64_t getTotalTables(const STableListInfo* pTableList) {
}
uint64_t
getTableGroupId
(
const
STableListInfo
*
pTableList
,
uint64_t
tableUid
)
{
if
(
pTableList
->
oneTableForEachGroup
)
{
return
tableUid
;
}
ASSERT
(
pTableList
->
map
!=
NULL
);
int32_t
*
slot
=
taosHashGet
(
pTableList
->
map
,
&
tableUid
,
sizeof
(
tableUid
))
;
ASSERT
(
slot
!=
NULL
);
uint64_t
*
groupId
=
taosHashGet
(
pTableList
->
map
,
&
tableUid
,
sizeof
(
tableUid
));
if
(
groupId
!=
NULL
)
{
return
*
groupId
;
}
else
{
return
0
;
}
STableKeyInfo
*
pKeyInfo
=
taosArrayGet
(
pTableList
->
pTableList
,
*
slot
);
ASSERT
(
pKeyInfo
->
uid
==
tableUid
);
return
pKeyInfo
->
groupId
;
}
int32_t
addTableIntoTableList
(
STableListInfo
*
pTableList
,
uint64_t
uid
,
uint64_t
gid
)
{
if
(
pTableList
->
map
==
NULL
)
{
ASSERT
(
taosArrayGetSize
(
pTableList
->
pTableList
)
==
0
);
pTableList
->
map
=
taosHashInit
(
32
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_ENTRY_LOCK
);
}
STableKeyInfo
keyInfo
=
{.
uid
=
uid
,
.
groupId
=
gid
};
taosArrayPush
(
pTableList
->
pTableList
,
&
keyInfo
);
if
(
!
pTableList
->
oneTableForEachGroup
)
{
if
(
pTableList
->
map
==
NULL
)
{
pTableList
->
map
=
taosHashInit
(
32
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_ENTRY_LOCK
);
}
taosHashPut
(
pTableList
->
map
,
&
uid
,
sizeof
(
uid
),
&
keyInfo
.
groupId
,
sizeof
(
keyInfo
.
groupId
))
;
}
int32_t
slot
=
(
int32_t
)
taosArrayGetSize
(
pTableList
->
pTableList
)
-
1
;
taosHashPut
(
pTableList
->
map
,
&
uid
,
sizeof
(
uid
),
&
slot
,
sizeof
(
slot
));
qDebug
(
"uid:%"
PRIu64
", groupId:%"
PRIu64
" added into table list, slot:%d, %d"
,
uid
,
gid
,
slot
,
slot
+
1
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1724,6 +1725,7 @@ int32_t getNumOfOutputGroups(const STableListInfo* pTableList) {
return
pTableList
->
numOfOuputGroups
;
}
// todo remove it
bool
oneTableForEachGroup
(
const
STableListInfo
*
pTableList
)
{
return
pTableList
->
oneTableForEachGroup
;
}
...
...
source/libs/executor/src/executor.c
浏览文件 @
e4de7322
...
...
@@ -360,6 +360,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
if (!exists) {
#endif
addTableIntoTableList
(
pTableListInfo
,
keyInfo
.
uid
,
keyInfo
.
groupId
);
}
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
e4de7322
...
...
@@ -3489,11 +3489,8 @@ bool groupbyTbname(SNodeList* pGroupList) {
return
bytbname
;
}
int32_t
generateGroupIdMap
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
SNodeList
*
group
,
bool
groupSort
)
{
int32_t
setGroupIdMapForAllTables
(
STableListInfo
*
pTableListInfo
,
SReadHandle
*
pHandle
,
SNodeList
*
group
,
bool
groupSort
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
group
==
NULL
)
{
return
code
;
}
pTableListInfo
->
map
=
taosHashInit
(
32
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_ENTRY_LOCK
);
if
(
pTableListInfo
->
map
==
NULL
)
{
...
...
@@ -3501,19 +3498,22 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
return
code
;
}
bool
assignUid
=
groupbyTbname
(
group
);
bool
groupByTbname
=
groupbyTbname
(
group
);
size_t
numOfTables
=
taosArrayGetSize
(
pTableListInfo
->
pTableList
);
if
(
assignUid
)
{
// in case of group/partition by tbname, the group id is equalled to the uid of table
if
(
group
==
NULL
||
groupByTbname
)
{
for
(
int32_t
i
=
0
;
i
<
numOfTables
;
i
++
)
{
STableKeyInfo
*
info
=
taosArrayGet
(
pTableListInfo
->
pTableList
,
i
);
info
->
groupId
=
info
->
uid
;
taosHashPut
(
pTableListInfo
->
map
,
&
(
info
->
uid
),
sizeof
(
uint64_t
),
&
info
->
groupId
,
sizeof
(
uint64_t
));
info
->
groupId
=
groupByTbname
?
info
->
uid
:
0
;
taosHashPut
(
pTableListInfo
->
map
,
&
(
info
->
uid
),
sizeof
(
uint64_t
),
&
i
,
sizeof
(
int32_t
));
}
pTableListInfo
->
oneTableForEachGroup
=
true
;
if
(
groupSort
)
{
pTableListInfo
->
oneTableForEachGroup
=
groupByTbname
;
if
(
groupSort
&&
groupByTbname
)
{
pTableListInfo
->
numOfOuputGroups
=
numOfTables
;
}
else
{
pTableListInfo
->
numOfOuputGroups
=
1
;
}
}
else
{
code
=
getColInfoResultForGroupby
(
pHandle
->
meta
,
group
,
pTableListInfo
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
e4de7322
...
...
@@ -1137,12 +1137,13 @@ static uint64_t getGroupIdByCol(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts,
}
static
uint64_t
getGroupIdByUid
(
SStreamScanInfo
*
pInfo
,
uint64_t
uid
)
{
SHashObj
*
map
=
pInfo
->
pTableScanOp
->
pTaskInfo
->
tableqinfoList
.
map
;
uint64_t
*
groupId
=
taosHashGet
(
map
,
&
uid
,
sizeof
(
int64_t
));
if
(
groupId
)
{
return
*
groupId
;
}
return
0
;
return
getTableGroupId
(
&
pInfo
->
pTableScanOp
->
pTaskInfo
->
tableqinfoList
,
uid
);
// SHashObj* map = pInfo->pTableScanOp->pTaskInfo->tableqinfoList.map;
// uint64_t* groupId = taosHashGet(map, &uid, sizeof(int64_t));
// if (groupId) {
// return *groupId;
// }
// return 0;
}
static
uint64_t
getGroupIdByData
(
SStreamScanInfo
*
pInfo
,
uint64_t
uid
,
TSKEY
ts
,
int64_t
maxVersion
)
{
...
...
@@ -1561,12 +1562,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
pInfo
->
pRes
->
info
.
type
=
STREAM_NORMAL
;
pInfo
->
pRes
->
info
.
version
=
pBlock
->
info
.
version
;
uint64_t
*
groupIdPre
=
taosHashGet
(
pTaskInfo
->
tableqinfoList
.
map
,
&
pBlock
->
info
.
uid
,
sizeof
(
int64_t
));
if
(
groupIdPre
)
{
pInfo
->
pRes
->
info
.
groupId
=
*
groupIdPre
;
}
else
{
pInfo
->
pRes
->
info
.
groupId
=
0
;
}
pInfo
->
pRes
->
info
.
groupId
=
getTableGroupId
(
&
pTaskInfo
->
tableqinfoList
,
pBlock
->
info
.
uid
);
// todo extract method
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
matchInfo
.
pList
);
++
i
)
{
...
...
@@ -4236,7 +4232,7 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags
}
pTableListInfo
->
numOfOuputGroups
=
1
;
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
pGroupTags
,
groupSort
);
code
=
setGroupIdMapForAllTables
(
pTableListInfo
,
pHandle
,
pGroupTags
,
groupSort
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
...
...
@@ -4566,10 +4562,7 @@ static SSDataBlock* getTableDataBlockTemp(void* param) {
continue
;
}
uint64_t
*
groupId
=
taosHashGet
(
pOperator
->
pTaskInfo
->
tableqinfoList
.
map
,
&
pBlock
->
info
.
uid
,
sizeof
(
int64_t
));
if
(
groupId
)
{
pBlock
->
info
.
groupId
=
*
groupId
;
}
pBlock
->
info
.
groupId
=
getTableGroupId
(
&
pOperator
->
pTaskInfo
->
tableqinfoList
,
pBlock
->
info
.
uid
);
pOperator
->
resultInfo
.
totalRows
+=
pBlock
->
info
.
rows
;
// pTableScanInfo->readRecorder.totalRows;
pTableScanInfo
->
readRecorder
.
elapsedTime
+=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
...
...
@@ -4626,11 +4619,7 @@ static SSDataBlock* getTableDataBlock2(void* param) {
continue
;
}
uint64_t
*
groupId
=
taosHashGet
(
pOperator
->
pTaskInfo
->
tableqinfoList
.
map
,
&
pBlock
->
info
.
uid
,
sizeof
(
int64_t
));
if
(
groupId
)
{
pBlock
->
info
.
groupId
=
*
groupId
;
}
pBlock
->
info
.
groupId
=
getTableGroupId
(
&
pOperator
->
pTaskInfo
->
tableqinfoList
,
pBlock
->
info
.
uid
);
pOperator
->
resultInfo
.
totalRows
=
pTableScanInfo
->
readRecorder
.
totalRows
;
pTableScanInfo
->
readRecorder
.
elapsedTime
+=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
...
...
@@ -4684,11 +4673,7 @@ static SSDataBlock* getTableDataBlock(void* param) {
continue
;
}
uint64_t
*
groupId
=
taosHashGet
(
pOperator
->
pTaskInfo
->
tableqinfoList
.
map
,
&
pBlock
->
info
.
uid
,
sizeof
(
int64_t
));
if
(
groupId
)
{
pBlock
->
info
.
groupId
=
*
groupId
;
}
pBlock
->
info
.
groupId
=
getTableGroupId
(
&
pOperator
->
pTaskInfo
->
tableqinfoList
,
pBlock
->
info
.
uid
);
pOperator
->
resultInfo
.
totalRows
=
pTableScanInfo
->
readRecorder
.
totalRows
;
pTableScanInfo
->
readRecorder
.
elapsedTime
+=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录