Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8154200a
T
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1185
Star
22015
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8154200a
编写于
10月 24, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/feature/3_liaohj' into feature/3_liaohj
上级
4fe6da69
3213a8de
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
21 addition
and
13 deletion
+21
-13
source/dnode/vnode/src/tsdb/tsdbCache.c
source/dnode/vnode/src/tsdb/tsdbCache.c
+5
-5
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+16
-8
未找到文件。
source/dnode/vnode/src/tsdb/tsdbCache.c
浏览文件 @
8154200a
...
@@ -61,7 +61,7 @@ static void deleteTableCacheLast(const void *key, size_t keyLen, void *value) {
...
@@ -61,7 +61,7 @@ static void deleteTableCacheLast(const void *key, size_t keyLen, void *value) {
int16_t
nCol
=
taosArrayGetSize
(
pLastArray
);
int16_t
nCol
=
taosArrayGetSize
(
pLastArray
);
for
(
int16_t
iCol
=
0
;
iCol
<
nCol
;
++
iCol
)
{
for
(
int16_t
iCol
=
0
;
iCol
<
nCol
;
++
iCol
)
{
SLastCol
*
pLastCol
=
(
SLastCol
*
)
taosArrayGet
(
pLastArray
,
iCol
);
SLastCol
*
pLastCol
=
(
SLastCol
*
)
taosArrayGet
(
pLastArray
,
iCol
);
if
(
IS_VAR_DATA_TYPE
(
pLastCol
->
colVal
.
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pLastCol
->
colVal
.
type
)
&&
pLastCol
->
colVal
.
value
.
nData
>
0
)
{
taosMemoryFree
(
pLastCol
->
colVal
.
value
.
pData
);
taosMemoryFree
(
pLastCol
->
colVal
.
value
.
pData
);
}
}
}
}
...
@@ -1160,7 +1160,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, SArray **ppCo
...
@@ -1160,7 +1160,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, SArray **ppCo
tsdbRowGetColVal
(
pRow
,
pTSchema
,
iCol
,
pColVal
);
tsdbRowGetColVal
(
pRow
,
pTSchema
,
iCol
,
pColVal
);
SLastCol
lastCol
=
{.
ts
=
lastRowTs
,
.
colVal
=
*
pColVal
};
SLastCol
lastCol
=
{.
ts
=
lastRowTs
,
.
colVal
=
*
pColVal
};
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
type
)
&&
pColVal
->
value
.
nData
>
0
)
{
lastCol
.
colVal
.
value
.
pData
=
taosMemoryMalloc
(
lastCol
.
colVal
.
value
.
nData
);
lastCol
.
colVal
.
value
.
pData
=
taosMemoryMalloc
(
lastCol
.
colVal
.
value
.
nData
);
if
(
lastCol
.
colVal
.
value
.
pData
==
NULL
)
{
if
(
lastCol
.
colVal
.
value
.
pData
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -1202,7 +1202,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, SArray **ppCo
...
@@ -1202,7 +1202,7 @@ static int32_t mergeLastRow(tb_uid_t uid, STsdb *pTsdb, bool *dup, SArray **ppCo
tsdbRowGetColVal
(
pRow
,
pTSchema
,
iCol
,
pColVal
);
tsdbRowGetColVal
(
pRow
,
pTSchema
,
iCol
,
pColVal
);
if
(
COL_VAL_IS_NONE
(
tColVal
)
&&
!
COL_VAL_IS_NONE
(
pColVal
))
{
if
(
COL_VAL_IS_NONE
(
tColVal
)
&&
!
COL_VAL_IS_NONE
(
pColVal
))
{
SLastCol
lastCol
=
{.
ts
=
rowTs
,
.
colVal
=
*
pColVal
};
SLastCol
lastCol
=
{.
ts
=
rowTs
,
.
colVal
=
*
pColVal
};
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
type
)
&&
pColVal
->
value
.
nData
>
0
)
{
SLastCol
*
pLastCol
=
(
SLastCol
*
)
taosArrayGet
(
pColArray
,
iCol
);
SLastCol
*
pLastCol
=
(
SLastCol
*
)
taosArrayGet
(
pColArray
,
iCol
);
taosMemoryFree
(
pLastCol
->
colVal
.
value
.
pData
);
taosMemoryFree
(
pLastCol
->
colVal
.
value
.
pData
);
...
@@ -1283,7 +1283,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
...
@@ -1283,7 +1283,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
tsdbRowGetColVal
(
pRow
,
pTSchema
,
iCol
,
pColVal
);
tsdbRowGetColVal
(
pRow
,
pTSchema
,
iCol
,
pColVal
);
SLastCol
lastCol
=
{.
ts
=
lastRowTs
,
.
colVal
=
*
pColVal
};
SLastCol
lastCol
=
{.
ts
=
lastRowTs
,
.
colVal
=
*
pColVal
};
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
type
)
&&
pColVal
->
value
.
nData
>
0
)
{
lastCol
.
colVal
.
value
.
pData
=
taosMemoryMalloc
(
lastCol
.
colVal
.
value
.
nData
);
lastCol
.
colVal
.
value
.
pData
=
taosMemoryMalloc
(
lastCol
.
colVal
.
value
.
nData
);
if
(
lastCol
.
colVal
.
value
.
pData
==
NULL
)
{
if
(
lastCol
.
colVal
.
value
.
pData
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -1321,7 +1321,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
...
@@ -1321,7 +1321,7 @@ static int32_t mergeLast(tb_uid_t uid, STsdb *pTsdb, SArray **ppLastArray) {
tsdbRowGetColVal
(
pRow
,
pTSchema
,
iCol
,
pColVal
);
tsdbRowGetColVal
(
pRow
,
pTSchema
,
iCol
,
pColVal
);
if
(
!
COL_VAL_IS_VALUE
(
tColVal
)
&&
COL_VAL_IS_VALUE
(
pColVal
))
{
if
(
!
COL_VAL_IS_VALUE
(
tColVal
)
&&
COL_VAL_IS_VALUE
(
pColVal
))
{
SLastCol
lastCol
=
{.
ts
=
rowTs
,
.
colVal
=
*
pColVal
};
SLastCol
lastCol
=
{.
ts
=
rowTs
,
.
colVal
=
*
pColVal
};
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pColVal
->
type
)
&&
pColVal
->
value
.
nData
>
0
)
{
SLastCol
*
pLastCol
=
(
SLastCol
*
)
taosArrayGet
(
pColArray
,
iCol
);
SLastCol
*
pLastCol
=
(
SLastCol
*
)
taosArrayGet
(
pColArray
,
iCol
);
taosMemoryFree
(
pLastCol
->
colVal
.
value
.
pData
);
taosMemoryFree
(
pLastCol
->
colVal
.
value
.
pData
);
...
...
source/libs/planner/src/planOptimizer.c
浏览文件 @
8154200a
...
@@ -2139,20 +2139,28 @@ static int32_t rewriteUniqueOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLog
...
@@ -2139,20 +2139,28 @@ static int32_t rewriteUniqueOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLog
return
rewriteUniqueOptimizeImpl
(
pCxt
,
pLogicSubplan
,
pIndef
);
return
rewriteUniqueOptimizeImpl
(
pCxt
,
pLogicSubplan
,
pIndef
);
}
}
static
EDealRes
lastRowScanOptHasTagImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
typedef
struct
SLastRowScanOptLastParaCkCxt
{
bool
hasTag
;
bool
hasCol
;
}
SLastRowScanOptLastParaCkCxt
;
static
EDealRes
lastRowScanOptLastParaCheckImpl
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
SLastRowScanOptLastParaCkCxt
*
pCxt
=
pContext
;
if
(
COLUMN_TYPE_TAG
==
((
SColumnNode
*
)
pNode
)
->
colType
||
COLUMN_TYPE_TBNAME
==
((
SColumnNode
*
)
pNode
)
->
colType
)
{
if
(
COLUMN_TYPE_TAG
==
((
SColumnNode
*
)
pNode
)
->
colType
||
COLUMN_TYPE_TBNAME
==
((
SColumnNode
*
)
pNode
)
->
colType
)
{
*
(
bool
*
)
pContext
=
true
;
pCxt
->
hasTag
=
true
;
return
DEAL_RES_END
;
}
else
{
pCxt
->
hasCol
=
true
;
}
}
return
DEAL_RES_END
;
}
}
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
static
bool
lastRowScanOpt
HasTag
(
SNode
*
pExpr
)
{
static
bool
lastRowScanOpt
LastParaCheck
(
SNode
*
pExpr
)
{
bool
hasTag
=
false
;
SLastRowScanOptLastParaCkCxt
cxt
=
{.
hasTag
=
false
,
.
hasCol
=
false
}
;
nodesWalkExpr
(
pExpr
,
lastRowScanOpt
HasTagImpl
,
&
hasTag
);
nodesWalkExpr
(
pExpr
,
lastRowScanOpt
LastParaCheckImpl
,
&
cxt
);
return
hasTag
;
return
!
cxt
.
hasTag
&&
cxt
.
hasCol
;
}
}
static
bool
hasSuitableCache
(
int8_t
cacheLastMode
,
bool
hasLastRow
,
bool
hasLast
)
{
static
bool
hasSuitableCache
(
int8_t
cacheLastMode
,
bool
hasLastRow
,
bool
hasLast
)
{
...
@@ -2192,7 +2200,7 @@ static bool lastRowScanOptMayBeOptimized(SLogicNode* pNode) {
...
@@ -2192,7 +2200,7 @@ static bool lastRowScanOptMayBeOptimized(SLogicNode* pNode) {
FOREACH
(
pFunc
,
((
SAggLogicNode
*
)
pNode
)
->
pAggFuncs
)
{
FOREACH
(
pFunc
,
((
SAggLogicNode
*
)
pNode
)
->
pAggFuncs
)
{
SFunctionNode
*
pAggFunc
=
(
SFunctionNode
*
)
pFunc
;
SFunctionNode
*
pAggFunc
=
(
SFunctionNode
*
)
pFunc
;
if
(
FUNCTION_TYPE_LAST
==
pAggFunc
->
funcType
)
{
if
(
FUNCTION_TYPE_LAST
==
pAggFunc
->
funcType
)
{
if
(
hasSelectFunc
||
lastRowScanOptHasTag
(
nodesListGetNode
(
pAggFunc
->
pParameterList
,
0
)))
{
if
(
hasSelectFunc
||
!
lastRowScanOptLastParaCheck
(
nodesListGetNode
(
pAggFunc
->
pParameterList
,
0
)))
{
return
false
;
return
false
;
}
}
hasLastFunc
=
true
;
hasLastFunc
=
true
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录