Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
34b74ff0
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看板
提交
34b74ff0
编写于
12月 28, 2021
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
catalog code refactor
上级
2a47a257
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
22 deletion
+19
-22
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+1
-1
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+1
-0
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+17
-21
未找到文件。
source/client/src/clientEnv.c
浏览文件 @
34b74ff0
...
...
@@ -227,7 +227,7 @@ void taos_init_imp(void) {
rpcInit
();
SCatalogCfg
cfg
=
{.
enableVgroupCache
=
true
,
.
maxDBCacheNum
=
100
,
.
maxTblCacheNum
=
100
};
SCatalogCfg
cfg
=
{.
maxDBCacheNum
=
100
,
.
maxTblCacheNum
=
100
};
catalogInit
(
&
cfg
);
tscDebug
(
"starting to initialize TAOS driver, local ep: %s"
,
tsLocalEp
);
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
34b74ff0
...
...
@@ -67,6 +67,7 @@ typedef uint32_t (*tableNameHashFp)(const char *, uint32_t);
#define ctgTrace(...) do { if (ctgDebugFlag & DEBUG_TRACE) { taosPrintLog("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define ctgDebugL(...) do { if (ctgDebugFlag & DEBUG_DEBUG) { taosPrintLongString("CTG ", ctgDebugFlag, __VA_ARGS__); }} while(0)
#define CTG_CACHE_ENABLED(cfg) ((cfg)->maxDBCacheNum > 0 || (cfg)->maxTblCacheNum > 0)
#define CTG_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
#define CTG_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
34b74ff0
...
...
@@ -343,7 +343,9 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
ctgError
(
"init hash[%d] for tablemeta cache failed"
,
ctgMgmt
.
cfg
.
maxTblCacheNum
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
}
if
(
NULL
==
pCatalog
->
tableCache
.
stableCache
)
{
pCatalog
->
tableCache
.
stableCache
=
taosHashInit
(
ctgMgmt
.
cfg
.
maxTblCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_UBIGINT
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
pCatalog
->
tableCache
.
stableCache
)
{
ctgError
(
"init hash[%d] for stablemeta cache failed"
,
ctgMgmt
.
cfg
.
maxTblCacheNum
);
...
...
@@ -354,55 +356,51 @@ int32_t ctgUpdateTableMetaCache(struct SCatalog *pCatalog, STableMetaOutput *out
if
(
output
->
metaNum
==
2
)
{
if
(
taosHashPut
(
pCatalog
->
tableCache
.
cache
,
output
->
ctbFname
,
strlen
(
output
->
ctbFname
),
&
output
->
ctbMeta
,
sizeof
(
output
->
ctbMeta
))
!=
0
)
{
ctgError
(
"push ctable[%s] to table cache failed"
,
output
->
ctbFname
);
goto
error_exit
;
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
)
;
}
if
(
TSDB_SUPER_TABLE
!=
output
->
tbMeta
->
tableType
)
{
ctgError
(
"table type[%d] error, expected:%d"
,
output
->
tbMeta
->
tableType
,
TSDB_SUPER_TABLE
);
goto
error_exit
;
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
)
;
}
}
int32_t
tbSize
=
sizeof
(
*
output
->
tbMeta
)
+
sizeof
(
SSchema
)
*
(
output
->
tbMeta
->
tableInfo
.
numOfColumns
+
output
->
tbMeta
->
tableInfo
.
numOfTags
);
if
(
taosHashPut
(
pCatalog
->
tableCache
.
cache
,
output
->
tbFname
,
strlen
(
output
->
tbFname
),
output
->
tbMeta
,
tbSize
)
!=
0
)
{
ctgError
(
"push table[%s] to table cache failed"
,
output
->
tbFname
);
goto
error_exit
;
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
)
;
}
if
(
TSDB_SUPER_TABLE
==
output
->
tbMeta
->
tableType
)
{
if
(
taosHashPut
(
pCatalog
->
tableCache
.
stableCache
,
&
output
->
tbMeta
->
suid
,
sizeof
(
output
->
tbMeta
->
suid
),
&
output
->
tbMeta
,
POINTER_BYTES
)
!=
0
)
{
ctgError
(
"push suid[%"
PRIu64
"] to stable cache failed"
,
output
->
tbMeta
->
suid
);
goto
error_exit
;
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
)
;
}
}
return
TSDB_CODE_SUCCESS
;
error_exit:
if
(
pCatalog
->
vgroupCache
.
cache
)
{
taosHashCleanup
(
pCatalog
->
vgroupCache
.
cache
);
pCatalog
->
vgroupCache
.
cache
=
NULL
;
}
pCatalog
->
vgroupCache
.
vgroupVersion
=
CTG_DEFAULT_INVALID_VERSION
;
CTG_ERR_RET
(
TSDB_CODE_CTG_INTERNAL_ERROR
);
}
int32_t
catalogInit
(
SCatalogCfg
*
cfg
)
{
ctgMgmt
.
pCluster
=
taosHashInit
(
CTG_DEFAULT_CACHE_CLUSTER_NUMBER
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
ctgMgmt
.
pCluster
)
{
CTG_ERR_
LRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
,
"init %d cluster cache failed"
,
CTG_DEFAULT_CACHE_CLUSTER_NUMBER
);
if
(
ctgMgmt
.
pCluster
)
{
ctgError
(
"catalog already init"
);
CTG_ERR_
RET
(
TSDB_CODE_CTG_INVALID_INPUT
);
}
if
(
cfg
)
{
memcpy
(
&
ctgMgmt
.
cfg
,
cfg
,
sizeof
(
*
cfg
));
}
else
{
ctgMgmt
.
cfg
.
enableVgroupCache
=
true
;
ctgMgmt
.
cfg
.
maxDBCacheNum
=
CTG_DEFAULT_CACHE_DB_NUMBER
;
ctgMgmt
.
cfg
.
maxTblCacheNum
=
CTG_DEFAULT_CACHE_TABLEMETA_NUMBER
;
}
if
(
CTG_CACHE_ENABLED
(
&
ctgMgmt
.
cfg
))
{
ctgMgmt
.
pCluster
=
taosHashInit
(
CTG_DEFAULT_CACHE_CLUSTER_NUMBER
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
ctgMgmt
.
pCluster
)
{
CTG_ERR_LRET
(
TSDB_CODE_CTG_INTERNAL_ERROR
,
"init %d cluster cache failed"
,
CTG_DEFAULT_CACHE_CLUSTER_NUMBER
);
}
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -430,8 +428,6 @@ int32_t catalogGetHandle(const char* clusterId , struct SCatalog** catalogHandle
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
}
clusterCtg
->
vgroupCache
.
vgroupVersion
=
CTG_DEFAULT_INVALID_VERSION
;
if
(
taosHashPut
(
ctgMgmt
.
pCluster
,
clusterId
,
clen
,
&
clusterCtg
,
POINTER_BYTES
))
{
ctgError
(
"put cluster %s cache to hash failed"
,
clusterId
);
tfree
(
clusterCtg
);
...
...
@@ -479,7 +475,7 @@ int32_t catalogUpdateDBVgroupCache(struct SCatalog* pCatalog, const char* dbName
}
if
(
NULL
==
pCatalog
->
dbCache
.
cache
)
{
pCatalog
->
dbCache
.
cache
=
taosHashInit
(
CTG_DEFAULT_CACHE_DB_NUMBER
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
pCatalog
->
dbCache
.
cache
=
taosHashInit
(
ctgMgmt
.
cfg
.
maxDBCacheNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
true
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
pCatalog
->
dbCache
.
cache
)
{
ctgError
(
"init hash[%d] for db cache failed"
,
CTG_DEFAULT_CACHE_DB_NUMBER
);
CTG_ERR_RET
(
TSDB_CODE_CTG_MEM_ERROR
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录