Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
72615fde
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1181
Star
22014
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
72615fde
编写于
9月 05, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
9月 05, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #16662 from taosdata/feat/TD-18892
feat: support table name prefix/suffix config
上级
0963df90
dc4504b4
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
26 addition
and
12 deletion
+26
-12
include/common/tmsg.h
include/common/tmsg.h
+2
-0
include/libs/qcom/query.h
include/libs/qcom/query.h
+2
-0
source/client/src/clientHb.c
source/client/src/clientHb.c
+2
-0
source/common/src/tmsg.c
source/common/src/tmsg.c
+4
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+4
-0
source/libs/catalog/src/ctgDbg.c
source/libs/catalog/src/ctgDbg.c
+6
-2
source/libs/catalog/src/ctgUtil.c
source/libs/catalog/src/ctgUtil.c
+2
-10
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+2
-0
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+2
-0
未找到文件。
include/common/tmsg.h
浏览文件 @
72615fde
...
...
@@ -845,6 +845,8 @@ typedef struct {
int64_t
uid
;
int32_t
vgVersion
;
int32_t
vgNum
;
int16_t
hashPrefix
;
int16_t
hashSuffix
;
int8_t
hashMethod
;
SArray
*
pVgroupInfos
;
// Array of SVgroupInfo
}
SUseDbRsp
;
...
...
include/libs/qcom/query.h
浏览文件 @
72615fde
...
...
@@ -116,6 +116,8 @@ typedef struct STableMeta {
typedef
struct
SDBVgInfo
{
int32_t
vgVersion
;
int16_t
hashPrefix
;
int16_t
hashSuffix
;
int8_t
hashMethod
;
int32_t
numOfTable
;
// DB's table num, unit is TSDB_TABLE_NUM_UNIT
SHashObj
*
vgHash
;
// key:vgId, value:SVgroupInfo
...
...
source/client/src/clientHb.c
浏览文件 @
72615fde
...
...
@@ -73,6 +73,8 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
vgInfo
->
vgVersion
=
rsp
->
vgVersion
;
vgInfo
->
hashMethod
=
rsp
->
hashMethod
;
vgInfo
->
hashPrefix
=
rsp
->
hashPrefix
;
vgInfo
->
hashSuffix
=
rsp
->
hashSuffix
;
vgInfo
->
vgHash
=
taosHashInit
(
rsp
->
vgNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
vgInfo
->
vgHash
)
{
taosMemoryFree
(
vgInfo
);
...
...
source/common/src/tmsg.c
浏览文件 @
72615fde
...
...
@@ -2463,6 +2463,8 @@ int32_t tSerializeSUseDbRspImp(SEncoder *pEncoder, const SUseDbRsp *pRsp) {
if
(
tEncodeI64
(
pEncoder
,
pRsp
->
uid
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pRsp
->
vgVersion
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pRsp
->
vgNum
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
pEncoder
,
pRsp
->
hashPrefix
)
<
0
)
return
-
1
;
if
(
tEncodeI16
(
pEncoder
,
pRsp
->
hashSuffix
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pRsp
->
hashMethod
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pRsp
->
vgNum
;
++
i
)
{
...
...
@@ -2514,6 +2516,8 @@ int32_t tDeserializeSUseDbRspImp(SDecoder *pDecoder, SUseDbRsp *pRsp) {
if
(
tDecodeI64
(
pDecoder
,
&
pRsp
->
uid
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pRsp
->
vgVersion
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pRsp
->
vgNum
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
pDecoder
,
&
pRsp
->
hashPrefix
)
<
0
)
return
-
1
;
if
(
tDecodeI16
(
pDecoder
,
&
pRsp
->
hashSuffix
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pRsp
->
hashMethod
)
<
0
)
return
-
1
;
if
(
pRsp
->
vgNum
<=
0
)
{
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
72615fde
...
...
@@ -1171,6 +1171,8 @@ int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUs
pRsp
->
vgVersion
=
pDb
->
vgVersion
;
pRsp
->
vgNum
=
taosArrayGetSize
(
pRsp
->
pVgroupInfos
);
pRsp
->
hashMethod
=
pDb
->
cfg
.
hashMethod
;
pRsp
->
hashPrefix
=
pDb
->
cfg
.
hashPrefix
;
pRsp
->
hashSuffix
=
pDb
->
cfg
.
hashSuffix
;
return
0
;
}
...
...
@@ -1303,6 +1305,8 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
usedbRsp
.
vgVersion
=
pDb
->
vgVersion
;
usedbRsp
.
vgNum
=
(
int32_t
)
taosArrayGetSize
(
usedbRsp
.
pVgroupInfos
);
usedbRsp
.
hashMethod
=
pDb
->
cfg
.
hashMethod
;
usedbRsp
.
hashPrefix
=
pDb
->
cfg
.
hashPrefix
;
usedbRsp
.
hashSuffix
=
pDb
->
cfg
.
hashSuffix
;
taosArrayPush
(
batchUseRsp
.
pArray
,
&
usedbRsp
);
mndReleaseDb
(
pMnode
,
pDb
);
...
...
source/libs/catalog/src/ctgDbg.c
浏览文件 @
72615fde
...
...
@@ -367,18 +367,22 @@ void ctgdShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
int32_t
stbNum
=
dbCache
->
stbCache
?
taosHashGetSize
(
dbCache
->
stbCache
)
:
0
;
int32_t
vgVersion
=
CTG_DEFAULT_INVALID_VERSION
;
int32_t
hashMethod
=
-
1
;
int16_t
hashPrefix
=
0
;
int16_t
hashSuffix
=
0
;
int32_t
vgNum
=
0
;
if
(
dbCache
->
vgCache
.
vgInfo
)
{
vgVersion
=
dbCache
->
vgCache
.
vgInfo
->
vgVersion
;
hashMethod
=
dbCache
->
vgCache
.
vgInfo
->
hashMethod
;
hashPrefix
=
dbCache
->
vgCache
.
vgInfo
->
hashPrefix
;
hashSuffix
=
dbCache
->
vgCache
.
vgInfo
->
hashSuffix
;
if
(
dbCache
->
vgCache
.
vgInfo
->
vgHash
)
{
vgNum
=
taosHashGetSize
(
dbCache
->
vgCache
.
vgInfo
->
vgHash
);
}
}
ctgDebug
(
"[%d] db [%.*s][0x%"
PRIx64
"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, vgNum:%d"
,
i
,
(
int32_t
)
len
,
dbFName
,
dbCache
->
dbId
,
dbCache
->
deleted
?
"deleted"
:
""
,
metaNum
,
stbNum
,
vgVersion
,
hashMethod
,
vgNum
);
ctgDebug
(
"[%d] db [%.*s][0x%"
PRIx64
"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d,
prefix:%d, suffix:%d,
vgNum:%d"
,
i
,
(
int32_t
)
len
,
dbFName
,
dbCache
->
dbId
,
dbCache
->
deleted
?
"deleted"
:
""
,
metaNum
,
stbNum
,
vgVersion
,
hashMethod
,
hashPrefix
,
hashSuffix
,
vgNum
);
pIter
=
taosHashIterate
(
dbHash
,
pIter
);
}
...
...
source/libs/catalog/src/ctgUtil.c
浏览文件 @
72615fde
...
...
@@ -848,15 +848,11 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
CTG_ERR_RET
(
TSDB_CODE_TSC_DB_NOT_SELECTED
);
}
tableNameHashFp
fp
=
NULL
;
SVgroupInfo
*
vgInfo
=
NULL
;
CTG_ERR_RET
(
ctgGetHashFunction
(
dbInfo
->
hashMethod
,
&
fp
));
char
tbFullName
[
TSDB_TABLE_FNAME_LEN
];
tNameExtractFullName
(
pTableName
,
tbFullName
);
uint32_t
hashValue
=
(
*
fp
)(
tbFullName
,
(
uint32_t
)
strlen
(
tbFullName
)
);
uint32_t
hashValue
=
taosGetTbHashVal
(
tbFullName
,
(
uint32_t
)
strlen
(
tbFullName
),
dbInfo
->
hashMethod
,
dbInfo
->
hashPrefix
,
dbInfo
->
hashSuffix
);
void
*
pIter
=
taosHashIterate
(
dbInfo
->
vgHash
,
NULL
);
while
(
pIter
)
{
...
...
@@ -919,11 +915,7 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
tableNameHashFp
fp
=
NULL
;
SVgroupInfo
*
vgInfo
=
NULL
;
CTG_ERR_RET
(
ctgGetHashFunction
(
dbInfo
->
hashMethod
,
&
fp
));
int32_t
tbNum
=
taosArrayGetSize
(
pNames
);
if
(
1
==
vgNum
)
{
...
...
@@ -975,7 +967,7 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo
tbNameLen
=
offset
+
strlen
(
pName
->
tname
);
strcpy
(
tbFullName
+
offset
,
pName
->
tname
);
uint32_t
hashValue
=
(
*
fp
)(
tbFullName
,
(
uint32_t
)
tbNameLen
);
uint32_t
hashValue
=
taosGetTbHashVal
(
tbFullName
,
(
uint32_t
)
strlen
(
tbFullName
),
dbInfo
->
hashMethod
,
dbInfo
->
hashPrefix
,
dbInfo
->
hashSuffix
);
SVgroupInfo
**
p
=
taosArraySearch
(
pVgList
,
&
hashValue
,
ctgHashValueComp
,
TD_EQ
);
...
...
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
72615fde
...
...
@@ -218,6 +218,8 @@ void ctgTestBuildDBVgroup(SDBVgInfo **pdbVgroup) {
ctgTestCurrentVgVersion
=
dbVgroup
->
vgVersion
;
dbVgroup
->
hashMethod
=
0
;
dbVgroup
->
hashPrefix
=
0
;
dbVgroup
->
hashSuffix
=
0
;
dbVgroup
->
vgHash
=
taosHashInit
(
ctgTestVgNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
true
,
HASH_ENTRY_LOCK
);
vgNum
=
ctgTestGetVgNumFromVgVersion
(
dbVgroup
->
vgVersion
);
...
...
source/libs/qcom/src/querymsg.c
浏览文件 @
72615fde
...
...
@@ -38,6 +38,8 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
pOut
->
dbVgroup
->
vgVersion
=
usedbRsp
->
vgVersion
;
pOut
->
dbVgroup
->
hashMethod
=
usedbRsp
->
hashMethod
;
pOut
->
dbVgroup
->
hashPrefix
=
usedbRsp
->
hashPrefix
;
pOut
->
dbVgroup
->
hashSuffix
=
usedbRsp
->
hashSuffix
;
qDebug
(
"Got %d vgroup for db %s"
,
usedbRsp
->
vgNum
,
usedbRsp
->
db
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录