Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9883d670
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看板
提交
9883d670
编写于
6月 21, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
opti: patition by tag
上级
c79be2da
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
64 addition
and
28 deletion
+64
-28
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+53
-25
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+11
-3
未找到文件。
source/libs/executor/src/executorimpl.c
浏览文件 @
9883d670
...
...
@@ -3916,32 +3916,44 @@ static EDealRes doTranslateGroupExpr(SNode** pNode, void* pContext) {
}
res
->
translate
=
true
;
res
->
node
.
resType
=
pSColumnNode
->
node
.
resType
;
STagVal
tagVal
=
{
0
};
tagVal
.
cid
=
pSColumnNode
->
colId
;
const
char
*
p
=
metaGetTableTagVal
(
&
mr
->
me
,
pSColumnNode
->
node
.
resType
.
type
,
&
tagVal
);
if
(
p
==
NULL
)
{
res
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_NULL
;
}
else
if
(
pSColumnNode
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_JSON
)
{
int32_t
len
=
((
const
STag
*
)
p
)
->
len
;
res
->
datum
.
p
=
taosMemoryCalloc
(
len
+
1
,
1
);
memcpy
(
res
->
datum
.
p
,
p
,
len
);
}
else
if
(
IS_VAR_DATA_TYPE
(
pSColumnNode
->
node
.
resType
.
type
))
{
res
->
datum
.
p
=
taosMemoryCalloc
(
tagVal
.
nData
+
VARSTR_HEADER_SIZE
+
1
,
1
);
memcpy
(
varDataVal
(
res
->
datum
.
p
),
tagVal
.
pData
,
tagVal
.
nData
);
varDataSetLen
(
res
->
datum
.
p
,
tagVal
.
nData
);
}
else
{
nodesSetValueNodeValue
(
res
,
&
(
tagVal
.
i64
));
}
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
res
;
}
else
if
(
nodeType
(
*
pNode
)
==
QUERY_NODE_FUNCTION
){
SFunctionNode
*
pFuncNode
=
*
(
SFunctionNode
**
)
pNode
;
if
(
pFuncNode
->
funcType
==
FUNCTION_TYPE_TBNAME
){
SValueNode
*
res
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
if
(
NULL
==
res
)
{
return
DEAL_RES_ERROR
;
}
res
->
translate
=
true
;
res
->
node
.
resType
=
pFuncNode
->
node
.
resType
;
if
(
strcmp
(
pSColumnNode
->
colName
,
"tbname"
)
==
0
)
{
int32_t
len
=
strlen
(
mr
->
me
.
name
);
res
->
datum
.
p
=
taosMemoryCalloc
(
len
+
VARSTR_HEADER_SIZE
+
1
,
1
);
memcpy
(
varDataVal
(
res
->
datum
.
p
),
mr
->
me
.
name
,
len
);
varDataSetLen
(
res
->
datum
.
p
,
len
);
}
else
{
STagVal
tagVal
=
{
0
};
tagVal
.
cid
=
pSColumnNode
->
colId
;
const
char
*
p
=
metaGetTableTagVal
(
&
mr
->
me
,
pSColumnNode
->
node
.
resType
.
type
,
&
tagVal
);
if
(
p
==
NULL
)
{
res
->
node
.
resType
.
type
=
TSDB_DATA_TYPE_NULL
;
}
else
if
(
pSColumnNode
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_JSON
)
{
int32_t
len
=
((
const
STag
*
)
p
)
->
len
;
res
->
datum
.
p
=
taosMemoryCalloc
(
len
+
1
,
1
);
memcpy
(
res
->
datum
.
p
,
p
,
len
);
}
else
if
(
IS_VAR_DATA_TYPE
(
pSColumnNode
->
node
.
resType
.
type
))
{
res
->
datum
.
p
=
taosMemoryCalloc
(
tagVal
.
nData
+
VARSTR_HEADER_SIZE
+
1
,
1
);
memcpy
(
varDataVal
(
res
->
datum
.
p
),
tagVal
.
pData
,
tagVal
.
nData
);
varDataSetLen
(
res
->
datum
.
p
,
tagVal
.
nData
);
}
else
{
nodesSetValueNodeValue
(
res
,
&
(
tagVal
.
i64
));
}
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
res
;
}
nodesDestroyNode
(
*
pNode
);
*
pNode
=
(
SNode
*
)
res
;
}
return
DEAL_RES_CONTINUE
;
...
...
@@ -4039,7 +4051,11 @@ int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle,
}
else
{
isNull
[
index
++
]
=
0
;
char
*
data
=
nodesGetValueFromNode
(
pValue
);
if
(
IS_VAR_DATA_TYPE
(
pValue
->
node
.
resType
.
type
))
{
if
(
pValue
->
node
.
resType
.
type
==
TSDB_DATA_TYPE_JSON
){
int32_t
len
=
((
const
STag
*
)
data
)
->
len
;
memcpy
(
pStart
,
data
,
len
);
pStart
+=
len
;
}
else
if
(
IS_VAR_DATA_TYPE
(
pValue
->
node
.
resType
.
type
))
{
memcpy
(
pStart
,
data
,
varDataTLen
(
data
));
pStart
+=
varDataTLen
(
data
);
}
else
{
...
...
@@ -4086,7 +4102,12 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
return
NULL
;
}
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
pTableScanNode
->
pPartitionTags
);
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
pTableScanNode
->
pPartitionTags
);
if
(
code
)
{
tsdbCleanupReadHandle
(
pDataReader
);
pTaskInfo
->
code
=
code
;
return
NULL
;
}
SOperatorInfo
*
pOperator
=
createTableScanOperatorInfo
(
pTableScanNode
,
pDataReader
,
pHandle
,
pTaskInfo
);
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
...
...
@@ -4098,7 +4119,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
SArray
*
dataReaders
=
taosArrayInit
(
8
,
POINTER_BYTES
);
createMultipleDataReaders
(
pTableScanNode
,
pHandle
,
pTableListInfo
,
dataReaders
,
queryId
,
taskId
,
pTagCond
);
extractTableSchemaVersion
(
pHandle
,
pTableScanNode
->
scan
.
uid
,
pTaskInfo
);
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
pTableScanNode
->
pPartitionTags
);
int32_t
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
pTableScanNode
->
pPartitionTags
);
if
(
code
){
taosArrayDestroy
(
dataReaders
);
return
NULL
;
}
SOperatorInfo
*
pOperator
=
createTableMergeScanOperatorInfo
(
pTableScanNode
,
dataReaders
,
pHandle
,
pTaskInfo
);
STableScanInfo
*
pScanInfo
=
pOperator
->
info
;
pTaskInfo
->
cost
.
pRecoder
=
&
pScanInfo
->
readRecorder
;
...
...
@@ -4133,8 +4158,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
qDebug
(
"%s pDataReader is not NULL"
,
GET_TASKID
(
pTaskInfo
));
}
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
pTableScanNode
->
pPartitionTags
);
int32_t
code
=
generateGroupIdMap
(
pTableListInfo
,
pHandle
,
pTableScanNode
->
pPartitionTags
);
if
(
code
)
{
tsdbCleanupReadHandle
(
pDataReader
);
return
NULL
;
}
SOperatorInfo
*
pOperator
=
createStreamScanOperatorInfo
(
pDataReader
,
pHandle
,
pTableScanNode
,
pTaskInfo
,
&
twSup
);
return
pOperator
;
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
9883d670
...
...
@@ -1057,9 +1057,9 @@ static bool partTagsOptHasCol(SNodeList* pPartKeys) {
}
static
bool
partTagsIsOptimizableNode
(
SLogicNode
*
pNode
)
{
return
((
QUERY_NODE_LOGIC_PLAN_PARTITION
==
nodeType
(
pNode
)
/*
||
return
((
QUERY_NODE_LOGIC_PLAN_PARTITION
==
nodeType
(
pNode
)
||
(
QUERY_NODE_LOGIC_PLAN_AGG
==
nodeType
(
pNode
)
&&
NULL
!=
((
SAggLogicNode
*
)
pNode
)
->
pGroupKeys
&&
NULL != ((SAggLogicNode*)pNode)->pAggFuncs)
*/
)
&&
NULL
!=
((
SAggLogicNode
*
)
pNode
)
->
pAggFuncs
))
&&
1
==
LIST_LENGTH
(
pNode
->
pChildren
)
&&
QUERY_NODE_LOGIC_PLAN_SCAN
==
nodeType
(
nodesListGetNode
(
pNode
->
pChildren
,
0
)));
}
...
...
@@ -1096,7 +1096,15 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub
nodesDestroyNode
((
SNode
*
)
pNode
);
}
}
else
{
TSWAP
(((
SAggLogicNode
*
)
pNode
)
->
pGroupKeys
,
pScan
->
pPartTags
);
SNode
*
pGroupKey
=
NULL
;
FOREACH
(
pGroupKey
,
((
SAggLogicNode
*
)
pNode
)
->
pGroupKeys
)
{
code
=
nodesListMakeStrictAppend
(
&
pScan
->
pPartTags
,
nodesCloneNode
(
nodesListGetNode
(((
SGroupingSetNode
*
)
pGroupKey
)
->
pParameterList
,
0
)));
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
break
;
}
}
DESTORY_LIST
(((
SAggLogicNode
*
)
pNode
)
->
pGroupKeys
);
}
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录