Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
34c125e1
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看板
提交
34c125e1
编写于
4月 16, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(query): fix bug in employing sma data during aggregate process.
上级
fd9e5208
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
46 addition
and
30 deletion
+46
-30
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+27
-26
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+19
-4
未找到文件。
source/libs/executor/src/executorimpl.c
浏览文件 @
34c125e1
...
...
@@ -186,7 +186,7 @@ static void getNextTimeWindow(SInterval* pInterval, int32_t precision, int32_t o
static
void
doSetTagValueToResultBuf
(
char
*
output
,
const
char
*
val
,
int16_t
type
,
int16_t
bytes
);
static
bool
functionNeedToExecute
(
SqlFunctionCtx
*
pCtx
);
static
void
setBlockStatisInfo
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pSDataBlock
,
SColumn
*
pColumn
);
static
void
setBlockStatisInfo
(
SqlFunctionCtx
*
pCtx
,
S
ExprInfo
*
pExpr
,
S
SDataBlock
*
pSDataBlock
,
SColumn
*
pColumn
);
static
void
destroyTableQueryInfoImpl
(
STableQueryInfo
*
pTableQueryInfo
);
static
bool
hasMainOutput
(
STaskAttr
*
pQueryAttr
);
...
...
@@ -325,8 +325,7 @@ static bool isSelectivityWithTagsQuery(SqlFunctionCtx* pCtx, int32_t numOfOutput
}
static
bool
hasNull
(
SColumn
*
pColumn
,
SColumnDataAgg
*
pStatis
)
{
if
(
TSDB_COL_IS_TAG
(
pColumn
->
flag
)
||
TSDB_COL_IS_UD_COL
(
pColumn
->
flag
)
||
pColumn
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
if
(
TSDB_COL_IS_TAG
(
pColumn
->
flag
)
||
TSDB_COL_IS_UD_COL
(
pColumn
->
flag
)
||
pColumn
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
return
false
;
}
...
...
@@ -1042,22 +1041,19 @@ static TSKEY getStartTsKey(STimeWindow* win, const TSKEY* tsCols, int32_t rows,
static
void
doSetInputDataBlock
(
SOperatorInfo
*
pOperator
,
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
);
static
void
doSetInputDataBlockInfo
(
SOperatorInfo
*
pOperator
,
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
)
{
static
void
doSetInputDataBlockInfo
(
SOperatorInfo
*
pOperator
,
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
)
{
for
(
int32_t
i
=
0
;
i
<
pOperator
->
numOfOutput
;
++
i
)
{
pCtx
[
i
].
order
=
order
;
pCtx
[
i
].
size
=
pBlock
->
info
.
rows
;
pCtx
[
i
].
currentStage
=
(
uint8_t
)
pOperator
->
pRuntimeEnv
->
scanFlag
;
setBlockStatisInfo
(
&
pCtx
[
i
],
pBlock
,
NULL
/*&pOperator->pExpr[i].base.colInfo*/
);
setBlockStatisInfo
(
&
pCtx
[
i
],
&
pOperator
->
pExpr
[
i
],
pBlock
,
NULL
/*&pOperator->pExpr[i].base.colInfo*/
);
}
}
void
setInputDataBlock
(
SOperatorInfo
*
pOperator
,
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
)
{
if
(
pBlock
->
pDataBlock
!=
NULL
)
{
doSetInputDataBlock
(
pOperator
,
pCtx
,
pBlock
,
order
);
}
else
{
if
(
pBlock
->
pBlockAgg
!=
NULL
)
{
doSetInputDataBlockInfo
(
pOperator
,
pCtx
,
pBlock
,
order
);
}
else
{
doSetInputDataBlock
(
pOperator
,
pCtx
,
pBlock
,
order
);
}
}
...
...
@@ -1745,27 +1741,32 @@ static bool functionNeedToExecute(SqlFunctionCtx* pCtx) {
return
true
;
}
void
setBlockStatisInfo
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pSDataBlock
,
SColumn
*
pColumn
)
{
SColumnDataAgg
*
pAgg
=
NULL
;
if
(
pSDataBlock
->
pBlockAgg
!=
NULL
&&
TSDB_COL_IS_NORMAL_COL
(
pColumn
->
flag
))
{
pAgg
=
&
pSDataBlock
->
pBlockAgg
[
pCtx
->
columnIndex
];
void
setBlockStatisInfo
(
SqlFunctionCtx
*
pCtx
,
SExprInfo
*
pExprInfo
,
SSDataBlock
*
pBlock
,
SColumn
*
pColumn
)
{
if
(
pBlock
->
pBlockAgg
!=
NULL
/*&& TSDB_COL_IS_NORMAL_COL(pColumn->flag)*/
)
{
for
(
int32_t
j
=
0
;
j
<
pExprInfo
->
base
.
numOfParams
;
++
j
)
{
SFunctParam
*
pFuncParam
=
&
pExprInfo
->
base
.
pParam
[
j
];
if
(
pFuncParam
->
type
==
FUNC_PARAM_TYPE_COLUMN
)
{
int32_t
slotId
=
pFuncParam
->
pCol
->
slotId
;
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
pCtx
->
agg
=
*
pAgg
;
pCtx
->
isAggSet
=
true
;
assert
(
pCtx
->
agg
.
numOfNull
<=
pSDataBlock
->
info
.
rows
);
pInput
->
pColumnDataAgg
[
j
]
=
&
pBlock
->
pBlockAgg
[
slotId
];
pInput
->
colDataAggIsSet
=
true
;
pInput
->
numOfRows
=
pBlock
->
info
.
rows
;
pInput
->
totalRows
=
pBlock
->
info
.
rows
;
}
}
}
else
{
pCtx
->
i
sAgg
Set
=
false
;
pCtx
->
i
nput
.
colDataAggIs
Set
=
false
;
}
pCtx
->
hasNull
=
hasNull
(
pColumn
,
pAgg
);
//
pCtx->hasNull = hasNull(pColumn, pAgg);
// set the statistics data for primary time stamp column
if
(
pCtx
->
functionId
==
FUNCTION_SPREAD
&&
pColumn
->
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
pCtx
->
isAggSet
=
true
;
pCtx
->
agg
.
min
=
pSData
Block
->
info
.
window
.
skey
;
pCtx
->
agg
.
max
=
pSData
Block
->
info
.
window
.
ekey
;
}
//
if (pCtx->functionId == FUNCTION_SPREAD && pColumn->colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
//
pCtx->isAggSet = true;
// pCtx->agg.min = p
Block->info.window.skey;
// pCtx->agg.max = p
Block->info.window.ekey;
//
}
}
// set the output buffer for the selectivity + tag query
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
34c125e1
...
...
@@ -80,6 +80,7 @@ int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo,
}
SDataBlockInfo
*
pBlockInfo
=
&
pBlock
->
info
;
taosMemoryFreeClear
(
pBlock
->
pBlockAgg
);
if
(
*
status
==
FUNC_DATA_REQUIRED_FILTEROUT
)
{
qDebug
(
"%s data block filter out, brange:%"
PRId64
"-%"
PRId64
", rows:%d"
,
GET_TASKID
(
pTaskInfo
),
pBlockInfo
->
window
.
skey
,
...
...
@@ -93,15 +94,28 @@ int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo,
return
TSDB_CODE_SUCCESS
;
}
else
if
(
*
status
==
FUNC_DATA_REQUIRED_STATIS_LOAD
)
{
pCost
->
loadBlockStatis
+=
1
;
tsdbRetrieveDataBlockStatisInfo
(
pTableScanInfo
->
dataReader
,
&
pBlock
->
pBlockAgg
);
// failed to load the block sma data, data block statistics does not exist, load data block instead
if
(
pBlock
->
pBlockAgg
==
NULL
)
{
SColumnDataAgg
*
pColAgg
=
NULL
;
tsdbRetrieveDataBlockStatisInfo
(
pTableScanInfo
->
dataReader
,
&
pColAgg
);
if
(
pColAgg
!=
NULL
)
{
int32_t
numOfCols
=
pBlock
->
info
.
numOfCols
;
// todo create this buffer during creating operator
pBlock
->
pBlockAgg
=
taosMemoryCalloc
(
numOfCols
,
sizeof
(
SColumnDataAgg
));
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColMatchInfo
*
pColMatchInfo
=
taosArrayGet
(
pTableScanInfo
->
pColMatchInfo
,
i
);
if
(
!
pColMatchInfo
->
output
)
{
continue
;
}
pBlock
->
pBlockAgg
[
pColMatchInfo
->
targetSlotId
]
=
pColAgg
[
i
];
}
}
else
{
// failed to load the block sma data, data block statistics does not exist, load data block instead
pBlock
->
pDataBlock
=
tsdbRetrieveDataBlock
(
pTableScanInfo
->
dataReader
,
NULL
);
pCost
->
totalCheckedRows
+=
pBlock
->
info
.
rows
;
pCost
->
loadBlocks
+=
1
;
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -136,6 +150,7 @@ int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableScanInfo,
ASSERT
(
pColMatchInfo
->
colId
==
p
->
info
.
colId
);
taosArraySet
(
pBlock
->
pDataBlock
,
pColMatchInfo
->
targetSlotId
,
p
);
// taosArraySet(pBlock->pBlockAgg)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录