Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8988de19
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8988de19
编写于
10月 19, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add retrieve table meta and vgroup info from cache
上级
510a7458
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
55 addition
and
10 deletion
+55
-10
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+2
-1
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+53
-9
未找到文件。
source/libs/catalog/inc/catalogInt.h
浏览文件 @
8988de19
...
@@ -505,6 +505,7 @@ typedef struct SCtgOperation {
...
@@ -505,6 +505,7 @@ typedef struct SCtgOperation {
#define CTG_FLAG_UNKNOWN_STB 0x4
#define CTG_FLAG_UNKNOWN_STB 0x4
#define CTG_FLAG_SYS_DB 0x8
#define CTG_FLAG_SYS_DB 0x8
#define CTG_FLAG_FORCE_UPDATE 0x10
#define CTG_FLAG_FORCE_UPDATE 0x10
#define CTG_FLAG_ONLY_CACHE 0x20
#define CTG_FLAG_SET(_flag, _v) ((_flag) |= (_v))
#define CTG_FLAG_SET(_flag, _v) ((_flag) |= (_v))
...
@@ -783,7 +784,7 @@ void ctgFreeQNode(SCtgQNode* node);
...
@@ -783,7 +784,7 @@ void ctgFreeQNode(SCtgQNode* node);
void
ctgClearHandle
(
SCatalog
*
pCtg
);
void
ctgClearHandle
(
SCatalog
*
pCtg
);
void
ctgFreeTbCacheImpl
(
SCtgTbCache
*
pCache
);
void
ctgFreeTbCacheImpl
(
SCtgTbCache
*
pCache
);
int32_t
ctgRemoveTbMeta
(
SCatalog
*
pCtg
,
SName
*
pTableName
);
int32_t
ctgRemoveTbMeta
(
SCatalog
*
pCtg
,
SName
*
pTableName
);
int32_t
ctgGetTbHashVgroup
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
);
int32_t
ctgGetTbHashVgroup
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
,
bool
*
exists
);
SName
*
ctgGetFetchName
(
SArray
*
pNames
,
SCtgFetch
*
pFetch
);
SName
*
ctgGetFetchName
(
SArray
*
pNames
,
SCtgFetch
*
pFetch
);
extern
SCatalogMgmt
gCtgMgmt
;
extern
SCatalogMgmt
gCtgMgmt
;
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
8988de19
...
@@ -23,12 +23,21 @@
...
@@ -23,12 +23,21 @@
SCatalogMgmt
gCtgMgmt
=
{
0
};
SCatalogMgmt
gCtgMgmt
=
{
0
};
int32_t
ctgGetDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SCtgDBCache
**
dbCache
,
int32_t
ctgGetDBVgInfo
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
char
*
dbFName
,
SCtgDBCache
**
dbCache
,
SDBVgInfo
**
pInfo
)
{
SDBVgInfo
**
pInfo
,
bool
*
exists
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
dbFName
,
dbCache
));
CTG_ERR_RET
(
ctgAcquireVgInfoFromCache
(
pCtg
,
dbFName
,
dbCache
));
if
(
*
dbCache
)
{
if
(
*
dbCache
)
{
if
(
exists
)
{
*
exists
=
true
;
}
return
TSDB_CODE_SUCCESS
;
}
if
(
exists
)
{
*
exists
=
false
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -94,7 +103,7 @@ int32_t ctgRefreshTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx*
...
@@ -94,7 +103,7 @@ int32_t ctgRefreshTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx*
int32_t
code
=
0
;
int32_t
code
=
0
;
if
(
!
CTG_FLAG_IS_SYS_DB
(
ctx
->
flag
))
{
if
(
!
CTG_FLAG_IS_SYS_DB
(
ctx
->
flag
))
{
CTG_ERR_RET
(
ctgGetTbHashVgroup
(
pCtg
,
pConn
,
ctx
->
pName
,
&
vgroupInfo
));
CTG_ERR_RET
(
ctgGetTbHashVgroup
(
pCtg
,
pConn
,
ctx
->
pName
,
&
vgroupInfo
,
NULL
));
}
}
STableMetaOutput
moutput
=
{
0
};
STableMetaOutput
moutput
=
{
0
};
...
@@ -194,7 +203,7 @@ int32_t ctgGetTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx
...
@@ -194,7 +203,7 @@ int32_t ctgGetTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx
STableMetaOutput
*
output
=
NULL
;
STableMetaOutput
*
output
=
NULL
;
CTG_ERR_RET
(
ctgGetTbMetaFromCache
(
pCtg
,
pConn
,
ctx
,
pTableMeta
));
CTG_ERR_RET
(
ctgGetTbMetaFromCache
(
pCtg
,
pConn
,
ctx
,
pTableMeta
));
if
(
*
pTableMeta
)
{
if
(
*
pTableMeta
||
(
ctx
->
flag
&
CTG_FLAG_ONLY_CACHE
)
)
{
goto
_return
;
goto
_return
;
}
}
...
@@ -415,7 +424,7 @@ int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName,
...
@@ -415,7 +424,7 @@ int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName,
CTG_ERR_RET
(
ctgGetTableCfgFromMnode
(
pCtg
,
pConn
,
pTableName
,
pCfg
,
NULL
));
CTG_ERR_RET
(
ctgGetTableCfgFromMnode
(
pCtg
,
pConn
,
pTableName
,
pCfg
,
NULL
));
}
else
{
}
else
{
SVgroupInfo
vgroupInfo
=
{
0
};
SVgroupInfo
vgroupInfo
=
{
0
};
CTG_ERR_RET
(
ctgGetTbHashVgroup
(
pCtg
,
pConn
,
pTableName
,
&
vgroupInfo
));
CTG_ERR_RET
(
ctgGetTbHashVgroup
(
pCtg
,
pConn
,
pTableName
,
&
vgroupInfo
,
NULL
));
CTG_ERR_RET
(
ctgGetTableCfgFromVnode
(
pCtg
,
pConn
,
pTableName
,
&
vgroupInfo
,
pCfg
,
NULL
));
CTG_ERR_RET
(
ctgGetTableCfgFromVnode
(
pCtg
,
pConn
,
pTableName
,
&
vgroupInfo
,
pCfg
,
NULL
));
}
}
...
@@ -441,7 +450,7 @@ int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTabl
...
@@ -441,7 +450,7 @@ int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTabl
tNameGetFullDbName
(
pTableName
,
db
);
tNameGetFullDbName
(
pTableName
,
db
);
SHashObj
*
vgHash
=
NULL
;
SHashObj
*
vgHash
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
db
,
&
dbCache
,
&
vgInfo
));
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
db
,
&
dbCache
,
&
vgInfo
,
NULL
));
if
(
dbCache
)
{
if
(
dbCache
)
{
vgHash
=
dbCache
->
vgCache
.
vgInfo
->
vgHash
;
vgHash
=
dbCache
->
vgCache
.
vgInfo
->
vgHash
;
...
@@ -501,7 +510,7 @@ _return:
...
@@ -501,7 +510,7 @@ _return:
CTG_RET
(
code
);
CTG_RET
(
code
);
}
}
int32_t
ctgGetTbHashVgroup
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
)
{
int32_t
ctgGetTbHashVgroup
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
,
bool
*
exists
)
{
if
(
IS_SYS_DBNAME
(
pTableName
->
dbname
))
{
if
(
IS_SYS_DBNAME
(
pTableName
->
dbname
))
{
ctgError
(
"no valid vgInfo for db, dbname:%s"
,
pTableName
->
dbname
);
ctgError
(
"no valid vgInfo for db, dbname:%s"
,
pTableName
->
dbname
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
CTG_ERR_RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
...
@@ -513,8 +522,13 @@ int32_t ctgGetTbHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName*
...
@@ -513,8 +522,13 @@ int32_t ctgGetTbHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName*
tNameGetFullDbName
(
pTableName
,
db
);
tNameGetFullDbName
(
pTableName
,
db
);
SDBVgInfo
*
vgInfo
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
db
,
&
dbCache
,
&
vgInfo
));
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
db
,
&
dbCache
,
&
vgInfo
,
exists
));
if
(
exists
&&
false
==
*
exists
)
{
ctgDebug
(
"db %s vgInfo not in cache"
,
pTableName
->
dbname
);
return
TSDB_CODE_SUCCESS
;
}
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
vgInfo
?
vgInfo
:
dbCache
->
vgCache
.
vgInfo
,
pTableName
,
pVgroup
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pCtg
,
vgInfo
?
vgInfo
:
dbCache
->
vgCache
.
vgInfo
,
pTableName
,
pVgroup
));
_return:
_return:
...
@@ -737,7 +751,7 @@ int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char*
...
@@ -737,7 +751,7 @@ int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char*
SArray
*
vgList
=
NULL
;
SArray
*
vgList
=
NULL
;
SHashObj
*
vgHash
=
NULL
;
SHashObj
*
vgHash
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
SDBVgInfo
*
vgInfo
=
NULL
;
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
dbFName
,
&
dbCache
,
&
vgInfo
));
CTG_ERR_JRET
(
ctgGetDBVgInfo
(
pCtg
,
pConn
,
dbFName
,
&
dbCache
,
&
vgInfo
,
NULL
));
if
(
dbCache
)
{
if
(
dbCache
)
{
vgHash
=
dbCache
->
vgCache
.
vgInfo
->
vgHash
;
vgHash
=
dbCache
->
vgCache
.
vgInfo
->
vgHash
;
}
else
{
}
else
{
...
@@ -880,6 +894,17 @@ int32_t catalogGetTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName
...
@@ -880,6 +894,17 @@ int32_t catalogGetTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName
CTG_API_LEAVE
(
ctgGetTbMeta
(
pCtg
,
pConn
,
&
ctx
,
pTableMeta
));
CTG_API_LEAVE
(
ctgGetTbMeta
(
pCtg
,
pConn
,
&
ctx
,
pTableMeta
));
}
}
int32_t
catalogGetCachedTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
CTG_API_ENTER
();
SCtgTbMetaCtx
ctx
=
{
0
};
ctx
.
pName
=
(
SName
*
)
pTableName
;
ctx
.
flag
=
CTG_FLAG_UNKNOWN_STB
|
CTG_FLAG_ONLY_CACHE
;
CTG_API_LEAVE
(
ctgGetTbMeta
(
pCtg
,
pConn
,
&
ctx
,
pTableMeta
));
}
int32_t
catalogGetSTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
int32_t
catalogGetSTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
STableMeta
**
pTableMeta
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
...
@@ -891,6 +916,18 @@ int32_t catalogGetSTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SNam
...
@@ -891,6 +916,18 @@ int32_t catalogGetSTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SNam
CTG_API_LEAVE
(
ctgGetTbMeta
(
pCtg
,
pConn
,
&
ctx
,
pTableMeta
));
CTG_API_LEAVE
(
ctgGetTbMeta
(
pCtg
,
pConn
,
&
ctx
,
pTableMeta
));
}
}
int32_t
catalogGetCachedSTableMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
)
{
CTG_API_ENTER
();
SCtgTbMetaCtx
ctx
=
{
0
};
ctx
.
pName
=
(
SName
*
)
pTableName
;
ctx
.
flag
=
CTG_FLAG_STB
|
CTG_FLAG_ONLY_CACHE
;
CTG_API_LEAVE
(
ctgGetTbMeta
(
pCtg
,
pConn
,
&
ctx
,
pTableMeta
));
}
int32_t
catalogUpdateTableMeta
(
SCatalog
*
pCtg
,
STableMetaRsp
*
pMsg
)
{
int32_t
catalogUpdateTableMeta
(
SCatalog
*
pCtg
,
STableMetaRsp
*
pMsg
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
...
@@ -1009,7 +1046,14 @@ int32_t catalogGetTableHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const
...
@@ -1009,7 +1046,14 @@ int32_t catalogGetTableHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const
SVgroupInfo
*
pVgroup
)
{
SVgroupInfo
*
pVgroup
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
CTG_API_LEAVE
(
ctgGetTbHashVgroup
(
pCtg
,
pConn
,
pTableName
,
pVgroup
));
CTG_API_LEAVE
(
ctgGetTbHashVgroup
(
pCtg
,
pConn
,
pTableName
,
pVgroup
,
NULL
));
}
int32_t
catalogGetCachedTableHashVgroup
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SName
*
pTableName
,
SVgroupInfo
*
pVgroup
,
bool
*
exists
)
{
CTG_API_ENTER
();
CTG_API_LEAVE
(
ctgGetTbHashVgroup
(
pCtg
,
pConn
,
pTableName
,
pVgroup
,
exists
));
}
}
int32_t
catalogGetAllMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SCatalogReq
*
pReq
,
SMetaData
*
pRsp
)
{
int32_t
catalogGetAllMeta
(
SCatalog
*
pCtg
,
SRequestConnInfo
*
pConn
,
const
SCatalogReq
*
pReq
,
SMetaData
*
pRsp
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录