Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c4b3da50
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看板
提交
c4b3da50
编写于
10月 13, 2022
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more code format
上级
c79cc7e4
变更
17
展开全部
显示空白变更内容
内联
并排
Showing
17 changed file
with
574 addition
and
623 deletion
+574
-623
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+81
-81
source/libs/function/inc/tfunctionInt.h
source/libs/function/inc/tfunctionInt.h
+5
-5
source/libs/function/inc/thistogram.h
source/libs/function/inc/thistogram.h
+8
-8
source/libs/function/inc/tpercentile.h
source/libs/function/inc/tpercentile.h
+3
-3
source/libs/function/inc/tscript.h
source/libs/function/inc/tscript.h
+4
-4
source/libs/function/inc/tudfInt.h
source/libs/function/inc/tudfInt.h
+16
-18
source/libs/function/inc/udfc.h
source/libs/function/inc/udfc.h
+37
-41
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+4
-3
source/libs/function/src/tfunctionInt.c
source/libs/function/src/tfunctionInt.c
+7
-11
source/libs/function/src/thistogram.c
source/libs/function/src/thistogram.c
+7
-7
source/libs/function/src/tpercentile.c
source/libs/function/src/tpercentile.c
+79
-80
source/libs/function/src/tscript.c
source/libs/function/src/tscript.c
+2
-2
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+292
-322
source/libs/function/test/runUdf.c
source/libs/function/test/runUdf.c
+6
-7
source/libs/function/test/udf1.c
source/libs/function/test/udf1.c
+8
-13
source/libs/function/test/udf2.c
source/libs/function/test/udf2.c
+12
-17
tools/scripts/codeFormat.sh
tools/scripts/codeFormat.sh
+3
-1
未找到文件。
source/libs/function/inc/builtinsimpl.h
浏览文件 @
c4b3da50
...
@@ -28,32 +28,32 @@ bool dummyInit(SqlFunctionCtx* UNUSED_PARAM(pCtx), SResultRowEntryInfo* UNUSED_P
...
@@ -28,32 +28,32 @@ bool dummyInit(SqlFunctionCtx* UNUSED_PARAM(pCtx), SResultRowEntryInfo* UNUSED_P
int32_t
dummyProcess
(
SqlFunctionCtx
*
UNUSED_PARAM
(
pCtx
));
int32_t
dummyProcess
(
SqlFunctionCtx
*
UNUSED_PARAM
(
pCtx
));
int32_t
dummyFinalize
(
SqlFunctionCtx
*
UNUSED_PARAM
(
pCtx
),
SSDataBlock
*
UNUSED_PARAM
(
pBlock
));
int32_t
dummyFinalize
(
SqlFunctionCtx
*
UNUSED_PARAM
(
pCtx
),
SSDataBlock
*
UNUSED_PARAM
(
pBlock
));
bool
functionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
functionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
functionFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
functionFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
functionFinalizeWithResultBuf
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
char
*
finalResult
);
int32_t
functionFinalizeWithResultBuf
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
char
*
finalResult
);
int32_t
combineFunction
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
int32_t
combineFunction
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
EFuncDataRequired
countDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
);
EFuncDataRequired
countDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
);
bool
getCountFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getCountFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
int32_t
countFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
countFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
countInvertFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
countInvertFunction
(
SqlFunctionCtx
*
pCtx
);
EFuncDataRequired
statisDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
);
EFuncDataRequired
statisDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
);
bool
getSumFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getSumFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
int32_t
sumFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
sumFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
sumInvertFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
sumInvertFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
sumCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
int32_t
sumCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
bool
minmaxFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
minmaxFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
getMinmaxFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getMinmaxFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
int32_t
minFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
minFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
maxFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
maxFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
minmaxFunctionFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
minmaxFunctionFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
minCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
int32_t
minCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
int32_t
maxCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
int32_t
maxCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
bool
getAvgFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getAvgFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
avgFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
avgFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
avgFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
avgFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
avgFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
avgFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
avgFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
avgFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
...
@@ -63,7 +63,7 @@ int32_t avgCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
...
@@ -63,7 +63,7 @@ int32_t avgCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
int32_t
getAvgInfoSize
();
int32_t
getAvgInfoSize
();
bool
getStddevFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getStddevFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
stddevFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
stddevFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
stddevFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
stddevFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
stddevFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
stddevFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
stddevFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
stddevFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
...
@@ -73,20 +73,20 @@ int32_t stddevCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
...
@@ -73,20 +73,20 @@ int32_t stddevCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
int32_t
getStddevInfoSize
();
int32_t
getStddevInfoSize
();
bool
getLeastSQRFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getLeastSQRFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
leastSQRFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
leastSQRFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
leastSQRFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
leastSQRFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
leastSQRFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
leastSQRFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
leastSQRInvertFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
leastSQRInvertFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
leastSQRCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
int32_t
leastSQRCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
bool
getPercentileFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getPercentileFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
percentileFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
percentileFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
percentileFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
percentileFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
percentileFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
percentileFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getApercentileFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getApercentileFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
apercentileFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
apercentileFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
apercentileFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
apercentileFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
apercentileFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
apercentileFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
apercentileFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
apercentileFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
apercentilePartialFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
apercentilePartialFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
...
@@ -94,25 +94,25 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx)
...
@@ -94,25 +94,25 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx)
int32_t
getApercentileMaxSize
();
int32_t
getApercentileMaxSize
();
bool
getDiffFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getDiffFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
diffFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
bool
diffFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
int32_t
diffFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
diffFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getDerivativeFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getDerivativeFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
derivativeFuncSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
bool
derivativeFuncSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
int32_t
derivativeFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
derivativeFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getIrateFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getIrateFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
irateFuncSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
bool
irateFuncSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResInfo
);
int32_t
irateFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
irateFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
irateFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
irateFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
cachedLastRowFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
cachedLastRowFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getFirstLastFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getFirstLastFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
int32_t
firstFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
firstFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
firstFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
firstFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
lastFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
lastFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
lastFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
lastFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
firstLastFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
firstLastFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
firstLastPartialFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
firstLastPartialFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
firstCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
int32_t
firstCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
...
@@ -120,15 +120,15 @@ int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
...
@@ -120,15 +120,15 @@ int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
int32_t
getFirstLastInfoSize
(
int32_t
resBytes
);
int32_t
getFirstLastInfoSize
(
int32_t
resBytes
);
EFuncDataRequired
lastDynDataReq
(
void
*
pRes
,
STimeWindow
*
pTimeWindow
);
EFuncDataRequired
lastDynDataReq
(
void
*
pRes
,
STimeWindow
*
pTimeWindow
);
int32_t
lastRowFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
lastRowFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getTopBotFuncEnv
(
SFunctionNode
*
UNUSED_PARAM
(
pFunc
),
SFuncExecEnv
*
pEnv
);
bool
getTopBotFuncEnv
(
SFunctionNode
*
UNUSED_PARAM
(
pFunc
),
SFuncExecEnv
*
pEnv
);
bool
getTopBotMergeFuncEnv
(
SFunctionNode
*
UNUSED_PARAM
(
pFunc
),
SFuncExecEnv
*
pEnv
);
bool
getTopBotMergeFuncEnv
(
SFunctionNode
*
UNUSED_PARAM
(
pFunc
),
SFuncExecEnv
*
pEnv
);
bool
topBotFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
topBotFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
topFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
topFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
topFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
topFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
bottomFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
bottomFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
bottomFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
bottomFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
topBotFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
topBotFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
topBotPartialFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
topBotPartialFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
topBotMergeFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
topBotMergeFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
...
@@ -137,7 +137,7 @@ int32_t bottomCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
...
@@ -137,7 +137,7 @@ int32_t bottomCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx);
int32_t
getTopBotInfoSize
(
int64_t
numOfItems
);
int32_t
getTopBotInfoSize
(
int64_t
numOfItems
);
bool
getSpreadFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getSpreadFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
spreadFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
spreadFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
spreadFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
spreadFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
spreadFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
spreadFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
spreadFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
spreadFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
...
@@ -146,7 +146,7 @@ int32_t getSpreadInfoSize();
...
@@ -146,7 +146,7 @@ int32_t getSpreadInfoSize();
int32_t
spreadCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
int32_t
spreadCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
bool
getElapsedFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getElapsedFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
elapsedFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
elapsedFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
elapsedFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
elapsedFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
elapsedFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
elapsedFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
elapsedFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
elapsedFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
...
@@ -155,7 +155,7 @@ int32_t getElapsedInfoSize();
...
@@ -155,7 +155,7 @@ int32_t getElapsedInfoSize();
int32_t
elapsedCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
int32_t
elapsedCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
bool
getHistogramFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getHistogramFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
histogramFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
histogramFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
histogramFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
histogramFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
histogramFunctionPartial
(
SqlFunctionCtx
*
pCtx
);
int32_t
histogramFunctionPartial
(
SqlFunctionCtx
*
pCtx
);
int32_t
histogramFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
int32_t
histogramFunctionMerge
(
SqlFunctionCtx
*
pCtx
);
...
@@ -173,7 +173,7 @@ int32_t getHLLInfoSize();
...
@@ -173,7 +173,7 @@ int32_t getHLLInfoSize();
int32_t
hllCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
int32_t
hllCombine
(
SqlFunctionCtx
*
pDestCtx
,
SqlFunctionCtx
*
pSourceCtx
);
bool
getStateFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getStateFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
stateFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
stateFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
stateCountFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
stateCountFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
stateDurationFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
stateDurationFunction
(
SqlFunctionCtx
*
pCtx
);
...
@@ -181,36 +181,36 @@ bool getCsumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
...
@@ -181,36 +181,36 @@ bool getCsumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv);
int32_t
csumFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
csumFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getMavgFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getMavgFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
mavgFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
mavgFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
mavgFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
mavgFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getSampleFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getSampleFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
sampleFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
sampleFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
sampleFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
sampleFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
sampleFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
sampleFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getTailFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getTailFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
tailFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
tailFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
tailFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
tailFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getUniqueFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getUniqueFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
uniqueFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
uniqueFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
uniqueFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
uniqueFunction
(
SqlFunctionCtx
*
pCtx
);
bool
getModeFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getModeFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
modeFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
modeFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
modeFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
modeFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
modeFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
modeFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getTwaFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getTwaFuncEnv
(
struct
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
twaFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
twaFunctionSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
twaFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
twaFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
twaFinalize
(
struct
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
twaFinalize
(
struct
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getSelectivityFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getSelectivityFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
blockDistSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
bool
blockDistSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
blockDistFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
blockDistFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
blockDistFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
blockDistFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getGroupKeyFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getGroupKeyFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
...
...
source/libs/function/inc/tfunctionInt.h
浏览文件 @
c4b3da50
...
@@ -22,11 +22,11 @@ extern "C" {
...
@@ -22,11 +22,11 @@ extern "C" {
#include "os.h"
#include "os.h"
#include "tname.h"
#include "taosdef.h"
#include "tvariant.h"
#include "function.h"
#include "function.h"
#include "taosdef.h"
#include "tname.h"
#include "tudf.h"
#include "tudf.h"
#include "tvariant.h"
bool
topbot_datablock_filter
(
SqlFunctionCtx
*
pCtx
,
const
char
*
minval
,
const
char
*
maxval
);
bool
topbot_datablock_filter
(
SqlFunctionCtx
*
pCtx
,
const
char
*
minval
,
const
char
*
maxval
);
...
...
source/libs/function/inc/thistogram.h
浏览文件 @
c4b3da50
source/libs/function/inc/tpercentile.h
浏览文件 @
c4b3da50
...
@@ -61,10 +61,10 @@ typedef struct tMemBucket {
...
@@ -61,10 +61,10 @@ typedef struct tMemBucket {
MinMaxEntry
range
;
// value range
MinMaxEntry
range
;
// value range
int32_t
times
;
// count that has been checked for deciding the correct data value buckets.
int32_t
times
;
// count that has been checked for deciding the correct data value buckets.
__compar_fn_t
comparFn
;
__compar_fn_t
comparFn
;
tMemBucketSlot
*
pSlots
;
tMemBucketSlot
*
pSlots
;
SDiskbasedBuf
*
pBuffer
;
SDiskbasedBuf
*
pBuffer
;
__perc_hash_func_t
hashFunc
;
__perc_hash_func_t
hashFunc
;
SHashObj
*
groupPagesMap
;
// disk page map for different groups;
SHashObj
*
groupPagesMap
;
// disk page map for different groups;
}
tMemBucket
;
}
tMemBucket
;
tMemBucket
*
tMemBucketCreate
(
int16_t
nElemSize
,
int16_t
dataType
,
double
minval
,
double
maxval
);
tMemBucket
*
tMemBucketCreate
(
int16_t
nElemSize
,
int16_t
dataType
,
double
minval
,
double
maxval
);
...
...
source/libs/function/inc/tscript.h
浏览文件 @
c4b3da50
...
@@ -17,14 +17,14 @@
...
@@ -17,14 +17,14 @@
#define TDENGINE_QSCRIPT_H
#define TDENGINE_QSCRIPT_H
#if 0
#if 0
#include <lua.h>
#include <lauxlib.h>
#include <lauxlib.h>
#include <lua.h>
#include <lualib.h>
#include <lualib.h>
#include "tutil.h"
#include "hash.h"
#include "hash.h"
#include "tlist.h"
#include "tlist.h"
#include "tudf.h"
#include "tudf.h"
#include "tutil.h"
#define MAX_FUNC_NAME 64
#define MAX_FUNC_NAME 64
...
@@ -81,4 +81,4 @@ void scriptEnvPoolCleanup();
...
@@ -81,4 +81,4 @@ void scriptEnvPoolCleanup();
bool isValidScript(char *script, int32_t len);
bool isValidScript(char *script, int32_t len);
#endif
#endif
#endif
//TDENGINE_QSCRIPT_H
#endif
// TDENGINE_QSCRIPT_H
source/libs/function/inc/tudfInt.h
浏览文件 @
c4b3da50
...
@@ -61,12 +61,10 @@ typedef struct SUdfCallResponse {
...
@@ -61,12 +61,10 @@ typedef struct SUdfCallResponse {
SUdfInterBuf
resultBuf
;
SUdfInterBuf
resultBuf
;
}
SUdfCallResponse
;
}
SUdfCallResponse
;
typedef
struct
SUdfTeardownRequest
{
typedef
struct
SUdfTeardownRequest
{
int64_t
udfHandle
;
int64_t
udfHandle
;
}
SUdfTeardownRequest
;
}
SUdfTeardownRequest
;
typedef
struct
SUdfTeardownResponse
{
typedef
struct
SUdfTeardownResponse
{
#ifdef WINDOWS
#ifdef WINDOWS
size_t
avoidCompilationErrors
;
size_t
avoidCompilationErrors
;
...
@@ -98,20 +96,20 @@ typedef struct SUdfResponse {
...
@@ -98,20 +96,20 @@ typedef struct SUdfResponse {
};
};
}
SUdfResponse
;
}
SUdfResponse
;
int32_t
encodeUdfRequest
(
void
**
buf
,
const
SUdfRequest
*
request
);
int32_t
encodeUdfRequest
(
void
**
buf
,
const
SUdfRequest
*
request
);
void
*
decodeUdfRequest
(
const
void
*
buf
,
SUdfRequest
*
request
);
void
*
decodeUdfRequest
(
const
void
*
buf
,
SUdfRequest
*
request
);
int32_t
encodeUdfResponse
(
void
**
buf
,
const
SUdfResponse
*
response
);
int32_t
encodeUdfResponse
(
void
**
buf
,
const
SUdfResponse
*
response
);
void
*
decodeUdfResponse
(
const
void
*
buf
,
SUdfResponse
*
response
);
void
*
decodeUdfResponse
(
const
void
*
buf
,
SUdfResponse
*
response
);
void
freeUdfColumnData
(
SUdfColumnData
*
data
,
SUdfColumnMeta
*
meta
);
void
freeUdfColumnData
(
SUdfColumnData
*
data
,
SUdfColumnMeta
*
meta
);
void
freeUdfColumn
(
SUdfColumn
*
col
);
void
freeUdfColumn
(
SUdfColumn
*
col
);
void
freeUdfDataDataBlock
(
SUdfDataBlock
*
block
);
void
freeUdfDataDataBlock
(
SUdfDataBlock
*
block
);
int32_t
convertDataBlockToUdfDataBlock
(
SSDataBlock
*
block
,
SUdfDataBlock
*
udfBlock
);
int32_t
convertDataBlockToUdfDataBlock
(
SSDataBlock
*
block
,
SUdfDataBlock
*
udfBlock
);
int32_t
convertUdfColumnToDataBlock
(
SUdfColumn
*
udfCol
,
SSDataBlock
*
block
);
int32_t
convertUdfColumnToDataBlock
(
SUdfColumn
*
udfCol
,
SSDataBlock
*
block
);
int32_t
getUdfdPipeName
(
char
*
pipeName
,
int32_t
size
);
int32_t
getUdfdPipeName
(
char
*
pipeName
,
int32_t
size
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/libs/function/inc/udfc.h
浏览文件 @
c4b3da50
...
@@ -20,7 +20,7 @@ enum {
...
@@ -20,7 +20,7 @@ enum {
};
};
typedef
struct
SSDataBlock
{
typedef
struct
SSDataBlock
{
char
*
data
;
char
*
data
;
int32_t
size
;
int32_t
size
;
}
SSDataBlock
;
}
SSDataBlock
;
...
@@ -36,9 +36,9 @@ int32_t createUdfdProxy();
...
@@ -36,9 +36,9 @@ int32_t createUdfdProxy();
int32_t
destroyUdfdProxy
();
int32_t
destroyUdfdProxy
();
//int32_t setupUdf(SUdfInfo *udf, int32_t numOfUdfs, UdfcFuncHandle *handles);
//
int32_t setupUdf(SUdfInfo *udf, int32_t numOfUdfs, UdfcFuncHandle *handles);
int32_t
setupUdf
(
SUdfInfo
*
udf
,
UdfcFuncHandle
*
handle
);
int32_t
setupUdf
(
SUdfInfo
*
udf
,
UdfcFuncHandle
*
handle
);
int32_t
callUdf
(
UdfcFuncHandle
handle
,
int8_t
step
,
char
*
state
,
int32_t
stateSize
,
SSDataBlock
input
,
char
**
newstate
,
int32_t
callUdf
(
UdfcFuncHandle
handle
,
int8_t
step
,
char
*
state
,
int32_t
stateSize
,
SSDataBlock
input
,
char
**
newstate
,
int32_t
*
newStateSize
,
SSDataBlock
*
output
);
int32_t
*
newStateSize
,
SSDataBlock
*
output
);
...
@@ -48,7 +48,7 @@ int32_t doTeardownUdf(UdfcFuncHandle handle);
...
@@ -48,7 +48,7 @@ int32_t doTeardownUdf(UdfcFuncHandle handle);
typedef
struct
SUdfSetupRequest
{
typedef
struct
SUdfSetupRequest
{
char
udfName
[
16
];
//
char
udfName
[
16
];
//
int8_t
scriptType
;
// 0:c, 1: lua, 2:js
int8_t
scriptType
;
// 0:c, 1: lua, 2:js
int8_t
udfType
;
//
udaf, udf, udtf
int8_t
udfType
;
//
udaf, udf, udtf
int16_t
pathSize
;
int16_t
pathSize
;
char
*
path
;
char
*
path
;
}
SUdfSetupRequest
;
}
SUdfSetupRequest
;
...
@@ -57,7 +57,6 @@ typedef struct SUdfSetupResponse {
...
@@ -57,7 +57,6 @@ typedef struct SUdfSetupResponse {
int64_t
udfHandle
;
int64_t
udfHandle
;
}
SUdfSetupResponse
;
}
SUdfSetupResponse
;
typedef
struct
SUdfCallRequest
{
typedef
struct
SUdfCallRequest
{
int64_t
udfHandle
;
int64_t
udfHandle
;
int8_t
step
;
int8_t
step
;
...
@@ -69,7 +68,6 @@ typedef struct SUdfCallRequest {
...
@@ -69,7 +68,6 @@ typedef struct SUdfCallRequest {
char
*
state
;
char
*
state
;
}
SUdfCallRequest
;
}
SUdfCallRequest
;
typedef
struct
SUdfCallResponse
{
typedef
struct
SUdfCallResponse
{
int32_t
outputBytes
;
int32_t
outputBytes
;
char
*
output
;
char
*
output
;
...
@@ -77,12 +75,10 @@ typedef struct SUdfCallResponse {
...
@@ -77,12 +75,10 @@ typedef struct SUdfCallResponse {
char
*
newState
;
char
*
newState
;
}
SUdfCallResponse
;
}
SUdfCallResponse
;
typedef
struct
SUdfTeardownRequest
{
typedef
struct
SUdfTeardownRequest
{
int64_t
udfHandle
;
int64_t
udfHandle
;
}
SUdfTeardownRequest
;
}
SUdfTeardownRequest
;
typedef
struct
SUdfTeardownResponse
{
typedef
struct
SUdfTeardownResponse
{
#ifdef WINDOWS
#ifdef WINDOWS
size_t
avoidCompilationErrors
;
size_t
avoidCompilationErrors
;
...
@@ -110,4 +106,4 @@ int32_t decodeRequest(char *buf, int32_t bufLen, SUdfRequest **pRequest);
...
@@ -110,4 +106,4 @@ int32_t decodeRequest(char *buf, int32_t bufLen, SUdfRequest **pRequest);
int32_t
encodeResponse
(
char
**
buf
,
int32_t
*
bufLen
,
SUdfResponse
*
response
);
int32_t
encodeResponse
(
char
**
buf
,
int32_t
*
bufLen
,
SUdfResponse
*
response
);
int32_t
encodeRequest
(
char
**
buf
,
int32_t
*
bufLen
,
SUdfRequest
*
request
);
int32_t
encodeRequest
(
char
**
buf
,
int32_t
*
bufLen
,
SUdfRequest
*
request
);
int32_t
decodeResponse
(
char
*
buf
,
int32_t
bufLen
,
SUdfResponse
**
pResponse
);
int32_t
decodeResponse
(
char
*
buf
,
int32_t
bufLen
,
SUdfResponse
**
pResponse
);
#endif
//
UDF_UDF_H
#endif
//
UDF_UDF_H
source/libs/function/src/builtinsimpl.c
浏览文件 @
c4b3da50
...
@@ -2977,7 +2977,8 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
...
@@ -2977,7 +2977,8 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
firstLastTransferInfo
(
SqlFunctionCtx
*
pCtx
,
SFirstLastRes
*
pInput
,
SFirstLastRes
*
pOutput
,
bool
isFirst
,
int32_t
rowIndex
)
{
static
void
firstLastTransferInfo
(
SqlFunctionCtx
*
pCtx
,
SFirstLastRes
*
pInput
,
SFirstLastRes
*
pOutput
,
bool
isFirst
,
int32_t
rowIndex
)
{
SInputColumnInfoData
*
pColInfo
=
&
pCtx
->
input
;
SInputColumnInfoData
*
pColInfo
=
&
pCtx
->
input
;
if
(
pOutput
->
hasResult
)
{
if
(
pOutput
->
hasResult
)
{
...
...
source/libs/function/src/tfunctionInt.c
浏览文件 @
c4b3da50
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
#include "os.h"
#include "os.h"
#include "taosdef.h"
#include "taosdef.h"
#include "tmsg.h"
#include "thash.h"
#include "thash.h"
#include "tmsg.h"
#include "ttypes.h"
#include "ttypes.h"
#include "function.h"
#include "function.h"
...
@@ -29,15 +29,13 @@
...
@@ -29,15 +29,13 @@
#include "ttszip.h"
#include "ttszip.h"
#include "tudf.h"
#include "tudf.h"
void
cleanupResultRowEntry
(
struct
SResultRowEntryInfo
*
pCell
)
{
void
cleanupResultRowEntry
(
struct
SResultRowEntryInfo
*
pCell
)
{
pCell
->
initialized
=
false
;
}
pCell
->
initialized
=
false
;
}
int32_t
getNumOfResult
(
SqlFunctionCtx
*
pCtx
,
int32_t
num
,
SSDataBlock
*
pResBlock
)
{
int32_t
getNumOfResult
(
SqlFunctionCtx
*
pCtx
,
int32_t
num
,
SSDataBlock
*
pResBlock
)
{
int32_t
maxRows
=
0
;
int32_t
maxRows
=
0
;
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
num
;
++
j
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
&
pCtx
[
j
]);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
&
pCtx
[
j
]);
if
(
pResInfo
!=
NULL
&&
maxRows
<
pResInfo
->
numOfRes
)
{
if
(
pResInfo
!=
NULL
&&
maxRows
<
pResInfo
->
numOfRes
)
{
maxRows
=
pResInfo
->
numOfRes
;
maxRows
=
pResInfo
->
numOfRes
;
}
}
...
@@ -46,12 +44,12 @@ int32_t getNumOfResult(SqlFunctionCtx* pCtx, int32_t num, SSDataBlock* pResBlock
...
@@ -46,12 +44,12 @@ int32_t getNumOfResult(SqlFunctionCtx* pCtx, int32_t num, SSDataBlock* pResBlock
assert
(
maxRows
>=
0
);
assert
(
maxRows
>=
0
);
blockDataEnsureCapacity
(
pResBlock
,
maxRows
);
blockDataEnsureCapacity
(
pResBlock
,
maxRows
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
SColumnInfoData
*
pCol
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
i
);
SColumnInfoData
*
pCol
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
i
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
&
pCtx
[
i
]);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
&
pCtx
[
i
]);
if
(
pResInfo
->
numOfRes
==
0
)
{
if
(
pResInfo
->
numOfRes
==
0
)
{
for
(
int32_t
j
=
0
;
j
<
pResInfo
->
numOfRes
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pResInfo
->
numOfRes
;
++
j
)
{
colDataAppend
(
pCol
,
j
,
NULL
,
true
);
// TODO add set null data api
colDataAppend
(
pCol
,
j
,
NULL
,
true
);
// TODO add set null data api
}
}
}
else
{
}
else
{
...
@@ -70,6 +68,4 @@ bool isRowEntryCompleted(struct SResultRowEntryInfo* pEntry) {
...
@@ -70,6 +68,4 @@ bool isRowEntryCompleted(struct SResultRowEntryInfo* pEntry) {
return
pEntry
->
complete
;
return
pEntry
->
complete
;
}
}
bool
isRowEntryInitialized
(
struct
SResultRowEntryInfo
*
pEntry
)
{
bool
isRowEntryInitialized
(
struct
SResultRowEntryInfo
*
pEntry
)
{
return
pEntry
->
initialized
;
}
return
pEntry
->
initialized
;
}
source/libs/function/src/thistogram.c
浏览文件 @
c4b3da50
...
@@ -14,10 +14,10 @@
...
@@ -14,10 +14,10 @@
*/
*/
#include "os.h"
#include "os.h"
#include "thistogram.h"
#include "taosdef.h"
#include "taosdef.h"
#include "t
msg
.h"
#include "t
histogram
.h"
#include "tlosertree.h"
#include "tlosertree.h"
#include "tmsg.h"
/**
/**
*
*
...
@@ -54,7 +54,7 @@ SHistogramInfo* tHistogramCreateFrom(void* pBuf, int32_t numOfBins) {
...
@@ -54,7 +54,7 @@ SHistogramInfo* tHistogramCreateFrom(void* pBuf, int32_t numOfBins) {
SHistogramInfo
*
pHisto
=
(
SHistogramInfo
*
)
pBuf
;
SHistogramInfo
*
pHisto
=
(
SHistogramInfo
*
)
pBuf
;
pHisto
->
elems
=
(
SHistBin
*
)((
char
*
)
pBuf
+
sizeof
(
SHistogramInfo
));
pHisto
->
elems
=
(
SHistBin
*
)((
char
*
)
pBuf
+
sizeof
(
SHistogramInfo
));
for
(
int32_t
i
=
0
;
i
<
numOfBins
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfBins
;
++
i
)
{
pHisto
->
elems
[
i
].
val
=
-
DBL_MAX
;
pHisto
->
elems
[
i
].
val
=
-
DBL_MAX
;
}
}
...
@@ -357,7 +357,7 @@ void tHistogramDestroy(SHistogramInfo** pHisto) {
...
@@ -357,7 +357,7 @@ void tHistogramDestroy(SHistogramInfo** pHisto) {
}
}
void
tHistogramPrint
(
SHistogramInfo
*
pHisto
)
{
void
tHistogramPrint
(
SHistogramInfo
*
pHisto
)
{
printf
(
"total entries: %d, elements: %"
PRId64
"
\n
"
,
pHisto
->
numOfEntries
,
pHisto
->
numOfElems
);
printf
(
"total entries: %d, elements: %"
PRId64
"
\n
"
,
pHisto
->
numOfEntries
,
pHisto
->
numOfElems
);
#if defined(USE_ARRAYLIST)
#if defined(USE_ARRAYLIST)
for
(
int32_t
i
=
0
;
i
<
pHisto
->
numOfEntries
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pHisto
->
numOfEntries
;
++
i
)
{
printf
(
"%d: (%f, %"
PRId64
")
\n
"
,
i
+
1
,
pHisto
->
elems
[
i
].
val
,
pHisto
->
elems
[
i
].
num
);
printf
(
"%d: (%f, %"
PRId64
")
\n
"
,
i
+
1
,
pHisto
->
elems
[
i
].
val
,
pHisto
->
elems
[
i
].
num
);
...
...
source/libs/function/src/tpercentile.c
浏览文件 @
c4b3da50
...
@@ -14,8 +14,8 @@
...
@@ -14,8 +14,8 @@
*/
*/
#include "taoserror.h"
#include "taoserror.h"
#include "tglobal.h"
#include "tcompare.h"
#include "tcompare.h"
#include "tglobal.h"
#include "taosdef.h"
#include "taosdef.h"
#include "tcompare.h"
#include "tcompare.h"
...
@@ -25,21 +25,20 @@
...
@@ -25,21 +25,20 @@
#define DEFAULT_NUM_OF_SLOT 1024
#define DEFAULT_NUM_OF_SLOT 1024
int32_t
getGroupId
(
int32_t
numOfSlots
,
int32_t
slotIndex
,
int32_t
times
)
{
int32_t
getGroupId
(
int32_t
numOfSlots
,
int32_t
slotIndex
,
int32_t
times
)
{
return
(
times
*
numOfSlots
)
+
slotIndex
;
}
return
(
times
*
numOfSlots
)
+
slotIndex
;
}
static
SFilePage
*
loadDataFromFilePage
(
tMemBucket
*
pMemBucket
,
int32_t
slotIdx
)
{
static
SFilePage
*
loadDataFromFilePage
(
tMemBucket
*
pMemBucket
,
int32_t
slotIdx
)
{
SFilePage
*
buffer
=
(
SFilePage
*
)
taosMemoryCalloc
(
1
,
pMemBucket
->
bytes
*
pMemBucket
->
pSlots
[
slotIdx
].
info
.
size
+
sizeof
(
SFilePage
));
SFilePage
*
buffer
=
(
SFilePage
*
)
taosMemoryCalloc
(
1
,
pMemBucket
->
bytes
*
pMemBucket
->
pSlots
[
slotIdx
].
info
.
size
+
sizeof
(
SFilePage
));
int32_t
groupId
=
getGroupId
(
pMemBucket
->
numOfSlots
,
slotIdx
,
pMemBucket
->
times
);
int32_t
groupId
=
getGroupId
(
pMemBucket
->
numOfSlots
,
slotIdx
,
pMemBucket
->
times
);
SArray
*
pIdList
=
*
(
SArray
**
)
taosHashGet
(
pMemBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
));
SArray
*
pIdList
=
*
(
SArray
**
)
taosHashGet
(
pMemBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
));
int32_t
offset
=
0
;
int32_t
offset
=
0
;
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pIdList
);
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
pIdList
);
++
i
)
{
int32_t
*
pageId
=
taosArrayGet
(
pIdList
,
i
);
int32_t
*
pageId
=
taosArrayGet
(
pIdList
,
i
);
SFilePage
*
pg
=
getBufPage
(
pMemBucket
->
pBuffer
,
*
pageId
);
SFilePage
*
pg
=
getBufPage
(
pMemBucket
->
pBuffer
,
*
pageId
);
memcpy
(
buffer
->
data
+
offset
,
pg
->
data
,
(
size_t
)(
pg
->
num
*
pMemBucket
->
bytes
));
memcpy
(
buffer
->
data
+
offset
,
pg
->
data
,
(
size_t
)(
pg
->
num
*
pMemBucket
->
bytes
));
offset
+=
(
int32_t
)(
pg
->
num
*
pMemBucket
->
bytes
);
offset
+=
(
int32_t
)(
pg
->
num
*
pMemBucket
->
bytes
);
...
@@ -49,7 +48,7 @@ static SFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx)
...
@@ -49,7 +48,7 @@ static SFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx)
return
buffer
;
return
buffer
;
}
}
static
void
resetBoundingBox
(
MinMaxEntry
*
range
,
int32_t
type
)
{
static
void
resetBoundingBox
(
MinMaxEntry
*
range
,
int32_t
type
)
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
range
->
i64MaxVal
=
INT64_MIN
;
range
->
i64MaxVal
=
INT64_MIN
;
range
->
i64MinVal
=
INT64_MAX
;
range
->
i64MinVal
=
INT64_MAX
;
...
@@ -62,17 +61,17 @@ static void resetBoundingBox(MinMaxEntry* range, int32_t type) {
...
@@ -62,17 +61,17 @@ static void resetBoundingBox(MinMaxEntry* range, int32_t type) {
}
}
}
}
static
int32_t
setBoundingBox
(
MinMaxEntry
*
range
,
int16_t
type
,
double
minval
,
double
maxval
)
{
static
int32_t
setBoundingBox
(
MinMaxEntry
*
range
,
int16_t
type
,
double
minval
,
double
maxval
)
{
if
(
minval
>
maxval
)
{
if
(
minval
>
maxval
)
{
return
-
1
;
return
-
1
;
}
}
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
type
))
{
range
->
i64MinVal
=
(
int64_t
)
minval
;
range
->
i64MinVal
=
(
int64_t
)
minval
;
range
->
i64MaxVal
=
(
int64_t
)
maxval
;
range
->
i64MaxVal
=
(
int64_t
)
maxval
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
)){
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
type
))
{
range
->
u64MinVal
=
(
uint64_t
)
minval
;
range
->
u64MinVal
=
(
uint64_t
)
minval
;
range
->
u64MaxVal
=
(
uint64_t
)
maxval
;
range
->
u64MaxVal
=
(
uint64_t
)
maxval
;
}
else
{
}
else
{
range
->
dMinVal
=
minval
;
range
->
dMinVal
=
minval
;
range
->
dMaxVal
=
maxval
;
range
->
dMaxVal
=
maxval
;
...
@@ -81,7 +80,7 @@ static int32_t setBoundingBox(MinMaxEntry* range, int16_t type, double minval, d
...
@@ -81,7 +80,7 @@ static int32_t setBoundingBox(MinMaxEntry* range, int16_t type, double minval, d
return
0
;
return
0
;
}
}
static
void
resetPosInfo
(
SSlotInfo
*
pInfo
)
{
static
void
resetPosInfo
(
SSlotInfo
*
pInfo
)
{
pInfo
->
size
=
0
;
pInfo
->
size
=
0
;
pInfo
->
pageId
=
-
1
;
pInfo
->
pageId
=
-
1
;
pInfo
->
data
=
NULL
;
pInfo
->
data
=
NULL
;
...
@@ -97,11 +96,11 @@ double findOnlyResult(tMemBucket *pMemBucket) {
...
@@ -97,11 +96,11 @@ double findOnlyResult(tMemBucket *pMemBucket) {
}
}
int32_t
groupId
=
getGroupId
(
pMemBucket
->
numOfSlots
,
i
,
pMemBucket
->
times
);
int32_t
groupId
=
getGroupId
(
pMemBucket
->
numOfSlots
,
i
,
pMemBucket
->
times
);
SArray
*
list
=
*
(
SArray
**
)
taosHashGet
(
pMemBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
));
SArray
*
list
=
*
(
SArray
**
)
taosHashGet
(
pMemBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
));
assert
(
list
->
size
==
1
);
assert
(
list
->
size
==
1
);
int32_t
*
pageId
=
taosArrayGet
(
list
,
0
);
int32_t
*
pageId
=
taosArrayGet
(
list
,
0
);
SFilePage
*
pPage
=
getBufPage
(
pMemBucket
->
pBuffer
,
*
pageId
);
SFilePage
*
pPage
=
getBufPage
(
pMemBucket
->
pBuffer
,
*
pageId
);
assert
(
pPage
->
num
==
1
);
assert
(
pPage
->
num
==
1
);
double
v
=
0
;
double
v
=
0
;
...
@@ -155,7 +154,7 @@ int32_t tBucketUintHash(tMemBucket *pBucket, const void *value) {
...
@@ -155,7 +154,7 @@ int32_t tBucketUintHash(tMemBucket *pBucket, const void *value) {
uint64_t
span
=
pBucket
->
range
.
u64MaxVal
-
pBucket
->
range
.
u64MinVal
;
uint64_t
span
=
pBucket
->
range
.
u64MaxVal
-
pBucket
->
range
.
u64MinVal
;
if
(
span
<
pBucket
->
numOfSlots
)
{
if
(
span
<
pBucket
->
numOfSlots
)
{
int64_t
delta
=
v
-
pBucket
->
range
.
u64MinVal
;
int64_t
delta
=
v
-
pBucket
->
range
.
u64MinVal
;
index
=
(
int32_t
)
(
delta
%
pBucket
->
numOfSlots
);
index
=
(
int32_t
)(
delta
%
pBucket
->
numOfSlots
);
}
else
{
}
else
{
double
slotSpan
=
(
double
)
span
/
pBucket
->
numOfSlots
;
double
slotSpan
=
(
double
)
span
/
pBucket
->
numOfSlots
;
index
=
(
int32_t
)((
v
-
pBucket
->
range
.
u64MinVal
)
/
slotSpan
);
index
=
(
int32_t
)((
v
-
pBucket
->
range
.
u64MinVal
)
/
slotSpan
);
...
@@ -209,9 +208,9 @@ static __perc_hash_func_t getHashFunc(int32_t type) {
...
@@ -209,9 +208,9 @@ static __perc_hash_func_t getHashFunc(int32_t type) {
}
}
}
}
static
void
resetSlotInfo
(
tMemBucket
*
pBucket
)
{
static
void
resetSlotInfo
(
tMemBucket
*
pBucket
)
{
for
(
int32_t
i
=
0
;
i
<
pBucket
->
numOfSlots
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pBucket
->
numOfSlots
;
++
i
)
{
tMemBucketSlot
*
pSlot
=
&
pBucket
->
pSlots
[
i
];
tMemBucketSlot
*
pSlot
=
&
pBucket
->
pSlots
[
i
];
resetBoundingBox
(
&
pSlot
->
range
,
pBucket
->
type
);
resetBoundingBox
(
&
pSlot
->
range
,
pBucket
->
type
);
resetPosInfo
(
&
pSlot
->
info
);
resetPosInfo
(
&
pSlot
->
info
);
...
@@ -235,17 +234,17 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval,
...
@@ -235,17 +234,17 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval,
pBucket
->
maxCapacity
=
200000
;
pBucket
->
maxCapacity
=
200000
;
pBucket
->
groupPagesMap
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_NO_LOCK
);
pBucket
->
groupPagesMap
=
taosHashInit
(
128
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_NO_LOCK
);
if
(
setBoundingBox
(
&
pBucket
->
range
,
pBucket
->
type
,
minval
,
maxval
)
!=
0
)
{
if
(
setBoundingBox
(
&
pBucket
->
range
,
pBucket
->
type
,
minval
,
maxval
)
!=
0
)
{
// qError("MemBucket:%p, invalid value range: %f-%f", pBucket, minval, maxval);
// qError("MemBucket:%p, invalid value range: %f-%f", pBucket, minval, maxval);
taosMemoryFree
(
pBucket
);
taosMemoryFree
(
pBucket
);
return
NULL
;
return
NULL
;
}
}
pBucket
->
elemPerPage
=
(
pBucket
->
bufPageSize
-
sizeof
(
SFilePage
))
/
pBucket
->
bytes
;
pBucket
->
elemPerPage
=
(
pBucket
->
bufPageSize
-
sizeof
(
SFilePage
))
/
pBucket
->
bytes
;
pBucket
->
comparFn
=
getKeyComparFunc
(
pBucket
->
type
,
TSDB_ORDER_ASC
);
pBucket
->
comparFn
=
getKeyComparFunc
(
pBucket
->
type
,
TSDB_ORDER_ASC
);
pBucket
->
hashFunc
=
getHashFunc
(
pBucket
->
type
);
pBucket
->
hashFunc
=
getHashFunc
(
pBucket
->
type
);
if
(
pBucket
->
hashFunc
==
NULL
)
{
if
(
pBucket
->
hashFunc
==
NULL
)
{
// qError("MemBucket:%p, not support data type %d, failed", pBucket, pBucket->type);
// qError("MemBucket:%p, not support data type %d, failed", pBucket, pBucket->type);
taosMemoryFree
(
pBucket
);
taosMemoryFree
(
pBucket
);
return
NULL
;
return
NULL
;
}
}
...
@@ -271,7 +270,7 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval,
...
@@ -271,7 +270,7 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval,
return
NULL
;
return
NULL
;
}
}
// qDebug("MemBucket:%p, elem size:%d", pBucket, pBucket->bytes);
// qDebug("MemBucket:%p, elem size:%d", pBucket, pBucket->bytes);
return
pBucket
;
return
pBucket
;
}
}
...
@@ -280,9 +279,9 @@ void tMemBucketDestroy(tMemBucket *pBucket) {
...
@@ -280,9 +279,9 @@ void tMemBucketDestroy(tMemBucket *pBucket) {
return
;
return
;
}
}
void
*
p
=
taosHashIterate
(
pBucket
->
groupPagesMap
,
NULL
);
void
*
p
=
taosHashIterate
(
pBucket
->
groupPagesMap
,
NULL
);
while
(
p
)
{
while
(
p
)
{
SArray
**
p1
=
p
;
SArray
**
p1
=
p
;
p
=
taosHashIterate
(
pBucket
->
groupPagesMap
,
p
);
p
=
taosHashIterate
(
pBucket
->
groupPagesMap
,
p
);
taosArrayDestroy
(
*
p1
);
taosArrayDestroy
(
*
p1
);
}
}
...
@@ -341,7 +340,7 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
...
@@ -341,7 +340,7 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
int32_t
count
=
0
;
int32_t
count
=
0
;
int32_t
bytes
=
pBucket
->
bytes
;
int32_t
bytes
=
pBucket
->
bytes
;
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
char
*
d
=
(
char
*
)
data
+
i
*
bytes
;
char
*
d
=
(
char
*
)
data
+
i
*
bytes
;
int32_t
index
=
(
pBucket
->
hashFunc
)(
pBucket
,
d
);
int32_t
index
=
(
pBucket
->
hashFunc
)(
pBucket
,
d
);
if
(
index
<
0
)
{
if
(
index
<
0
)
{
continue
;
continue
;
...
@@ -365,9 +364,9 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
...
@@ -365,9 +364,9 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) {
pSlot
->
info
.
data
=
NULL
;
pSlot
->
info
.
data
=
NULL
;
}
}
SArray
*
pPageIdList
=
(
SArray
*
)
taosHashGet
(
pBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
));
SArray
*
pPageIdList
=
(
SArray
*
)
taosHashGet
(
pBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
));
if
(
pPageIdList
==
NULL
)
{
if
(
pPageIdList
==
NULL
)
{
SArray
*
pList
=
taosArrayInit
(
4
,
sizeof
(
int32_t
));
SArray
*
pList
=
taosArrayInit
(
4
,
sizeof
(
int32_t
));
taosHashPut
(
pBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
),
&
pList
,
POINTER_BYTES
);
taosHashPut
(
pBucket
->
groupPagesMap
,
&
groupId
,
sizeof
(
groupId
),
&
pList
,
POINTER_BYTES
);
pPageIdList
=
pList
;
pPageIdList
=
pList
;
}
}
...
@@ -407,18 +406,18 @@ static MinMaxEntry getMinMaxEntryOfNextSlotWithData(tMemBucket *pMemBucket, int3
...
@@ -407,18 +406,18 @@ static MinMaxEntry getMinMaxEntryOfNextSlotWithData(tMemBucket *pMemBucket, int3
static
bool
isIdenticalData
(
tMemBucket
*
pMemBucket
,
int32_t
index
);
static
bool
isIdenticalData
(
tMemBucket
*
pMemBucket
,
int32_t
index
);
static
double
getIdenticalDataVal
(
tMemBucket
*
pMemBucket
,
int32_t
slotIndex
)
{
static
double
getIdenticalDataVal
(
tMemBucket
*
pMemBucket
,
int32_t
slotIndex
)
{
assert
(
isIdenticalData
(
pMemBucket
,
slotIndex
));
assert
(
isIdenticalData
(
pMemBucket
,
slotIndex
));
tMemBucketSlot
*
pSlot
=
&
pMemBucket
->
pSlots
[
slotIndex
];
tMemBucketSlot
*
pSlot
=
&
pMemBucket
->
pSlots
[
slotIndex
];
double
finalResult
=
0
.
0
;
double
finalResult
=
0
.
0
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
finalResult
=
(
double
)
pSlot
->
range
.
i64MinVal
;
finalResult
=
(
double
)
pSlot
->
range
.
i64MinVal
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
finalResult
=
(
double
)
pSlot
->
range
.
u64MinVal
;
finalResult
=
(
double
)
pSlot
->
range
.
u64MinVal
;
}
else
{
}
else
{
finalResult
=
(
double
)
pSlot
->
range
.
dMinVal
;
finalResult
=
(
double
)
pSlot
->
range
.
dMinVal
;
}
}
return
finalResult
;
return
finalResult
;
...
@@ -445,14 +444,14 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
...
@@ -445,14 +444,14 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
double
maxOfThisSlot
=
0
;
double
maxOfThisSlot
=
0
;
double
minOfNextSlot
=
0
;
double
minOfNextSlot
=
0
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
maxOfThisSlot
=
(
double
)
pSlot
->
range
.
i64MaxVal
;
maxOfThisSlot
=
(
double
)
pSlot
->
range
.
i64MaxVal
;
minOfNextSlot
=
(
double
)
next
.
i64MinVal
;
minOfNextSlot
=
(
double
)
next
.
i64MinVal
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
maxOfThisSlot
=
(
double
)
pSlot
->
range
.
u64MaxVal
;
maxOfThisSlot
=
(
double
)
pSlot
->
range
.
u64MaxVal
;
minOfNextSlot
=
(
double
)
next
.
u64MinVal
;
minOfNextSlot
=
(
double
)
next
.
u64MinVal
;
}
else
{
}
else
{
maxOfThisSlot
=
(
double
)
pSlot
->
range
.
dMaxVal
;
maxOfThisSlot
=
(
double
)
pSlot
->
range
.
dMaxVal
;
minOfNextSlot
=
(
double
)
next
.
dMinVal
;
minOfNextSlot
=
(
double
)
next
.
dMinVal
;
}
}
assert
(
minOfNextSlot
>
maxOfThisSlot
);
assert
(
minOfNextSlot
>
maxOfThisSlot
);
...
@@ -484,7 +483,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
...
@@ -484,7 +483,7 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction)
// try next round
// try next round
pMemBucket
->
times
+=
1
;
pMemBucket
->
times
+=
1
;
// qDebug("MemBucket:%p, start next round data bucketing, time:%d", pMemBucket, pMemBucket->times);
// qDebug("MemBucket:%p, start next round data bucketing, time:%d", pMemBucket, pMemBucket->times);
pMemBucket
->
range
=
pSlot
->
range
;
pMemBucket
->
range
=
pSlot
->
range
;
pMemBucket
->
total
=
0
;
pMemBucket
->
total
=
0
;
...
@@ -527,7 +526,7 @@ double getPercentile(tMemBucket *pMemBucket, double percent) {
...
@@ -527,7 +526,7 @@ double getPercentile(tMemBucket *pMemBucket, double percent) {
// find the min/max value, no need to scan all data in bucket
// find the min/max value, no need to scan all data in bucket
if
(
fabs
(
percent
-
100
.
0
)
<
DBL_EPSILON
||
(
percent
<
DBL_EPSILON
))
{
if
(
fabs
(
percent
-
100
.
0
)
<
DBL_EPSILON
||
(
percent
<
DBL_EPSILON
))
{
MinMaxEntry
*
pRange
=
&
pMemBucket
->
range
;
MinMaxEntry
*
pRange
=
&
pMemBucket
->
range
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
pMemBucket
->
type
))
{
double
v
=
(
double
)(
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
i64MaxVal
:
pRange
->
i64MinVal
);
double
v
=
(
double
)(
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
i64MaxVal
:
pRange
->
i64MinVal
);
...
@@ -536,7 +535,7 @@ double getPercentile(tMemBucket *pMemBucket, double percent) {
...
@@ -536,7 +535,7 @@ double getPercentile(tMemBucket *pMemBucket, double percent) {
double
v
=
(
double
)(
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
u64MaxVal
:
pRange
->
u64MinVal
);
double
v
=
(
double
)(
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
u64MaxVal
:
pRange
->
u64MinVal
);
return
v
;
return
v
;
}
else
{
}
else
{
return
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
dMaxVal
:
pRange
->
dMinVal
;
return
fabs
(
percent
-
100
)
<
DBL_EPSILON
?
pRange
->
dMaxVal
:
pRange
->
dMinVal
;
}
}
}
}
...
...
source/libs/function/src/tscript.c
浏览文件 @
c4b3da50
...
@@ -13,10 +13,10 @@
...
@@ -13,10 +13,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "os.h"
#include "tscript.h"
#include "tscript.h"
#include "
ttype
s.h"
#include "
o
s.h"
#include "tstrbuild.h"
#include "tstrbuild.h"
#include "ttypes.h"
//#include "queryLog.h"
//#include "queryLog.h"
#include "ttokendef.h"
#include "ttokendef.h"
#if 0
#if 0
...
...
source/libs/function/src/tudf.c
浏览文件 @
c4b3da50
此差异已折叠。
点击以展开。
source/libs/function/test/runUdf.c
浏览文件 @
c4b3da50
...
@@ -53,7 +53,7 @@ int scalarFuncTest() {
...
@@ -53,7 +53,7 @@ int scalarFuncTest() {
blockDataEnsureCapacity
(
pBlock
,
1024
);
blockDataEnsureCapacity
(
pBlock
,
1024
);
pBlock
->
info
.
rows
=
1024
;
pBlock
->
info
.
rows
=
1024
;
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
0
);
SColumnInfoData
*
pCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
0
);
for
(
int32_t
j
=
0
;
j
<
pBlock
->
info
.
rows
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pBlock
->
info
.
rows
;
++
j
)
{
colDataAppendInt32
(
pCol
,
j
,
&
j
);
colDataAppendInt32
(
pCol
,
j
,
&
j
);
}
}
...
@@ -68,14 +68,13 @@ int scalarFuncTest() {
...
@@ -68,14 +68,13 @@ int scalarFuncTest() {
SColumnInfoData
*
col
=
output
.
columnData
;
SColumnInfoData
*
col
=
output
.
columnData
;
for
(
int32_t
i
=
0
;
i
<
output
.
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
output
.
numOfRows
;
++
i
)
{
if
(
i
%
100
==
0
)
if
(
i
%
100
==
0
)
fprintf
(
stderr
,
"%d
\t
%d
\n
"
,
i
,
*
(
int32_t
*
)(
col
->
pData
+
i
*
sizeof
(
int32_t
)));
fprintf
(
stderr
,
"%d
\t
%d
\n
"
,
i
,
*
(
int32_t
*
)(
col
->
pData
+
i
*
sizeof
(
int32_t
)));
}
}
colDataDestroy
(
output
.
columnData
);
colDataDestroy
(
output
.
columnData
);
taosMemoryFree
(
output
.
columnData
);
taosMemoryFree
(
output
.
columnData
);
}
}
int64_t
end
=
taosGetTimestampUs
();
int64_t
end
=
taosGetTimestampUs
();
fprintf
(
stderr
,
"time: %f
\n
"
,
(
end
-
beg
)
/
1000
.
0
);
fprintf
(
stderr
,
"time: %f
\n
"
,
(
end
-
beg
)
/
1000
.
0
);
doTeardownUdf
(
handle
);
doTeardownUdf
(
handle
);
return
0
;
return
0
;
...
@@ -98,7 +97,7 @@ int aggregateFuncTest() {
...
@@ -98,7 +97,7 @@ int aggregateFuncTest() {
blockDataEnsureCapacity
(
pBlock
,
1024
);
blockDataEnsureCapacity
(
pBlock
,
1024
);
pBlock
->
info
.
rows
=
1024
;
pBlock
->
info
.
rows
=
1024
;
SColumnInfoData
*
pColInfo
=
bdGetColumnInfoData
(
pBlock
,
0
);
SColumnInfoData
*
pColInfo
=
bdGetColumnInfoData
(
pBlock
,
0
);
for
(
int32_t
j
=
0
;
j
<
pBlock
->
info
.
rows
;
++
j
)
{
for
(
int32_t
j
=
0
;
j
<
pBlock
->
info
.
rows
;
++
j
)
{
colDataAppendInt32
(
pColInfo
,
j
,
&
j
);
colDataAppendInt32
(
pColInfo
,
j
,
&
j
);
}
}
...
@@ -111,7 +110,7 @@ int aggregateFuncTest() {
...
@@ -111,7 +110,7 @@ int aggregateFuncTest() {
taosArrayDestroy
(
pBlock
->
pDataBlock
);
taosArrayDestroy
(
pBlock
->
pDataBlock
);
doCallUdfAggFinalize
(
handle
,
&
newBuf
,
&
resultBuf
);
doCallUdfAggFinalize
(
handle
,
&
newBuf
,
&
resultBuf
);
fprintf
(
stderr
,
"agg result: %f
\n
"
,
*
(
double
*
)
resultBuf
.
buf
);
fprintf
(
stderr
,
"agg result: %f
\n
"
,
*
(
double
*
)
resultBuf
.
buf
);
freeUdfInterBuf
(
&
buf
);
freeUdfInterBuf
(
&
buf
);
freeUdfInterBuf
(
&
newBuf
);
freeUdfInterBuf
(
&
newBuf
);
...
...
source/libs/function/test/udf1.c
浏览文件 @
c4b3da50
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef LINUX
#ifdef LINUX
#include <unistd.h>
#include <unistd.h>
#endif
#endif
...
@@ -9,16 +9,11 @@
...
@@ -9,16 +9,11 @@
#endif
#endif
#include "taosudf.h"
#include "taosudf.h"
DLL_EXPORT
int32_t
udf1_init
()
{
return
0
;
}
DLL_EXPORT
int32_t
udf1_init
()
{
DLL_EXPORT
int32_t
udf1_destroy
()
{
return
0
;
}
return
0
;
}
DLL_EXPORT
int32_t
udf1_destroy
()
{
return
0
;
}
DLL_EXPORT
int32_t
udf1
(
SUdfDataBlock
*
block
,
SUdfColumn
*
resultCol
)
{
DLL_EXPORT
int32_t
udf1
(
SUdfDataBlock
*
block
,
SUdfColumn
*
resultCol
)
{
SUdfColumnMeta
*
meta
=
&
resultCol
->
colMeta
;
SUdfColumnMeta
*
meta
=
&
resultCol
->
colMeta
;
meta
->
bytes
=
4
;
meta
->
bytes
=
4
;
meta
->
type
=
TSDB_DATA_TYPE_INT
;
meta
->
type
=
TSDB_DATA_TYPE_INT
;
...
@@ -35,12 +30,12 @@ DLL_EXPORT int32_t udf1(SUdfDataBlock* block, SUdfColumn *resultCol) {
...
@@ -35,12 +30,12 @@ DLL_EXPORT int32_t udf1(SUdfDataBlock* block, SUdfColumn *resultCol) {
break
;
break
;
}
}
}
}
if
(
j
==
block
->
numOfCols
)
{
if
(
j
==
block
->
numOfCols
)
{
int32_t
luckyNum
=
88
;
int32_t
luckyNum
=
88
;
udfColDataSet
(
resultCol
,
i
,
(
char
*
)
&
luckyNum
,
false
);
udfColDataSet
(
resultCol
,
i
,
(
char
*
)
&
luckyNum
,
false
);
}
}
}
}
//to simulate actual processing delay by udf
//
to simulate actual processing delay by udf
#ifdef LINUX
#ifdef LINUX
usleep
(
1
*
1000
);
// usleep takes sleep time in us (1 millionth of a second)
usleep
(
1
*
1000
);
// usleep takes sleep time in us (1 millionth of a second)
#endif
#endif
...
...
source/libs/function/test/udf2.c
浏览文件 @
c4b3da50
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "taosudf.h"
#include "taosudf.h"
DLL_EXPORT
int32_t
udf2_init
()
{
DLL_EXPORT
int32_t
udf2_init
()
{
return
0
;
}
return
0
;
}
DLL_EXPORT
int32_t
udf2_destroy
()
{
DLL_EXPORT
int32_t
udf2_destroy
()
{
return
0
;
}
return
0
;
}
DLL_EXPORT
int32_t
udf2_start
(
SUdfInterBuf
*
buf
)
{
DLL_EXPORT
int32_t
udf2_start
(
SUdfInterBuf
*
buf
)
{
*
(
int64_t
*
)(
buf
->
buf
)
=
0
;
*
(
int64_t
*
)(
buf
->
buf
)
=
0
;
buf
->
bufLen
=
sizeof
(
double
);
buf
->
bufLen
=
sizeof
(
double
);
buf
->
numOfResult
=
0
;
buf
->
numOfResult
=
0
;
return
0
;
return
0
;
}
}
DLL_EXPORT
int32_t
udf2
(
SUdfDataBlock
*
block
,
SUdfInterBuf
*
interBuf
,
SUdfInterBuf
*
newInterBuf
)
{
DLL_EXPORT
int32_t
udf2
(
SUdfDataBlock
*
block
,
SUdfInterBuf
*
interBuf
,
SUdfInterBuf
*
newInterBuf
)
{
double
sumSquares
=
*
(
double
*
)
interBuf
->
buf
;
double
sumSquares
=
*
(
double
*
)
interBuf
->
buf
;
int8_t
numNotNull
=
0
;
int8_t
numNotNull
=
0
;
for
(
int32_t
i
=
0
;
i
<
block
->
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
block
->
numOfCols
;
++
i
)
{
SUdfColumn
*
col
=
block
->
udfCols
[
i
];
SUdfColumn
*
col
=
block
->
udfCols
[
i
];
if
(
!
(
col
->
colMeta
.
type
==
TSDB_DATA_TYPE_INT
||
if
(
!
(
col
->
colMeta
.
type
==
TSDB_DATA_TYPE_INT
||
col
->
colMeta
.
type
==
TSDB_DATA_TYPE_DOUBLE
))
{
col
->
colMeta
.
type
==
TSDB_DATA_TYPE_DOUBLE
))
{
return
TSDB_CODE_UDF_INVALID_INPUT
;
return
TSDB_CODE_UDF_INVALID_INPUT
;
}
}
}
}
...
@@ -67,7 +62,7 @@ DLL_EXPORT int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterB
...
@@ -67,7 +62,7 @@ DLL_EXPORT int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterB
return
0
;
return
0
;
}
}
DLL_EXPORT
int32_t
udf2_finish
(
SUdfInterBuf
*
buf
,
SUdfInterBuf
*
resultData
)
{
DLL_EXPORT
int32_t
udf2_finish
(
SUdfInterBuf
*
buf
,
SUdfInterBuf
*
resultData
)
{
if
(
buf
->
numOfResult
==
0
)
{
if
(
buf
->
numOfResult
==
0
)
{
resultData
->
numOfResult
=
0
;
resultData
->
numOfResult
=
0
;
return
0
;
return
0
;
...
...
tools/scripts/codeFormat.sh
浏览文件 @
c4b3da50
...
@@ -16,7 +16,7 @@ FORMAT_DIR_LIST=(
...
@@ -16,7 +16,7 @@ FORMAT_DIR_LIST=(
"
${
PRJ_ROOT_DIR
}
/source/libs/catalog"
"
${
PRJ_ROOT_DIR
}
/source/libs/catalog"
"
${
PRJ_ROOT_DIR
}
/source/libs/command"
"
${
PRJ_ROOT_DIR
}
/source/libs/command"
"
${
PRJ_ROOT_DIR
}
/source/libs/executor"
"
${
PRJ_ROOT_DIR
}
/source/libs/executor"
#
"${PRJ_ROOT_DIR}/source/libs/function"
"
${
PRJ_ROOT_DIR
}
/source/libs/function"
"
${
PRJ_ROOT_DIR
}
/source/libs/index"
"
${
PRJ_ROOT_DIR
}
/source/libs/index"
"
${
PRJ_ROOT_DIR
}
/source/libs/monitor"
"
${
PRJ_ROOT_DIR
}
/source/libs/monitor"
"
${
PRJ_ROOT_DIR
}
/source/libs/nodes"
"
${
PRJ_ROOT_DIR
}
/source/libs/nodes"
...
@@ -49,3 +49,5 @@ for d in ${FORMAT_DIR_LIST[@]}; do
...
@@ -49,3 +49,5 @@ for d in ${FORMAT_DIR_LIST[@]}; do
done
done
cd
${
ORIGIN_DIR
}
cd
${
ORIGIN_DIR
}
# find source/libs/ -path ./source/libs/qworker -prune -o -regex '.*\.\(cpp\|hpp\|c\|h\)' -print
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录