Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
ac9ae238
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ac9ae238
编写于
4月 28, 2021
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-225]fix the bug found by regression test.
上级
b4a072f0
变更
7
展开全部
隐藏空白更改
内联
并排
Showing
7 changed file
with
142 addition
and
356 deletion
+142
-356
src/client/inc/tscLocalMerge.h
src/client/inc/tscLocalMerge.h
+11
-23
src/client/src/tscLocalMerge.c
src/client/src/tscLocalMerge.c
+102
-312
src/client/src/tscServer.c
src/client/src/tscServer.c
+5
-0
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+19
-17
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+2
-3
src/vnode/src/vnodeRead.c
src/vnode/src/vnodeRead.c
+1
-1
tests/examples/c/CMakeLists.txt
tests/examples/c/CMakeLists.txt
+2
-0
未找到文件。
src/client/inc/tscLocalMerge.h
浏览文件 @
ac9ae238
...
@@ -39,39 +39,29 @@ typedef struct SLocalDataSource {
...
@@ -39,39 +39,29 @@ typedef struct SLocalDataSource {
}
SLocalDataSource
;
}
SLocalDataSource
;
typedef
struct
SLocalMerger
{
typedef
struct
SLocalMerger
{
SLocalDataSource
**
pLocalDataSrc
;
SLocalDataSource
**
pLocalDataSrc
;
int32_t
numOfBuffer
;
int32_t
numOfBuffer
;
int32_t
numOfCompleted
;
int32_t
numOfCompleted
;
int32_t
numOfVnode
;
int32_t
numOfVnode
;
SLoserTreeInfo
*
pLoserTree
;
SLoserTreeInfo
*
pLoserTree
;
tFilePage
*
pResultBuf
;
int32_t
rowSize
;
// size of each intermediate result.
int32_t
nResultBufSize
;
tOrderDescriptor
*
pDesc
;
tFilePage
*
pTempBuffer
;
tExtMemBuffer
**
pExtMemBuffer
;
// disk-based buffer
struct
SQLFunctionCtx
*
pCtx
;
char
*
buf
;
// temp buffer
int32_t
rowSize
;
// size of each intermediate result.
tOrderDescriptor
*
pDesc
;
SColumnModel
*
resColModel
;
SColumnModel
*
finalModel
;
tExtMemBuffer
**
pExtMemBuffer
;
// disk-based buffer
bool
orderPrjOnSTable
;
// projection query on stable
}
SLocalMerger
;
}
SLocalMerger
;
typedef
struct
SRetrieveSupport
{
typedef
struct
SRetrieveSupport
{
tExtMemBuffer
**
pExtMemBuffer
;
// for build loser tree
tExtMemBuffer
**
pExtMemBuffer
;
// for build loser tree
tOrderDescriptor
*
pOrderDescriptor
;
tOrderDescriptor
*
pOrderDescriptor
;
SColumnModel
*
pFinalColModel
;
// colModel for final result
SColumnModel
*
pFFColModel
;
int32_t
subqueryIndex
;
// index of current vnode in vnode list
int32_t
subqueryIndex
;
// index of current vnode in vnode list
SSqlObj
*
pParentSql
;
SSqlObj
*
pParentSql
;
tFilePage
*
localBuffer
;
// temp buffer, there is a buffer for each vnode to
tFilePage
*
localBuffer
;
// temp buffer, there is a buffer for each vnode to
uint32_t
numOfRetry
;
// record the number of retry times
uint32_t
numOfRetry
;
// record the number of retry times
}
SRetrieveSupport
;
}
SRetrieveSupport
;
int32_t
tscLocalReducerEnvCreate
(
SSqlObj
*
pSql
,
tExtMemBuffer
***
pMemBuffer
,
tOrderDescriptor
**
pDesc
,
int32_t
tscLocalReducerEnvCreate
(
SQueryInfo
*
pQueryInfo
,
tExtMemBuffer
***
pMemBuffer
,
int32_t
numOfSub
,
tOrderDescriptor
**
pDesc
,
uint32_t
nBufferSize
,
int64_t
id
);
SColumnModel
**
pFinalModel
,
SColumnModel
**
pFFModel
,
uint32_t
nBufferSize
);
void
tscLocalReducerEnvDestroy
(
tExtMemBuffer
**
pMemBuffer
,
tOrderDescriptor
*
pDesc
,
SColumnModel
*
pFinalModel
,
SColumnModel
*
pFFModel
,
void
tscLocalReducerEnvDestroy
(
tExtMemBuffer
**
pMemBuffer
,
tOrderDescriptor
*
pDesc
,
int32_t
numOfVnodes
);
int32_t
numOfVnodes
);
int32_t
saveToBuffer
(
tExtMemBuffer
*
pMemoryBuf
,
tOrderDescriptor
*
pDesc
,
tFilePage
*
pPage
,
void
*
data
,
int32_t
saveToBuffer
(
tExtMemBuffer
*
pMemoryBuf
,
tOrderDescriptor
*
pDesc
,
tFilePage
*
pPage
,
void
*
data
,
int32_t
numOfRows
,
int32_t
orderType
);
int32_t
numOfRows
,
int32_t
orderType
);
...
@@ -81,12 +71,10 @@ int32_t tscFlushTmpBuffer(tExtMemBuffer *pMemoryBuf, tOrderDescriptor *pDesc, tF
...
@@ -81,12 +71,10 @@ int32_t tscFlushTmpBuffer(tExtMemBuffer *pMemoryBuf, tOrderDescriptor *pDesc, tF
/*
/*
* create local reducer to launch the second-stage reduce process at client site
* create local reducer to launch the second-stage reduce process at client site
*/
*/
void
tscCreateLocalMerger
(
tExtMemBuffer
**
pMemBuffer
,
int32_t
numOfBuffer
,
tOrderDescriptor
*
pDesc
,
int32_t
tscCreateLocalMerger
(
tExtMemBuffer
**
pMemBuffer
,
int32_t
numOfBuffer
,
tOrderDescriptor
*
pDesc
,
SColumnModel
*
finalModel
,
SColumnModel
*
pFFModel
,
SSqlObj
*
pSql
);
SQueryInfo
*
pQueryInfo
,
SLocalMerger
**
pMerger
,
int64_t
id
);
void
tscDestroyLocalMerger
(
SSqlObj
*
pSql
);
void
tscDestroyLocalMerger
(
SLocalMerger
*
pLocalMerger
);
//int32_t tscDoLocalMerge(SSqlObj *pSql);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
src/client/src/tscLocalMerge.c
浏览文件 @
ac9ae238
此差异已折叠。
点击以展开。
src/client/src/tscServer.c
浏览文件 @
ac9ae238
...
@@ -1615,6 +1615,11 @@ int tscProcessRetrieveLocalMergeRsp(SSqlObj *pSql) {
...
@@ -1615,6 +1615,11 @@ int tscProcessRetrieveLocalMergeRsp(SSqlObj *pSql) {
return
code
;
return
code
;
}
}
if
(
pRes
->
pLocalMerger
==
NULL
)
{
// no result from subquery, so abort here directly.
(
*
pSql
->
fp
)(
pSql
->
param
,
pSql
,
pRes
->
numOfRows
);
return
code
;
}
// global aggregation may be the upstream for parent query
// global aggregation may be the upstream for parent query
SQueryInfo
*
pQueryInfo
=
tscGetActiveQueryInfo
(
pCmd
);
SQueryInfo
*
pQueryInfo
=
tscGetActiveQueryInfo
(
pCmd
);
if
(
pQueryInfo
->
pQInfo
==
NULL
)
{
if
(
pQueryInfo
->
pQInfo
==
NULL
)
{
...
...
src/client/src/tscSubquery.c
浏览文件 @
ac9ae238
...
@@ -2422,8 +2422,6 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
...
@@ -2422,8 +2422,6 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
tExtMemBuffer
**
pMemoryBuf
=
NULL
;
tExtMemBuffer
**
pMemoryBuf
=
NULL
;
tOrderDescriptor
*
pDesc
=
NULL
;
tOrderDescriptor
*
pDesc
=
NULL
;
SColumnModel
*
pModel
=
NULL
;
SColumnModel
*
pFinalModel
=
NULL
;
pRes
->
qId
=
0x1
;
// hack the qhandle check
pRes
->
qId
=
0x1
;
// hack the qhandle check
...
@@ -2442,9 +2440,9 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
...
@@ -2442,9 +2440,9 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
assert
(
pState
->
numOfSub
>
0
);
assert
(
pState
->
numOfSub
>
0
);
int32_t
ret
=
tscLocalReducerEnvCreate
(
p
Sql
,
&
pMemoryBuf
,
&
pDesc
,
&
pModel
,
&
pFinalModel
,
nBufferSize
);
int32_t
ret
=
tscLocalReducerEnvCreate
(
p
QueryInfo
,
&
pMemoryBuf
,
pSql
->
subState
.
numOfSub
,
&
pDesc
,
nBufferSize
,
pSql
->
self
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
pRes
->
code
=
ret
;
tscAsyncResultOnError
(
pSql
);
tscAsyncResultOnError
(
pSql
);
tfree
(
pMemoryBuf
);
tfree
(
pMemoryBuf
);
return
ret
;
return
ret
;
...
@@ -2455,7 +2453,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
...
@@ -2455,7 +2453,7 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
if
(
pSql
->
pSubs
==
NULL
)
{
if
(
pSql
->
pSubs
==
NULL
)
{
tfree
(
pSql
->
pSubs
);
tfree
(
pSql
->
pSubs
);
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
tscLocalReducerEnvDestroy
(
pMemoryBuf
,
pDesc
,
pModel
,
pFinalModel
,
pState
->
numOfSub
);
tscLocalReducerEnvDestroy
(
pMemoryBuf
,
pDesc
,
pState
->
numOfSub
);
tscAsyncResultOnError
(
pSql
);
tscAsyncResultOnError
(
pSql
);
return
ret
;
return
ret
;
...
@@ -2498,8 +2496,6 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
...
@@ -2498,8 +2496,6 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
trs
->
subqueryIndex
=
i
;
trs
->
subqueryIndex
=
i
;
trs
->
pParentSql
=
pSql
;
trs
->
pParentSql
=
pSql
;
trs
->
pFinalColModel
=
pModel
;
trs
->
pFFColModel
=
pFinalModel
;
SSqlObj
*
pNew
=
tscCreateSTableSubquery
(
pSql
,
trs
,
NULL
);
SSqlObj
*
pNew
=
tscCreateSTableSubquery
(
pSql
,
trs
,
NULL
);
if
(
pNew
==
NULL
)
{
if
(
pNew
==
NULL
)
{
...
@@ -2524,13 +2520,13 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
...
@@ -2524,13 +2520,13 @@ int32_t tscHandleMasterSTableQuery(SSqlObj *pSql) {
tscError
(
"0x%"
PRIx64
" failed to prepare subquery structure and launch subqueries"
,
pSql
->
self
);
tscError
(
"0x%"
PRIx64
" failed to prepare subquery structure and launch subqueries"
,
pSql
->
self
);
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
pRes
->
code
=
TSDB_CODE_TSC_OUT_OF_MEMORY
;
tscLocalReducerEnvDestroy
(
pMemoryBuf
,
pDesc
,
p
Model
,
pFinalModel
,
p
State
->
numOfSub
);
tscLocalReducerEnvDestroy
(
pMemoryBuf
,
pDesc
,
pState
->
numOfSub
);
doCleanupSubqueries
(
pSql
,
i
);
doCleanupSubqueries
(
pSql
,
i
);
return
pRes
->
code
;
// free all allocated resource
return
pRes
->
code
;
// free all allocated resource
}
}
if
(
pRes
->
code
==
TSDB_CODE_TSC_QUERY_CANCELLED
)
{
if
(
pRes
->
code
==
TSDB_CODE_TSC_QUERY_CANCELLED
)
{
tscLocalReducerEnvDestroy
(
pMemoryBuf
,
pDesc
,
p
Model
,
pFinalModel
,
p
State
->
numOfSub
);
tscLocalReducerEnvDestroy
(
pMemoryBuf
,
pDesc
,
pState
->
numOfSub
);
doCleanupSubqueries
(
pSql
,
i
);
doCleanupSubqueries
(
pSql
,
i
);
return
pRes
->
code
;
return
pRes
->
code
;
}
}
...
@@ -2695,7 +2691,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
...
@@ -2695,7 +2691,7 @@ void tscHandleSubqueryError(SRetrieveSupport *trsupport, SSqlObj *pSql, int numO
tstrerror
(
pParentSql
->
res
.
code
));
tstrerror
(
pParentSql
->
res
.
code
));
// release allocated resource
// release allocated resource
tscLocalReducerEnvDestroy
(
trsupport
->
pExtMemBuffer
,
trsupport
->
pOrderDescriptor
,
trsupport
->
pFinalColModel
,
trsupport
->
pFFColModel
,
tscLocalReducerEnvDestroy
(
trsupport
->
pExtMemBuffer
,
trsupport
->
pOrderDescriptor
,
pState
->
numOfSub
);
pState
->
numOfSub
);
tscFreeRetrieveSup
(
pSql
);
tscFreeRetrieveSup
(
pSql
);
...
@@ -2770,19 +2766,25 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
...
@@ -2770,19 +2766,25 @@ static void tscAllDataRetrievedFromDnode(SRetrieveSupport *trsupport, SSqlObj* p
SQueryInfo
*
pPQueryInfo
=
tscGetQueryInfo
(
&
pParentSql
->
cmd
,
0
);
SQueryInfo
*
pPQueryInfo
=
tscGetQueryInfo
(
&
pParentSql
->
cmd
,
0
);
tscClearInterpInfo
(
pPQueryInfo
);
tscClearInterpInfo
(
pPQueryInfo
);
tscCreateLocalMerger
(
trsupport
->
pExtMemBuffer
,
pState
->
numOfSub
,
pDesc
,
trsupport
->
pFinalColModel
,
trsupport
->
pFFColModel
,
pParentSql
);
code
=
tscCreateLocalMerger
(
trsupport
->
pExtMemBuffer
,
pState
->
numOfSub
,
pDesc
,
pPQueryInfo
,
&
pParentSql
->
res
.
pLocalMerger
,
pParentSql
->
self
);
pParentSql
->
res
.
code
=
code
;
if
(
code
==
TSDB_CODE_SUCCESS
&&
trsupport
->
pExtMemBuffer
==
NULL
)
{
pParentSql
->
cmd
.
command
=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
;
// no result, set the result empty
}
else
{
pParentSql
->
cmd
.
command
=
TSDB_SQL_RETRIEVE_LOCALMERGE
;
}
tscCreateResPointerInfo
(
&
pParentSql
->
res
,
pPQueryInfo
);
tscDebug
(
"0x%"
PRIx64
" build loser tree completed"
,
pParentSql
->
self
);
tscDebug
(
"0x%"
PRIx64
" build loser tree completed"
,
pParentSql
->
self
);
pParentSql
->
res
.
precision
=
pSql
->
res
.
precision
;
pParentSql
->
res
.
precision
=
pSql
->
res
.
precision
;
pParentSql
->
res
.
numOfRows
=
0
;
pParentSql
->
res
.
numOfRows
=
0
;
pParentSql
->
res
.
row
=
0
;
pParentSql
->
res
.
row
=
0
;
pParentSql
->
res
.
numOfGroups
=
0
;
tscFreeRetrieveSup
(
pSql
);
// set the command flag must be after the semaphore been correctly set.
tscFreeRetrieveSup
(
pSql
);
if
(
pParentSql
->
cmd
.
command
!=
TSDB_SQL_RETRIEVE_EMPTY_RESULT
)
{
pParentSql
->
cmd
.
command
=
TSDB_SQL_RETRIEVE_LOCALMERGE
;
}
if
(
pParentSql
->
res
.
code
==
TSDB_CODE_SUCCESS
)
{
if
(
pParentSql
->
res
.
code
==
TSDB_CODE_SUCCESS
)
{
(
*
pParentSql
->
fp
)(
pParentSql
->
param
,
pParentSql
,
0
);
(
*
pParentSql
->
fp
)(
pParentSql
->
param
,
pParentSql
,
0
);
...
...
src/client/src/tscUtil.c
浏览文件 @
ac9ae238
...
@@ -828,11 +828,10 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool removeMeta) {
...
@@ -828,11 +828,10 @@ void tscResetSqlCmd(SSqlCmd* pCmd, bool removeMeta) {
}
}
void
tscFreeSqlResult
(
SSqlObj
*
pSql
)
{
void
tscFreeSqlResult
(
SSqlObj
*
pSql
)
{
tscDestroyLocalMerger
(
pSql
);
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlRes
*
pRes
=
&
pSql
->
res
;
tscDestroy
ResPointerInfo
(
pRes
);
tscDestroy
LocalMerger
(
pRes
->
pLocalMerger
);
tscDestroyResPointerInfo
(
pRes
);
memset
(
&
pSql
->
res
,
0
,
sizeof
(
SSqlRes
));
memset
(
&
pSql
->
res
,
0
,
sizeof
(
SSqlRes
));
}
}
...
...
src/vnode/src/vnodeRead.c
浏览文件 @
ac9ae238
...
@@ -354,7 +354,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
...
@@ -354,7 +354,7 @@ static int32_t vnodeProcessFetchMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
// kill current query and free corresponding resources.
// kill current query and free corresponding resources.
if
(
pRetrieve
->
free
==
1
)
{
if
(
pRetrieve
->
free
==
1
)
{
vWarn
(
"vgId:%d, QInfo:%"
PRI
u
64
"-%p, retrieve msg received to kill query and free qhandle"
,
pVnode
->
vgId
,
pRetrieve
->
qId
,
*
handle
);
vWarn
(
"vgId:%d, QInfo:%"
PRI
x
64
"-%p, retrieve msg received to kill query and free qhandle"
,
pVnode
->
vgId
,
pRetrieve
->
qId
,
*
handle
);
qKillQuery
(
*
handle
);
qKillQuery
(
*
handle
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
qReleaseQInfo
(
pVnode
->
qMgmt
,
(
void
**
)
&
handle
,
true
);
...
...
tests/examples/c/CMakeLists.txt
浏览文件 @
ac9ae238
...
@@ -5,6 +5,8 @@ IF (TD_LINUX)
...
@@ -5,6 +5,8 @@ IF (TD_LINUX)
AUX_SOURCE_DIRECTORY
(
. SRC
)
AUX_SOURCE_DIRECTORY
(
. SRC
)
ADD_EXECUTABLE
(
demo apitest.c
)
ADD_EXECUTABLE
(
demo apitest.c
)
TARGET_LINK_LIBRARIES
(
demo taos_static trpc tutil pthread
)
TARGET_LINK_LIBRARIES
(
demo taos_static trpc tutil pthread
)
ADD_EXECUTABLE
(
subscribe subscribe.c
)
TARGET_LINK_LIBRARIES
(
subscribe taos_static trpc tutil pthread
)
ADD_EXECUTABLE
(
epoll epoll.c
)
ADD_EXECUTABLE
(
epoll epoll.c
)
TARGET_LINK_LIBRARIES
(
epoll taos_static trpc tutil pthread
)
TARGET_LINK_LIBRARIES
(
epoll taos_static trpc tutil pthread
)
ENDIF
()
ENDIF
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录