Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2cccfe2b
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看板
提交
2cccfe2b
编写于
11月 26, 2022
作者:
S
slzhou
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature: save work
上级
c2a7404b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
86 addition
and
36 deletion
+86
-36
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+86
-36
未找到文件。
source/libs/executor/src/scanoperator.c
浏览文件 @
2cccfe2b
...
...
@@ -4921,68 +4921,118 @@ _error:
return
NULL
;
}
void
fillTableCountScanDataBlock
(
STableCountScanSupp
*
pSupp
,
char
*
dbName
,
char
*
stbName
,
int64_t
count
,
SSDataBlock
*
pRes
)
{
if
(
pSupp
->
dbNameSlotId
!=
-
1
)
{
ASSERT
(
strlen
(
dbName
));
SColumnInfoData
*
colInfoData
=
taosArrayGet
(
pRes
->
pDataBlock
,
pSupp
->
dbNameSlotId
);
char
varDbName
[
TSDB_DB_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
strncpy
(
varDataVal
(
varDbName
),
dbName
,
strlen
(
dbName
));
varDataSetLen
(
varDbName
,
strlen
(
dbName
));
colDataAppend
(
colInfoData
,
0
,
varDbName
,
false
);
}
if
(
pSupp
->
stbNameSlotId
!=
-
1
)
{
ASSERT
(
strlen
(
stbName
));
SColumnInfoData
*
colInfoData
=
taosArrayGet
(
pRes
->
pDataBlock
,
pSupp
->
stbNameSlotId
);
char
varStbName
[
TSDB_TABLE_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
strncpy
(
varDataVal
(
varStbName
),
stbName
,
strlen
(
stbName
));
varDataSetLen
(
varStbName
,
strlen
(
stbName
));
colDataAppend
(
colInfoData
,
0
,
varStbName
,
false
);
}
if
(
pSupp
->
tbCountSlotId
!=
-
1
)
{
SColumnInfoData
*
colInfoData
=
taosArrayGet
(
pRes
->
pDataBlock
,
pSupp
->
stbNameSlotId
);
colDataAppend
(
colInfoData
,
0
,
(
char
*
)
&
count
,
false
);
}
pRes
->
info
.
rows
=
1
;
}
static
SSDataBlock
*
buildSysDbTableCount
(
STableCountScanOperatorInfo
*
pInfo
)
{
STableCountScanSupp
*
pSupp
=
&
pInfo
->
supp
;
SSDataBlock
*
pRes
=
pInfo
->
pRes
;
int64_t
infodbTableNum
;
getInfosDbMeta
(
NULL
,
&
infodbTableNum
);
int64_t
perfdbTableNum
;
getPerfDbMeta
(
NULL
,
&
perfdbTableNum
);
if
(
pSupp
->
groupByDbName
)
{
if
(
pInfo
->
currGrpIdx
==
0
)
{
uint64_t
groupId
=
calcGroupId
(
TSDB_INFORMATION_SCHEMA_DB
,
strlen
(
TSDB_INFORMATION_SCHEMA_DB
));
pRes
->
info
.
groupId
=
groupId
;
fillTableCountScanDataBlock
(
pSupp
,
TSDB_INFORMATION_SCHEMA_DB
,
""
,
infodbTableNum
,
pRes
);
}
else
if
(
pInfo
->
currGrpIdx
==
1
)
{
uint64_t
groupId
=
calcGroupId
(
TSDB_PERFORMANCE_SCHEMA_DB
,
strlen
(
TSDB_PERFORMANCE_SCHEMA_DB
));
pRes
->
info
.
groupId
=
groupId
;
fillTableCountScanDataBlock
(
pSupp
,
TSDB_PERFORMANCE_SCHEMA_DB
,
""
,
perfdbTableNum
,
pRes
);
}
pInfo
->
currGrpIdx
++
;
return
(
pRes
->
info
.
rows
>
0
)
?
pRes
:
NULL
;
}
else
{
if
(
strcmp
(
pSupp
->
dbName
,
TSDB_INFORMATION_SCHEMA_DB
)
==
0
)
{
fillTableCountScanDataBlock
(
pSupp
,
TSDB_INFORMATION_SCHEMA_DB
,
""
,
infodbTableNum
,
pRes
);
}
else
if
(
strcmp
(
pSupp
->
dbName
,
TSDB_PERFORMANCE_SCHEMA_DB
)
==
0
)
{
fillTableCountScanDataBlock
(
pSupp
,
TSDB_PERFORMANCE_SCHEMA_DB
,
""
,
perfdbTableNum
,
pRes
);
}
else
if
(
strlen
(
pSupp
->
dbName
)
==
0
)
{
fillTableCountScanDataBlock
(
pSupp
,
""
,
""
,
infodbTableNum
+
perfdbTableNum
,
pRes
);
}
return
(
pRes
->
info
.
rows
>
0
)
?
pRes
:
NULL
;
}
}
static
SSDataBlock
*
doTableCountScan
(
SOperatorInfo
*
pOperator
)
{
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
STableCountScanOperatorInfo
*
pInfo
=
pOperator
->
info
;
STableCountScanSupp
*
pSupp
=
&
pInfo
->
supp
;
SSDataBlock
*
pRes
=
pInfo
->
pRes
;
blockDataCleanup
(
pRes
);
// compute group id must, but output is according to scancols. output group by group
// grouptags high priority(groupid<=>grouptag), then tablename(dbname,tableName).
// scanCols, (grouptags cols)
{
// mnode, query table count of information_schema and performance_schema
if
(
pInfo
->
readHandle
.
mnd
!=
NULL
)
{
if
(
pSupp
->
groupByDbName
)
{
if
(
pInfo
->
currGrpIdx
==
0
)
{
uint64_t
groupId
=
calcGroupId
(
TSDB_INFORMATION_SCHEMA_DB
,
strlen
(
TSDB_INFORMATION_SCHEMA_DB
));
size_t
infodbTableNum
;
getInfosDbMeta
(
NULL
,
&
infodbTableNum
);
pRes
->
info
.
groupId
=
groupId
;
if
(
pSupp
->
dbNameSlotId
!=
-
1
)
{
SColumnInfoData
*
colInfoData
=
taosArrayGet
(
pRes
->
pDataBlock
,
pSupp
->
dbNameSlotId
);
//colDataAppend(colInfoData, 0, )
}
return
NULL
;
}
else
if
(
pInfo
->
currGrpIdx
==
1
)
{
uint64_t
groupId
=
calcGroupId
(
TSDB_PERFORMANCE_SCHEMA_DB
,
strlen
(
TSDB_PERFORMANCE_SCHEMA_DB
));
size_t
perfdbTableNum
;
getPerfDbMeta
(
NULL
,
&
perfdbTableNum
);
}
else
if
(
pInfo
->
currGrpIdx
>=
2
)
{
return
NULL
;
}
uint64_t
groupId
=
calcGroupId
(
TSDB_INFORMATION_SCHEMA_DB
,
strlen
(
TSDB_INFORMATION_SCHEMA_DB
));
size_t
infodbTableNum
;
getInfosDbMeta
(
NULL
,
&
infodbTableNum
);
size_t
perfdbTableNum
;
getPerfDbMeta
(
NULL
,
&
perfdbTableNum
);
// grouptags, db name
}
else
{
}
}
return
NULL
;
// mnode, query table count of information_schema and performance_schema
if
(
pInfo
->
readHandle
.
mnd
!=
NULL
)
{
return
buildSysDbTableCount
(
pInfo
);
}
const
char
*
db
=
NULL
;
int32_t
vgId
=
0
;
char
dbName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
{
// get dbname
vnodeGetInfo
(
pInfo
->
readHandle
.
vnode
,
&
db
,
&
vgId
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pInfo
->
pRes
->
pDataBlock
,
0
);
SName
sn
=
{
0
};
char
varDbName
[
TSDB_DB_FNAME_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
tNameFromString
(
&
sn
,
db
,
T_NAME_ACCT
|
T_NAME_DB
);
tNameGetDbName
(
&
sn
,
varDataVal
(
varDbName
));
varDataSetLen
(
varDbName
,
strlen
(
varDataVal
(
varDbName
)));
tNameGetDbName
(
&
sn
,
dbName
);
}
const
char
*
tableName
=
tNameGetTableName
(
&
pInfo
->
tableName
);
if
(
pSupp
->
groupByDbName
)
{
if
(
pSupp
->
groupByStbName
)
{
}
else
{
uint64_t
groupId
=
calcGroupId
(
dbName
,
strlen
(
dbName
));
pRes
->
info
.
groupId
=
groupId
;
int64_t
dbTableCount
=
metaGetTbNum
(
pInfo
->
readHandle
.
meta
);
fillTableCountScanDataBlock
(
pSupp
,
dbName
,
""
,
dbTableCount
,
pRes
);
}
}
else
{
if
(
strlen
(
pSupp
->
dbName
)
!=
0
)
{
if
(
strlen
(
pSupp
->
stbName
)
!=
0
)
{
}
else
{
}
}
}
{
// 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
,
table
Name
);
{
tb_uid_t
uid
=
metaGetTableEntryUidByName
(
pInfo
->
readHandle
.
meta
,
pSupp
->
stb
Name
);
SMetaStbStats
stats
=
{
0
};
metaGetStbStats
(
pInfo
->
readHandle
.
meta
,
uid
,
&
stats
);
int64_t
ctbNum
=
stats
.
ctbNum
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录