Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
684db8eb
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看板
提交
684db8eb
编写于
4月 15, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(query): refactor some variable name and macro definitions.
上级
7873c74e
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
50 addition
and
64 deletion
+50
-64
include/libs/function/function.h
include/libs/function/function.h
+4
-5
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+8
-0
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+16
-37
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+3
-3
source/libs/function/src/taggfunction.c
source/libs/function/src/taggfunction.c
+19
-19
未找到文件。
include/libs/function/function.h
浏览文件 @
684db8eb
...
...
@@ -110,7 +110,6 @@ typedef struct SFileBlockInfo {
#define FUNCTION_COV 38
typedef
struct
SResultRowEntryInfo
{
// int8_t hasResult:6; // result generated, not NULL value
bool
initialized
:
1
;
// output buffer has been initialized
bool
complete
:
1
;
// query has completed
uint8_t
isNullRes
:
6
;
// the result is null
...
...
@@ -119,10 +118,10 @@ typedef struct SResultRowEntryInfo {
// determine the real data need to calculated the result
enum
{
BLK_DATA_NO
_NEEDED
=
0x0
,
BLK_DATA_S
TATIS_NEEDED
=
0x1
,
BLK_DATA_
ALL_NEEDED
=
0x3
,
BLK_DATA_
DISCARD
=
0x4
,
// discard current data block since it is not qualified for filter
BLK_DATA_NO
T_LOAD
=
0x0
,
BLK_DATA_S
MA_LOAD
=
0x1
,
BLK_DATA_
DATA_LOAD
=
0x3
,
BLK_DATA_
FILTEROUT
=
0x4
,
// discard current data block since it is not qualified for filter
};
enum
{
...
...
source/client/inc/clientInt.h
浏览文件 @
684db8eb
...
...
@@ -46,6 +46,14 @@ extern "C" {
#define ERROR_MSG_BUF_DEFAULT_SIZE 512
#define HEARTBEAT_INTERVAL 1500 // ms
enum
{
RES_TYPE__QUERY
=
1
,
RES_TYPE__TMQ
,
};
#define TD_RES_QUERY(res) (*(int8_t*)res == RES_TYPE__QUERY)
#define TD_RES_TMQ(res) (*(int8_t*)res == RES_TYPE__TMQ)
typedef
struct
SAppInstInfo
SAppInstInfo
;
typedef
struct
{
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
684db8eb
...
...
@@ -2004,7 +2004,7 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) {
bool
hasFirstLastFunc
=
false
;
bool
hasOtherFunc
=
false
;
if
(
status
==
BLK_DATA_
ALL_NEEDED
||
status
==
BLK_DATA_DISCARD
)
{
if
(
status
==
BLK_DATA_
DATA_LOAD
||
status
==
BLK_DATA_FILTEROUT
)
{
return
status
;
}
...
...
@@ -2023,11 +2023,11 @@ static int32_t updateBlockLoadStatus(STaskAttr* pQuery, int32_t status) {
}
}
if
(
hasFirstLastFunc
&&
status
==
BLK_DATA_NO
_NEEDE
D
)
{
if
(
hasFirstLastFunc
&&
status
==
BLK_DATA_NO
T_LOA
D
)
{
if
(
!
hasOtherFunc
)
{
return
BLK_DATA_
DISCARD
;
return
BLK_DATA_
FILTEROUT
;
}
else
{
return
BLK_DATA_
ALL_NEEDE
D
;
return
BLK_DATA_
DATA_LOA
D
;
}
}
...
...
@@ -2360,7 +2360,7 @@ static void doSetTagValueInParam(void* pTable, int32_t tagColId, SVarian
static
uint32_t
doFilterByBlockTimeWindow
(
STableScanInfo
*
pTableScanInfo
,
SSDataBlock
*
pBlock
)
{
SqlFunctionCtx
*
pCtx
=
pTableScanInfo
->
pCtx
;
uint32_t
status
=
BLK_DATA_NO
_NEEDE
D
;
uint32_t
status
=
BLK_DATA_NO
T_LOA
D
;
int32_t
numOfOutput
=
pTableScanInfo
->
numOfOutput
;
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
...
...
@@ -2369,11 +2369,11 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData
// group by + first/last should not apply the first/last block filter
if
(
functionId
<
0
)
{
status
|=
BLK_DATA_
ALL_NEEDE
D
;
status
|=
BLK_DATA_
DATA_LOA
D
;
return
status
;
}
else
{
// status |= aAggs[functionId].dataReqFunc(&pTableScanInfo->pCtx[i], &pBlock->info.window, colId);
// if ((status & BLK_DATA_
ALL_NEEDED) == BLK_DATA_ALL_NEEDE
D) {
// if ((status & BLK_DATA_
DATA_LOAD) == BLK_DATA_DATA_LOA
D) {
// return status;
// }
}
...
...
@@ -2384,7 +2384,7 @@ static uint32_t doFilterByBlockTimeWindow(STableScanInfo* pTableScanInfo, SSData
int32_t
loadDataBlockOnDemand
(
SExecTaskInfo
*
pTaskInfo
,
STableScanInfo
*
pTableScanInfo
,
SSDataBlock
*
pBlock
,
uint32_t
*
status
)
{
*
status
=
BLK_DATA_NO
_NEEDE
D
;
*
status
=
BLK_DATA_NO
T_LOA
D
;
pBlock
->
pDataBlock
=
NULL
;
pBlock
->
pBlockAgg
=
NULL
;
...
...
@@ -2397,36 +2397,15 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
pCost
->
totalBlocks
+=
1
;
pCost
->
totalRows
+=
pBlock
->
info
.
rows
;
#if 0
if (pRuntimeEnv->pTsBuf != NULL) {
(*status) = BLK_DATA_ALL_NEEDED;
if (pQueryAttr->stableQuery) { // todo refactor
SExprInfo* pExprInfo = &pTableScanInfo->pExpr[0];
int16_t tagId = (int16_t)pExprInfo->base.param[0].i;
SColumnInfo* pColInfo = doGetTagColumnInfoById(pQueryAttr->tagColList, pQueryAttr->numOfTags, tagId);
// compare tag first
SVariant t = {0};
doSetTagValueInParam(pRuntimeEnv->current->pTable, tagId, &t, pColInfo->type, pColInfo->bytes);
setTimestampListJoinInfo(pRuntimeEnv, &t, pRuntimeEnv->current);
STSElem elem = tsBufGetElem(pRuntimeEnv->pTsBuf);
if (!tsBufIsValidElem(&elem) || (tsBufIsValidElem(&elem) && (taosVariantCompare(&t, elem.tag) != 0))) {
(*status) = BLK_DATA_DISCARD;
return TSDB_CODE_SUCCESS;
}
}
}
// Calculate all time windows that are overlapping or contain current data block.
// If current data block is contained by all possible time window, do not load current data block.
if (/*pQueryAttr->pFilters || */pQueryAttr->groupbyColumn || pQueryAttr->sw.gap > 0 ||
(QUERY_IS_INTERVAL_QUERY(pQueryAttr) && overlapWithTimeWindow(pTaskInfo, &pBlock->info))) {
(*status) = BLK_DATA_
ALL_NEEDE
D;
(*status) = BLK_DATA_
DATA_LOA
D;
}
// check if this data block is required to load
if ((*status) != BLK_DATA_
ALL_NEEDE
D) {
if ((*status) != BLK_DATA_
DATA_LOA
D) {
bool needFilter = true;
// the pCtx[i] result is belonged to previous time window since the outputBuf has not been set yet,
...
...
@@ -2458,18 +2437,18 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
if (needFilter) {
(*status) = doFilterByBlockTimeWindow(pTableScanInfo, pBlock);
} else {
(*status) = BLK_DATA_
ALL_NEEDE
D;
(*status) = BLK_DATA_
DATA_LOA
D;
}
}
SDataBlockInfo* pBlockInfo = &pBlock->info;
// *status = updateBlockLoadStatus(pRuntimeEnv->pQueryAttr, *status);
if ((*status) == BLK_DATA_NO
_NEEDED || (*status) == BLK_DATA_DISCARD
) {
if ((*status) == BLK_DATA_NO
T_LOAD || (*status) == BLK_DATA_FILTEROUT
) {
//qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
// pBlockInfo->window.ekey, pBlockInfo->rows);
pCost->discardBlocks += 1;
} else if ((*status) == BLK_DATA_S
TATIS_NEEDE
D) {
} else if ((*status) == BLK_DATA_S
MA_LOA
D) {
// this function never returns error?
pCost->loadBlockStatis += 1;
// tsdbRetrieveDataBlockStatisInfo(pTableScanInfo->pTsdbReadHandle, &pBlock->pBlockAgg);
...
...
@@ -2479,7 +2458,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
pCost->totalCheckedRows += pBlock->info.rows;
}
} else {
assert((*status) == BLK_DATA_
ALL_NEEDE
D);
assert((*status) == BLK_DATA_
DATA_LOA
D);
// load the data block statistics to perform further filter
pCost->loadBlockStatis += 1;
...
...
@@ -2511,7 +2490,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
pCost->discardBlocks += 1;
//qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId,
// pBlockInfo->window.skey, pBlockInfo->window.ekey, pBlockInfo->rows);
(*status) = BLK_DATA_
DISCARD
;
(*status) = BLK_DATA_
FILTEROUT
;
return TSDB_CODE_SUCCESS;
}
}
...
...
@@ -2523,7 +2502,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
// pCost->discardBlocks += 1;
// qDebug("QInfo:0x%"PRIx64" data block discard, brange:%" PRId64 "-%" PRId64 ", rows:%d", pQInfo->qId, pBlockInfo->window.skey,
// pBlockInfo->window.ekey, pBlockInfo->rows);
// (*status) = BLK_DATA_
DISCARD
;
// (*status) = BLK_DATA_
FILTEROUT
;
// return TSDB_CODE_SUCCESS;
// }
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
684db8eb
...
...
@@ -73,7 +73,7 @@ int32_t loadDataBlock(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableScanInfo,
pCost
->
totalCheckedRows
+=
pBlock
->
info
.
rows
;
pCost
->
loadBlocks
+=
1
;
*
status
=
BLK_DATA_
ALL_NEEDE
D
;
*
status
=
BLK_DATA_
DATA_LOA
D
;
SArray
*
pCols
=
tsdbRetrieveDataBlock
(
pTableScanInfo
->
dataReader
,
NULL
);
if
(
pCols
==
NULL
)
{
...
...
@@ -138,7 +138,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
// }
// this function never returns error?
uint32_t
status
=
BLK_DATA_
ALL_NEEDE
D
;
uint32_t
status
=
BLK_DATA_
DATA_LOA
D
;
int32_t
code
=
loadDataBlock
(
pTaskInfo
,
pTableScanInfo
,
pBlock
,
&
status
);
// int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -146,7 +146,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator, bool* newgroup) {
}
// current block is ignored according to filter result by block statistics data, continue load the next block
if
(
status
==
BLK_DATA_
DISCARD
||
pBlock
->
info
.
rows
==
0
)
{
if
(
status
==
BLK_DATA_
FILTEROUT
||
pBlock
->
info
.
rows
==
0
)
{
continue
;
}
...
...
source/libs/function/src/taggfunction.c
浏览文件 @
684db8eb
...
...
@@ -557,14 +557,14 @@ static void count_func_merge(SqlFunctionCtx *pCtx) {
*/
int32_t
countRequired
(
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
if
(
colId
==
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
return
BLK_DATA_NO
_NEEDE
D
;
return
BLK_DATA_NO
T_LOA
D
;
}
else
{
return
BLK_DATA_S
TATIS_NEEDE
D
;
return
BLK_DATA_S
MA_LOA
D
;
}
}
int32_t
noDataRequired
(
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
return
BLK_DATA_NO
_NEEDE
D
;
return
BLK_DATA_NO
T_LOA
D
;
}
#define LIST_ADD_N_DOUBLE_FLOAT(x, ctx, p, t, numOfElem, tsdbType) \
do { \
...
...
@@ -743,76 +743,76 @@ static void sum_func_merge(SqlFunctionCtx *pCtx) {
}
static
int32_t
statisRequired
(
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
return
BLK_DATA_S
TATIS_NEEDE
D
;
return
BLK_DATA_S
MA_LOA
D
;
}
static
int32_t
dataBlockRequired
(
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
return
BLK_DATA_
ALL_NEEDE
D
;
return
BLK_DATA_
DATA_LOA
D
;
}
// todo: if column in current data block are null, opt for this case
static
int32_t
firstFuncRequired
(
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
if
(
pCtx
->
order
==
TSDB_ORDER_DESC
)
{
return
BLK_DATA_NO
_NEEDE
D
;
return
BLK_DATA_NO
T_LOA
D
;
}
// no result for first query, data block is required
if
(
GET_RES_INFO
(
pCtx
)
==
NULL
||
GET_RES_INFO
(
pCtx
)
->
numOfRes
<=
0
)
{
return
BLK_DATA_
ALL_NEEDE
D
;
return
BLK_DATA_
DATA_LOA
D
;
}
else
{
return
BLK_DATA_NO
_NEEDE
D
;
return
BLK_DATA_NO
T_LOA
D
;
}
}
static
int32_t
lastFuncRequired
(
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
if
(
pCtx
->
order
!=
pCtx
->
param
[
0
].
i
)
{
return
BLK_DATA_NO
_NEEDE
D
;
return
BLK_DATA_NO
T_LOA
D
;
}
if
(
GET_RES_INFO
(
pCtx
)
==
NULL
||
GET_RES_INFO
(
pCtx
)
->
numOfRes
<=
0
)
{
return
BLK_DATA_
ALL_NEEDE
D
;
return
BLK_DATA_
DATA_LOA
D
;
}
else
{
return
BLK_DATA_NO
_NEEDE
D
;
return
BLK_DATA_NO
T_LOA
D
;
}
}
static
int32_t
firstDistFuncRequired
(
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
if
(
pCtx
->
order
==
TSDB_ORDER_DESC
)
{
return
BLK_DATA_NO
_NEEDE
D
;
return
BLK_DATA_NO
T_LOA
D
;
}
// not initialized yet, it is the first block, load it.
if
(
pCtx
->
pOutput
==
NULL
)
{
return
BLK_DATA_
ALL_NEEDE
D
;
return
BLK_DATA_
DATA_LOA
D
;
}
// the pCtx should be set to current Ctx and output buffer before call this function. Otherwise, pCtx->pOutput is
// the previous windowRes output buffer, not current unloaded block. In this case, the following filter is invalid
SFirstLastInfo
*
pInfo
=
(
SFirstLastInfo
*
)
(
pCtx
->
pOutput
+
pCtx
->
inputBytes
);
if
(
pInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
return
BLK_DATA_
ALL_NEEDE
D
;
return
BLK_DATA_
DATA_LOA
D
;
}
else
{
// data in current block is not earlier than current result
return
(
pInfo
->
ts
<=
w
->
skey
)
?
BLK_DATA_NO
_NEEDED
:
BLK_DATA_ALL_NEEDE
D
;
return
(
pInfo
->
ts
<=
w
->
skey
)
?
BLK_DATA_NO
T_LOAD
:
BLK_DATA_DATA_LOA
D
;
}
}
static
int32_t
lastDistFuncRequired
(
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
w
,
int32_t
colId
)
{
if
(
pCtx
->
order
!=
pCtx
->
param
[
0
].
i
)
{
return
BLK_DATA_NO
_NEEDE
D
;
return
BLK_DATA_NO
T_LOA
D
;
}
// not initialized yet, it is the first block, load it.
if
(
pCtx
->
pOutput
==
NULL
)
{
return
BLK_DATA_
ALL_NEEDE
D
;
return
BLK_DATA_
DATA_LOA
D
;
}
// the pCtx should be set to current Ctx and output buffer before call this function. Otherwise, pCtx->pOutput is
// the previous windowRes output buffer, not current unloaded block. In this case, the following filter is invalid
SFirstLastInfo
*
pInfo
=
(
SFirstLastInfo
*
)
(
pCtx
->
pOutput
+
pCtx
->
inputBytes
);
if
(
pInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
return
BLK_DATA_
ALL_NEEDE
D
;
return
BLK_DATA_
DATA_LOA
D
;
}
else
{
return
(
pInfo
->
ts
>
w
->
ekey
)
?
BLK_DATA_NO
_NEEDED
:
BLK_DATA_ALL_NEEDE
D
;
return
(
pInfo
->
ts
>
w
->
ekey
)
?
BLK_DATA_NO
T_LOAD
:
BLK_DATA_DATA_LOA
D
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录