Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2d58e1fe
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
2d58e1fe
编写于
2月 27, 2022
作者:
D
dapan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
7129ba9c
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
537 addition
and
658 deletion
+537
-658
include/common/tep.h
include/common/tep.h
+3
-0
include/libs/function/function.h
include/libs/function/function.h
+4
-1
include/libs/scalar/scalar.h
include/libs/scalar/scalar.h
+1
-1
source/common/src/tep.c
source/common/src/tep.c
+0
-1
source/libs/scalar/inc/filterInt.h
source/libs/scalar/inc/filterInt.h
+1
-0
source/libs/scalar/inc/sclInt.h
source/libs/scalar/inc/sclInt.h
+6
-3
source/libs/scalar/inc/sclvector.h
source/libs/scalar/inc/sclvector.h
+1
-1
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+6
-1
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+146
-69
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+369
-581
未找到文件。
include/common/tep.h
浏览文件 @
2d58e1fe
...
@@ -67,6 +67,9 @@ static FORCE_INLINE bool colDataIsNull(const SColumnInfoData* pColumnInfoData, u
...
@@ -67,6 +67,9 @@ static FORCE_INLINE bool colDataIsNull(const SColumnInfoData* pColumnInfoData, u
}
}
}
}
#define BitmapLen(_n) (((_n) + ((1<<NBIT)-1)) >> NBIT)
#define colDataGet(p1_, r_) \
#define colDataGet(p1_, r_) \
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? ((p1_)->pData + (p1_)->varmeta.offset[(r_)]) \
((IS_VAR_DATA_TYPE((p1_)->info.type)) ? ((p1_)->pData + (p1_)->varmeta.offset[(r_)]) \
: ((p1_)->pData + ((r_) * (p1_)->info.bytes)))
: ((p1_)->pData + ((r_) * (p1_)->info.bytes)))
...
...
include/libs/function/function.h
浏览文件 @
2d58e1fe
...
@@ -228,7 +228,10 @@ typedef struct SAggFunctionInfo {
...
@@ -228,7 +228,10 @@ typedef struct SAggFunctionInfo {
typedef
struct
SScalarParam
{
typedef
struct
SScalarParam
{
void
*
data
;
void
*
data
;
SColumnInfoData
*
columnData
;
union
{
SColumnInfoData
*
columnData
;
void
*
data
;
}
orig
;
char
*
bitmap
;
char
*
bitmap
;
bool
dataInBlock
;
bool
dataInBlock
;
int32_t
num
;
int32_t
num
;
...
...
include/libs/scalar/scalar.h
浏览文件 @
2d58e1fe
...
@@ -27,7 +27,7 @@ typedef struct SFilterInfo SFilterInfo;
...
@@ -27,7 +27,7 @@ typedef struct SFilterInfo SFilterInfo;
int32_t
scalarCalculateConstants
(
SNode
*
pNode
,
SNode
**
pRes
);
int32_t
scalarCalculateConstants
(
SNode
*
pNode
,
SNode
**
pRes
);
int32_t
scalarCalculate
(
SNode
*
pNode
,
S
SDataBlock
*
pSrc
,
SScalarParam
*
pDst
);
int32_t
scalarCalculate
(
SNode
*
pNode
,
S
Array
*
pBlockList
,
SScalarParam
*
pDst
);
int32_t
scalarGetOperatorParamNum
(
EOperatorType
type
);
int32_t
scalarGetOperatorParamNum
(
EOperatorType
type
);
int32_t
scalarGenerateSetFromList
(
void
**
data
,
void
*
pNode
,
uint32_t
type
);
int32_t
scalarGenerateSetFromList
(
void
**
data
,
void
*
pNode
,
uint32_t
type
);
...
...
source/common/src/tep.c
浏览文件 @
2d58e1fe
...
@@ -61,7 +61,6 @@ SEpSet getEpSet_s(SCorEpSet *pEpSet) {
...
@@ -61,7 +61,6 @@ SEpSet getEpSet_s(SCorEpSet *pEpSet) {
return
ep
;
return
ep
;
}
}
#define BitmapLen(_n) (((_n) + ((1<<NBIT)-1)) >> NBIT)
int32_t
colDataGetSize
(
const
SColumnInfoData
*
pColumnInfoData
,
int32_t
numOfRows
)
{
int32_t
colDataGetSize
(
const
SColumnInfoData
*
pColumnInfoData
,
int32_t
numOfRows
)
{
ASSERT
(
pColumnInfoData
!=
NULL
);
ASSERT
(
pColumnInfoData
!=
NULL
);
...
...
source/libs/scalar/inc/filterInt.h
浏览文件 @
2d58e1fe
...
@@ -253,6 +253,7 @@ typedef struct SFilterInfo {
...
@@ -253,6 +253,7 @@ typedef struct SFilterInfo {
uint32_t
*
blkUnits
;
uint32_t
*
blkUnits
;
int8_t
*
blkUnitRes
;
int8_t
*
blkUnitRes
;
void
*
pTable
;
void
*
pTable
;
SArray
*
blkList
;
SFilterPCtx
pctx
;
SFilterPCtx
pctx
;
}
SFilterInfo
;
}
SFilterInfo
;
...
...
source/libs/scalar/inc/sclInt.h
浏览文件 @
2d58e1fe
...
@@ -24,7 +24,7 @@ extern "C" {
...
@@ -24,7 +24,7 @@ extern "C" {
typedef
struct
SScalarCtx
{
typedef
struct
SScalarCtx
{
int32_t
code
;
int32_t
code
;
S
SDataBlock
*
pSrc
;
S
Array
*
pBlockList
;
/* element is SSDataBlock* */
SHashObj
*
pRes
;
/* element is SScalarParam */
SHashObj
*
pRes
;
/* element is SScalarParam */
}
SScalarCtx
;
}
SScalarCtx
;
...
@@ -44,10 +44,13 @@ typedef struct SScalarCtx {
...
@@ -44,10 +44,13 @@ typedef struct SScalarCtx {
#define SCL_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
#define SCL_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
int32_t
sclMoveParamListData
(
SScalarParam
*
params
,
int32_t
listNum
,
int32_t
idx
);
bool
sclIsNull
(
SScalarParam
*
param
,
int32_t
idx
);
void
sclSetNull
(
SScalarParam
*
param
,
int32_t
idx
);
void
sclFreeParam
(
SScalarParam
*
param
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
#endif // TDENGINE_SCALARINT_H
#endif // TDENGINE_SCALARINT_H
\ No newline at end of file
source/libs/scalar/inc/sclvector.h
浏览文件 @
2d58e1fe
...
@@ -23,7 +23,7 @@ extern "C" {
...
@@ -23,7 +23,7 @@ extern "C" {
#include "sclfunc.h"
#include "sclfunc.h"
typedef
void
(
*
_bufConverteFunc
)(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
outType
);
typedef
void
(
*
_bufConverteFunc
)(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
outType
);
typedef
void
(
*
_bin_scalar_fn_t
)(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
output
,
int32_t
order
);
typedef
void
(
*
_bin_scalar_fn_t
)(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
output
,
int32_t
order
);
_bin_scalar_fn_t
getBinScalarOperatorFn
(
int32_t
binOperator
);
_bin_scalar_fn_t
getBinScalarOperatorFn
(
int32_t
binOperator
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
source/libs/scalar/src/filter.c
浏览文件 @
2d58e1fe
...
@@ -3668,7 +3668,12 @@ _return:
...
@@ -3668,7 +3668,12 @@ _return:
bool
filterExecute
(
SFilterInfo
*
info
,
SSDataBlock
*
pSrc
,
int8_t
**
p
,
SColumnDataAgg
*
statis
,
int16_t
numOfCols
)
{
bool
filterExecute
(
SFilterInfo
*
info
,
SSDataBlock
*
pSrc
,
int8_t
**
p
,
SColumnDataAgg
*
statis
,
int16_t
numOfCols
)
{
if
(
info
->
scalarMode
)
{
if
(
info
->
scalarMode
)
{
SScalarParam
output
=
{
0
};
SScalarParam
output
=
{
0
};
FLT_ERR_RET
(
scalarCalculate
(
info
->
sclCtx
.
node
,
pSrc
,
&
output
));
SArray
*
pList
=
taosArrayInit
(
1
,
POINTER_BYTES
);
taosArrayPush
(
pList
,
&
pSrc
);
FLT_ERR_RET
(
scalarCalculate
(
info
->
sclCtx
.
node
,
pList
,
&
output
));
taosArrayDestroy
(
pList
);
*
p
=
output
.
data
;
*
p
=
output
.
data
;
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
2d58e1fe
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
#include "functionMgt.h"
#include "functionMgt.h"
#include "sclvector.h"
#include "sclvector.h"
#include "sclInt.h"
#include "sclInt.h"
#include "tep.h"
int32_t
scalarGetOperatorParamNum
(
EOperatorType
type
)
{
int32_t
scalarGetOperatorParamNum
(
EOperatorType
type
)
{
if
(
OP_TYPE_IS_NULL
==
type
||
OP_TYPE_IS_NOT_NULL
==
type
||
OP_TYPE_IS_TRUE
==
type
||
OP_TYPE_IS_NOT_TRUE
==
type
if
(
OP_TYPE_IS_NULL
==
type
||
OP_TYPE_IS_NOT_NULL
==
type
||
OP_TYPE_IS_TRUE
==
type
||
OP_TYPE_IS_NOT_TRUE
==
type
...
@@ -87,15 +88,23 @@ _return:
...
@@ -87,15 +88,23 @@ _return:
SCL_RET
(
code
);
SCL_RET
(
code
);
}
}
bool
sclIsNull
(
SScalarParam
*
param
,
int32_t
idx
)
{
FORCE_INLINE
bool
sclIsNull
(
SScalarParam
*
param
,
int32_t
idx
)
{
if
(
param
->
dataInBlock
)
{
if
(
param
->
dataInBlock
)
{
return
colDataIsNull
(
param
->
columnData
,
0
,
idx
,
NULL
);
return
colDataIsNull
(
param
->
orig
.
columnData
,
0
,
idx
,
NULL
);
}
}
return
colDataIsNull_f
(
param
->
bitmap
,
idx
)
;
return
param
->
bitmap
?
colDataIsNull_f
(
param
->
bitmap
,
idx
)
:
false
;
}
}
void
sclSetNull
(
SScalarParam
*
param
,
int32_t
idx
)
{
FORCE_INLINE
void
sclSetNull
(
SScalarParam
*
param
,
int32_t
idx
)
{
if
(
NULL
==
param
->
bitmap
)
{
param
->
bitmap
=
calloc
(
BitmapLen
(
param
->
num
),
sizeof
(
char
));
if
(
NULL
==
param
->
bitmap
)
{
sclError
(
"calloc %d failed"
,
param
->
num
);
return
;
}
}
colDataSetNull_f
(
param
->
bitmap
,
idx
);
colDataSetNull_f
(
param
->
bitmap
,
idx
);
}
}
...
@@ -107,7 +116,7 @@ void sclFreeRes(SHashObj *res) {
...
@@ -107,7 +116,7 @@ void sclFreeRes(SHashObj *res) {
p
=
(
SScalarParam
*
)
pIter
;
p
=
(
SScalarParam
*
)
pIter
;
if
(
p
)
{
if
(
p
)
{
tfree
(
p
->
data
);
sclFreeParam
(
p
);
}
}
pIter
=
taosHashIterate
(
res
,
pIter
);
pIter
=
taosHashIterate
(
res
,
pIter
);
...
@@ -117,7 +126,15 @@ void sclFreeRes(SHashObj *res) {
...
@@ -117,7 +126,15 @@ void sclFreeRes(SHashObj *res) {
}
}
void
sclFreeParam
(
SScalarParam
*
param
)
{
void
sclFreeParam
(
SScalarParam
*
param
)
{
tfree
(
param
->
data
);
tfree
(
param
->
bitmap
);
if
(
!
param
->
dataInBlock
)
{
if
(
SCL_DATA_TYPE_DUMMY_HASH
==
param
->
type
)
{
taosHashCleanup
((
SHashObj
*
)
param
->
orig
.
data
);
}
else
{
tfree
(
param
->
orig
.
data
);
}
}
}
}
int32_t
sclInitParam
(
SNode
*
node
,
SScalarParam
*
param
,
SScalarCtx
*
ctx
,
int32_t
*
rowNum
)
{
int32_t
sclInitParam
(
SNode
*
node
,
SScalarParam
*
param
,
SScalarCtx
*
ctx
,
int32_t
*
rowNum
)
{
...
@@ -140,30 +157,45 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
...
@@ -140,30 +157,45 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
}
}
SCL_ERR_RET
(
scalarGenerateSetFromList
(
&
param
->
data
,
node
,
nodeList
->
dataType
.
type
));
SCL_ERR_RET
(
scalarGenerateSetFromList
(
&
param
->
data
,
node
,
nodeList
->
dataType
.
type
));
param
->
orig
.
data
=
param
->
data
;
param
->
num
=
1
;
param
->
num
=
1
;
param
->
type
=
SCL_DATA_TYPE_DUMMY_HASH
;
param
->
type
=
SCL_DATA_TYPE_DUMMY_HASH
;
param
->
dataInBlock
=
false
;
param
->
dataInBlock
=
false
;
if
(
taosHashPut
(
ctx
->
pRes
,
&
node
,
POINTER_BYTES
,
param
,
sizeof
(
*
param
)))
{
taosHashCleanup
(
param
->
orig
.
data
);
param
->
orig
.
data
=
NULL
;
sclError
(
"taosHashPut nodeList failed, size:%d"
,
(
int32_t
)
sizeof
(
*
param
));
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
break
;
break
;
}
}
case
QUERY_NODE_COLUMN
:
{
case
QUERY_NODE_COLUMN
:
{
if
(
NULL
==
ctx
)
{
if
(
NULL
==
ctx
->
pBlockList
)
{
sclError
(
"invalid node type for constant calculating, type:%d,
ctx:%p"
,
nodeType
(
node
),
ctx
);
sclError
(
"invalid node type for constant calculating, type:%d,
src:%p"
,
nodeType
(
node
),
ctx
->
pBlockList
);
SCL_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
SCL_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
}
SColumnNode
*
ref
=
(
SColumnNode
*
)
node
;
SColumnNode
*
ref
=
(
SColumnNode
*
)
node
;
if
(
ref
->
slotId
>=
taosArrayGetSize
(
ctx
->
pSrc
->
pDataBlock
))
{
if
(
ref
->
tupleId
>=
taosArrayGetSize
(
ctx
->
pBlockList
))
{
sclError
(
"column ref slotId is too big, slodId:%d, dataBlockSize:%d"
,
ref
->
slotId
,
(
int32_t
)
taosArrayGetSize
(
ctx
->
pSrc
->
pDataBlock
));
sclError
(
"column tupleId is too big, tupleId:%d, dataBlockNum:%d"
,
ref
->
tupleId
,
(
int32_t
)
taosArrayGetSize
(
ctx
->
pBlockList
));
SCL_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
SSDataBlock
*
block
=
taosArrayGet
(
ctx
->
pBlockList
,
ref
->
tupleId
);
if
(
NULL
==
block
||
ref
->
slotId
>=
taosArrayGetSize
(
block
->
pDataBlock
))
{
sclError
(
"column slotId is too big, slodId:%d, dataBlockSize:%d"
,
ref
->
slotId
,
(
int32_t
)
taosArrayGetSize
(
block
->
pDataBlock
));
SCL_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
SCL_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
}
SColumnInfoData
*
columnData
=
(
SColumnInfoData
*
)
taosArrayGet
(
ctx
->
pSrc
->
pDataBlock
,
ref
->
slotId
);
SColumnInfoData
*
columnData
=
(
SColumnInfoData
*
)
taosArrayGet
(
block
->
pDataBlock
,
ref
->
slotId
);
param
->
data
=
NULL
;
param
->
data
=
NULL
;
param
->
columnData
=
columnData
;
param
->
orig
.
columnData
=
columnData
;
param
->
dataInBlock
=
true
;
param
->
dataInBlock
=
true
;
param
->
num
=
ctx
->
pSrc
->
info
.
rows
;
param
->
num
=
block
->
info
.
rows
;
param
->
type
=
columnData
->
info
.
type
;
param
->
type
=
columnData
->
info
.
type
;
param
->
bytes
=
columnData
->
info
.
bytes
;
param
->
bytes
=
columnData
->
info
.
bytes
;
...
@@ -171,11 +203,6 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
...
@@ -171,11 +203,6 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
}
}
case
QUERY_NODE_LOGIC_CONDITION
:
case
QUERY_NODE_LOGIC_CONDITION
:
case
QUERY_NODE_OPERATOR
:
{
case
QUERY_NODE_OPERATOR
:
{
if
(
NULL
==
ctx
)
{
sclError
(
"invalid node type for constant calculating, type:%d, ctx:%p"
,
nodeType
(
node
),
ctx
);
SCL_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
SScalarParam
*
res
=
(
SScalarParam
*
)
taosHashGet
(
ctx
->
pRes
,
&
node
,
POINTER_BYTES
);
SScalarParam
*
res
=
(
SScalarParam
*
)
taosHashGet
(
ctx
->
pRes
,
&
node
,
POINTER_BYTES
);
if
(
NULL
==
res
)
{
if
(
NULL
==
res
)
{
sclError
(
"no result for node, type:%d, node:%p"
,
nodeType
(
node
),
node
);
sclError
(
"no result for node, type:%d, node:%p"
,
nodeType
(
node
),
node
);
...
@@ -211,13 +238,15 @@ int32_t sclMoveParamListData(SScalarParam *params, int32_t listNum, int32_t idx)
...
@@ -211,13 +238,15 @@ int32_t sclMoveParamListData(SScalarParam *params, int32_t listNum, int32_t idx)
}
}
if
(
param
->
dataInBlock
)
{
if
(
param
->
dataInBlock
)
{
param
->
data
=
colDataGet
(
param
->
columnData
,
idx
);
param
->
data
=
colDataGet
(
param
->
orig
.
columnData
,
idx
);
}
else
if
(
idx
)
{
}
else
if
(
idx
)
{
if
(
IS_VAR_DATA_TYPE
(
param
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
param
->
type
))
{
param
->
data
=
(
char
*
)(
param
->
data
)
+
varDataTLen
(
param
->
data
);
param
->
data
=
(
char
*
)(
param
->
data
)
+
varDataTLen
(
param
->
data
);
}
else
{
}
else
{
param
->
data
=
(
char
*
)(
param
->
data
)
+
tDataTypes
[
param
->
type
].
bytes
;
param
->
data
=
(
char
*
)(
param
->
data
)
+
tDataTypes
[
param
->
type
].
bytes
;
}
}
}
else
{
param
->
data
=
param
->
orig
.
data
;
}
}
}
}
...
@@ -307,6 +336,7 @@ int32_t sclExecFuncion(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *outpu
...
@@ -307,6 +336,7 @@ int32_t sclExecFuncion(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *outpu
sclError
(
"calloc %d failed"
,
(
int32_t
)(
rowNum
*
sizeof
(
tDataTypes
[
output
->
type
].
bytes
)));
sclError
(
"calloc %d failed"
,
(
int32_t
)(
rowNum
*
sizeof
(
tDataTypes
[
output
->
type
].
bytes
)));
SCL_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
SCL_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
output
->
orig
.
data
=
output
->
data
;
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
sclMoveParamListData
(
output
,
1
,
i
);
sclMoveParamListData
(
output
,
1
,
i
);
...
@@ -358,9 +388,8 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o
...
@@ -358,9 +388,8 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o
sclError
(
"calloc %d failed"
,
(
int32_t
)(
rowNum
*
sizeof
(
bool
)));
sclError
(
"calloc %d failed"
,
(
int32_t
)(
rowNum
*
sizeof
(
bool
)));
SCL_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
SCL_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
output
->
orig
.
data
=
output
->
data
;
void
*
data
=
output
->
data
;
bool
value
=
false
;
bool
value
=
false
;
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
...
@@ -382,8 +411,6 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o
...
@@ -382,8 +411,6 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o
*
(
bool
*
)
output
->
data
=
value
;
*
(
bool
*
)
output
->
data
=
value
;
}
}
output
->
data
=
data
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_return:
_return:
...
@@ -407,6 +434,7 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
...
@@ -407,6 +434,7 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
sclError
(
"calloc %d failed"
,
(
int32_t
)
rowNum
*
tDataTypes
[
output
->
type
].
bytes
);
sclError
(
"calloc %d failed"
,
(
int32_t
)
rowNum
*
tDataTypes
[
output
->
type
].
bytes
);
SCL_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
SCL_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
}
output
->
orig
.
data
=
output
->
data
;
_bin_scalar_fn_t
OperatorFn
=
getBinScalarOperatorFn
(
node
->
opType
);
_bin_scalar_fn_t
OperatorFn
=
getBinScalarOperatorFn
(
node
->
opType
);
...
@@ -414,7 +442,7 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
...
@@ -414,7 +442,7 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
SScalarParam
*
pLeft
=
&
params
[
0
];
SScalarParam
*
pLeft
=
&
params
[
0
];
SScalarParam
*
pRight
=
paramNum
>
1
?
&
params
[
1
]
:
NULL
;
SScalarParam
*
pRight
=
paramNum
>
1
?
&
params
[
1
]
:
NULL
;
OperatorFn
(
pLeft
,
pRight
,
output
->
data
,
TSDB_ORDER_ASC
);
OperatorFn
(
pLeft
,
pRight
,
output
,
TSDB_ORDER_ASC
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -425,12 +453,12 @@ _return:
...
@@ -425,12 +453,12 @@ _return:
}
}
EDealRes
sclRewriteFunction
(
SNode
**
pNode
,
void
*
pContext
)
{
EDealRes
sclRewriteFunction
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
SFunctionNode
*
node
=
(
SFunctionNode
*
)
*
pNode
;
SFunctionNode
*
node
=
(
SFunctionNode
*
)
*
pNode
;
SScalarParam
output
=
{
0
};
SScalarParam
output
=
{
0
};
*
(
int32_t
*
)
pContext
=
sclExecFuncion
(
node
,
NULL
,
&
output
);
ctx
->
code
=
sclExecFuncion
(
node
,
ctx
,
&
output
);
if
(
*
(
int32_t
*
)
pContext
)
{
if
(
ctx
->
code
)
{
return
DEAL_RES_ERROR
;
return
DEAL_RES_ERROR
;
}
}
...
@@ -438,7 +466,7 @@ EDealRes sclRewriteFunction(SNode** pNode, void* pContext) {
...
@@ -438,7 +466,7 @@ EDealRes sclRewriteFunction(SNode** pNode, void* pContext) {
if
(
NULL
==
res
)
{
if
(
NULL
==
res
)
{
sclError
(
"make value node failed"
);
sclError
(
"make value node failed"
);
sclFreeParam
(
&
output
);
sclFreeParam
(
&
output
);
*
(
int32_t
*
)
pContext
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
ctx
->
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
DEAL_RES_ERROR
;
return
DEAL_RES_ERROR
;
}
}
...
@@ -459,12 +487,12 @@ EDealRes sclRewriteFunction(SNode** pNode, void* pContext) {
...
@@ -459,12 +487,12 @@ EDealRes sclRewriteFunction(SNode** pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
EDealRes
sclRewriteLogic
(
SNode
**
pNode
,
void
*
pContext
)
{
EDealRes
sclRewriteLogic
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
SLogicConditionNode
*
node
=
(
SLogicConditionNode
*
)
*
pNode
;
SLogicConditionNode
*
node
=
(
SLogicConditionNode
*
)
*
pNode
;
SScalarParam
output
=
{
0
};
SScalarParam
output
=
{
0
};
*
(
int32_t
*
)
pContext
=
sclExecLogic
(
node
,
NULL
,
&
output
);
ctx
->
code
=
sclExecLogic
(
node
,
ctx
,
&
output
);
if
(
*
(
int32_t
*
)
pContext
)
{
if
(
ctx
->
code
)
{
return
DEAL_RES_ERROR
;
return
DEAL_RES_ERROR
;
}
}
...
@@ -472,7 +500,7 @@ EDealRes sclRewriteLogic(SNode** pNode, void* pContext) {
...
@@ -472,7 +500,7 @@ EDealRes sclRewriteLogic(SNode** pNode, void* pContext) {
if
(
NULL
==
res
)
{
if
(
NULL
==
res
)
{
sclError
(
"make value node failed"
);
sclError
(
"make value node failed"
);
sclFreeParam
(
&
output
);
sclFreeParam
(
&
output
);
*
(
int32_t
*
)
pContext
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
ctx
->
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
DEAL_RES_ERROR
;
return
DEAL_RES_ERROR
;
}
}
...
@@ -493,12 +521,12 @@ EDealRes sclRewriteLogic(SNode** pNode, void* pContext) {
...
@@ -493,12 +521,12 @@ EDealRes sclRewriteLogic(SNode** pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
EDealRes
sclRewriteOperator
(
SNode
**
pNode
,
void
*
pContext
)
{
EDealRes
sclRewriteOperator
(
SNode
**
pNode
,
SScalarCtx
*
ctx
)
{
SOperatorNode
*
node
=
(
SOperatorNode
*
)
*
pNode
;
SOperatorNode
*
node
=
(
SOperatorNode
*
)
*
pNode
;
SScalarParam
output
=
{
0
};
SScalarParam
output
=
{
0
};
*
(
int32_t
*
)
pContext
=
sclExecOperator
(
node
,
NULL
,
&
output
);
ctx
->
code
=
sclExecOperator
(
node
,
ctx
,
&
output
);
if
(
*
(
int32_t
*
)
pContext
)
{
if
(
ctx
->
code
)
{
return
DEAL_RES_ERROR
;
return
DEAL_RES_ERROR
;
}
}
...
@@ -506,7 +534,7 @@ EDealRes sclRewriteOperator(SNode** pNode, void* pContext) {
...
@@ -506,7 +534,7 @@ EDealRes sclRewriteOperator(SNode** pNode, void* pContext) {
if
(
NULL
==
res
)
{
if
(
NULL
==
res
)
{
sclError
(
"make value node failed"
);
sclError
(
"make value node failed"
);
sclFreeParam
(
&
output
);
sclFreeParam
(
&
output
);
*
(
int32_t
*
)
pContext
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
ctx
->
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
DEAL_RES_ERROR
;
return
DEAL_RES_ERROR
;
}
}
...
@@ -533,28 +561,29 @@ EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) {
...
@@ -533,28 +561,29 @@ EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
SScalarCtx
*
ctx
=
(
SScalarCtx
*
)
pContext
;
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
*
pNode
))
{
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
*
pNode
))
{
return
sclRewriteFunction
(
pNode
,
pContext
);
return
sclRewriteFunction
(
pNode
,
ctx
);
}
}
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
*
pNode
))
{
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
*
pNode
))
{
return
sclRewriteLogic
(
pNode
,
pContext
);
return
sclRewriteLogic
(
pNode
,
ctx
);
}
}
if
(
QUERY_NODE_OPERATOR
==
nodeType
(
*
pNode
))
{
if
(
QUERY_NODE_OPERATOR
==
nodeType
(
*
pNode
))
{
return
sclRewriteOperator
(
pNode
,
pContext
);
return
sclRewriteOperator
(
pNode
,
ctx
);
}
}
sclError
(
"invalid node type for calculating constants, type:%d"
,
nodeType
(
*
pNode
));
sclError
(
"invalid node type for calculating constants, type:%d"
,
nodeType
(
*
pNode
));
*
(
int32_t
*
)
pContext
=
TSDB_CODE_QRY_INVALID_INPUT
;
ctx
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
DEAL_RES_ERROR
;
return
DEAL_RES_ERROR
;
}
}
EDealRes
sclWalkFunction
(
SNode
*
pNode
,
void
*
pContext
)
{
EDealRes
sclWalkFunction
(
SNode
*
pNode
,
SScalarCtx
*
ctx
)
{
SScalarCtx
*
ctx
=
(
SScalarCtx
*
)
pContext
;
SFunctionNode
*
node
=
(
SFunctionNode
*
)
pNode
;
SFunctionNode
*
node
=
(
SFunctionNode
*
)
pNode
;
SScalarParam
output
=
{
0
};
SScalarParam
output
=
{
0
};
...
@@ -572,8 +601,7 @@ EDealRes sclWalkFunction(SNode* pNode, void* pContext) {
...
@@ -572,8 +601,7 @@ EDealRes sclWalkFunction(SNode* pNode, void* pContext) {
}
}
EDealRes
sclWalkLogic
(
SNode
*
pNode
,
void
*
pContext
)
{
EDealRes
sclWalkLogic
(
SNode
*
pNode
,
SScalarCtx
*
ctx
)
{
SScalarCtx
*
ctx
=
(
SScalarCtx
*
)
pContext
;
SLogicConditionNode
*
node
=
(
SLogicConditionNode
*
)
pNode
;
SLogicConditionNode
*
node
=
(
SLogicConditionNode
*
)
pNode
;
SScalarParam
output
=
{
0
};
SScalarParam
output
=
{
0
};
...
@@ -591,8 +619,7 @@ EDealRes sclWalkLogic(SNode* pNode, void* pContext) {
...
@@ -591,8 +619,7 @@ EDealRes sclWalkLogic(SNode* pNode, void* pContext) {
}
}
EDealRes
sclWalkOperator
(
SNode
*
pNode
,
void
*
pContext
)
{
EDealRes
sclWalkOperator
(
SNode
*
pNode
,
SScalarCtx
*
ctx
)
{
SScalarCtx
*
ctx
=
(
SScalarCtx
*
)
pContext
;
SOperatorNode
*
node
=
(
SOperatorNode
*
)
pNode
;
SOperatorNode
*
node
=
(
SOperatorNode
*
)
pNode
;
SScalarParam
output
=
{
0
};
SScalarParam
output
=
{
0
};
...
@@ -609,27 +636,69 @@ EDealRes sclWalkOperator(SNode* pNode, void* pContext) {
...
@@ -609,27 +636,69 @@ EDealRes sclWalkOperator(SNode* pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
EDealRes
sclWalkTarget
(
SNode
*
pNode
,
SScalarCtx
*
ctx
)
{
STargetNode
*
target
=
(
STargetNode
*
)
pNode
;
if
(
target
->
tupleId
>=
taosArrayGetSize
(
ctx
->
pBlockList
))
{
sclError
(
"target tupleId is too big, tupleId:%d, dataBlockNum:%d"
,
target
->
tupleId
,
(
int32_t
)
taosArrayGetSize
(
ctx
->
pBlockList
));
ctx
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
DEAL_RES_ERROR
;
}
SSDataBlock
*
block
=
taosArrayGet
(
ctx
->
pBlockList
,
target
->
tupleId
);
if
(
target
->
slotId
>=
taosArrayGetSize
(
block
->
pDataBlock
))
{
sclError
(
"target slot not exist, slotId:%d, dataBlockNum:%d"
,
target
->
slotId
,
(
int32_t
)
taosArrayGetSize
(
block
->
pDataBlock
));
ctx
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
DEAL_RES_ERROR
;
}
SColumnInfoData
*
col
=
taosArrayGet
(
block
->
pDataBlock
,
target
->
slotId
);
SScalarParam
*
res
=
(
SScalarParam
*
)
taosHashGet
(
ctx
->
pRes
,
(
void
*
)
&
target
->
pExpr
,
POINTER_BYTES
);
if
(
NULL
==
res
)
{
sclError
(
"no valid res in hash, node:%p, type:%d"
,
target
->
pExpr
,
nodeType
(
target
->
pExpr
));
ctx
->
code
=
TSDB_CODE_QRY_APP_ERROR
;
return
DEAL_RES_ERROR
;
}
taosHashRemove
(
ctx
->
pRes
,
(
void
*
)
&
target
->
pExpr
,
POINTER_BYTES
);
for
(
int32_t
i
=
0
;
i
<
res
->
num
;
++
i
)
{
sclMoveParamListData
(
res
,
1
,
i
);
colDataAppend
(
col
,
i
,
res
->
data
,
sclIsNull
(
res
,
i
));
}
sclFreeParam
(
res
);
return
DEAL_RES_CONTINUE
;
}
EDealRes
sclCalcWalker
(
SNode
*
pNode
,
void
*
pContext
)
{
EDealRes
sclCalcWalker
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
pNode
)
||
QUERY_NODE_NODE_LIST
==
nodeType
(
pNode
)
||
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
pNode
)
||
QUERY_NODE_NODE_LIST
==
nodeType
(
pNode
)
||
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
SScalarCtx
*
ctx
=
(
SScalarCtx
*
)
pContext
;
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
))
{
if
(
QUERY_NODE_FUNCTION
==
nodeType
(
pNode
))
{
return
sclWalkFunction
(
pNode
,
pContext
);
return
sclWalkFunction
(
pNode
,
ctx
);
}
}
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
pNode
))
{
if
(
QUERY_NODE_LOGIC_CONDITION
==
nodeType
(
pNode
))
{
return
sclWalkLogic
(
pNode
,
pContext
);
return
sclWalkLogic
(
pNode
,
ctx
);
}
}
if
(
QUERY_NODE_OPERATOR
==
nodeType
(
pNode
))
{
if
(
QUERY_NODE_OPERATOR
==
nodeType
(
pNode
))
{
return
sclWalkOperator
(
pNode
,
pContext
);
return
sclWalkOperator
(
pNode
,
ctx
);
}
}
sclError
(
"invalid node type for scalar calculating, type:%d"
,
nodeType
(
pNode
));
if
(
QUERY_NODE_TARGET
==
nodeType
(
pNode
))
{
return
sclWalkTarget
(
pNode
,
ctx
);
}
SScalarCtx
*
ctx
=
(
SScalarCtx
*
)
pContext
;
sclError
(
"invalid node type for scalar calculating, type:%d"
,
nodeType
(
pNode
))
;
ctx
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
ctx
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
...
@@ -644,26 +713,33 @@ int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) {
...
@@ -644,26 +713,33 @@ int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) {
}
}
int32_t
code
=
0
;
int32_t
code
=
0
;
SScalarCtx
ctx
=
{
0
};
ctx
.
pRes
=
taosHashInit
(
SCL_DEFAULT_OP_NUM
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
if
(
NULL
==
ctx
.
pRes
)
{
sclError
(
"taosHashInit failed, num:%d"
,
SCL_DEFAULT_OP_NUM
);
SCL_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
nodesRewriteNodePostOrder
(
&
pNode
,
sclConstantsRewriter
,
(
void
*
)
&
c
ode
);
nodesRewriteNodePostOrder
(
&
pNode
,
sclConstantsRewriter
,
(
void
*
)
&
c
tx
);
if
(
code
)
{
SCL_ERR_JRET
(
ctx
.
code
);
nodesDestroyNode
(
pNode
);
SCL_ERR_RET
(
code
);
}
*
pRes
=
pNode
;
*
pRes
=
pNode
;
SCL_RET
(
code
);
_return:
sclFreeRes
(
ctx
.
pRes
);
return
code
;
}
}
int32_t
scalarCalculate
(
SNode
*
pNode
,
S
SDataBlock
*
pSrc
,
SScalarParam
*
pDst
)
{
int32_t
scalarCalculate
(
SNode
*
pNode
,
S
Array
*
pBlockList
,
SScalarParam
*
pDst
)
{
if
(
NULL
==
pNode
||
NULL
==
p
Src
||
NULL
==
pDst
)
{
if
(
NULL
==
pNode
||
NULL
==
p
BlockList
||
NULL
==
pDst
)
{
SCL_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
SCL_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
}
int32_t
code
=
0
;
int32_t
code
=
0
;
SScalarCtx
ctx
=
{.
code
=
0
,
.
p
Src
=
pSrc
};
SScalarCtx
ctx
=
{.
code
=
0
,
.
p
BlockList
=
pBlockList
};
ctx
.
pRes
=
taosHashInit
(
SCL_DEFAULT_OP_NUM
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
ctx
.
pRes
=
taosHashInit
(
SCL_DEFAULT_OP_NUM
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
),
false
,
HASH_NO_LOCK
);
if
(
NULL
==
ctx
.
pRes
)
{
if
(
NULL
==
ctx
.
pRes
)
{
...
@@ -673,23 +749,24 @@ int32_t scalarCalculate(SNode *pNode, SSDataBlock *pSrc, SScalarParam *pDst) {
...
@@ -673,23 +749,24 @@ int32_t scalarCalculate(SNode *pNode, SSDataBlock *pSrc, SScalarParam *pDst) {
nodesWalkNodePostOrder
(
pNode
,
sclCalcWalker
,
(
void
*
)
&
ctx
);
nodesWalkNodePostOrder
(
pNode
,
sclCalcWalker
,
(
void
*
)
&
ctx
);
if
(
ctx
.
code
)
{
SCL_ERR_JRET
(
ctx
.
code
);
nodesDestroyNode
(
pNode
);
sclFreeRes
(
ctx
.
pRes
);
SCL_ERR_RET
(
ctx
.
code
);
}
SScalarParam
*
res
=
(
SScalarParam
*
)
taosHashGet
(
ctx
.
pRes
,
(
void
*
)
&
pNode
,
POINTER_BYTES
);
SScalarParam
*
res
=
(
SScalarParam
*
)
taosHashGet
(
ctx
.
pRes
,
(
void
*
)
&
pNode
,
POINTER_BYTES
);
if
(
NULL
==
res
)
{
if
(
NULL
==
res
)
{
sclError
(
"no
res for calculating
, node:%p, type:%d"
,
pNode
,
nodeType
(
pNode
));
sclError
(
"no
valid res in hash
, node:%p, type:%d"
,
pNode
,
nodeType
(
pNode
));
SCL_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
SCL_ERR_
J
RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
}
taosHashRemove
(
ctx
.
pRes
,
(
void
*
)
&
pNode
,
POINTER_BYTES
);
*
pDst
=
*
res
;
*
pDst
=
*
res
;
_return:
nodesDestroyNode
(
pNode
);
nodesDestroyNode
(
pNode
);
sclFreeRes
(
ctx
.
pRes
);
return
TSDB_CODE_SUCCESS
;
return
code
;
}
}
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
2d58e1fe
...
@@ -261,19 +261,19 @@ _getValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) {
...
@@ -261,19 +261,19 @@ _getValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) {
return
p
;
return
p
;
}
}
static
FORCE_INLINE
void
convert
ToSigned
(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
outType
)
{
static
FORCE_INLINE
void
var
ToSigned
(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
outType
)
{
int64_t
value
=
strtoll
(
buf
,
NULL
,
10
);
int64_t
value
=
strtoll
(
buf
,
NULL
,
10
);
SET_TYPED_DATA
(
pOut
->
data
,
outType
,
value
);
SET_TYPED_DATA
(
pOut
->
data
,
outType
,
value
);
}
}
static
FORCE_INLINE
void
convert
ToUnsigned
(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
outType
)
{
static
FORCE_INLINE
void
var
ToUnsigned
(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
outType
)
{
uint64_t
value
=
strtoull
(
buf
,
NULL
,
10
);
uint64_t
value
=
strtoull
(
buf
,
NULL
,
10
);
SET_TYPED_DATA
(
pOut
->
data
,
outType
,
value
);
SET_TYPED_DATA
(
pOut
->
data
,
outType
,
value
);
}
}
static
FORCE_INLINE
void
convert
ToFloat
(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
outType
)
{
static
FORCE_INLINE
void
var
ToFloat
(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
outType
)
{
double
value
=
strtod
(
tmp
,
NULL
);
double
value
=
strtod
(
buf
,
NULL
);
SET_TYPED_DATA
(
output
,
outType
,
value
);
SET_TYPED_DATA
(
pOut
->
data
,
outType
,
value
);
}
}
...
@@ -282,14 +282,14 @@ int32_t vectorConvertFromVarData(SScalarParam* pIn, SScalarParam* pOut, int32_t
...
@@ -282,14 +282,14 @@ int32_t vectorConvertFromVarData(SScalarParam* pIn, SScalarParam* pOut, int32_t
char
*
tmp
=
NULL
;
char
*
tmp
=
NULL
;
_bufConverteFunc
func
=
NULL
;
_bufConverteFunc
func
=
NULL
;
if
(
IS_SIGNED_NUMERIC_TYPE
(
outType
)
||
TSDB_DATA_TYPE_TIMESTAMP
==
outType
)
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
outType
)
||
TSDB_DATA_TYPE_TIMESTAMP
==
outType
||
TSDB_DATA_TYPE_BOOL
==
outType
)
{
func
=
convert
ToSigned
;
func
=
var
ToSigned
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
outType
))
{
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
outType
))
{
func
=
convert
ToUnsigned
;
func
=
var
ToUnsigned
;
}
else
if
(
IS_FLOAT_TYPE
(
outType
))
{
}
else
if
(
IS_FLOAT_TYPE
(
outType
))
{
func
=
convert
ToFloat
;
func
=
var
ToFloat
;
}
else
{
}
else
{
sclError
(
"
unknown
outType:%d"
,
outType
);
sclError
(
"
invalid convert
outType:%d"
,
outType
);
return
TSDB_CODE_QRY_APP_ERROR
;
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
...
@@ -301,29 +301,49 @@ int32_t vectorConvertFromVarData(SScalarParam* pIn, SScalarParam* pOut, int32_t
...
@@ -301,29 +301,49 @@ int32_t vectorConvertFromVarData(SScalarParam* pIn, SScalarParam* pOut, int32_t
sclSetNull
(
pOut
,
i
);
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
if
(
varDataLen
(
pIn
->
data
)
>=
bufSize
)
{
if
(
TSDB_DATA_TYPE_BINARY
==
inType
)
{
bufSize
=
varDataLen
(
pIn
->
data
)
+
1
;
if
(
varDataLen
(
pIn
->
data
)
>=
bufSize
)
{
tmp
=
realloc
(
tmp
,
bufSize
);
bufSize
=
varDataLen
(
pIn
->
data
)
+
1
;
tmp
=
realloc
(
tmp
,
bufSize
);
}
memcpy
(
tmp
,
varDataVal
(
pIn
->
data
),
varDataLen
(
pIn
->
data
));
tmp
[
varDataLen
(
pIn
->
data
)]
=
0
;
}
else
{
if
(
varDataLen
(
pIn
->
data
)
*
TSDB_NCHAR_SIZE
>=
bufSize
)
{
bufSize
=
varDataLen
(
pIn
->
data
)
*
TSDB_NCHAR_SIZE
+
1
;
tmp
=
realloc
(
tmp
,
bufSize
);
}
int
len
=
taosUcs4ToMbs
(
varDataVal
(
pIn
->
data
),
varDataLen
(
pIn
->
data
),
tmp
);
if
(
len
<
0
){
sclError
(
"castConvert taosUcs4ToMbs error 1"
);
tfree
(
tmp
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
tmp
[
len
]
=
0
;
}
}
memcpy
(
tmp
,
varDataVal
(
pIn
->
data
),
varDataLen
(
pIn
->
data
));
tmp
[
varDataLen
(
pIn
->
data
)]
=
0
;
(
*
func
)(
tmp
,
pOut
,
outType
);
(
*
func
)(
tmp
,
pOut
,
outType
);
}
}
tfree
(
tmp
);
tfree
(
tmp
);
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
vectorConvertImpl
(
SScalarParam
*
pIn
,
SScalarParam
*
pOut
)
{
int32_t
vectorConvertImpl
(
SScalarParam
*
pIn
,
SScalarParam
*
pOut
)
{
int16_t
inType
=
pIn
->
type
;
int16_t
inType
=
pIn
->
type
;
int16_t
inBytes
=
pIn
->
bytes
;
int16_t
inBytes
=
pIn
->
bytes
;
char
*
input
=
pIn
->
data
;
int16_t
outType
=
pOut
->
type
;
int16_t
outType
=
pOut
->
type
;
int16_t
outBytes
=
pOut
->
bytes
;
int16_t
outBytes
=
pOut
->
bytes
;
char
*
output
=
pOut
->
data
;
if
(
inType
==
TSDB_DATA_TYPE_BINARY
||
inType
==
TSDB_DATA_TYPE_NCHAR
)
{
return
vectorConvertFromVarData
(
pIn
,
pOut
,
inType
,
outType
);
}
switch
(
outType
)
{
switch
(
outType
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_TINYINT
:
...
@@ -331,234 +351,55 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
...
@@ -331,234 +351,55 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
if
(
inType
==
TSDB_DATA_TYPE_BINARY
)
{
for
(
int32_t
i
=
0
;
i
<
pIn
->
num
;
++
i
)
{
int32_t
bufSize
=
0
;
sclMoveParamListData
(
pIn
,
1
,
i
)
;
char
*
tmp
=
NULL
;
sclMoveParamListData
(
pOut
,
1
,
i
)
;
for
(
int32_t
i
=
0
;
i
<
pIn
->
num
;
++
i
)
{
if
(
sclIsNull
(
pIn
,
i
))
{
sclMoveParamListData
(
pIn
,
1
,
i
);
sclSetNull
(
pOut
,
i
);
sclMoveParamListData
(
pOut
,
1
,
i
);
continue
;
if
(
sclIsNull
(
pIn
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
}
if
(
varDataLen
(
pIn
->
data
)
>=
bufSize
)
{
bufSize
=
varDataLen
(
pIn
->
data
)
+
1
;
tmp
=
realloc
(
tmp
,
bufSize
);
}
memcpy
(
tmp
,
varDataVal
(
pIn
->
data
),
varDataLen
(
pIn
->
data
));
tmp
[
varDataLen
(
pIn
->
data
)]
=
0
;
int64_t
value
=
strtoll
(
tmp
,
NULL
,
10
);
SET_TYPED_DATA
(
pOut
->
data
,
outType
,
value
);
}
tfree
(
tmp
);
}
else
if
(
inType
==
TSDB_DATA_TYPE_NCHAR
)
{
int32_t
bufSize
=
0
;
char
*
tmp
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
pIn
->
num
;
++
i
)
{
sclMoveParamListData
(
pIn
,
1
,
i
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pIn
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
}
if
(
varDataLen
(
pIn
->
data
)
*
TSDB_NCHAR_SIZE
>=
bufSize
)
{
bufSize
=
varDataLen
(
pIn
->
data
)
*
TSDB_NCHAR_SIZE
+
1
;
tmp
=
realloc
(
tmp
,
bufSize
);
}
int
len
=
taosUcs4ToMbs
(
varDataVal
(
pIn
->
data
),
varDataLen
(
pIn
->
data
),
tmp
);
if
(
len
<
0
){
sclError
(
"castConvert taosUcs4ToMbs error 1"
);
tfree
(
tmp
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
tmp
[
len
]
=
0
;
int64_t
value
=
strtoll
(
tmp
,
NULL
,
10
);
SET_TYPED_DATA
(
pOut
->
data
,
outType
,
value
);
}
}
int64_t
value
=
0
;
tfree
(
tmp
);
GET_TYPED_DATA
(
value
,
int64_t
,
inType
,
pIn
->
data
);
}
else
{
SET_TYPED_DATA
(
pOut
->
data
,
outType
,
value
);
for
(
int32_t
i
=
0
;
i
<
pIn
->
num
;
++
i
)
{
int64_t
value
=
0
;
GET_TYPED_DATA
(
value
,
int64_t
,
inType
,
input
);
SET_TYPED_DATA
(
output
,
outType
,
value
);
input
+=
tDataTypes
[
inType
].
bytes
;
output
+=
tDataTypes
[
outType
].
bytes
;
}
}
}
break
;
break
;
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
if
(
inType
==
TSDB_DATA_TYPE_BINARY
)
{
for
(
int32_t
i
=
0
;
i
<
pIn
->
num
;
++
i
)
{
int32_t
bufSize
=
varDataLen
(
input
)
+
1
;
sclMoveParamListData
(
pIn
,
1
,
i
);
char
*
tmp
=
malloc
(
bufSize
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
NULL
==
tmp
)
{
sclError
(
"malloc %d failed"
,
bufSize
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
for
(
int32_t
i
=
0
;
i
<
pIn
->
num
;
++
i
)
{
if
(
isNull
(
input
,
inType
))
{
assignVal
(
output
,
getNullValue
(
outType
),
0
,
outType
);
}
else
{
if
(
varDataLen
(
input
)
>=
bufSize
)
{
bufSize
=
varDataLen
(
input
)
+
1
;
tmp
=
realloc
(
tmp
,
bufSize
);
}
memcpy
(
tmp
,
varDataVal
(
input
),
varDataLen
(
input
));
tmp
[
varDataLen
(
input
)]
=
0
;
uint64_t
value
=
strtoull
(
tmp
,
NULL
,
10
);
SET_TYPED_DATA
(
output
,
outType
,
value
);
}
input
+=
varDataLen
(
input
)
+
VARSTR_HEADER_SIZE
;
output
+=
tDataTypes
[
outType
].
bytes
;
}
tfree
(
tmp
);
if
(
sclIsNull
(
pIn
,
i
))
{
}
else
if
(
inType
==
TSDB_DATA_TYPE_NCHAR
)
{
sclSetNull
(
pOut
,
i
);
int32_t
bufSize
=
varDataLen
(
input
)
*
TSDB_NCHAR_SIZE
+
1
;
continue
;
char
*
tmp
=
calloc
(
1
,
bufSize
);
if
(
NULL
==
tmp
)
{
sclError
(
"calloc %d failed"
,
bufSize
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
}
for
(
int32_t
i
=
0
;
i
<
pIn
->
num
;
++
i
)
{
uint64_t
value
=
0
;
if
(
isNull
(
input
,
inType
))
{
assignVal
(
output
,
getNullValue
(
outType
),
0
,
outType
);
GET_TYPED_DATA
(
value
,
uint64_t
,
inType
,
pIn
->
data
);
}
else
{
SET_TYPED_DATA
(
pOut
->
data
,
outType
,
value
);
if
(
varDataLen
(
input
)
*
TSDB_NCHAR_SIZE
>=
bufSize
)
{
bufSize
=
varDataLen
(
input
)
*
TSDB_NCHAR_SIZE
+
1
;
tmp
=
realloc
(
tmp
,
bufSize
);
}
int
len
=
taosUcs4ToMbs
(
varDataVal
(
input
),
varDataLen
(
input
),
tmp
);
if
(
len
<
0
){
sclError
(
"castConvert taosUcs4ToMbs error 1"
);
tfree
(
tmp
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
tmp
[
len
]
=
0
;
uint64_t
value
=
strtoull
(
tmp
,
NULL
,
10
);
SET_TYPED_DATA
(
output
,
outType
,
value
);
}
input
+=
varDataLen
(
input
)
+
VARSTR_HEADER_SIZE
;
output
+=
tDataTypes
[
outType
].
bytes
;
}
tfree
(
tmp
);
}
else
{
for
(
int32_t
i
=
0
;
i
<
pIn
->
num
;
++
i
)
{
if
(
isNull
(
input
,
inType
))
{
assignVal
(
output
,
getNullValue
(
outType
),
0
,
outType
);
}
else
{
uint64_t
value
=
0
;
GET_TYPED_DATA
(
value
,
uint64_t
,
inType
,
input
);
SET_TYPED_DATA
(
output
,
outType
,
value
);
}
input
+=
tDataTypes
[
inType
].
bytes
;
output
+=
tDataTypes
[
outType
].
bytes
;
}
}
}
break
;
break
;
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_DOUBLE
:
case
TSDB_DATA_TYPE_DOUBLE
:
if
(
inType
==
TSDB_DATA_TYPE_BINARY
)
{
for
(
int32_t
i
=
0
;
i
<
pIn
->
num
;
++
i
)
{
int32_t
bufSize
=
varDataLen
(
input
)
+
1
;
sclMoveParamListData
(
pIn
,
1
,
i
);
char
*
tmp
=
malloc
(
bufSize
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
NULL
==
tmp
)
{
sclError
(
"malloc %d failed"
,
bufSize
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
for
(
int32_t
i
=
0
;
i
<
pIn
->
num
;
++
i
)
{
if
(
sclIsNull
(
pIn
,
i
))
{
if
(
isNull
(
input
,
inType
))
{
sclSetNull
(
pOut
,
i
);
assignVal
(
output
,
getNullValue
(
outType
),
0
,
outType
);
continue
;
}
else
{
if
(
varDataLen
(
input
)
>=
bufSize
)
{
bufSize
=
varDataLen
(
input
)
+
1
;
tmp
=
realloc
(
tmp
,
bufSize
);
}
memcpy
(
tmp
,
varDataVal
(
input
),
varDataLen
(
input
));
tmp
[
varDataLen
(
input
)]
=
0
;
double
value
=
strtod
(
tmp
,
NULL
);
SET_TYPED_DATA
(
output
,
outType
,
value
);
}
input
+=
varDataLen
(
input
)
+
VARSTR_HEADER_SIZE
;
output
+=
tDataTypes
[
outType
].
bytes
;
}
}
tfree
(
tmp
);
double
value
=
0
;
}
else
if
(
inType
==
TSDB_DATA_TYPE_NCHAR
)
{
int32_t
bufSize
=
varDataLen
(
input
)
*
TSDB_NCHAR_SIZE
+
1
;
GET_TYPED_DATA
(
value
,
double
,
inType
,
pIn
->
data
);
char
*
tmp
=
calloc
(
1
,
bufSize
);
SET_TYPED_DATA
(
pOut
->
data
,
outType
,
value
);
if
(
NULL
==
tmp
)
{
sclError
(
"calloc %d failed"
,
bufSize
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
for
(
int32_t
i
=
0
;
i
<
pIn
->
num
;
++
i
)
{
if
(
isNull
(
input
,
inType
))
{
assignVal
(
output
,
getNullValue
(
outType
),
0
,
outType
);
}
else
{
if
(
varDataLen
(
input
)
*
TSDB_NCHAR_SIZE
>=
bufSize
)
{
bufSize
=
varDataLen
(
input
)
*
TSDB_NCHAR_SIZE
+
1
;
tmp
=
realloc
(
tmp
,
bufSize
);
}
int
len
=
taosUcs4ToMbs
(
varDataVal
(
input
),
varDataLen
(
input
),
tmp
);
if
(
len
<
0
){
sclError
(
"castConvert taosUcs4ToMbs error 1"
);
tfree
(
tmp
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
tmp
[
len
]
=
0
;
double
value
=
strtod
(
tmp
,
NULL
);
SET_TYPED_DATA
(
output
,
outType
,
value
);
}
input
+=
varDataLen
(
input
)
+
VARSTR_HEADER_SIZE
;
output
+=
tDataTypes
[
outType
].
bytes
;
}
tfree
(
tmp
);
}
else
{
for
(
int32_t
i
=
0
;
i
<
pIn
->
num
;
++
i
)
{
if
(
isNull
(
input
,
inType
))
{
assignVal
(
output
,
getNullValue
(
outType
),
0
,
outType
);
}
else
{
int64_t
value
=
0
;
GET_TYPED_DATA
(
value
,
int64_t
,
inType
,
input
);
SET_TYPED_DATA
(
output
,
outType
,
value
);
}
input
+=
tDataTypes
[
inType
].
bytes
;
output
+=
tDataTypes
[
outType
].
bytes
;
}
}
}
break
;
break
;
default:
default:
...
@@ -673,7 +514,7 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p
...
@@ -673,7 +514,7 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
void
vectorAdd
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorAdd
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
...
@@ -686,11 +527,6 @@ void vectorAdd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or
...
@@ -686,11 +527,6 @@ void vectorAdd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or
return
;
return
;
}
}
if
(
pLeft
->
dataInBlock
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
pLeft
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
return
;
return
;
}
}
...
@@ -700,62 +536,65 @@ void vectorAdd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or
...
@@ -700,62 +536,65 @@ void vectorAdd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
rightParam
.
data
)
{
if
(
NULL
==
rightParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
return
;
return
;
}
}
if
(
pRight
->
dataInBlock
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pRight
->
data
;
pRight
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
tfree
(
rightParam
.
data
);
sclFreeParam
(
&
rightParam
);
return
;
return
;
}
}
pRight
=
&
rightParam
;
pRight
=
&
rightParam
;
}
}
double
*
output
=
(
double
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeft
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeft
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRight
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRight
->
type
);
if
(
pLeft
->
num
==
pRight
->
num
)
{
if
(
pLeft
->
num
==
pRight
->
num
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
sclMoveParamListData
(
pLeft
,
1
,
i
);
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclMoveParamListData
(
pRight
,
1
,
i
);
SET_DOUBLE_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
+
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
SET_DOUBLE_VAL
(
pOut
->
data
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
+
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
}
}
}
else
if
(
pLeft
->
num
==
1
)
{
}
else
if
(
pLeft
->
num
==
1
)
{
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
0
),
pLeft
->
type
)
||
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclMoveParamListData
(
pRight
,
1
,
i
);
SET_DOUBLE_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
0
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
0
)
+
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
SET_DOUBLE_VAL
(
pOut
->
data
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
0
)
+
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
}
}
}
else
if
(
pRight
->
num
==
1
)
{
}
else
if
(
pRight
->
num
==
1
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
0
),
pRight
->
type
))
{
sclMoveParamListData
(
pLeft
,
1
,
i
);
SET_DOUBLE_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
0
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
+
getVectorDoubleValueFnRight
(
pRight
->
data
,
0
));
SET_DOUBLE_VAL
(
pOut
->
data
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
+
getVectorDoubleValueFnRight
(
pRight
->
data
,
0
));
}
}
}
}
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
tfree
(
rightParam
.
data
);
sclFreeParam
(
&
rightParam
);
}
}
void
vectorSub
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorSub
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
...
@@ -768,11 +607,6 @@ void vectorSub(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or
...
@@ -768,11 +607,6 @@ void vectorSub(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or
return
;
return
;
}
}
if
(
pLeft
->
dataInBlock
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
pLeft
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
return
;
return
;
}
}
...
@@ -782,60 +616,65 @@ void vectorSub(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or
...
@@ -782,60 +616,65 @@ void vectorSub(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
rightParam
.
data
)
{
if
(
NULL
==
rightParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
return
;
return
;
}
}
if
(
pRight
->
dataInBlock
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pRight
->
data
;
pRight
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
tfree
(
rightParam
.
data
);
sclFreeParam
(
&
rightParam
);
return
;
return
;
}
}
pRight
=
&
rightParam
;
pRight
=
&
rightParam
;
}
}
double
*
output
=
(
double
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeft
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeft
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRight
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRight
->
type
);
if
(
pLeft
->
num
==
pRight
->
num
)
{
if
(
pLeft
->
num
==
pRight
->
num
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
sclMoveParamListData
(
pLeft
,
1
,
i
);
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclMoveParamListData
(
pRight
,
1
,
i
);
SET_DOUBLE_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
continue
;
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
}
}
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
-
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
}
SET_DOUBLE_VAL
(
pOut
->
data
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
-
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
}
}
else
if
(
pLeft
->
num
==
1
)
{
}
else
if
(
pLeft
->
num
==
1
)
{
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
0
),
pLeft
->
type
)
||
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclMoveParamListData
(
pRight
,
1
,
i
);
SET_DOUBLE_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
0
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
0
)
-
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
SET_DOUBLE_VAL
(
pOut
->
data
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
0
)
-
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
}
}
}
else
if
(
pRight
->
num
==
1
)
{
}
else
if
(
pRight
->
num
==
1
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
0
),
pRight
->
type
))
{
sclMoveParamListData
(
pLeft
,
1
,
i
);
SET_DOUBLE_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
0
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
-
getVectorDoubleValueFnRight
(
pRight
->
data
,
0
));
SET_DOUBLE_VAL
(
pOut
->
data
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
-
getVectorDoubleValueFnRight
(
pRight
->
data
,
0
));
}
}
}
}
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
tfree
(
rightParam
.
data
);
sclFreeParam
(
&
rightParam
);
}
}
void
vectorMultiply
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorMultiply
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
...
@@ -848,11 +687,6 @@ void vectorMultiply(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_
...
@@ -848,11 +687,6 @@ void vectorMultiply(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_
return
;
return
;
}
}
if
(
pLeft
->
dataInBlock
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
pLeft
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
return
;
return
;
}
}
...
@@ -862,62 +696,66 @@ void vectorMultiply(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_
...
@@ -862,62 +696,66 @@ void vectorMultiply(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
rightParam
.
data
)
{
if
(
NULL
==
rightParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
return
;
return
;
}
}
if
(
pRight
->
dataInBlock
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pRight
->
data
;
pRight
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
tfree
(
rightParam
.
data
);
sclFreeParam
(
&
rightParam
);
return
;
return
;
}
}
pRight
=
&
rightParam
;
pRight
=
&
rightParam
;
}
}
double
*
output
=
(
double
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeft
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeft
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRight
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRight
->
type
);
if
(
pLeft
->
num
==
pRight
->
num
)
{
if
(
pLeft
->
num
==
pRight
->
num
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
sclMoveParamListData
(
pLeft
,
1
,
i
);
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclMoveParamListData
(
pRight
,
1
,
i
);
SET_DOUBLE_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
*
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
SET_DOUBLE_VAL
(
pOut
->
data
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
*
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
}
}
}
else
if
(
pLeft
->
num
==
1
)
{
}
else
if
(
pLeft
->
num
==
1
)
{
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
0
),
pLeft
->
type
)
||
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclMoveParamListData
(
pRight
,
1
,
i
);
SET_DOUBLE_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
0
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
0
)
*
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
SET_DOUBLE_VAL
(
pOut
->
data
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
0
)
*
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
}
}
}
else
if
(
pRight
->
num
==
1
)
{
}
else
if
(
pRight
->
num
==
1
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
0
),
pRight
->
type
))
{
sclMoveParamListData
(
pLeft
,
1
,
i
);
SET_DOUBLE_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
0
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
*
getVectorDoubleValueFnRight
(
pRight
->
data
,
0
));
SET_DOUBLE_VAL
(
pOut
->
data
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
*
getVectorDoubleValueFnRight
(
pRight
->
data
,
0
));
}
}
}
}
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
tfree
(
rightParam
.
data
);
sclFreeParam
(
&
rightParam
);
}
}
void
vectorDivide
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorDivide
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
...
@@ -930,11 +768,6 @@ void vectorDivide(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
...
@@ -930,11 +768,6 @@ void vectorDivide(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
return
;
return
;
}
}
if
(
pLeft
->
dataInBlock
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
pLeft
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
return
;
return
;
}
}
...
@@ -944,69 +777,66 @@ void vectorDivide(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
...
@@ -944,69 +777,66 @@ void vectorDivide(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
rightParam
.
data
)
{
if
(
NULL
==
rightParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
return
;
return
;
}
}
if
(
pRight
->
dataInBlock
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pRight
->
data
;
pRight
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
tfree
(
rightParam
.
data
);
sclFreeParam
(
&
rightParam
);
return
;
return
;
}
}
pRight
=
&
rightParam
;
pRight
=
&
rightParam
;
}
}
double
*
output
=
(
double
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeft
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeft
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRight
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRight
->
type
);
if
(
pLeft
->
num
==
pRight
->
num
)
{
if
(
pLeft
->
num
==
pRight
->
num
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
sclMoveParamListData
(
pLeft
,
1
,
i
);
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclMoveParamListData
(
pRight
,
1
,
i
);
SET_DOUBLE_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
/
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
SET_DOUBLE_VAL
(
pOut
->
data
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
/
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
}
}
}
else
if
(
pLeft
->
num
==
1
)
{
}
else
if
(
pLeft
->
num
==
1
)
{
double
left
=
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
0
);
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
)
{
sclMoveParamListData
(
pRight
,
1
,
i
);
sclMoveParamListData
(
pOut
,
1
,
i
);
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
,
output
+=
1
)
{
if
(
sclIsNull
(
pLeft
,
0
)
||
sclIsNull
(
pRight
,
i
))
{
if
(
isNull
(
&
left
,
pLeft
->
type
)
||
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclSetNull
(
pOut
,
i
);
SET_DOUBLE_NULL
(
output
);
continue
;
continue
;
}
}
SET_DOUBLE_VAL
(
output
,
left
/
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
SET_DOUBLE_VAL
(
pOut
->
data
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
0
)
/
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
));
}
}
}
else
if
(
pRight
->
num
==
1
)
{
}
else
if
(
pRight
->
num
==
1
)
{
double
right
=
getVectorDoubleValueFnRight
(
pRight
->
data
,
0
);
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
)
{
sclMoveParamListData
(
pLeft
,
1
,
i
);
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
,
output
+=
1
)
{
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
isNull
(
&
right
,
pRight
->
type
))
{
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
0
))
{
SET_DOUBLE_NULL
(
output
);
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
/
right
);
SET_DOUBLE_VAL
(
pOut
->
data
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
/
getVectorDoubleValueFnRight
(
pRight
->
data
,
0
)
);
}
}
}
}
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
tfree
(
rightParam
.
data
);
sclFreeParam
(
&
rightParam
);
}
}
void
vectorRemainder
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorRemainder
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
...
@@ -1019,11 +849,6 @@ void vectorRemainder(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32
...
@@ -1019,11 +849,6 @@ void vectorRemainder(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32
return
;
return
;
}
}
if
(
pLeft
->
dataInBlock
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
pLeft
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
return
;
return
;
}
}
...
@@ -1033,92 +858,92 @@ void vectorRemainder(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32
...
@@ -1033,92 +858,92 @@ void vectorRemainder(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
rightParam
.
data
)
{
if
(
NULL
==
rightParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
return
;
return
;
}
}
if
(
pRight
->
dataInBlock
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pRight
->
data
;
pRight
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
tfree
(
rightParam
.
data
);
sclFreeParam
(
&
rightParam
);
return
;
return
;
}
}
pRight
=
&
rightParam
;
pRight
=
&
rightParam
;
}
}
double
*
output
=
(
double
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeft
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeft
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRight
->
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRight
->
type
);
if
(
pLeft
->
num
==
pRight
->
num
)
{
if
(
pLeft
->
num
==
pRight
->
num
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
sclMoveParamListData
(
pLeft
,
1
,
i
);
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclMoveParamListData
(
pRight
,
1
,
i
);
SET_DOUBLE_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
double
v
,
u
=
0
.
0
;
double
v
,
u
=
0
.
0
;
GET_TYPED_DATA
(
v
,
double
,
pRight
->
type
,
getVectorValueAddrFnRight
(
pRight
->
data
,
i
)
);
GET_TYPED_DATA
(
v
,
double
,
pRight
->
type
,
pRight
->
data
);
if
(
getComparFunc
(
TSDB_DATA_TYPE_DOUBLE
,
0
)(
&
v
,
&
u
)
==
0
)
{
if
(
getComparFunc
(
TSDB_DATA_TYPE_DOUBLE
,
0
)(
&
v
,
&
u
)
==
0
)
{
SET_DOUBLE_NULL
(
output
);
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
double
left
=
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
);
double
left
=
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
);
double
right
=
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
);
double
right
=
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
);
SET_DOUBLE_VAL
(
output
,
left
-
((
int64_t
)(
left
/
right
))
*
right
);
SET_DOUBLE_VAL
(
pOut
->
data
,
left
-
((
int64_t
)(
left
/
right
))
*
right
);
}
}
}
else
if
(
pLeft
->
num
==
1
)
{
}
else
if
(
pLeft
->
num
==
1
)
{
double
left
=
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
0
);
double
left
=
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
0
);
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
)
{
if
(
isNull
(
&
left
,
pLeft
->
type
)
||
sclMoveParamListData
(
pRight
,
1
,
i
);
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclMoveParamListData
(
pOut
,
1
,
i
);
SET_DOUBLE_NULL
(
output
);
if
(
sclIsNull
(
pLeft
,
0
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
double
v
,
u
=
0
.
0
;
double
v
,
u
=
0
.
0
;
GET_TYPED_DATA
(
v
,
double
,
pRight
->
type
,
getVectorValueAddrFnRight
(
pRight
->
data
,
i
)
);
GET_TYPED_DATA
(
v
,
double
,
pRight
->
type
,
pRight
->
data
);
if
(
getComparFunc
(
TSDB_DATA_TYPE_DOUBLE
,
0
)(
&
v
,
&
u
)
==
0
)
{
if
(
getComparFunc
(
TSDB_DATA_TYPE_DOUBLE
,
0
)(
&
v
,
&
u
)
==
0
)
{
SET_DOUBLE_NULL
(
output
);
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
double
right
=
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
);
double
right
=
getVectorDoubleValueFnRight
(
pRight
->
data
,
i
);
SET_DOUBLE_VAL
(
output
,
left
-
((
int64_t
)(
left
/
right
))
*
right
);
SET_DOUBLE_VAL
(
pOut
->
data
,
left
-
((
int64_t
)(
left
/
right
))
*
right
);
}
}
}
else
if
(
pRight
->
num
==
1
)
{
}
else
if
(
pRight
->
num
==
1
)
{
double
right
=
getVectorDoubleValueFnRight
(
pRight
->
data
,
0
);
double
right
=
getVectorDoubleValueFnRight
(
pRight
->
data
,
0
);
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
sclMoveParamListData
(
pLeft
,
1
,
i
);
isNull
(
&
right
,
pRight
->
type
))
{
sclMoveParamListData
(
pOut
,
1
,
i
);
SET_DOUBLE_NULL
(
output
);
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
double
v
,
u
=
0
.
0
;
double
v
,
u
=
0
.
0
;
GET_TYPED_DATA
(
v
,
double
,
pRight
->
type
,
getVectorValueAddrFnRight
(
pRight
->
data
,
0
)
);
GET_TYPED_DATA
(
v
,
double
,
pRight
->
type
,
pRight
->
data
);
if
(
getComparFunc
(
TSDB_DATA_TYPE_DOUBLE
,
0
)(
&
v
,
&
u
)
==
0
)
{
if
(
getComparFunc
(
TSDB_DATA_TYPE_DOUBLE
,
0
)(
&
v
,
&
u
)
==
0
)
{
SET_DOUBLE_NULL
(
output
);
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
double
left
=
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
);
double
left
=
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
);
SET_DOUBLE_VAL
(
output
,
left
-
((
int64_t
)(
left
/
right
))
*
right
);
SET_DOUBLE_VAL
(
pOut
->
data
,
left
-
((
int64_t
)(
left
/
right
))
*
right
);
}
}
}
}
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
tfree
(
rightParam
.
data
);
sclFreeParam
(
&
rightParam
);
}
}
void
vectorConcat
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
void
vectorConcat
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
...
@@ -1168,11 +993,10 @@ void vectorConcat(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
...
@@ -1168,11 +993,10 @@ void vectorConcat(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
varDataSetLen
(
output
,
varDataLen
(
left
)
+
varDataLen
(
pRight
->
data
));
varDataSetLen
(
output
,
varDataLen
(
left
)
+
varDataLen
(
pRight
->
data
));
}
}
}
}
}
}
void
vectorBitAnd
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorBitAnd
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
...
@@ -1181,15 +1005,10 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
...
@@ -1181,15 +1005,10 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
if
(
IS_VAR_DATA_TYPE
(
pLeft
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pLeft
->
type
))
{
leftParam
.
data
=
calloc
(
leftParam
.
num
,
sizeof
(
int64_t
));
leftParam
.
data
=
calloc
(
leftParam
.
num
,
sizeof
(
int64_t
));
if
(
NULL
==
leftParam
.
data
)
{
if
(
NULL
==
leftParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
leftParam
.
num
*
sizeof
(
int64_t
)));
sclError
(
"malloc %d failed"
,
(
int32_t
)(
leftParam
.
num
*
sizeof
(
double
)));
return
;
return
;
}
}
if
(
pLeft
->
dataInBlock
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
pLeft
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
return
;
return
;
}
}
...
@@ -1198,63 +1017,67 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
...
@@ -1198,63 +1017,67 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
if
(
IS_VAR_DATA_TYPE
(
pRight
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pRight
->
type
))
{
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
int64_t
));
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
int64_t
));
if
(
NULL
==
rightParam
.
data
)
{
if
(
NULL
==
rightParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
int64_t
)));
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
return
;
return
;
}
}
if
(
pRight
->
dataInBlock
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pRight
->
data
;
pRight
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
tfree
(
rightParam
.
data
);
sclFreeParam
(
&
rightParam
);
return
;
return
;
}
}
pRight
=
&
rightParam
;
pRight
=
&
rightParam
;
}
}
int64_t
*
output
=
(
int64_t
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
_getBigintValue_fn_t
getVectorBigintValueFnLeft
=
getVectorBigintValueFn
(
pLeft
->
type
);
_getBigintValue_fn_t
getVectorBigintValueFnLeft
=
getVectorBigintValueFn
(
pLeft
->
type
);
_getBigintValue_fn_t
getVectorBigintValueFnRight
=
getVectorBigintValueFn
(
pRight
->
type
);
_getBigintValue_fn_t
getVectorBigintValueFnRight
=
getVectorBigintValueFn
(
pRight
->
type
);
if
(
pLeft
->
num
==
pRight
->
num
)
{
if
(
pLeft
->
num
==
pRight
->
num
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
sclMoveParamListData
(
pLeft
,
1
,
i
);
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclMoveParamListData
(
pRight
,
1
,
i
);
SET_BIGINT_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_BIGINT_VAL
(
output
,
getVectorBigintValueFnLeft
(
pLeft
->
data
,
i
)
&
getVectorBigintValueFnRight
(
pRight
->
data
,
i
));
SET_BIGINT_VAL
(
pOut
->
data
,
getVectorBigintValueFnLeft
(
pLeft
->
data
,
i
)
&
getVectorBigintValueFnRight
(
pRight
->
data
,
i
));
}
}
}
else
if
(
pLeft
->
num
==
1
)
{
}
else
if
(
pLeft
->
num
==
1
)
{
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
0
),
pLeft
->
type
)
||
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclMoveParamListData
(
pRight
,
1
,
i
);
SET_BIGINT_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
0
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_BIGINT_VAL
(
output
,
getVectorBigintValueFnLeft
(
pLeft
->
data
,
0
)
&
getVectorBigintValueFnRight
(
pRight
->
data
,
i
));
SET_BIGINT_VAL
(
pOut
->
data
,
getVectorBigintValueFnLeft
(
pLeft
->
data
,
0
)
&
getVectorBigintValueFnRight
(
pRight
->
data
,
i
));
}
}
}
else
if
(
pRight
->
num
==
1
)
{
}
else
if
(
pRight
->
num
==
1
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
0
),
pRight
->
type
))
{
sclMoveParamListData
(
pLeft
,
1
,
i
);
SET_BIGINT_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
0
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_BIGINT_VAL
(
output
,
getVectorBigintValueFnLeft
(
pLeft
->
data
,
i
)
&
getVectorBigintValueFnRight
(
pRight
->
data
,
0
));
SET_BIGINT_VAL
(
pOut
->
data
,
getVectorBigintValueFnLeft
(
pLeft
->
data
,
i
)
&
getVectorBigintValueFnRight
(
pRight
->
data
,
0
));
}
}
}
}
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
tfree
(
rightParam
.
data
);
sclFreeParam
(
&
rightParam
);
}
}
void
vectorBitOr
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorBitOr
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
...
@@ -1263,15 +1086,10 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _
...
@@ -1263,15 +1086,10 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _
if
(
IS_VAR_DATA_TYPE
(
pLeft
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pLeft
->
type
))
{
leftParam
.
data
=
calloc
(
leftParam
.
num
,
sizeof
(
int64_t
));
leftParam
.
data
=
calloc
(
leftParam
.
num
,
sizeof
(
int64_t
));
if
(
NULL
==
leftParam
.
data
)
{
if
(
NULL
==
leftParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
leftParam
.
num
*
sizeof
(
int64_t
)));
sclError
(
"malloc %d failed"
,
(
int32_t
)(
leftParam
.
num
*
sizeof
(
double
)));
return
;
return
;
}
}
if
(
pLeft
->
dataInBlock
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
pLeft
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
return
;
return
;
}
}
...
@@ -1280,131 +1098,119 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _
...
@@ -1280,131 +1098,119 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _
if
(
IS_VAR_DATA_TYPE
(
pRight
->
type
))
{
if
(
IS_VAR_DATA_TYPE
(
pRight
->
type
))
{
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
int64_t
));
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
int64_t
));
if
(
NULL
==
rightParam
.
data
)
{
if
(
NULL
==
rightParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
int64_t
)));
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
return
;
return
;
}
}
if
(
pRight
->
dataInBlock
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pRight
->
data
;
pRight
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
tfree
(
leftParam
.
data
);
sclFreeParam
(
&
leftParam
);
tfree
(
rightParam
.
data
);
sclFreeParam
(
&
rightParam
);
return
;
return
;
}
}
pRight
=
&
rightParam
;
pRight
=
&
rightParam
;
}
}
int64_t
*
output
=
(
int64_t
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
_getBigintValue_fn_t
getVectorBigintValueFnLeft
=
getVectorBigintValueFn
(
pLeft
->
type
);
_getBigintValue_fn_t
getVectorBigintValueFnLeft
=
getVectorBigintValueFn
(
pLeft
->
type
);
_getBigintValue_fn_t
getVectorBigintValueFnRight
=
getVectorBigintValueFn
(
pRight
->
type
);
_getBigintValue_fn_t
getVectorBigintValueFnRight
=
getVectorBigintValueFn
(
pRight
->
type
);
if
(
pLeft
->
num
==
pRight
->
num
)
{
if
(
pLeft
->
num
==
pRight
->
num
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
sclMoveParamListData
(
pLeft
,
1
,
i
);
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclMoveParamListData
(
pRight
,
1
,
i
);
SET_BIGINT_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_BIGINT_VAL
(
output
,
getVectorBigintValueFnLeft
(
pLeft
->
data
,
i
)
|
getVectorBigintValueFnRight
(
pRight
->
data
,
i
));
SET_BIGINT_VAL
(
pOut
->
data
,
getVectorBigintValueFnLeft
(
pLeft
->
data
,
i
)
|
getVectorBigintValueFnRight
(
pRight
->
data
,
i
));
}
}
}
else
if
(
pLeft
->
num
==
1
)
{
}
else
if
(
pLeft
->
num
==
1
)
{
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
0
),
pLeft
->
type
)
||
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclMoveParamListData
(
pRight
,
1
,
i
);
SET_BIGINT_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
0
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_BIGINT_VAL
(
output
,
getVectorBigintValueFnLeft
(
pLeft
->
data
,
0
)
|
getVectorBigintValueFnRight
(
pRight
->
data
,
i
));
SET_BIGINT_VAL
(
pOut
->
data
,
getVectorBigintValueFnLeft
(
pLeft
->
data
,
0
)
|
getVectorBigintValueFnRight
(
pRight
->
data
,
i
));
}
}
}
else
if
(
pRight
->
num
==
1
)
{
}
else
if
(
pRight
->
num
==
1
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
0
),
pRight
->
type
))
{
sclMoveParamListData
(
pLeft
,
1
,
i
);
SET_BIGINT_NULL
(
output
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
0
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
SET_BIGINT_VAL
(
output
,
getVectorBigintValueFnLeft
(
pLeft
->
data
,
i
)
|
getVectorBigintValueFnRight
(
pRight
->
data
,
0
));
SET_BIGINT_VAL
(
pOut
->
data
,
getVectorBigintValueFnLeft
(
pLeft
->
data
,
i
)
|
getVectorBigintValueFnRight
(
pRight
->
data
,
0
));
}
}
}
}
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
sclFreeParam
(
&
leftParam
);
sclFreeParam
(
&
rightParam
);
}
}
void
vectorCompareImpl
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
,
int32_t
optr
)
{
void
vectorCompareImpl
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
,
int32_t
optr
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
__compar_fn_t
fp
=
filterGetCompFunc
(
pLeft
->
type
,
optr
);
__compar_fn_t
fp
=
filterGetCompFunc
(
pLeft
->
type
,
optr
);
bool
res
=
false
;
bool
res
=
false
;
bool
*
output
=
(
bool
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
NULL
;
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
NULL
;
if
(
IS_VAR_DATA_TYPE
(
pLeft
->
type
)
&&
!
pLeft
->
dataInBlock
)
{
getVectorValueAddrFnLeft
=
getVectorValueAddr_default
;
}
else
{
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
}
if
(
IS_VAR_DATA_TYPE
(
pRight
->
type
)
&&
!
pRight
->
dataInBlock
)
{
getVectorValueAddrFnRight
=
getVectorValueAddr_default
;
}
else
{
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
}
if
(
pLeft
->
num
==
pRight
->
num
)
{
if
(
pLeft
->
num
==
pRight
->
num
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
num
&&
i
>=
0
;
i
+=
step
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
sclMoveParamListData
(
pLeft
,
1
,
i
);
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
sclMoveParamListData
(
pRight
,
1
,
i
);
res
=
false
;
sclMoveParamListData
(
pOut
,
1
,
i
);
SET_TYPED_DATA
(
output
,
TSDB_DATA_TYPE_BOOL
,
res
);
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
i
))
{
sclSetNull
(
pOut
,
i
);
continue
;
continue
;
}
}
res
=
filterDoCompare
(
fp
,
optr
,
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
getVectorValueAddrFnRight
(
pRight
->
data
,
i
));
SET_TYPED_DATA
(
output
,
TSDB_DATA_TYPE_BOOL
,
res
);
res
=
filterDoCompare
(
fp
,
optr
,
pLeft
->
data
,
pRight
->
data
);
SET_TYPED_DATA
(
pOut
->
data
,
TSDB_DATA_TYPE_BOOL
,
res
);
}
}
}
else
if
(
pLeft
->
num
==
1
)
{
}
else
if
(
pLeft
->
num
==
1
)
{
void
*
leftData
=
getVectorValueAddrFnLeft
(
pLeft
->
data
,
0
);
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
)
{
sclMoveParamListData
(
pRight
,
1
,
i
);
for
(;
i
>=
0
&&
i
<
pRight
->
num
;
i
+=
step
,
output
+=
1
)
{
if
(
isNull
(
leftData
,
pLeft
->
type
)
||
isNull
(
getVectorValueAddrFnRight
(
pRight
->
data
,
i
),
pRight
->
type
))
{
if
(
sclIsNull
(
pLeft
,
0
)
||
sclIsNull
(
pRight
,
i
))
{
res
=
false
;
sclSetNull
(
pOut
,
i
);
SET_TYPED_DATA
(
output
,
TSDB_DATA_TYPE_BOOL
,
res
);
continue
;
continue
;
}
}
res
=
filterDoCompare
(
fp
,
optr
,
leftData
,
getVectorValueAddrFnRight
(
pRight
->
data
,
i
));
SET_TYPED_DATA
(
output
,
TSDB_DATA_TYPE_BOOL
,
res
);
res
=
filterDoCompare
(
fp
,
optr
,
pLeft
->
data
,
pRight
->
data
);
SET_TYPED_DATA
(
pOut
->
data
,
TSDB_DATA_TYPE_BOOL
,
res
);
}
}
}
else
if
(
pRight
->
num
==
1
)
{
}
else
if
(
pRight
->
num
==
1
)
{
void
*
rightData
=
getVectorValueAddrFnRight
(
pRight
->
data
,
0
);
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
)
{
sclMoveParamListData
(
pLeft
,
1
,
i
);
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
,
output
+=
1
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
)
||
isNull
(
rightData
,
pRight
->
type
))
{
if
(
sclIsNull
(
pLeft
,
i
)
||
sclIsNull
(
pRight
,
0
))
{
res
=
false
;
sclSetNull
(
pOut
,
i
);
SET_TYPED_DATA
(
output
,
TSDB_DATA_TYPE_BOOL
,
res
);
continue
;
continue
;
}
}
res
=
filterDoCompare
(
fp
,
optr
,
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
rightD
ata
);
res
=
filterDoCompare
(
fp
,
optr
,
pLeft
->
data
,
pRight
->
d
ata
);
SET_TYPED_DATA
(
output
,
TSDB_DATA_TYPE_BOOL
,
res
);
SET_TYPED_DATA
(
pOut
->
data
,
TSDB_DATA_TYPE_BOOL
,
res
);
}
}
}
}
}
}
void
vectorCompare
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
,
int32_t
optr
)
{
void
vectorCompare
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
,
int32_t
optr
)
{
SScalarParam
pLeftOut
=
{
0
};
SScalarParam
pLeftOut
=
{
0
};
SScalarParam
pRightOut
=
{
0
};
SScalarParam
pRightOut
=
{
0
};
...
@@ -1426,118 +1232,100 @@ void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
...
@@ -1426,118 +1232,100 @@ void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
param2
=
pRight
;
param2
=
pRight
;
}
}
vectorCompareImpl
(
param1
,
param2
,
o
ut
,
_ord
,
optr
);
vectorCompareImpl
(
param1
,
param2
,
pO
ut
,
_ord
,
optr
);
}
}
void
vectorGreater
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorGreater
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
o
ut
,
_ord
,
OP_TYPE_GREATER_THAN
);
vectorCompare
(
pLeft
,
pRight
,
pO
ut
,
_ord
,
OP_TYPE_GREATER_THAN
);
}
}
void
vectorGreaterEqual
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorGreaterEqual
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
o
ut
,
_ord
,
OP_TYPE_GREATER_EQUAL
);
vectorCompare
(
pLeft
,
pRight
,
pO
ut
,
_ord
,
OP_TYPE_GREATER_EQUAL
);
}
}
void
vectorLower
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorLower
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
o
ut
,
_ord
,
OP_TYPE_LOWER_THAN
);
vectorCompare
(
pLeft
,
pRight
,
pO
ut
,
_ord
,
OP_TYPE_LOWER_THAN
);
}
}
void
vectorLowerEqual
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorLowerEqual
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
o
ut
,
_ord
,
OP_TYPE_LOWER_EQUAL
);
vectorCompare
(
pLeft
,
pRight
,
pO
ut
,
_ord
,
OP_TYPE_LOWER_EQUAL
);
}
}
void
vectorEqual
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorEqual
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
o
ut
,
_ord
,
OP_TYPE_EQUAL
);
vectorCompare
(
pLeft
,
pRight
,
pO
ut
,
_ord
,
OP_TYPE_EQUAL
);
}
}
void
vectorNotEqual
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorNotEqual
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
o
ut
,
_ord
,
OP_TYPE_NOT_EQUAL
);
vectorCompare
(
pLeft
,
pRight
,
pO
ut
,
_ord
,
OP_TYPE_NOT_EQUAL
);
}
}
void
vectorIn
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorIn
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
o
ut
,
_ord
,
OP_TYPE_IN
);
vectorCompare
(
pLeft
,
pRight
,
pO
ut
,
_ord
,
OP_TYPE_IN
);
}
}
void
vectorNotIn
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorNotIn
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
o
ut
,
_ord
,
OP_TYPE_NOT_IN
);
vectorCompare
(
pLeft
,
pRight
,
pO
ut
,
_ord
,
OP_TYPE_NOT_IN
);
}
}
void
vectorLike
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorLike
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
o
ut
,
_ord
,
OP_TYPE_LIKE
);
vectorCompare
(
pLeft
,
pRight
,
pO
ut
,
_ord
,
OP_TYPE_LIKE
);
}
}
void
vectorNotLike
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorNotLike
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
o
ut
,
_ord
,
OP_TYPE_NOT_LIKE
);
vectorCompare
(
pLeft
,
pRight
,
pO
ut
,
_ord
,
OP_TYPE_NOT_LIKE
);
}
}
void
vectorMatch
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorMatch
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
o
ut
,
_ord
,
OP_TYPE_MATCH
);
vectorCompare
(
pLeft
,
pRight
,
pO
ut
,
_ord
,
OP_TYPE_MATCH
);
}
}
void
vectorNotMatch
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorNotMatch
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
vectorCompare
(
pLeft
,
pRight
,
o
ut
,
_ord
,
OP_TYPE_NMATCH
);
vectorCompare
(
pLeft
,
pRight
,
pO
ut
,
_ord
,
OP_TYPE_NMATCH
);
}
}
void
vectorIsNull
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorIsNull
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
bool
res
=
false
;
bool
res
=
false
;
bool
*
output
=
(
bool
*
)
out
;
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
)
{
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
NULL
;
sclMoveParamListData
(
pLeft
,
1
,
i
);
sclMoveParamListData
(
pOut
,
1
,
i
);
if
(
IS_VAR_DATA_TYPE
(
pLeft
->
type
)
&&
!
pLeft
->
dataInBlock
)
{
getVectorValueAddrFnLeft
=
getVectorValueAddr_default
;
if
(
sclIsNull
(
pLeft
,
i
))
{
}
else
{
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
}
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
,
output
+=
1
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
))
{
res
=
true
;
res
=
true
;
SET_TYPED_DATA
(
output
,
TSDB_DATA_TYPE_BOOL
,
res
);
SET_TYPED_DATA
(
pOut
->
data
,
TSDB_DATA_TYPE_BOOL
,
res
);
continue
;
continue
;
}
}
res
=
false
;
res
=
false
;
SET_TYPED_DATA
(
output
,
TSDB_DATA_TYPE_BOOL
,
res
);
SET_TYPED_DATA
(
pOut
->
data
,
TSDB_DATA_TYPE_BOOL
,
res
);
}
}
}
}
void
vectorNotNull
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
o
ut
,
int32_t
_ord
)
{
void
vectorNotNull
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pO
ut
,
int32_t
_ord
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
bool
res
=
false
;
bool
res
=
false
;
bool
*
output
=
(
bool
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
NULL
;
if
(
IS_VAR_DATA_TYPE
(
pLeft
->
type
)
&&
!
pLeft
->
dataInBlock
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
)
{
getVectorValueAddrFnLeft
=
getVectorValueAddr_default
;
sclMoveParamListData
(
pLeft
,
1
,
i
);
}
else
{
sclMoveParamListData
(
pOut
,
1
,
i
);
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
}
if
(
sclIsNull
(
pLeft
,
i
))
{
for
(;
i
>=
0
&&
i
<
pLeft
->
num
;
i
+=
step
,
output
+=
1
)
{
if
(
isNull
(
getVectorValueAddrFnLeft
(
pLeft
->
data
,
i
),
pLeft
->
type
))
{
res
=
false
;
res
=
false
;
SET_TYPED_DATA
(
output
,
TSDB_DATA_TYPE_BOOL
,
res
);
SET_TYPED_DATA
(
pOut
->
data
,
TSDB_DATA_TYPE_BOOL
,
res
);
continue
;
continue
;
}
}
res
=
true
;
res
=
true
;
SET_TYPED_DATA
(
output
,
TSDB_DATA_TYPE_BOOL
,
res
);
SET_TYPED_DATA
(
pOut
->
data
,
TSDB_DATA_TYPE_BOOL
,
res
);
}
}
}
void
vectorIsTrue
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
}
SScalarParam
output
=
{.
data
=
out
,
.
num
=
pLeft
->
num
,
.
type
=
TSDB_DATA_TYPE_BOOL
};
if
(
pLeft
->
dataInBlock
)
{
void
vectorIsTrue
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
vectorConvertImpl
(
pLeft
,
pOut
);
pLeft
->
data
=
colInfo
->
pData
;
}
vectorConvertImpl
(
pLeft
,
&
output
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录