Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
XKZJ_WCL
TDengine
提交
46e58d52
T
TDengine
项目概览
XKZJ_WCL
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
46e58d52
编写于
3月 21, 2020
作者:
H
hjxilinx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[TD-32] refactor codes.
上级
ca859544
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
1616 addition
and
855 deletion
+1616
-855
src/client/inc/tscSubquery.h
src/client/inc/tscSubquery.h
+6
-0
src/client/inc/tscUtil.h
src/client/inc/tscUtil.h
+1
-3
src/client/inc/tsclient.h
src/client/inc/tsclient.h
+1
-3
src/client/src/TSDBJNIConnector.c
src/client/src/TSDBJNIConnector.c
+3
-3
src/client/src/tscAsync.c
src/client/src/tscAsync.c
+0
-42
src/client/src/tscFunctionImpl.c
src/client/src/tscFunctionImpl.c
+1
-1
src/client/src/tscParseInsert.c
src/client/src/tscParseInsert.c
+2
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+24
-705
src/client/src/tscSql.c
src/client/src/tscSql.c
+4
-4
src/client/src/tscSubquery.c
src/client/src/tscSubquery.c
+1572
-0
src/client/src/tscUtil.c
src/client/src/tscUtil.c
+2
-93
未找到文件。
src/client/inc/tsc
JoinProcess
.h
→
src/client/inc/tsc
Subquery
.h
浏览文件 @
46e58d52
...
...
@@ -32,6 +32,12 @@ void tscJoinQueryCallback(void* param, TAOS_RES* tres, int code);
SJoinSubquerySupporter
*
tscCreateJoinSupporter
(
SSqlObj
*
pSql
,
SSubqueryState
*
pState
,
int32_t
index
);
void
tscDestroyJoinSupporter
(
SJoinSubquerySupporter
*
pSupporter
);
int32_t
tscHandleMasterJoinQuery
(
SSqlObj
*
pSql
);
int32_t
tscHandleMasterSTableQuery
(
SSqlObj
*
pSql
);
int32_t
tscHandleMultivnodeInsert
(
SSqlObj
*
pSql
);
#ifdef __cplusplus
}
#endif
...
...
src/client/inc/tscUtil.h
浏览文件 @
46e58d52
...
...
@@ -104,7 +104,7 @@ bool tscIsProjectionQueryOnSTable(SQueryInfo* pQueryInfo, int32_t tableIndex);
bool
tscProjectionQueryOnTable
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsTwoStage
MergeMetric
Query
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
bool
tscIsTwoStage
STable
Query
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
);
bool
tscQueryOnMetric
(
SSqlCmd
*
pCmd
);
bool
tscQueryMetricTags
(
SQueryInfo
*
pQueryInfo
);
bool
tscIsSelectivityWithTagQuery
(
SSqlCmd
*
pCmd
);
...
...
@@ -252,8 +252,6 @@ void tscTryQueryNextVnode(SSqlObj *pSql, __async_cb_func_t fp);
void
tscAsyncQuerySingleRowForNextVnode
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
);
void
tscTryQueryNextClause
(
SSqlObj
*
pSql
,
void
(
*
queryFp
)());
int32_t
launchMultivnodeInsert
(
SSqlObj
*
pSql
);
#ifdef __cplusplus
}
#endif
...
...
src/client/inc/tsclient.h
浏览文件 @
46e58d52
...
...
@@ -259,7 +259,7 @@ typedef struct {
union
{
bool
existsCheck
;
// check if the table exists or not
bool
inStream
;
// denote if current sql is executed in stream or not
bool
createOnDeman
d
;
// if the table is missing, on-the-fly create it. during getmeterMeta
bool
autoCreate
d
;
// if the table is missing, on-the-fly create it. during getmeterMeta
int8_t
dataSourceType
;
// load data from file or not
};
...
...
@@ -404,8 +404,6 @@ extern int (*tscBuildMsg[TSDB_SQL_MAX])(SSqlObj *pSql, SSqlInfo *pInfo);
void
tscProcessMsgFromServer
(
SRpcMsg
*
rpcMsg
);
int
tscProcessSql
(
SSqlObj
*
pSql
);
void
tscAsyncInsertMultiVnodesProxy
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
);
int
tscRenewMeterMeta
(
SSqlObj
*
pSql
,
char
*
tableId
);
void
tscQueueAsyncRes
(
SSqlObj
*
pSql
);
...
...
src/client/src/TSDBJNIConnector.c
浏览文件 @
46e58d52
...
...
@@ -13,13 +13,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "os.h"
#include "com_taosdata_jdbc_TSDBJNIConnector.h"
#include "os.h"
#include "taos.h"
#include "tlog.h"
#include "tscJoinProcess.h"
#include "tsclient.h"
#include "tscSubquery.h"
#include "tscUtil.h"
#include "tsclient.h"
#include "ttime.h"
int
__init
=
0
;
...
...
src/client/src/tscAsync.c
浏览文件 @
46e58d52
...
...
@@ -397,48 +397,6 @@ void tscQueueAsyncFreeResult(SSqlObj *pSql) {
taosScheduleTask
(
tscQhandle
,
&
schedMsg
);
}
void
tscAsyncInsertMultiVnodesProxy
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
)
{
SSqlObj
*
pSql
=
(
SSqlObj
*
)
param
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
assert
(
pCmd
->
dataSourceType
!=
0
&&
pSql
->
signature
==
pSql
);
int32_t
index
=
0
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
index
);
STableMetaInfo
*
pTableMetaInfo
=
tscGetMetaInfo
(
pQueryInfo
,
0
);
assert
(
pQueryInfo
->
numOfTables
==
1
||
pQueryInfo
->
numOfTables
==
2
);
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
if
(
pDataBlocks
==
NULL
||
pTableMetaInfo
->
vnodeIndex
>=
pDataBlocks
->
nSize
)
{
// restore user defined fp
pSql
->
fp
=
pSql
->
fetchFp
;
tscTrace
(
"%p Async insertion completed, destroy data block list"
,
pSql
);
// release data block data
pCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pCmd
->
pDataBlocks
);
// all data has been sent to vnode, call user function
(
*
pSql
->
fp
)(
pSql
->
param
,
tres
,
numOfRows
);
}
else
{
do
{
code
=
tscCopyDataBlockToPayload
(
pSql
,
pDataBlocks
->
pData
[
pTableMetaInfo
->
vnodeIndex
++
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscTrace
(
"%p prepare submit data block failed in async insertion, vnodeIdx:%d, total:%d, code:%d"
,
pSql
,
pTableMetaInfo
->
vnodeIndex
-
1
,
pDataBlocks
->
nSize
,
code
);
}
}
while
(
code
!=
TSDB_CODE_SUCCESS
&&
pTableMetaInfo
->
vnodeIndex
<
pDataBlocks
->
nSize
);
// build submit msg may fail
if
(
code
==
TSDB_CODE_SUCCESS
)
{
tscTrace
(
"%p async insertion, vnodeIdx:%d, total:%d"
,
pSql
,
pTableMetaInfo
->
vnodeIndex
-
1
,
pDataBlocks
->
nSize
);
tscProcessSql
(
pSql
);
}
}
}
int
tscSendMsgToServer
(
SSqlObj
*
pSql
);
void
tscTableMetaCallBack
(
void
*
param
,
TAOS_RES
*
res
,
int
code
)
{
...
...
src/client/src/tscFunctionImpl.c
浏览文件 @
46e58d52
...
...
@@ -24,7 +24,7 @@
#include "taosdef.h"
#include "taosmsg.h"
#include "tlog.h"
#include "tsc
JoinProcess
.h"
#include "tsc
Subquery
.h"
#include "tscompression.h"
#include "tsqlfunction.h"
#include "ttime.h"
...
...
src/client/src/tscParseInsert.c
浏览文件 @
46e58d52
...
...
@@ -28,6 +28,7 @@
#include "taosdef.h"
#include "tlog.h"
#include "tscSubquery.h"
#include "tstoken.h"
#include "ttime.h"
...
...
@@ -1324,7 +1325,7 @@ int tsParseSql(SSqlObj *pSql, bool multiVnodeInsertion) {
pSql
->
fetchFp
=
pSql
->
fp
;
// replace user defined callback function with multi-insert proxy function
pSql
->
fp
=
(
void
(
*
)())
launch
MultivnodeInsert
;
pSql
->
fp
=
(
void
(
*
)())
tscHandle
MultivnodeInsert
;
}
ret
=
tsParseInsertSql
(
pSql
);
...
...
src/client/src/tscServer.c
浏览文件 @
46e58d52
此差异已折叠。
点击以展开。
src/client/src/tscSql.c
浏览文件 @
46e58d52
...
...
@@ -15,21 +15,21 @@
#include "hash.h"
#include "os.h"
#include "qast.h"
#include "tcache.h"
#include "tlog.h"
#include "tnote.h"
#include "trpc.h"
#include "tscJoinProcess.h"
#include "tscProfile.h"
#include "tscSecondaryMerge.h"
#include "tscSubquery.h"
#include "tscUtil.h"
#include "tsclient.h"
#include "tscompression.h"
#include "tsocket.h"
#include "ttimer.h"
#include "tutil.h"
#include "ttokendef.h"
#include "
qast
.h"
#include "
tutil
.h"
static
bool
validImpl
(
const
char
*
str
,
size_t
maxsize
)
{
if
(
str
==
NULL
)
{
...
...
@@ -994,7 +994,7 @@ void taos_stop_query(TAOS_RES *res) {
pSql
->
res
.
code
=
TSDB_CODE_QUERY_CANCELLED
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfoDetail
(
pCmd
,
pCmd
->
clauseIndex
);
if
(
tscIsTwoStage
MergeMetric
Query
(
pQueryInfo
,
0
))
{
if
(
tscIsTwoStage
STable
Query
(
pQueryInfo
,
0
))
{
tscKillMetricQuery
(
pSql
);
return
;
}
...
...
src/client/src/tsc
JoinProcess
.c
→
src/client/src/tsc
Subquery
.c
浏览文件 @
46e58d52
此差异已折叠。
点击以展开。
src/client/src/tscUtil.c
浏览文件 @
46e58d52
...
...
@@ -21,9 +21,9 @@
#include "tcache.h"
#include "tkey.h"
#include "tmd5.h"
#include "tscJoinProcess.h"
#include "tscProfile.h"
#include "tscSecondaryMerge.h"
#include "tscSubquery.h"
#include "tschemautil.h"
#include "tsclient.h"
#include "ttimer.h"
...
...
@@ -209,7 +209,7 @@ STableSidExtInfo* tscGetMeterSidInfo(SVnodeSidList* pSidList, int32_t idx) {
return
(
STableSidExtInfo
*
)(
pSidList
->
pSidExtInfoList
[
idx
]
+
(
char
*
)
pSidList
);
}
bool
tscIsTwoStage
MergeMetric
Query
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
)
{
bool
tscIsTwoStage
STable
Query
(
SQueryInfo
*
pQueryInfo
,
int32_t
tableIndex
)
{
if
(
pQueryInfo
==
NULL
)
{
return
false
;
}
...
...
@@ -2321,94 +2321,3 @@ void tscTryQueryNextClause(SSqlObj* pSql, void (*queryFp)()) {
tscProcessSql
(
pSql
);
}
}
typedef
struct
SinsertSupporter
{
SSubqueryState
*
pState
;
SSqlObj
*
pSql
;
}
SinsertSupporter
;
void
multiVnodeInsertMerge
(
void
*
param
,
TAOS_RES
*
tres
,
int
numOfRows
)
{
SinsertSupporter
*
pSupporter
=
(
SinsertSupporter
*
)
param
;
SSqlObj
*
pParentObj
=
pSupporter
->
pSql
;
SSqlCmd
*
pParentCmd
=
&
pParentObj
->
cmd
;
SSubqueryState
*
pState
=
pSupporter
->
pState
;
int32_t
total
=
pState
->
numOfTotal
;
// increase the total inserted rows
if
(
numOfRows
>
0
)
{
pParentObj
->
res
.
numOfRows
+=
numOfRows
;
}
int32_t
completed
=
atomic_add_fetch_32
(
&
pState
->
numOfCompleted
,
1
);
if
(
completed
<
total
)
{
return
;
}
tscTrace
(
"%p Async insertion completed, total inserted:%d"
,
pParentObj
,
pParentObj
->
res
.
numOfRows
);
// release data block data
pParentCmd
->
pDataBlocks
=
tscDestroyBlockArrayList
(
pParentCmd
->
pDataBlocks
);
// restore user defined fp
pParentObj
->
fp
=
pParentObj
->
fetchFp
;
// all data has been sent to vnode, call user function
(
*
pParentObj
->
fp
)(
pParentObj
->
param
,
tres
,
numOfRows
);
}
int32_t
launchMultivnodeInsert
(
SSqlObj
*
pSql
)
{
SSqlRes
*
pRes
=
&
pSql
->
res
;
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pRes
->
qhandle
=
1
;
// hack the qhandle check
SDataBlockList
*
pDataBlocks
=
pCmd
->
pDataBlocks
;
pSql
->
pSubs
=
calloc
(
pDataBlocks
->
nSize
,
POINTER_BYTES
);
pSql
->
numOfSubs
=
pDataBlocks
->
nSize
;
assert
(
pDataBlocks
->
nSize
>
0
);
tscTrace
(
"%p submit data to %d vnode(s)"
,
pSql
,
pDataBlocks
->
nSize
);
SSubqueryState
*
pState
=
calloc
(
1
,
sizeof
(
SSubqueryState
));
pState
->
numOfTotal
=
pSql
->
numOfSubs
;
pRes
->
code
=
TSDB_CODE_SUCCESS
;
int32_t
i
=
0
;
for
(;
i
<
pSql
->
numOfSubs
;
++
i
)
{
SinsertSupporter
*
pSupporter
=
calloc
(
1
,
sizeof
(
SinsertSupporter
));
pSupporter
->
pSql
=
pSql
;
pSupporter
->
pState
=
pState
;
SSqlObj
*
pNew
=
createSubqueryObj
(
pSql
,
0
,
multiVnodeInsertMerge
,
pSupporter
,
NULL
);
if
(
pNew
==
NULL
)
{
tscError
(
"%p failed to malloc buffer for subObj, orderOfSub:%d, reason:%s"
,
pSql
,
i
,
strerror
(
errno
));
break
;
}
pSql
->
pSubs
[
i
]
=
pNew
;
tscTrace
(
"%p sub:%p create subObj success. orderOfSub:%d"
,
pSql
,
pNew
,
i
);
}
if
(
i
<
pSql
->
numOfSubs
)
{
tscError
(
"%p failed to prepare subObj structure and launch sub-insertion"
,
pSql
);
pRes
->
code
=
TSDB_CODE_CLI_OUT_OF_MEMORY
;
return
pRes
->
code
;
// free all allocated resource
}
for
(
int32_t
j
=
0
;
j
<
pSql
->
numOfSubs
;
++
j
)
{
SSqlObj
*
pSub
=
pSql
->
pSubs
[
j
];
pSub
->
cmd
.
command
=
TSDB_SQL_INSERT
;
int32_t
code
=
tscCopyDataBlockToPayload
(
pSub
,
pDataBlocks
->
pData
[
j
]);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
tscTrace
(
"%p prepare submit data block failed in async insertion, vnodeIdx:%d, total:%d, code:%d"
,
pSql
,
j
,
pDataBlocks
->
nSize
,
code
);
}
tscTrace
(
"%p sub:%p launch sub insert, orderOfSub:%d"
,
pSql
,
pSub
,
j
);
tscProcessSql
(
pSub
);
}
return
TSDB_CODE_SUCCESS
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录