Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
5d83a353
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
5d83a353
编写于
12月 10, 2020
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-225] refactor codes.
上级
4a939018
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
35 deletion
+27
-35
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+11
-5
src/query/src/qExecutor.c
src/query/src/qExecutor.c
+16
-30
未找到文件。
src/client/src/tscSubquery.c
浏览文件 @
5d83a353
...
...
@@ -2172,6 +2172,15 @@ static bool needRetryInsert(SSqlObj* pParentObj, int32_t numOfSub) {
return
true
;
}
static
void
doFreeInsertSupporter
(
SSqlObj
*
pSqlObj
)
{
assert
(
pSqlObj
!=
NULL
&&
pSqlObj
->
subState
.
numOfSub
>
0
);
for
(
int32_t
i
=
0
;
i
<
pSqlObj
->
subState
.
numOfSub
;
++
i
)
{
SSqlObj
*
pSql
=
pSqlObj
->
pSubs
[
i
];
tfree
(
pSql
->
param
);
}
}
static
void
multiVnodeInsertFinalize
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
)
{
SInsertSupporter
*
pSupporter
=
(
SInsertSupporter
*
)
param
;
SSqlObj
*
pParentObj
=
pSupporter
->
pSql
;
...
...
@@ -2203,10 +2212,7 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
if
(
pParentObj
->
res
.
code
==
TSDB_CODE_SUCCESS
)
{
tscDebug
(
"%p Async insertion completed, total inserted:%d"
,
pParentObj
,
pParentObj
->
res
.
numOfRows
);
for
(
int32_t
i
=
0
;
i
<
numOfSub
;
++
i
)
{
SSqlObj
*
pSql
=
pParentObj
->
pSubs
[
i
];
tfree
(
pSql
->
param
);
}
doFreeInsertSupporter
(
pParentObj
);
// todo remove this parameter in async callback function definition.
// all data has been sent to vnode, call user function
...
...
@@ -2214,6 +2220,7 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
(
*
pParentObj
->
fp
)(
pParentObj
->
param
,
pParentObj
,
v
);
}
else
{
if
(
!
needRetryInsert
(
pParentObj
,
numOfSub
))
{
doFreeInsertSupporter
(
pParentObj
);
tscQueueAsyncRes
(
pParentObj
);
return
;
}
...
...
@@ -2244,7 +2251,6 @@ static void multiVnodeInsertFinalize(void* param, TAOS_RES* tres, int numOfRows)
pParentObj
->
cmd
.
parseFinished
=
false
;
pParentObj
->
subState
.
numOfRemain
=
numOfFailed
;
pParentObj
->
subState
.
numOfSub
=
numOfFailed
;
tscResetSqlCmdObj
(
&
pParentObj
->
cmd
,
false
);
...
...
src/query/src/qExecutor.c
浏览文件 @
5d83a353
...
...
@@ -703,10 +703,11 @@ static FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_se
return
forwardStep
;
}
static
UNUSED_FUNC
void
updateResultRowCurrentIndex
(
SResultRowInfo
*
pWindowResInfo
,
int32_t
*
numOfClosed
,
TSKEY
lastKey
,
bool
ascQuery
)
{
static
int32_t
updateResultRowCurrentIndex
(
SResultRowInfo
*
pWindowResInfo
,
TSKEY
lastKey
,
bool
ascQuery
)
{
int32_t
i
=
0
;
int64_t
skey
=
TSKEY_INITIAL_VAL
;
int32_t
numOfClosed
=
0
;
for
(
i
=
0
;
i
<
pWindowResInfo
->
size
;
++
i
)
{
SResultRow
*
pResult
=
pWindowResInfo
->
pResult
[
i
];
if
(
pResult
->
closed
)
{
...
...
@@ -732,11 +733,11 @@ static UNUSED_FUNC void updateResultRowCurrentIndex(SResultRowInfo* pWindowResIn
}
pWindowResInfo
->
prevSKey
=
pWindowResInfo
->
pResult
[
pWindowResInfo
->
curIndex
]
->
win
.
skey
;
return
numOfClosed
;
}
/**
* NOTE: the query status only set for the first scan of master scan.
* TODO refactor
*/
static
int32_t
doCheckQueryCompleted
(
SQueryRuntimeEnv
*
pRuntimeEnv
,
TSKEY
lastKey
,
SResultRowInfo
*
pWindowResInfo
)
{
SQuery
*
pQuery
=
pRuntimeEnv
->
pQuery
;
...
...
@@ -755,34 +756,7 @@ static int32_t doCheckQueryCompleted(SQueryRuntimeEnv *pRuntimeEnv, TSKEY lastKe
pWindowResInfo
->
curIndex
=
pWindowResInfo
->
size
-
1
;
setQueryStatus
(
pQuery
,
QUERY_COMPLETED
|
QUERY_RESBUF_FULL
);
}
else
{
// set the current index to be the last unclosed window
int32_t
i
=
0
;
int64_t
skey
=
TSKEY_INITIAL_VAL
;
for
(
i
=
0
;
i
<
pWindowResInfo
->
size
;
++
i
)
{
SResultRow
*
pResult
=
pWindowResInfo
->
pResult
[
i
];
if
(
pResult
->
closed
)
{
numOfClosed
+=
1
;
continue
;
}
TSKEY
ekey
=
pResult
->
win
.
ekey
;
if
((
ekey
<=
lastKey
&&
ascQuery
)
||
(
pResult
->
win
.
skey
>=
lastKey
&&
!
ascQuery
))
{
closeTimeWindow
(
pWindowResInfo
,
i
);
}
else
{
skey
=
pResult
->
win
.
skey
;
break
;
}
}
// all windows are closed, set the last one to be the skey
if
(
skey
==
TSKEY_INITIAL_VAL
)
{
assert
(
i
==
pWindowResInfo
->
size
);
pWindowResInfo
->
curIndex
=
pWindowResInfo
->
size
-
1
;
}
else
{
pWindowResInfo
->
curIndex
=
i
;
}
pWindowResInfo
->
prevSKey
=
pWindowResInfo
->
pResult
[
pWindowResInfo
->
curIndex
]
->
win
.
skey
;
numOfClosed
=
updateResultRowCurrentIndex
(
pWindowResInfo
,
lastKey
,
ascQuery
);
// the number of completed slots are larger than the threshold, return current generated results to client.
if
(
numOfClosed
>
pQuery
->
rec
.
threshold
)
{
...
...
@@ -4501,6 +4475,18 @@ static void stableApplyFunctionsOnBlock(SQueryRuntimeEnv *pRuntimeEnv, SDataBloc
}
else
{
blockwiseApplyFunctions
(
pRuntimeEnv
,
pStatis
,
pDataBlockInfo
,
pWindowResInfo
,
searchFn
,
pDataBlock
);
}
if
(
QUERY_IS_INTERVAL_QUERY
(
pQuery
))
{
bool
ascQuery
=
QUERY_IS_ASC_QUERY
(
pQuery
);
// TODO refactor
if
((
pTableQueryInfo
->
lastKey
>=
pTableQueryInfo
->
win
.
ekey
&&
ascQuery
)
||
(
pTableQueryInfo
->
lastKey
<=
pTableQueryInfo
->
win
.
ekey
&&
(
!
ascQuery
)))
{
closeAllTimeWindow
(
pWindowResInfo
);
pWindowResInfo
->
curIndex
=
pWindowResInfo
->
size
-
1
;
}
else
{
updateResultRowCurrentIndex
(
pWindowResInfo
,
pTableQueryInfo
->
lastKey
,
ascQuery
);
}
}
}
bool
queryHasRemainResForTableQuery
(
SQueryRuntimeEnv
*
pRuntimeEnv
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录