Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
eea32f5f
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看板
提交
eea32f5f
编写于
5月 25, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: add tag condition
上级
131e9237
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
75 deletion
+25
-75
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+1
-3
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+11
-59
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+13
-13
未找到文件。
source/dnode/vnode/inc/vnode.h
浏览文件 @
eea32f5f
...
...
@@ -103,9 +103,7 @@ tsdbReaderT tsdbQueryCacheLast(SVnode *pVnode, SQueryTableDataCond *pCond, STab
void
*
pMemRef
);
int32_t
tsdbGetFileBlocksDistInfo
(
tsdbReaderT
*
pReader
,
STableBlockDistInfo
*
pTableBlockInfo
);
bool
isTsdbCacheLastRow
(
tsdbReaderT
*
pReader
);
int32_t
tsdbQuerySTableByTagCond
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
skey
,
const
char
*
pTagCond
,
size_t
len
,
int16_t
tagNameRelType
,
const
char
*
tbnameCond
,
STableGroupInfo
*
pGroupInfo
,
SColIndex
*
pColIndex
,
int32_t
numOfCols
,
uint64_t
reqId
,
uint64_t
taskId
);
int32_t
tsdbQueryAllTable
(
void
*
pMeta
,
uint64_t
uid
,
STableGroupInfo
*
pGroupInfo
,
SNode
*
pTagCond
);
int64_t
tsdbGetNumOfRowsInMemTable
(
tsdbReaderT
*
pHandle
);
bool
tsdbNextDataBlock
(
tsdbReaderT
pTsdbReadHandle
);
void
tsdbRetrieveDataBlockInfo
(
tsdbReaderT
*
pTsdbReadHandle
,
SDataBlockInfo
*
pBlockInfo
);
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
eea32f5f
...
...
@@ -14,6 +14,7 @@
*/
#include "tsdb.h"
#include "index.h"
#define EXTRA_BYTES 2
#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
...
...
@@ -3875,74 +3876,25 @@ SArray* createTableGroup(SArray* pTableList, SSchemaWrapper* pTagSchema, SColInd
// return TSDB_CODE_SUCCESS;
//}
int32_t
tsdbQuerySTableByTagCond
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
skey
,
const
char
*
pTagCond
,
size_t
len
,
int16_t
tagNameRelType
,
const
char
*
tbnameCond
,
STableGroupInfo
*
pGroupInfo
,
SColIndex
*
pColIndex
,
int32_t
numOfCols
,
uint64_t
reqId
,
uint64_t
taskId
)
{
SMetaReader
mr
=
{
0
};
metaReaderInit
(
&
mr
,
(
SMeta
*
)
pMeta
,
0
);
if
(
metaGetTableEntryByUid
(
&
mr
,
uid
)
<
0
)
{
tsdbError
(
"%p failed to get stable, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
metaReaderClear
(
&
mr
);
terrno
=
TSDB_CODE_PAR_TABLE_NOT_EXIST
;
goto
_error
;
}
else
{
tsdbDebug
(
"%p succeed to get stable, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
}
if
(
mr
.
me
.
type
!=
TSDB_SUPER_TABLE
)
{
tsdbError
(
"%p query normal tag not allowed, uid:%"
PRIu64
", TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
uid
,
taskId
,
reqId
);
terrno
=
TSDB_CODE_OPS_NOT_SUPPORT
;
// basically, this error is caused by invalid sql issued by client
metaReaderClear
(
&
mr
);
goto
_error
;
}
metaReaderClear
(
&
mr
);
int32_t
tsdbQueryAllTable
(
void
*
pMeta
,
uint64_t
uid
,
STableGroupInfo
*
pGroupInfo
,
SNode
*
pTagCond
)
{
// NOTE: not add ref count for super table
SArray
*
res
=
taosArrayInit
(
8
,
sizeof
(
STableKeyInfo
));
SSchemaWrapper
*
pTagSchema
=
metaGetTableSchema
(
pMeta
,
uid
,
1
,
true
);
// no tags and tbname condition, all child tables of this stable are involved
if
(
tbnameCond
==
NULL
&&
(
pTagCond
==
NULL
||
len
==
0
))
{
int32_t
ret
=
getAllTableList
(
pMeta
,
uid
,
res
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
pGroupInfo
->
numOfTables
=
(
uint32_t
)
taosArrayGetSize
(
res
);
pGroupInfo
->
pGroupList
=
createTableGroup
(
res
,
pTagSchema
,
pColIndex
,
numOfCols
,
skey
);
tsdbDebug
(
"%p no table name/tag condition, all tables qualified, numOfTables:%u, group:%zu, TID:0x%"
PRIx64
" QID:0x%"
PRIx64
,
pMeta
,
pGroupInfo
->
numOfTables
,
taosArrayGetSize
(
pGroupInfo
->
pGroupList
),
taskId
,
reqId
);
taosArrayDestroy
(
res
);
return
ret
;
}
SArray
*
res
=
taosArrayInit
(
8
,
sizeof
(
STableKeyInfo
));
int32_t
ret
=
TSDB_CODE_SUCCESS
;
SFilterInfo
*
filterInfo
=
NULL
;
ret
=
filterInitFromNode
((
SNode
*
)
pTagCond
,
&
filterInfo
,
0
);
if
(
pTagCond
){
ret
=
doFilterTag
(
pTagCond
,
res
);
}
else
{
ret
=
getAllTableList
(
pMeta
,
uid
,
res
);
}
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
ret
;
return
ret
;
}
ret
=
tsdbQueryTableList
(
pMeta
,
res
,
filterInfo
);
pGroupInfo
->
numOfTables
=
(
uint32_t
)
taosArrayGetSize
(
res
);
pGroupInfo
->
pGroupList
=
createTableGroup
(
res
,
pTagSchema
,
pColIndex
,
numOfCols
,
skey
);
// tsdbDebug("%p stable tid:%d, uid:%" PRIu64 " query, numOfTables:%u, belong to %" PRIzu " groups", tsdb,
// pTable->tableId, pTable->uid, pGroupInfo->numOfTables, taosArrayGetSize(pGroupInfo->pGroupList));
pGroupInfo
->
numOfTables
=
(
uint32_t
)
taosArrayGetSize
(
res
);
pGroupInfo
->
pGroupList
=
taosArrayInit
(
1
,
POINTER_BYTES
);
taosArrayPush
(
pGroupInfo
->
pGroupList
,
&
res
);
taosArrayDestroy
(
res
);
return
ret
;
_error:
return
terrno
;
}
int32_t
tsdbQueryTableList
(
void
*
pMeta
,
SArray
*
pRes
,
void
*
filterInfo
)
{
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
eea32f5f
...
...
@@ -4438,10 +4438,10 @@ static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId, EOPT
}
static
tsdbReaderT
doCreateDataReader
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableGroupInfo
*
pTableGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
);
STableGroupInfo
*
pTableGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
,
SNode
*
pTagNode
);
static
int32_t
doCreateTableGroup
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableGroupInfo
*
pGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
);
uint64_t
queryId
,
uint64_t
taskId
,
SNode
*
pTagCond
);
static
SArray
*
extractTableIdList
(
const
STableGroupInfo
*
pTableGroupInfo
);
static
SArray
*
extractColumnInfo
(
SNodeList
*
pNodeList
);
...
...
@@ -4471,14 +4471,14 @@ void extractTableSchemaVersion(SReadHandle* pHandle, uint64_t uid, SExecTaskInfo
}
SOperatorInfo
*
createOperatorTree
(
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
,
STableGroupInfo
*
pTableGroupInfo
)
{
uint64_t
queryId
,
uint64_t
taskId
,
STableGroupInfo
*
pTableGroupInfo
,
SNode
*
pTagCond
)
{
int32_t
type
=
nodeType
(
pPhyNode
);
if
(
pPhyNode
->
pChildren
==
NULL
||
LIST_LENGTH
(
pPhyNode
->
pChildren
)
==
0
)
{
if
(
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
==
type
)
{
STableScanPhysiNode
*
pTableScanNode
=
(
STableScanPhysiNode
*
)
pPhyNode
;
tsdbReaderT
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableGroupInfo
,
(
uint64_t
)
queryId
,
taskId
);
tsdbReaderT
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableGroupInfo
,
(
uint64_t
)
queryId
,
taskId
,
pTagCond
);
if
(
pDataReader
==
NULL
&&
terrno
!=
0
)
{
return
NULL
;
}
...
...
@@ -4502,9 +4502,9 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
tsdbReaderT
pDataReader
=
NULL
;
if
(
pHandle
->
vnode
)
{
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableGroupInfo
,
(
uint64_t
)
queryId
,
taskId
);
pDataReader
=
doCreateDataReader
(
pTableScanNode
,
pHandle
,
pTableGroupInfo
,
(
uint64_t
)
queryId
,
taskId
,
pTagCond
);
}
else
{
doCreateTableGroup
(
pHandle
->
meta
,
pScanPhyNode
->
tableType
,
pScanPhyNode
->
uid
,
pTableGroupInfo
,
queryId
,
taskId
);
doCreateTableGroup
(
pHandle
->
meta
,
pScanPhyNode
->
tableType
,
pScanPhyNode
->
uid
,
pTableGroupInfo
,
queryId
,
taskId
,
pTagCond
);
}
if
(
pDataReader
==
NULL
&&
terrno
!=
0
)
{
...
...
@@ -4551,7 +4551,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pDescNode
);
int32_t
code
=
doCreateTableGroup
(
pHandle
->
meta
,
pScanPhyNode
->
tableType
,
pScanPhyNode
->
uid
,
pTableGroupInfo
,
queryId
,
taskId
);
queryId
,
taskId
,
pTagCond
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
NULL
;
}
...
...
@@ -4577,7 +4577,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SOperatorInfo
**
ops
=
taosMemoryCalloc
(
size
,
POINTER_BYTES
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
SPhysiNode
*
pChildNode
=
(
SPhysiNode
*
)
nodesListGetNode
(
pPhyNode
->
pChildren
,
i
);
ops
[
i
]
=
createOperatorTree
(
pChildNode
,
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
pTableGroupInfo
);
ops
[
i
]
=
createOperatorTree
(
pChildNode
,
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
pTableGroupInfo
,
pTagCond
);
if
(
ops
[
i
]
==
NULL
)
{
return
NULL
;
}
...
...
@@ -4893,10 +4893,10 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
}
int32_t
doCreateTableGroup
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableGroupInfo
*
pGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
)
{
uint64_t
queryId
,
uint64_t
taskId
,
SNode
*
pTagCond
)
{
int32_t
code
=
0
;
if
(
tableType
==
TSDB_SUPER_TABLE
)
{
code
=
tsdbQuery
STableByTagCond
(
metaHandle
,
tableUid
,
0
,
NULL
,
0
,
0
,
NULL
,
pGroupInfo
,
NULL
,
0
,
queryId
,
taskI
d
);
code
=
tsdbQuery
AllTable
(
metaHandle
,
tableUid
,
pGroupInfo
,
pTagCon
d
);
}
else
{
// Create one table group.
code
=
tsdbGetOneTableGroup
(
metaHandle
,
tableUid
,
0
,
pGroupInfo
);
}
...
...
@@ -4923,10 +4923,10 @@ SArray* extractTableIdList(const STableGroupInfo* pTableGroupInfo) {
}
tsdbReaderT
doCreateDataReader
(
STableScanPhysiNode
*
pTableScanNode
,
SReadHandle
*
pHandle
,
STableGroupInfo
*
pTableGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
)
{
STableGroupInfo
*
pTableGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
,
SNode
*
pTagNode
)
{
uint64_t
uid
=
pTableScanNode
->
scan
.
uid
;
int32_t
code
=
doCreateTableGroup
(
pHandle
->
meta
,
pTableScanNode
->
scan
.
tableType
,
uid
,
pTableGroupInfo
,
queryId
,
taskId
);
doCreateTableGroup
(
pHandle
->
meta
,
pTableScanNode
->
scan
.
tableType
,
uid
,
pTableGroupInfo
,
queryId
,
taskId
,
pTagNode
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -4962,7 +4962,7 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
}
(
*
pTaskInfo
)
->
pRoot
=
createOperatorTree
(
pPlan
->
pNode
,
*
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
&
(
*
pTaskInfo
)
->
tableqinfoGroupInfo
);
createOperatorTree
(
pPlan
->
pNode
,
*
pTaskInfo
,
pHandle
,
queryId
,
taskId
,
&
(
*
pTaskInfo
)
->
tableqinfoGroupInfo
,
pPlan
->
pTagCond
);
if
(
NULL
==
(
*
pTaskInfo
)
->
pRoot
)
{
code
=
terrno
;
goto
_complete
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录