Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
93baf85a
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
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看板
提交
93baf85a
编写于
2月 22, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
8f7b375b
变更
9
展开全部
显示空白变更内容
内联
并排
Showing
9 changed file
with
1102 addition
and
35 deletion
+1102
-35
include/common/ttypes.h
include/common/ttypes.h
+2
-0
include/libs/function/function.h
include/libs/function/function.h
+1
-0
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-0
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+1
-1
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+2
-0
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+6
-0
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+27
-22
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+332
-8
source/libs/scalar/test/scalarTests.cpp
source/libs/scalar/test/scalarTests.cpp
+730
-4
未找到文件。
include/common/ttypes.h
浏览文件 @
93baf85a
...
...
@@ -91,6 +91,8 @@ typedef struct {
do { \
switch (_type) { \
case TSDB_DATA_TYPE_BOOL: \
*(bool *)(_v) = (bool)(_data); \
break; \
case TSDB_DATA_TYPE_TINYINT: \
*(int8_t *)(_v) = (int8_t)(_data); \
break; \
...
...
include/libs/function/function.h
浏览文件 @
93baf85a
...
...
@@ -228,6 +228,7 @@ typedef struct SAggFunctionInfo {
typedef
struct
SScalarParam
{
void
*
data
;
bool
colData
;
int32_t
num
;
int32_t
type
;
int32_t
bytes
;
...
...
include/libs/nodes/querynodes.h
浏览文件 @
93baf85a
...
...
@@ -141,6 +141,7 @@ typedef struct SLogicConditionNode {
typedef
struct
SNodeListNode
{
ENodeType
type
;
// QUERY_NODE_NODE_LIST
SDataType
dataType
;
SNodeList
*
pNodeList
;
}
SNodeListNode
;
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
93baf85a
...
...
@@ -546,7 +546,7 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable
if
(
tbMeta
->
tableType
!=
TSDB_CHILD_TABLE
)
{
ctgReleaseDBCache
(
pCtg
,
dbCache
);
ctgDebug
(
"Got
tbl
from cache, type:%d, dbFName:%s, tbName:%s"
,
tbMeta
->
tableType
,
dbFName
,
pTableName
->
tname
);
ctgDebug
(
"Got
meta
from cache, type:%d, dbFName:%s, tbName:%s"
,
tbMeta
->
tableType
,
dbFName
,
pTableName
->
tname
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
93baf85a
...
...
@@ -63,6 +63,8 @@ SNode* nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SNodeListNode
));
case
QUERY_NODE_FILL
:
return
makeNode
(
type
,
sizeof
(
SFillNode
));
case
QUERY_NODE_COLUMN_REF
:
return
makeNode
(
type
,
sizeof
(
SColumnRefNode
));
case
QUERY_NODE_RAW_EXPR
:
return
makeNode
(
type
,
sizeof
(
SRawExprNode
));
case
QUERY_NODE_SET_OPERATOR
:
...
...
source/libs/scalar/src/filter.c
浏览文件 @
93baf85a
...
...
@@ -1820,6 +1820,9 @@ bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right)
case
TSDB_RELATION_LIKE
:
{
return
ret
==
0
;
}
case
TSDB_RELATION_NOT_LIKE
:
{
return
ret
==
0
;
}
case
TSDB_RELATION_MATCH
:
{
return
ret
==
0
;
}
...
...
@@ -1829,6 +1832,9 @@ bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right)
case
TSDB_RELATION_IN
:
{
return
ret
==
1
;
}
case
TSDB_RELATION_NOT_IN
:
{
return
ret
==
1
;
}
default:
assert
(
false
);
...
...
source/libs/scalar/src/scalar.c
浏览文件 @
93baf85a
...
...
@@ -50,20 +50,28 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) {
if
(
IS_VAR_DATA_TYPE
(
type
))
{
len
=
varDataLen
(
out
.
data
);
buf
=
varDataVal
(
out
.
data
);
}
else
{
len
=
tDataTypes
[
type
].
bytes
;
}
buf
=
out
.
data
;
}
}
else
{
buf
=
nodesGetValueFromNode
(
valueNode
);
if
(
IS_VAR_DATA_TYPE
(
type
))
{
len
=
varDataLen
(
buf
);
buf
=
varDataVal
(
buf
);
}
else
{
len
=
valueNode
->
node
.
resType
.
bytes
;
buf
=
out
.
data
;
}
}
if
(
taosHashPut
(
pObj
,
buf
,
(
size_t
)
len
,
&
dummy
,
sizeof
(
dummy
)))
{
sclError
(
"taosHashPut failed"
);
SCL_ERR_JRET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
cell
=
cell
->
pNext
;
}
tfree
(
out
.
data
);
...
...
@@ -108,6 +116,7 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
param
->
num
=
1
;
param
->
type
=
valueNode
->
node
.
resType
.
type
;
param
->
bytes
=
valueNode
->
node
.
resType
.
bytes
;
param
->
colData
=
false
;
break
;
}
...
...
@@ -121,6 +130,7 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
SCL_ERR_RET
(
scalarGenerateSetFromList
(
&
param
->
data
,
node
,
nodeList
->
dataType
.
type
));
param
->
num
=
1
;
param
->
type
=
SCL_DATA_TYPE_DUMMY_HASH
;
param
->
colData
=
false
;
break
;
}
...
...
@@ -137,7 +147,14 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
}
SColumnInfoData
*
columnData
=
(
SColumnInfoData
*
)
taosArrayGet
(
ctx
->
pSrc
->
pDataBlock
,
ref
->
slotId
);
if
(
IS_VAR_DATA_TYPE
(
columnData
->
info
.
type
))
{
param
->
data
=
columnData
;
param
->
colData
=
true
;
}
else
{
param
->
data
=
columnData
->
pData
;
param
->
colData
=
false
;
}
param
->
num
=
ctx
->
pSrc
->
info
.
rows
;
param
->
type
=
columnData
->
info
.
type
;
param
->
bytes
=
columnData
->
info
.
bytes
;
...
...
@@ -366,6 +383,7 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
output
->
type
=
node
->
node
.
resType
.
type
;
output
->
num
=
rowNum
;
output
->
bytes
=
tDataTypes
[
output
->
type
].
bytes
;
output
->
data
=
calloc
(
rowNum
,
tDataTypes
[
output
->
type
].
bytes
);
if
(
NULL
==
output
->
data
)
{
sclError
(
"calloc %d failed"
,
(
int32_t
)
rowNum
*
tDataTypes
[
output
->
type
].
bytes
);
...
...
@@ -378,21 +396,8 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp
SScalarParam
*
pLeft
=
&
params
[
0
];
SScalarParam
*
pRight
=
paramNum
>
1
?
&
params
[
1
]
:
NULL
;
void
*
data
=
output
->
data
;
for
(
int32_t
i
=
0
;
i
<
rowNum
;
++
i
)
{
OperatorFn
(
pLeft
,
pRight
,
output
->
data
,
TSDB_ORDER_ASC
);
sclParamMoveNext
(
output
,
1
);
sclParamMoveNext
(
pLeft
,
1
);
if
(
pRight
)
{
sclParamMoveNext
(
pRight
,
1
);
}
}
output
->
data
=
data
;
return
TSDB_CODE_SUCCESS
;
_return:
...
...
@@ -506,7 +511,7 @@ EDealRes sclRewriteOperator(SNode** pNode, void* pContext) {
EDealRes
sclConstantsRewriter
(
SNode
**
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
*
pNode
))
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
*
pNode
)
||
QUERY_NODE_NODE_LIST
==
nodeType
(
*
pNode
)
)
{
return
DEAL_RES_CONTINUE
;
}
...
...
@@ -588,7 +593,7 @@ EDealRes sclWalkOperator(SNode* pNode, void* pContext) {
EDealRes
sclCalcWalker
(
SNode
*
pNode
,
void
*
pContext
)
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
pNode
))
{
if
(
QUERY_NODE_VALUE
==
nodeType
(
pNode
)
||
QUERY_NODE_NODE_LIST
==
nodeType
(
pNode
)
||
QUERY_NODE_COLUMN_REF
==
nodeType
(
pNode
)
)
{
return
DEAL_RES_CONTINUE
;
}
...
...
@@ -604,7 +609,7 @@ EDealRes sclCalcWalker(SNode* pNode, void* pContext) {
return
sclWalkOperator
(
pNode
,
pContext
);
}
sclError
(
"invalid node type for
calculating constants
, type:%d"
,
nodeType
(
pNode
));
sclError
(
"invalid node type for
scalar calculating
, type:%d"
,
nodeType
(
pNode
));
SScalarCtx
*
ctx
=
(
SScalarCtx
*
)
pContext
;
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
93baf85a
...
...
@@ -21,6 +21,8 @@
#include "querynodes.h"
#include "filterInt.h"
#include "query.h"
#include "sclInt.h"
#include "tep.h"
//GET_TYPED_DATA(v, double, pRight->type, (char *)&((right)[i]));
...
...
@@ -93,6 +95,7 @@ double getVectorDoubleValue_FLOAT(void *src, int32_t index) {
double
getVectorDoubleValue_DOUBLE
(
void
*
src
,
int32_t
index
)
{
return
(
double
)
*
((
double
*
)
src
+
index
);
}
_getDoubleValue_fn_t
getVectorDoubleValueFn
(
int32_t
srcType
)
{
_getDoubleValue_fn_t
p
=
NULL
;
if
(
srcType
==
TSDB_DATA_TYPE_TINYINT
)
{
...
...
@@ -218,6 +221,12 @@ void* getVectorValueAddr_FLOAT(void *src, int32_t index) {
void
*
getVectorValueAddr_DOUBLE
(
void
*
src
,
int32_t
index
)
{
return
(
void
*
)((
double
*
)
src
+
index
);
}
void
*
getVectorValueAddr_default
(
void
*
src
,
int32_t
index
)
{
return
src
;
}
void
*
getVectorValueAddr_VAR
(
void
*
src
,
int32_t
index
)
{
return
colDataGet
((
SColumnInfoData
*
)
src
,
index
);
}
_getValueAddr_fn_t
getVectorValueAddrFn
(
int32_t
srcType
)
{
_getValueAddr_fn_t
p
=
NULL
;
...
...
@@ -241,8 +250,12 @@ _getValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) {
p
=
getVectorValueAddr_FLOAT
;
}
else
if
(
srcType
==
TSDB_DATA_TYPE_DOUBLE
)
{
p
=
getVectorValueAddr_DOUBLE
;
}
else
if
(
srcType
==
TSDB_DATA_TYPE_BINARY
)
{
p
=
getVectorValueAddr_VAR
;
}
else
if
(
srcType
==
TSDB_DATA_TYPE_NCHAR
)
{
p
=
getVectorValueAddr_VAR
;
}
else
{
assert
(
0
)
;
p
=
getVectorValueAddr_default
;
}
return
p
;
}
...
...
@@ -267,6 +280,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int32_t
bufSize
=
varDataLen
(
input
)
+
1
;
char
*
tmp
=
malloc
(
bufSize
);
if
(
NULL
==
tmp
)
{
sclError
(
"malloc %d failed"
,
bufSize
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
...
...
@@ -295,6 +309,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int32_t
bufSize
=
varDataLen
(
input
)
*
TSDB_NCHAR_SIZE
+
1
;
char
*
tmp
=
calloc
(
1
,
bufSize
);
if
(
NULL
==
tmp
)
{
sclError
(
"calloc %d failed"
,
bufSize
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
...
...
@@ -309,7 +324,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int
len
=
taosUcs4ToMbs
(
varDataVal
(
input
),
varDataLen
(
input
),
tmp
);
if
(
len
<
0
){
q
Error
(
"castConvert taosUcs4ToMbs error 1"
);
scl
Error
(
"castConvert taosUcs4ToMbs error 1"
);
tfree
(
tmp
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
...
...
@@ -343,6 +358,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int32_t
bufSize
=
varDataLen
(
input
)
+
1
;
char
*
tmp
=
malloc
(
bufSize
);
if
(
NULL
==
tmp
)
{
sclError
(
"malloc %d failed"
,
bufSize
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
...
...
@@ -370,6 +386,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int32_t
bufSize
=
varDataLen
(
input
)
*
TSDB_NCHAR_SIZE
+
1
;
char
*
tmp
=
calloc
(
1
,
bufSize
);
if
(
NULL
==
tmp
)
{
sclError
(
"calloc %d failed"
,
bufSize
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
...
...
@@ -384,7 +401,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int
len
=
taosUcs4ToMbs
(
varDataVal
(
input
),
varDataLen
(
input
),
tmp
);
if
(
len
<
0
){
q
Error
(
"castConvert taosUcs4ToMbs error 1"
);
scl
Error
(
"castConvert taosUcs4ToMbs error 1"
);
tfree
(
tmp
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
...
...
@@ -420,6 +437,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int32_t
bufSize
=
varDataLen
(
input
)
+
1
;
char
*
tmp
=
malloc
(
bufSize
);
if
(
NULL
==
tmp
)
{
sclError
(
"malloc %d failed"
,
bufSize
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
...
...
@@ -448,6 +466,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int32_t
bufSize
=
varDataLen
(
input
)
*
TSDB_NCHAR_SIZE
+
1
;
char
*
tmp
=
calloc
(
1
,
bufSize
);
if
(
NULL
==
tmp
)
{
sclError
(
"calloc %d failed"
,
bufSize
);
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
...
...
@@ -462,7 +481,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
int
len
=
taosUcs4ToMbs
(
varDataVal
(
input
),
varDataLen
(
input
),
tmp
);
if
(
len
<
0
){
q
Error
(
"castConvert taosUcs4ToMbs error 1"
);
scl
Error
(
"castConvert taosUcs4ToMbs error 1"
);
tfree
(
tmp
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
...
...
@@ -493,7 +512,7 @@ int32_t vectorConvertImpl(SScalarParam* pIn, SScalarParam* pOut) {
}
break
;
default:
q
Error
(
"invalid convert output type:%d"
,
outType
);
scl
Error
(
"invalid convert output type:%d"
,
outType
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
...
...
@@ -541,6 +560,10 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p
return
TSDB_CODE_SUCCESS
;
}
if
(
SCL_DATA_TYPE_DUMMY_HASH
==
pLeft
->
type
||
SCL_DATA_TYPE_DUMMY_HASH
==
pRight
->
type
)
{
return
TSDB_CODE_SUCCESS
;
}
SScalarParam
*
param1
=
NULL
,
*
paramOut1
=
NULL
;
SScalarParam
*
param2
=
NULL
,
*
paramOut2
=
NULL
;
int32_t
code
=
0
;
...
...
@@ -604,6 +627,46 @@ void vectorAdd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
SScalarParam
leftParam
=
{.
type
=
TSDB_DATA_TYPE_DOUBLE
,
.
num
=
pLeft
->
num
};
SScalarParam
rightParam
=
{.
type
=
TSDB_DATA_TYPE_DOUBLE
,
.
num
=
pRight
->
num
};
if
(
IS_VAR_DATA_TYPE
(
pLeft
->
type
))
{
leftParam
.
data
=
calloc
(
leftParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
leftParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
leftParam
.
num
*
sizeof
(
double
)));
return
;
}
if
(
pLeft
->
colData
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
pLeft
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
return
;
}
pLeft
=
&
leftParam
;
}
if
(
IS_VAR_DATA_TYPE
(
pRight
->
type
))
{
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
rightParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
tfree
(
leftParam
.
data
);
return
;
}
if
(
pRight
->
colData
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pRight
->
data
;
pRight
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
return
;
}
pRight
=
&
rightParam
;
}
double
*
output
=
(
double
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
...
...
@@ -637,12 +700,55 @@ void vectorAdd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
+
getVectorDoubleValueFnRight
(
pRight
->
data
,
0
));
}
}
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
}
void
vectorSub
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
SScalarParam
leftParam
=
{.
type
=
TSDB_DATA_TYPE_DOUBLE
,
.
num
=
pLeft
->
num
};
SScalarParam
rightParam
=
{.
type
=
TSDB_DATA_TYPE_DOUBLE
,
.
num
=
pRight
->
num
};
if
(
IS_VAR_DATA_TYPE
(
pLeft
->
type
))
{
leftParam
.
data
=
calloc
(
leftParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
leftParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
leftParam
.
num
*
sizeof
(
double
)));
return
;
}
if
(
pLeft
->
colData
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
pLeft
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
return
;
}
pLeft
=
&
leftParam
;
}
if
(
IS_VAR_DATA_TYPE
(
pRight
->
type
))
{
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
rightParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
tfree
(
leftParam
.
data
);
return
;
}
if
(
pRight
->
colData
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pRight
->
data
;
pRight
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
return
;
}
pRight
=
&
rightParam
;
}
double
*
output
=
(
double
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
...
...
@@ -675,11 +781,54 @@ void vectorSub(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _or
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
-
getVectorDoubleValueFnRight
(
pRight
->
data
,
0
));
}
}
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
}
void
vectorMultiply
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
SScalarParam
leftParam
=
{.
type
=
TSDB_DATA_TYPE_DOUBLE
,
.
num
=
pLeft
->
num
};
SScalarParam
rightParam
=
{.
type
=
TSDB_DATA_TYPE_DOUBLE
,
.
num
=
pRight
->
num
};
if
(
IS_VAR_DATA_TYPE
(
pLeft
->
type
))
{
leftParam
.
data
=
calloc
(
leftParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
leftParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
leftParam
.
num
*
sizeof
(
double
)));
return
;
}
if
(
pLeft
->
colData
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
pLeft
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
return
;
}
pLeft
=
&
leftParam
;
}
if
(
IS_VAR_DATA_TYPE
(
pRight
->
type
))
{
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
rightParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
tfree
(
leftParam
.
data
);
return
;
}
if
(
pRight
->
colData
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pRight
->
data
;
pRight
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
return
;
}
pRight
=
&
rightParam
;
}
double
*
output
=
(
double
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
...
...
@@ -713,12 +862,55 @@ void vectorMultiply(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
*
getVectorDoubleValueFnRight
(
pRight
->
data
,
0
));
}
}
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
}
void
vectorDivide
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
SScalarParam
leftParam
=
{.
type
=
TSDB_DATA_TYPE_DOUBLE
,
.
num
=
pLeft
->
num
};
SScalarParam
rightParam
=
{.
type
=
TSDB_DATA_TYPE_DOUBLE
,
.
num
=
pRight
->
num
};
if
(
IS_VAR_DATA_TYPE
(
pLeft
->
type
))
{
leftParam
.
data
=
calloc
(
leftParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
leftParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
leftParam
.
num
*
sizeof
(
double
)));
return
;
}
if
(
pLeft
->
colData
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
pLeft
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
return
;
}
pLeft
=
&
leftParam
;
}
if
(
IS_VAR_DATA_TYPE
(
pRight
->
type
))
{
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
rightParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
tfree
(
leftParam
.
data
);
return
;
}
if
(
pRight
->
colData
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pRight
->
data
;
pRight
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
return
;
}
pRight
=
&
rightParam
;
}
double
*
output
=
(
double
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
...
...
@@ -759,12 +951,55 @@ void vectorDivide(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
SET_DOUBLE_VAL
(
output
,
getVectorDoubleValueFnLeft
(
pLeft
->
data
,
i
)
/
right
);
}
}
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
}
void
vectorRemainder
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
SScalarParam
leftParam
=
{.
type
=
TSDB_DATA_TYPE_DOUBLE
,
.
num
=
pLeft
->
num
};
SScalarParam
rightParam
=
{.
type
=
TSDB_DATA_TYPE_DOUBLE
,
.
num
=
pRight
->
num
};
if
(
IS_VAR_DATA_TYPE
(
pLeft
->
type
))
{
leftParam
.
data
=
calloc
(
leftParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
leftParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
leftParam
.
num
*
sizeof
(
double
)));
return
;
}
if
(
pLeft
->
colData
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
pLeft
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
return
;
}
pLeft
=
&
leftParam
;
}
if
(
IS_VAR_DATA_TYPE
(
pRight
->
type
))
{
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
double
));
if
(
NULL
==
rightParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
double
)));
tfree
(
leftParam
.
data
);
return
;
}
if
(
pRight
->
colData
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pRight
->
data
;
pRight
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
return
;
}
pRight
=
&
rightParam
;
}
double
*
output
=
(
double
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
...
...
@@ -831,6 +1066,9 @@ void vectorRemainder(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32
SET_DOUBLE_VAL
(
output
,
left
-
((
int64_t
)(
left
/
right
))
*
right
);
}
}
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
}
void
vectorConcat
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
...
...
@@ -888,6 +1126,46 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
SScalarParam
leftParam
=
{.
type
=
TSDB_DATA_TYPE_BIGINT
,
.
num
=
pLeft
->
num
};
SScalarParam
rightParam
=
{.
type
=
TSDB_DATA_TYPE_BIGINT
,
.
num
=
pRight
->
num
};
if
(
IS_VAR_DATA_TYPE
(
pLeft
->
type
))
{
leftParam
.
data
=
calloc
(
leftParam
.
num
,
sizeof
(
int64_t
));
if
(
NULL
==
leftParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
leftParam
.
num
*
sizeof
(
int64_t
)));
return
;
}
if
(
pLeft
->
colData
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
pLeft
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
return
;
}
pLeft
=
&
leftParam
;
}
if
(
IS_VAR_DATA_TYPE
(
pRight
->
type
))
{
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
int64_t
));
if
(
NULL
==
rightParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
int64_t
)));
tfree
(
leftParam
.
data
);
return
;
}
if
(
pRight
->
colData
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pRight
->
data
;
pRight
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
return
;
}
pRight
=
&
rightParam
;
}
int64_t
*
output
=
(
int64_t
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
...
...
@@ -921,12 +1199,55 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
SET_BIGINT_VAL
(
output
,
getVectorBigintValueFnLeft
(
pLeft
->
data
,
i
)
&
getVectorBigintValueFnRight
(
pRight
->
data
,
0
));
}
}
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
}
void
vectorBitOr
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
int32_t
i
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
0
:
TMAX
(
pLeft
->
num
,
pRight
->
num
)
-
1
;
int32_t
step
=
((
_ord
)
==
TSDB_ORDER_ASC
)
?
1
:
-
1
;
SScalarParam
leftParam
=
{.
type
=
TSDB_DATA_TYPE_BIGINT
,
.
num
=
pLeft
->
num
};
SScalarParam
rightParam
=
{.
type
=
TSDB_DATA_TYPE_BIGINT
,
.
num
=
pRight
->
num
};
if
(
IS_VAR_DATA_TYPE
(
pLeft
->
type
))
{
leftParam
.
data
=
calloc
(
leftParam
.
num
,
sizeof
(
int64_t
));
if
(
NULL
==
leftParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
leftParam
.
num
*
sizeof
(
int64_t
)));
return
;
}
if
(
pLeft
->
colData
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pLeft
->
data
;
pLeft
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pLeft
,
&
leftParam
))
{
return
;
}
pLeft
=
&
leftParam
;
}
if
(
IS_VAR_DATA_TYPE
(
pRight
->
type
))
{
rightParam
.
data
=
calloc
(
rightParam
.
num
,
sizeof
(
int64_t
));
if
(
NULL
==
rightParam
.
data
)
{
sclError
(
"malloc %d failed"
,
(
int32_t
)(
rightParam
.
num
*
sizeof
(
int64_t
)));
tfree
(
leftParam
.
data
);
return
;
}
if
(
pRight
->
colData
)
{
SColumnInfoData
*
colInfo
=
(
SColumnInfoData
*
)
pRight
->
data
;
pRight
->
data
=
colInfo
->
pData
;
}
if
(
vectorConvertImpl
(
pRight
,
&
rightParam
))
{
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
return
;
}
pRight
=
&
rightParam
;
}
int64_t
*
output
=
(
int64_t
*
)
out
;
_getValueAddr_fn_t
getVectorValueAddrFnLeft
=
getVectorValueAddrFn
(
pLeft
->
type
);
_getValueAddr_fn_t
getVectorValueAddrFnRight
=
getVectorValueAddrFn
(
pRight
->
type
);
...
...
@@ -960,6 +1281,9 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _
SET_BIGINT_VAL
(
output
,
getVectorBigintValueFnLeft
(
pLeft
->
data
,
i
)
|
getVectorBigintValueFnRight
(
pRight
->
data
,
0
));
}
}
tfree
(
leftParam
.
data
);
tfree
(
rightParam
.
data
);
}
...
...
@@ -1039,7 +1363,7 @@ void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t
param2
=
pRight
;
}
vectorCompareImpl
(
param1
,
param2
,
out
,
_ord
,
TSDB_RELATION_GREATER
);
vectorCompareImpl
(
param1
,
param2
,
out
,
_ord
,
optr
);
}
void
vectorGreater
(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
void
*
out
,
int32_t
_ord
)
{
...
...
source/libs/scalar/test/scalarTests.cpp
浏览文件 @
93baf85a
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录