Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
820d6d13
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看板
提交
820d6d13
编写于
6月 17, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: do some internal refactor.
上级
d2f8a330
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
127 addition
and
175 deletion
+127
-175
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+2
-2
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+29
-46
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+5
-20
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+33
-55
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+17
-12
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+9
-8
source/libs/executor/src/sortoperator.c
source/libs/executor/src/sortoperator.c
+1
-1
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+31
-31
未找到文件。
source/libs/executor/inc/executil.h
浏览文件 @
820d6d13
...
...
@@ -113,7 +113,7 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
SExprInfo
*
createExprInfo
(
SNodeList
*
pNodeList
,
SNodeList
*
pGroupKeys
,
int32_t
*
numOfExprs
);
SqlFunctionCtx
*
createSqlFunctionCtx
(
SExprInfo
*
pExprInfo
,
int32_t
numOfOutput
,
int32_t
**
row
Cell
InfoOffset
);
SqlFunctionCtx
*
createSqlFunctionCtx
(
SExprInfo
*
pExprInfo
,
int32_t
numOfOutput
,
int32_t
**
row
Entry
InfoOffset
);
void
relocateColumnData
(
SSDataBlock
*
pBlock
,
const
SArray
*
pColMatchInfo
,
SArray
*
pCols
);
void
initExecTimeWindowInfo
(
SColumnInfoData
*
pColData
,
STimeWindow
*
pQueryWindow
);
...
...
@@ -121,6 +121,6 @@ SInterval extractIntervalInfo(const STableScanPhysiNode* pTableScanNode);
SColumn
extractColumnFromColumnNode
(
SColumnNode
*
pColNode
);
int32_t
initQueryTableDataCond
(
SQueryTableDataCond
*
pCond
,
const
STableScanPhysiNode
*
pTableScanNode
);
void
cleanupQueryTableDataCond
(
SQueryTableDataCond
*
pCond
);
void
cleanupQueryTableDataCond
(
SQueryTableDataCond
*
pCond
);
#endif // TDENGINE_QUERYUTIL_H
source/libs/executor/inc/executorimpl.h
浏览文件 @
820d6d13
...
...
@@ -83,7 +83,6 @@ typedef struct SResultInfo { // TODO refactor
typedef
struct
STableQueryInfo
{
TSKEY
lastKey
;
// last check ts, todo remove it later
SResultRowPosition
pos
;
// current active time window
// SVariant tag;
}
STableQueryInfo
;
typedef
struct
SLimit
{
...
...
@@ -156,8 +155,6 @@ typedef struct STaskAttr {
}
STaskAttr
;
struct
SOperatorInfo
;
//struct SAggSupporter;
//struct SOptrBasicInfo;
typedef
int32_t
(
*
__optr_encode_fn_t
)(
struct
SOperatorInfo
*
pOperator
,
char
**
result
,
int32_t
*
length
);
typedef
int32_t
(
*
__optr_decode_fn_t
)(
struct
SOperatorInfo
*
pOperator
,
char
*
result
);
...
...
@@ -199,25 +196,15 @@ typedef struct STaskRuntimeEnv {
STaskAttr
*
pQueryAttr
;
uint32_t
status
;
// query status
uint8_t
scanFlag
;
// denotes reversed scan of data or not
SDiskbasedBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
SHashObj
*
pResultRowHashTable
;
// quick locate the window object for each result
SHashObj
*
pResultRowListSet
;
// used to check if current ResultRowInfo has ResultRow object or not
SArray
*
pResultRowArrayList
;
// The array list that contains the Result rows
char
*
keyBuf
;
// window key buffer
// The window result objects pool, all the resultRow Objects are allocated and managed by this object.
char
**
prevRow
;
STSBuf
*
pTsBuf
;
// timestamp filter list
STSCursor
cur
;
char
*
tagVal
;
// tag value of current data block
// STableGroupInfo tableqinfoGroupInfo; // this is a table list
STSCursor
cur
;
char
*
tagVal
;
// tag value of current data block
struct
SOperatorInfo
*
proot
;
SGroupResInfo
groupResInfo
;
int64_t
currentOffset
;
// dynamic offset value
int64_t
currentOffset
;
// dynamic offset value
STableQueryInfo
*
current
;
SResultInfo
resultInfo
;
struct
SUdfInfo
*
pUdfInfo
;
}
STaskRuntimeEnv
;
enum
{
...
...
@@ -243,7 +230,7 @@ typedef struct SOperatorInfo {
bool
blocking
;
// block operator or not
uint8_t
status
;
// denote if current operator is completed
int32_t
numOfExprs
;
// number of columns of the current operator results
char
*
name
;
// name,
used to show the query execution plan
char
*
name
;
// name,
for debug purpose
void
*
info
;
// extension attribution
SExprInfo
*
pExpr
;
SExecTaskInfo
*
pTaskInfo
;
...
...
@@ -308,6 +295,13 @@ typedef struct SSampleExecInfo {
uint32_t
seed
;
// random seed value
}
SSampleExecInfo
;
typedef
struct
SExecSupp
{
SExprInfo
*
pExprInfo
;
int32_t
numOfExprs
;
// the number of scalar expression in group operator
SqlFunctionCtx
*
pCtx
;
int32_t
*
rowEntryInfoOffset
;
// offset value for each row result cell info
}
SExecSupp
;
typedef
struct
STableScanInfo
{
void
*
dataReader
;
SReadHandle
readHandle
;
...
...
@@ -320,17 +314,13 @@ typedef struct STableScanInfo {
SNode
*
pFilterNode
;
// filter info, which is push down by optimizer
SqlFunctionCtx
*
pCtx
;
// which belongs to the direct upstream operator operator query context
SResultRowInfo
*
pResultRowInfo
;
int32_t
*
row
Cell
InfoOffset
;
int32_t
*
row
Entry
InfoOffset
;
SExprInfo
*
pExpr
;
SSDataBlock
*
pResBlock
;
SArray
*
pColMatchInfo
;
int32_t
numOfOutput
;
SExprInfo
*
pPseudoExpr
;
int32_t
numOfPseudoExpr
;
SqlFunctionCtx
*
pPseudoCtx
;
// int32_t* rowCellInfoOffset;
SExecSupp
pseudoSup
;
SQueryTableDataCond
cond
;
int32_t
scanFlag
;
// table scan flag to denote if it is a repeat/reverse/main scan
int32_t
dataBlockLoadFlag
;
...
...
@@ -436,19 +426,20 @@ typedef struct SBlockDistInfo {
void
*
pHandle
;
}
SBlockDistInfo
;
// todo remove this
typedef
struct
SOptrBasicInfo
{
SResultRowInfo
resultRowInfo
;
int32_t
*
row
Cell
InfoOffset
;
// offset value for each row result cell info
int32_t
*
row
Entry
InfoOffset
;
// offset value for each row result cell info
SqlFunctionCtx
*
pCtx
;
SSDataBlock
*
pRes
;
}
SOptrBasicInfo
;
// TODO move the resultrowsiz together with SOptrBasicInfo:row
Cell
InfoOffset
// TODO move the resultrowsiz together with SOptrBasicInfo:row
Entry
InfoOffset
typedef
struct
SAggSupporter
{
SHashObj
*
pResultRowHashTable
;
// quick locate the window object for each result
char
*
keyBuf
;
// window key buffer
SDiskbasedBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
int32_t
resultRowSize
;
// the result buffer size for each result row, with the meta data size for each row
int32_t
resultRowSize
;
// the result buffer size for each result row, with the meta data size for each row
, todo remove it
}
SAggSupporter
;
typedef
struct
STimeWindowSupp
{
...
...
@@ -503,7 +494,7 @@ typedef struct SAggOperatorInfo {
SExprInfo
*
pScalarExprInfo
;
int32_t
numOfScalarExpr
;
// the number of scalar expression before the aggregate function can be applied
SqlFunctionCtx
*
pScalarCtx
;
// scalar function requried sql function struct.
int32_t
*
row
Cell
InfoOffset
;
// offset value for each row result cell info
int32_t
*
row
Entry
InfoOffset
;
// offset value for each row result cell info
}
SAggOperatorInfo
;
typedef
struct
SProjectOperatorInfo
{
...
...
@@ -528,11 +519,7 @@ typedef struct SIndefOperatorInfo {
SOptrBasicInfo
binfo
;
SAggSupporter
aggSup
;
SArray
*
pPseudoColInfo
;
SExprInfo
*
pScalarExpr
;
int32_t
numOfScalarExpr
;
SqlFunctionCtx
*
pScalarCtx
;
int32_t
*
rowCellInfoOffset
;
SExecSupp
scalarSup
;
}
SIndefOperatorInfo
;
typedef
struct
SFillOperatorInfo
{
...
...
@@ -544,13 +531,6 @@ typedef struct SFillOperatorInfo {
bool
multigroupResult
;
}
SFillOperatorInfo
;
typedef
struct
SScalarSupp
{
SExprInfo
*
pScalarExprInfo
;
int32_t
numOfScalarExpr
;
// the number of scalar expression in group operator
SqlFunctionCtx
*
pScalarFuncCtx
;
int32_t
*
rowCellInfoOffset
;
// offset value for each row result cell info
}
SScalarSupp
;
typedef
struct
SGroupbyOperatorInfo
{
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
SOptrBasicInfo
binfo
;
...
...
@@ -563,7 +543,7 @@ typedef struct SGroupbyOperatorInfo {
char
*
keyBuf
;
// group by keys for hash
int32_t
groupKeyLen
;
// total group by column width
SGroupResInfo
groupResInfo
;
S
ScalarSupp
scalarSup
;
S
ExecSupp
scalarSup
;
}
SGroupbyOperatorInfo
;
typedef
struct
SDataGroupInfo
{
...
...
@@ -587,7 +567,7 @@ typedef struct SPartitionOperatorInfo {
void
*
pGroupIter
;
// group iterator
int32_t
pageIndex
;
// page index of current group
SSDataBlock
*
pUpdateRes
;
S
ScalarSupp
scalarSup
p
;
S
ExecSupp
scalarSu
p
;
}
SPartitionOperatorInfo
;
typedef
struct
SWindowRowsSup
{
...
...
@@ -764,9 +744,11 @@ void destroyBasicOperatorInfo(void* param, int32_t numOfOutput);
void
appendOneRowToDataBlock
(
SSDataBlock
*
pBlock
,
STupleHandle
*
pTupleHandle
);
void
setTbNameColData
(
void
*
pMeta
,
const
SSDataBlock
*
pBlock
,
SColumnInfoData
*
pColInfoData
,
int32_t
functionId
);
void
cleanupExecSupp
(
SExecSupp
*
pSupp
);
SSDataBlock
*
loadNextDataBlock
(
void
*
param
);
void
setResultRowInitCtx
(
SResultRow
*
pResult
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
row
Cell
InfoOffset
);
void
setResultRowInitCtx
(
SResultRow
*
pResult
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
row
Entry
InfoOffset
);
SResultRow
*
doSetResultOutBufByKey
(
SDiskbasedBuf
*
pResultBuf
,
SResultRowInfo
*
pResultRowInfo
,
char
*
pData
,
int16_t
bytes
,
bool
masterscan
,
uint64_t
groupId
,
...
...
@@ -885,12 +867,13 @@ STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowI
int32_t
getNumOfRowsInTimeWindow
(
SDataBlockInfo
*
pDataBlockInfo
,
TSKEY
*
pPrimaryColumn
,
int32_t
startPos
,
TSKEY
ekey
,
__block_search_fn_t
searchFn
,
STableQueryInfo
*
item
,
int32_t
order
);
int32_t
binarySearchForKey
(
char
*
pValue
,
int
num
,
TSKEY
key
,
int
order
);
int32_t
initStreamAggSupporter
(
SStreamAggSupporter
*
pSup
,
const
char
*
pKey
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
size
);
int32_t
initStreamAggSupporter
(
SStreamAggSupporter
*
pSup
,
const
char
*
pKey
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
size
);
SResultRow
*
getNewResultRow
(
SDiskbasedBuf
*
pResultBuf
,
int64_t
tableGroupId
,
int32_t
interBufSize
);
SResultWindowInfo
*
getSessionTimeWindow
(
SStreamAggSupporter
*
pAggSup
,
TSKEY
ts
,
uint64_t
groupId
,
int64_t
gap
,
int32_t
*
pIndex
);
int32_t
updateSessionWindowInfo
(
SResultWindowInfo
*
pWinInfo
,
TSKEY
*
pTs
,
int32_t
rows
,
int32_t
start
,
int64_t
gap
,
SHashObj
*
pStDeleted
);
int32_t
updateSessionWindowInfo
(
SResultWindowInfo
*
pWinInfo
,
TSKEY
*
pTs
,
int32_t
rows
,
int32_t
start
,
int64_t
gap
,
SHashObj
*
pStDeleted
);
bool
functionNeedToExecute
(
SqlFunctionCtx
*
pCtx
);
int32_t
compareTimeWindow
(
const
void
*
p1
,
const
void
*
p2
,
const
void
*
param
);
...
...
source/libs/executor/src/executil.c
浏览文件 @
820d6d13
...
...
@@ -42,21 +42,6 @@ void cleanupResultRowInfo(SResultRowInfo *pResultRowInfo) {
}
}
void
resetResultRowInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
)
{
for
(
int32_t
i
=
0
;
i
<
pResultRowInfo
->
size
;
++
i
)
{
// SResultRow *pWindowRes = pResultRowInfo->pResult[i];
// clearResultRow(pRuntimeEnv, pWindowRes);
int32_t
groupIndex
=
0
;
int64_t
uid
=
0
;
SET_RES_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
&
groupIndex
,
sizeof
(
groupIndex
),
uid
);
taosHashRemove
(
pRuntimeEnv
->
pResultRowHashTable
,
(
const
char
*
)
pRuntimeEnv
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
sizeof
(
groupIndex
)));
}
pResultRowInfo
->
size
=
0
;
}
void
closeAllResultRows
(
SResultRowInfo
*
pResultRowInfo
)
{
// do nothing
}
...
...
@@ -518,14 +503,14 @@ static int32_t setSelectValueColumnInfo(SqlFunctionCtx* pCtx, int32_t numOfOutpu
return
TSDB_CODE_SUCCESS
;
}
SqlFunctionCtx
*
createSqlFunctionCtx
(
SExprInfo
*
pExprInfo
,
int32_t
numOfOutput
,
int32_t
**
row
Cell
InfoOffset
)
{
SqlFunctionCtx
*
createSqlFunctionCtx
(
SExprInfo
*
pExprInfo
,
int32_t
numOfOutput
,
int32_t
**
row
Entry
InfoOffset
)
{
SqlFunctionCtx
*
pFuncCtx
=
(
SqlFunctionCtx
*
)
taosMemoryCalloc
(
numOfOutput
,
sizeof
(
SqlFunctionCtx
));
if
(
pFuncCtx
==
NULL
)
{
return
NULL
;
}
*
row
Cell
InfoOffset
=
taosMemoryCalloc
(
numOfOutput
,
sizeof
(
int32_t
));
if
(
*
row
Cell
InfoOffset
==
0
)
{
*
row
Entry
InfoOffset
=
taosMemoryCalloc
(
numOfOutput
,
sizeof
(
int32_t
));
if
(
*
row
Entry
InfoOffset
==
0
)
{
taosMemoryFreeClear
(
pFuncCtx
);
return
NULL
;
}
...
...
@@ -584,8 +569,8 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
}
for
(
int32_t
i
=
1
;
i
<
numOfOutput
;
++
i
)
{
(
*
row
Cell
InfoOffset
)[
i
]
=
(
int32_t
)((
*
row
Cell
InfoOffset
)[
i
-
1
]
+
sizeof
(
SResultRowEntryInfo
)
+
pFuncCtx
[
i
-
1
].
resDataInfo
.
interBufSize
);
(
*
row
Entry
InfoOffset
)[
i
]
=
(
int32_t
)((
*
row
Entry
InfoOffset
)[
i
-
1
]
+
sizeof
(
SResultRowEntryInfo
)
+
pFuncCtx
[
i
-
1
].
resDataInfo
.
interBufSize
);
}
setSelectValueColumnInfo
(
pFuncCtx
,
numOfOutput
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
820d6d13
...
...
@@ -147,32 +147,6 @@ static void setResultBufSize(STaskAttr* pQueryAttr, SResultInfo* pResultInfo);
static
void
doSetTableGroupOutputBuf
(
SAggOperatorInfo
*
pAggInfo
,
int32_t
numOfOutput
,
uint64_t
groupId
,
SExecTaskInfo
*
pTaskInfo
);
SArray
*
getOrderCheckColumns
(
STaskAttr
*
pQuery
);
typedef
struct
SRowCompSupporter
{
STaskRuntimeEnv
*
pRuntimeEnv
;
int16_t
dataOffset
;
__compar_fn_t
comFunc
;
}
SRowCompSupporter
;
static
int
compareRowData
(
const
void
*
a
,
const
void
*
b
,
const
void
*
userData
)
{
const
SResultRow
*
pRow1
=
(
const
SResultRow
*
)
a
;
const
SResultRow
*
pRow2
=
(
const
SResultRow
*
)
b
;
SRowCompSupporter
*
supporter
=
(
SRowCompSupporter
*
)
userData
;
STaskRuntimeEnv
*
pRuntimeEnv
=
supporter
->
pRuntimeEnv
;
SFilePage
*
page1
=
getBufPage
(
pRuntimeEnv
->
pResultBuf
,
pRow1
->
pageId
);
SFilePage
*
page2
=
getBufPage
(
pRuntimeEnv
->
pResultBuf
,
pRow2
->
pageId
);
int16_t
offset
=
supporter
->
dataOffset
;
return
0
;
// char* in1 = getPosInResultPage(pRuntimeEnv->pQueryAttr, page1, pRow1->offset, offset);
// char* in2 = getPosInResultPage(pRuntimeEnv->pQueryAttr, page2, pRow2->offset, offset);
// return (in1 != NULL && in2 != NULL) ? supporter->comFunc(in1, in2) : 0;
}
// setup the output buffer for each operator
static
bool
hasNull
(
SColumn
*
pColumn
,
SColumnDataAgg
*
pStatis
)
{
if
(
TSDB_COL_IS_TAG
(
pColumn
->
flag
)
||
TSDB_COL_IS_UD_COL
(
pColumn
->
flag
)
||
...
...
@@ -410,7 +384,7 @@ static int32_t addNewWindowResultBuf(SResultRow* pWindowRes, SDiskbasedBuf* pRes
static
bool
chkWindowOutputBufByKey
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
,
STimeWindow
*
win
,
bool
masterscan
,
SResultRow
**
pResult
,
int64_t
groupId
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
row
Cell
InfoOffset
)
{
int32_t
numOfOutput
,
int32_t
*
row
Entry
InfoOffset
)
{
assert
(
win
->
skey
<=
win
->
ekey
);
return
chkResultRowFromKey
(
pRuntimeEnv
,
pResultRowInfo
,
(
char
*
)
&
win
->
skey
,
TSDB_KEYSIZE
,
masterscan
,
groupId
);
}
...
...
@@ -1248,17 +1222,17 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
if (pQueryAttr->pointInterpQuery) {
needFilter = chkWindowOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, &win, masterScan, &pResult, groupId,
pTableScanInfo->pCtx, pTableScanInfo->numOfOutput,
pTableScanInfo->row
Cell
InfoOffset);
pTableScanInfo->row
Entry
InfoOffset);
} else {
if (setResultOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.uid, &win, masterScan, &pResult, groupId,
pTableScanInfo->pCtx, pTableScanInfo->numOfOutput,
pTableScanInfo->row
Cell
InfoOffset) != TSDB_CODE_SUCCESS) {
pTableScanInfo->row
Entry
InfoOffset) != TSDB_CODE_SUCCESS) {
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
}
}
} else if (pQueryAttr->stableQuery && (!pQueryAttr->tsCompQuery) && (!pQueryAttr->diffQuery)) { // stable aggregate, not interval aggregate or normal column aggregate
doSetTableGroupOutputBuf(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pTableScanInfo->pCtx,
pTableScanInfo->row
Cell
InfoOffset, pTableScanInfo->numOfOutput,
pTableScanInfo->row
Entry
InfoOffset, pTableScanInfo->numOfOutput,
pRuntimeEnv->current->groupIndex);
}
...
...
@@ -1303,7 +1277,7 @@ int32_t loadDataBlockOnDemand(SExecTaskInfo* pTaskInfo, STableScanInfo* pTableSc
STimeWindow win = getActiveTimeWindow(pTableScanInfo->pResultRowInfo, k, pQueryAttr);
if (setResultOutputBufByKey(pRuntimeEnv, pTableScanInfo->pResultRowInfo, pBlock->info.uid, &win, masterScan, &pResult, groupId,
pTableScanInfo->pCtx, pTableScanInfo->numOfOutput,
pTableScanInfo->row
Cell
InfoOffset) != TSDB_CODE_SUCCESS) {
pTableScanInfo->row
Entry
InfoOffset) != TSDB_CODE_SUCCESS) {
longjmp(pRuntimeEnv->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
}
}
...
...
@@ -1389,7 +1363,7 @@ void initResultRow(SResultRow* pResultRow) {
void
setFunctionResultOutput
(
SOptrBasicInfo
*
pInfo
,
SAggSupporter
*
pSup
,
int32_t
stage
,
int32_t
numOfExprs
,
SExecTaskInfo
*
pTaskInfo
)
{
SqlFunctionCtx
*
pCtx
=
pInfo
->
pCtx
;
int32_t
*
row
CellInfoOffset
=
pInfo
->
rowCell
InfoOffset
;
int32_t
*
row
EntryInfoOffset
=
pInfo
->
rowEntry
InfoOffset
;
SResultRowInfo
*
pResultRowInfo
=
&
pInfo
->
resultRowInfo
;
initResultRowInfo
(
pResultRowInfo
);
...
...
@@ -1400,7 +1374,7 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t
pTaskInfo
,
false
,
pSup
);
for
(
int32_t
i
=
0
;
i
<
numOfExprs
;
++
i
)
{
struct
SResultRowEntryInfo
*
pEntry
=
getResultEntryInfo
(
pRow
,
i
,
row
Cell
InfoOffset
);
struct
SResultRowEntryInfo
*
pEntry
=
getResultEntryInfo
(
pRow
,
i
,
row
Entry
InfoOffset
);
cleanupResultRowEntry
(
pEntry
);
pCtx
[
i
].
resultInfo
=
pEntry
;
...
...
@@ -1441,9 +1415,9 @@ void destroyTableQueryInfoImpl(STableQueryInfo* pTableQueryInfo) {
// cleanupResultRowInfo(&pTableQueryInfo->resInfo);
}
void
setResultRowInitCtx
(
SResultRow
*
pResult
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
row
Cell
InfoOffset
)
{
void
setResultRowInitCtx
(
SResultRow
*
pResult
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
row
Entry
InfoOffset
)
{
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
pCtx
[
i
].
resultInfo
=
getResultEntryInfo
(
pResult
,
i
,
row
Cell
InfoOffset
);
pCtx
[
i
].
resultInfo
=
getResultEntryInfo
(
pResult
,
i
,
row
Entry
InfoOffset
);
struct
SResultRowEntryInfo
*
pResInfo
=
pCtx
[
i
].
resultInfo
;
if
(
isRowEntryCompleted
(
pResInfo
)
&&
isRowEntryInitialized
(
pResInfo
))
{
...
...
@@ -1543,7 +1517,7 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, u
SResultRowInfo
*
pResultRowInfo
=
&
pAggInfo
->
binfo
.
resultRowInfo
;
SqlFunctionCtx
*
pCtx
=
pAggInfo
->
binfo
.
pCtx
;
int32_t
*
row
CellInfoOffset
=
pAggInfo
->
binfo
.
rowCell
InfoOffset
;
int32_t
*
row
EntryInfoOffset
=
pAggInfo
->
binfo
.
rowEntry
InfoOffset
;
SResultRow
*
pResultRow
=
doSetResultOutBufByKey
(
pAggInfo
->
aggSup
.
pResultBuf
,
pResultRowInfo
,
(
char
*
)
&
groupId
,
sizeof
(
groupId
),
true
,
groupId
,
pTaskInfo
,
false
,
&
pAggInfo
->
aggSup
);
...
...
@@ -1561,7 +1535,7 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, u
}
}
setResultRowInitCtx
(
pResultRow
,
pCtx
,
numOfOutput
,
row
Cell
InfoOffset
);
setResultRowInitCtx
(
pResultRow
,
pCtx
,
numOfOutput
,
row
Entry
InfoOffset
);
}
void
setExecutionContext
(
int32_t
numOfOutput
,
uint64_t
groupId
,
SExecTaskInfo
*
pTaskInfo
,
SAggOperatorInfo
*
pAggInfo
)
{
...
...
@@ -1725,7 +1699,7 @@ void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SG
int32_t
numOfExprs
=
pOperator
->
numOfExprs
;
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
int32_t
*
rowCellOffset
=
pbInfo
->
row
Cell
InfoOffset
;
int32_t
*
rowCellOffset
=
pbInfo
->
row
Entry
InfoOffset
;
SSDataBlock
*
pBlock
=
pbInfo
->
pRes
;
SqlFunctionCtx
*
pCtx
=
pbInfo
->
pCtx
;
...
...
@@ -1740,7 +1714,7 @@ void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SG
}
static
void
updateNumOfRowsInResultRows
(
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SResultRowInfo
*
pResultRowInfo
,
int32_t
*
row
Cell
InfoOffset
)
{
int32_t
*
row
Entry
InfoOffset
)
{
// update the number of result for each, only update the number of rows for the corresponding window result.
// if (QUERY_IS_INTERVAL_QUERY(pQueryAttr)) {
// return;
...
...
@@ -1755,7 +1729,7 @@ static void updateNumOfRowsInResultRows(SqlFunctionCtx* pCtx, int32_t numOfOutpu
continue;
}
SResultRowEntryInfo* pCell = getResultEntryInfo(pResult, j, row
Cell
InfoOffset);
SResultRowEntryInfo* pCell = getResultEntryInfo(pResult, j, row
Entry
InfoOffset);
pResult->numOfRows = (uint16_t)(TMAX(pResult->numOfRows, pCell->numOfRes));
}
}
...
...
@@ -2909,7 +2883,7 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t
goto
_error
;
}
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
num
,
&
pInfo
->
binfo
.
row
Cell
InfoOffset
);
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
num
,
&
pInfo
->
binfo
.
row
Entry
InfoOffset
);
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
if
(
pInfo
->
binfo
.
pCtx
==
NULL
||
pInfo
->
binfo
.
pRes
==
NULL
)
{
...
...
@@ -3561,7 +3535,7 @@ void cleanupAggSup(SAggSupporter* pAggSup) {
int32_t
initAggInfo
(
SOptrBasicInfo
*
pBasicInfo
,
SAggSupporter
*
pAggSup
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
size_t
keyBufSize
,
const
char
*
pkey
)
{
pBasicInfo
->
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
numOfCols
,
&
pBasicInfo
->
row
Cell
InfoOffset
);
pBasicInfo
->
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
numOfCols
,
&
pBasicInfo
->
row
Entry
InfoOffset
);
pBasicInfo
->
pRes
=
pResultBlock
;
doInitAggInfoSup
(
pAggSup
,
pBasicInfo
->
pCtx
,
numOfCols
,
keyBufSize
,
pkey
);
...
...
@@ -3607,7 +3581,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo*
pInfo
->
pScalarExprInfo
=
pScalarExprInfo
;
pInfo
->
numOfScalarExpr
=
numOfScalarExpr
;
if
(
pInfo
->
pScalarExprInfo
!=
NULL
)
{
pInfo
->
pScalarCtx
=
createSqlFunctionCtx
(
pScalarExprInfo
,
numOfScalarExpr
,
&
pInfo
->
row
Cell
InfoOffset
);
pInfo
->
pScalarCtx
=
createSqlFunctionCtx
(
pScalarExprInfo
,
numOfScalarExpr
,
&
pInfo
->
row
Entry
InfoOffset
);
}
pOperator
->
name
=
"TableAggregate"
;
...
...
@@ -3659,7 +3633,7 @@ void doDestroyBasicInfo(SOptrBasicInfo* pInfo, int32_t numOfOutput) {
assert
(
pInfo
!=
NULL
);
destroySqlFunctionCtx
(
pInfo
->
pCtx
,
numOfOutput
);
taosMemoryFreeClear
(
pInfo
->
row
Cell
InfoOffset
);
taosMemoryFreeClear
(
pInfo
->
row
Entry
InfoOffset
);
cleanupResultRowInfo
(
&
pInfo
->
resultRowInfo
);
pInfo
->
pRes
=
blockDataDestroy
(
pInfo
->
pRes
);
...
...
@@ -3692,17 +3666,20 @@ static void destroyProjectOperatorInfo(void* param, int32_t numOfOutput) {
taosArrayDestroy
(
pInfo
->
pPseudoColInfo
);
}
void
cleanupExecSupp
(
SExecSupp
*
pSupp
)
{
destroySqlFunctionCtx
(
pSupp
->
pCtx
,
pSupp
->
numOfExprs
);
destroyExprInfo
(
pSupp
->
pExprInfo
,
pSupp
->
numOfExprs
);
taosMemoryFree
(
pSupp
->
rowEntryInfoOffset
);
}
static
void
destroyIndefinitOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
SIndefOperatorInfo
*
pInfo
=
(
SIndefOperatorInfo
*
)
param
;
doDestroyBasicInfo
(
&
pInfo
->
binfo
,
numOfOutput
);
taosArrayDestroy
(
pInfo
->
pPseudoColInfo
);
cleanupAggSup
(
&
pInfo
->
aggSup
);
destroySqlFunctionCtx
(
pInfo
->
pScalarCtx
,
numOfOutput
);
destroyExprInfo
(
pInfo
->
pScalarExpr
,
pInfo
->
numOfScalarExpr
);
taosMemoryFree
(
pInfo
->
rowCellInfoOffset
);
cleanupExecSupp
(
&
pInfo
->
scalarSup
);
}
void
destroyExchangeOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
...
...
@@ -3829,9 +3806,10 @@ static SSDataBlock* doApplyIndefinitFunction(SOperatorInfo* pOperator) {
}
// there is an scalar expression that needs to be calculated before apply the group aggregation.
if
(
pIndefInfo
->
pScalarExpr
!=
NULL
)
{
code
=
projectApplyFunctions
(
pIndefInfo
->
pScalarExpr
,
pBlock
,
pBlock
,
pIndefInfo
->
pScalarCtx
,
pIndefInfo
->
numOfScalarExpr
,
pIndefInfo
->
pPseudoColInfo
);
SExecSupp
*
pScalarSup
=
&
pIndefInfo
->
scalarSup
;
if
(
pScalarSup
->
pExprInfo
!=
NULL
)
{
code
=
projectApplyFunctions
(
pScalarSup
->
pExprInfo
,
pBlock
,
pBlock
,
pScalarSup
->
pCtx
,
pScalarSup
->
numOfExprs
,
pIndefInfo
->
pPseudoColInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
...
...
@@ -3872,8 +3850,9 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
int32_t
numOfScalarExpr
=
0
;
if
(
pPhyNode
->
pExprs
!=
NULL
)
{
pInfo
->
pScalarExpr
=
createExprInfo
(
pPhyNode
->
pExprs
,
NULL
,
&
numOfScalarExpr
);
pInfo
->
pScalarCtx
=
createSqlFunctionCtx
(
pInfo
->
pScalarExpr
,
numOfScalarExpr
,
&
pInfo
->
rowCellInfoOffset
);
SExecSupp
*
pSup
=
&
pInfo
->
scalarSup
;
pSup
->
pExprInfo
=
createExprInfo
(
pPhyNode
->
pExprs
,
NULL
,
&
pSup
->
numOfExprs
);
pSup
->
pCtx
=
createSqlFunctionCtx
(
pSup
->
pExprInfo
,
numOfScalarExpr
,
&
pSup
->
rowEntryInfoOffset
);
}
SSDataBlock
*
pResBlock
=
createResDataBlock
(
pPhyNode
->
node
.
pOutputDataBlockDesc
);
...
...
@@ -3893,7 +3872,6 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
setFunctionResultOutput
(
&
pInfo
->
binfo
,
&
pInfo
->
aggSup
,
MAIN_SCAN
,
numOfExpr
,
pTaskInfo
);
pInfo
->
binfo
.
pRes
=
pResBlock
;
pInfo
->
numOfScalarExpr
=
numOfScalarExpr
;
pInfo
->
pPseudoColInfo
=
setRowTsColumnOutputInfo
(
pInfo
->
binfo
.
pCtx
,
numOfExpr
);
pOperator
->
name
=
"IndefinitOperator"
;
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
820d6d13
...
...
@@ -37,6 +37,7 @@ static void destroyGroupOperatorInfo(void* param, int32_t numOfOutput) {
taosMemoryFreeClear
(
pInfo
->
keyBuf
);
taosArrayDestroy
(
pInfo
->
pGroupCols
);
taosArrayDestroy
(
pInfo
->
pGroupColVals
);
cleanupExecSupp
(
&
pInfo
->
scalarSup
);
}
static
int32_t
initGroupOptrInfo
(
SArray
**
pGroupColVals
,
int32_t
*
keyLen
,
char
**
keyBuf
,
const
SArray
*
pGroupColList
)
{
...
...
@@ -322,8 +323,8 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
setInputDataBlock
(
pOperator
,
pInfo
->
binfo
.
pCtx
,
pBlock
,
order
,
scanFlag
,
true
);
// there is an scalar expression that needs to be calculated right before apply the group aggregation.
if
(
pInfo
->
scalarSup
.
p
Scalar
ExprInfo
!=
NULL
)
{
pTaskInfo
->
code
=
projectApplyFunctions
(
pInfo
->
scalarSup
.
p
ScalarExprInfo
,
pBlock
,
pBlock
,
pInfo
->
scalarSup
.
pScalarFuncCtx
,
pInfo
->
scalarSup
.
numOfScalarExpr
,
NULL
);
if
(
pInfo
->
scalarSup
.
pExprInfo
!=
NULL
)
{
pTaskInfo
->
code
=
projectApplyFunctions
(
pInfo
->
scalarSup
.
p
ExprInfo
,
pBlock
,
pBlock
,
pInfo
->
scalarSup
.
pCtx
,
pInfo
->
scalarSup
.
numOfExprs
,
NULL
);
if
(
pTaskInfo
->
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
pTaskInfo
->
code
);
}
...
...
@@ -386,9 +387,9 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
pInfo
->
pGroupCols
=
pGroupColList
;
pInfo
->
pCondition
=
pCondition
;
pInfo
->
scalarSup
.
p
Scalar
ExprInfo
=
pScalarExprInfo
;
pInfo
->
scalarSup
.
numOf
ScalarExpr
=
numOfScalarExpr
;
pInfo
->
scalarSup
.
p
ScalarFuncCtx
=
createSqlFunctionCtx
(
pScalarExprInfo
,
numOfScalarExpr
,
&
pInfo
->
scalarSup
.
rowCell
InfoOffset
);
pInfo
->
scalarSup
.
pExprInfo
=
pScalarExprInfo
;
pInfo
->
scalarSup
.
numOf
Exprs
=
numOfScalarExpr
;
pInfo
->
scalarSup
.
p
Ctx
=
createSqlFunctionCtx
(
pScalarExprInfo
,
numOfScalarExpr
,
&
pInfo
->
scalarSup
.
rowEntry
InfoOffset
);
int32_t
code
=
initGroupOptrInfo
(
&
pInfo
->
pGroupColVals
,
&
pInfo
->
groupKeyLen
,
&
pInfo
->
keyBuf
,
pGroupColList
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -645,8 +646,8 @@ static SSDataBlock* hashPartition(SOperatorInfo* pOperator) {
}
// there is an scalar expression that needs to be calculated right before apply the group aggregation.
if
(
pInfo
->
scalarSup
p
.
pScalar
ExprInfo
!=
NULL
)
{
pTaskInfo
->
code
=
projectApplyFunctions
(
pInfo
->
scalarSup
p
.
pScalarExprInfo
,
pBlock
,
pBlock
,
pInfo
->
scalarSupp
.
pScalarFuncCtx
,
pInfo
->
scalarSupp
.
numOfScalarExpr
,
NULL
);
if
(
pInfo
->
scalarSup
.
p
ExprInfo
!=
NULL
)
{
pTaskInfo
->
code
=
projectApplyFunctions
(
pInfo
->
scalarSup
.
pExprInfo
,
pBlock
,
pBlock
,
pInfo
->
scalarSup
.
pCtx
,
pInfo
->
scalarSup
.
numOfExprs
,
NULL
);
if
(
pTaskInfo
->
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
pTaskInfo
->
code
);
}
...
...
@@ -666,14 +667,18 @@ static void destroyPartitionOperatorInfo(void* param, int32_t numOfOutput) {
SPartitionOperatorInfo
*
pInfo
=
(
SPartitionOperatorInfo
*
)
param
;
doDestroyBasicInfo
(
&
pInfo
->
binfo
,
numOfOutput
);
taosArrayDestroy
(
pInfo
->
pGroupCols
);
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pInfo
->
pGroupColVals
);
i
++
){
SGroupKeys
key
=
*
(
SGroupKeys
*
)
taosArrayGet
(
pInfo
->
pGroupColVals
,
i
);
taosMemoryFree
(
key
.
pData
);
}
taosArrayDestroy
(
pInfo
->
pGroupColVals
);
taosMemoryFree
(
pInfo
->
keyBuf
);
taosHashCleanup
(
pInfo
->
pGroupSet
);
taosMemoryFree
(
pInfo
->
columnOffset
);
cleanupExecSupp
(
&
pInfo
->
scalarSup
);
}
SOperatorInfo
*
createPartitionOperatorInfo
(
SOperatorInfo
*
downstream
,
SPartitionPhysiNode
*
pPartNode
,
SExecTaskInfo
*
pTaskInfo
)
{
...
...
@@ -691,10 +696,10 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
pInfo
->
pGroupCols
=
extractPartitionColInfo
(
pPartNode
->
pPartitionKeys
);
if
(
pPartNode
->
pExprs
!=
NULL
)
{
pInfo
->
scalarSup
p
.
numOfScalarExpr
=
0
;
pInfo
->
scalarSup
p
.
pScalarExprInfo
=
createExprInfo
(
pPartNode
->
pExprs
,
NULL
,
&
pInfo
->
scalarSupp
.
numOfScalarExpr
);
pInfo
->
scalarSup
p
.
pScalarFunc
Ctx
=
createSqlFunctionCtx
(
pInfo
->
scalarSup
p
.
pScalarExprInfo
,
pInfo
->
scalarSupp
.
numOfScalarExpr
,
&
pInfo
->
scalarSupp
.
rowCell
InfoOffset
);
pInfo
->
scalarSup
.
numOfExprs
=
0
;
pInfo
->
scalarSup
.
pExprInfo
=
createExprInfo
(
pPartNode
->
pExprs
,
NULL
,
&
pInfo
->
scalarSup
.
numOfExprs
);
pInfo
->
scalarSup
.
p
Ctx
=
createSqlFunctionCtx
(
pInfo
->
scalarSup
.
pExprInfo
,
pInfo
->
scalarSup
.
numOfExprs
,
&
pInfo
->
scalarSup
.
rowEntry
InfoOffset
);
}
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
...
...
@@ -752,6 +757,6 @@ int32_t setGroupResultOutputBuf(SOptrBasicInfo* binfo, int32_t numOfCols, char*
doSetResultOutBufByKey
(
pBuf
,
pResultRowInfo
,
(
char
*
)
pData
,
bytes
,
true
,
groupId
,
pTaskInfo
,
false
,
pAggSup
);
assert
(
pResultRow
!=
NULL
);
setResultRowInitCtx
(
pResultRow
,
pCtx
,
numOfCols
,
binfo
->
row
Cell
InfoOffset
);
setResultRowInitCtx
(
pResultRow
,
pCtx
,
numOfCols
,
binfo
->
row
Entry
InfoOffset
);
return
TSDB_CODE_SUCCESS
;
}
\ No newline at end of file
source/libs/executor/src/scanoperator.c
浏览文件 @
820d6d13
...
...
@@ -261,9 +261,9 @@ static int32_t loadDataBlock(SOperatorInfo* pOperator, STableScanInfo* pTableSca
relocateColumnData
(
pBlock
,
pTableScanInfo
->
pColMatchInfo
,
pCols
);
// currently only the tbname pseudo column
if
(
pTableScanInfo
->
numOfPseudoExpr
>
0
)
{
addTagPseudoColumnData
(
&
pTableScanInfo
->
readHandle
,
pTableScanInfo
->
pPseudoExpr
,
pTableScanInfo
->
numOfPseudoExpr
,
pBlock
);
if
(
pTableScanInfo
->
pseudoSup
.
numOfExprs
>
0
)
{
SExecSupp
*
pSup
=
&
pTableScanInfo
->
pseudoSup
;
addTagPseudoColumnData
(
&
pTableScanInfo
->
readHandle
,
pSup
->
pExprInfo
,
pSup
->
numOfExprs
,
pBlock
);
}
int64_t
st
=
taosGetTimestampMs
();
...
...
@@ -538,8 +538,9 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
}
if
(
pTableScanNode
->
scan
.
pScanPseudoCols
!=
NULL
)
{
pInfo
->
pPseudoExpr
=
createExprInfo
(
pTableScanNode
->
scan
.
pScanPseudoCols
,
NULL
,
&
pInfo
->
numOfPseudoExpr
);
pInfo
->
pPseudoCtx
=
createSqlFunctionCtx
(
pInfo
->
pPseudoExpr
,
pInfo
->
numOfPseudoExpr
,
&
pInfo
->
rowCellInfoOffset
);
SExecSupp
*
pSup
=
&
pInfo
->
pseudoSup
;
pSup
->
pExprInfo
=
createExprInfo
(
pTableScanNode
->
scan
.
pScanPseudoCols
,
NULL
,
&
pSup
->
numOfExprs
);
pSup
->
pCtx
=
createSqlFunctionCtx
(
pSup
->
pExprInfo
,
pSup
->
numOfExprs
,
&
pSup
->
rowEntryInfoOffset
);
}
pInfo
->
scanInfo
=
(
SScanInfo
){.
numOfAsc
=
pTableScanNode
->
scanSeq
[
0
],
.
numOfDesc
=
pTableScanNode
->
scanSeq
[
1
]};
...
...
@@ -1869,7 +1870,7 @@ typedef struct STableMergeScanInfo {
SNode
*
pFilterNode
;
// filter info, which is push down by optimizer
SqlFunctionCtx
*
pCtx
;
// which belongs to the direct upstream operator operator query context
SResultRowInfo
*
pResultRowInfo
;
int32_t
*
row
Cell
InfoOffset
;
int32_t
*
row
Entry
InfoOffset
;
SExprInfo
*
pExpr
;
SSDataBlock
*
pResBlock
;
SArray
*
pColMatchInfo
;
...
...
@@ -1878,7 +1879,7 @@ typedef struct STableMergeScanInfo {
SExprInfo
*
pPseudoExpr
;
int32_t
numOfPseudoExpr
;
SqlFunctionCtx
*
pPseudoCtx
;
// int32_t* row
Cell
InfoOffset;
// int32_t* row
Entry
InfoOffset;
SQueryTableDataCond
cond
;
int32_t
scanFlag
;
// table scan flag to denote if it is a repeat/reverse/main scan
...
...
@@ -2257,7 +2258,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
if
(
pTableScanNode
->
scan
.
pScanPseudoCols
!=
NULL
)
{
pInfo
->
pPseudoExpr
=
createExprInfo
(
pTableScanNode
->
scan
.
pScanPseudoCols
,
NULL
,
&
pInfo
->
numOfPseudoExpr
);
pInfo
->
pPseudoCtx
=
createSqlFunctionCtx
(
pInfo
->
pPseudoExpr
,
pInfo
->
numOfPseudoExpr
,
&
pInfo
->
row
Cell
InfoOffset
);
pInfo
->
pPseudoCtx
=
createSqlFunctionCtx
(
pInfo
->
pPseudoExpr
,
pInfo
->
numOfPseudoExpr
,
&
pInfo
->
row
Entry
InfoOffset
);
}
pInfo
->
scanInfo
=
(
SScanInfo
){.
numOfAsc
=
pTableScanNode
->
scanSeq
[
0
],
.
numOfDesc
=
pTableScanNode
->
scanSeq
[
1
]};
...
...
source/libs/executor/src/sortoperator.c
浏览文件 @
820d6d13
...
...
@@ -39,7 +39,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode*
SArray
*
pColMatchColInfo
=
extractColMatchInfo
(
pSortPhyNode
->
pTargets
,
pDescNode
,
&
numOfOutputCols
,
COL_MATCH_FROM_SLOT_ID
);
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
numOfCols
,
&
pInfo
->
binfo
.
row
Cell
InfoOffset
);
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
numOfCols
,
&
pInfo
->
binfo
.
row
Entry
InfoOffset
);
pInfo
->
binfo
.
pRes
=
pResBlock
;
initResultSizeInfo
(
pOperator
,
1024
);
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
820d6d13
...
...
@@ -103,7 +103,7 @@ STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowI
static
int32_t
setTimeWindowOutputBuf
(
SResultRowInfo
*
pResultRowInfo
,
STimeWindow
*
win
,
bool
masterscan
,
SResultRow
**
pResult
,
int64_t
tableGroupId
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
int32_t
*
row
Cell
InfoOffset
,
SAggSupporter
*
pAggSup
,
int32_t
numOfOutput
,
int32_t
*
row
Entry
InfoOffset
,
SAggSupporter
*
pAggSup
,
SExecTaskInfo
*
pTaskInfo
)
{
assert
(
win
->
skey
<=
win
->
ekey
);
SResultRow
*
pResultRow
=
doSetResultOutBufByKey
(
pAggSup
->
pResultBuf
,
pResultRowInfo
,
(
char
*
)
&
win
->
skey
,
TSDB_KEYSIZE
,
...
...
@@ -118,7 +118,7 @@ static int32_t setTimeWindowOutputBuf(SResultRowInfo* pResultRowInfo, STimeWindo
pResultRow
->
win
=
(
*
win
);
*
pResult
=
pResultRow
;
setResultRowInitCtx
(
pResultRow
,
pCtx
,
numOfOutput
,
row
Cell
InfoOffset
);
setResultRowInitCtx
(
pResultRow
,
pCtx
,
numOfOutput
,
row
Entry
InfoOffset
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -656,7 +656,7 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
STimeWindow
w
=
pr
->
win
;
int32_t
ret
=
setTimeWindowOutputBuf
(
pResultRowInfo
,
&
w
,
(
scanFlag
==
MAIN_SCAN
),
&
pResult
,
groupId
,
pInfo
->
binfo
.
pCtx
,
numOfOutput
,
pInfo
->
binfo
.
row
Cell
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
numOfOutput
,
pInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
...
...
@@ -812,7 +812,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
int32_t
ret
=
setTimeWindowOutputBuf
(
pResultRowInfo
,
&
win
,
(
scanFlag
==
MAIN_SCAN
),
&
pResult
,
tableGroupId
,
pInfo
->
binfo
.
pCtx
,
numOfOutput
,
pInfo
->
binfo
.
row
Cell
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
numOfOutput
,
pInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
||
pResult
==
NULL
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
...
...
@@ -836,7 +836,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
// restore current time window
ret
=
setTimeWindowOutputBuf
(
pResultRowInfo
,
&
win
,
(
scanFlag
==
MAIN_SCAN
),
&
pResult
,
tableGroupId
,
pInfo
->
binfo
.
pCtx
,
numOfOutput
,
pInfo
->
binfo
.
row
Cell
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
numOfOutput
,
pInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
...
...
@@ -861,7 +861,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
// null data, failed to allocate more memory buffer
int32_t
code
=
setTimeWindowOutputBuf
(
pResultRowInfo
,
&
nextWin
,
(
scanFlag
==
MAIN_SCAN
),
&
pResult
,
tableGroupId
,
pInfo
->
binfo
.
pCtx
,
numOfOutput
,
pInfo
->
binfo
.
row
Cell
InfoOffset
,
pInfo
->
binfo
.
pCtx
,
numOfOutput
,
pInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
||
pResult
==
NULL
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
...
...
@@ -1042,7 +1042,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
pRowSup
->
win
.
ekey
=
pRowSup
->
win
.
skey
;
int32_t
ret
=
setTimeWindowOutputBuf
(
&
pInfo
->
binfo
.
resultRowInfo
,
&
window
,
masterScan
,
&
pResult
,
gid
,
pInfo
->
binfo
.
pCtx
,
numOfOutput
,
pInfo
->
binfo
.
row
Cell
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
numOfOutput
,
pInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
}
...
...
@@ -1068,7 +1068,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
pRowSup
->
win
.
ekey
=
tsList
[
pBlock
->
info
.
rows
-
1
];
int32_t
ret
=
setTimeWindowOutputBuf
(
&
pInfo
->
binfo
.
resultRowInfo
,
&
pRowSup
->
win
,
masterScan
,
&
pResult
,
gid
,
pInfo
->
binfo
.
pCtx
,
numOfOutput
,
pInfo
->
binfo
.
row
Cell
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
numOfOutput
,
pInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
}
...
...
@@ -1166,7 +1166,7 @@ static SSDataBlock* doBuildIntervalResult(SOperatorInfo* pOperator) {
// todo merged with the build group result.
static
void
finalizeUpdatedResult
(
int32_t
numOfOutput
,
SDiskbasedBuf
*
pBuf
,
SArray
*
pUpdateList
,
int32_t
*
row
Cell
InfoOffset
)
{
int32_t
*
row
Entry
InfoOffset
)
{
size_t
num
=
taosArrayGetSize
(
pUpdateList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
...
...
@@ -1176,7 +1176,7 @@ static void finalizeUpdatedResult(int32_t numOfOutput, SDiskbasedBuf* pBuf, SArr
SResultRow
*
pRow
=
(
SResultRow
*
)((
char
*
)
bufPage
+
pPos
->
pos
.
offset
);
for
(
int32_t
j
=
0
;
j
<
numOfOutput
;
++
j
)
{
SResultRowEntryInfo
*
pEntry
=
getResultEntryInfo
(
pRow
,
j
,
row
Cell
InfoOffset
);
SResultRowEntryInfo
*
pEntry
=
getResultEntryInfo
(
pRow
,
j
,
row
Entry
InfoOffset
);
if
(
pRow
->
numOfRows
<
pEntry
->
numOfRes
)
{
pRow
->
numOfRows
=
pEntry
->
numOfRes
;
}
...
...
@@ -1199,7 +1199,7 @@ void doClearWindowImpl(SResultRowPosition* p1, SDiskbasedBuf* pResultBuf, SOptrB
SResultRow
*
pResult
=
getResultRowByPos
(
pResultBuf
,
p1
);
SqlFunctionCtx
*
pCtx
=
pBinfo
->
pCtx
;
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
pCtx
[
i
].
resultInfo
=
getResultEntryInfo
(
pResult
,
i
,
pBinfo
->
row
Cell
InfoOffset
);
pCtx
[
i
].
resultInfo
=
getResultEntryInfo
(
pResult
,
i
,
pBinfo
->
row
Entry
InfoOffset
);
struct
SResultRowEntryInfo
*
pResInfo
=
pCtx
[
i
].
resultInfo
;
if
(
fmIsWindowPseudoColumnFunc
(
pCtx
[
i
].
functionId
))
{
continue
;
...
...
@@ -1338,7 +1338,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
}
closeIntervalWindow
(
pInfo
->
aggSup
.
pResultRowHashTable
,
&
pInfo
->
twAggSup
,
&
pInfo
->
interval
,
pUpdated
);
finalizeUpdatedResult
(
pOperator
->
numOfExprs
,
pInfo
->
aggSup
.
pResultBuf
,
pUpdated
,
pInfo
->
binfo
.
row
Cell
InfoOffset
);
finalizeUpdatedResult
(
pOperator
->
numOfExprs
,
pInfo
->
aggSup
.
pResultBuf
,
pUpdated
,
pInfo
->
binfo
.
row
Entry
InfoOffset
);
initMultiResInfoFromArrayList
(
&
pInfo
->
groupResInfo
,
pUpdated
);
blockDataEnsureCapacity
(
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
);
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
...
...
@@ -1603,7 +1603,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator
pRowSup
->
win
.
ekey
=
pRowSup
->
win
.
skey
;
int32_t
ret
=
setTimeWindowOutputBuf
(
&
pInfo
->
binfo
.
resultRowInfo
,
&
window
,
masterScan
,
&
pResult
,
gid
,
pInfo
->
binfo
.
pCtx
,
numOfOutput
,
pInfo
->
binfo
.
row
Cell
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
numOfOutput
,
pInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
}
...
...
@@ -1623,7 +1623,7 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator
pRowSup
->
win
.
ekey
=
tsList
[
pBlock
->
info
.
rows
-
1
];
int32_t
ret
=
setTimeWindowOutputBuf
(
&
pInfo
->
binfo
.
resultRowInfo
,
&
pRowSup
->
win
,
masterScan
,
&
pResult
,
gid
,
pInfo
->
binfo
.
pCtx
,
numOfOutput
,
pInfo
->
binfo
.
row
Cell
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
numOfOutput
,
pInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
}
...
...
@@ -2068,14 +2068,14 @@ static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SArra
STimeWindow
*
pParentWin
=
taosArrayGet
(
pWinArray
,
i
);
SResultRow
*
pCurResult
=
NULL
;
setTimeWindowOutputBuf
(
&
pInfo
->
binfo
.
resultRowInfo
,
pParentWin
,
true
,
&
pCurResult
,
0
,
pInfo
->
binfo
.
pCtx
,
numOfOutput
,
pInfo
->
binfo
.
row
Cell
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
numOfOutput
,
pInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
int32_t
numOfChildren
=
taosArrayGetSize
(
pInfo
->
pChildren
);
for
(
int32_t
j
=
0
;
j
<
numOfChildren
;
j
++
)
{
SOperatorInfo
*
pChildOp
=
taosArrayGetP
(
pInfo
->
pChildren
,
j
);
SIntervalAggOperatorInfo
*
pChInfo
=
pChildOp
->
info
;
SResultRow
*
pChResult
=
NULL
;
setTimeWindowOutputBuf
(
&
pChInfo
->
binfo
.
resultRowInfo
,
pParentWin
,
true
,
&
pChResult
,
0
,
pChInfo
->
binfo
.
pCtx
,
pChildOp
->
numOfExprs
,
pChInfo
->
binfo
.
row
Cell
InfoOffset
,
&
pChInfo
->
aggSup
,
pTaskInfo
);
pChildOp
->
numOfExprs
,
pChInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pChInfo
->
aggSup
,
pTaskInfo
);
compactFunctions
(
pInfo
->
binfo
.
pCtx
,
pChInfo
->
binfo
.
pCtx
,
numOfOutput
,
pTaskInfo
);
}
}
...
...
@@ -2121,7 +2121,7 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc
taosArrayDestroy
(
pUpWins
);
}
int32_t
code
=
setTimeWindowOutputBuf
(
pResultRowInfo
,
&
nextWin
,
true
,
&
pResult
,
tableGroupId
,
pInfo
->
binfo
.
pCtx
,
numOfOutput
,
pInfo
->
binfo
.
row
Cell
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
numOfOutput
,
pInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pInfo
->
aggSup
,
pTaskInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
||
pResult
==
NULL
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
...
...
@@ -2267,7 +2267,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
closeIntervalWindow
(
pInfo
->
aggSup
.
pResultRowHashTable
,
&
pInfo
->
twAggSup
,
&
pInfo
->
interval
,
pUpdated
);
}
finalizeUpdatedResult
(
pOperator
->
numOfExprs
,
pInfo
->
aggSup
.
pResultBuf
,
pUpdated
,
pInfo
->
binfo
.
row
Cell
InfoOffset
);
finalizeUpdatedResult
(
pOperator
->
numOfExprs
,
pInfo
->
aggSup
.
pResultBuf
,
pUpdated
,
pInfo
->
binfo
.
row
Entry
InfoOffset
);
initMultiResInfoFromArrayList
(
&
pInfo
->
groupResInfo
,
pUpdated
);
blockDataEnsureCapacity
(
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
);
doBuildResultDatablock
(
pOperator
,
&
pInfo
->
binfo
,
&
pInfo
->
groupResInfo
,
pInfo
->
aggSup
.
pResultBuf
);
...
...
@@ -2398,7 +2398,7 @@ void destroyStreamSessionAggOperatorInfo(void* param, int32_t numOfOutput) {
}
int32_t
initBiasicInfo
(
SOptrBasicInfo
*
pBasicInfo
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
)
{
pBasicInfo
->
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
numOfCols
,
&
pBasicInfo
->
row
Cell
InfoOffset
);
pBasicInfo
->
pCtx
=
createSqlFunctionCtx
(
pExprInfo
,
numOfCols
,
&
pBasicInfo
->
row
Entry
InfoOffset
);
pBasicInfo
->
pRes
=
pResultBlock
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
pBasicInfo
->
pCtx
[
i
].
pBuf
=
NULL
;
...
...
@@ -2592,7 +2592,7 @@ int32_t updateSessionWindowInfo(SResultWindowInfo* pWinInfo, TSKEY* pTs, int32_t
}
static
int32_t
setWindowOutputBuf
(
SResultWindowInfo
*
pWinInfo
,
SResultRow
**
pResult
,
SqlFunctionCtx
*
pCtx
,
uint64_t
groupId
,
int32_t
numOfOutput
,
int32_t
*
row
Cell
InfoOffset
,
uint64_t
groupId
,
int32_t
numOfOutput
,
int32_t
*
row
Entry
InfoOffset
,
SStreamAggSupporter
*
pAggSup
,
SExecTaskInfo
*
pTaskInfo
)
{
assert
(
pWinInfo
->
win
.
skey
<=
pWinInfo
->
win
.
ekey
);
// too many time window in query
...
...
@@ -2621,7 +2621,7 @@ static int32_t setWindowOutputBuf(SResultWindowInfo* pWinInfo, SResultRow** pRes
// set time window for current result
(
*
pResult
)
->
win
=
pWinInfo
->
win
;
setResultRowInitCtx
(
*
pResult
,
pCtx
,
numOfOutput
,
row
Cell
InfoOffset
);
setResultRowInitCtx
(
*
pResult
,
pCtx
,
numOfOutput
,
row
Entry
InfoOffset
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -2632,7 +2632,7 @@ static int32_t doOneWindowAggImpl(int32_t tsColId, SOptrBasicInfo* pBinfo, SStre
SColumnInfoData
*
pColDataInfo
=
taosArrayGet
(
pSDataBlock
->
pDataBlock
,
tsColId
);
TSKEY
*
tsCols
=
(
int64_t
*
)
pColDataInfo
->
pData
;
int32_t
code
=
setWindowOutputBuf
(
pCurWin
,
pResult
,
pBinfo
->
pCtx
,
pSDataBlock
->
info
.
groupId
,
numOutput
,
pBinfo
->
row
Cell
InfoOffset
,
pAggSup
,
pTaskInfo
);
pBinfo
->
row
Entry
InfoOffset
,
pAggSup
,
pTaskInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
||
(
*
pResult
)
==
NULL
)
{
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
...
...
@@ -2674,7 +2674,7 @@ void compactTimeWindow(SStreamSessionAggOperatorInfo* pInfo, int32_t startIndex,
int32_t
numOfOutput
,
SExecTaskInfo
*
pTaskInfo
,
SHashObj
*
pStUpdated
,
SHashObj
*
pStDeleted
)
{
SResultWindowInfo
*
pCurWin
=
taosArrayGet
(
pInfo
->
streamAggSup
.
pCurWins
,
startIndex
);
SResultRow
*
pCurResult
=
NULL
;
setWindowOutputBuf
(
pCurWin
,
&
pCurResult
,
pInfo
->
binfo
.
pCtx
,
groupId
,
numOfOutput
,
pInfo
->
binfo
.
row
Cell
InfoOffset
,
setWindowOutputBuf
(
pCurWin
,
&
pCurResult
,
pInfo
->
binfo
.
pCtx
,
groupId
,
numOfOutput
,
pInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pInfo
->
streamAggSup
,
pTaskInfo
);
num
+=
startIndex
+
1
;
ASSERT
(
num
<=
taosArrayGetSize
(
pInfo
->
streamAggSup
.
pCurWins
));
...
...
@@ -2682,7 +2682,7 @@ void compactTimeWindow(SStreamSessionAggOperatorInfo* pInfo, int32_t startIndex,
for
(
int32_t
i
=
startIndex
+
1
;
i
<
num
;
i
++
)
{
SResultWindowInfo
*
pWinInfo
=
taosArrayGet
(
pInfo
->
streamAggSup
.
pCurWins
,
i
);
SResultRow
*
pWinResult
=
NULL
;
setWindowOutputBuf
(
pWinInfo
,
&
pWinResult
,
pInfo
->
pDummyCtx
,
groupId
,
numOfOutput
,
pInfo
->
binfo
.
row
Cell
InfoOffset
,
setWindowOutputBuf
(
pWinInfo
,
&
pWinResult
,
pInfo
->
pDummyCtx
,
groupId
,
numOfOutput
,
pInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pInfo
->
streamAggSup
,
pTaskInfo
);
pCurWin
->
win
.
ekey
=
TMAX
(
pCurWin
->
win
.
ekey
,
pWinInfo
->
win
.
ekey
);
compactFunctions
(
pInfo
->
binfo
.
pCtx
,
pInfo
->
pDummyCtx
,
numOfOutput
,
pTaskInfo
);
...
...
@@ -2815,7 +2815,7 @@ static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWin
for
(
int32_t
i
=
0
;
i
<
size
;
i
++
)
{
SResultWindowInfo
*
pParentWin
=
taosArrayGet
(
pWinArray
,
i
);
SResultRow
*
pCurResult
=
NULL
;
setWindowOutputBuf
(
pParentWin
,
&
pCurResult
,
pInfo
->
binfo
.
pCtx
,
groupId
,
numOfOutput
,
pInfo
->
binfo
.
row
Cell
InfoOffset
,
setWindowOutputBuf
(
pParentWin
,
&
pCurResult
,
pInfo
->
binfo
.
pCtx
,
groupId
,
numOfOutput
,
pInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pInfo
->
streamAggSup
,
pTaskInfo
);
int32_t
numOfChildren
=
taosArrayGetSize
(
pInfo
->
pChildren
);
for
(
int32_t
j
=
0
;
j
<
numOfChildren
;
j
++
)
{
...
...
@@ -2829,7 +2829,7 @@ static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWin
if
(
pParentWin
->
win
.
skey
<=
pcw
->
win
.
skey
&&
pcw
->
win
.
ekey
<=
pParentWin
->
win
.
ekey
)
{
SResultRow
*
pChResult
=
NULL
;
setWindowOutputBuf
(
pcw
,
&
pChResult
,
pChInfo
->
binfo
.
pCtx
,
groupId
,
numOfOutput
,
pChInfo
->
binfo
.
row
Cell
InfoOffset
,
&
pChInfo
->
streamAggSup
,
pTaskInfo
);
pChInfo
->
binfo
.
row
Entry
InfoOffset
,
&
pChInfo
->
streamAggSup
,
pTaskInfo
);
compactFunctions
(
pInfo
->
binfo
.
pCtx
,
pChInfo
->
binfo
.
pCtx
,
numOfOutput
,
pTaskInfo
);
continue
;
}
...
...
@@ -2956,7 +2956,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
taosHashCleanup
(
pStUpdated
);
finalizeUpdatedResult
(
pOperator
->
numOfExprs
,
pInfo
->
streamAggSup
.
pResultBuf
,
pUpdated
,
pInfo
->
binfo
.
row
Cell
InfoOffset
);
pInfo
->
binfo
.
row
Entry
InfoOffset
);
initMultiResInfoFromArrayList
(
&
pInfo
->
groupResInfo
,
pUpdated
);
blockDataEnsureCapacity
(
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
);
doBuildDeleteDataBlock
(
pInfo
->
pStDeleted
,
pInfo
->
pDelRes
,
&
pInfo
->
pDelIterator
);
...
...
@@ -3310,7 +3310,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
taosHashCleanup
(
pSeUpdated
);
finalizeUpdatedResult
(
pOperator
->
numOfExprs
,
pInfo
->
streamAggSup
.
pResultBuf
,
pUpdated
,
pInfo
->
binfo
.
row
Cell
InfoOffset
);
pInfo
->
binfo
.
row
Entry
InfoOffset
);
initMultiResInfoFromArrayList
(
&
pInfo
->
groupResInfo
,
pUpdated
);
blockDataEnsureCapacity
(
pInfo
->
binfo
.
pRes
,
pOperator
->
resultInfo
.
capacity
);
doBuildDeleteDataBlock
(
pInfo
->
pSeDeleted
,
pInfo
->
pDelRes
,
&
pInfo
->
pDelIterator
);
...
...
@@ -3428,7 +3428,7 @@ static int32_t outputMergeIntervalResult(SOperatorInfo* pOperatorInfo, uint64_t
ASSERT
(
p1
!=
NULL
);
finalizeResultRowIntoResultDataBlock
(
iaInfo
->
aggSup
.
pResultBuf
,
p1
,
iaInfo
->
binfo
.
pCtx
,
pOperatorInfo
->
pExpr
,
pOperatorInfo
->
numOfExprs
,
iaInfo
->
binfo
.
row
Cell
InfoOffset
,
pResultBlock
,
pOperatorInfo
->
numOfExprs
,
iaInfo
->
binfo
.
row
Entry
InfoOffset
,
pResultBlock
,
pTaskInfo
);
taosHashRemove
(
iaInfo
->
aggSup
.
pResultRowHashTable
,
iaInfo
->
aggSup
.
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
TSDB_KEYSIZE
));
...
...
@@ -3456,7 +3456,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
//TODO: remove the hash table usage (groupid + winkey => result row position)
int32_t
ret
=
setTimeWindowOutputBuf
(
pResultRowInfo
,
&
win
,
(
scanFlag
==
MAIN_SCAN
),
&
pResult
,
tableGroupId
,
iaInfo
->
binfo
.
pCtx
,
numOfOutput
,
iaInfo
->
binfo
.
row
Cell
InfoOffset
,
&
iaInfo
->
aggSup
,
pTaskInfo
);
numOfOutput
,
iaInfo
->
binfo
.
row
Entry
InfoOffset
,
&
iaInfo
->
aggSup
,
pTaskInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
||
pResult
==
NULL
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
...
...
@@ -3483,7 +3483,7 @@ static void doMergeIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo*
currWin
.
ekey
=
taosTimeAdd
(
currWin
.
skey
,
iaInfo
->
interval
.
interval
,
iaInfo
->
interval
.
intervalUnit
,
iaInfo
->
interval
.
precision
)
-
1
;
startPos
=
currPos
;
ret
=
setTimeWindowOutputBuf
(
pResultRowInfo
,
&
currWin
,
(
scanFlag
==
MAIN_SCAN
),
&
pResult
,
tableGroupId
,
iaInfo
->
binfo
.
pCtx
,
numOfOutput
,
iaInfo
->
binfo
.
row
Cell
InfoOffset
,
&
iaInfo
->
aggSup
,
pTaskInfo
);
numOfOutput
,
iaInfo
->
binfo
.
row
Entry
InfoOffset
,
&
iaInfo
->
aggSup
,
pTaskInfo
);
if
(
ret
!=
TSDB_CODE_SUCCESS
||
pResult
==
NULL
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录