Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
70927458
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
70927458
编写于
5月 30, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(query): do some internal refactor.
上级
1652cd0e
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
250 addition
and
337 deletion
+250
-337
include/libs/function/function.h
include/libs/function/function.h
+0
-30
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+8
-3
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+1
-11
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+1
-13
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+31
-25
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+2
-2
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+172
-139
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+35
-100
source/libs/function/src/texpr.c
source/libs/function/src/texpr.c
+0
-14
未找到文件。
include/libs/function/function.h
浏览文件 @
70927458
...
...
@@ -61,9 +61,6 @@ typedef struct SFileBlockInfo {
#define TSDB_BLOCK_DIST_STEP_ROWS 8
#define MAX_INTERVAL_TIME_WINDOW 1000000 // maximum allowed time windows in final results
#define FUNCTION_TYPE_SCALAR 1
#define FUNCTION_TYPE_AGG 2
#define TOP_BOTTOM_QUERY_LIMIT 100
#define FUNCTIONS_NAME_MAX_LENGTH 16
...
...
@@ -165,9 +162,6 @@ enum {
typedef
struct
tExprNode
{
int32_t
nodeType
;
union
{
SSchema
*
pSchema
;
// column node
struct
SVariant
*
pVal
;
// value node
struct
{
// function node
char
functionName
[
FUNCTIONS_NAME_MAX_LENGTH
];
// todo refactor
int32_t
functionId
;
...
...
@@ -210,47 +204,23 @@ struct SScalarParam {
int32_t
getResultDataInfo
(
int32_t
dataType
,
int32_t
dataBytes
,
int32_t
functionId
,
int32_t
param
,
SResultDataInfo
*
pInfo
,
int16_t
extLength
,
bool
isSuperTable
);
bool
qIsValidUdf
(
SArray
*
pUdfInfo
,
const
char
*
name
,
int32_t
len
,
int32_t
*
functionId
);
void
resetResultRowEntryResult
(
SqlFunctionCtx
*
pCtx
,
int32_t
num
);
void
cleanupResultRowEntry
(
struct
SResultRowEntryInfo
*
pCell
);
int32_t
getNumOfResult
(
SqlFunctionCtx
*
pCtx
,
int32_t
num
,
SSDataBlock
*
pResBlock
);
bool
isRowEntryCompleted
(
struct
SResultRowEntryInfo
*
pEntry
);
bool
isRowEntryInitialized
(
struct
SResultRowEntryInfo
*
pEntry
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// fill api
struct
SFillInfo
;
struct
SFillColInfo
;
typedef
struct
SPoint
{
int64_t
key
;
void
*
val
;
}
SPoint
;
//void taosFillSetStartInfo(struct SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey);
//void taosResetFillInfo(struct SFillInfo* pFillInfo, TSKEY startTimestamp);
//void taosFillSetInputDataBlock(struct SFillInfo* pFillInfo, const struct SSDataBlock* pInput);
//struct SFillColInfo* createFillColInfo(SExprInfo* pExpr, int32_t numOfOutput, const SValueNode* val);
//bool taosFillHasMoreResults(struct SFillInfo* pFillInfo);
//
//struct SFillInfo* taosCreateFillInfo(int32_t order, TSKEY skey, int32_t numOfTags, int32_t capacity, int32_t numOfCols,
// SInterval* pInterval, int32_t fillType,
// struct SFillColInfo* pCol, const char* id);
//
//void* taosDestroyFillInfo(struct SFillInfo *pFillInfo);
//int64_t taosFillResultDataBlock(struct SFillInfo* pFillInfo, void** output, int32_t capacity);
//int64_t getFillInfoStart(struct SFillInfo *pFillInfo);
int32_t
taosGetLinearInterpolationVal
(
SPoint
*
point
,
int32_t
outputType
,
SPoint
*
point1
,
SPoint
*
point2
,
int32_t
inputType
);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// udf api
struct
SUdfInfo
;
void
qAddUdfInfo
(
uint64_t
id
,
struct
SUdfInfo
*
pUdfInfo
);
void
qRemoveUdfInfo
(
uint64_t
id
,
struct
SUdfInfo
*
pUdfInfo
);
/**
* create udfd proxy, called once in process that call doSetupUdf/callUdfxxx/doTeardownUdf
* @return error code
...
...
source/common/src/tdatablock.c
浏览文件 @
70927458
...
...
@@ -354,14 +354,19 @@ int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex)
return
-
1
;
}
int32_t
index
=
(
tsColumnIndex
==
-
1
)
?
0
:
tsColumnIndex
;
int32_t
index
=
(
tsColumnIndex
==
-
1
)
?
0
:
tsColumnIndex
;
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
index
);
if
(
pColInfoData
->
info
.
type
!=
TSDB_DATA_TYPE_TIMESTAMP
)
{
return
0
;
}
pDataBlock
->
info
.
window
.
skey
=
*
(
TSKEY
*
)
colDataGetData
(
pColInfoData
,
0
);
pDataBlock
->
info
.
window
.
ekey
=
*
(
TSKEY
*
)
colDataGetData
(
pColInfoData
,
(
pDataBlock
->
info
.
rows
-
1
));
TSKEY
skey
=
*
(
TSKEY
*
)
colDataGetData
(
pColInfoData
,
0
);
TSKEY
ekey
=
*
(
TSKEY
*
)
colDataGetData
(
pColInfoData
,
(
pDataBlock
->
info
.
rows
-
1
));
pDataBlock
->
info
.
window
.
skey
=
TMIN
(
skey
,
ekey
);
pDataBlock
->
info
.
window
.
ekey
=
TMAX
(
skey
,
ekey
);
return
0
;
}
...
...
source/libs/executor/inc/executil.h
浏览文件 @
70927458
...
...
@@ -80,11 +80,10 @@ typedef struct SResultRowInfo {
struct
SqlFunctionCtx
;
size_t
getResultRowSize
(
struct
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
);
size_t
getResultRowSize
(
struct
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
);
int32_t
initResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
,
int32_t
size
);
void
cleanupResultRowInfo
(
SResultRowInfo
*
pResultRowInfo
);
int32_t
numOfClosedResultRows
(
SResultRowInfo
*
pResultRowInfo
);
void
closeAllResultRows
(
SResultRowInfo
*
pResultRowInfo
);
void
initResultRow
(
SResultRow
*
pResultRow
);
...
...
@@ -93,15 +92,6 @@ bool isResultRowClosed(SResultRow* pResultRow);
struct
SResultRowEntryInfo
*
getResultCell
(
const
SResultRow
*
pRow
,
int32_t
index
,
const
int32_t
*
offset
);
static
FORCE_INLINE
SResultRow
*
getResultRow
(
SDiskbasedBuf
*
pBuf
,
SResultRowInfo
*
pResultRowInfo
,
int32_t
slot
)
{
ASSERT
(
pResultRowInfo
!=
NULL
&&
slot
>=
0
&&
slot
<
pResultRowInfo
->
size
);
SResultRowPosition
*
pos
=
&
pResultRowInfo
->
pPosition
[
slot
];
SFilePage
*
bufPage
=
(
SFilePage
*
)
getBufPage
(
pBuf
,
pos
->
pageId
);
SResultRow
*
pRow
=
(
SResultRow
*
)((
char
*
)
bufPage
+
pos
->
offset
);
return
pRow
;
}
static
FORCE_INLINE
SResultRow
*
getResultRowByPos
(
SDiskbasedBuf
*
pBuf
,
SResultRowPosition
*
pos
)
{
SFilePage
*
bufPage
=
(
SFilePage
*
)
getBufPage
(
pBuf
,
pos
->
pageId
);
SResultRow
*
pRow
=
(
SResultRow
*
)((
char
*
)
bufPage
+
pos
->
offset
);
...
...
source/libs/executor/src/executil.c
浏览文件 @
70927458
...
...
@@ -101,20 +101,8 @@ void resetResultRowInfo(STaskRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRow
pResultRowInfo
->
size
=
0
;
}
int32_t
numOfClosedResultRows
(
SResultRowInfo
*
pResultRowInfo
)
{
int32_t
i
=
0
;
// while (i < pResultRowInfo->size && pResultRowInfo->pResult[i]->closed) {
// ++i;
// }
return
i
;
}
void
closeAllResultRows
(
SResultRowInfo
*
pResultRowInfo
)
{
assert
(
pResultRowInfo
->
size
>=
0
&&
pResultRowInfo
->
capacity
>=
pResultRowInfo
->
size
);
for
(
int32_t
i
=
0
;
i
<
pResultRowInfo
->
size
;
++
i
)
{
}
// do nothing
}
bool
isResultRowClosed
(
SResultRow
*
pRow
)
{
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
70927458
...
...
@@ -345,6 +345,8 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
// In case of group by column query, the required SResultRow object must be existInCurrentResusltRowInfo in the
// pResultRowInfo object.
if
(
p1
!=
NULL
)
{
// todo
pResult
=
getResultRowByPos
(
pResultBuf
,
p1
);
ASSERT
(
pResult
->
pageId
==
p1
->
pageId
&&
pResult
->
offset
==
p1
->
offset
);
}
...
...
@@ -353,11 +355,9 @@ SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pR
// 1. close current opened time window
if
(
pResultRowInfo
->
cur
.
pageId
!=
-
1
&&
((
pResult
==
NULL
)
||
(
pResult
->
pageId
!=
pResultRowInfo
->
cur
.
pageId
&&
pResult
->
offset
!=
pResultRowInfo
->
cur
.
offset
)))
{
// todo extract function
SResultRowPosition
pos
=
pResultRowInfo
->
cur
;
SFilePage
*
pPage
=
getBufPage
(
pResultBuf
,
pos
.
pageId
);
SResultRow
*
pRow
=
(
SResultRow
*
)((
char
*
)
pPage
+
pos
.
offset
);
closeResultRow
(
pRow
);
SFilePage
*
pPage
=
getBufPage
(
pResultBuf
,
pos
.
pageId
);
releaseBufPage
(
pResultBuf
,
pPage
);
}
...
...
@@ -552,11 +552,13 @@ void initExecTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pQueryWindow
colDataAppendInt64
(
pColData
,
4
,
&
pQueryWindow
->
ekey
);
}
void
doApplyFunctions
(
SExecTaskInfo
*
taskInfo
,
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
pWin
,
SColumnInfoData
*
pTimeWindowData
,
int32_t
offset
,
int32_t
forwardStep
,
TSKEY
*
tsCol
,
int32_t
numOfTotal
,
int32_t
numOfOutput
,
int32_t
order
)
{
for
(
int32_t
k
=
0
;
k
<
numOfOutput
;
++
k
)
{
// keep it temporarily
// todo no need this??
bool
hasAgg
=
pCtx
[
k
].
input
.
colDataAggIsSet
;
int32_t
numOfRows
=
pCtx
[
k
].
input
.
numOfRows
;
int32_t
startOffset
=
pCtx
[
k
].
input
.
startRowIndex
;
...
...
@@ -576,7 +578,8 @@ void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWindow
if
(
fmIsWindowPseudoColumnFunc
(
pCtx
[
k
].
functionId
))
{
SResultRowEntryInfo
*
pEntryInfo
=
GET_RES_INFO
(
&
pCtx
[
k
]);
char
*
p
=
GET_ROWCELL_INTERBUF
(
pEntryInfo
);
char
*
p
=
GET_ROWCELL_INTERBUF
(
pEntryInfo
);
SColumnInfoData
idata
=
{
0
};
idata
.
info
.
type
=
TSDB_DATA_TYPE_BIGINT
;
...
...
@@ -587,22 +590,23 @@ void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, STimeWindow
SScalarParam
tw
=
{.
numOfRows
=
5
,
.
columnData
=
pTimeWindowData
};
pCtx
[
k
].
sfp
.
process
(
&
tw
,
1
,
&
out
);
pEntryInfo
->
numOfRes
=
1
;
continue
;
}
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
functionNeedToExecute
(
&
pCtx
[
k
])
&&
pCtx
[
k
].
fpSet
.
process
!=
NULL
)
{
code
=
pCtx
[
k
].
fpSet
.
process
(
&
pCtx
[
k
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"%s apply functions error, code: %s"
,
GET_TASKID
(
taskInfo
),
tstrerror
(
code
));
taskInfo
->
code
=
code
;
longjmp
(
taskInfo
->
env
,
code
);
}
else
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
if
(
functionNeedToExecute
(
&
pCtx
[
k
])
&&
pCtx
[
k
].
fpSet
.
process
!=
NULL
)
{
code
=
pCtx
[
k
].
fpSet
.
process
(
&
pCtx
[
k
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"%s apply functions error, code: %s"
,
GET_TASKID
(
taskInfo
),
tstrerror
(
code
));
taskInfo
->
code
=
code
;
longjmp
(
taskInfo
->
env
,
code
);
}
}
}
// restore it
pCtx
[
k
].
input
.
colDataAggIsSet
=
hasAgg
;
pCtx
[
k
].
input
.
startRowIndex
=
startOffset
;
pCtx
[
k
].
input
.
numOfRows
=
numOfRows
;
// restore it
pCtx
[
k
].
input
.
colDataAggIsSet
=
hasAgg
;
pCtx
[
k
].
input
.
startRowIndex
=
startOffset
;
pCtx
[
k
].
input
.
numOfRows
=
numOfRows
;
}
}
}
...
...
@@ -741,12 +745,14 @@ static int32_t doAggregateImpl(SOperatorInfo* pOperator, TSKEY startTs, SqlFunct
for
(
int32_t
k
=
0
;
k
<
pOperator
->
numOfExprs
;
++
k
)
{
if
(
functionNeedToExecute
(
&
pCtx
[
k
]))
{
// todo add a dummy funtion to avoid process check
if
(
pCtx
[
k
].
fpSet
.
process
!=
NULL
)
{
int32_t
code
=
pCtx
[
k
].
fpSet
.
process
(
&
pCtx
[
k
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"%s aggregate function error happens, code: %s"
,
GET_TASKID
(
pOperator
->
pTaskInfo
),
tstrerror
(
code
));
return
code
;
}
if
(
pCtx
[
k
].
fpSet
.
process
==
NULL
)
{
continue
;
}
int32_t
code
=
pCtx
[
k
].
fpSet
.
process
(
&
pCtx
[
k
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"%s aggregate function error happens, code: %s"
,
GET_TASKID
(
pOperator
->
pTaskInfo
),
tstrerror
(
code
));
return
code
;
}
}
}
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
70927458
...
...
@@ -534,8 +534,8 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
pInfo
->
pPseudoCtx
=
createSqlFunctionCtx
(
pInfo
->
pPseudoExpr
,
pInfo
->
numOfPseudoExpr
,
&
pInfo
->
rowCellInfoOffset
);
}
//
pInfo->scanInfo = (SScanInfo){.numOfAsc = pTableScanNode->scanSeq[0], .numOfDesc = pTableScanNode->scanSeq[1]};
pInfo
->
scanInfo
=
(
SScanInfo
){.
numOfAsc
=
0
,
.
numOfDesc
=
1
};
// for debug purpose
pInfo
->
scanInfo
=
(
SScanInfo
){.
numOfAsc
=
pTableScanNode
->
scanSeq
[
0
],
.
numOfDesc
=
pTableScanNode
->
scanSeq
[
1
]};
//
pInfo->scanInfo = (SScanInfo){.numOfAsc = 0, .numOfDesc = 1}; // for debug purpose
pInfo
->
readHandle
=
*
readHandle
;
pInfo
->
interval
=
extractIntervalInfo
(
pTableScanNode
);
...
...
source/libs/executor/src/timewindowoperator.c
浏览文件 @
70927458
此差异已折叠。
点击以展开。
source/libs/function/src/builtinsimpl.c
浏览文件 @
70927458
...
...
@@ -3946,7 +3946,6 @@ int32_t uniqueFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
typedef
struct
STwaInfo
{
double
dOutput
;
int8_t
hasResult
;
// flag to denote has value
SPoint1
p
;
STimeWindow
win
;
}
STwaInfo
;
...
...
@@ -3977,28 +3976,25 @@ static double twa_get_area(SPoint1 s, SPoint1 e) {
return
val
;
}
#define INIT_INTP_POINT(_p, _k, _v) \
do { \
(_p).key = (_k); \
(_p).val = (_v); \
} while (0)
int32_t
twaFunction
(
SqlFunctionCtx
*
pCtx
)
{
SInputColumnInfoData
*
pInput
=
&
pCtx
->
input
;
SColumnInfoData
*
pInputCol
=
pInput
->
pData
[
0
];
int32_t
numOfElems
=
0
;
TSKEY
*
tsList
=
(
int64_t
*
)
pInput
->
pPTS
->
pData
;
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STwaInfo
*
pInfo
=
GET_ROWCELL_INTERBUF
(
pResInfo
);
SPoint1
*
last
=
&
pInfo
->
p
;
int32_t
numOfElems
=
0
;
SPoint1
*
last
=
&
pInfo
->
p
;
int32_t
step
=
1
;
//GET_FORWARD_DIRECTION_FACTOR(pCtx->order);
int32_t
i
=
pInput
->
startRowIndex
;
for
(
i
=
pInput
->
startRowIndex
;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
step
)
{
if
(
!
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
break
;
}
}
if
(
pCtx
->
start
.
key
!=
INT64_MIN
)
{
ASSERT
((
pCtx
->
start
.
key
<
tsList
[
i
]
&&
pCtx
->
order
==
TSDB_ORDER_ASC
)
||
(
pCtx
->
start
.
key
>
tsList
[
i
]
&&
pCtx
->
order
==
TSDB_ORDER_DESC
));
...
...
@@ -4009,37 +4005,30 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
GET_TYPED_DATA
(
last
->
val
,
double
,
pInputCol
->
info
.
type
,
colDataGetData
(
pInputCol
,
i
));
pInfo
->
dOutput
+=
twa_get_area
(
pCtx
->
start
,
*
last
);
pInfo
->
hasResult
=
DATA_SET_FLAG
;
pInfo
->
win
.
skey
=
pCtx
->
start
.
key
;
numOfElems
++
;
i
+=
step
;
i
+=
1
;
}
else
if
(
pInfo
->
p
.
key
==
INT64_MIN
)
{
last
->
key
=
tsList
[
i
];
GET_TYPED_DATA
(
last
->
val
,
double
,
pInputCol
->
info
.
type
,
colDataGetData
(
pInputCol
,
i
));
pInfo
->
hasResult
=
DATA_SET_FLAG
;
pInfo
->
win
.
skey
=
last
->
key
;
numOfElems
++
;
i
+=
step
;
i
+=
1
;
}
SPoint1
st
=
{
0
};
// calculate the value of
switch
(
pInputCol
->
info
.
type
)
{
case
TSDB_DATA_TYPE_TINYINT
:
{
int8_t
*
val
=
(
int8_t
*
)
colDataGetData
(
pInputCol
,
0
);
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
step
)
{
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
}
#ifndef _TD_NINGSI_60
SPoint1
st
=
{.
key
=
tsList
[
i
],
.
val
=
val
[
i
]};
#else
SPoint1
st
;
st
.
key
=
tsList
[
i
];
st
.
val
=
val
[
i
];
#endif
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
p
=
st
;
}
...
...
@@ -4048,18 +4037,12 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
case
TSDB_DATA_TYPE_SMALLINT
:
{
int16_t
*
val
=
(
int16_t
*
)
colDataGetData
(
pInputCol
,
0
);
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
step
)
{
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
}
#ifndef _TD_NINGSI_60
SPoint1
st
=
{.
key
=
tsList
[
i
],
.
val
=
val
[
i
]};
#else
SPoint1
st
;
st
.
key
=
tsList
[
i
];
st
.
val
=
val
[
i
];
#endif
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
p
=
st
;
}
...
...
@@ -4067,18 +4050,12 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
case
TSDB_DATA_TYPE_INT
:
{
int32_t
*
val
=
(
int32_t
*
)
colDataGetData
(
pInputCol
,
0
);
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
step
)
{
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
}
#ifndef _TD_NINGSI_60
SPoint1
st
=
{.
key
=
tsList
[
i
],
.
val
=
val
[
i
]};
#else
SPoint1
st
;
st
.
key
=
tsList
[
i
];
st
.
val
=
val
[
i
];
#endif
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
p
=
st
;
}
...
...
@@ -4086,18 +4063,12 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
case
TSDB_DATA_TYPE_BIGINT
:
{
int64_t
*
val
=
(
int64_t
*
)
colDataGetData
(
pInputCol
,
0
);
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
step
)
{
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
}
#ifndef _TD_NINGSI_60
SPoint1
st
=
{.
key
=
tsList
[
i
],
.
val
=
(
double
)
val
[
i
]};
#else
SPoint1
st
;
st
.
key
=
tsList
[
i
];
st
.
val
=
(
double
)
val
[
i
];
#endif
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
p
=
st
;
}
...
...
@@ -4105,18 +4076,12 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
case
TSDB_DATA_TYPE_FLOAT
:
{
float
*
val
=
(
float
*
)
colDataGetData
(
pInputCol
,
0
);
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
step
)
{
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
}
#ifndef _TD_NINGSI_60
SPoint1
st
=
{.
key
=
tsList
[
i
],
.
val
=
val
[
i
]};
#else
SPoint1
st
;
st
.
key
=
tsList
[
i
];
st
.
val
=
(
double
)
val
[
i
];
#endif
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
p
=
st
;
}
...
...
@@ -4124,18 +4089,12 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
case
TSDB_DATA_TYPE_DOUBLE
:
{
double
*
val
=
(
double
*
)
colDataGetData
(
pInputCol
,
0
);
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
step
)
{
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
}
#ifndef _TD_NINGSI_60
SPoint1
st
=
{.
key
=
tsList
[
i
],
.
val
=
val
[
i
]};
#else
SPoint1
st
;
st
.
key
=
tsList
[
i
];
st
.
val
=
val
[
i
];
#endif
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
p
=
st
;
}
...
...
@@ -4143,18 +4102,12 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
case
TSDB_DATA_TYPE_UTINYINT
:
{
uint8_t
*
val
=
(
uint8_t
*
)
colDataGetData
(
pInputCol
,
0
);
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
step
)
{
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
}
#ifndef _TD_NINGSI_60
SPoint1
st
=
{.
key
=
tsList
[
i
],
.
val
=
val
[
i
]};
#else
SPoint1
st
;
st
.
key
=
tsList
[
i
];
st
.
val
=
val
[
i
];
#endif
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
p
=
st
;
}
...
...
@@ -4162,18 +4115,12 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
case
TSDB_DATA_TYPE_USMALLINT
:
{
uint16_t
*
val
=
(
uint16_t
*
)
colDataGetData
(
pInputCol
,
0
);
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
step
)
{
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
}
#ifndef _TD_NINGSI_60
SPoint1
st
=
{.
key
=
tsList
[
i
],
.
val
=
val
[
i
]};
#else
SPoint1
st
;
st
.
key
=
tsList
[
i
];
st
.
val
=
val
[
i
];
#endif
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
p
=
st
;
}
...
...
@@ -4181,18 +4128,12 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
case
TSDB_DATA_TYPE_UINT
:
{
uint32_t
*
val
=
(
uint32_t
*
)
colDataGetData
(
pInputCol
,
0
);
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
step
)
{
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
}
#ifndef _TD_NINGSI_60
SPoint1
st
=
{.
key
=
tsList
[
i
],
.
val
=
val
[
i
]};
#else
SPoint1
st
;
st
.
key
=
tsList
[
i
];
st
.
val
=
val
[
i
];
#endif
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
p
=
st
;
}
...
...
@@ -4200,25 +4141,19 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
}
case
TSDB_DATA_TYPE_UBIGINT
:
{
uint64_t
*
val
=
(
uint64_t
*
)
colDataGetData
(
pInputCol
,
0
);
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
step
)
{
for
(;
i
<
pInput
->
numOfRows
+
pInput
->
startRowIndex
;
i
+=
1
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
continue
;
}
#ifndef _TD_NINGSI_60
SPoint1
st
=
{.
key
=
tsList
[
i
],
.
val
=
(
double
)
val
[
i
]};
#else
SPoint1
st
;
st
.
key
=
tsList
[
i
];
st
.
val
=
(
double
)
val
[
i
];
#endif
INIT_INTP_POINT
(
st
,
tsList
[
i
],
val
[
i
]);
pInfo
->
dOutput
+=
twa_get_area
(
pInfo
->
p
,
st
);
pInfo
->
p
=
st
;
}
break
;
}
default:
assert
(
0
);
default:
ASSERT
(
0
);
}
// the last interpolated time window value
...
...
@@ -4229,7 +4164,7 @@ int32_t twaFunction(SqlFunctionCtx* pCtx) {
pInfo
->
win
.
ekey
=
pInfo
->
p
.
key
;
SET_VAL
(
GET_RES_INFO
(
pCtx
)
,
numOfElems
,
1
);
SET_VAL
(
pResInfo
,
numOfElems
,
1
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -4250,7 +4185,7 @@ int32_t twaFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock* pBlock) {
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
STwaInfo
*
pInfo
=
(
STwaInfo
*
)
GET_ROWCELL_INTERBUF
(
pResInfo
);
if
(
p
Info
->
hasResult
!=
DATA_SET_FLAG
)
{
if
(
p
ResInfo
->
numOfRes
==
0
)
{
pResInfo
->
isNullRes
=
1
;
}
else
{
// assert(pInfo->win.ekey == pInfo->p.key && pInfo->hasResult == pResInfo->hasResult);
...
...
source/libs/function/src/texpr.c
浏览文件 @
70927458
...
...
@@ -36,12 +36,7 @@ void tExprTreeDestroy(tExprNode *pNode, void (*fp)(void *)) {
if
(
pNode
->
nodeType
==
TEXPR_BINARYEXPR_NODE
||
pNode
->
nodeType
==
TEXPR_UNARYEXPR_NODE
)
{
doExprTreeDestroy
(
&
pNode
,
fp
);
}
else
if
(
pNode
->
nodeType
==
TEXPR_VALUE_NODE
)
{
taosVariantDestroy
(
pNode
->
pVal
);
}
else
if
(
pNode
->
nodeType
==
TEXPR_COL_NODE
)
{
taosMemoryFreeClear
(
pNode
->
pSchema
);
}
taosMemoryFree
(
pNode
);
}
...
...
@@ -49,15 +44,6 @@ static void doExprTreeDestroy(tExprNode **pExpr, void (*fp)(void *)) {
if
(
*
pExpr
==
NULL
)
{
return
;
}
int32_t
type
=
(
*
pExpr
)
->
nodeType
;
if
(
type
==
TEXPR_VALUE_NODE
)
{
taosVariantDestroy
((
*
pExpr
)
->
pVal
);
taosMemoryFree
((
*
pExpr
)
->
pVal
);
}
else
if
(
type
==
TEXPR_COL_NODE
)
{
taosMemoryFree
((
*
pExpr
)
->
pSchema
);
}
taosMemoryFree
(
*
pExpr
);
*
pExpr
=
NULL
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录