Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
97e7a41a
T
TDengine
项目概览
taosdata
/
TDengine
12 个月 前同步成功
通知
1180
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
97e7a41a
编写于
2月 28, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feature/qnode
上级
cda69861
变更
8
展开全部
隐藏空白更改
内联
并排
Showing
8 changed file
with
569 addition
and
163 deletion
+569
-163
include/common/tep.h
include/common/tep.h
+1
-0
source/common/src/tep.c
source/common/src/tep.c
+41
-26
source/libs/nodes/src/nodesTraverseFuncs.c
source/libs/nodes/src/nodesTraverseFuncs.c
+3
-0
source/libs/scalar/inc/sclvector.h
source/libs/scalar/inc/sclvector.h
+3
-0
source/libs/scalar/src/filter.c
source/libs/scalar/src/filter.c
+1
-0
source/libs/scalar/src/scalar.c
source/libs/scalar/src/scalar.c
+22
-16
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+256
-15
source/libs/scalar/test/scalar/scalarTests.cpp
source/libs/scalar/test/scalar/scalarTests.cpp
+242
-106
未找到文件。
include/common/tep.h
浏览文件 @
97e7a41a
...
...
@@ -101,6 +101,7 @@ size_t blockDataNumOfRowsForSerialize(const SSDataBlock* pBlock, int32_t blockSi
int32_t
blockDataSort
(
SSDataBlock
*
pDataBlock
,
SArray
*
pOrderInfo
,
bool
nullFirst
);
int32_t
blockDataSort_rv
(
SSDataBlock
*
pDataBlock
,
SArray
*
pOrderInfo
,
bool
nullFirst
);
int32_t
blockDataEnsureColumnCapacity
(
SColumnInfoData
*
pColumn
,
uint32_t
numOfRows
);
int32_t
blockDataEnsureCapacity
(
SSDataBlock
*
pDataBlock
,
uint32_t
numOfRows
);
void
blockDataClearup
(
SSDataBlock
*
pDataBlock
,
bool
hasVarCol
);
void
*
blockDataDestroy
(
SSDataBlock
*
pBlock
);
...
...
source/common/src/tep.c
浏览文件 @
97e7a41a
...
...
@@ -120,14 +120,18 @@ int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, con
}
else
{
char
*
p
=
pColumnInfoData
->
pData
+
pColumnInfoData
->
info
.
bytes
*
currentRow
;
switch
(
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
{
*
(
bool
*
)
p
=
*
(
bool
*
)
pData
;
break
;}
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_UTINYINT
:
{
*
(
int8_t
*
)
p
=
*
(
int8_t
*
)
pData
;
break
;}
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
{
*
(
int16_t
*
)
p
=
*
(
int16_t
*
)
pData
;
break
;}
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_UINT
:
{
*
(
int32_t
*
)
p
=
*
(
int32_t
*
)
pData
;
break
;}
case
TSDB_DATA_TYPE_TIMESTAMP
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
{
*
(
int64_t
*
)
p
=
*
(
int64_t
*
)
pData
;
break
;}
case
TSDB_DATA_TYPE_FLOAT
:
{
*
(
float
*
)
p
=
*
(
float
*
)
pData
;
break
;}
case
TSDB_DATA_TYPE_DOUBLE
:
{
*
(
double
*
)
p
=
*
(
double
*
)
pData
;
break
;}
default:
assert
(
0
);
}
...
...
@@ -1040,36 +1044,47 @@ void blockDataClearup(SSDataBlock* pDataBlock, bool hasVarCol) {
}
}
int32_t
blockDataEnsureCapacity
(
SSDataBlock
*
pDataBlock
,
uint32_t
numOfRows
)
{
for
(
int32_t
i
=
0
;
i
<
pDataBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
p
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
i
);
if
(
IS_VAR_DATA_TYPE
(
p
->
info
.
type
))
{
char
*
tmp
=
realloc
(
p
->
varmeta
.
offset
,
sizeof
(
int32_t
)
*
numOfRows
);
if
(
tmp
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
blockDataEnsureColumnCapacity
(
SColumnInfoData
*
pColumn
,
uint32_t
numOfRows
)
{
if
(
IS_VAR_DATA_TYPE
(
pColumn
->
info
.
type
))
{
char
*
tmp
=
realloc
(
pColumn
->
varmeta
.
offset
,
sizeof
(
int32_t
)
*
numOfRows
);
if
(
tmp
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
p
->
varmeta
.
offset
=
(
int32_t
*
)
tmp
;
memset
(
p
->
varmeta
.
offset
,
0
,
sizeof
(
int32_t
)
*
numOfRows
);
pColumn
->
varmeta
.
offset
=
(
int32_t
*
)
tmp
;
memset
(
pColumn
->
varmeta
.
offset
,
0
,
sizeof
(
int32_t
)
*
numOfRows
);
p
->
varmeta
.
length
=
0
;
p
->
varmeta
.
allocLen
=
0
;
tfree
(
p
->
pData
);
}
else
{
char
*
tmp
=
realloc
(
p
->
nullbitmap
,
BitmapLen
(
numOfRows
));
if
(
tmp
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pColumn
->
varmeta
.
length
=
0
;
pColumn
->
varmeta
.
allocLen
=
0
;
tfree
(
pColumn
->
pData
);
}
else
{
char
*
tmp
=
realloc
(
pColumn
->
nullbitmap
,
BitmapLen
(
numOfRows
));
if
(
tmp
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
p
->
nullbitmap
=
tmp
;
memset
(
p
->
nullbitmap
,
0
,
BitmapLen
(
numOfRows
));
pColumn
->
nullbitmap
=
tmp
;
memset
(
pColumn
->
nullbitmap
,
0
,
BitmapLen
(
numOfRows
));
tmp
=
realloc
(
p
->
pData
,
numOfRows
*
p
->
info
.
bytes
);
if
(
tmp
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
tmp
=
realloc
(
pColumn
->
pData
,
numOfRows
*
pColumn
->
info
.
bytes
);
if
(
tmp
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
p
->
pData
=
tmp
;
pColumn
->
pData
=
tmp
;
}
return
TSDB_CODE_SUCCESS
;
}
int32_t
blockDataEnsureCapacity
(
SSDataBlock
*
pDataBlock
,
uint32_t
numOfRows
)
{
int32_t
code
=
0
;
for
(
int32_t
i
=
0
;
i
<
pDataBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
p
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
i
);
code
=
blockDataEnsureColumnCapacity
(
p
,
numOfRows
);
if
(
code
)
{
return
code
;
}
}
...
...
@@ -1097,4 +1112,4 @@ void* blockDataDestroy(SSDataBlock* pBlock) {
tfree
(
pBlock
->
pBlockAgg
);
tfree
(
pBlock
);
return
NULL
;
}
\ No newline at end of file
}
source/libs/nodes/src/nodesTraverseFuncs.c
浏览文件 @
97e7a41a
...
...
@@ -105,6 +105,9 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker
case
QUERY_NODE_RAW_EXPR
:
res
=
walkNode
(((
SRawExprNode
*
)
pNode
)
->
pNode
,
order
,
walker
,
pContext
);
break
;
case
QUERY_NODE_TARGET
:
res
=
walkNode
(((
STargetNode
*
)
pNode
)
->
pExpr
,
order
,
walker
,
pContext
);
break
;
default:
break
;
}
...
...
source/libs/scalar/inc/sclvector.h
浏览文件 @
97e7a41a
...
...
@@ -22,6 +22,9 @@ extern "C" {
#include "sclfunc.h"
typedef
double
(
*
_mathFunc
)(
double
,
double
,
bool
*
);
typedef
void
(
*
_bufConverteFunc
)(
char
*
buf
,
SScalarParam
*
pOut
,
int32_t
outType
);
typedef
void
(
*
_bin_scalar_fn_t
)(
SScalarParam
*
pLeft
,
SScalarParam
*
pRight
,
SScalarParam
*
output
,
int32_t
order
);
_bin_scalar_fn_t
getBinScalarOperatorFn
(
int32_t
binOperator
);
...
...
source/libs/scalar/src/filter.c
浏览文件 @
97e7a41a
无法预览此类型文件
source/libs/scalar/src/scalar.c
浏览文件 @
97e7a41a
...
...
@@ -142,9 +142,13 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
case
QUERY_NODE_VALUE
:
{
SValueNode
*
valueNode
=
(
SValueNode
*
)
node
;
param
->
data
=
nodesGetValueFromNode
(
valueNode
);
param
->
orig
.
data
=
param
->
data
;
param
->
num
=
1
;
param
->
type
=
valueNode
->
node
.
resType
.
type
;
param
->
bytes
=
valueNode
->
node
.
resType
.
bytes
;
if
(
TSDB_DATA_TYPE_NULL
==
param
->
type
)
{
sclSetNull
(
param
,
0
);
}
param
->
dataInBlock
=
false
;
break
;
...
...
@@ -178,12 +182,12 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t
}
SColumnNode
*
ref
=
(
SColumnNode
*
)
node
;
if
(
ref
->
tuple
Id
>=
taosArrayGetSize
(
ctx
->
pBlockList
))
{
sclError
(
"column tupleId is too big, tupleId:%d, dataBlockNum:%d"
,
ref
->
tuple
Id
,
(
int32_t
)
taosArrayGetSize
(
ctx
->
pBlockList
));
if
(
ref
->
dataBlock
Id
>=
taosArrayGetSize
(
ctx
->
pBlockList
))
{
sclError
(
"column tupleId is too big, tupleId:%d, dataBlockNum:%d"
,
ref
->
dataBlock
Id
,
(
int32_t
)
taosArrayGetSize
(
ctx
->
pBlockList
));
SCL_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
SSDataBlock
*
block
=
*
(
SSDataBlock
**
)
taosArrayGet
(
ctx
->
pBlockList
,
ref
->
tuple
Id
);
SSDataBlock
*
block
=
*
(
SSDataBlock
**
)
taosArrayGet
(
ctx
->
pBlockList
,
ref
->
dataBlock
Id
);
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
));
...
...
@@ -639,15 +643,15 @@ EDealRes sclWalkOperator(SNode* pNode, SScalarCtx *ctx) {
EDealRes
sclWalkTarget
(
SNode
*
pNode
,
SScalarCtx
*
ctx
)
{
STargetNode
*
target
=
(
STargetNode
*
)
pNode
;
if
(
target
->
tuple
Id
>=
taosArrayGetSize
(
ctx
->
pBlockList
))
{
sclError
(
"target tupleId is too big, tupleId:%d, dataBlockNum:%d"
,
target
->
tuple
Id
,
(
int32_t
)
taosArrayGetSize
(
ctx
->
pBlockList
));
if
(
target
->
dataBlock
Id
>=
taosArrayGetSize
(
ctx
->
pBlockList
))
{
sclError
(
"target tupleId is too big, tupleId:%d, dataBlockNum:%d"
,
target
->
dataBlock
Id
,
(
int32_t
)
taosArrayGetSize
(
ctx
->
pBlockList
));
ctx
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
DEAL_RES_ERROR
;
}
SSDataBlock
*
block
=
taosArrayGet
(
ctx
->
pBlockList
,
target
->
tuple
Id
);
SSDataBlock
*
block
=
*
(
SSDataBlock
**
)
taosArrayGet
(
ctx
->
pBlockList
,
target
->
dataBlock
Id
);
if
(
target
->
slotId
>=
taosArrayGetSize
(
block
->
pDataBlock
))
{
sclError
(
"target slot not exist,
slotId:%d, dataBlockNum:%d"
,
target
->
slotId
,
(
int32_t
)
taosArrayGetSize
(
block
->
pDataBlock
));
sclError
(
"target slot not exist,
dataBlockId:%d, slotId:%d, dataBlockNum:%d"
,
target
->
dataBlockId
,
target
->
slotId
,
(
int32_t
)
taosArrayGetSize
(
block
->
pDataBlock
));
ctx
->
code
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
DEAL_RES_ERROR
;
}
...
...
@@ -734,7 +738,7 @@ _return:
}
int32_t
scalarCalculate
(
SNode
*
pNode
,
SArray
*
pBlockList
,
SScalarParam
*
pDst
)
{
if
(
NULL
==
pNode
||
NULL
==
pBlockList
||
NULL
==
pDst
)
{
if
(
NULL
==
pNode
||
NULL
==
pBlockList
)
{
SCL_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
...
...
@@ -751,15 +755,17 @@ int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) {
SCL_ERR_JRET
(
ctx
.
code
);
SScalarParam
*
res
=
(
SScalarParam
*
)
taosHashGet
(
ctx
.
pRes
,
(
void
*
)
&
pNode
,
POINTER_BYTES
);
if
(
NULL
==
res
)
{
sclError
(
"no valid res in hash, node:%p, type:%d"
,
pNode
,
nodeType
(
pNode
));
SCL_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
if
(
pDst
)
{
SScalarParam
*
res
=
(
SScalarParam
*
)
taosHashGet
(
ctx
.
pRes
,
(
void
*
)
&
pNode
,
POINTER_BYTES
);
if
(
NULL
==
res
)
{
sclError
(
"no valid res in hash, node:%p, type:%d"
,
pNode
,
nodeType
(
pNode
));
SCL_ERR_JRET
(
TSDB_CODE_QRY_APP_ERROR
);
}
taosHashRemove
(
ctx
.
pRes
,
(
void
*
)
&
pNode
,
POINTER_BYTES
);
*
pDst
=
*
res
;
}
taosHashRemove
(
ctx
.
pRes
,
(
void
*
)
&
pNode
,
POINTER_BYTES
);
*
pDst
=
*
res
;
_return:
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
97e7a41a
此差异已折叠。
点击以展开。
source/libs/scalar/test/scalar/scalarTests.cpp
浏览文件 @
97e7a41a
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录