Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Tonvia
TDengine
提交
afc8b5a3
T
TDengine
项目概览
Tonvia
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
afc8b5a3
编写于
5月 23, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225]refactor codes
上级
5bc55638
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
9 addition
and
14 deletion
+9
-14
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+6
-10
src/query/inc/tsqlfunction.h
src/query/inc/tsqlfunction.h
+0
-2
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+3
-2
未找到文件。
src/client/src/tscFunctionImpl.c
浏览文件 @
afc8b5a3
...
...
@@ -396,10 +396,6 @@ static void function_finalizer(SQLFunctionCtx *pCtx) {
doFinalizer
(
pCtx
);
}
static
bool
usePreVal
(
SQLFunctionCtx
*
pCtx
)
{
return
pCtx
->
preAggVals
.
isSet
&&
pCtx
->
size
==
pCtx
->
preAggVals
.
size
;
}
/*
* count function does need the finalize, if data is missing, the default value, which is 0, is used
* count function does not use the pCtx->interResBuf to keep the intermediate buffer
...
...
@@ -412,7 +408,7 @@ static void count_function(SQLFunctionCtx *pCtx) {
* 2. for general non-primary key columns, pCtx->hasNull may be true or false, pCtx->preAggVals.isSet == true;
* 3. for primary key column, pCtx->hasNull always be false, pCtx->preAggVals.isSet == false;
*/
if
(
usePreVal
(
pCtx
)
)
{
if
(
pCtx
->
preAggVals
.
isSet
)
{
numOfElem
=
pCtx
->
size
-
pCtx
->
preAggVals
.
statis
.
numOfNull
;
}
else
{
if
(
pCtx
->
hasNull
)
{
...
...
@@ -537,7 +533,7 @@ static void do_sum(SQLFunctionCtx *pCtx) {
int32_t
notNullElems
=
0
;
// Only the pre-computing information loaded and actual data does not loaded
if
(
pCtx
->
preAggVals
.
isSet
&&
pCtx
->
preAggVals
.
size
==
pCtx
->
size
)
{
if
(
pCtx
->
preAggVals
.
isSet
)
{
notNullElems
=
pCtx
->
size
-
pCtx
->
preAggVals
.
statis
.
numOfNull
;
assert
(
pCtx
->
size
>=
pCtx
->
preAggVals
.
statis
.
numOfNull
);
...
...
@@ -768,7 +764,7 @@ static void avg_function(SQLFunctionCtx *pCtx) {
SAvgInfo
*
pAvgInfo
=
(
SAvgInfo
*
)
pResInfo
->
interResultBuf
;
double
*
pVal
=
&
pAvgInfo
->
sum
;
if
(
usePreVal
(
pCtx
)
)
{
if
(
pCtx
->
preAggVals
.
isSet
)
{
// Pre-aggregation
notNullElems
=
pCtx
->
size
-
pCtx
->
preAggVals
.
statis
.
numOfNull
;
assert
(
notNullElems
>=
0
);
...
...
@@ -932,7 +928,7 @@ static void avg_finalizer(SQLFunctionCtx *pCtx) {
static
void
minMax_function
(
SQLFunctionCtx
*
pCtx
,
char
*
pOutput
,
int32_t
isMin
,
int32_t
*
notNullElems
)
{
// data in current data block are qualified to the query
if
(
usePreVal
(
pCtx
)
)
{
if
(
pCtx
->
preAggVals
.
isSet
)
{
*
notNullElems
=
pCtx
->
size
-
pCtx
->
preAggVals
.
statis
.
numOfNull
;
assert
(
*
notNullElems
>=
0
);
...
...
@@ -2916,7 +2912,7 @@ static void leastsquares_finalizer(SQLFunctionCtx *pCtx) {
}
static
void
date_col_output_function
(
SQLFunctionCtx
*
pCtx
)
{
if
(
pCtx
->
scanFlag
==
REVERSE_SCAN
)
{
if
(
pCtx
->
scanFlag
==
REVERSE_SCAN
)
{
// todo : remove it
return
;
}
...
...
@@ -3423,7 +3419,7 @@ static void spread_function(SQLFunctionCtx *pCtx) {
// todo : opt with pre-calculated result
// column missing cause the hasNull to be true
if
(
usePreVal
(
pCtx
)
)
{
if
(
pCtx
->
preAggVals
.
isSet
)
{
numOfElems
=
pCtx
->
size
-
pCtx
->
preAggVals
.
statis
.
numOfNull
;
// all data are null in current data block, ignore current data block
...
...
src/query/inc/tsqlfunction.h
浏览文件 @
afc8b5a3
...
...
@@ -126,7 +126,6 @@ typedef struct SArithmeticSupport {
typedef
struct
SQLPreAggVal
{
bool
isSet
;
int32_t
size
;
SDataStatis
statis
;
}
SQLPreAggVal
;
...
...
@@ -174,7 +173,6 @@ typedef struct SQLFunctionCtx {
int16_t
outputBytes
;
// size of results, determined by function and input column data type
bool
hasNull
;
// null value exist in current block
int16_t
functionId
;
// function id
int32_t
blockStatus
;
// Indicate if data is loaded, it is first/last/internal block. Only for file blocks
void
*
aInputElemBuf
;
char
*
aOutputBuf
;
// final result output buffer, point to sdata->data
uint8_t
currentStage
;
// record current running step, default: 0
...
...
src/query/src/qExecutor.c
浏览文件 @
afc8b5a3
...
...
@@ -1342,14 +1342,13 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void *inputData, TSKEY
if
(
pStatis
!=
NULL
)
{
pCtx
->
preAggVals
.
isSet
=
true
;
pCtx
->
preAggVals
.
size
=
size
;
pCtx
->
preAggVals
.
statis
=
*
pStatis
;
}
else
{
pCtx
->
preAggVals
.
isSet
=
false
;
}
pCtx
->
startOffset
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
pQuery
->
pos
:
0
;
pCtx
->
size
=
QUERY_IS_ASC_QUERY
(
pQuery
)
?
size
-
pQuery
->
pos
:
pQuery
->
pos
+
1
;
pCtx
->
size
=
size
;
uint32_t
status
=
aAggs
[
functionId
].
nStatus
;
if
(((
status
&
(
TSDB_FUNCSTATE_SELECTIVITY
|
TSDB_FUNCSTATE_NEED_TS
))
!=
0
)
&&
(
tsCol
!=
NULL
))
{
...
...
@@ -1377,6 +1376,8 @@ void setExecParams(SQuery *pQuery, SQLFunctionCtx *pCtx, void *inputData, TSKEY
}
else
if
(
functionId
==
TSDB_FUNC_ARITHM
)
{
pCtx
->
param
[
1
].
pz
=
param
;
}
else
if
(
functionId
==
TSDB_FUNC_SPREAD
)
{
pCtx
->
}
#if defined(_DEBUG_VIEW)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录