Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
3162f930
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3162f930
编写于
3月 26, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-13039] refactor scalar operator.
上级
d4fa5820
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
124 addition
and
95 deletion
+124
-95
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+1
-1
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+123
-92
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+0
-2
未找到文件。
source/libs/scalar/src/scalar.c
浏览文件 @
3162f930
...
@@ -510,7 +510,7 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) {
...
@@ -510,7 +510,7 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) {
res
->
node
.
resType
=
node
->
node
.
resType
;
res
->
node
.
resType
=
node
->
node
.
resType
;
int32_t
type
=
output
.
columnData
->
info
.
type
;
int32_t
type
=
output
.
columnData
->
info
.
type
;
if
(
IS_VAR_DATA_TYPE
(
type
))
{
if
(
IS_VAR_DATA_TYPE
(
type
))
{
// todo refactor
res
->
datum
.
p
=
output
.
columnData
->
pData
;
res
->
datum
.
p
=
output
.
columnData
->
pData
;
output
.
columnData
->
pData
=
NULL
;
output
.
columnData
->
pData
=
NULL
;
}
else
{
}
else
{
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
3162f930
...
@@ -259,19 +259,25 @@ _getValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) {
...
@@ -259,19 +259,25 @@ _getValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) {
return
p
;
return
p
;
}
}
static
FORCE_INLINE
void
varToSigned
(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
outType
)
{
static
FORCE_INLINE
void
varToSigned
(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
rowIndex
)
{
int64_t
value
=
strtoll
(
buf
,
NULL
,
10
);
int64_t
value
=
strtoll
(
buf
,
NULL
,
10
);
SET_TYPED_DATA
(
pOut
->
columnData
->
pData
,
outType
,
valu
e
);
colDataAppend
(
pOut
->
columnData
,
rowIndex
,
(
char
*
)
&
value
,
fals
e
);
}
}
static
FORCE_INLINE
void
varToUnsigned
(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
outType
)
{
static
FORCE_INLINE
void
varToUnsigned
(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
rowIndex
)
{
uint64_t
value
=
strtoull
(
buf
,
NULL
,
10
);
uint64_t
value
=
strtoull
(
buf
,
NULL
,
10
);
SET_TYPED_DATA
(
pOut
->
columnData
->
pData
,
outType
,
valu
e
);
colDataAppend
(
pOut
->
columnData
,
rowIndex
,
(
char
*
)
&
value
,
fals
e
);
}
}
static
FORCE_INLINE
void
varToFloat
(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
outType
)
{
static
FORCE_INLINE
void
varToFloat
(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
rowIndex
)
{
double
value
=
strtod
(
buf
,
NULL
);
double
value
=
strtod
(
buf
,
NULL
);
SET_TYPED_DATA
(
pOut
->
columnData
->
pData
,
outType
,
value
);
colDataAppend
(
pOut
->
columnData
,
rowIndex
,
(
char
*
)
&
value
,
false
);
}
static
FORCE_INLINE
void
varToBool
(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
rowIndex
)
{
int64_t
value
=
strtoll
(
buf
,
NULL
,
10
);
bool
v
=
(
value
!=
0
)
?
true
:
false
;
colDataAppend
(
pOut
->
columnData
,
rowIndex
,
(
char
*
)
&
v
,
false
);
}
}
int32_t
vectorConvertFromVarData
(
SScalarParam
*
pIn
,
SScalarParam
*
pOut
,
int32_t
inType
,
int32_t
outType
)
{
int32_t
vectorConvertFromVarData
(
SScalarParam
*
pIn
,
SScalarParam
*
pOut
,
int32_t
inType
,
int32_t
outType
)
{
...
@@ -279,8 +285,9 @@ int32_t vectorConvertFromVarData(SScalarParam* pIn, SScalarParam* pOut, int32_t
...
@@ -279,8 +285,9 @@ int32_t vectorConvertFromVarData(SScalarParam* pIn, SScalarParam* pOut, int32_t
char
*
tmp
=
malloc
(
bufSize
);
char
*
tmp
=
malloc
(
bufSize
);
_bufConverteFunc
func
=
NULL
;
_bufConverteFunc
func
=
NULL
;
if
(
TSDB_DATA_TYPE_BOOL
==
outType
)
{
if
(
IS_SIGNED_NUMERIC_TYPE
(
outType
)
||
TSDB_DATA_TYPE_TIMESTAMP
==
outType
||
TSDB_DATA_TYPE_BOOL
==
outType
)
{
func
=
varToBool
;
}
else
if
(
IS_SIGNED_NUMERIC_TYPE
(
outType
)
||
TSDB_DATA_TYPE_TIMESTAMP
==
outType
)
{
func
=
varToSigned
;
func
=
varToSigned
;
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
outType
))
{
}
else
if
(
IS_UNSIGNED_NUMERIC_TYPE
(
outType
))
{
func
=
varToUnsigned
;
func
=
varToUnsigned
;
...
@@ -290,7 +297,8 @@ int32_t vectorConvertFromVarData(SScalarParam* pIn, SScalarParam* pOut, int32_t
...
@@ -290,7 +297,8 @@ int32_t vectorConvertFromVarData(SScalarParam* pIn, SScalarParam* pOut, int32_t
sclError
(
"invalid convert outType:%d"
,
outType
);
sclError
(
"invalid convert outType:%d"
,
outType
);
return
TSDB_CODE_QRY_APP_ERROR
;
return
TSDB_CODE_QRY_APP_ERROR
;
}
}
pOut
->
numOfRows
=
pIn
->
numOfRows
;
for
(
int32_t
i
=
0
;
i
<
pIn
->
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pIn
->
numOfRows
;
++
i
)
{
if
(
colDataIsNull
(
pIn
->
columnData
,
pIn
->
numOfRows
,
i
,
NULL
))
{
if
(
colDataIsNull
(
pIn
->
columnData
,
pIn
->
numOfRows
,
i
,
NULL
))
{
colDataAppend
(
pOut
->
columnData
,
i
,
NULL
,
true
);
colDataAppend
(
pOut
->
columnData
,
i
,
NULL
,
true
);
...
@@ -314,7 +322,7 @@ int32_t vectorConvertFromVarData(SScalarParam* pIn, SScalarParam* pOut, int32_t
...
@@ -314,7 +322,7 @@ int32_t vectorConvertFromVarData(SScalarParam* pIn, SScalarParam* pOut, int32_t
tmp
[
len
]
=
0
;
tmp
[
len
]
=
0
;
}
}
(
*
func
)(
tmp
,
pOut
,
outType
);
(
*
func
)(
tmp
,
pOut
,
i
);
}
}
tfree
(
tmp
);
tfree
(
tmp
);
...
@@ -334,12 +342,24 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
...
@@ -334,12 +342,24 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
}
}
switch
(
outType
)
{
switch
(
outType
)
{
case
TSDB_DATA_TYPE_BOOL
:
case
TSDB_DATA_TYPE_BOOL
:
{
for
(
int32_t
i
=
0
;
i
<
pIn
->
numOfRows
;
++
i
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
colDataAppend
(
pOutputCol
,
i
,
NULL
,
true
);
continue
;
}
bool
value
=
0
;
GET_TYPED_DATA
(
value
,
int64_t
,
inType
,
colDataGetData
(
pInputCol
,
i
));
colDataAppend
(
pOutputCol
,
i
,
(
char
*
)
&
value
,
false
);
}
break
;
}
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
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
:
{
for
(
int32_t
i
=
0
;
i
<
pIn
->
numOfRows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pIn
->
numOfRows
;
++
i
)
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
if
(
colDataIsNull_f
(
pInputCol
->
nullbitmap
,
i
))
{
colDataAppend
(
pOutputCol
,
i
,
NULL
,
true
);
colDataAppend
(
pOutputCol
,
i
,
NULL
,
true
);
...
@@ -348,9 +368,10 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
...
@@ -348,9 +368,10 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int64_t
value
=
0
;
int64_t
value
=
0
;
GET_TYPED_DATA
(
value
,
int64_t
,
inType
,
colDataGetData
(
pInputCol
,
i
));
GET_TYPED_DATA
(
value
,
int64_t
,
inType
,
colDataGetData
(
pInputCol
,
i
));
colDataAppend
(
pOutputCol
,
i
,
(
char
*
)
&
value
,
false
);
colDataAppend
(
pOutputCol
,
i
,
(
char
*
)
&
value
,
false
);
}
}
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
:
...
@@ -525,7 +546,7 @@ static void vectorMathAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
...
@@ -525,7 +546,7 @@ static void vectorMathAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
// TODO set numOfRows NULL value
// TODO set numOfRows NULL value
}
else
{
}
else
{
for
(;
i
>=
0
&&
i
<
numOfRows
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
numOfRows
;
i
+=
step
,
output
+=
1
)
{
output
[
i
]
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
+
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
0
);
*
output
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
+
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
0
);
}
}
pOutputCol
->
hasNull
=
pLeftCol
->
hasNull
;
pOutputCol
->
hasNull
=
pLeftCol
->
hasNull
;
if
(
pOutputCol
->
hasNull
)
{
if
(
pOutputCol
->
hasNull
)
{
...
@@ -535,23 +556,26 @@ static void vectorMathAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
...
@@ -535,23 +556,26 @@ static void vectorMathAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
}
}
void
vectorMathAdd
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
void
vectorMathAdd
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
SColumnInfoData
*
pLeftCol
=
pLeft
->
columnData
;
SColumnInfoData
*
pRightCol
=
pRight
->
columnData
;
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
pOut
->
numOfRows
=
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
);
doConvertHelper
(
pLeft
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pLeft
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pRight
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pRight
,
TSDB_DATA_TYPE_DOUBLE
);
SColumnInfoData
*
pLeftCol
=
pLeft
->
columnData
;
SColumnInfoData
*
pRightCol
=
pRight
->
columnData
;
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeftCol
->
info
.
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeftCol
->
info
.
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRightCol
->
info
.
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRightCol
->
info
.
type
);
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
output
[
i
]
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
+
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
i
);
*
output
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
+
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
i
);
}
}
pOutputCol
->
hasNull
=
(
pLeftCol
->
hasNull
||
pRightCol
->
hasNull
);
pOutputCol
->
hasNull
=
(
pLeftCol
->
hasNull
||
pRightCol
->
hasNull
);
...
@@ -580,7 +604,7 @@ static void vectorMathSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
...
@@ -580,7 +604,7 @@ static void vectorMathSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
// TODO set numOfRows NULL value
// TODO set numOfRows NULL value
}
else
{
}
else
{
for
(;
i
>=
0
&&
i
<
numOfRows
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
numOfRows
;
i
+=
step
,
output
+=
1
)
{
output
[
i
]
=
(
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
-
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
0
))
*
factor
;
*
output
=
(
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
-
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
0
))
*
factor
;
}
}
pOutputCol
->
hasNull
=
pLeftCol
->
hasNull
;
pOutputCol
->
hasNull
=
pLeftCol
->
hasNull
;
if
(
pOutputCol
->
hasNull
)
{
if
(
pOutputCol
->
hasNull
)
{
...
@@ -590,23 +614,26 @@ static void vectorMathSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
...
@@ -590,23 +614,26 @@ static void vectorMathSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig
}
}
void
vectorMathSub
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
void
vectorMathSub
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
SColumnInfoData
*
pLeftCol
=
pLeft
->
columnData
;
SColumnInfoData
*
pRightCol
=
pRight
->
columnData
;
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
pOut
->
numOfRows
=
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
);
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
doConvertHelper
(
pLeft
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pLeft
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pRight
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pRight
,
TSDB_DATA_TYPE_DOUBLE
);
SColumnInfoData
*
pLeftCol
=
pLeft
->
columnData
;
SColumnInfoData
*
pRightCol
=
pRight
->
columnData
;
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeftCol
->
info
.
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeftCol
->
info
.
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRightCol
->
info
.
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRightCol
->
info
.
type
);
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
output
[
i
]
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
-
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
i
);
*
output
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
-
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
i
);
}
}
pOutputCol
->
hasNull
=
(
pLeftCol
->
hasNull
||
pRightCol
->
hasNull
);
pOutputCol
->
hasNull
=
(
pLeftCol
->
hasNull
||
pRightCol
->
hasNull
);
...
@@ -635,7 +662,7 @@ static void vectorMathMultiplyHelper(SColumnInfoData* pLeftCol, SColumnInfoData*
...
@@ -635,7 +662,7 @@ static void vectorMathMultiplyHelper(SColumnInfoData* pLeftCol, SColumnInfoData*
// TODO set numOfRows NULL value
// TODO set numOfRows NULL value
}
else
{
}
else
{
for
(;
i
>=
0
&&
i
<
numOfRows
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
numOfRows
;
i
+=
step
,
output
+=
1
)
{
output
[
i
]
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
*
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
0
);
*
output
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
*
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
0
);
}
}
pOutputCol
->
hasNull
=
pLeftCol
->
hasNull
;
pOutputCol
->
hasNull
=
pLeftCol
->
hasNull
;
if
(
pOutputCol
->
hasNull
)
{
if
(
pOutputCol
->
hasNull
)
{
...
@@ -646,11 +673,12 @@ static void vectorMathMultiplyHelper(SColumnInfoData* pLeftCol, SColumnInfoData*
...
@@ -646,11 +673,12 @@ static void vectorMathMultiplyHelper(SColumnInfoData* pLeftCol, SColumnInfoData*
void
vectorMathMultiply
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
void
vectorMathMultiply
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
pOut
->
numOfRows
=
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
);
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
doConvertHelper
(
pLeft
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pLeft
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pRight
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pRight
,
TSDB_DATA_TYPE_DOUBLE
);
SColumnInfoData
*
pLeftCol
=
pLeft
->
columnData
;
SColumnInfoData
*
pLeftCol
=
pLeft
->
columnData
;
...
@@ -662,7 +690,7 @@ void vectorMathMultiply(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
...
@@ -662,7 +690,7 @@ void vectorMathMultiply(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
output
[
i
]
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
*
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
i
);
*
output
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
*
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
i
);
}
}
pOutputCol
->
hasNull
=
(
pLeftCol
->
hasNull
||
pRightCol
->
hasNull
);
pOutputCol
->
hasNull
=
(
pLeftCol
->
hasNull
||
pRightCol
->
hasNull
);
...
@@ -680,30 +708,9 @@ void vectorMathMultiply(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
...
@@ -680,30 +708,9 @@ void vectorMathMultiply(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
}
}
}
}
// TODO not correct for descending order scan
static
void
vectorMathDivideHelper
(
SColumnInfoData
*
pLeftCol
,
SColumnInfoData
*
pRightCol
,
SColumnInfoData
*
pOutputCol
,
int32_t
numOfRows
,
int32_t
step
,
int32_t
i
)
{
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeftCol
->
info
.
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRightCol
->
info
.
type
);
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
if
(
colDataIsNull_f
(
pRightCol
->
nullbitmap
,
0
))
{
// Set pLeft->numOfRows NULL value
// TODO set numOfRows NULL value
}
else
{
for
(;
i
>=
0
&&
i
<
numOfRows
;
i
+=
step
,
output
+=
1
)
{
output
[
i
]
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
*
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
0
);
}
pOutputCol
->
hasNull
=
pLeftCol
->
hasNull
;
if
(
pOutputCol
->
hasNull
)
{
memcpy
(
pOutputCol
->
nullbitmap
,
pLeftCol
->
nullbitmap
,
BitmapLen
(
numOfRows
));
}
}
}
void
vectorMathDivide
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
void
vectorMathDivide
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
SColumnInfoData
*
pLeftCol
=
pLeft
->
columnData
;
SColumnInfoData
*
pRightCol
=
pRight
->
columnData
;
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
pOut
->
numOfRows
=
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
);
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
...
@@ -711,13 +718,16 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
...
@@ -711,13 +718,16 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
doConvertHelper
(
pLeft
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pLeft
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pRight
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pRight
,
TSDB_DATA_TYPE_DOUBLE
);
SColumnInfoData
*
pLeftCol
=
pLeft
->
columnData
;
SColumnInfoData
*
pRightCol
=
pRight
->
columnData
;
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeftCol
->
info
.
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeftCol
->
info
.
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRightCol
->
info
.
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRightCol
->
info
.
type
);
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
// check for the 0 value
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
// check for the 0 value
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
output
[
i
]
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
/
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
i
);
*
output
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
/
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
i
);
}
}
pOutputCol
->
hasNull
=
(
pLeftCol
->
hasNull
||
pRightCol
->
hasNull
);
pOutputCol
->
hasNull
=
(
pLeftCol
->
hasNull
||
pRightCol
->
hasNull
);
...
@@ -733,7 +743,7 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
...
@@ -733,7 +743,7 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
// TODO set numOfRows NULL value
// TODO set numOfRows NULL value
}
else
{
}
else
{
for
(;
i
>=
0
&&
i
<
pRight
->
numOfRows
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pRight
->
numOfRows
;
i
+=
step
,
output
+=
1
)
{
output
[
i
]
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
0
)
/
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
i
);
*
output
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
0
)
/
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
i
);
}
}
pOutputCol
->
hasNull
=
pRightCol
->
hasNull
;
pOutputCol
->
hasNull
=
pRightCol
->
hasNull
;
if
(
pOutputCol
->
hasNull
)
{
if
(
pOutputCol
->
hasNull
)
{
...
@@ -745,7 +755,7 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
...
@@ -745,7 +755,7 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
// TODO set numOfRows NULL value
// TODO set numOfRows NULL value
}
else
{
}
else
{
for
(;
i
>=
0
&&
i
<
pLeft
->
numOfRows
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
numOfRows
;
i
+=
step
,
output
+=
1
)
{
output
[
i
]
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
/
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
0
);
*
output
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
)
/
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
0
);
}
}
pOutputCol
->
hasNull
=
pLeftCol
->
hasNull
;
pOutputCol
->
hasNull
=
pLeftCol
->
hasNull
;
if
(
pOutputCol
->
hasNull
)
{
if
(
pOutputCol
->
hasNull
)
{
...
@@ -756,9 +766,8 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
...
@@ -756,9 +766,8 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p
}
}
void
vectorMathRemainder
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
void
vectorMathRemainder
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
SColumnInfoData
*
pLeftCol
=
pLeft
->
columnData
;
SColumnInfoData
*
pRightCol
=
pRight
->
columnData
;
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
pOut
->
numOfRows
=
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
);
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
...
@@ -766,6 +775,9 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
...
@@ -766,6 +775,9 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
doConvertHelper
(
pLeft
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pLeft
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pRight
,
TSDB_DATA_TYPE_DOUBLE
);
doConvertHelper
(
pRight
,
TSDB_DATA_TYPE_DOUBLE
);
SColumnInfoData
*
pLeftCol
=
pLeft
->
columnData
;
SColumnInfoData
*
pRightCol
=
pRight
->
columnData
;
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeftCol
->
info
.
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnLeft
=
getVectorDoubleValueFn
(
pLeftCol
->
info
.
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRightCol
->
info
.
type
);
_getDoubleValue_fn_t
getVectorDoubleValueFnRight
=
getVectorDoubleValueFn
(
pRightCol
->
info
.
type
);
...
@@ -786,7 +798,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
...
@@ -786,7 +798,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
continue
;
continue
;
}
}
output
[
i
]
=
lx
-
((
int64_t
)(
lx
/
rx
))
*
rx
;
*
output
=
lx
-
((
int64_t
)(
lx
/
rx
))
*
rx
;
}
}
}
else
if
(
pLeft
->
numOfRows
==
1
)
{
}
else
if
(
pLeft
->
numOfRows
==
1
)
{
double
lx
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
0
);
double
lx
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
0
);
...
@@ -805,7 +817,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
...
@@ -805,7 +817,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
continue
;
continue
;
}
}
output
[
i
]
=
lx
-
((
int64_t
)(
lx
/
rx
))
*
rx
;
*
output
=
lx
-
((
int64_t
)(
lx
/
rx
))
*
rx
;
}
}
}
}
}
else
if
(
pRight
->
numOfRows
==
1
)
{
}
else
if
(
pRight
->
numOfRows
==
1
)
{
...
@@ -825,7 +837,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
...
@@ -825,7 +837,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
continue
;
continue
;
}
}
output
[
i
]
=
lx
-
((
int64_t
)(
lx
/
rx
))
*
rx
;
*
output
=
lx
-
((
int64_t
)(
lx
/
rx
))
*
rx
;
}
}
}
}
}
}
...
@@ -1387,7 +1399,7 @@ static void vectorBitAndHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRigh
...
@@ -1387,7 +1399,7 @@ static void vectorBitAndHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRigh
// TODO set numOfRows NULL value
// TODO set numOfRows NULL value
}
else
{
}
else
{
for
(;
i
>=
0
&&
i
<
numOfRows
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
numOfRows
;
i
+=
step
,
output
+=
1
)
{
output
[
i
]
=
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
)
&
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
0
);
*
output
=
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
)
&
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
0
);
}
}
pOutputCol
->
hasNull
=
pLeftCol
->
hasNull
;
pOutputCol
->
hasNull
=
pLeftCol
->
hasNull
;
if
(
pOutputCol
->
hasNull
)
{
if
(
pOutputCol
->
hasNull
)
{
...
@@ -1398,6 +1410,7 @@ static void vectorBitAndHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRigh
...
@@ -1398,6 +1410,7 @@ static void vectorBitAndHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRigh
void
vectorBitAnd
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
void
vectorBitAnd
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
pOut
->
numOfRows
=
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
);
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
...
@@ -1414,7 +1427,7 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
...
@@ -1414,7 +1427,7 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
int64_t
*
output
=
(
int64_t
*
)
pOutputCol
->
pData
;
int64_t
*
output
=
(
int64_t
*
)
pOutputCol
->
pData
;
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
output
[
i
]
=
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
)
&
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
i
);
*
output
=
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
)
&
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
i
);
}
}
pOutputCol
->
hasNull
=
(
pLeftCol
->
hasNull
||
pRightCol
->
hasNull
);
pOutputCol
->
hasNull
=
(
pLeftCol
->
hasNull
||
pRightCol
->
hasNull
);
...
@@ -1436,13 +1449,14 @@ static void vectorBitOrHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRight
...
@@ -1436,13 +1449,14 @@ static void vectorBitOrHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRight
_getBigintValue_fn_t
getVectorBigintValueFnLeft
=
getVectorBigintValueFn
(
pLeftCol
->
info
.
type
);
_getBigintValue_fn_t
getVectorBigintValueFnLeft
=
getVectorBigintValueFn
(
pLeftCol
->
info
.
type
);
_getBigintValue_fn_t
getVectorBigintValueFnRight
=
getVectorBigintValueFn
(
pRightCol
->
info
.
type
);
_getBigintValue_fn_t
getVectorBigintValueFnRight
=
getVectorBigintValueFn
(
pRightCol
->
info
.
type
);
double
*
output
=
(
double
*
)
pOutputCol
->
pData
;
int64_t
*
output
=
(
int64_t
*
)
pOutputCol
->
pData
;
if
(
colDataIsNull_f
(
pRightCol
->
nullbitmap
,
0
))
{
// Set pLeft->numOfRows NULL value
if
(
colDataIsNull_f
(
pRightCol
->
nullbitmap
,
0
))
{
// Set pLeft->numOfRows NULL value
// TODO set numOfRows NULL value
// TODO set numOfRows NULL value
}
else
{
}
else
{
int64_t
rx
=
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
0
);
for
(;
i
>=
0
&&
i
<
numOfRows
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
>=
0
&&
i
<
numOfRows
;
i
+=
step
,
output
+=
1
)
{
output
[
i
]
=
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
)
|
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
0
)
;
*
output
=
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
)
|
rx
;
}
}
pOutputCol
->
hasNull
=
pLeftCol
->
hasNull
;
pOutputCol
->
hasNull
=
pLeftCol
->
hasNull
;
if
(
pOutputCol
->
hasNull
)
{
if
(
pOutputCol
->
hasNull
)
{
...
@@ -1453,6 +1467,7 @@ static void vectorBitOrHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRight
...
@@ -1453,6 +1467,7 @@ static void vectorBitOrHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRight
void
vectorBitOr
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
void
vectorBitOr
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
SColumnInfoData
*
pOutputCol
=
pOut
->
columnData
;
pOut
->
numOfRows
=
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
);
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
...
@@ -1469,7 +1484,7 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
...
@@ -1469,7 +1484,7 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
int64_t
*
output
=
(
int64_t
*
)
pOutputCol
->
pData
;
int64_t
*
output
=
(
int64_t
*
)
pOutputCol
->
pData
;
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
,
output
+=
1
)
{
output
[
i
]
=
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
)
|
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
i
);
*
output
=
getVectorBigintValueFnLeft
(
pLeftCol
->
pData
,
i
)
|
getVectorBigintValueFnRight
(
pRightCol
->
pData
,
i
);
}
}
pOutputCol
->
hasNull
=
(
pLeftCol
->
hasNull
||
pRightCol
->
hasNull
);
pOutputCol
->
hasNull
=
(
pLeftCol
->
hasNull
||
pRightCol
->
hasNull
);
...
@@ -1486,51 +1501,66 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
...
@@ -1486,51 +1501,66 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
}
}
}
}
static
void
vectorCompareHelper
(
SColumnInfoData
*
pLeftCol
,
SColumnInfoData
*
pRightCol
,
SColumnInfoData
*
pOutputCol
,
int32_t
numOfRows
,
int32_t
step
,
int32_t
i
,
void
vectorCompareImpl
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
,
int32_t
optr
)
{
__compar_fn_t
fp
,
int32_t
optr
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
if
(
colDataIsNull_f
(
pRightCol
->
nullbitmap
,
0
))
{
// Set pLeft->numOfRows NULL value
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
// TODO set numOfRows NULL value
__compar_fn_t
fp
=
filterGetCompFunc
(
GET_PARAM_TYPE
(
pLeft
),
optr
);
}
else
{
for
(;
i
>=
0
&&
i
<
numOfRows
;
i
+=
step
)
{
pOut
->
numOfRows
=
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
);
if
(
colDataIsNull
(
pRightCol
,
numOfRows
,
i
,
NULL
))
{
colDataAppend
(
pOutputCol
,
i
,
NULL
,
true
);
if
(
pRight
->
pHashFilter
!=
NULL
)
{
for
(;
i
>=
0
&&
i
<
pLeft
->
numOfRows
;
i
+=
step
)
{
if
(
colDataIsNull
(
pLeft
->
columnData
,
pLeft
->
numOfRows
,
i
,
NULL
)
/*||
colDataIsNull(pRight->columnData, pRight->numOfRows, i, NULL)*/
)
{
continue
;
continue
;
}
}
char
*
pLeftData
=
colDataGetData
(
pLeftCol
,
i
);
char
*
pLeftData
=
colDataGetData
(
pLeft
->
columnData
,
i
);
char
*
pRightData
=
colDataGetData
(
pRightCol
,
i
);
bool
res
=
filterDoCompare
(
fp
,
optr
,
pLeftData
,
pRight
->
pHashFilter
);
bool
res
=
filterDoCompare
(
fp
,
optr
,
pLeftData
,
pRightData
);
colDataAppend
(
pOut
->
columnData
,
i
,
(
char
*
)
&
res
,
false
);
colDataAppend
(
pOutputCol
,
i
,
(
char
*
)
&
res
,
false
);
}
pOutputCol
->
hasNull
=
pLeftCol
->
hasNull
;
if
(
pOutputCol
->
hasNull
)
{
memcpy
(
pOutputCol
->
nullbitmap
,
pLeftCol
->
nullbitmap
,
BitmapLen
(
numOfRows
));
}
}
return
;
}
}
}
void
vectorCompareImpl
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
,
int32_t
optr
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
numOfRows
,
pRight
->
numOfRows
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
__compar_fn_t
fp
=
filterGetCompFunc
(
GET_PARAM_TYPE
(
pLeft
),
optr
);
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
if
(
pLeft
->
numOfRows
==
pRight
->
numOfRows
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
)
{
for
(;
i
<
pRight
->
numOfRows
&&
i
>=
0
;
i
+=
step
)
{
if
(
colDataIsNull
(
pLeft
->
columnData
,
pLeft
->
numOfRows
,
i
,
NULL
)
||
if
(
colDataIsNull
(
pLeft
->
columnData
,
pLeft
->
numOfRows
,
i
,
NULL
)
||
colDataIsNull
(
pRight
->
columnData
,
pRight
->
numOfRows
,
i
,
NULL
))
{
colDataIsNull
(
pRight
->
columnData
,
pRight
->
numOfRows
,
i
,
NULL
))
{
continue
;
continue
;
// TODO set null or ignore
}
}
char
*
pLeftData
=
colDataGetData
(
pLeft
->
columnData
,
i
);
char
*
pLeftData
=
colDataGetData
(
pLeft
->
columnData
,
i
);
char
*
pRightData
=
colDataGetData
(
pRight
->
columnData
,
i
);
char
*
pRightData
=
colDataGetData
(
pRight
->
columnData
,
i
);
bool
res
=
filterDoCompare
(
fp
,
optr
,
pLeftData
,
pRightData
);
bool
res
=
filterDoCompare
(
fp
,
optr
,
pLeftData
,
pRightData
);
colDataAppend
(
pOut
->
columnData
,
i
,
(
char
*
)
&
res
,
false
);
colDataAppend
(
pOut
->
columnData
,
i
,
(
char
*
)
&
res
,
false
);
}
}
}
else
if
(
pLeft
->
numOfRows
==
1
)
{
vectorCompareHelper
(
pRight
->
columnData
,
pLeft
->
columnData
,
pOut
->
columnData
,
pRight
->
numOfRows
,
step
,
i
,
fp
,
optr
);
}
else
if
(
pRight
->
numOfRows
==
1
)
{
}
else
if
(
pRight
->
numOfRows
==
1
)
{
vectorCompareHelper
(
pLeft
->
columnData
,
pRight
->
columnData
,
pOut
->
columnData
,
pLeft
->
numOfRows
,
step
,
i
,
fp
,
optr
);
char
*
pRightData
=
colDataGetData
(
pRight
->
columnData
,
0
);
ASSERT
(
pLeft
->
pHashFilter
==
NULL
);
for
(;
i
>=
0
&&
i
<
pLeft
->
numOfRows
;
i
+=
step
)
{
if
(
colDataIsNull
(
pLeft
->
columnData
,
pLeft
->
numOfRows
,
i
,
NULL
)
/*||
colDataIsNull(pRight->columnData, pRight->numOfRows, i, NULL)*/
)
{
continue
;
}
char
*
pLeftData
=
colDataGetData
(
pLeft
->
columnData
,
i
);
bool
res
=
filterDoCompare
(
fp
,
optr
,
pLeftData
,
pRightData
);
colDataAppend
(
pOut
->
columnData
,
i
,
(
char
*
)
&
res
,
false
);
}
}
else
if
(
pLeft
->
numOfRows
==
1
)
{
char
*
pLeftData
=
colDataGetData
(
pLeft
->
columnData
,
0
);
for
(;
i
>=
0
&&
i
<
pRight
->
numOfRows
;
i
+=
step
)
{
if
(
colDataIsNull
(
pRight
->
columnData
,
pRight
->
numOfRows
,
i
,
NULL
)
/*||
colDataIsNull(pRight->columnData, pRight->numOfRows, i, NULL)*/
)
{
continue
;
}
char
*
pRightData
=
colDataGetData
(
pLeft
->
columnData
,
i
);
bool
res
=
filterDoCompare
(
fp
,
optr
,
pLeftData
,
pRightData
);
colDataAppend
(
pOut
->
columnData
,
i
,
(
char
*
)
&
res
,
false
);
}
}
}
}
}
...
@@ -1616,6 +1646,8 @@ void vectorIsNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
...
@@ -1616,6 +1646,8 @@ void vectorIsNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut,
}
}
colDataAppend
(
pOut
->
columnData
,
i
,
(
char
*
)
&
v
,
false
);
colDataAppend
(
pOut
->
columnData
,
i
,
(
char
*
)
&
v
,
false
);
}
}
pOut
->
numOfRows
=
pLeft
->
numOfRows
;
}
}
void
vectorNotNull
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
void
vectorNotNull
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
...
@@ -1626,6 +1658,7 @@ void vectorNotNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
...
@@ -1626,6 +1658,7 @@ void vectorNotNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut
}
}
colDataAppend
(
pOut
->
columnData
,
i
,
(
char
*
)
&
v
,
false
);
colDataAppend
(
pOut
->
columnData
,
i
,
(
char
*
)
&
v
,
false
);
}
}
pOut
->
numOfRows
=
pLeft
->
numOfRows
;
}
}
void
vectorIsTrue
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
void
vectorIsTrue
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
pOut
,
int32_t
_ord
)
{
...
@@ -1682,6 +1715,4 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) {
...
@@ -1682,6 +1715,4 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) {
assert
(
0
);
assert
(
0
);
return
NULL
;
return
NULL
;
}
}
}
}
\ No newline at end of file
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
3162f930
...
@@ -471,8 +471,6 @@ TEST(constantTest, int_not_equal_smallint2) {
...
@@ -471,8 +471,6 @@ TEST(constantTest, int_not_equal_smallint2) {
nodesDestroyNode
(
res
);
nodesDestroyNode
(
res
);
}
}
TEST
(
constantTest
,
int_in_smallint1
)
{
TEST
(
constantTest
,
int_in_smallint1
)
{
scltInitLogFile
();
scltInitLogFile
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录