Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8ad76f43
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
未验证
提交
8ad76f43
编写于
8月 11, 2022
作者:
D
dapan1121
提交者:
GitHub
8月 11, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #15962 from taosdata/enh/tbHashPerf
enh: optimize getting table hash performance
上级
5570e964
11ae805c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
47 addition
and
12 deletion
+47
-12
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+45
-12
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+2
-0
未找到文件。
source/libs/catalog/src/ctgUtil.c
浏览文件 @
8ad76f43
...
...
@@ -883,6 +883,32 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
CTG_RET
(
code
);
}
int32_t
ctgHashValueComp
(
void
const
*
lp
,
void
const
*
rp
)
{
uint32_t
*
key
=
(
uint32_t
*
)
lp
;
SVgroupInfo
*
pVg
=
*
(
SVgroupInfo
**
)
rp
;
if
(
*
key
<
pVg
->
hashBegin
)
{
return
-
1
;
}
else
if
(
*
key
>
pVg
->
hashEnd
)
{
return
1
;
}
return
0
;
}
int
ctgVgInfoComp
(
const
void
*
lp
,
const
void
*
rp
)
{
SVgroupInfo
*
pLeft
=
*
(
SVgroupInfo
**
)
lp
;
SVgroupInfo
*
pRight
=
*
(
SVgroupInfo
**
)
rp
;
if
(
pLeft
->
hashBegin
<
pRight
->
hashBegin
)
{
return
-
1
;
}
else
if
(
pLeft
->
hashBegin
>
pRight
->
hashBegin
)
{
return
1
;
}
return
0
;
}
int32_t
ctgGetVgInfosFromHashValue
(
SCatalog
*
pCtg
,
SCtgTaskReq
*
tReq
,
SDBVgInfo
*
dbInfo
,
SCtgTbHashsCtx
*
pCtx
,
char
*
dbFName
,
SArray
*
pNames
,
bool
update
)
{
int32_t
code
=
0
;
SCtgTask
*
pTask
=
tReq
->
pTask
;
...
...
@@ -923,9 +949,19 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo
}
}
taosHashCancelIterate
(
dbInfo
->
vgHash
,
pIter
);
return
TSDB_CODE_SUCCESS
;
}
SArray
*
pVgList
=
taosArrayInit
(
vgNum
,
POINTER_BYTES
);
void
*
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
NULL
);
while
(
pIter
)
{
taosArrayPush
(
pVgList
,
&
pIter
);
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
pIter
);
}
taosArraySort
(
pVgList
,
ctgVgInfoComp
);
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
sprintf
(
tbFullName
,
"%s."
,
dbFName
);
int32_t
offset
=
strlen
(
tbFullName
);
...
...
@@ -940,25 +976,20 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo
uint32_t
hashValue
=
(
*
fp
)(
tbFullName
,
(
uint32_t
)
tbNameLen
);
void
*
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
NULL
);
while
(
pIter
)
{
vgInfo
=
pIter
;
if
(
hashValue
>=
vgInfo
->
hashBegin
&&
hashValue
<=
vgInfo
->
hashEnd
)
{
taosHashCancelIterate
(
dbInfo
->
vgHash
,
pIter
);
break
;
}
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
pIter
);
vgInfo
=
NULL
;
}
SVgroupInfo
**
p
=
taosArraySearch
(
pVgList
,
&
hashValue
,
ctgHashValueComp
,
TD_EQ
);
if
(
NULL
==
vgInfo
)
{
if
(
NULL
==
p
)
{
ctgError
(
"no hash range found for hash value [%u], db:%s, numOfVgId:%d"
,
hashValue
,
dbFName
,
taosHashGetSize
(
dbInfo
->
vgHash
));
ASSERT
(
0
);
taosArrayDestroy
(
pVgList
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
vgInfo
=
*
p
;
SVgroupInfo
*
pNewVg
=
taosMemoryMalloc
(
sizeof
(
SVgroupInfo
));
if
(
NULL
==
pNewVg
)
{
taosArrayDestroy
(
pVgList
);
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
...
...
@@ -977,6 +1008,8 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo
}
}
taosArrayDestroy
(
pVgList
);
CTG_RET
(
code
);
}
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
8ad76f43
...
...
@@ -1949,6 +1949,7 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
SExchangeInfo
*
pExchangeInfo
=
taosAcquireRef
(
exchangeObjRefPool
,
pWrapper
->
exchangeId
);
if
(
pExchangeInfo
==
NULL
)
{
qWarn
(
"failed to acquire exchange operator, since it may have been released"
);
taosMemoryFree
(
pMsg
->
pData
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1969,6 +1970,7 @@ int32_t loadRemoteDataCallback(void* param, SDataBuf* pMsg, int32_t code) {
qDebug
(
"%s fetch rsp received, index:%d, blocks:%d, rows:%d"
,
pSourceDataInfo
->
taskId
,
index
,
pRsp
->
numOfBlocks
,
pRsp
->
numOfRows
);
}
else
{
taosMemoryFree
(
pMsg
->
pData
);
pSourceDataInfo
->
code
=
code
;
qDebug
(
"%s fetch rsp received, index:%d, error:%d"
,
pSourceDataInfo
->
taskId
,
index
,
tstrerror
(
code
));
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录