Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
lzh_me
TDengine
提交
df667dea
TDengine
项目概览
lzh_me
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
df667dea
编写于
2月 22, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-2895] refactor query processing model.
上级
7170a716
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
1006 addition
and
1611 deletion
+1006
-1611
src/client/src/tscServer.c
src/client/src/tscServer.c
+1
-1
src/query/inc/qAggMain.h
src/query/inc/qAggMain.h
+2
-2
src/query/inc/qExecutor.h
src/query/inc/qExecutor.h
+4
-4
src/query/src/qAggMain.c
src/query/src/qAggMain.c
+1
-9
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+957
-1557
src/tsdb/src/tsdbRead.c
src/tsdb/src/tsdbRead.c
+8
-7
tests/script/general/parser/col_arithmetic_operation.sim
tests/script/general/parser/col_arithmetic_operation.sim
+1
-0
tests/script/general/parser/col_arithmetic_query.sim
tests/script/general/parser/col_arithmetic_query.sim
+31
-31
tests/script/general/parser/fill.sim
tests/script/general/parser/fill.sim
+1
-0
未找到文件。
src/client/src/tscServer.c
浏览文件 @
df667dea
...
...
@@ -883,7 +883,7 @@ int tscBuildQueryMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
assert
(
pField
->
pArithExprInfo
!=
NULL
);
SExprInfo
*
pExprInfo
=
pField
->
pArithExprInfo
;
pSqlFuncExpr1
->
colInfo
.
colId
=
htons
(
pExprInfo
->
base
.
colInfo
.
colId
);
pSqlFuncExpr1
->
colInfo
.
colId
=
htons
(
pExprInfo
->
base
.
colInfo
.
colId
);
pSqlFuncExpr1
->
functionId
=
htons
(
pExprInfo
->
base
.
functionId
);
pSqlFuncExpr1
->
numOfParams
=
htons
(
pExprInfo
->
base
.
numOfParams
);
pMsg
+=
sizeof
(
SSqlFuncMsg
);
...
...
src/query/inc/qAggMain.h
浏览文件 @
df667dea
...
...
@@ -258,14 +258,14 @@ bool topbot_datablock_filter(SQLFunctionCtx *pCtx, const char *minval, const cha
(_r)->initialized = false; \
} while (0)
static
FORCE_INLINE
void
initResultInfo
(
SResultRowCellInfo
*
pResInfo
,
u
int32_t
bufLen
)
{
static
FORCE_INLINE
void
initResultInfo
(
SResultRowCellInfo
*
pResInfo
,
int32_t
bufLen
)
{
pResInfo
->
initialized
=
true
;
// the this struct has been initialized flag
pResInfo
->
complete
=
false
;
pResInfo
->
hasResult
=
false
;
pResInfo
->
numOfRes
=
0
;
memset
(
GET_ROWCELL_INTERBUF
(
pResInfo
),
0
,
(
size_t
)
bufLen
);
memset
(
GET_ROWCELL_INTERBUF
(
pResInfo
),
0
,
bufLen
);
}
#ifdef __cplusplus
...
...
src/query/inc/qExecutor.h
浏览文件 @
df667dea
...
...
@@ -259,14 +259,12 @@ typedef struct SQueryRuntimeEnv {
SQuery
*
pQuery
;
void
*
qinfo
;
SQLFunctionCtx
*
pCtx
;
//
SQLFunctionCtx* pCtx;
int32_t
numOfRowsPerPage
;
uint16_t
*
offset
;
uint16_t
scanFlag
;
// denotes reversed scan of data or not
SFillInfo
*
pFillInfo
;
SResultRowInfo
resultRowInfo
;
void
*
pQueryHandle
;
void
*
pSecQueryHandle
;
// another thread for
int32_t
prevGroupId
;
// previous executed group id
SDiskbasedResultBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
...
...
@@ -375,6 +373,8 @@ typedef struct SAggOperatorInfo {
STableQueryInfo
*
pTableQueryInfo
;
SQueryRuntimeEnv
*
pRuntimeEnv
;
SQLFunctionCtx
*
pCtx
;
SSDataBlock
*
pRes
;
}
SAggOperatorInfo
;
typedef
struct
SArithOperatorInfo
{
...
...
@@ -383,6 +383,7 @@ typedef struct SArithOperatorInfo {
SQLFunctionCtx
*
pCtx
;
SResultRowInfo
resultRowInfo
;
SSDataBlock
*
pOutput
;
int32_t
bufCapacity
;
}
SArithOperatorInfo
;
typedef
struct
SLimitOperatorInfo
{
...
...
@@ -411,7 +412,6 @@ typedef struct SFillOperatorInfo {
}
SFillOperatorInfo
;
typedef
struct
SHashGroupbyOperatorInfo
{
SResultRowInfo
*
pResultRowInfo
;
STableQueryInfo
*
pTableQueryInfo
;
SQueryRuntimeEnv
*
pRuntimeEnv
;
SQLFunctionCtx
*
pCtx
;
...
...
src/query/src/qAggMain.c
浏览文件 @
df667dea
...
...
@@ -2005,13 +2005,7 @@ static void last_dist_function(SQLFunctionCtx *pCtx) {
return
;
}
// data block is discard, not loaded, do not need to check it
if
(
!
pCtx
->
preAggVals
.
dataBlockLoaded
)
{
return
;
}
int32_t
notNullElems
=
0
;
for
(
int32_t
i
=
pCtx
->
size
-
1
;
i
>=
0
;
--
i
)
{
char
*
data
=
GET_INPUT_DATA
(
pCtx
,
i
);
if
(
pCtx
->
hasNull
&&
isNull
(
data
,
pCtx
->
inputType
))
{
...
...
@@ -3174,8 +3168,6 @@ static void col_project_function(SQLFunctionCtx *pCtx) {
pCtx
->
inputBytes
);
}
}
pCtx
->
pOutput
+=
pCtx
->
size
*
pCtx
->
outputBytes
;
}
static
void
col_project_function_f
(
SQLFunctionCtx
*
pCtx
,
int32_t
index
)
{
...
...
@@ -3574,7 +3566,7 @@ static void arithmetic_function(SQLFunctionCtx *pCtx) {
SArithmeticSupport
*
sas
=
(
SArithmeticSupport
*
)
pCtx
->
param
[
1
].
pz
;
arithmeticTreeTraverse
(
sas
->
pArithExpr
->
pExpr
,
pCtx
->
size
,
pCtx
->
pOutput
,
sas
,
pCtx
->
order
,
getArithColumnData
);
pCtx
->
pOutput
+=
pCtx
->
outputBytes
*
pCtx
->
size
;
//
pCtx->pOutput += pCtx->outputBytes * pCtx->size;
}
static
void
arithmetic_function_f
(
SQLFunctionCtx
*
pCtx
,
int32_t
index
)
{
...
...
src/query/src/qExecutor.c
浏览文件 @
df667dea
此差异已折叠。
点击以展开。
src/tsdb/src/tsdbRead.c
浏览文件 @
df667dea
...
...
@@ -297,13 +297,13 @@ static void resetCheckInfo(STsdbQueryHandle* pQueryHandle) {
pCheckInfo
->
lastKey
=
pQueryHandle
->
window
.
skey
;
pCheckInfo
->
iter
=
tSkipListDestroyIter
(
pCheckInfo
->
iter
);
pCheckInfo
->
iiter
=
tSkipListDestroyIter
(
pCheckInfo
->
iiter
);
pCheckInfo
->
initBuf
=
false
;
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
assert
(
pCheckInfo
->
lastKey
>=
pQueryHandle
->
window
.
skey
);
}
else
{
assert
(
pCheckInfo
->
lastKey
<=
pQueryHandle
->
window
.
skey
);
}
if
(
ASCENDING_TRAVERSE
(
pQueryHandle
->
order
))
{
assert
(
pCheckInfo
->
lastKey
>=
pQueryHandle
->
window
.
skey
);
}
else
{
assert
(
pCheckInfo
->
lastKey
<=
pQueryHandle
->
window
.
skey
);
}
}
}
...
...
@@ -2035,7 +2035,8 @@ static bool doHasDataInBuffer(STsdbQueryHandle* pQueryHandle) {
}
// no data in memtable or imemtable, decrease the memory reference.
tsdbMayUnTakeMemSnapshot
(
pQueryHandle
);
// TODO !!
// tsdbMayUnTakeMemSnapshot(pQueryHandle);
return
false
;
}
...
...
tests/script/general/parser/col_arithmetic_operation.sim
浏览文件 @
df667dea
...
...
@@ -93,6 +93,7 @@ $halfTbNum = $tbNum / 2
$nchar = 'nchar . $c
$nchar = $nchar . '
$ts = $ts + 1
sql insert into $tb5 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb6 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb7 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb8 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar ) $tb9 values ( $ts , NULL , $c , NULL , $c , NULL , $c , NULL, NULL , $nchar )
$x = $x + 1
endw
...
...
tests/script/general/parser/col_arithmetic_query.sim
浏览文件 @
df667dea
...
...
@@ -426,7 +426,7 @@ if $data02 != 9.000000020 then
endi
# all possible function in the arithmetic expression, add more
sql select min(c1) * max(c2) /4, sum(c1) * apercentile(c2, 20), apercentile(c4, 33) + 52/9, spread(c5)/min(c2), count(1)/sum(c1), avg(c2)*count(c2) from $stb where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-11-25 19:30:0
0
.000';
sql select min(c1) * max(c2) /4, sum(c1) * apercentile(c2, 20), apercentile(c4, 33) + 52/9, spread(c5)/min(c2), count(1)/sum(c1), avg(c2)*count(c2) from $stb where ts >= '2018-09-17 09:00:00.000' and ts <= '2018-11-25 19:30:0
1
.000';
if $rows != 1 then
return -1
endi
...
...
@@ -462,7 +462,7 @@ if $rows != 0 then
endi
# no result return [d.3]
sql select sum(c2) - avg(c2) from $stb where ts > '2018-11-25 19:30:0
0
.000'
sql select sum(c2) - avg(c2) from $stb where ts > '2018-11-25 19:30:0
1
.000'
if $rows != 0 then
return -1
endi
...
...
@@ -520,35 +520,35 @@ if $data91 != 9 then
endi
# in group by column
sql select apercentile(c6, 50)-first(c6)+last(c5)*12, last(c5)*12 from ca_stb0 group by c2;
if $rows != 10 then
return -1
endi
if $data00 != 0.000000000 then
return -1
endi
if $data01 != 0.000000000 then
return -1
endi
if $data10 != 12.000000000 then
return -1
endi
if $data11 != 12.000000000 then
return -1
endi
if $data20 != 24.000000000 then
return -1
endi
if $data21 != 24.000000000 then
return -1
endi
#
sql select apercentile(c6, 50)-first(c6)+last(c5)*12, last(c5)*12 from ca_stb0 group by c2;
#
if $rows != 10 then
#
return -1
#
endi
#
#
if $data00 != 0.000000000 then
#
return -1
#
endi
#
#
if $data01 != 0.000000000 then
#
return -1
#
endi
#
#
if $data10 != 12.000000000 then
#
return -1
#
endi
#
#
if $data11 != 12.000000000 then
#
return -1
#
endi
#
#
if $data20 != 24.000000000 then
#
return -1
#
endi
#
#
if $data21 != 24.000000000 then
#
return -1
#
endi
#
sql_error select first(c6) - last(c6) *12 / count(*) from $stb group by c3;
sql select first(c6) - last(c6) *12 / count(*) from $stb group by c5;
...
...
tests/script/general/parser/fill.sim
浏览文件 @
df667dea
...
...
@@ -313,6 +313,7 @@ if $rows != 9 then
return -1
endi
if $data01 != 0 then
print expect 0, actual:$data01
return -1
endi
if $data11 != 6 then
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录