Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a01f8d44
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看板
提交
a01f8d44
编写于
3月 10, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0_query_integrate' into feature/3.0_query_integrate_wxy
上级
da0fa267
ddbe4095
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
110 addition
and
85 deletion
+110
-85
include/common/tcommon.h
include/common/tcommon.h
+0
-1
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+2
-1
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+2
-0
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+9
-4
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+18
-23
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+28
-3
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+51
-53
未找到文件。
include/common/tcommon.h
浏览文件 @
a01f8d44
...
...
@@ -256,7 +256,6 @@ typedef struct SFunctParam {
// the structure for sql function in select clause
typedef
struct
SExprBasicInfo
{
SSchema
resSchema
;
// TODO refactor
int32_t
interBytes
;
// inter result buffer size, TODO remove it
int16_t
numOfParams
;
// argument value of each function
SFunctParam
*
pParam
;
// SVariant param[3]; // parameters are not more than 3
...
...
source/libs/executor/inc/executil.h
浏览文件 @
a01f8d44
...
...
@@ -92,10 +92,11 @@ typedef struct SResultRowPool {
struct
STaskAttr
;
struct
STaskRuntimeEnv
;
struct
SUdfInfo
;
struct
SqlFunctionCtx
;
int32_t
getOutputInterResultBufSize
(
struct
STaskAttr
*
pQueryAttr
);
size_t
getResultRowSize
(
SArray
*
pExprInfo
);
size_t
getResultRowSize
(
struct
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
);
int32_t
initResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
,
int32_t
size
);
void
cleanupResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
);
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
a01f8d44
...
...
@@ -469,12 +469,14 @@ typedef struct SOptrBasicInfo {
int32_t
capacity
;
}
SOptrBasicInfo
;
//TODO move the resultrowsiz together with SOptrBasicInfo:rowCellInfoOffset
typedef
struct
SAggSupporter
{
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
SResultRowPool
*
pool
;
// The window result objects pool, all the resultRow Objects are allocated and managed by this object.
int32_t
resultRowSize
;
// the result buffer size for each result row, with the meta data size for each row
}
SAggSupporter
;
typedef
struct
STableIntervalOperatorInfo
{
...
...
source/libs/executor/src/executil.c
浏览文件 @
a01f8d44
...
...
@@ -46,7 +46,7 @@ int32_t getOutputInterResultBufSize(STaskAttr* pQueryAttr) {
int32_t
size
=
0
;
for
(
int32_t
i
=
0
;
i
<
pQueryAttr
->
numOfOutput
;
++
i
)
{
size
+=
pQueryAttr
->
pExpr1
[
i
].
base
.
interBytes
;
//
size += pQueryAttr->pExpr1[i].base.interBytes;
}
assert
(
size
>=
0
);
...
...
@@ -172,9 +172,14 @@ SResultRowEntryInfo* getResultCell(const SResultRow* pRow, int32_t index, int32_
return
(
SResultRowEntryInfo
*
)((
char
*
)
pRow
->
pEntryInfo
+
offset
[
index
]);
}
size_t
getResultRowSize
(
SArray
*
pExprInfo
)
{
size_t
numOfOutput
=
taosArrayGetSize
(
pExprInfo
);
return
(
numOfOutput
*
sizeof
(
SResultRowEntryInfo
))
+
/*pQueryAttr->interBufSize +*/
sizeof
(
SResultRow
);
size_t
getResultRowSize
(
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
int32_t
rowSize
=
(
numOfOutput
*
sizeof
(
SResultRowEntryInfo
))
+
sizeof
(
SResultRow
);
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
rowSize
+=
pCtx
[
i
].
resDataInfo
.
interBufSize
;
}
return
rowSize
;
}
SResultRowPool
*
initResultRowPool
(
size_t
size
)
{
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
a01f8d44
...
...
@@ -1970,7 +1970,7 @@ static SqlFunctionCtx* createSqlFunctionCtx(STaskRuntimeEnv* pRuntimeEnv, SExprI
pCtx
->
order
=
pQueryAttr
->
order
.
order
;
// pCtx->functionId = pFunct->functionId;
pCtx
->
stableQuery
=
pQueryAttr
->
stableQuery
;
pCtx
->
resDataInfo
.
interBufSize
=
pFunct
->
interBytes
;
//
pCtx->resDataInfo.interBufSize = pFunct->interBytes;
pCtx
->
start
.
key
=
INT64_MIN
;
pCtx
->
end
.
key
=
INT64_MIN
;
...
...
@@ -2052,7 +2052,7 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SArray* pExprInfo, int32_t** rowC
SExprBasicInfo
*
pFunct
=
&
pExpr
->
base
;
SqlFunctionCtx
*
pCtx
=
&
pFuncCtx
[
i
];
fmGetFuncExecFuncs
(
pExpr
->
pExpr
->
_function
.
function
Id
,
&
pCtx
->
fpSet
);
fmGetFuncExecFuncs
(
pExpr
->
pExpr
->
_function
.
pFunctNode
->
func
Id
,
&
pCtx
->
fpSet
);
pCtx
->
input
.
numOfInputCols
=
pFunct
->
numOfParams
;
pCtx
->
input
.
pData
=
calloc
(
pFunct
->
numOfParams
,
POINTER_BYTES
);
...
...
@@ -2062,8 +2062,6 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SArray* pExprInfo, int32_t** rowC
pCtx
->
resDataInfo
.
bytes
=
pFunct
->
resSchema
.
bytes
;
pCtx
->
resDataInfo
.
type
=
pFunct
->
resSchema
.
type
;
pCtx
->
order
=
TSDB_ORDER_ASC
;
// pCtx->functionId = pExpr->pExpr->_function.pFunctNode->;//TODO remove it
pCtx
->
stableQuery
=
false
;
// TODO
pCtx
->
start
.
key
=
INT64_MIN
;
pCtx
->
end
.
key
=
INT64_MIN
;
...
...
@@ -2120,8 +2118,7 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SArray* pExprInfo, int32_t** rowC
}
for
(
int32_t
i
=
1
;
i
<
numOfOutput
;
++
i
)
{
SExprInfo
*
pExpr
=
taosArrayGetP
(
pExprInfo
,
i
-
1
);
(
*
rowCellInfoOffset
)[
i
]
=
(
int32_t
)((
*
rowCellInfoOffset
)[
i
-
1
]
+
sizeof
(
SResultRowEntryInfo
)
+
pExpr
->
base
.
interBytes
);
(
*
rowCellInfoOffset
)[
i
]
=
(
int32_t
)((
*
rowCellInfoOffset
)[
i
-
1
]
+
sizeof
(
SResultRowEntryInfo
)
+
pFuncCtx
[
i
].
resDataInfo
.
interBufSize
);
}
setCtxTagColumnInfo
(
pFuncCtx
,
numOfOutput
);
...
...
@@ -3347,15 +3344,11 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t
for
(
int32_t
i
=
0
;
i
<
pDataBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
pData
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
i
);
/*
* set the output buffer information and intermediate buffer
* not all queries require the interResultBuf, such as COUNT/TAGPRJ/PRJ/TAG etc.
*/
struct
SResultRowEntryInfo
*
pEntry
=
getResultCell
(
pRow
,
i
,
rowCellInfoOffset
);
cleanupResultRowEntry
(
pEntry
);
pCtx
[
i
].
resultInfo
=
pEntry
;
pCtx
[
i
].
pOutput
=
pData
->
pData
;
pCtx
[
i
].
pOutput
=
pData
->
pData
;
// todo remove it
pCtx
[
i
].
currentStage
=
stage
;
// set the timestamp output buffer for top/bottom/diff query
...
...
@@ -5663,7 +5656,7 @@ SArray* getResultGroupCheckColumns(STaskAttr* pQuery) {
return
pOrderColumns
;
}
static
int32_t
doInitAggInfoSup
(
SAggSupporter
*
pAggSup
,
S
Array
*
pExprInfo
);
static
int32_t
doInitAggInfoSup
(
SAggSupporter
*
pAggSup
,
S
qlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
);
static
void
clearupAggSup
(
SAggSupporter
*
pAggSup
);
static
void
destroySortedMergeOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
...
...
@@ -6044,7 +6037,7 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t
goto
_error
;
}
int32_t
code
=
doInitAggInfoSup
(
&
pInfo
->
aggSup
,
p
ExprInfo
);
int32_t
code
=
doInitAggInfoSup
(
&
pInfo
->
aggSup
,
p
Info
->
binfo
.
pCtx
,
numOfOutput
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
...
...
@@ -7085,13 +7078,14 @@ static void destroyOperatorInfo(SOperatorInfo* pOperator) {
tfree
(
pOperator
);
}
static
int32_t
doInitAggInfoSup
(
SAggSupporter
*
pAggSup
,
SArray
*
pExprInfo
)
{
int32_t
doInitAggInfoSup
(
SAggSupporter
*
pAggSup
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
)
{
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
pAggSup
->
resultRowSize
=
getResultRowSize
(
pCtx
,
numOfOutput
);
pAggSup
->
keyBuf
=
calloc
(
1
,
sizeof
(
int64_t
)
+
sizeof
(
int64_t
)
+
POINTER_BYTES
);
pAggSup
->
pResultRowHashTable
=
taosHashInit
(
10
,
hashFn
,
true
,
HASH_NO_LOCK
);
pAggSup
->
pResultRowListSet
=
taosHashInit
(
100
,
hashFn
,
false
,
HASH_NO_LOCK
);
pAggSup
->
pool
=
initResultRowPool
(
getResultRowSize
(
pExprInfo
)
);
pAggSup
->
pool
=
initResultRowPool
(
pAggSup
->
resultRowSize
);
pAggSup
->
pResultRowArrayList
=
taosArrayInit
(
10
,
sizeof
(
SResultRowCell
));
if
(
pAggSup
->
keyBuf
==
NULL
||
pAggSup
->
pResultRowArrayList
==
NULL
||
pAggSup
->
pResultRowListSet
==
NULL
||
...
...
@@ -7115,7 +7109,7 @@ static int32_t initAggInfo(SAggOperatorInfo* pInfo, SArray* pExprInfo, int32_t n
pInfo
->
binfo
.
pRes
=
pResultBlock
;
pInfo
->
binfo
.
capacity
=
numOfRows
;
doInitAggInfoSup
(
&
pInfo
->
aggSup
,
p
ExprInfo
);
doInitAggInfoSup
(
&
pInfo
->
aggSup
,
p
Info
->
binfo
.
pCtx
,
taosArrayGetSize
(
pExprInfo
)
);
pInfo
->
pTableQueryInfo
=
calloc
(
pTableGroupInfo
->
numOfTables
,
sizeof
(
STableQueryInfo
));
int32_t
index
=
0
;
...
...
@@ -7353,14 +7347,15 @@ SOperatorInfo* createLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorIn
SOperatorInfo
*
createIntervalOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SInterval
*
pInterval
,
SExecTaskInfo
*
pTaskInfo
)
{
STableIntervalOperatorInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
STableIntervalOperatorInfo
));
doInitAggInfoSup
(
&
pInfo
->
aggSup
,
pExprInfo
);
size_t
numOfOutput
=
taosArrayGetSize
(
pExprInfo
);
doInitAggInfoSup
(
&
pInfo
->
aggSup
,
pInfo
->
binfo
.
pCtx
,
numOfOutput
);
pInfo
->
order
=
TSDB_ORDER_ASC
;
pInfo
->
order
=
TSDB_ORDER_ASC
;
pInfo
->
precision
=
TSDB_TIME_PRECISION_MICRO
;
pInfo
->
win
=
pTaskInfo
->
window
;
pInfo
->
interval
=
*
pInterval
;
pInfo
->
win
=
pTaskInfo
->
window
;
pInfo
->
interval
=
*
pInterval
;
int32_t
code
=
createDiskbasedBuf
(
&
pInfo
->
pResultBuf
,
4096
,
4096
*
256
,
pTaskInfo
->
id
.
str
,
"/tmp/"
);
int32_t
code
=
createDiskbasedBuf
(
&
pInfo
->
pResultBuf
,
4096
,
4096
*
256
,
pTaskInfo
->
id
.
str
,
"/tmp/"
);
pInfo
->
binfo
.
pCtx
=
createSqlFunctionCtx_rv
(
pExprInfo
,
&
pInfo
->
binfo
.
rowCellInfoOffset
);
pInfo
->
binfo
.
pRes
=
createOutputBuf_rv
(
pExprInfo
,
pInfo
->
binfo
.
capacity
);
...
...
@@ -8039,8 +8034,8 @@ SArray* createExprInfo(SAggPhysiNode* pPhyNode, int32_t* resultRowSize) {
pExp
->
base
.
pParam
[
0
].
pCol
=
calloc
(
1
,
sizeof
(
SColumn
));
SColumn
*
pCol
=
pExp
->
base
.
pParam
[
0
].
pCol
;
ASSERT
(
LIST_LENGTH
(
pPhyNode
->
pAggFuncs
)
==
1
);
STargetNode
*
pTargetNode
=
(
STargetNode
*
)
nodesListGetNode
(
pPhyNode
->
pAggFuncs
,
0
);
STargetNode
*
pTargetNode
=
(
STargetNode
*
)
nodesListGetNode
(
pPhyNode
->
pAggFuncs
,
i
);
ASSERT
(
pTargetNode
->
slotId
==
i
);
SFunctionNode
*
pFuncNode
=
(
SFunctionNode
*
)
pTargetNode
->
pExpr
;
pExp
->
base
.
resSchema
=
createSchema
(
pFuncNode
->
node
.
resType
.
type
,
pFuncNode
->
node
.
resType
.
bytes
,
pTargetNode
->
slotId
,
pFuncNode
->
node
.
aliasName
);
...
...
source/libs/function/src/builtins.c
浏览文件 @
a01f8d44
...
...
@@ -44,7 +44,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.
name
=
"min"
,
.
type
=
FUNCTION_TYPE_MIN
,
.
classification
=
FUNC_MGT_
NONSTANDARD_SQL
_FUNC
,
.
classification
=
FUNC_MGT_
AGG
_FUNC
,
.
checkFunc
=
stubCheckAndGetResultType
,
.
getEnvFunc
=
getMinmaxFuncEnv
,
.
initFunc
=
minFunctionSetup
,
...
...
@@ -54,7 +54,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
{
.
name
=
"max"
,
.
type
=
FUNCTION_TYPE_MAX
,
.
classification
=
FUNC_MGT_
NONSTANDARD_SQL
_FUNC
,
.
classification
=
FUNC_MGT_
AGG
_FUNC
,
.
checkFunc
=
stubCheckAndGetResultType
,
.
getEnvFunc
=
getMinmaxFuncEnv
,
.
initFunc
=
maxFunctionSetup
,
...
...
@@ -78,8 +78,33 @@ const int32_t funcMgtBuiltinsNum = (sizeof(funcMgtBuiltins) / sizeof(SBuiltinFun
int32_t
stubCheckAndGetResultType
(
SFunctionNode
*
pFunc
)
{
switch
(
pFunc
->
funcType
)
{
case
FUNCTION_TYPE_COUNT
:
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
sizeof
(
int64_t
),
.
type
=
TSDB_DATA_TYPE_BIGINT
};
break
;
default:
case
FUNCTION_TYPE_SUM
:
{
SColumnNode
*
pParam
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
int32_t
paraType
=
pParam
->
node
.
resType
.
type
;
int32_t
resType
=
0
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
paraType
))
{
resType
=
TSDB_DATA_TYPE_BIGINT
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
paraType
))
{
resType
=
TSDB_DATA_TYPE_UBIGINT
;
}
else
if
(
IS_FLOAT_TYPE
(
paraType
))
{
resType
=
TSDB_DATA_TYPE_DOUBLE
;
}
else
{
ASSERT
(
0
);
}
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
tDataTypes
[
resType
].
bytes
,
.
type
=
resType
};
break
;
}
case
FUNCTION_TYPE_MIN
:
case
FUNCTION_TYPE_MAX
:
{
SColumnNode
*
pParam
=
nodesListGetNode
(
pFunc
->
pParameterList
,
0
);
int32_t
paraType
=
pParam
->
node
.
resType
.
type
;
pFunc
->
node
.
resType
=
(
SDataType
)
{
.
bytes
=
tDataTypes
[
paraType
].
bytes
,
.
type
=
paraType
};
break
;
}
default:
ASSERT
(
0
);
// to found the fault ASAP.
}
return
TSDB_CODE_SUCCESS
;
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
a01f8d44
...
...
@@ -14,7 +14,7 @@
*/
#include "builtinsimpl.h"
#include
<querynodes.h>
#include
"querynodes.h"
#include "taggfunction.h"
#include "tdatablock.h"
...
...
@@ -123,17 +123,18 @@ void sumFunction(SqlFunctionCtx *pCtx) {
SColumnDataAgg
*
pAgg
=
pInput
->
pColumnDataAgg
[
0
];
int32_t
type
=
pInput
->
pData
[
0
]
->
info
.
type
;
SSumRes
*
pSumRes
=
GET_ROWCELL_INTERBUF
(
GET_RES_INFO
(
pCtx
));
if
(
pInput
->
colDataAggIsSet
)
{
numOfElem
=
pInput
->
numOfRows
-
pAgg
->
numOfNull
;
ASSERT
(
numOfElem
>=
0
);
SSumRes
*
pSumInfo
=
(
SSumRes
*
)
pCtx
->
pOutput
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
pSum
Info
->
isum
+=
pAgg
->
sum
;
pSum
Res
->
isum
+=
pAgg
->
sum
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
))
{
pSum
Info
->
usum
+=
pAgg
->
sum
;
pSum
Res
->
usum
+=
pAgg
->
sum
;
}
else
if
(
IS_FLOAT_TYPE
(
type
))
{
pSum
Info
->
dsum
+=
GET_DOUBLE_VAL
((
const
char
*
)
&
(
pAgg
->
sum
));
pSum
Res
->
dsum
+=
GET_DOUBLE_VAL
((
const
char
*
)
&
(
pAgg
->
sum
));
}
}
else
{
// computing based on the true data block
SColumnInfoData
*
pCol
=
pInput
->
pData
[
0
];
...
...
@@ -141,32 +142,30 @@ void sumFunction(SqlFunctionCtx *pCtx) {
int32_t
start
=
pInput
->
startRowIndex
;
int32_t
numOfRows
=
pInput
->
numOfRows
;
SSumRes
*
pSum
=
(
SSumRes
*
)
pCtx
->
pOutput
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
pCtx
->
inputType
))
{
if
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_TINYINT
)
{
LIST_ADD_N
(
pSum
->
isum
,
pCol
,
start
,
numOfRows
,
int8_t
,
numOfElem
);
}
else
if
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_SMALLINT
)
{
LIST_ADD_N
(
pSum
->
isum
,
pCol
,
start
,
numOfRows
,
int16_t
,
numOfElem
);
}
else
if
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_INT
)
{
LIST_ADD_N
(
pSum
->
isum
,
pCol
,
start
,
numOfRows
,
int32_t
,
numOfElem
);
}
else
if
(
pCtx
->
inputType
==
TSDB_DATA_TYPE_BIGINT
)
{
LIST_ADD_N
(
pSum
->
isum
,
pCol
,
start
,
numOfRows
,
int64_t
,
numOfElem
);
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
if
(
type
==
TSDB_DATA_TYPE_TINYINT
)
{
LIST_ADD_N
(
pSumRes
->
isum
,
pCol
,
start
,
numOfRows
,
int8_t
,
numOfElem
);
}
else
if
(
type
==
TSDB_DATA_TYPE_SMALLINT
)
{
LIST_ADD_N
(
pSumRes
->
isum
,
pCol
,
start
,
numOfRows
,
int16_t
,
numOfElem
);
}
else
if
(
type
==
TSDB_DATA_TYPE_INT
)
{
LIST_ADD_N
(
pSumRes
->
isum
,
pCol
,
start
,
numOfRows
,
int32_t
,
numOfElem
);
}
else
if
(
type
==
TSDB_DATA_TYPE_BIGINT
)
{
LIST_ADD_N
(
pSumRes
->
isum
,
pCol
,
start
,
numOfRows
,
int64_t
,
numOfElem
);
}
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
pCtx
->
inputT
ype
))
{
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_UTINYINT
)
{
LIST_ADD_N
(
pSum
->
usum
,
pCol
,
start
,
numOfRows
,
uint8_t
,
numOfElem
);
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_USMALLINT
)
{
LIST_ADD_N
(
pSum
->
usum
,
pCol
,
start
,
numOfRows
,
uint16_t
,
numOfElem
);
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_UINT
)
{
LIST_ADD_N
(
pSum
->
usum
,
pCol
,
start
,
numOfRows
,
uint32_t
,
numOfElem
);
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_UBIGINT
)
{
LIST_ADD_N
(
pSum
->
usum
,
pCol
,
start
,
numOfRows
,
uint64_t
,
numOfElem
);
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
t
ype
))
{
if
(
t
ype
==
TSDB_DATA_TYPE_UTINYINT
)
{
LIST_ADD_N
(
pSum
Res
->
usum
,
pCol
,
start
,
numOfRows
,
uint8_t
,
numOfElem
);
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_USMALLINT
)
{
LIST_ADD_N
(
pSum
Res
->
usum
,
pCol
,
start
,
numOfRows
,
uint16_t
,
numOfElem
);
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_UINT
)
{
LIST_ADD_N
(
pSum
Res
->
usum
,
pCol
,
start
,
numOfRows
,
uint32_t
,
numOfElem
);
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_UBIGINT
)
{
LIST_ADD_N
(
pSum
Res
->
usum
,
pCol
,
start
,
numOfRows
,
uint64_t
,
numOfElem
);
}
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_DOUBLE
)
{
LIST_ADD_N
(
pSum
->
dsum
,
pCol
,
start
,
numOfRows
,
double
,
numOfElem
);
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_FLOAT
)
{
LIST_ADD_N
(
pSum
->
dsum
,
pCol
,
start
,
numOfRows
,
float
,
numOfElem
);
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_DOUBLE
)
{
LIST_ADD_N
(
pSum
Res
->
dsum
,
pCol
,
start
,
numOfRows
,
double
,
numOfElem
);
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_FLOAT
)
{
LIST_ADD_N
(
pSum
Res
->
dsum
,
pCol
,
start
,
numOfRows
,
float
,
numOfElem
);
}
}
...
...
@@ -179,14 +178,13 @@ bool getSumFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv) {
return
true
;
}
bool
maxFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
)
{
if
(
!
functionSetup
(
pCtx
,
pResultInfo
))
{
return
false
;
}
char
*
buf
=
GET_ROWCELL_INTERBUF
(
pResultInfo
);
switch
(
pCtx
->
input
.
pData
[
0
]
->
i
nfo
.
type
)
{
switch
(
pCtx
->
resDataI
nfo
.
type
)
{
case
TSDB_DATA_TYPE_INT
:
*
((
int32_t
*
)
buf
)
=
INT32_MIN
;
break
;
...
...
@@ -229,7 +227,7 @@ bool minFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo) {
}
char
*
buf
=
GET_ROWCELL_INTERBUF
(
pResultInfo
);
switch
(
pCtx
->
input
.
pData
[
0
]
->
i
nfo
.
type
)
{
switch
(
pCtx
->
resDataI
nfo
.
type
)
{
case
TSDB_DATA_TYPE_TINYINT
:
*
((
int8_t
*
)
buf
)
=
INT8_MAX
;
break
;
...
...
@@ -374,13 +372,13 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
__ctx
->
fpSet
.
process
(
__ctx
);
}
}
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
pCtx
->
inputT
ype
))
{
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
t
ype
))
{
uint64_t
val
=
GET_UINT64_VAL
(
tval
);
UPDATE_DATA
(
pCtx
,
*
(
uint64_t
*
)
buf
,
val
,
numOfElems
,
isMinFunc
,
key
);
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_DOUBLE
)
{
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_DOUBLE
)
{
double
val
=
GET_DOUBLE_VAL
(
tval
);
UPDATE_DATA
(
pCtx
,
*
(
double
*
)
buf
,
val
,
numOfElems
,
isMinFunc
,
key
);
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_FLOAT
)
{
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_FLOAT
)
{
double
val
=
GET_DOUBLE_VAL
(
tval
);
UPDATE_DATA
(
pCtx
,
*
(
float
*
)
buf
,
(
float
)
val
,
numOfElems
,
isMinFunc
,
key
);
}
...
...
@@ -391,14 +389,14 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
int32_t
start
=
pInput
->
startRowIndex
;
int32_t
numOfRows
=
pInput
->
numOfRows
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
pCtx
->
inputT
ype
))
{
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_TINYINT
)
{
LOOPCHECK_N
(
*
(
int
64
_t
*
)
buf
,
pCol
,
pCtx
,
int8_t
,
numOfRows
,
start
,
isMinFunc
,
numOfElems
);
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_SMALLINT
)
{
LOOPCHECK_N
(
*
(
int
64
_t
*
)
buf
,
pCol
,
pCtx
,
int16_t
,
numOfRows
,
start
,
isMinFunc
,
numOfElems
);
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_INT
)
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
t
ype
))
{
if
(
t
ype
==
TSDB_DATA_TYPE_TINYINT
)
{
LOOPCHECK_N
(
*
(
int
8
_t
*
)
buf
,
pCol
,
pCtx
,
int8_t
,
numOfRows
,
start
,
isMinFunc
,
numOfElems
);
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_SMALLINT
)
{
LOOPCHECK_N
(
*
(
int
16
_t
*
)
buf
,
pCol
,
pCtx
,
int16_t
,
numOfRows
,
start
,
isMinFunc
,
numOfElems
);
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_INT
)
{
int32_t
*
pData
=
(
int32_t
*
)
pCol
->
pData
;
int
64_t
*
val
=
(
int64
_t
*
)
buf
;
int
32_t
*
val
=
(
int32
_t
*
)
buf
;
for
(
int32_t
i
=
0
;
i
<
pCtx
->
size
;
++
i
)
{
if
((
pCol
->
hasNull
)
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
...
...
@@ -417,22 +415,22 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
#if defined(_DEBUG_VIEW)
qDebug
(
"max value updated:%d"
,
*
retVal
);
#endif
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_BIGINT
)
{
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_BIGINT
)
{
LOOPCHECK_N
(
*
(
int64_t
*
)
buf
,
pCol
,
pCtx
,
int64_t
,
numOfRows
,
start
,
isMinFunc
,
numOfElems
);
}
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
pCtx
->
inputT
ype
))
{
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_UTINYINT
)
{
LOOPCHECK_N
(
*
(
uint
64
_t
*
)
buf
,
pCol
,
pCtx
,
uint8_t
,
numOfRows
,
start
,
isMinFunc
,
numOfElems
);
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_USMALLINT
)
{
LOOPCHECK_N
(
*
(
uint
64
_t
*
)
buf
,
pCol
,
pCtx
,
uint16_t
,
numOfRows
,
start
,
isMinFunc
,
numOfElems
);
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_UINT
)
{
LOOPCHECK_N
(
*
(
uint
64
_t
*
)
buf
,
pCol
,
pCtx
,
uint32_t
,
numOfRows
,
start
,
isMinFunc
,
numOfElems
);
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_UBIGINT
)
{
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
t
ype
))
{
if
(
t
ype
==
TSDB_DATA_TYPE_UTINYINT
)
{
LOOPCHECK_N
(
*
(
uint
8
_t
*
)
buf
,
pCol
,
pCtx
,
uint8_t
,
numOfRows
,
start
,
isMinFunc
,
numOfElems
);
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_USMALLINT
)
{
LOOPCHECK_N
(
*
(
uint
16
_t
*
)
buf
,
pCol
,
pCtx
,
uint16_t
,
numOfRows
,
start
,
isMinFunc
,
numOfElems
);
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_UINT
)
{
LOOPCHECK_N
(
*
(
uint
32
_t
*
)
buf
,
pCol
,
pCtx
,
uint32_t
,
numOfRows
,
start
,
isMinFunc
,
numOfElems
);
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_UBIGINT
)
{
LOOPCHECK_N
(
*
(
uint64_t
*
)
buf
,
pCol
,
pCtx
,
uint64_t
,
numOfRows
,
start
,
isMinFunc
,
numOfElems
);
}
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_DOUBLE
)
{
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_DOUBLE
)
{
LOOPCHECK_N
(
*
(
double
*
)
buf
,
pCol
,
pCtx
,
double
,
numOfRows
,
start
,
isMinFunc
,
numOfElems
);
}
else
if
(
pCtx
->
inputT
ype
==
TSDB_DATA_TYPE_FLOAT
)
{
}
else
if
(
t
ype
==
TSDB_DATA_TYPE_FLOAT
)
{
LOOPCHECK_N
(
*
(
float
*
)
buf
,
pCol
,
pCtx
,
float
,
numOfRows
,
start
,
isMinFunc
,
numOfElems
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录