Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
25e9d94f
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看板
未验证
提交
25e9d94f
编写于
12月 29, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
12月 29, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19244 from taosdata/feature/stream_main
enh: put func state into tdb
上级
4da5957d
b2f6fcd0
变更
10
显示空白变更内容
内联
并排
Showing
10 changed file
with
192 addition
and
159 deletion
+192
-159
include/libs/function/function.h
include/libs/function/function.h
+5
-4
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+19
-14
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+2
-1
source/libs/executor/src/projectoperator.c
source/libs/executor/src/projectoperator.c
+5
-3
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+64
-54
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+2
-2
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+74
-61
source/libs/function/src/detail/tminmax.c
source/libs/function/src/detail/tminmax.c
+19
-18
source/libs/stream/src/streamState.c
source/libs/stream/src/streamState.c
+1
-1
未找到文件。
include/libs/function/function.h
浏览文件 @
25e9d94f
...
...
@@ -152,6 +152,7 @@ typedef struct SqlFunctionCtx {
struct
SSDataBlock
*
pSrcBlock
;
struct
SSDataBlock
*
pDstBlock
;
// used by indefinite rows function to set selectivity
SSerializeDataHandle
saveHandle
;
int32_t
exprIdx
;
char
udfName
[
TSDB_FUNC_NAME_LEN
];
}
SqlFunctionCtx
;
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
25e9d94f
...
...
@@ -693,7 +693,7 @@ void cleanupExprSupp(SExprSupp* pSup);
void
destroyExprInfo
(
SExprInfo
*
pExpr
,
int32_t
numOfExprs
);
int32_t
initAggSup
(
SExprSupp
*
pSup
,
SAggSupporter
*
pAggSup
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
size_t
keyBufSize
,
const
char
*
pkey
);
const
char
*
pkey
,
void
*
pState
);
void
cleanupAggSup
(
SAggSupporter
*
pAggSup
);
void
initResultSizeInfo
(
SResultInfo
*
pResultInfo
,
int32_t
numOfRows
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
25e9d94f
...
...
@@ -605,9 +605,7 @@ void setBlockSMAInfo(SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, SSDataBlock* pB
}
}
bool
isTaskKilled
(
SExecTaskInfo
*
pTaskInfo
)
{
return
(
0
!=
pTaskInfo
->
code
)
?
true
:
false
;
}
bool
isTaskKilled
(
SExecTaskInfo
*
pTaskInfo
)
{
return
(
0
!=
pTaskInfo
->
code
)
?
true
:
false
;
}
void
setTaskKilled
(
SExecTaskInfo
*
pTaskInfo
,
int32_t
rspCode
)
{
pTaskInfo
->
code
=
rspCode
;
}
...
...
@@ -1350,7 +1348,7 @@ int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scan
}
}
static
int32_t
createDataBlockForEmptyInput
(
SOperatorInfo
*
pOperator
,
SSDataBlock
**
ppBlock
)
{
static
int32_t
createDataBlockForEmptyInput
(
SOperatorInfo
*
pOperator
,
SSDataBlock
**
ppBlock
)
{
if
(
!
tsCountAlwaysReturnValue
)
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1363,7 +1361,7 @@ static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBloc
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
if
(
downstream
->
operatorType
==
QUERY_NODE_PHYSICAL_PLAN_PARTITION
||
(
downstream
->
operatorType
==
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
&&
((
STableScanInfo
*
)
downstream
->
info
)
->
hasGroupByTag
==
true
))
{
((
STableScanInfo
*
)
downstream
->
info
)
->
hasGroupByTag
==
true
))
{
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1417,7 +1415,7 @@ static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBloc
return
TSDB_CODE_SUCCESS
;
}
static
void
destroyDataBlockForEmptyInput
(
bool
blockAllocated
,
SSDataBlock
**
ppBlock
)
{
static
void
destroyDataBlockForEmptyInput
(
bool
blockAllocated
,
SSDataBlock
**
ppBlock
)
{
if
(
!
blockAllocated
)
{
return
;
}
...
...
@@ -1487,7 +1485,6 @@ static int32_t doOpenAggregateOptr(SOperatorInfo* pOperator) {
}
destroyDataBlockForEmptyInput
(
blockAllocated
,
&
pBlock
);
}
// the downstream operator may return with error code, so let's check the code before generating results.
...
...
@@ -1642,7 +1639,7 @@ void cleanupAggSup(SAggSupporter* pAggSup) {
}
int32_t
initAggSup
(
SExprSupp
*
pSup
,
SAggSupporter
*
pAggSup
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
size_t
keyBufSize
,
const
char
*
pkey
)
{
const
char
*
pkey
,
void
*
pState
)
{
int32_t
code
=
initExprSupp
(
pSup
,
pExprInfo
,
numOfCols
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
...
...
@@ -1654,8 +1651,14 @@ int32_t initAggSup(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo
}
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
if
(
pState
)
{
pSup
->
pCtx
[
i
].
saveHandle
.
pBuf
=
NULL
;
pSup
->
pCtx
[
i
].
saveHandle
.
pState
=
pState
;
pSup
->
pCtx
[
i
].
exprIdx
=
i
;
}
else
{
pSup
->
pCtx
[
i
].
saveHandle
.
pBuf
=
pAggSup
->
pResultBuf
;
}
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1739,7 +1742,8 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN
int32_t
num
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pAggNode
->
pAggFuncs
,
pAggNode
->
pGroupKeys
,
&
num
);
int32_t
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
num
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
int32_t
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
num
,
keyBufSize
,
pTaskInfo
->
id
.
str
,
pTaskInfo
->
streamInfo
.
pState
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -1766,7 +1770,8 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN
setOperatorInfo
(
pOperator
,
"TableAggregate"
,
QUERY_NODE_PHYSICAL_PLAN_HASH_AGG
,
true
,
OP_NOT_OPENED
,
pInfo
,
pTaskInfo
);
pOperator
->
fpSet
=
createOperatorFpSet
(
doOpenAggregateOptr
,
getAggregateResult
,
NULL
,
destroyAggOperatorInfo
,
optrDefaultBufFn
,
NULL
);
pOperator
->
fpSet
=
createOperatorFpSet
(
doOpenAggregateOptr
,
getAggregateResult
,
NULL
,
destroyAggOperatorInfo
,
optrDefaultBufFn
,
NULL
);
if
(
downstream
->
operatorType
==
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
)
{
STableScanInfo
*
pTableScanInfo
=
downstream
->
info
;
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
25e9d94f
...
...
@@ -458,7 +458,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SAggPhysiNode*
int32_t
num
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pAggNode
->
pAggFuncs
,
pAggNode
->
pGroupKeys
,
&
num
);
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
num
,
pInfo
->
groupKeyLen
,
pTaskInfo
->
id
.
str
);
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
num
,
pInfo
->
groupKeyLen
,
pTaskInfo
->
id
.
str
,
pTaskInfo
->
streamInfo
.
pState
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
source/libs/executor/src/projectoperator.c
浏览文件 @
25e9d94f
...
...
@@ -102,7 +102,8 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhys
}
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
numOfRows
);
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
,
pTaskInfo
->
streamInfo
.
pState
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -317,7 +318,7 @@ SSDataBlock* doProjectOperation(SOperatorInfo* pOperator) {
if
(
pProjectInfo
->
mergeDataBlocks
)
{
if
(
pRes
->
info
.
rows
>
0
)
{
pFinalRes
->
info
.
id
.
groupId
=
0
;
//clear groupId
pFinalRes
->
info
.
id
.
groupId
=
0
;
//
clear groupId
pFinalRes
->
info
.
version
=
pRes
->
info
.
version
;
// continue merge data, ignore the group id
...
...
@@ -402,7 +403,8 @@ SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhy
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
numOfRows
);
blockDataEnsureCapacity
(
pResBlock
,
numOfRows
);
int32_t
code
=
initAggSup
(
pSup
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfExpr
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
int32_t
code
=
initAggSup
(
pSup
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfExpr
,
keyBufSize
,
pTaskInfo
->
id
.
str
,
pTaskInfo
->
streamInfo
.
pState
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
25e9d94f
...
...
@@ -666,8 +666,8 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
setNotInterpoWindowKey
(
pSup
->
pCtx
,
numOfExprs
,
RESULT_ROW_START_INTERP
);
updateTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
w
,
true
);
applyAggFunctionOnPartialTuples
(
pTaskInfo
,
pSup
->
pCtx
,
&
pInfo
->
twAggSup
.
timeWindowData
,
startPos
,
0
,
pBlock
->
info
.
rows
,
numOfExprs
);
applyAggFunctionOnPartialTuples
(
pTaskInfo
,
pSup
->
pCtx
,
&
pInfo
->
twAggSup
.
timeWindowData
,
startPos
,
0
,
pBlock
->
info
.
rows
,
numOfExprs
);
if
(
isResultRowInterpolated
(
pResult
,
RESULT_ROW_END_INTERP
))
{
closeResultRow
(
pr
);
...
...
@@ -817,13 +817,13 @@ static int32_t savePullWindow(SPullWindowInfo* pPullInfo, SArray* pPullWins) {
}
else
{
int32_t
code
=
comparePullWinKey
(
pPullInfo
,
pPullWins
,
index
);
if
(
code
==
0
)
{
SPullWindowInfo
*
pos
=
taosArrayGet
(
pPullWins
,
index
);
SPullWindowInfo
*
pos
=
taosArrayGet
(
pPullWins
,
index
);
pos
->
window
.
skey
=
TMIN
(
pos
->
window
.
skey
,
pPullInfo
->
window
.
skey
);
pos
->
window
.
ekey
=
TMAX
(
pos
->
window
.
ekey
,
pPullInfo
->
window
.
ekey
);
pos
->
calWin
.
skey
=
TMIN
(
pos
->
calWin
.
skey
,
pPullInfo
->
calWin
.
skey
);
pos
->
calWin
.
ekey
=
TMAX
(
pos
->
calWin
.
ekey
,
pPullInfo
->
calWin
.
ekey
);
return
TSDB_CODE_SUCCESS
;
}
else
if
(
code
>
0
)
{
}
else
if
(
code
>
0
)
{
index
++
;
}
}
...
...
@@ -882,7 +882,7 @@ int32_t compareWinRes(void* pKey, void* data, int32_t index) {
if
(
*
(
int64_t
*
)
pRKey
->
key
>
pDataPos
->
ts
)
{
return
1
;
}
else
if
(
*
(
int64_t
*
)
pRKey
->
key
<
pDataPos
->
ts
){
}
else
if
(
*
(
int64_t
*
)
pRKey
->
key
<
pDataPos
->
ts
)
{
return
-
1
;
}
return
0
;
...
...
@@ -961,8 +961,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
}
updateTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
win
,
true
);
applyAggFunctionOnPartialTuples
(
pTaskInfo
,
pSup
->
pCtx
,
&
pInfo
->
twAggSup
.
timeWindowData
,
startPos
,
forwardRows
,
pBlock
->
info
.
rows
,
numOfOutput
);
applyAggFunctionOnPartialTuples
(
pTaskInfo
,
pSup
->
pCtx
,
&
pInfo
->
twAggSup
.
timeWindowData
,
startPos
,
forwardRows
,
pBlock
->
info
.
rows
,
numOfOutput
);
doCloseWindow
(
pResultRowInfo
,
pInfo
,
pResult
);
...
...
@@ -996,8 +996,8 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
}
#endif
updateTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
nextWin
,
true
);
applyAggFunctionOnPartialTuples
(
pTaskInfo
,
pSup
->
pCtx
,
&
pInfo
->
twAggSup
.
timeWindowData
,
startPos
,
forwardRows
,
pBlock
->
info
.
rows
,
numOfOutput
);
applyAggFunctionOnPartialTuples
(
pTaskInfo
,
pSup
->
pCtx
,
&
pInfo
->
twAggSup
.
timeWindowData
,
startPos
,
forwardRows
,
pBlock
->
info
.
rows
,
numOfOutput
);
doCloseWindow
(
pResultRowInfo
,
pInfo
,
pResult
);
}
...
...
@@ -1188,8 +1188,8 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI
}
updateTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pRowSup
->
win
,
false
);
applyAggFunctionOnPartialTuples
(
pTaskInfo
,
pSup
->
pCtx
,
&
pInfo
->
twAggSup
.
timeWindowData
,
pRowSup
->
startRowIndex
,
pRowSup
->
numOfRows
,
pBlock
->
info
.
rows
,
numOfOutput
);
applyAggFunctionOnPartialTuples
(
pTaskInfo
,
pSup
->
pCtx
,
&
pInfo
->
twAggSup
.
timeWindowData
,
pRowSup
->
startRowIndex
,
pRowSup
->
numOfRows
,
pBlock
->
info
.
rows
,
numOfOutput
);
}
static
int32_t
openStateWindowAggOptr
(
SOperatorInfo
*
pOperator
)
{
...
...
@@ -1656,7 +1656,7 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt
// the primary timestamp column
bool
needed
=
false
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SExprInfo
*
pExpr
=
pCtx
[
i
].
pExpr
;
if
(
fmIsIntervalInterpoFunc
(
pCtx
[
i
].
functionId
))
{
needed
=
true
;
...
...
@@ -1724,7 +1724,7 @@ void initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SAggSuppor
void
initStreamFunciton
(
SqlFunctionCtx
*
pCtx
,
int32_t
numOfExpr
)
{
for
(
int32_t
i
=
0
;
i
<
numOfExpr
;
i
++
)
{
// pCtx[i].isStream = true;
// pCtx[i].isStream = true;
}
}
...
...
@@ -1748,7 +1748,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh
int32_t
num
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pPhyNode
->
window
.
pFuncs
,
NULL
,
&
num
);
int32_t
code
=
initAggSup
(
pSup
,
&
pInfo
->
aggSup
,
pExprInfo
,
num
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
int32_t
code
=
initAggSup
(
pSup
,
&
pInfo
->
aggSup
,
pExprInfo
,
num
,
keyBufSize
,
pTaskInfo
->
id
.
str
,
pTaskInfo
->
streamInfo
.
pState
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -1800,8 +1801,8 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SIntervalPh
setOperatorInfo
(
pOperator
,
"TimeIntervalAggOperator"
,
QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL
,
true
,
OP_NOT_OPENED
,
pInfo
,
pTaskInfo
);
pOperator
->
fpSet
=
createOperatorFpSet
(
doOpenIntervalAgg
,
doBuildIntervalResult
,
NULL
,
destroyIntervalOperatorInfo
,
optrDefaultBufFn
,
NULL
);
pOperator
->
fpSet
=
createOperatorFpSet
(
doOpenIntervalAgg
,
doBuildIntervalResult
,
NULL
,
destroyIntervalOperatorInfo
,
optrDefaultBufFn
,
NULL
);
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -1886,8 +1887,8 @@ static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperator
}
updateTimeWindowInfo
(
&
pInfo
->
twAggSup
.
timeWindowData
,
&
pRowSup
->
win
,
false
);
applyAggFunctionOnPartialTuples
(
pTaskInfo
,
pSup
->
pCtx
,
&
pInfo
->
twAggSup
.
timeWindowData
,
pRowSup
->
startRowIndex
,
pRowSup
->
numOfRows
,
pBlock
->
info
.
rows
,
numOfOutput
);
applyAggFunctionOnPartialTuples
(
pTaskInfo
,
pSup
->
pCtx
,
&
pInfo
->
twAggSup
.
timeWindowData
,
pRowSup
->
startRowIndex
,
pRowSup
->
numOfRows
,
pBlock
->
info
.
rows
,
numOfOutput
);
}
static
SSDataBlock
*
doSessionWindowAgg
(
SOperatorInfo
*
pOperator
)
{
...
...
@@ -2000,7 +2001,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi
SExprInfo
*
pExprInfo
=
createExprInfo
(
pStateNode
->
window
.
pFuncs
,
NULL
,
&
num
);
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
num
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
num
,
keyBufSize
,
pTaskInfo
->
id
.
str
,
pTaskInfo
->
streamInfo
.
pState
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -2018,8 +2020,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi
setOperatorInfo
(
pOperator
,
"StateWindowOperator"
,
QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE
,
true
,
OP_NOT_OPENED
,
pInfo
,
pTaskInfo
);
pOperator
->
fpSet
=
createOperatorFpSet
(
openStateWindowAggOptr
,
doStateWindowAgg
,
NULL
,
destroyStateWindowOperatorInfo
,
optrDefaultBufFn
,
NULL
);
pOperator
->
fpSet
=
createOperatorFpSet
(
openStateWindowAggOptr
,
doStateWindowAgg
,
NULL
,
destroyStateWindowOperatorInfo
,
optrDefaultBufFn
,
NULL
);
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -2068,7 +2070,8 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionW
SSDataBlock
*
pResBlock
=
createDataBlockFromDescNode
(
pSessionNode
->
window
.
node
.
pOutputDataBlockDesc
);
initBasicInfo
(
&
pInfo
->
binfo
,
pResBlock
);
int32_t
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
int32_t
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
,
pTaskInfo
->
streamInfo
.
pState
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -2091,8 +2094,8 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SSessionW
setOperatorInfo
(
pOperator
,
"SessionWindowAggOperator"
,
QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION
,
true
,
OP_NOT_OPENED
,
pInfo
,
pTaskInfo
);
pOperator
->
fpSet
=
createOperatorFpSet
(
optrDummyOpenFn
,
doSessionWindowAgg
,
NULL
,
destroySWindowOperatorInfo
,
optrDefaultBufFn
,
NULL
);
pOperator
->
fpSet
=
createOperatorFpSet
(
optrDummyOpenFn
,
doSessionWindowAgg
,
NULL
,
destroySWindowOperatorInfo
,
optrDefaultBufFn
,
NULL
);
pOperator
->
pTaskInfo
=
pTaskInfo
;
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -2309,7 +2312,8 @@ static void addRetriveWindow(SArray* wins, SStreamIntervalOperatorInfo* pInfo) {
if
(
needDeleteWindowBuf
(
&
nextWin
,
&
pInfo
->
twAggSup
)
&&
!
pInfo
->
ignoreExpiredData
)
{
void
*
chIds
=
taosHashGet
(
pInfo
->
pPullDataMap
,
winKey
,
sizeof
(
SWinKey
));
if
(
!
chIds
)
{
SPullWindowInfo
pull
=
{.
window
=
nextWin
,
.
groupId
=
winKey
->
groupId
,
.
calWin
.
skey
=
nextWin
.
skey
,
.
calWin
.
ekey
=
nextWin
.
skey
};
SPullWindowInfo
pull
=
{
.
window
=
nextWin
,
.
groupId
=
winKey
->
groupId
,
.
calWin
.
skey
=
nextWin
.
skey
,
.
calWin
.
ekey
=
nextWin
.
skey
};
// add pull data request
if
(
savePullWindow
(
&
pull
,
pInfo
->
pPullWins
)
==
TSDB_CODE_SUCCESS
)
{
int32_t
size1
=
taosArrayGetSize
(
pInfo
->
pChildren
);
...
...
@@ -2395,7 +2399,8 @@ static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SSDataBlock* p
};
void
*
chIds
=
taosHashGet
(
pInfo
->
pPullDataMap
,
&
winRes
,
sizeof
(
SWinKey
));
if
(
isDeletedStreamWindow
(
&
nextWin
,
groupId
,
pInfo
->
pState
,
&
pInfo
->
twAggSup
)
&&
!
chIds
)
{
SPullWindowInfo
pull
=
{.
window
=
nextWin
,
.
groupId
=
groupId
,
.
calWin
.
skey
=
nextWin
.
skey
,
.
calWin
.
ekey
=
nextWin
.
skey
};
SPullWindowInfo
pull
=
{
.
window
=
nextWin
,
.
groupId
=
groupId
,
.
calWin
.
skey
=
nextWin
.
skey
,
.
calWin
.
ekey
=
nextWin
.
skey
};
// add pull data request
if
(
savePullWindow
(
&
pull
,
pInfo
->
pPullWins
)
==
TSDB_CODE_SUCCESS
)
{
int32_t
size
=
taosArrayGetSize
(
pInfo
->
pChildren
);
...
...
@@ -2545,7 +2550,8 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
SSDataBlock
*
pBlock
=
downstream
->
fpSet
.
getNextFn
(
downstream
);
if
(
pBlock
==
NULL
)
{
pOperator
->
status
=
OP_RES_TO_RETURN
;
qDebug
(
"===stream===return data:%s. recv datablock num:%"
PRIu64
,
IS_FINAL_OP
(
pInfo
)
?
"interval final"
:
"interval semi"
,
pInfo
->
numOfDatapack
);
qDebug
(
"===stream===return data:%s. recv datablock num:%"
PRIu64
,
IS_FINAL_OP
(
pInfo
)
?
"interval final"
:
"interval semi"
,
pInfo
->
numOfDatapack
);
pInfo
->
numOfDatapack
=
0
;
break
;
}
...
...
@@ -2665,7 +2671,7 @@ int64_t getDeleteMark(SIntervalPhysiNode* pIntervalPhyNode) {
if
(
pIntervalPhyNode
->
window
.
deleteMark
<=
0
)
{
return
DEAULT_DELETE_MARK
;
}
int64_t
deleteMark
=
TMAX
(
pIntervalPhyNode
->
window
.
deleteMark
,
pIntervalPhyNode
->
window
.
watermark
);
int64_t
deleteMark
=
TMAX
(
pIntervalPhyNode
->
window
.
deleteMark
,
pIntervalPhyNode
->
window
.
watermark
);
deleteMark
=
TMAX
(
deleteMark
,
pIntervalPhyNode
->
interval
);
return
deleteMark
;
}
...
...
@@ -2713,7 +2719,8 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
SSDataBlock
*
pResBlock
=
createDataBlockFromDescNode
(
pPhyNode
->
pOutputDataBlockDesc
);
initBasicInfo
(
&
pInfo
->
binfo
,
pResBlock
);
int32_t
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
int32_t
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
,
pTaskInfo
->
streamInfo
.
pState
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -2778,8 +2785,8 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
fpSet
=
createOperatorFpSet
(
NULL
,
doStreamFinalIntervalAgg
,
NULL
,
destroyStreamFinalIntervalOperatorInfo
,
optrDefaultBufFn
,
NULL
);
pOperator
->
fpSet
=
createOperatorFpSet
(
NULL
,
doStreamFinalIntervalAgg
,
NULL
,
destroyStreamFinalIntervalOperatorInfo
,
optrDefaultBufFn
,
NULL
);
if
(
pPhyNode
->
type
==
QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL
)
{
initIntervalDownStream
(
downstream
,
pPhyNode
->
type
,
&
pInfo
->
aggSup
,
&
pInfo
->
interval
,
&
pInfo
->
twAggSup
);
}
...
...
@@ -3578,8 +3585,8 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
setOperatorInfo
(
pOperator
,
"StreamSessionWindowAggOperator"
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION
,
true
,
OP_NOT_OPENED
,
pInfo
,
pTaskInfo
);
pOperator
->
fpSet
=
createOperatorFpSet
(
optrDummyOpenFn
,
doStreamSessionAgg
,
NULL
,
destroyStreamSessionAggOperatorInfo
,
optrDefaultBufFn
,
NULL
);
pOperator
->
fpSet
=
createOperatorFpSet
(
optrDummyOpenFn
,
doStreamSessionAgg
,
NULL
,
destroyStreamSessionAggOperatorInfo
,
optrDefaultBufFn
,
NULL
);
if
(
downstream
)
{
initDownStream
(
downstream
,
&
pInfo
->
streamAggSup
,
pOperator
->
operatorType
,
pInfo
->
primaryTsIndex
,
&
pInfo
->
twAggSup
);
...
...
@@ -4083,8 +4090,8 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
setOperatorInfo
(
pOperator
,
"StreamStateAggOperator"
,
QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE
,
true
,
OP_NOT_OPENED
,
pInfo
,
pTaskInfo
);
pOperator
->
fpSet
=
createOperatorFpSet
(
optrDummyOpenFn
,
doStreamStateAgg
,
NULL
,
destroyStreamStateOperatorInfo
,
optrDefaultBufFn
,
NULL
);
pOperator
->
fpSet
=
createOperatorFpSet
(
optrDummyOpenFn
,
doStreamStateAgg
,
NULL
,
destroyStreamStateOperatorInfo
,
optrDefaultBufFn
,
NULL
);
initDownStream
(
downstream
,
&
pInfo
->
streamAggSup
,
pOperator
->
operatorType
,
pInfo
->
primaryTsIndex
,
&
pInfo
->
twAggSup
);
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -4169,8 +4176,8 @@ static void doMergeAlignedIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultR
}
updateTimeWindowInfo
(
&
iaInfo
->
twAggSup
.
timeWindowData
,
&
currWin
,
true
);
applyAggFunctionOnPartialTuples
(
pTaskInfo
,
pSup
->
pCtx
,
&
iaInfo
->
twAggSup
.
timeWindowData
,
startPos
,
currPos
-
startPos
,
pBlock
->
info
.
rows
,
pSup
->
numOfExprs
);
applyAggFunctionOnPartialTuples
(
pTaskInfo
,
pSup
->
pCtx
,
&
iaInfo
->
twAggSup
.
timeWindowData
,
startPos
,
currPos
-
startPos
,
pBlock
->
info
.
rows
,
pSup
->
numOfExprs
);
finalizeResultRows
(
iaInfo
->
aggSup
.
pResultBuf
,
&
pResultRowInfo
->
cur
,
pSup
,
pResultBlock
,
pTaskInfo
);
resetResultRow
(
miaInfo
->
pResultRow
,
iaInfo
->
aggSup
.
resultRowSize
-
sizeof
(
SResultRow
));
...
...
@@ -4341,7 +4348,8 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
int32_t
num
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pNode
->
window
.
pFuncs
,
NULL
,
&
num
);
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
iaInfo
->
aggSup
,
pExprInfo
,
num
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
code
=
initAggSup
(
&
pOperator
->
exprSupp
,
&
iaInfo
->
aggSup
,
pExprInfo
,
num
,
keyBufSize
,
pTaskInfo
->
id
.
str
,
pTaskInfo
->
streamInfo
.
pState
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -4360,8 +4368,8 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
setOperatorInfo
(
pOperator
,
"TimeMergeAlignedIntervalAggOperator"
,
QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL
,
false
,
OP_NOT_OPENED
,
miaInfo
,
pTaskInfo
);
pOperator
->
fpSet
=
createOperatorFpSet
(
optrDummyOpenFn
,
mergeAlignedIntervalAgg
,
NULL
,
destroyMAIOperatorInfo
,
optrDefaultBufFn
,
NULL
);
pOperator
->
fpSet
=
createOperatorFpSet
(
optrDummyOpenFn
,
mergeAlignedIntervalAgg
,
NULL
,
destroyMAIOperatorInfo
,
optrDefaultBufFn
,
NULL
);
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -4645,7 +4653,8 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
int32_t
code
=
initAggSup
(
pExprSupp
,
&
pIntervalInfo
->
aggSup
,
pExprInfo
,
num
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
int32_t
code
=
initAggSup
(
pExprSupp
,
&
pIntervalInfo
->
aggSup
,
pExprInfo
,
num
,
keyBufSize
,
pTaskInfo
->
id
.
str
,
pTaskInfo
->
streamInfo
.
pState
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -4665,8 +4674,8 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge
initResultRowInfo
(
&
pIntervalInfo
->
binfo
.
resultRowInfo
);
setOperatorInfo
(
pOperator
,
"TimeMergeIntervalAggOperator"
,
QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL
,
false
,
OP_NOT_OPENED
,
pMergeIntervalInfo
,
pTaskInfo
);
pOperator
->
fpSet
=
createOperatorFpSet
(
optrDummyOpenFn
,
doMergeIntervalAgg
,
NULL
,
destroyMergeIntervalOperatorInfo
,
optrDefaultBufFn
,
NULL
);
pOperator
->
fpSet
=
createOperatorFpSet
(
optrDummyOpenFn
,
doMergeIntervalAgg
,
NULL
,
destroyMergeIntervalOperatorInfo
,
optrDefaultBufFn
,
NULL
);
code
=
appendDownstream
(
pOperator
,
&
downstream
,
1
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
@@ -4843,7 +4852,8 @@ SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhys
initResultSizeInfo
(
&
pOperator
->
resultInfo
,
4096
);
size_t
keyBufSize
=
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
;
code
=
initAggSup
(
pSup
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
);
code
=
initAggSup
(
pSup
,
&
pInfo
->
aggSup
,
pExprInfo
,
numOfCols
,
keyBufSize
,
pTaskInfo
->
id
.
str
,
pTaskInfo
->
streamInfo
.
pState
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
source/libs/function/inc/builtinsimpl.h
浏览文件 @
25e9d94f
...
...
@@ -46,7 +46,7 @@ typedef struct SMinmaxResInfo {
}
SMinmaxResInfo
;
int32_t
doMinMaxHelper
(
SqlFunctionCtx
*
pCtx
,
int32_t
isMinFunc
);
STuplePos
saveTupleData
(
SqlFunctionCtx
*
pCtx
,
int32_t
rowIndex
,
const
SSDataBlock
*
pSrcBlock
,
const
STupleKey
*
pKey
);
STuplePos
saveTupleData
(
SqlFunctionCtx
*
pCtx
,
int32_t
rowIndex
,
const
SSDataBlock
*
pSrcBlock
);
int32_t
updateTupleData
(
SqlFunctionCtx
*
pCtx
,
int32_t
rowIndex
,
const
SSDataBlock
*
pSrcBlock
,
STuplePos
*
pPos
);
const
char
*
loadTupleData
(
SqlFunctionCtx
*
pCtx
,
const
STuplePos
*
pPos
);
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
25e9d94f
...
...
@@ -41,7 +41,7 @@
#define HLL_BUCKET_MASK (HLL_BUCKETS - 1)
#define HLL_ALPHA_INF 0.721347520444481703680 // constant for 0.5/ln(2)
//typedef struct SMinmaxResInfo {
//
typedef struct SMinmaxResInfo {
// bool assign; // assign the first value or not
// int64_t v;
// STuplePos tuplePos;
...
...
@@ -49,7 +49,7 @@
// STuplePos nullTuplePos;
// bool nullTupleSaved;
// int16_t type;
//} SMinmaxResInfo;
//
} SMinmaxResInfo;
typedef
struct
STopBotResItem
{
SVariant
v
;
...
...
@@ -818,8 +818,8 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple
return
;
}
if
(
pCtx
->
saveHandle
.
pBuf
!=
NULL
)
{
if
(
pTuplePos
->
pageId
!=
-
1
)
{
if
(
(
pCtx
->
saveHandle
.
pBuf
!=
NULL
&&
pTuplePos
->
pageId
!=
-
1
)
||
(
pCtx
->
saveHandle
.
pState
&&
pTuplePos
->
streamTupleKey
.
ts
>
0
)
)
{
int32_t
numOfCols
=
pCtx
->
subsidiaries
.
num
;
const
char
*
p
=
loadTupleData
(
pCtx
,
pTuplePos
);
...
...
@@ -840,6 +840,9 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple
}
pStart
+=
pDstCol
->
info
.
bytes
;
}
if
(
pCtx
->
saveHandle
.
pState
)
{
tdbFree
((
void
*
)
p
);
}
}
}
...
...
@@ -2018,7 +2021,7 @@ static void firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowInde
}
if
(
!
pInfo
->
hasResult
)
{
pInfo
->
pos
=
saveTupleData
(
pCtx
,
rowIndex
,
pSrcBlock
,
NULL
);
pInfo
->
pos
=
saveTupleData
(
pCtx
,
rowIndex
,
pSrcBlock
);
}
else
{
updateTupleData
(
pCtx
,
rowIndex
,
pSrcBlock
,
&
pInfo
->
pos
);
}
...
...
@@ -2071,8 +2074,8 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
int32_t
blockDataOrder
=
(
startKey
<=
endKey
)
?
TSDB_ORDER_ASC
:
TSDB_ORDER_DESC
;
// please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first
function.
// we will use this opt implementation in an new version that is only available in scan subplan
// please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first
//
function.
we will use this opt implementation in an new version that is only available in scan subplan
#if 0
if (blockDataOrder == TSDB_ORDER_ASC) {
// filter according to current result firstly
...
...
@@ -2179,7 +2182,8 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
int32_t
blockDataOrder
=
(
startKey
<=
endKey
)
?
TSDB_ORDER_ASC
:
TSDB_ORDER_DESC
;
// please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first function.
// please ref. to the comment in lastRowFunction for the reason why disabling the opt version of last/first
// function.
#if 0
if (blockDataOrder == TSDB_ORDER_ASC) {
for (int32_t i = pInput->numOfRows + pInput->startRowIndex - 1; i >= pInput->startRowIndex; --i) {
...
...
@@ -2777,7 +2781,7 @@ int32_t topFunction(SqlFunctionCtx* pCtx) {
}
if
(
numOfElems
==
0
&&
pCtx
->
subsidiaries
.
num
>
0
&&
!
pRes
->
nullTupleSaved
)
{
pRes
->
nullTuplePos
=
saveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
,
NULL
);
pRes
->
nullTuplePos
=
saveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
);
pRes
->
nullTupleSaved
=
true
;
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -2805,7 +2809,7 @@ int32_t bottomFunction(SqlFunctionCtx* pCtx) {
}
if
(
numOfElems
==
0
&&
pCtx
->
subsidiaries
.
num
>
0
&&
!
pRes
->
nullTupleSaved
)
{
pRes
->
nullTuplePos
=
saveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
,
NULL
);
pRes
->
nullTuplePos
=
saveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
);
pRes
->
nullTupleSaved
=
true
;
}
...
...
@@ -2863,7 +2867,7 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData
// save the data of this tuple
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
pItem
->
tuplePos
=
saveTupleData
(
pCtx
,
rowIndex
,
pSrcBlock
,
NULL
);
pItem
->
tuplePos
=
saveTupleData
(
pCtx
,
rowIndex
,
pSrcBlock
);
}
#ifdef BUF_PAGE_DEBUG
qDebug
(
"page_saveTuple i:%d, item:%p,pageId:%d, offset:%d
\n
"
,
pEntryInfo
->
numOfRes
,
pItem
,
pItem
->
tuplePos
.
pageId
,
...
...
@@ -2937,8 +2941,7 @@ void* serializeTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SSubsid
return
buf
;
}
static
STuplePos
doSaveTupleData
(
SSerializeDataHandle
*
pHandle
,
const
void
*
pBuf
,
size_t
length
,
const
STupleKey
*
pKey
)
{
static
STuplePos
doSaveTupleData
(
SSerializeDataHandle
*
pHandle
,
const
void
*
pBuf
,
size_t
length
,
STupleKey
key
)
{
STuplePos
p
=
{
0
};
if
(
pHandle
->
pBuf
!=
NULL
)
{
SFilePage
*
pPage
=
NULL
;
...
...
@@ -2964,20 +2967,31 @@ static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf
releaseBufPage
(
pHandle
->
pBuf
,
pPage
);
}
else
{
// other tuple save policy
if
(
streamStateFuncPut
(
pHandle
->
pState
,
pK
ey
,
pBuf
,
length
)
<
0
)
{
if
(
streamStateFuncPut
(
pHandle
->
pState
,
&
k
ey
,
pBuf
,
length
)
<
0
)
{
ASSERT
(
0
);
}
p
.
streamTupleKey
=
*
pK
ey
;
p
.
streamTupleKey
=
k
ey
;
}
return
p
;
}
STuplePos
saveTupleData
(
SqlFunctionCtx
*
pCtx
,
int32_t
rowIndex
,
const
SSDataBlock
*
pSrcBlock
,
const
STupleKey
*
pKey
)
{
STuplePos
saveTupleData
(
SqlFunctionCtx
*
pCtx
,
int32_t
rowIndex
,
const
SSDataBlock
*
pSrcBlock
)
{
prepareBuf
(
pCtx
);
STupleKey
key
;
if
(
pCtx
->
saveHandle
.
pBuf
==
NULL
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pSrcBlock
->
pDataBlock
,
0
);
ASSERT
(
pColInfo
->
info
.
type
==
TSDB_DATA_TYPE_TIMESTAMP
);
int64_t
skey
=
*
(
int64_t
*
)
colDataGetData
(
pColInfo
,
rowIndex
);
key
.
groupId
=
pSrcBlock
->
info
.
id
.
groupId
;
key
.
ts
=
skey
;
key
.
exprIdx
=
pCtx
->
exprIdx
;
}
char
*
buf
=
serializeTupleData
(
pSrcBlock
,
rowIndex
,
&
pCtx
->
subsidiaries
,
pCtx
->
subsidiaries
.
buf
);
return
doSaveTupleData
(
&
pCtx
->
saveHandle
,
buf
,
pCtx
->
subsidiaries
.
rowLen
,
pK
ey
);
return
doSaveTupleData
(
&
pCtx
->
saveHandle
,
buf
,
pCtx
->
subsidiaries
.
rowLen
,
k
ey
);
}
static
int32_t
doUpdateTupleData
(
SSerializeDataHandle
*
pHandle
,
const
void
*
pBuf
,
size_t
length
,
STuplePos
*
pPos
)
{
...
...
@@ -3623,7 +3637,7 @@ bool histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultIn
pInfo
->
totalCount
=
0
;
pInfo
->
normalized
=
0
;
char
*
binTypeStr
=
strndup
(
varDataVal
(
pCtx
->
param
[
1
].
param
.
pz
),
varDataLen
(
pCtx
->
param
[
1
].
param
.
pz
));
char
*
binTypeStr
=
strndup
(
varDataVal
(
pCtx
->
param
[
1
].
param
.
pz
),
varDataLen
(
pCtx
->
param
[
1
].
param
.
pz
));
int8_t
binType
=
getHistogramBinType
(
binTypeStr
);
taosMemoryFree
(
binTypeStr
);
...
...
@@ -3947,7 +3961,6 @@ int32_t hllFunctionMerge(SqlFunctionCtx* pCtx) {
int32_t
start
=
pInput
->
startRowIndex
;
for
(
int32_t
i
=
start
;
i
<
start
+
pInput
->
numOfRows
;
++
i
)
{
char
*
data
=
colDataGetData
(
pCol
,
i
);
SHLLInfo
*
pInputInfo
=
(
SHLLInfo
*
)
varDataVal
(
data
);
...
...
@@ -4423,7 +4436,7 @@ static void doReservoirSample(SqlFunctionCtx* pCtx, SSampleInfo* pInfo, char* da
if
(
pInfo
->
numSampled
<
pInfo
->
samples
)
{
sampleAssignResult
(
pInfo
,
data
,
pInfo
->
numSampled
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
pInfo
->
tuplePos
[
pInfo
->
numSampled
]
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
NULL
);
pInfo
->
tuplePos
[
pInfo
->
numSampled
]
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
);
}
pInfo
->
numSampled
++
;
}
else
{
...
...
@@ -4454,7 +4467,7 @@ int32_t sampleFunction(SqlFunctionCtx* pCtx) {
}
if
(
pInfo
->
numSampled
==
0
&&
pCtx
->
subsidiaries
.
num
>
0
&&
!
pInfo
->
nullTupleSaved
)
{
pInfo
->
nullTuplePos
=
saveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
,
NULL
);
pInfo
->
nullTuplePos
=
saveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
);
pInfo
->
nullTupleSaved
=
true
;
}
...
...
@@ -4758,7 +4771,7 @@ static void doModeAdd(SModeInfo* pInfo, int32_t rowIndex, SqlFunctionCtx* pCtx,
pItem
->
count
+=
1
;
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
pItem
->
tuplePos
=
saveTupleData
(
pCtx
,
rowIndex
,
pCtx
->
pSrcBlock
,
NULL
);
pItem
->
tuplePos
=
saveTupleData
(
pCtx
,
rowIndex
,
pCtx
->
pSrcBlock
);
}
taosHashPut
(
pInfo
->
pHash
,
data
,
hashKeyBytes
,
&
pItem
,
sizeof
(
SModeItem
*
));
...
...
@@ -4798,7 +4811,7 @@ int32_t modeFunction(SqlFunctionCtx* pCtx) {
}
if
(
numOfElems
==
0
&&
pCtx
->
subsidiaries
.
num
>
0
&&
!
pInfo
->
nullTupleSaved
)
{
pInfo
->
nullTuplePos
=
saveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
,
NULL
);
pInfo
->
nullTuplePos
=
saveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
);
pInfo
->
nullTupleSaved
=
true
;
}
...
...
@@ -5299,7 +5312,7 @@ int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
int32_t
len
=
sprintf
(
st
+
VARSTR_HEADER_SIZE
,
"Total_Blocks=[%d] Total_Size=[%.2f Kb] Average_size=[%.2f Kb] Compression_Ratio=[%.2f %c]"
,
pData
->
numOfBlocks
,
pData
->
totalSize
/
1024
.
0
,
averageSize
/
1024
.
0
,
compRatio
,
'%'
);
pData
->
numOfBlocks
,
pData
->
totalSize
/
1024
.
0
,
averageSize
/
1024
.
0
,
compRatio
,
'%'
);
varDataSetLen
(
st
,
len
);
colDataAppend
(
pColInfo
,
row
++
,
st
,
false
);
...
...
source/libs/function/src/detail/tminmax.c
浏览文件 @
25e9d94f
...
...
@@ -64,7 +64,7 @@
static
void
calculateRounds
(
int32_t
numOfRows
,
int32_t
bytes
,
int32_t
*
remainder
,
int32_t
*
rounds
,
int32_t
*
width
)
{
const
int32_t
bitWidth
=
256
;
*
width
=
(
bitWidth
>>
3u
)
/
bytes
;
*
width
=
(
bitWidth
>>
3u
)
/
bytes
;
*
remainder
=
numOfRows
%
(
*
width
);
*
rounds
=
numOfRows
/
(
*
width
);
}
...
...
@@ -93,7 +93,6 @@ static void calculateRounds(int32_t numOfRows, int32_t bytes, int32_t* remainder
} \
}
static
int8_t
i8VectorCmpAVX2
(
const
void
*
pData
,
int32_t
numOfRows
,
bool
isMinFunc
,
bool
signVal
)
{
int8_t
v
=
0
;
const
int8_t
*
p
=
pData
;
...
...
@@ -495,7 +494,8 @@ static void handleInt64Col(const void* data, int32_t start, int32_t numOfRows, S
}
}
static
void
handleFloatCol
(
SColumnInfoData
*
pCol
,
int32_t
start
,
int32_t
numOfRows
,
SMinmaxResInfo
*
pBuf
,
bool
isMinFunc
)
{
static
void
handleFloatCol
(
SColumnInfoData
*
pCol
,
int32_t
start
,
int32_t
numOfRows
,
SMinmaxResInfo
*
pBuf
,
bool
isMinFunc
)
{
float
*
pData
=
(
float
*
)
pCol
->
pData
;
float
*
val
=
(
float
*
)
&
pBuf
->
v
;
...
...
@@ -525,7 +525,8 @@ static void handleFloatCol(SColumnInfoData* pCol, int32_t start, int32_t numOfRo
pBuf
->
assign
=
true
;
}
static
void
handleDoubleCol
(
SColumnInfoData
*
pCol
,
int32_t
start
,
int32_t
numOfRows
,
SMinmaxResInfo
*
pBuf
,
bool
isMinFunc
)
{
static
void
handleDoubleCol
(
SColumnInfoData
*
pCol
,
int32_t
start
,
int32_t
numOfRows
,
SMinmaxResInfo
*
pBuf
,
bool
isMinFunc
)
{
double
*
pData
=
(
double
*
)
pCol
->
pData
;
double
*
val
=
(
double
*
)
&
pBuf
->
v
;
...
...
@@ -740,7 +741,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
index
=
findRowIndex
(
pInput
->
startRowIndex
,
pInput
->
numOfRows
,
pCol
,
tval
);
if
(
index
>=
0
)
{
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
NULL
);
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
);
}
}
}
else
{
...
...
@@ -754,7 +755,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
index
=
findRowIndex
(
pInput
->
startRowIndex
,
pInput
->
numOfRows
,
pCol
,
tval
);
if
(
index
>=
0
)
{
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
NULL
);
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
);
}
}
}
...
...
@@ -768,7 +769,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
index
=
findRowIndex
(
pInput
->
startRowIndex
,
pInput
->
numOfRows
,
pCol
,
tval
);
if
(
index
>=
0
)
{
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
NULL
);
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
);
}
}
}
...
...
@@ -782,7 +783,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
index
=
findRowIndex
(
pInput
->
startRowIndex
,
pInput
->
numOfRows
,
pCol
,
tval
);
if
(
index
>=
0
)
{
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
NULL
);
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
);
}
}
}
...
...
@@ -798,7 +799,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
index
=
findRowIndex
(
pInput
->
startRowIndex
,
pInput
->
numOfRows
,
pCol
,
tval
);
if
(
index
>=
0
)
{
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
,
NULL
);
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
index
,
pCtx
->
pSrcBlock
);
}
}
}
...
...
@@ -819,7 +820,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
memcpy
(
&
pBuf
->
v
,
pCol
->
pData
+
(
pCol
->
info
.
bytes
*
i
),
pCol
->
info
.
bytes
);
if
(
pCtx
->
subsidiaries
.
num
>
0
)
{
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
,
NULL
);
pBuf
->
tuplePos
=
saveTupleData
(
pCtx
,
i
,
pCtx
->
pSrcBlock
);
}
pBuf
->
assign
=
true
;
numOfElems
=
1
;
...
...
@@ -883,7 +884,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
_over:
if
(
numOfElems
==
0
&&
pCtx
->
subsidiaries
.
num
>
0
&&
!
pBuf
->
nullTupleSaved
)
{
pBuf
->
nullTuplePos
=
saveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
,
NULL
);
pBuf
->
nullTuplePos
=
saveTupleData
(
pCtx
,
pInput
->
startRowIndex
,
pCtx
->
pSrcBlock
);
pBuf
->
nullTupleSaved
=
true
;
}
...
...
source/libs/stream/src/streamState.c
浏览文件 @
25e9d94f
...
...
@@ -107,7 +107,7 @@ static inline int stateKeyCmpr(const void* pKey1, int kLen1, const void* pKey2,
}
SStreamState
*
streamStateOpen
(
char
*
path
,
SStreamTask
*
pTask
,
bool
specPath
,
int32_t
szPage
,
int32_t
pages
)
{
szPage
=
szPage
<
0
?
4096
:
szPage
;
szPage
=
szPage
<
0
?
(
16
*
1024
)
:
szPage
;
pages
=
pages
<
0
?
256
:
pages
;
SStreamState
*
pState
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamState
));
if
(
pState
==
NULL
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录