Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b5b6fff6
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看板
提交
b5b6fff6
编写于
11月 27, 2022
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature: save work
上级
2cccfe2b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
58 addition
and
39 deletion
+58
-39
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+1
-0
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+16
-0
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-0
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+40
-39
未找到文件。
source/dnode/vnode/inc/vnode.h
浏览文件 @
b5b6fff6
...
...
@@ -105,6 +105,7 @@ int32_t metaGetTableTagsByUids(SMeta *pMeta, int64_t suid, SArray *uidList,
int32_t
metaReadNext
(
SMetaReader
*
pReader
);
const
void
*
metaGetTableTagVal
(
void
*
tag
,
int16_t
type
,
STagVal
*
tagVal
);
int
metaGetTableNameByUid
(
void
*
meta
,
uint64_t
uid
,
char
*
tbName
);
int
metaGetTableSzNameByUid
(
void
*
meta
,
uint64_t
uid
,
char
*
tbName
);
int
metaGetTableUidByName
(
void
*
meta
,
char
*
tbName
,
int64_t
*
uid
);
int
metaGetTableTypeByName
(
void
*
meta
,
char
*
tbName
,
ETableType
*
tbType
);
bool
metaIsTableExist
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
b5b6fff6
...
...
@@ -211,6 +211,22 @@ int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName) {
return
0
;
}
int
metaGetTableSzNameByUid
(
void
*
meta
,
uint64_t
uid
,
char
*
tbName
)
{
int
code
=
0
;
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
(
SMeta
*
)
meta
,
0
);
code
=
metaGetTableEntryByUid
(
&
mr
,
uid
);
if
(
code
<
0
)
{
metaReaderClear
(
&
mr
);
return
-
1
;
}
strncpy
(
tbName
,
mr
.
me
.
name
,
TSDB_TABLE_NAME_LEN
);
metaReaderClear
(
&
mr
);
return
0
;
}
int
metaGetTableUidByName
(
void
*
meta
,
char
*
tbName
,
int64_t
*
uid
)
{
int
code
=
0
;
SMetaReader
mr
=
{
0
};
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
b5b6fff6
...
...
@@ -555,6 +555,7 @@ typedef struct STableCountScanOperatorInfo {
STableCountScanSupp
supp
;
int32_t
currGrpIdx
;
SArray
*
stbUidList
;
// when group by db_name and stable_name
}
STableCountScanOperatorInfo
;
typedef
struct
SBlockDistInfo
{
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
b5b6fff6
...
...
@@ -4926,7 +4926,7 @@ void fillTableCountScanDataBlock(STableCountScanSupp* pSupp, char* dbName, char*
if
(
pSupp
->
dbNameSlotId
!=
-
1
)
{
ASSERT
(
strlen
(
dbName
));
SColumnInfoData
*
colInfoData
=
taosArrayGet
(
pRes
->
pDataBlock
,
pSupp
->
dbNameSlotId
);
char
varDbName
[
TSDB_DB_
F
NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
varDbName
[
TSDB_DB_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
strncpy
(
varDataVal
(
varDbName
),
dbName
,
strlen
(
dbName
));
varDataSetLen
(
varDbName
,
strlen
(
dbName
));
colDataAppend
(
colInfoData
,
0
,
varDbName
,
false
);
...
...
@@ -4935,7 +4935,7 @@ void fillTableCountScanDataBlock(STableCountScanSupp* pSupp, char* dbName, char*
if
(
pSupp
->
stbNameSlotId
!=
-
1
)
{
ASSERT
(
strlen
(
stbName
));
SColumnInfoData
*
colInfoData
=
taosArrayGet
(
pRes
->
pDataBlock
,
pSupp
->
stbNameSlotId
);
char
varStbName
[
TSDB_TABLE_
F
NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
varStbName
[
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
strncpy
(
varDataVal
(
varStbName
),
stbName
,
strlen
(
stbName
));
varDataSetLen
(
varStbName
,
strlen
(
stbName
));
colDataAppend
(
colInfoData
,
0
,
varStbName
,
false
);
...
...
@@ -4997,7 +4997,7 @@ static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator) {
const
char
*
db
=
NULL
;
int32_t
vgId
=
0
;
char
dbName
[
TSDB_DB_F
NAME_LEN
]
=
{
0
};
char
dbName
[
TSDB_DB_
NAME_LEN
]
=
{
0
};
{
// get dbname
...
...
@@ -5005,13 +5005,40 @@ static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator) {
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pInfo
->
pRes
->
pDataBlock
,
0
);
SName
sn
=
{
0
};
tNameFromString
(
&
sn
,
db
,
T_NAME_ACCT
|
T_NAME_DB
);
tNameGetDbName
(
&
sn
,
dbName
);
}
if
(
pSupp
->
groupByDbName
)
{
if
(
pSupp
->
groupByStbName
)
{
// group by db_name and stable_name
if
(
pInfo
->
stbUidList
==
NULL
)
{
pInfo
->
stbUidList
=
taosArrayInit
(
16
,
sizeof
(
tb_uid_t
));
if
(
vnodeGetStbIdList
(
pInfo
->
readHandle
.
vnode
,
0
,
pInfo
->
stbUidList
)
<
0
)
{
qError
(
"vgId:%d, failed to get stb id list error: %s"
,
vgId
,
terrstr
());
}
}
if
(
pInfo
->
currGrpIdx
<
taosArrayGetSize
(
pInfo
->
stbUidList
))
{
tb_uid_t
stbUid
=
*
(
tb_uid_t
*
)
taosArrayGet
(
pInfo
->
stbUidList
,
pInfo
->
currGrpIdx
);
SMetaStbStats
stats
=
{
0
};
metaGetStbStats
(
pInfo
->
readHandle
.
meta
,
stbUid
,
&
stats
);
int64_t
ctbNum
=
stats
.
ctbNum
;
char
stbName
[
TSDB_TABLE_NAME_LEN
]
=
{
0
};
metaGetTableSzNameByUid
(
pInfo
->
readHandle
.
meta
,
stbUid
,
stbName
);
char
fullStbName
[
TSDB_TABLE_FNAME_LEN
]
=
{
0
};
strcpy
(
fullStbName
,
dbName
);
strcat
(
fullStbName
,
"."
);
strcat
(
fullStbName
,
stbName
);
uint64_t
groupId
=
calcGroupId
(
fullStbName
,
strlen
(
fullStbName
));
pRes
->
info
.
groupId
=
groupId
;
pInfo
->
currGrpIdx
++
;
fillTableCountScanDataBlock
(
pSupp
,
dbName
,
stbName
,
ctbNum
,
pRes
);
}
}
else
{
// group by only db_name
uint64_t
groupId
=
calcGroupId
(
dbName
,
strlen
(
dbName
));
pRes
->
info
.
groupId
=
groupId
;
int64_t
dbTableCount
=
metaGetTbNum
(
pInfo
->
readHandle
.
meta
);
...
...
@@ -5020,45 +5047,18 @@ static SSDataBlock* doTableCountScan(SOperatorInfo* pOperator) {
}
else
{
if
(
strlen
(
pSupp
->
dbName
)
!=
0
)
{
if
(
strlen
(
pSupp
->
stbName
)
!=
0
)
{
tb_uid_t
uid
=
metaGetTableEntryUidByName
(
pInfo
->
readHandle
.
meta
,
pSupp
->
stbName
);
SMetaStbStats
stats
=
{
0
};
metaGetStbStats
(
pInfo
->
readHandle
.
meta
,
uid
,
&
stats
);
int64_t
ctbNum
=
stats
.
ctbNum
;
fillTableCountScanDataBlock
(
pSupp
,
dbName
,
pSupp
->
stbName
,
ctbNum
,
pRes
);
}
else
{
int64_t
tbNumVnode
=
metaGetTbNum
(
pInfo
->
readHandle
.
meta
);
fillTableCountScanDataBlock
(
pSupp
,
pSupp
->
dbName
,
""
,
tbNumVnode
,
pRes
);
}
}
}
{
// grouptags only have column db_name or (no grouptags and tablename is null)
// if (tableName == NULL | strlen(tableName) == 0)
metaGetTbNum
(
pInfo
->
readHandle
.
meta
);
}
{
// no grouptags and TableName is not null, return child table count
{
tb_uid_t
uid
=
metaGetTableEntryUidByName
(
pInfo
->
readHandle
.
meta
,
pSupp
->
stbName
);
SMetaStbStats
stats
=
{
0
};
metaGetStbStats
(
pInfo
->
readHandle
.
meta
,
uid
,
&
stats
);
int64_t
ctbNum
=
stats
.
ctbNum
;
}
}
{
// grouptags have column stable_name. return (stable name, child table count)
SArray
*
stbUidList
=
taosArrayInit
(
16
,
sizeof
(
tb_uid_t
));
vnodeGetStbIdList
(
pInfo
->
readHandle
.
vnode
,
0
,
stbUidList
);
if
(
vnodeGetStbIdList
(
pInfo
->
readHandle
.
vnode
,
0
,
stbUidList
)
<
0
)
{
qError
(
"vgId:%d, failed to get stb id list error: %s"
,
vgId
,
terrstr
());
taosArrayDestroy
(
stbUidList
);
// return failure
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
stbUidList
);
++
i
)
{
tb_uid_t
stbUid
=
*
(
tb_uid_t
*
)
taosArrayGet
(
stbUidList
,
i
);
SMetaStbStats
stats
=
{
0
};
metaGetStbStats
(
pInfo
->
readHandle
.
meta
,
stbUid
,
&
stats
);
int64_t
ctbNum
=
stats
.
ctbNum
;
char
varStbName
[
TSDB_TABLE_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
metaGetTableNameByUid
(
pInfo
->
readHandle
.
meta
,
stbUid
,
varStbName
);
}
taosArrayDestroy
(
stbUidList
);
}
return
NULL
;
return
pRes
->
info
.
rows
>
0
?
pRes
:
pRes
;
}
static
void
destoryTableCountScanOperator
(
void
*
param
)
{
...
...
@@ -5066,5 +5066,6 @@ static void destoryTableCountScanOperator(void* param) {
blockDataDestroy
(
pTableCountScanInfo
->
pRes
);
nodesDestroyList
(
pTableCountScanInfo
->
groupTags
);
taosArrayDestroy
(
pTableCountScanInfo
->
stbUidList
);
taosMemoryFreeClear
(
param
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录