Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aa8d25f6
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看板
提交
aa8d25f6
编写于
4月 19, 2023
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: support fetching table tag value
上级
4417c79c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
135 addition
and
1 deletion
+135
-1
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+1
-0
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+8
-0
source/libs/catalog/src/ctgAsync.c
source/libs/catalog/src/ctgAsync.c
+126
-1
未找到文件。
include/libs/catalog/catalog.h
浏览文件 @
aa8d25f6
...
...
@@ -82,6 +82,7 @@ typedef struct SCatalogReq {
SArray
*
pUser
;
// element is SUserAuthInfo
SArray
*
pTableIndex
;
// element is SNAME
SArray
*
pTableCfg
;
// element is SNAME
SArray
*
pTableTag
;
// element is SNAME
bool
qNodeRequired
;
// valid qnode
bool
dNodeRequired
;
// valid dnode
bool
svrVerRequired
;
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
aa8d25f6
...
...
@@ -58,6 +58,7 @@ typedef enum {
CTG_CI_OTHERTABLE_META
,
CTG_CI_TBL_SMA
,
CTG_CI_TBL_CFG
,
CTG_CI_TBL_TAG
,
CTG_CI_INDEX_INFO
,
CTG_CI_USER
,
CTG_CI_UDF
,
...
...
@@ -110,6 +111,7 @@ typedef enum {
CTG_TASK_GET_SVR_VER
,
CTG_TASK_GET_TB_META_BATCH
,
CTG_TASK_GET_TB_HASH_BATCH
,
CTG_TASK_GET_TB_TAG
,
}
CTG_TASK_TYPE
;
typedef
enum
{
...
...
@@ -186,6 +188,11 @@ typedef struct SCtgTbCfgCtx {
SVgroupInfo
*
pVgInfo
;
}
SCtgTbCfgCtx
;
typedef
struct
SCtgTbTagCtx
{
SName
*
pName
;
SVgroupInfo
*
pVgInfo
;
}
SCtgTbTagCtx
;
typedef
struct
SCtgDbVgCtx
{
char
dbFName
[
TSDB_DB_FNAME_LEN
];
}
SCtgDbVgCtx
;
...
...
@@ -304,6 +311,7 @@ typedef struct SCtgJob {
catalogCallback
userFp
;
int32_t
tbMetaNum
;
int32_t
tbHashNum
;
int32_t
tbTagNum
;
int32_t
dbVgNum
;
int32_t
udfNum
;
int32_t
qnodeNum
;
...
...
source/libs/catalog/src/ctgAsync.c
浏览文件 @
aa8d25f6
...
...
@@ -386,6 +386,37 @@ int32_t ctgInitGetTbCfgTask(SCtgJob* pJob, int32_t taskIdx, void* param) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgInitGetTbTagTask
(
SCtgJob
*
pJob
,
int32_t
taskIdx
,
void
*
param
)
{
SName
*
name
=
(
SName
*
)
param
;
SCtgTask
task
=
{
0
};
task
.
type
=
CTG_TASK_GET_TB_TAG
;
task
.
taskId
=
taskIdx
;
task
.
pJob
=
pJob
;
task
.
taskCtx
=
taosMemoryCalloc
(
1
,
sizeof
(
SCtgTbTagCtx
));
if
(
NULL
==
task
.
taskCtx
)
{
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
SCtgTbTagCtx
*
ctx
=
task
.
taskCtx
;
ctx
->
pName
=
taosMemoryMalloc
(
sizeof
(
*
name
));
if
(
NULL
==
ctx
->
pName
)
{
taosMemoryFree
(
task
.
taskCtx
);
CTG_ERR_RET
(
TSDB_CODE_OUT_OF_MEMORY
);
}
memcpy
(
ctx
->
pName
,
name
,
sizeof
(
*
name
));
taosArrayPush
(
pJob
->
pTasks
,
&
task
);
qDebug
(
"QID:0x%"
PRIx64
" the %dth task type %s initialized, tbName:%s"
,
pJob
->
queryId
,
taskIdx
,
ctgTaskTypeStr
(
task
.
type
),
name
->
tname
);
return
TSDB_CODE_SUCCESS
;
}
int32_t
ctgHandleForceUpdate
(
SCatalog
*
pCtg
,
int32_t
taskNum
,
SCtgJob
*
pJob
,
const
SCatalogReq
*
pReq
)
{
SHashObj
*
pDb
=
taosHashInit
(
taskNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
SHashObj
*
pTb
=
taosHashInit
(
taskNum
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
...
...
@@ -437,6 +468,15 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, con
char
dbFName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
name
,
dbFName
);
taosHashPut
(
pDb
,
dbFName
,
strlen
(
dbFName
),
dbFName
,
TSDB_DB_FNAME_LEN
);
taosHashPut
(
pTb
,
name
,
sizeof
(
SName
),
name
,
sizeof
(
SName
));
}
for
(
int32_t
i
=
0
;
i
<
pJob
->
tbTagNum
;
++
i
)
{
SName
*
name
=
taosArrayGet
(
pReq
->
pTableTag
,
i
);
char
dbFName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
name
,
dbFName
);
taosHashPut
(
pDb
,
dbFName
,
strlen
(
dbFName
),
dbFName
,
TSDB_DB_FNAME_LEN
);
taosHashPut
(
pTb
,
name
,
sizeof
(
SName
),
name
,
sizeof
(
SName
));
}
char
*
dbFName
=
taosHashIterate
(
pDb
,
NULL
);
...
...
@@ -505,9 +545,10 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
int32_t
dbInfoNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pDbInfo
);
int32_t
tbIndexNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pTableIndex
);
int32_t
tbCfgNum
=
(
int32_t
)
taosArrayGetSize
(
pReq
->
pTableCfg
);
int32_t
tbTagNum
=
(
int32_t
)
ctgGetTablesReqNum
(
pReq
->
pTableTag
);
int32_t
taskNum
=
tbMetaNum
+
dbVgNum
+
udfNum
+
tbHashNum
+
qnodeNum
+
dnodeNum
+
svrVerNum
+
dbCfgNum
+
indexNum
+
userNum
+
dbInfoNum
+
tbIndexNum
+
tbCfgNum
;
userNum
+
dbInfoNum
+
tbIndexNum
+
tbCfgNum
+
tbTagNum
;
*
job
=
taosMemoryCalloc
(
1
,
sizeof
(
SCtgJob
));
if
(
NULL
==
*
job
)
{
...
...
@@ -537,6 +578,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
pJob
->
tbIndexNum
=
tbIndexNum
;
pJob
->
tbCfgNum
=
tbCfgNum
;
pJob
->
svrVerNum
=
svrVerNum
;
pJob
->
tbTagNum
=
tbTagNum
;
#if CTG_BATCH_FETCH
pJob
->
pBatchs
=
...
...
@@ -604,6 +646,12 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const
CTG_ERR_JRET
(
ctgInitTask
(
pJob
,
CTG_TASK_GET_TB_CFG
,
name
,
NULL
));
}
for
(
int32_t
i
=
0
;
i
<
tbCfgNum
;
++
i
)
{
SName
*
name
=
taosArrayGet
(
pReq
->
pTableTag
,
i
);
CTG_ERR_JRET
(
ctgInitTask
(
pJob
,
CTG_TASK_GET_TB_TAG
,
name
,
NULL
));
}
for
(
int32_t
i
=
0
;
i
<
indexNum
;
++
i
)
{
char
*
indexName
=
taosArrayGet
(
pReq
->
pIndex
,
i
);
CTG_ERR_JRET
(
ctgInitTask
(
pJob
,
CTG_TASK_GET_INDEX_INFO
,
indexName
,
NULL
));
...
...
@@ -1473,6 +1521,24 @@ _return:
CTG_RET
(
code
);
}
int32_t
ctgHandleGetTbTagRsp
(
SCtgTaskReq
*
tReq
,
int32_t
reqType
,
const
SDataBuf
*
pMsg
,
int32_t
rspCode
)
{
int32_t
code
=
0
;
SCtgTask
*
pTask
=
tReq
->
pTask
;
CTG_ERR_JRET
(
ctgProcessRspMsg
(
&
pTask
->
msgCtx
.
out
,
reqType
,
pMsg
->
pData
,
pMsg
->
len
,
rspCode
,
pTask
->
msgCtx
.
target
));
STableCfgRsp
*
pRsp
=
(
STableCfgRsp
*
)
pTask
->
msgCtx
.
out
;
TSWAP
(
pTask
->
res
,
pTask
->
msgCtx
.
out
);
_return:
ctgHandleTaskEnd
(
pTask
,
code
);
CTG_RET
(
code
);
}
int32_t
ctgHandleGetDbCfgRsp
(
SCtgTaskReq
*
tReq
,
int32_t
reqType
,
const
SDataBuf
*
pMsg
,
int32_t
rspCode
)
{
int32_t
code
=
0
;
SCtgTask
*
pTask
=
tReq
->
pTask
;
...
...
@@ -1935,6 +2001,45 @@ _return:
CTG_RET
(
code
);
}
int32_t
ctgLaunchGetTbTagTask
(
SCtgTask
*
pTask
)
{
int32_t
code
=
0
;
SCatalog
*
pCtg
=
pTask
->
pJob
->
pCtg
;
SRequestConnInfo
*
pConn
=
&
pTask
->
pJob
->
conn
;
SCtgTbTagCtx
*
pCtx
=
(
SCtgTbTagCtx
*
)
pTask
->
taskCtx
;
SArray
*
pRes
=
NULL
;
char
dbFName
[
TSDB_DB_FNAME_LEN
];
tNameGetFullDbName
(
pCtx
->
pName
,
dbFName
);
SCtgJob
*
pJob
=
pTask
->
pJob
;
SCtgMsgCtx
*
pMsgCtx
=
CTG_GET_TASK_MSGCTX
(
pTask
,
-
1
);
if
(
NULL
==
pMsgCtx
->
pBatchs
)
{
pMsgCtx
->
pBatchs
=
pJob
->
pBatchs
;
}
if
(
NULL
==
pCtx
->
pVgInfo
)
{
CTG_ERR_JRET
(
ctgGetTbHashVgroupFromCache
(
pCtg
,
pCtx
->
pName
,
&
pCtx
->
pVgInfo
));
if
(
NULL
==
pCtx
->
pVgInfo
)
{
CTG_ERR_JRET
(
ctgLaunchSubTask
(
pTask
,
CTG_TASK_GET_DB_VGROUP
,
ctgGetTbCfgCb
,
dbFName
));
return
TSDB_CODE_SUCCESS
;
}
}
CTG_CACHE_NHIT_INC
(
CTG_CI_TBL_TAG
,
1
);
CTG_ERR_JRET
(
ctgGetTableCfgFromVnode
(
pCtg
,
pConn
,
pCtx
->
pName
,
pCtx
->
pVgInfo
,
NULL
,
pTask
));
return
TSDB_CODE_SUCCESS
;
_return:
if
(
CTG_TASK_LAUNCHED
==
pTask
->
status
)
{
ctgHandleTaskEnd
(
pTask
,
code
);
}
CTG_RET
(
code
);
}
int32_t
ctgLaunchGetQnodeTask
(
SCtgTask
*
pTask
)
{
SCatalog
*
pCtg
=
pTask
->
pJob
->
pCtg
;
SRequestConnInfo
*
pConn
=
&
pTask
->
pJob
->
conn
;
...
...
@@ -2138,6 +2243,25 @@ _return:
CTG_RET
(
ctgHandleTaskEnd
(
pTask
,
pTask
->
subRes
.
code
));
}
int32_t
ctgGetTbTagCb
(
SCtgTask
*
pTask
)
{
int32_t
code
=
0
;
CTG_ERR_JRET
(
pTask
->
subRes
.
code
);
SCtgTbTagCtx
*
pCtx
=
(
SCtgTbTagCtx
*
)
pTask
->
taskCtx
;
SDBVgInfo
*
pDb
=
(
SDBVgInfo
*
)
pTask
->
subRes
.
res
;
pCtx
->
pVgInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SVgroupInfo
));
CTG_ERR_JRET
(
ctgGetVgInfoFromHashValue
(
pTask
->
pJob
->
pCtg
,
pDb
,
pCtx
->
pName
,
pCtx
->
pVgInfo
));
CTG_RET
(
ctgLaunchGetTbTagTask
(
pTask
));
_return:
CTG_RET
(
ctgHandleTaskEnd
(
pTask
,
pTask
->
subRes
.
code
));
}
int32_t
ctgGetUserCb
(
SCtgTask
*
pTask
)
{
int32_t
code
=
0
;
...
...
@@ -2197,6 +2321,7 @@ SCtgAsyncFps gCtgAsyncFps[] = {
{
ctgInitGetSvrVerTask
,
ctgLaunchGetSvrVerTask
,
ctgHandleGetSvrVerRsp
,
ctgDumpSvrVer
,
NULL
,
NULL
},
{
ctgInitGetTbMetasTask
,
ctgLaunchGetTbMetasTask
,
ctgHandleGetTbMetasRsp
,
ctgDumpTbMetasRes
,
NULL
,
NULL
},
{
ctgInitGetTbHashsTask
,
ctgLaunchGetTbHashsTask
,
ctgHandleGetTbHashsRsp
,
ctgDumpTbHashsRes
,
NULL
,
NULL
},
{
ctgInitGetTbTagTask
,
ctgLaunchGetTbTagTask
,
ctgHandleGetTbTagRsp
,
ctgDumpTbTagRes
,
NULL
,
NULL
},
};
int32_t
ctgMakeAsyncRes
(
SCtgJob
*
pJob
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录