Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1286f747
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
1286f747
编写于
9月 28, 2022
作者:
dengyihao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
QRY: opt tbname in
上级
1b3721b4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
83 addition
and
18 deletion
+83
-18
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+3
-0
source/dnode/vnode/src/meta/metaOpen.c
source/dnode/vnode/src/meta/metaOpen.c
+3
-9
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+15
-0
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+3
-0
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+59
-9
未找到文件。
source/dnode/vnode/inc/vnode.h
浏览文件 @
1286f747
...
...
@@ -62,7 +62,9 @@ void vnodeGetSnapshot(SVnode *pVnode, SSnapshot *pSnapshot);
void
vnodeGetInfo
(
SVnode
*
pVnode
,
const
char
**
dbname
,
int32_t
*
vgId
);
int32_t
vnodeProcessCreateTSma
(
SVnode
*
pVnode
,
void
*
pCont
,
uint32_t
contLen
);
int32_t
vnodeGetAllTableList
(
SVnode
*
pVnode
,
uint64_t
uid
,
SArray
*
list
);
int32_t
vnodeGetCtbIdList
(
SVnode
*
pVnode
,
int64_t
suid
,
SArray
*
list
);
int32_t
vnodeGetCtbIdListByFilter
(
SVnode
*
pVnode
,
int64_t
suid
,
SArray
*
list
,
bool
(
*
filter
)(
void
*
arg
),
void
*
arg
);
int32_t
vnodeGetStbIdList
(
SVnode
*
pVnode
,
int64_t
suid
,
SArray
*
list
);
void
*
vnodeGetIdx
(
SVnode
*
pVnode
);
void
*
vnodeGetIvtIdx
(
SVnode
*
pVnode
);
...
...
@@ -96,6 +98,7 @@ int32_t metaGetTableTags(SMeta *pMeta, uint64_t suid, SArray *uidList, SHash
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
metaGetTableUidByName
(
void
*
meta
,
char
*
tbName
,
uint64_t
*
uid
);
bool
metaIsTableExist
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
typedef
struct
SMetaFltParam
{
...
...
source/dnode/vnode/src/meta/metaOpen.c
浏览文件 @
1286f747
...
...
@@ -200,36 +200,30 @@ int metaClose(SMeta *pMeta) {
int32_t
metaRLock
(
SMeta
*
pMeta
)
{
int32_t
ret
=
0
;
metaTrace
(
"meta rlock %p
B
"
,
&
pMeta
->
lock
);
metaTrace
(
"meta rlock %p"
,
&
pMeta
->
lock
);
ret
=
taosThreadRwlockRdlock
(
&
pMeta
->
lock
);
metaTrace
(
"meta rlock %p E"
,
&
pMeta
->
lock
);
return
ret
;
}
int32_t
metaWLock
(
SMeta
*
pMeta
)
{
int32_t
ret
=
0
;
metaTrace
(
"meta wlock %p
B
"
,
&
pMeta
->
lock
);
metaTrace
(
"meta wlock %p"
,
&
pMeta
->
lock
);
ret
=
taosThreadRwlockWrlock
(
&
pMeta
->
lock
);
metaTrace
(
"meta wlock %p E"
,
&
pMeta
->
lock
);
return
ret
;
}
int32_t
metaULock
(
SMeta
*
pMeta
)
{
int32_t
ret
=
0
;
metaTrace
(
"meta ulock %p
B
"
,
&
pMeta
->
lock
);
metaTrace
(
"meta ulock %p"
,
&
pMeta
->
lock
);
ret
=
taosThreadRwlockUnlock
(
&
pMeta
->
lock
);
metaTrace
(
"meta ulock %p E"
,
&
pMeta
->
lock
);
return
ret
;
}
...
...
source/dnode/vnode/src/meta/metaQuery.c
浏览文件 @
1286f747
...
...
@@ -202,6 +202,21 @@ int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName) {
return
0
;
}
int
metaGetTableUidByName
(
void
*
meta
,
char
*
tbName
,
uint64_t
*
uid
)
{
int
code
=
0
;
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
(
SMeta
*
)
meta
,
0
);
code
=
metaGetTableEntryByName
(
&
mr
,
tbName
);
if
(
code
<
0
)
{
metaReaderClear
(
&
mr
);
return
-
1
;
}
*
uid
=
mr
.
me
.
uid
;
metaReaderClear
(
&
mr
);
return
0
;
}
int
metaReadNext
(
SMetaReader
*
pReader
)
{
SMeta
*
pMeta
=
pReader
->
pMeta
;
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
1286f747
...
...
@@ -409,6 +409,9 @@ int32_t vnodeGetAllTableList(SVnode *pVnode, uint64_t uid, SArray *list) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
vnodeGetCtbIdListByFilter
(
SVnode
*
pVnode
,
int64_t
suid
,
SArray
*
list
,
bool
(
*
filter
)(
void
*
arg
),
void
*
arg
)
{
return
0
;
}
int32_t
vnodeGetCtbIdList
(
SVnode
*
pVnode
,
int64_t
suid
,
SArray
*
list
)
{
SMCtbCursor
*
pCur
=
metaOpenCtbCursor
(
pVnode
->
pMeta
,
suid
);
...
...
source/libs/executor/src/executil.c
浏览文件 @
1286f747
...
...
@@ -26,6 +26,8 @@
#include "executorimpl.h"
#include "tcompression.h"
static
int32_t
optimizeTbnameInCond
(
void
*
metaHandle
,
int64_t
suid
,
SArray
*
list
,
SNode
*
pTagCond
);
void
initResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
)
{
pResultRowInfo
->
size
=
0
;
pResultRowInfo
->
cur
.
pageId
=
-
1
;
...
...
@@ -407,11 +409,15 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
// int64_t stt = taosGetTimestampUs();
tags
=
taosHashInit
(
32
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BIGINT
),
false
,
HASH_NO_LOCK
);
code
=
metaGetTableTags
(
metaHandle
,
suid
,
uidList
,
tags
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"failed to get table tags from meta, reason:%s, suid:%"
PRIu64
,
tstrerror
(
code
),
suid
);
terrno
=
code
;
goto
end
;
int32_t
filter
=
optimizeTbnameInCond
(
metaHandle
,
suid
,
uidList
,
pTagCond
);
if
(
filter
==
-
1
)
{
code
=
metaGetTableTags
(
metaHandle
,
suid
,
uidList
,
tags
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"failed to get table tags from meta, reason:%s, suid:%"
PRIu64
,
tstrerror
(
code
),
suid
);
terrno
=
code
;
goto
end
;
}
}
int32_t
rows
=
taosArrayGetSize
(
uidList
);
...
...
@@ -742,6 +748,53 @@ end:
return
code
;
}
static
int32_t
optimizeTbnameInCond
(
void
*
metaHandle
,
int64_t
suid
,
SArray
*
list
,
SNode
*
pTagCond
)
{
if
(
nodeType
(
pTagCond
)
!=
QUERY_NODE_OPERATOR
)
{
return
-
1
;
}
SOperatorNode
*
pNode
=
(
SOperatorNode
*
)
pTagCond
;
if
(
pNode
->
opType
!=
OP_TYPE_IN
)
{
return
-
1
;
}
if
((
pNode
->
pLeft
!=
NULL
&&
nodeType
(
pNode
->
pLeft
)
==
QUERY_NODE_COLUMN
&&
((
SColumnNode
*
)
pNode
->
pLeft
)
->
colType
==
COLUMN_TYPE_TBNAME
)
&&
(
pNode
->
pRight
!=
NULL
&&
nodeType
(
pNode
->
pRight
)
==
QUERY_NODE_NODE_LIST
))
{
SNodeListNode
*
pList
=
(
SNodeListNode
*
)
pNode
->
pRight
;
int32_t
len
=
LIST_LENGTH
(
pList
->
pNodeList
);
if
(
len
<=
0
)
return
-
1
;
SListCell
*
cell
=
pList
->
pNodeList
->
pHead
;
SArray
*
pTbList
=
taosArrayInit
(
len
,
sizeof
(
void
*
));
for
(
int
i
=
0
;
i
<
pList
->
pNodeList
->
length
;
i
++
)
{
SValueNode
*
valueNode
=
(
SValueNode
*
)
cell
->
pNode
;
if
(
!
IS_VAR_DATA_TYPE
(
valueNode
->
node
.
resType
.
type
))
{
taosArrayDestroy
(
pTbList
);
return
-
1
;
}
char
*
name
=
varDataVal
(
valueNode
->
datum
.
p
);
taosArrayPush
(
pTbList
,
&
name
);
cell
=
cell
->
pNext
;
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pTbList
);
i
++
)
{
char
*
name
=
taosArrayGetP
(
pTbList
,
i
);
uint64_t
uid
=
0
;
if
(
metaGetTableUidByName
(
metaHandle
,
name
,
&
uid
)
==
0
)
{
taosArrayPush
(
list
,
&
uid
);
}
else
{
terrno
=
0
;
qError
(
"failed to get tableIds from by table name: %s"
,
name
);
taosArrayDestroy
(
pTbList
);
return
-
1
;
}
}
taosArrayDestroy
(
pTbList
);
}
return
-
1
;
}
int32_t
getTableList
(
void
*
metaHandle
,
void
*
pVnode
,
SScanPhysiNode
*
pScanNode
,
SNode
*
pTagCond
,
SNode
*
pTagIndexCond
,
STableListInfo
*
pListInfo
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
...
@@ -767,9 +820,6 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
qError
(
"failed to get tableIds from index, reason:%s, suid:%"
PRIu64
,
tstrerror
(
code
),
tableUid
);
code
=
TDB_CODE_SUCCESS
;
}
// int64_t stt1 = taosGetTimestampUs();
// qDebug("generate table list, cost:%ld us", stt1-stt);
}
else
if
(
!
pTagCond
)
{
vnodeGetCtbIdList
(
pVnode
,
pScanNode
->
suid
,
res
);
}
...
...
@@ -813,7 +863,7 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
size_t
numOfTables
=
taosArrayGetSize
(
res
);
for
(
int
i
=
0
;
i
<
numOfTables
;
i
++
)
{
STableKeyInfo
info
=
{.
uid
=
*
(
uint64_t
*
)
taosArrayGet
(
res
,
i
),
.
groupId
=
0
};
void
*
p
=
taosArrayPush
(
pListInfo
->
pTableList
,
&
info
);
void
*
p
=
taosArrayPush
(
pListInfo
->
pTableList
,
&
info
);
if
(
p
==
NULL
)
{
taosArrayDestroy
(
res
);
return
TSDB_CODE_OUT_OF_MEMORY
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录