Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
c79be2da
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
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看板
提交
c79be2da
编写于
6月 21, 2022
作者:
wmmhello
浏览文件
操作
浏览文件
下载
差异文件
feat: merge from 3.0
上级
8494bf17
e9b0d939
变更
153
展开全部
隐藏空白更改
内联
并排
Showing
153 changed file
with
6338 addition
and
3554 deletion
+6338
-3554
examples/c/stream_demo.c
examples/c/stream_demo.c
+5
-10
include/common/systable.h
include/common/systable.h
+1
-0
include/common/tmsg.h
include/common/tmsg.h
+8
-7
include/common/tmsgcb.h
include/common/tmsgcb.h
+0
-1
include/common/tmsgdef.h
include/common/tmsgdef.h
+1
-0
include/dnode/mnode/mnode.h
include/dnode/mnode/mnode.h
+2
-1
include/dnode/snode/snode.h
include/dnode/snode/snode.h
+3
-3
include/libs/catalog/catalog.h
include/libs/catalog/catalog.h
+4
-0
include/libs/function/function.h
include/libs/function/function.h
+1
-1
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+13
-8
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+3
-1
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+6
-0
include/libs/planner/planner.h
include/libs/planner/planner.h
+0
-1
include/libs/qworker/qworker.h
include/libs/qworker/qworker.h
+2
-0
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+7
-9
include/libs/sync/sync.h
include/libs/sync/sync.h
+24
-16
include/libs/sync/syncTools.h
include/libs/sync/syncTools.h
+34
-0
include/util/taoserror.h
include/util/taoserror.h
+4
-0
source/client/src/clientMain.c
source/client/src/clientMain.c
+1
-0
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+46
-43
source/common/src/tglobal.c
source/common/src/tglobal.c
+2
-2
source/common/src/tmsg.c
source/common/src/tmsg.c
+50
-26
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
+1
-0
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
+5
-1
source/dnode/mgmt/mgmt_snode/src/smHandle.c
source/dnode/mgmt/mgmt_snode/src/smHandle.c
+6
-3
source/dnode/mgmt/mgmt_snode/src/smWorker.c
source/dnode/mgmt/mgmt_snode/src/smWorker.c
+8
-2
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
+0
-2
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+0
-1
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+3
-21
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+2
-2
source/dnode/mnode/impl/inc/mndScheduler.h
source/dnode/mnode/impl/inc/mndScheduler.h
+1
-1
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+27
-23
source/dnode/mnode/impl/src/mndQuery.c
source/dnode/mnode/impl/src/mndQuery.c
+7
-2
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+53
-27
source/dnode/mnode/impl/src/mndSnode.c
source/dnode/mnode/impl/src/mndSnode.c
+1
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+31
-27
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+8
-12
source/dnode/mnode/impl/src/mndSync.c
source/dnode/mnode/impl/src/mndSync.c
+13
-11
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+6
-6
source/dnode/mnode/impl/test/sdb/sdbTest.cpp
source/dnode/mnode/impl/test/sdb/sdbTest.cpp
+1
-1
source/dnode/mnode/sdb/inc/sdb.h
source/dnode/mnode/sdb/inc/sdb.h
+2
-2
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+5
-1
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+5
-1
source/dnode/snode/inc/sndInt.h
source/dnode/snode/inc/sndInt.h
+0
-1
source/dnode/snode/src/snode.c
source/dnode/snode/src/snode.c
+143
-31
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+1
-1
source/dnode/vnode/src/inc/sma.h
source/dnode/vnode/src/inc/sma.h
+6
-5
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+20
-20
source/dnode/vnode/src/sma/sma.c
source/dnode/vnode/src/sma/sma.c
+5
-0
source/dnode/vnode/src/sma/smaEnv.c
source/dnode/vnode/src/sma/smaEnv.c
+31
-1
source/dnode/vnode/src/sma/smaRollup.c
source/dnode/vnode/src/sma/smaRollup.c
+162
-64
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+32
-30
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+2
-2
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+11
-9
source/dnode/vnode/src/vnd/vnodeSync.c
source/dnode/vnode/src/vnd/vnodeSync.c
+21
-19
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+4
-0
source/libs/command/src/command.c
source/libs/command/src/command.c
+4
-0
source/libs/command/src/explain.c
source/libs/command/src/explain.c
+43
-12
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+3
-1
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+12
-7
source/libs/executor/src/dataDispatcher.c
source/libs/executor/src/dataDispatcher.c
+9
-3
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+44
-8
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+7
-1
source/libs/executor/src/executorMain.c
source/libs/executor/src/executorMain.c
+40
-43
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+148
-108
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+38
-14
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+157
-116
source/libs/executor/src/timewindowoperator.c
source/libs/executor/src/timewindowoperator.c
+198
-133
source/libs/function/inc/builtinsimpl.h
source/libs/function/inc/builtinsimpl.h
+2
-0
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+11
-110
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+70
-119
source/libs/function/src/tudf.c
source/libs/function/src/tudf.c
+5
-0
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+3
-0
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+21
-0
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+8
-2
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+1
-0
source/libs/parser/inc/parUtil.h
source/libs/parser/inc/parUtil.h
+4
-0
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+3
-1
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+17
-6
source/libs/parser/src/parAstParser.c
source/libs/parser/src/parAstParser.c
+32
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+178
-32
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+17
-0
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+1330
-1304
source/libs/parser/test/mockCatalog.cpp
source/libs/parser/test/mockCatalog.cpp
+22
-0
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+25
-0
source/libs/parser/test/mockCatalogService.h
source/libs/parser/test/mockCatalogService.h
+2
-0
source/libs/parser/test/parInitialDTest.cpp
source/libs/parser/test/parInitialDTest.cpp
+29
-1
source/libs/parser/test/parSelectTest.cpp
source/libs/parser/test/parSelectTest.cpp
+0
-2
source/libs/parser/test/parShowToUse.cpp
source/libs/parser/test/parShowToUse.cpp
+17
-1
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+9
-4
source/libs/planner/src/planOptimizer.c
source/libs/planner/src/planOptimizer.c
+109
-12
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+14
-1
source/libs/planner/src/planUtil.c
source/libs/planner/src/planUtil.c
+1
-0
source/libs/planner/test/planOptimizeTest.cpp
source/libs/planner/test/planOptimizeTest.cpp
+19
-2
source/libs/planner/test/planOtherTest.cpp
source/libs/planner/test/planOtherTest.cpp
+2
-0
source/libs/qworker/inc/qwMsg.h
source/libs/qworker/inc/qwMsg.h
+1
-0
source/libs/qworker/src/qwMsg.c
source/libs/qworker/src/qwMsg.c
+20
-0
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+8
-1
source/libs/stream/src/stream.c
source/libs/stream/src/stream.c
+18
-12
source/libs/stream/src/streamDispatch.c
source/libs/stream/src/streamDispatch.c
+3
-1
source/libs/stream/src/streamExec.c
source/libs/stream/src/streamExec.c
+6
-5
source/libs/stream/src/streamTask.c
source/libs/stream/src/streamTask.c
+2
-2
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+9
-2
source/libs/sync/inc/syncRaftCfg.h
source/libs/sync/inc/syncRaftCfg.h
+5
-5
source/libs/sync/inc/syncSnapshot.h
source/libs/sync/inc/syncSnapshot.h
+11
-10
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+2
-2
source/libs/sync/src/syncAppendEntriesReply.c
source/libs/sync/src/syncAppendEntriesReply.c
+3
-3
source/libs/sync/src/syncCommit.c
source/libs/sync/src/syncCommit.c
+1
-1
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+338
-210
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+129
-0
source/libs/sync/src/syncRaftCfg.c
source/libs/sync/src/syncRaftCfg.c
+4
-4
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+1
-1
source/libs/sync/src/syncSnapshot.c
source/libs/sync/src/syncSnapshot.c
+35
-48
source/libs/sync/src/syncUtil.c
source/libs/sync/src/syncUtil.c
+9
-3
source/libs/sync/test/CMakeLists.txt
source/libs/sync/test/CMakeLists.txt
+14
-0
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
+5
-5
source/libs/sync/test/syncConfigChangeTest.cpp
source/libs/sync/test/syncConfigChangeTest.cpp
+5
-5
source/libs/sync/test/syncRaftCfgTest.cpp
source/libs/sync/test/syncRaftCfgTest.cpp
+1
-1
source/libs/sync/test/syncRaftLogTest2.cpp
source/libs/sync/test/syncRaftLogTest2.cpp
+1
-1
source/libs/sync/test/syncRaftLogTest3.cpp
source/libs/sync/test/syncRaftLogTest3.cpp
+6
-6
source/libs/sync/test/syncReconfigFinishTest.cpp
source/libs/sync/test/syncReconfigFinishTest.cpp
+135
-0
source/libs/sync/test/syncReplicateTest.cpp
source/libs/sync/test/syncReplicateTest.cpp
+3
-3
source/libs/sync/test/syncSnapshotSenderTest.cpp
source/libs/sync/test/syncSnapshotSenderTest.cpp
+1
-1
source/libs/sync/test/syncSnapshotTest.cpp
source/libs/sync/test/syncSnapshotTest.cpp
+3
-3
source/libs/sync/test/syncTestTool.cpp
source/libs/sync/test/syncTestTool.cpp
+3
-3
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+467
-59
source/libs/tdb/src/db/tdbPage.c
source/libs/tdb/src/db/tdbPage.c
+9
-7
source/libs/tdb/src/inc/tdbInt.h
source/libs/tdb/src/inc/tdbInt.h
+22
-8
source/libs/tdb/test/CMakeLists.txt
source/libs/tdb/test/CMakeLists.txt
+6
-1
source/libs/tdb/test/tdbExOVFLTest.cpp
source/libs/tdb/test/tdbExOVFLTest.cpp
+469
-0
source/util/src/terror.c
source/util/src/terror.c
+3
-0
tests/pytest/util/common.py
tests/pytest/util/common.py
+127
-2
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+6
-3
tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
...ipt/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
+0
-21
tests/script/tsim/mnode/basic5.sim
tests/script/tsim/mnode/basic5.sim
+1
-1
tests/script/tsim/sma/rsmaCreateInsertQuery.sim
tests/script/tsim/sma/rsmaCreateInsertQuery.sim
+3
-1
tests/script/tsim/stream/distributeInterval0.sim
tests/script/tsim/stream/distributeInterval0.sim
+1
-1
tests/script/tsim/stream/distributesession0.sim
tests/script/tsim/stream/distributesession0.sim
+58
-0
tests/script/tsim/stream/schedSnode.sim
tests/script/tsim/stream/schedSnode.sim
+173
-0
tests/script/tsim/stream/windowClose.sim
tests/script/tsim/stream/windowClose.sim
+32
-0
tests/system-test/1-insert/create_table_comment.py
tests/system-test/1-insert/create_table_comment.py
+0
-113
tests/system-test/1-insert/table_comment.py
tests/system-test/1-insert/table_comment.py
+134
-0
tests/system-test/2-query/Today.py
tests/system-test/2-query/Today.py
+144
-375
tests/system-test/6-cluster/5dnode3mnodeDrop.py
tests/system-test/6-cluster/5dnode3mnodeDrop.py
+23
-23
tests/system-test/6-cluster/5dnode3mnodeStop.py
tests/system-test/6-cluster/5dnode3mnodeStop.py
+19
-19
tests/system-test/6-cluster/5dnode3mnodeStopInsert.py
tests/system-test/6-cluster/5dnode3mnodeStopInsert.py
+27
-27
tests/system-test/7-tmq/subscribeDb3.py
tests/system-test/7-tmq/subscribeDb3.py
+33
-5
tests/system-test/7-tmq/subscribeDb4.py
tests/system-test/7-tmq/subscribeDb4.py
+116
-0
tests/system-test/7-tmq/subscribeStb4.py
tests/system-test/7-tmq/subscribeStb4.py
+10
-12
tests/system-test/7-tmq/tmqCommon.py
tests/system-test/7-tmq/tmqCommon.py
+118
-0
tests/system-test/fulltest.sh
tests/system-test/fulltest.sh
+1
-1
tests/test/c/sdbDump.c
tests/test/c/sdbDump.c
+4
-2
tests/test/c/tmqSim.c
tests/test/c/tmqSim.c
+56
-33
未找到文件。
examples/c/stream_demo.c
浏览文件 @
c79be2da
...
@@ -25,19 +25,21 @@ int32_t init_env() {
...
@@ -25,19 +25,21 @@ int32_t init_env() {
return
-
1
;
return
-
1
;
}
}
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create database if not exists abc1 vgroups
2
"
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create database if not exists abc1 vgroups
1
"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in create db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"error in create db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
return
-
1
;
}
}
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
#if 0
pRes = taos_query(pConn, "create database if not exists abc2 vgroups 20");
pRes = taos_query(pConn, "create database if not exists abc2 vgroups 20");
if (taos_errno(pRes) != 0) {
if (taos_errno(pRes) != 0) {
printf("error in create db, reason:%s\n", taos_errstr(pRes));
printf("error in create db, reason:%s\n", taos_errstr(pRes));
return -1;
return -1;
}
}
taos_free_result(pRes);
taos_free_result(pRes);
#endif
pRes
=
taos_query
(
pConn
,
"use abc1"
);
pRes
=
taos_query
(
pConn
,
"use abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
...
@@ -89,8 +91,8 @@ int32_t create_stream() {
...
@@ -89,8 +91,8 @@ int32_t create_stream() {
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
/*const char* sql = "select sum(k) from tu1 interval(10m)";*/
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
/*pRes = tmq_create_stream(pConn, "stream1", "out1", sql);*/
pRes
=
taos_query
(
pConn
,
pRes
=
taos_query
(
pConn
,
"create stream stream1 trigger
at_once into abc2.outstb as select _wstartts, sum(k) from st1
"
"create stream stream1 trigger
window_close into outstb as select _wstartts, sum(k) from st1
"
"
partition by tbname interval(10m
) "
);
"
interval(10s
) "
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create stream stream1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"failed to create stream stream1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
return
-
1
;
...
@@ -107,11 +109,4 @@ int main(int argc, char* argv[]) {
...
@@ -107,11 +109,4 @@ int main(int argc, char* argv[]) {
code
=
init_env
();
code
=
init_env
();
}
}
create_stream
();
create_stream
();
#if 0
tmq_t* tmq = build_consumer();
tmq_list_t* topic_list = build_topic_list();
/*perf_loop(tmq, topic_list);*/
/*basic_consume_loop(tmq, topic_list);*/
sync_consume_loop(tmq, topic_list);
#endif
}
}
include/common/systable.h
浏览文件 @
c79be2da
...
@@ -41,6 +41,7 @@ extern "C" {
...
@@ -41,6 +41,7 @@ extern "C" {
#define TSDB_INS_TABLE_VGROUPS "vgroups"
#define TSDB_INS_TABLE_VGROUPS "vgroups"
#define TSDB_INS_TABLE_VNODES "vnodes"
#define TSDB_INS_TABLE_VNODES "vnodes"
#define TSDB_INS_TABLE_CONFIGS "configs"
#define TSDB_INS_TABLE_CONFIGS "configs"
#define TSDB_INS_TABLE_DNODE_VARIABLES "dnode_variables"
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
#define TSDB_PERFS_TABLE_SMAS "smas"
#define TSDB_PERFS_TABLE_SMAS "smas"
...
...
include/common/tmsg.h
浏览文件 @
c79be2da
...
@@ -1317,7 +1317,7 @@ int32_t tSerializeSSetStandbyReq(void* buf, int32_t bufLen, SSetStandbyReq* pReq
...
@@ -1317,7 +1317,7 @@ int32_t tSerializeSSetStandbyReq(void* buf, int32_t bufLen, SSetStandbyReq* pReq
int32_t
tDeserializeSSetStandbyReq
(
void
*
buf
,
int32_t
bufLen
,
SSetStandbyReq
*
pReq
);
int32_t
tDeserializeSSetStandbyReq
(
void
*
buf
,
int32_t
bufLen
,
SSetStandbyReq
*
pReq
);
typedef
struct
{
typedef
struct
{
char
queryStrId
[
TSDB_QUERY_ID_LEN
];
char
queryStrId
[
TSDB_QUERY_ID_LEN
];
}
SKillQueryReq
;
}
SKillQueryReq
;
int32_t
tSerializeSKillQueryReq
(
void
*
buf
,
int32_t
bufLen
,
SKillQueryReq
*
pReq
);
int32_t
tSerializeSKillQueryReq
(
void
*
buf
,
int32_t
bufLen
,
SKillQueryReq
*
pReq
);
...
@@ -1776,12 +1776,10 @@ typedef struct {
...
@@ -1776,12 +1776,10 @@ typedef struct {
}
SDDropTopicReq
;
}
SDDropTopicReq
;
typedef
struct
{
typedef
struct
{
float
xFilesFactor
;
int64_t
maxdelay
[
2
];
int32_t
delay
;
int64_t
watermark
[
2
];
int32_t
qmsg1Len
;
int32_t
qmsgLen
[
2
];
int32_t
qmsg2Len
;
char
*
qmsg
[
2
];
// pAst:qmsg:SRetention => trigger aggr task1/2
char
*
qmsg1
;
// pAst1:qmsg1:SRetention1 => trigger aggr task1
char
*
qmsg2
;
// pAst2:qmsg2:SRetention2 => trigger aggr task2
}
SRSmaParam
;
}
SRSmaParam
;
int32_t
tEncodeSRSmaParam
(
SEncoder
*
pCoder
,
const
SRSmaParam
*
pRSmaParam
);
int32_t
tEncodeSRSmaParam
(
SEncoder
*
pCoder
,
const
SRSmaParam
*
pRSmaParam
);
...
@@ -2284,6 +2282,9 @@ typedef struct {
...
@@ -2284,6 +2282,9 @@ typedef struct {
int8_t
igNotExists
;
int8_t
igNotExists
;
}
SMDropStreamReq
;
}
SMDropStreamReq
;
int32_t
tSerializeSMDropStreamReq
(
void
*
buf
,
int32_t
bufLen
,
const
SMDropStreamReq
*
pReq
);
int32_t
tDeserializeSMDropStreamReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropStreamReq
*
pReq
);
typedef
struct
{
typedef
struct
{
int8_t
reserved
;
int8_t
reserved
;
}
SMDropStreamRsp
;
}
SMDropStreamRsp
;
...
...
include/common/tmsgcb.h
浏览文件 @
c79be2da
...
@@ -34,7 +34,6 @@ typedef enum {
...
@@ -34,7 +34,6 @@ typedef enum {
WRITE_QUEUE
,
WRITE_QUEUE
,
APPLY_QUEUE
,
APPLY_QUEUE
,
SYNC_QUEUE
,
SYNC_QUEUE
,
MERGE_QUEUE
,
QUEUE_MAX
,
QUEUE_MAX
,
}
EQueueType
;
}
EQueueType
;
...
...
include/common/tmsgdef.h
浏览文件 @
c79be2da
...
@@ -236,6 +236,7 @@ enum {
...
@@ -236,6 +236,7 @@ enum {
TD_DEF_MSG_TYPE
(
TDMT_SYNC_COMMON_RESPONSE
,
"sync-common-response"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_COMMON_RESPONSE
,
"sync-common-response"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_APPLY_MSG
,
"sync-apply-msg"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_APPLY_MSG
,
"sync-apply-msg"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_CONFIG_CHANGE
,
"sync-config-change"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_CONFIG_CHANGE
,
"sync-config-change"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_CONFIG_CHANGE_FINISH
,
"sync-config-change-finish"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_SNAPSHOT_SEND
,
"sync-snapshot-send"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_SNAPSHOT_SEND
,
"sync-snapshot-send"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_SNAPSHOT_RSP
,
"sync-snapshot-rsp"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_SNAPSHOT_RSP
,
"sync-snapshot-rsp"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_LEADER_TRANSFER
,
"sync-leader-transfer"
,
NULL
,
NULL
)
TD_DEF_MSG_TYPE
(
TDMT_SYNC_LEADER_TRANSFER
,
"sync-leader-transfer"
,
NULL
,
NULL
)
...
...
include/dnode/mnode/mnode.h
浏览文件 @
c79be2da
...
@@ -95,7 +95,8 @@ int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
...
@@ -95,7 +95,8 @@ int32_t mndGetLoad(SMnode *pMnode, SMnodeLoad *pLoad);
*/
*/
int32_t
mndProcessRpcMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndProcessRpcMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndPreProcessMsg
(
SRpcMsg
*
pMsg
);
int32_t
mndPreProcessQueryMsg
(
SRpcMsg
*
pMsg
);
void
mndPostProcessQueryMsg
(
SRpcMsg
*
pMsg
);
/**
/**
* @brief Generate machine code
* @brief Generate machine code
...
...
include/dnode/snode/snode.h
浏览文件 @
c79be2da
...
@@ -16,8 +16,8 @@
...
@@ -16,8 +16,8 @@
#ifndef _TD_SNODE_H_
#ifndef _TD_SNODE_H_
#define _TD_SNODE_H_
#define _TD_SNODE_H_
#include "tmsgcb.h"
#include "tmsg.h"
#include "tmsg.h"
#include "tmsgcb.h"
#include "trpc.h"
#include "trpc.h"
#ifdef __cplusplus
#ifdef __cplusplus
...
@@ -68,8 +68,8 @@ int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad);
...
@@ -68,8 +68,8 @@ int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad);
* @param pMsg The request message
* @param pMsg The request message
* @param pRsp The response message
* @param pRsp The response message
*/
*/
void
sndProcessUMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
);
int32_t
sndProcessUMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
);
void
sndProcessSMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
);
int32_t
sndProcessSMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/libs/catalog/catalog.h
浏览文件 @
c79be2da
...
@@ -69,6 +69,7 @@ typedef struct SCatalogReq {
...
@@ -69,6 +69,7 @@ typedef struct SCatalogReq {
SArray
*
pUser
;
// element is SUserAuthInfo
SArray
*
pUser
;
// element is SUserAuthInfo
SArray
*
pTableIndex
;
// element is SNAME
SArray
*
pTableIndex
;
// element is SNAME
bool
qNodeRequired
;
// valid qnode
bool
qNodeRequired
;
// valid qnode
bool
dNodeRequired
;
// valid dnode
bool
forceUpdate
;
bool
forceUpdate
;
}
SCatalogReq
;
}
SCatalogReq
;
...
@@ -88,6 +89,7 @@ typedef struct SMetaData {
...
@@ -88,6 +89,7 @@ typedef struct SMetaData {
SArray
*
pIndex
;
// pRes = SIndexInfo*
SArray
*
pIndex
;
// pRes = SIndexInfo*
SArray
*
pUser
;
// pRes = bool*
SArray
*
pUser
;
// pRes = bool*
SArray
*
pQnodeList
;
// pRes = SArray<SQueryNodeLoad>*
SArray
*
pQnodeList
;
// pRes = SArray<SQueryNodeLoad>*
SArray
*
pDnodeList
;
// pRes = SArray<SEpSet>*
}
SMetaData
;
}
SMetaData
;
typedef
struct
SCatalogCfg
{
typedef
struct
SCatalogCfg
{
...
@@ -268,6 +270,8 @@ int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t
...
@@ -268,6 +270,8 @@ int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t
int32_t
catalogGetQnodeList
(
SCatalog
*
pCatalog
,
SRequestConnInfo
*
pConn
,
SArray
*
pQnodeList
);
int32_t
catalogGetQnodeList
(
SCatalog
*
pCatalog
,
SRequestConnInfo
*
pConn
,
SArray
*
pQnodeList
);
int32_t
catalogGetDnodeList
(
SCatalog
*
pCatalog
,
SRequestConnInfo
*
pConn
,
SArray
**
pDnodeList
);
int32_t
catalogGetExpiredSTables
(
SCatalog
*
pCatalog
,
SSTableVersion
**
stables
,
uint32_t
*
num
);
int32_t
catalogGetExpiredSTables
(
SCatalog
*
pCatalog
,
SSTableVersion
**
stables
,
uint32_t
*
num
);
int32_t
catalogGetExpiredDBs
(
SCatalog
*
pCatalog
,
SDbVgVersion
**
dbs
,
uint32_t
*
num
);
int32_t
catalogGetExpiredDBs
(
SCatalog
*
pCatalog
,
SDbVgVersion
**
dbs
,
uint32_t
*
num
);
...
...
include/libs/function/function.h
浏览文件 @
c79be2da
...
@@ -67,7 +67,7 @@ typedef struct SResultRowEntryInfo {
...
@@ -67,7 +67,7 @@ typedef struct SResultRowEntryInfo {
bool
initialized
:
1
;
// output buffer has been initialized
bool
initialized
:
1
;
// output buffer has been initialized
bool
complete
:
1
;
// query has completed
bool
complete
:
1
;
// query has completed
uint8_t
isNullRes
:
6
;
// the result is null
uint8_t
isNullRes
:
6
;
// the result is null
uint
8_t
numOfRes
;
// num of output result in current buffer
uint
16_t
numOfRes
;
// num of output result in current buffer
}
SResultRowEntryInfo
;
}
SResultRowEntryInfo
;
// determine the real data need to calculated the result
// determine the real data need to calculated the result
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
c79be2da
...
@@ -119,14 +119,14 @@ typedef struct SCreateTableStmt {
...
@@ -119,14 +119,14 @@ typedef struct SCreateTableStmt {
}
SCreateTableStmt
;
}
SCreateTableStmt
;
typedef
struct
SCreateSubTableClause
{
typedef
struct
SCreateSubTableClause
{
ENodeType
type
;
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
useDbName
[
TSDB_DB_NAME_LEN
];
char
useDbName
[
TSDB_DB_NAME_LEN
];
char
useTableName
[
TSDB_TABLE_NAME_LEN
];
char
useTableName
[
TSDB_TABLE_NAME_LEN
];
bool
ignoreExists
;
bool
ignoreExists
;
SNodeList
*
pSpecificTags
;
SNodeList
*
pSpecificTags
;
SNodeList
*
pValsOfTags
;
SNodeList
*
pValsOfTags
;
STableOptions
*
pOptions
;
STableOptions
*
pOptions
;
}
SCreateSubTableClause
;
}
SCreateSubTableClause
;
...
@@ -230,6 +230,11 @@ typedef struct SShowTableDistributedStmt {
...
@@ -230,6 +230,11 @@ typedef struct SShowTableDistributedStmt {
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
}
SShowTableDistributedStmt
;
}
SShowTableDistributedStmt
;
typedef
struct
SShowDnodeVariablesStmt
{
ENodeType
type
;
SNode
*
pDnodeId
;
}
SShowDnodeVariablesStmt
;
typedef
enum
EIndexType
{
INDEX_TYPE_SMA
=
1
,
INDEX_TYPE_FULLTEXT
}
EIndexType
;
typedef
enum
EIndexType
{
INDEX_TYPE_SMA
=
1
,
INDEX_TYPE_FULLTEXT
}
EIndexType
;
typedef
struct
SIndexOptions
{
typedef
struct
SIndexOptions
{
...
...
include/libs/nodes/nodes.h
浏览文件 @
c79be2da
...
@@ -180,7 +180,9 @@ typedef enum ENodeType {
...
@@ -180,7 +180,9 @@ typedef enum ENodeType {
QUERY_NODE_SHOW_VNODES_STMT
,
QUERY_NODE_SHOW_VNODES_STMT
,
QUERY_NODE_SHOW_APPS_STMT
,
QUERY_NODE_SHOW_APPS_STMT
,
QUERY_NODE_SHOW_SCORES_STMT
,
QUERY_NODE_SHOW_SCORES_STMT
,
QUERY_NODE_SHOW_VARIABLE_STMT
,
QUERY_NODE_SHOW_VARIABLES_STMT
,
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT
,
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
,
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
,
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
,
QUERY_NODE_SHOW_CREATE_TABLE_STMT
,
QUERY_NODE_SHOW_CREATE_TABLE_STMT
,
QUERY_NODE_SHOW_CREATE_STABLE_STMT
,
QUERY_NODE_SHOW_CREATE_STABLE_STMT
,
...
...
include/libs/nodes/plannodes.h
浏览文件 @
c79be2da
...
@@ -106,6 +106,9 @@ typedef struct SInterpFuncLogicNode {
...
@@ -106,6 +106,9 @@ typedef struct SInterpFuncLogicNode {
SNodeList
*
pFuncs
;
SNodeList
*
pFuncs
;
STimeWindow
timeRange
;
STimeWindow
timeRange
;
int64_t
interval
;
int64_t
interval
;
EFillMode
fillMode
;
SNode
*
pFillValues
;
// SNodeListNode
SNode
*
pTimeSeries
;
// SColumnNode
}
SInterpFuncLogicNode
;
}
SInterpFuncLogicNode
;
typedef
enum
EModifyTableType
{
MODIFY_TABLE_TYPE_INSERT
=
1
,
MODIFY_TABLE_TYPE_DELETE
}
EModifyTableType
;
typedef
enum
EModifyTableType
{
MODIFY_TABLE_TYPE_INSERT
=
1
,
MODIFY_TABLE_TYPE_DELETE
}
EModifyTableType
;
...
@@ -309,6 +312,9 @@ typedef struct SInterpFuncPhysiNode {
...
@@ -309,6 +312,9 @@ typedef struct SInterpFuncPhysiNode {
SNodeList
*
pFuncs
;
SNodeList
*
pFuncs
;
STimeWindow
timeRange
;
STimeWindow
timeRange
;
int64_t
interval
;
int64_t
interval
;
EFillMode
fillMode
;
SNode
*
pFillValues
;
// SNodeListNode
SNode
*
pTimeSeries
;
// SColumnNode
}
SInterpFuncPhysiNode
;
}
SInterpFuncPhysiNode
;
typedef
struct
SJoinPhysiNode
{
typedef
struct
SJoinPhysiNode
{
...
...
include/libs/planner/planner.h
浏览文件 @
c79be2da
...
@@ -36,7 +36,6 @@ typedef struct SPlanContext {
...
@@ -36,7 +36,6 @@ typedef struct SPlanContext {
int64_t
watermark
;
int64_t
watermark
;
char
*
pMsg
;
char
*
pMsg
;
int32_t
msgLen
;
int32_t
msgLen
;
// double filesFactor;
}
SPlanContext
;
}
SPlanContext
;
// Create the physical plan for the query, according to the AST.
// Create the physical plan for the query, according to the AST.
...
...
include/libs/qworker/qworker.h
浏览文件 @
c79be2da
...
@@ -64,6 +64,8 @@ typedef struct {
...
@@ -64,6 +64,8 @@ typedef struct {
int32_t
qWorkerInit
(
int8_t
nodeType
,
int32_t
nodeId
,
SQWorkerCfg
*
cfg
,
void
**
qWorkerMgmt
,
const
SMsgCb
*
pMsgCb
);
int32_t
qWorkerInit
(
int8_t
nodeType
,
int32_t
nodeId
,
SQWorkerCfg
*
cfg
,
void
**
qWorkerMgmt
,
const
SMsgCb
*
pMsgCb
);
int32_t
qWorkerAbortPreprocessQueryMsg
(
void
*
qWorkerMgmt
,
SRpcMsg
*
pMsg
);
int32_t
qWorkerPreprocessQueryMsg
(
void
*
qWorkerMgmt
,
SRpcMsg
*
pMsg
);
int32_t
qWorkerPreprocessQueryMsg
(
void
*
qWorkerMgmt
,
SRpcMsg
*
pMsg
);
int32_t
qWorkerProcessQueryMsg
(
void
*
node
,
void
*
qWorkerMgmt
,
SRpcMsg
*
pMsg
,
int64_t
ts
);
int32_t
qWorkerProcessQueryMsg
(
void
*
node
,
void
*
qWorkerMgmt
,
SRpcMsg
*
pMsg
,
int64_t
ts
);
...
...
include/libs/stream/tstream.h
浏览文件 @
c79be2da
...
@@ -152,7 +152,6 @@ void* streamDataBlockDecode(const void* buf, SStreamDataBlock* pInput);
...
@@ -152,7 +152,6 @@ void* streamDataBlockDecode(const void* buf, SStreamDataBlock* pInput);
typedef
struct
{
typedef
struct
{
char
*
qmsg
;
char
*
qmsg
;
// followings are not applicable to encoder and decoder
// followings are not applicable to encoder and decoder
void
*
inputHandle
;
void
*
executor
;
void
*
executor
;
}
STaskExec
;
}
STaskExec
;
...
@@ -240,12 +239,13 @@ struct SStreamTask {
...
@@ -240,12 +239,13 @@ struct SStreamTask {
int8_t
inputType
;
int8_t
inputType
;
int8_t
status
;
int8_t
status
;
int8_t
sourceType
;
int8_t
execType
;
int8_t
execType
;
int8_t
sinkType
;
int8_t
sinkType
;
int8_t
dispatchType
;
int8_t
dispatchType
;
int16_t
dispatchMsgType
;
int16_t
dispatchMsgType
;
int8_t
dataScan
;
// node info
// node info
int32_t
childId
;
int32_t
childId
;
int32_t
nodeId
;
int32_t
nodeId
;
...
@@ -399,15 +399,13 @@ typedef struct {
...
@@ -399,15 +399,13 @@ typedef struct {
int32_t
tDecodeStreamDispatchReq
(
SDecoder
*
pDecoder
,
SStreamDispatchReq
*
pReq
);
int32_t
tDecodeStreamDispatchReq
(
SDecoder
*
pDecoder
,
SStreamDispatchReq
*
pReq
);
int32_t
streamLaunchByWrite
(
SStreamTask
*
pTask
,
int32_t
vgId
,
SMsgCb
*
pMsgCb
);
int32_t
streamLaunchByWrite
(
SStreamTask
*
pTask
,
int32_t
vgId
);
int32_t
streamSetupTrigger
(
SStreamTask
*
pTask
);
int32_t
streamSetupTrigger
(
SStreamTask
*
pTask
);
int32_t
streamTaskRun
(
SStreamTask
*
pTask
);
int32_t
streamProcessRunReq
(
SStreamTask
*
pTask
);
int32_t
streamProcessDispatchReq
(
SStreamTask
*
pTask
,
SStreamDispatchReq
*
pReq
,
SRpcMsg
*
pMsg
);
int32_t
streamTaskProcessRunReq
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
);
int32_t
streamProcessDispatchRsp
(
SStreamTask
*
pTask
,
SStreamDispatchRsp
*
pRsp
);
int32_t
streamProcessDispatchReq
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
,
SStreamDispatchReq
*
pReq
,
SRpcMsg
*
pMsg
);
int32_t
streamProcessRecoverReq
(
SStreamTask
*
pTask
,
SStreamTaskRecoverReq
*
pReq
,
SRpcMsg
*
pMsg
);
int32_t
streamProcessDispatchRsp
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
,
SStreamDispatchRsp
*
pRsp
);
int32_t
streamProcessRecoverReq
(
SStreamTask
*
pTask
,
SMsgCb
*
pMsgCb
,
SStreamTaskRecoverReq
*
pReq
,
SRpcMsg
*
pMsg
);
int32_t
streamProcessRecoverRsp
(
SStreamTask
*
pTask
,
SStreamTaskRecoverRsp
*
pRsp
);
int32_t
streamProcessRecoverRsp
(
SStreamTask
*
pTask
,
SStreamTaskRecoverRsp
*
pRsp
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
include/libs/sync/sync.h
浏览文件 @
c79be2da
...
@@ -24,6 +24,8 @@ extern "C" {
...
@@ -24,6 +24,8 @@ extern "C" {
#include "tdef.h"
#include "tdef.h"
#include "tmsgcb.h"
#include "tmsgcb.h"
extern
bool
gRaftDetailLog
;
#define SYNC_INDEX_BEGIN 0
#define SYNC_INDEX_BEGIN 0
#define SYNC_INDEX_INVALID -1
#define SYNC_INDEX_INVALID -1
...
@@ -61,28 +63,35 @@ typedef struct SSyncCfg {
...
@@ -61,28 +63,35 @@ typedef struct SSyncCfg {
}
SSyncCfg
;
}
SSyncCfg
;
typedef
struct
SFsmCbMeta
{
typedef
struct
SFsmCbMeta
{
int32_t
code
;
SyncIndex
index
;
SyncIndex
index
;
SyncTerm
term
;
uint64_t
seqNum
;
SyncIndex
lastConfigIndex
;
SyncIndex
lastConfigIndex
;
bool
isWeak
;
int32_t
code
;
ESyncState
state
;
ESyncState
state
;
uint64_t
seqNum
;
SyncTerm
term
;
SyncTerm
currentTerm
;
SyncTerm
currentTerm
;
bool
isWeak
;
uint64_t
flag
;
uint64_t
flag
;
}
SFsmCbMeta
;
}
SFsmCbMeta
;
typedef
struct
SReConfigCbMeta
{
typedef
struct
SReConfigCbMeta
{
int32_t
code
;
int32_t
code
;
SyncIndex
index
;
SyncIndex
index
;
SyncTerm
term
;
SyncTerm
term
;
SyncIndex
lastConfigIndex
;
uint64_t
seqNum
;
SyncTerm
currentTerm
;
SyncIndex
lastConfigIndex
;
ESyncState
state
;
SyncTerm
currentTerm
;
bool
isWeak
;
uint64_t
flag
;
// config info
SSyncCfg
oldCfg
;
SSyncCfg
oldCfg
;
SSyncCfg
newCfg
;
SSyncCfg
newCfg
;
bool
isDrop
;
SyncIndex
newCfgIndex
;
uint64_t
flag
;
SyncTerm
newCfgTerm
;
uint64_t
seqNum
;
uint64_t
newCfgSeqNum
;
}
SReConfigCbMeta
;
}
SReConfigCbMeta
;
typedef
struct
SSnapshot
{
typedef
struct
SSnapshot
{
...
@@ -107,7 +116,8 @@ typedef struct SSyncFSM {
...
@@ -107,7 +116,8 @@ typedef struct SSyncFSM {
void
(
*
FpReConfigCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
cbMeta
);
void
(
*
FpReConfigCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SReConfigCbMeta
cbMeta
);
void
(
*
FpLeaderTransferCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
void
(
*
FpLeaderTransferCb
)(
struct
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
);
int32_t
(
*
FpGetSnapshot
)(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
);
int32_t
(
*
FpGetSnapshot
)(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
,
void
*
pReaderParam
,
void
**
ppReader
);
int32_t
(
*
FpGetSnapshotInfo
)(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
);
int32_t
(
*
FpSnapshotStartRead
)(
struct
SSyncFSM
*
pFsm
,
void
**
ppReader
);
int32_t
(
*
FpSnapshotStartRead
)(
struct
SSyncFSM
*
pFsm
,
void
**
ppReader
);
int32_t
(
*
FpSnapshotStopRead
)(
struct
SSyncFSM
*
pFsm
,
void
*
pReader
);
int32_t
(
*
FpSnapshotStopRead
)(
struct
SSyncFSM
*
pFsm
,
void
*
pReader
);
...
@@ -187,14 +197,12 @@ ESyncState syncGetMyRole(int64_t rid);
...
@@ -187,14 +197,12 @@ ESyncState syncGetMyRole(int64_t rid);
bool
syncIsReady
(
int64_t
rid
);
bool
syncIsReady
(
int64_t
rid
);
const
char
*
syncGetMyRoleStr
(
int64_t
rid
);
const
char
*
syncGetMyRoleStr
(
int64_t
rid
);
SyncTerm
syncGetMyTerm
(
int64_t
rid
);
SyncTerm
syncGetMyTerm
(
int64_t
rid
);
SyncGroupId
syncGetVgId
(
int64_t
rid
);
void
syncGetEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
);
void
syncGetEpSet
(
int64_t
rid
,
SEpSet
*
pEpSet
);
int32_t
syncGetVgId
(
int64_t
rid
);
int32_t
syncPropose
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
);
int32_t
syncPropose
(
int64_t
rid
,
const
SRpcMsg
*
pMsg
,
bool
isWeak
);
bool
syncEnvIsStart
();
bool
syncEnvIsStart
();
const
char
*
syncStr
(
ESyncState
state
);
const
char
*
syncStr
(
ESyncState
state
);
bool
syncIsRestoreFinish
(
int64_t
rid
);
bool
syncIsRestoreFinish
(
int64_t
rid
);
int32_t
syncGetSnapshotMeta
(
int64_t
rid
,
struct
SSnapshotMeta
*
sMeta
);
int32_t
syncGetSnapshotMetaByIndex
(
int64_t
rid
,
SyncIndex
snapshotIndex
,
struct
SSnapshotMeta
*
sMeta
);
int32_t
syncReconfig
(
int64_t
rid
,
const
SSyncCfg
*
pNewCfg
);
int32_t
syncReconfig
(
int64_t
rid
,
const
SSyncCfg
*
pNewCfg
);
...
...
include/libs/sync/syncTools.h
浏览文件 @
c79be2da
...
@@ -489,6 +489,40 @@ void syncLeaderTransferPrint2(char* s, const SyncLeaderTransfer* pMsg);
...
@@ -489,6 +489,40 @@ void syncLeaderTransferPrint2(char* s, const SyncLeaderTransfer* pMsg);
void
syncLeaderTransferLog
(
const
SyncLeaderTransfer
*
pMsg
);
void
syncLeaderTransferLog
(
const
SyncLeaderTransfer
*
pMsg
);
void
syncLeaderTransferLog2
(
char
*
s
,
const
SyncLeaderTransfer
*
pMsg
);
void
syncLeaderTransferLog2
(
char
*
s
,
const
SyncLeaderTransfer
*
pMsg
);
// ---------------------------------------------
typedef
struct
SyncReconfigFinish
{
uint32_t
bytes
;
int32_t
vgId
;
uint32_t
msgType
;
SSyncCfg
oldCfg
;
SSyncCfg
newCfg
;
SyncIndex
newCfgIndex
;
SyncTerm
newCfgTerm
;
uint64_t
newCfgSeqNum
;
}
SyncReconfigFinish
;
SyncReconfigFinish
*
syncReconfigFinishBuild
(
int32_t
vgId
);
void
syncReconfigFinishDestroy
(
SyncReconfigFinish
*
pMsg
);
void
syncReconfigFinishSerialize
(
const
SyncReconfigFinish
*
pMsg
,
char
*
buf
,
uint32_t
bufLen
);
void
syncReconfigFinishDeserialize
(
const
char
*
buf
,
uint32_t
len
,
SyncReconfigFinish
*
pMsg
);
char
*
syncReconfigFinishSerialize2
(
const
SyncReconfigFinish
*
pMsg
,
uint32_t
*
len
);
SyncReconfigFinish
*
syncReconfigFinishDeserialize2
(
const
char
*
buf
,
uint32_t
len
);
void
syncReconfigFinish2RpcMsg
(
const
SyncReconfigFinish
*
pMsg
,
SRpcMsg
*
pRpcMsg
);
void
syncReconfigFinishFromRpcMsg
(
const
SRpcMsg
*
pRpcMsg
,
SyncReconfigFinish
*
pMsg
);
SyncReconfigFinish
*
syncReconfigFinishFromRpcMsg2
(
const
SRpcMsg
*
pRpcMsg
);
cJSON
*
syncReconfigFinish2Json
(
const
SyncReconfigFinish
*
pMsg
);
char
*
syncReconfigFinish2Str
(
const
SyncReconfigFinish
*
pMsg
);
// for debug ----------------------
void
syncReconfigFinishPrint
(
const
SyncReconfigFinish
*
pMsg
);
void
syncReconfigFinishPrint2
(
char
*
s
,
const
SyncReconfigFinish
*
pMsg
);
void
syncReconfigFinishLog
(
const
SyncReconfigFinish
*
pMsg
);
void
syncReconfigFinishLog2
(
char
*
s
,
const
SyncReconfigFinish
*
pMsg
);
// on message ----------------------
// on message ----------------------
int32_t
syncNodeOnPingCb
(
SSyncNode
*
ths
,
SyncPing
*
pMsg
);
int32_t
syncNodeOnPingCb
(
SSyncNode
*
ths
,
SyncPing
*
pMsg
);
int32_t
syncNodeOnPingReplyCb
(
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
);
int32_t
syncNodeOnPingReplyCb
(
SSyncNode
*
ths
,
SyncPingReply
*
pMsg
);
...
...
include/util/taoserror.h
浏览文件 @
c79be2da
...
@@ -416,6 +416,9 @@ int32_t* taosGetErrno();
...
@@ -416,6 +416,9 @@ int32_t* taosGetErrno();
#define TSDB_CODE_SYN_NOT_LEADER TAOS_DEF_ERROR_CODE(0, 0x090C)
#define TSDB_CODE_SYN_NOT_LEADER TAOS_DEF_ERROR_CODE(0, 0x090C)
#define TSDB_CODE_SYN_ONE_REPLICA TAOS_DEF_ERROR_CODE(0, 0x090D)
#define TSDB_CODE_SYN_ONE_REPLICA TAOS_DEF_ERROR_CODE(0, 0x090D)
#define TSDB_CODE_SYN_NOT_IN_NEW_CONFIG TAOS_DEF_ERROR_CODE(0, 0x090E)
#define TSDB_CODE_SYN_NOT_IN_NEW_CONFIG TAOS_DEF_ERROR_CODE(0, 0x090E)
#define TSDB_CODE_SYN_NEW_CONFIG_ERROR TAOS_DEF_ERROR_CODE(0, 0x090F)
#define TSDB_CODE_SYN_RECONFIG_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0910)
#define TSDB_CODE_SYN_PROPOSE_NOT_READY TAOS_DEF_ERROR_CODE(0, 0x0911)
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
#define TSDB_CODE_SYN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x09FF)
// tq
// tq
...
@@ -564,6 +567,7 @@ int32_t* taosGetErrno();
...
@@ -564,6 +567,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_STREAM_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x265A)
#define TSDB_CODE_PAR_STREAM_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x265A)
#define TSDB_CODE_PAR_GROUP_BY_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x265B)
#define TSDB_CODE_PAR_GROUP_BY_NOT_ALLOWED_FUNC TAOS_DEF_ERROR_CODE(0, 0x265B)
#define TSDB_CODE_PAR_INVALID_TABLE_OPTION TAOS_DEF_ERROR_CODE(0, 0x265C)
#define TSDB_CODE_PAR_INVALID_TABLE_OPTION TAOS_DEF_ERROR_CODE(0, 0x265C)
#define TSDB_CODE_PAR_INVALID_INTERP_CLAUSE TAOS_DEF_ERROR_CODE(0, 0x265D)
//planner
//planner
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
#define TSDB_CODE_PLAN_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x2700)
...
...
source/client/src/clientMain.c
浏览文件 @
c79be2da
...
@@ -887,6 +887,7 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
...
@@ -887,6 +887,7 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
SRequestObj
*
pRequest
=
res
;
SRequestObj
*
pRequest
=
res
;
pRequest
->
body
.
fetchFp
=
fp
;
pRequest
->
body
.
fetchFp
=
fp
;
pRequest
->
body
.
param
=
param
;
SReqResultInfo
*
pResultInfo
=
&
pRequest
->
body
.
resInfo
;
SReqResultInfo
*
pResultInfo
=
&
pRequest
->
body
.
resInfo
;
if
(
taos_num_fields
(
pRequest
)
==
0
)
{
if
(
taos_num_fields
(
pRequest
)
==
0
)
{
...
...
source/client/test/clientTests.cpp
浏览文件 @
c79be2da
...
@@ -43,6 +43,26 @@ void showDB(TAOS* pConn) {
...
@@ -43,6 +43,26 @@ void showDB(TAOS* pConn) {
}
}
}
}
void
printResult
(
TAOS_RES
*
pRes
)
{
TAOS_ROW
pRow
=
NULL
;
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
int32_t
n
=
0
;
char
str
[
512
]
=
{
0
};
while
((
pRow
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
int32_t
*
length
=
taos_fetch_lengths
(
pRes
);
for
(
int32_t
i
=
0
;
i
<
numOfFields
;
++
i
)
{
printf
(
"(%d):%d "
,
i
,
length
[
i
]);
}
printf
(
"
\n
"
);
int32_t
code
=
taos_print_row
(
str
,
pRow
,
pFields
,
numOfFields
);
printf
(
"%s
\n
"
,
str
);
memset
(
str
,
0
,
sizeof
(
str
));
}
}
void
fetchCallback
(
void
*
param
,
void
*
res
,
int32_t
numOfRow
)
{
void
fetchCallback
(
void
*
param
,
void
*
res
,
int32_t
numOfRow
)
{
#if 0
#if 0
printf("numOfRow = %d \n", numOfRow);
printf("numOfRow = %d \n", numOfRow);
...
@@ -729,48 +749,31 @@ TEST(testCase, projection_query_tables) {
...
@@ -729,48 +749,31 @@ TEST(testCase, projection_query_tables) {
// taos_close(pConn);
// taos_close(pConn);
//}
//}
//TEST(testCase, agg_query_tables) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// ASSERT_NE(pConn, nullptr);
//
// TAOS_RES* pRes = taos_query(pConn, "use abc1");
// if (taos_errno(pRes) != 0) {
// printf("failed to use db, reason:%s\n", taos_errstr(pRes));
// taos_free_result(pRes);
// ASSERT_TRUE(false);
// }
// taos_free_result(pRes);
//
// pRes = taos_query(pConn, "show stables");
// if (taos_errno(pRes) != 0) {
// printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
// taos_free_result(pRes);
// ASSERT_TRUE(false);
// }
//
// TAOS_ROW pRow = NULL;
// TAOS_FIELD* pFields = taos_fetch_fields(pRes);
// int32_t numOfFields = taos_num_fields(pRes);
//
// int32_t n = 0;
// char str[512] = {0};
// while ((pRow = taos_fetch_row(pRes)) != NULL) {
// int32_t* length = taos_fetch_lengths(pRes);
// for(int32_t i = 0; i < numOfFields; ++i) {
// printf("(%d):%d " , i, length[i]);
// }
// printf("\n");
//
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
// printf("%s\n", str);
// memset(str, 0, sizeof(str));
// }
//
// taos_free_result(pRes);
// taos_close(pConn);
//}
#endif
TEST(testCase, agg_query_tables) {
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
ASSERT_NE(pConn, nullptr);
TAOS_RES* pRes = taos_query(pConn, "use abc1");
if (taos_errno(pRes) != 0) {
printf("failed to use db, reason:%s\n", taos_errstr(pRes));
taos_free_result(pRes);
ASSERT_TRUE(false);
}
taos_free_result(pRes);
pRes = taos_query(pConn, "show table distributed st1");
if (taos_errno(pRes) != 0) {
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
taos_free_result(pRes);
ASSERT_TRUE(false);
}
printResult(pRes);
taos_free_result(pRes);
taos_close(pConn);
}
#endif
/*
/*
--- copy the following script in the shell to setup the environment ---
--- copy the following script in the shell to setup the environment ---
...
@@ -786,7 +789,7 @@ TEST(testCase, async_api_test) {
...
@@ -786,7 +789,7 @@ TEST(testCase, async_api_test) {
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
ASSERT_NE
(
pConn
,
nullptr
);
taos_query
(
pConn
,
"use
table_alltype_hyperloglog
"
);
taos_query
(
pConn
,
"use
abc1
"
);
#if 0
#if 0
TAOS_RES* pRes = taos_query(pConn, "insert into tu(ts) values('2022-02-27 12:12:61')");
TAOS_RES* pRes = taos_query(pConn, "insert into tu(ts) values('2022-02-27 12:12:61')");
if (taos_errno(pRes) != 0) {
if (taos_errno(pRes) != 0) {
...
@@ -812,7 +815,7 @@ TEST(testCase, async_api_test) {
...
@@ -812,7 +815,7 @@ TEST(testCase, async_api_test) {
}
}
#endif
#endif
taos_query_a
(
pConn
,
"select
HYPERLOGLOG(q_ts) from stable_1_2 where ts between 1630000001000 and 1630100001000 interval(19d) Fill(NONE);
"
,
queryCallback
,
pConn
);
taos_query_a
(
pConn
,
"select
count(*) from tu
"
,
queryCallback
,
pConn
);
getchar
();
getchar
();
taos_close
(
pConn
);
taos_close
(
pConn
);
}
}
...
...
source/common/src/tglobal.c
浏览文件 @
c79be2da
...
@@ -161,7 +161,7 @@ int32_t tsDiskCfgNum = 0;
...
@@ -161,7 +161,7 @@ int32_t tsDiskCfgNum = 0;
SDiskCfg
tsDiskCfg
[
TFS_MAX_DISKS
]
=
{
0
};
SDiskCfg
tsDiskCfg
[
TFS_MAX_DISKS
]
=
{
0
};
// stream scheduler
// stream scheduler
bool
tsS
treamSchedV
=
true
;
bool
tsS
chedStreamToSnode
=
true
;
/*
/*
* minimum scale for whole system, millisecond by default
* minimum scale for whole system, millisecond by default
...
@@ -185,7 +185,7 @@ char tsCompressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPR
...
@@ -185,7 +185,7 @@ char tsCompressor[32] = "ZSTD_COMPRESSOR"; // ZSTD_COMPRESSOR or GZIP_COMPR
bool
tsStartUdfd
=
true
;
bool
tsStartUdfd
=
true
;
// internal
// internal
int32_t
tsTransPullupInterval
=
6
;
int32_t
tsTransPullupInterval
=
2
;
int32_t
tsMqRebalanceInterval
=
2
;
int32_t
tsMqRebalanceInterval
=
2
;
void
taosAddDataDir
(
int32_t
index
,
char
*
v1
,
int32_t
level
,
int32_t
primary
)
{
void
taosAddDataDir
(
int32_t
index
,
char
*
v1
,
int32_t
level
,
int32_t
primary
)
{
...
...
source/common/src/tmsg.c
浏览文件 @
c79be2da
...
@@ -4267,45 +4267,69 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
...
@@ -4267,45 +4267,69 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea
return
0
;
return
0
;
}
}
int32_t
tSerializeSMDropStreamReq
(
void
*
buf
,
int32_t
bufLen
,
const
SMDropStreamReq
*
pReq
)
{
SEncoder
encoder
=
{
0
};
tEncoderInit
(
&
encoder
,
buf
,
bufLen
);
if
(
tStartEncode
(
&
encoder
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
&
encoder
,
pReq
->
igNotExists
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
tEncoderClear
(
&
encoder
);
return
tlen
;
}
int32_t
tDeserializeSMDropStreamReq
(
void
*
buf
,
int32_t
bufLen
,
SMDropStreamReq
*
pReq
)
{
SDecoder
decoder
=
{
0
};
tDecoderInit
(
&
decoder
,
buf
,
bufLen
);
if
(
tStartDecode
(
&
decoder
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
&
decoder
,
pReq
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
&
decoder
,
&
pReq
->
igNotExists
)
<
0
)
return
-
1
;
tEndDecode
(
&
decoder
);
tDecoderClear
(
&
decoder
);
return
0
;
}
void
tFreeSCMCreateStreamReq
(
SCMCreateStreamReq
*
pReq
)
{
void
tFreeSCMCreateStreamReq
(
SCMCreateStreamReq
*
pReq
)
{
taosMemoryFreeClear
(
pReq
->
sql
);
taosMemoryFreeClear
(
pReq
->
sql
);
taosMemoryFreeClear
(
pReq
->
ast
);
taosMemoryFreeClear
(
pReq
->
ast
);
}
}
int32_t
tEncodeSRSmaParam
(
SEncoder
*
pCoder
,
const
SRSmaParam
*
pRSmaParam
)
{
int32_t
tEncodeSRSmaParam
(
SEncoder
*
pCoder
,
const
SRSmaParam
*
pRSmaParam
)
{
if
(
tEncodeFloat
(
pCoder
,
pRSmaParam
->
xFilesFactor
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
2
;
++
i
)
{
if
(
tEncodeI32v
(
pCoder
,
pRSmaParam
->
delay
)
<
0
)
return
-
1
;
if
(
tEncodeI64v
(
pCoder
,
pRSmaParam
->
maxdelay
[
i
])
<
0
)
return
-
1
;
if
(
tEncodeI32v
(
pCoder
,
pRSmaParam
->
qmsg1Len
)
<
0
)
return
-
1
;
if
(
tEncodeI64v
(
pCoder
,
pRSmaParam
->
watermark
[
i
])
<
0
)
return
-
1
;
if
(
tEncodeI32v
(
pCoder
,
pRSmaParam
->
qmsg2Len
)
<
0
)
return
-
1
;
if
(
tEncodeI32v
(
pCoder
,
pRSmaParam
->
qmsgLen
[
i
])
<
0
)
return
-
1
;
if
(
pRSmaParam
->
qmsg1Len
>
0
)
{
if
(
pRSmaParam
->
qmsgLen
[
i
]
>
0
)
{
if
(
tEncodeBinary
(
pCoder
,
pRSmaParam
->
qmsg1
,
(
uint64_t
)
pRSmaParam
->
qmsg1Len
)
<
0
)
// qmsg1Len contains len of '\0'
if
(
tEncodeBinary
(
pCoder
,
pRSmaParam
->
qmsg
[
i
],
(
uint64_t
)
pRSmaParam
->
qmsgLen
[
i
])
<
return
-
1
;
0
)
// qmsgLen contains len of '\0'
}
return
-
1
;
if
(
pRSmaParam
->
qmsg2Len
>
0
)
{
}
if
(
tEncodeBinary
(
pCoder
,
pRSmaParam
->
qmsg2
,
(
uint64_t
)
pRSmaParam
->
qmsg2Len
)
<
0
)
// qmsg2Len contains len of '\0'
return
-
1
;
}
}
return
0
;
return
0
;
}
}
int32_t
tDecodeSRSmaParam
(
SDecoder
*
pCoder
,
SRSmaParam
*
pRSmaParam
)
{
int32_t
tDecodeSRSmaParam
(
SDecoder
*
pCoder
,
SRSmaParam
*
pRSmaParam
)
{
if
(
tDecodeFloat
(
pCoder
,
&
pRSmaParam
->
xFilesFactor
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
2
;
++
i
)
{
if
(
tDecodeI32v
(
pCoder
,
&
pRSmaParam
->
delay
)
<
0
)
return
-
1
;
if
(
tDecodeI64v
(
pCoder
,
&
pRSmaParam
->
maxdelay
[
i
])
<
0
)
return
-
1
;
if
(
tDecodeI32v
(
pCoder
,
&
pRSmaParam
->
qmsg1Len
)
<
0
)
return
-
1
;
if
(
tDecodeI64v
(
pCoder
,
&
pRSmaParam
->
watermark
[
i
])
<
0
)
return
-
1
;
if
(
tDecodeI32v
(
pCoder
,
&
pRSmaParam
->
qmsg2Len
)
<
0
)
return
-
1
;
if
(
tDecodeI32v
(
pCoder
,
&
pRSmaParam
->
qmsgLen
[
i
])
<
0
)
return
-
1
;
if
(
pRSmaParam
->
qmsg1Len
>
0
)
{
if
(
pRSmaParam
->
qmsgLen
[
i
]
>
0
)
{
uint64_t
len
;
uint64_t
len
;
if
(
tDecodeBinaryAlloc
(
pCoder
,
(
void
**
)
&
pRSmaParam
->
qmsg1
,
&
len
)
<
0
)
return
-
1
;
// qmsg1Len contains len of '\0'
if
(
tDecodeBinaryAlloc
(
pCoder
,
(
void
**
)
&
pRSmaParam
->
qmsg
[
i
],
&
len
)
<
0
)
}
else
{
return
-
1
;
// qmsgLen contains len of '\0'
pRSmaParam
->
qmsg1
=
NULL
;
}
else
{
}
pRSmaParam
->
qmsg
[
i
]
=
NULL
;
if
(
pRSmaParam
->
qmsg2Len
>
0
)
{
}
uint64_t
len
;
if
(
tDecodeBinaryAlloc
(
pCoder
,
(
void
**
)
&
pRSmaParam
->
qmsg2
,
&
len
)
<
0
)
return
-
1
;
// qmsg2Len contains len of '\0'
}
else
{
pRSmaParam
->
qmsg2
=
NULL
;
}
}
return
0
;
return
0
;
}
}
...
...
source/dnode/mgmt/mgmt_mnode/src/mmHandle.c
浏览文件 @
c79be2da
...
@@ -183,6 +183,7 @@ SArray *mmGetMsgHandles() {
...
@@ -183,6 +183,7 @@ SArray *mmGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_SMA
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_SMA
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_SMA
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_SMA
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_STREAM
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_STREAM
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_DROP_STREAM
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_INDEX
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_INDEX
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_TABLE_INDEX
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_GET_TABLE_INDEX
,
mmPutMsgToReadQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_TOPIC
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MND_CREATE_TOPIC
,
mmPutMsgToWriteQueue
,
0
)
==
NULL
)
goto
_OVER
;
...
...
source/dnode/mgmt/mgmt_mnode/src/mmWorker.c
浏览文件 @
c79be2da
...
@@ -68,6 +68,10 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
...
@@ -68,6 +68,10 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
mmSendRsp
(
pMsg
,
code
);
mmSendRsp
(
pMsg
,
code
);
}
}
if
(
code
==
TSDB_CODE_RPC_REDIRECT
)
{
mndPostProcessQueryMsg
(
pMsg
);
}
dTrace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
dTrace
(
"msg:%p, is freed, code:0x%x"
,
pMsg
,
code
);
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
taosFreeQitem
(
pMsg
);
taosFreeQitem
(
pMsg
);
...
@@ -116,7 +120,7 @@ int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
...
@@ -116,7 +120,7 @@ int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
int32_t
mmPutMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
mmPutMsgToQueryQueue
(
SMnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
pMsg
->
info
.
node
=
pMgmt
->
pMnode
;
pMsg
->
info
.
node
=
pMgmt
->
pMnode
;
if
(
mndPreProcessMsg
(
pMsg
)
!=
0
)
{
if
(
mndPreProcess
Query
Msg
(
pMsg
)
!=
0
)
{
dError
(
"msg:%p, failed to pre-process in mnode since %s, type:%s"
,
pMsg
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
));
dError
(
"msg:%p, failed to pre-process in mnode since %s, type:%s"
,
pMsg
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
));
return
-
1
;
return
-
1
;
}
}
...
...
source/dnode/mgmt/mgmt_snode/src/smHandle.c
浏览文件 @
c79be2da
...
@@ -95,9 +95,12 @@ SArray *smGetMsgHandles() {
...
@@ -95,9 +95,12 @@ SArray *smGetMsgHandles() {
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MON_SM_INFO
,
smPutNodeMsgToMonitorQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_MON_SM_INFO
,
smPutNodeMsgToMonitorQueue
,
0
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DEPLOY
,
smPutNodeMsgToMgmtQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DEPLOY
,
smPutNodeMsgToMgmtQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RUN
,
smPutNodeMsgToMgmtQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_VND_STREAM_TASK_DROP
,
smPutNodeMsgToMgmtQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DISPATCH
,
smPutNodeMsgToMgmtQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RUN
,
smPutNodeMsgToSharedQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RECOVER
,
smPutNodeMsgToMgmtQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DISPATCH
,
smPutNodeMsgToSharedQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_DISPATCH_RSP
,
smPutNodeMsgToSharedQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RECOVER
,
smPutNodeMsgToSharedQueue
,
1
)
==
NULL
)
goto
_OVER
;
if
(
dmSetMgmtHandle
(
pArray
,
TDMT_STREAM_TASK_RECOVER_RSP
,
smPutNodeMsgToSharedQueue
,
1
)
==
NULL
)
goto
_OVER
;
code
=
0
;
code
=
0
;
_OVER:
_OVER:
...
...
source/dnode/mgmt/mgmt_snode/src/smWorker.c
浏览文件 @
c79be2da
...
@@ -55,7 +55,10 @@ static void smProcessUniqueQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t num
...
@@ -55,7 +55,10 @@ static void smProcessUniqueQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t num
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
);
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
);
dTrace
(
"msg:%p, get from snode-unique queue"
,
pMsg
);
dTrace
(
"msg:%p, get from snode-unique queue"
,
pMsg
);
sndProcessUMsg
(
pMgmt
->
pSnode
,
pMsg
);
if
(
sndProcessUMsg
(
pMgmt
->
pSnode
,
pMsg
)
<
0
)
{
ASSERT
(
0
);
}
smSendRsp
(
pMsg
,
0
);
dTrace
(
"msg:%p, is freed"
,
pMsg
);
dTrace
(
"msg:%p, is freed"
,
pMsg
);
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
...
@@ -67,7 +70,10 @@ static void smProcessSharedQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
...
@@ -67,7 +70,10 @@ static void smProcessSharedQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
SSnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
SSnodeMgmt
*
pMgmt
=
pInfo
->
ahandle
;
dTrace
(
"msg:%p, get from snode-shared queue"
,
pMsg
);
dTrace
(
"msg:%p, get from snode-shared queue"
,
pMsg
);
sndProcessSMsg
(
pMgmt
->
pSnode
,
pMsg
);
if
(
sndProcessSMsg
(
pMgmt
->
pSnode
,
pMsg
)
<
0
)
{
smSendRsp
(
pMsg
,
terrno
);
ASSERT
(
0
);
}
dTrace
(
"msg:%p, is freed"
,
pMsg
);
dTrace
(
"msg:%p, is freed"
,
pMsg
);
rpcFreeCont
(
pMsg
->
pCont
);
rpcFreeCont
(
pMsg
->
pCont
);
...
...
source/dnode/mgmt/mgmt_vnode/inc/vmInt.h
浏览文件 @
c79be2da
...
@@ -35,7 +35,6 @@ typedef struct SVnodeMgmt {
...
@@ -35,7 +35,6 @@ typedef struct SVnodeMgmt {
SWWorkerPool
syncPool
;
SWWorkerPool
syncPool
;
SWWorkerPool
writePool
;
SWWorkerPool
writePool
;
SWWorkerPool
applyPool
;
SWWorkerPool
applyPool
;
SWWorkerPool
mergePool
;
SSingleWorker
mgmtWorker
;
SSingleWorker
mgmtWorker
;
SSingleWorker
monitorWorker
;
SSingleWorker
monitorWorker
;
SHashObj
*
hash
;
SHashObj
*
hash
;
...
@@ -63,7 +62,6 @@ typedef struct {
...
@@ -63,7 +62,6 @@ typedef struct {
STaosQueue
*
pApplyQ
;
STaosQueue
*
pApplyQ
;
STaosQueue
*
pQueryQ
;
STaosQueue
*
pQueryQ
;
STaosQueue
*
pFetchQ
;
STaosQueue
*
pFetchQ
;
STaosQueue
*
pMergeQ
;
}
SVnodeObj
;
}
SVnodeObj
;
typedef
struct
{
typedef
struct
{
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
c79be2da
...
@@ -86,7 +86,6 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
...
@@ -86,7 +86,6 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
while
(
!
taosQueueEmpty
(
pVnode
->
pApplyQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pApplyQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pQueryQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pQueryQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pFetchQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pFetchQ
))
taosMsleep
(
10
);
while
(
!
taosQueueEmpty
(
pVnode
->
pMergeQ
))
taosMsleep
(
10
);
vmFreeQueue
(
pMgmt
,
pVnode
);
vmFreeQueue
(
pMgmt
,
pVnode
);
vnodeClose
(
pVnode
->
pImpl
);
vnodeClose
(
pVnode
->
pImpl
);
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
c79be2da
...
@@ -98,7 +98,7 @@ static void vmProcessFetchQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
...
@@ -98,7 +98,7 @@ static void vmProcessFetchQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
static
void
vmProcessSyncQueue
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
static
void
vmProcessSyncQueue
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
SRpcMsg
*
pMsg
=
NULL
;
SRpcMsg
*
pMsg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
...
@@ -119,7 +119,7 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
...
@@ -119,7 +119,7 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
static
void
vmProcessMergeQueue
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
static
void
vmProcessMergeQueue
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
SRpcMsg
*
pMsg
=
NULL
;
SRpcMsg
*
pMsg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
if
(
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
)
==
0
)
continue
;
...
@@ -170,10 +170,6 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
...
@@ -170,10 +170,6 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
dTrace
(
"vgId:%d, msg:%p put into vnode-sync queue"
,
pVnode
->
vgId
,
pMsg
);
dTrace
(
"vgId:%d, msg:%p put into vnode-sync queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pSyncQ
,
pMsg
);
taosWriteQitem
(
pVnode
->
pSyncQ
,
pMsg
);
break
;
break
;
case
MERGE_QUEUE
:
dTrace
(
"vgId:%d, msg:%p put into vnode-merge queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pMergeQ
,
pMsg
);
break
;
case
APPLY_QUEUE
:
case
APPLY_QUEUE
:
dTrace
(
"vgId:%d, msg:%p put into vnode-apply queue"
,
pVnode
->
vgId
,
pMsg
);
dTrace
(
"vgId:%d, msg:%p put into vnode-apply queue"
,
pVnode
->
vgId
,
pMsg
);
taosWriteQitem
(
pVnode
->
pApplyQ
,
pMsg
);
taosWriteQitem
(
pVnode
->
pApplyQ
,
pMsg
);
...
@@ -196,8 +192,6 @@ int32_t vmPutMsgToQueryQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsg
...
@@ -196,8 +192,6 @@ int32_t vmPutMsgToQueryQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsg
int32_t
vmPutMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
FETCH_QUEUE
);
}
int32_t
vmPutMsgToFetchQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
FETCH_QUEUE
);
}
int32_t
vmPutMsgToMergeQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
return
vmPutMsgToQueue
(
pMgmt
,
pMsg
,
MERGE_QUEUE
);
}
int32_t
vmPutMsgToMgmtQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
int32_t
vmPutMsgToMgmtQueue
(
SVnodeMgmt
*
pMgmt
,
SRpcMsg
*
pMsg
)
{
dTrace
(
"msg:%p, put into vnode-mgmt queue"
,
pMsg
);
dTrace
(
"msg:%p, put into vnode-mgmt queue"
,
pMsg
);
taosWriteQitem
(
pMgmt
->
mgmtWorker
.
queue
,
pMsg
);
taosWriteQitem
(
pMgmt
->
mgmtWorker
.
queue
,
pMsg
);
...
@@ -243,9 +237,6 @@ int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) {
...
@@ -243,9 +237,6 @@ int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) {
case
FETCH_QUEUE
:
case
FETCH_QUEUE
:
size
=
taosQueueItemSize
(
pVnode
->
pFetchQ
);
size
=
taosQueueItemSize
(
pVnode
->
pFetchQ
);
break
;
break
;
case
MERGE_QUEUE
:
size
=
taosQueueItemSize
(
pVnode
->
pMergeQ
);
break
;
default:
default:
break
;
break
;
}
}
...
@@ -260,10 +251,9 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
...
@@ -260,10 +251,9 @@ int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
pVnode
->
pApplyQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
applyPool
,
pVnode
->
pImpl
,
(
FItems
)
vnodeApplyMsg
);
pVnode
->
pApplyQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
applyPool
,
pVnode
->
pImpl
,
(
FItems
)
vnodeApplyMsg
);
pVnode
->
pQueryQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
queryPool
,
pVnode
,
(
FItem
)
vmProcessQueryQueue
);
pVnode
->
pQueryQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
queryPool
,
pVnode
,
(
FItem
)
vmProcessQueryQueue
);
pVnode
->
pFetchQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
fetchPool
,
pVnode
,
(
FItem
)
vmProcessFetchQueue
);
pVnode
->
pFetchQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
fetchPool
,
pVnode
,
(
FItem
)
vmProcessFetchQueue
);
pVnode
->
pMergeQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
mergePool
,
pVnode
,
(
FItems
)
vmProcessMergeQueue
);
if
(
pVnode
->
pWriteQ
==
NULL
||
pVnode
->
pSyncQ
==
NULL
||
pVnode
->
pApplyQ
==
NULL
||
pVnode
->
pQueryQ
==
NULL
||
if
(
pVnode
->
pWriteQ
==
NULL
||
pVnode
->
pSyncQ
==
NULL
||
pVnode
->
pApplyQ
==
NULL
||
pVnode
->
pQueryQ
==
NULL
||
pVnode
->
pFetchQ
==
NULL
||
pVnode
->
pMergeQ
==
NULL
)
{
pVnode
->
pFetchQ
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
...
@@ -278,13 +268,11 @@ void vmFreeQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
...
@@ -278,13 +268,11 @@ void vmFreeQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
tWWorkerFreeQueue
(
&
pMgmt
->
syncPool
,
pVnode
->
pSyncQ
);
tWWorkerFreeQueue
(
&
pMgmt
->
syncPool
,
pVnode
->
pSyncQ
);
tQWorkerFreeQueue
(
&
pMgmt
->
queryPool
,
pVnode
->
pQueryQ
);
tQWorkerFreeQueue
(
&
pMgmt
->
queryPool
,
pVnode
->
pQueryQ
);
tQWorkerFreeQueue
(
&
pMgmt
->
fetchPool
,
pVnode
->
pFetchQ
);
tQWorkerFreeQueue
(
&
pMgmt
->
fetchPool
,
pVnode
->
pFetchQ
);
tWWorkerFreeQueue
(
&
pMgmt
->
mergePool
,
pVnode
->
pMergeQ
);
pVnode
->
pWriteQ
=
NULL
;
pVnode
->
pWriteQ
=
NULL
;
pVnode
->
pSyncQ
=
NULL
;
pVnode
->
pSyncQ
=
NULL
;
pVnode
->
pApplyQ
=
NULL
;
pVnode
->
pApplyQ
=
NULL
;
pVnode
->
pQueryQ
=
NULL
;
pVnode
->
pQueryQ
=
NULL
;
pVnode
->
pFetchQ
=
NULL
;
pVnode
->
pFetchQ
=
NULL
;
pVnode
->
pMergeQ
=
NULL
;
dDebug
(
"vgId:%d, queue is freed"
,
pVnode
->
vgId
);
dDebug
(
"vgId:%d, queue is freed"
,
pVnode
->
vgId
);
}
}
...
@@ -316,11 +304,6 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
...
@@ -316,11 +304,6 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
pSPool
->
max
=
tsNumOfVnodeSyncThreads
;
pSPool
->
max
=
tsNumOfVnodeSyncThreads
;
if
(
tWWorkerInit
(
pSPool
)
!=
0
)
return
-
1
;
if
(
tWWorkerInit
(
pSPool
)
!=
0
)
return
-
1
;
SWWorkerPool
*
pMPool
=
&
pMgmt
->
mergePool
;
pMPool
->
name
=
"vnode-merge"
;
pMPool
->
max
=
tsNumOfVnodeMergeThreads
;
if
(
tWWorkerInit
(
pMPool
)
!=
0
)
return
-
1
;
SSingleWorkerCfg
mgmtCfg
=
{
SSingleWorkerCfg
mgmtCfg
=
{
.
min
=
1
,
.
min
=
1
,
.
max
=
1
,
.
max
=
1
,
...
@@ -351,6 +334,5 @@ void vmStopWorker(SVnodeMgmt *pMgmt) {
...
@@ -351,6 +334,5 @@ void vmStopWorker(SVnodeMgmt *pMgmt) {
tWWorkerCleanup
(
&
pMgmt
->
syncPool
);
tWWorkerCleanup
(
&
pMgmt
->
syncPool
);
tQWorkerCleanup
(
&
pMgmt
->
queryPool
);
tQWorkerCleanup
(
&
pMgmt
->
queryPool
);
tQWorkerCleanup
(
&
pMgmt
->
fetchPool
);
tQWorkerCleanup
(
&
pMgmt
->
fetchPool
);
tWWorkerCleanup
(
&
pMgmt
->
mergePool
);
dDebug
(
"vnode workers are closed"
);
dDebug
(
"vnode workers are closed"
);
}
}
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
c79be2da
...
@@ -341,8 +341,8 @@ typedef struct {
...
@@ -341,8 +341,8 @@ typedef struct {
int32_t
colVer
;
int32_t
colVer
;
int32_t
smaVer
;
int32_t
smaVer
;
int32_t
nextColId
;
int32_t
nextColId
;
float
xFilesFactor
;
int64_t
watermark
[
2
]
;
int
32_t
delay
;
int
64_t
maxdelay
[
2
]
;
int32_t
ttl
;
int32_t
ttl
;
int32_t
numOfColumns
;
int32_t
numOfColumns
;
int32_t
numOfTags
;
int32_t
numOfTags
;
...
...
source/dnode/mnode/impl/inc/mndScheduler.h
浏览文件 @
c79be2da
...
@@ -30,7 +30,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
...
@@ -30,7 +30,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
int32_t
mndScheduleStream
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
);
int32_t
mndScheduleStream
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
);
int32_t
mndConvertRsmaTask
(
char
**
pDst
,
int32_t
*
pDstLen
,
const
char
*
ast
,
int64_t
uid
,
int8_t
triggerType
,
int32_t
mndConvertRsmaTask
(
char
**
pDst
,
int32_t
*
pDstLen
,
const
char
*
ast
,
int64_t
uid
,
int8_t
triggerType
,
int64_t
watermark
,
double
filesFactor
);
int64_t
watermark
);
int32_t
mndScheduleStream
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
);
int32_t
mndScheduleStream
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SStreamObj
*
pStream
);
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
c79be2da
...
@@ -58,21 +58,21 @@ static void *mndBuildTimerMsg(int32_t *pContLen) {
...
@@ -58,21 +58,21 @@ static void *mndBuildTimerMsg(int32_t *pContLen) {
static
void
mndPullupTrans
(
SMnode
*
pMnode
)
{
static
void
mndPullupTrans
(
SMnode
*
pMnode
)
{
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TRANS_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TRANS_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
WRITE_QUEUE
,
&
rpcMsg
);
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
WRITE_QUEUE
,
&
rpcMsg
);
}
}
static
void
mndCalMqRebalance
(
SMnode
*
pMnode
)
{
static
void
mndCalMqRebalance
(
SMnode
*
pMnode
)
{
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_MQ_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_MQ_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
}
}
static
void
mndPullupTelem
(
SMnode
*
pMnode
)
{
static
void
mndPullupTelem
(
SMnode
*
pMnode
)
{
int32_t
contLen
=
0
;
int32_t
contLen
=
0
;
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
void
*
pReq
=
mndBuildTimerMsg
(
&
contLen
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TELEM_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_MND_TELEM_TIMER
,
.
pCont
=
pReq
,
.
contLen
=
contLen
};
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
tmsgPutToQueue
(
&
pMnode
->
msgCb
,
READ_QUEUE
,
&
rpcMsg
);
}
}
...
@@ -86,8 +86,8 @@ static void mndPushTtlTime(SMnode *pMnode) {
...
@@ -86,8 +86,8 @@ static void mndPushTtlTime(SMnode *pMnode) {
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
if
(
pIter
==
NULL
)
break
;
int32_t
contLen
=
sizeof
(
SMsgHead
)
+
sizeof
(
int32_t
);
int32_t
contLen
=
sizeof
(
SMsgHead
)
+
sizeof
(
int32_t
);
SMsgHead
*
pHead
=
rpcMallocCont
(
contLen
);
SMsgHead
*
pHead
=
rpcMallocCont
(
contLen
);
if
(
pHead
==
NULL
)
{
if
(
pHead
==
NULL
)
{
mError
(
"ttl time malloc err. contLen:%d"
,
contLen
);
mError
(
"ttl time malloc err. contLen:%d"
,
contLen
);
sdbRelease
(
pSdb
,
pVgroup
);
sdbRelease
(
pSdb
,
pVgroup
);
...
@@ -97,13 +97,13 @@ static void mndPushTtlTime(SMnode *pMnode) {
...
@@ -97,13 +97,13 @@ static void mndPushTtlTime(SMnode *pMnode) {
pHead
->
vgId
=
htonl
(
pVgroup
->
vgId
);
pHead
->
vgId
=
htonl
(
pVgroup
->
vgId
);
int32_t
t
=
taosGetTimestampSec
();
int32_t
t
=
taosGetTimestampSec
();
*
(
int32_t
*
)(
POINTER_SHIFT
(
pHead
,
sizeof
(
SMsgHead
)))
=
htonl
(
t
);
*
(
int32_t
*
)(
POINTER_SHIFT
(
pHead
,
sizeof
(
SMsgHead
)))
=
htonl
(
t
);
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_VND_DROP_TTL_TABLE
,
.
pCont
=
pHead
,
.
contLen
=
contLen
};
SRpcMsg
rpcMsg
=
{.
msgType
=
TDMT_VND_DROP_TTL_TABLE
,
.
pCont
=
pHead
,
.
contLen
=
contLen
};
SEpSet
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
SEpSet
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
int32_t
code
=
tmsgSendReq
(
&
epSet
,
&
rpcMsg
);
int32_t
code
=
tmsgSendReq
(
&
epSet
,
&
rpcMsg
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
mError
(
"ttl time seed err. code:%d"
,
code
);
mError
(
"ttl time seed err. code:%d"
,
code
);
}
}
mError
(
"ttl time seed succ. time:%d"
,
t
);
mError
(
"ttl time seed succ. time:%d"
,
t
);
...
@@ -117,7 +117,7 @@ static void *mndThreadFp(void *param) {
...
@@ -117,7 +117,7 @@ static void *mndThreadFp(void *param) {
setThreadName
(
"mnode-timer"
);
setThreadName
(
"mnode-timer"
);
while
(
1
)
{
while
(
1
)
{
if
(
lastTime
%
(
864000
)
==
0
)
{
// sleep 1 day for ttl
if
(
lastTime
%
(
864000
)
==
0
)
{
// sleep 1 day for ttl
mndPushTtlTime
(
pMnode
);
mndPushTtlTime
(
pMnode
);
}
}
...
@@ -416,7 +416,7 @@ void mndStop(SMnode *pMnode) {
...
@@ -416,7 +416,7 @@ void mndStop(SMnode *pMnode) {
}
}
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
)
{
int32_t
mndProcessSyncMsg
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
int32_t
code
=
0
;
int32_t
code
=
0
;
...
@@ -433,15 +433,19 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
...
@@ -433,15 +433,19 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
return
-
1
;
return
-
1
;
}
}
char
logBuf
[
512
]
=
{
0
};
do
{
char
*
syncNodeStr
=
sync2SimpleStr
(
pMgmt
->
sync
);
char
*
syncNodeStr
=
sync2SimpleStr
(
pMgmt
->
sync
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==mndProcessSyncMsg== msgType:%d, syncNode: %s"
,
pMsg
->
msgType
,
syncNodeStr
);
static
int64_t
mndTick
=
0
;
static
int64_t
mndTick
=
0
;
if
(
++
mndTick
%
10
==
1
)
{
if
(
++
mndTick
%
10
==
1
)
{
mTrace
(
"vgId:%d, sync heartbeat msg:%s, %s"
,
syncGetVgId
(
pMgmt
->
sync
),
TMSG_INFO
(
pMsg
->
msgType
),
syncNodeStr
);
mTrace
(
"sync trace msg:%s, %s"
,
TMSG_INFO
(
pMsg
->
msgType
),
syncNodeStr
);
}
}
if
(
gRaftDetailLog
)
{
syncRpcMsgLog2
(
logBuf
,
pMsg
);
char
logBuf
[
512
]
=
{
0
};
taosMemoryFree
(
syncNodeStr
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==mndProcessSyncMsg== msgType:%d, syncNode: %s"
,
pMsg
->
msgType
,
syncNodeStr
);
syncRpcMsgLog2
(
logBuf
,
pMsg
);
}
taosMemoryFree
(
syncNodeStr
);
}
while
(
0
);
// ToDo: ugly! use function pointer
// ToDo: ugly! use function pointer
if
(
syncNodeSnapshotEnable
(
pSyncNode
))
{
if
(
syncNodeSnapshotEnable
(
pSyncNode
))
{
...
@@ -546,7 +550,7 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
...
@@ -546,7 +550,7 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
if
(
!
IsReq
(
pMsg
))
return
0
;
if
(
!
IsReq
(
pMsg
))
return
0
;
if
(
mndAcquireRpcRef
(
pMsg
->
info
.
node
)
==
0
)
return
0
;
if
(
mndAcquireRpcRef
(
pMsg
->
info
.
node
)
==
0
)
return
0
;
if
(
IsReq
(
pMsg
)
&&
pMsg
->
msgType
!=
TDMT_MND_MQ_TIMER
&&
pMsg
->
msgType
!=
TDMT_MND_TELEM_TIMER
&&
if
(
pMsg
->
msgType
!=
TDMT_MND_MQ_TIMER
&&
pMsg
->
msgType
!=
TDMT_MND_TELEM_TIMER
&&
pMsg
->
msgType
!=
TDMT_MND_TRANS_TIMER
)
{
pMsg
->
msgType
!=
TDMT_MND_TRANS_TIMER
)
{
mError
(
"msg:%p, failed to check mnode state since %s, type:%s"
,
pMsg
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
));
mError
(
"msg:%p, failed to check mnode state since %s, type:%s"
,
pMsg
,
terrstr
(),
TMSG_INFO
(
pMsg
->
msgType
));
...
@@ -578,7 +582,7 @@ static int32_t mndCheckMsgContent(SRpcMsg *pMsg) {
...
@@ -578,7 +582,7 @@ static int32_t mndCheckMsgContent(SRpcMsg *pMsg) {
}
}
int32_t
mndProcessRpcMsg
(
SRpcMsg
*
pMsg
)
{
int32_t
mndProcessRpcMsg
(
SRpcMsg
*
pMsg
)
{
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
MndMsgFp
fp
=
pMnode
->
msgFp
[
TMSG_INDEX
(
pMsg
->
msgType
)];
MndMsgFp
fp
=
pMnode
->
msgFp
[
TMSG_INDEX
(
pMsg
->
msgType
)];
if
(
fp
==
NULL
)
{
if
(
fp
==
NULL
)
{
mError
(
"msg:%p, failed to get msg handle, app:%p type:%s"
,
pMsg
,
pMsg
->
info
.
ahandle
,
TMSG_INFO
(
pMsg
->
msgType
));
mError
(
"msg:%p, failed to get msg handle, app:%p type:%s"
,
pMsg
,
pMsg
->
info
.
ahandle
,
TMSG_INFO
(
pMsg
->
msgType
));
...
@@ -631,7 +635,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
...
@@ -631,7 +635,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
SMonGrantInfo
*
pGrantInfo
)
{
SMonGrantInfo
*
pGrantInfo
)
{
if
(
mndAcquireRpcRef
(
pMnode
)
!=
0
)
return
-
1
;
if
(
mndAcquireRpcRef
(
pMnode
)
!=
0
)
return
-
1
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int64_t
ms
=
taosGetTimestampMs
();
int64_t
ms
=
taosGetTimestampMs
();
pClusterInfo
->
dnodes
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_DNODE
),
sizeof
(
SMonDnodeDesc
));
pClusterInfo
->
dnodes
=
taosArrayInit
(
sdbGetSize
(
pSdb
,
SDB_DNODE
),
sizeof
(
SMonDnodeDesc
));
...
@@ -707,7 +711,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
...
@@ -707,7 +711,7 @@ int32_t mndGetMonitorInfo(SMnode *pMnode, SMonClusterInfo *pClusterInfo, SMonVgr
pGrantInfo
->
timeseries_used
+=
pVgroup
->
numOfTimeSeries
;
pGrantInfo
->
timeseries_used
+=
pVgroup
->
numOfTimeSeries
;
tstrncpy
(
desc
.
status
,
"unsynced"
,
sizeof
(
desc
.
status
));
tstrncpy
(
desc
.
status
,
"unsynced"
,
sizeof
(
desc
.
status
));
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
replica
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pVgroup
->
replica
;
++
i
)
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
i
];
SMonVnodeDesc
*
pVnDesc
=
&
desc
.
vnodes
[
i
];
SMonVnodeDesc
*
pVnDesc
=
&
desc
.
vnodes
[
i
];
pVnDesc
->
dnode_id
=
pVgid
->
dnodeId
;
pVnDesc
->
dnode_id
=
pVgid
->
dnodeId
;
tstrncpy
(
pVnDesc
->
vnode_role
,
syncStr
(
pVgid
->
role
),
sizeof
(
pVnDesc
->
vnode_role
));
tstrncpy
(
pVnDesc
->
vnode_role
,
syncStr
(
pVgid
->
role
),
sizeof
(
pVnDesc
->
vnode_role
));
...
...
source/dnode/mnode/impl/src/mndQuery.c
浏览文件 @
c79be2da
...
@@ -18,13 +18,18 @@
...
@@ -18,13 +18,18 @@
#include "mndMnode.h"
#include "mndMnode.h"
#include "qworker.h"
#include "qworker.h"
int32_t
mndPreProcessMsg
(
SRpcMsg
*
pMsg
)
{
int32_t
mndPreProcess
Query
Msg
(
SRpcMsg
*
pMsg
)
{
if
(
TDMT_VND_QUERY
!=
pMsg
->
msgType
)
return
0
;
if
(
TDMT_VND_QUERY
!=
pMsg
->
msgType
)
return
0
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
return
qWorkerPreprocessQueryMsg
(
pMnode
->
pQuery
,
pMsg
);
return
qWorkerPreprocessQueryMsg
(
pMnode
->
pQuery
,
pMsg
);
}
}
void
mndPostProcessQueryMsg
(
SRpcMsg
*
pMsg
)
{
if
(
TDMT_VND_QUERY
!=
pMsg
->
msgType
)
return
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
qWorkerAbortPreprocessQueryMsg
(
pMnode
->
pQuery
,
pMsg
);
}
int32_t
mndProcessQueryMsg
(
SRpcMsg
*
pMsg
)
{
int32_t
mndProcessQueryMsg
(
SRpcMsg
*
pMsg
)
{
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
SMnode
*
pMnode
=
pMsg
->
info
.
node
;
...
...
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
c79be2da
...
@@ -33,7 +33,7 @@
...
@@ -33,7 +33,7 @@
#include "tname.h"
#include "tname.h"
#include "tuuid.h"
#include "tuuid.h"
extern
bool
tsS
treamSchedV
;
extern
bool
tsS
chedStreamToSnode
;
static
int32_t
mndAddTaskToTaskSet
(
SArray
*
pArray
,
SStreamTask
*
pTask
)
{
static
int32_t
mndAddTaskToTaskSet
(
SArray
*
pArray
,
SStreamTask
*
pTask
)
{
int32_t
childId
=
taosArrayGetSize
(
pArray
);
int32_t
childId
=
taosArrayGetSize
(
pArray
);
...
@@ -43,7 +43,7 @@ static int32_t mndAddTaskToTaskSet(SArray* pArray, SStreamTask* pTask) {
...
@@ -43,7 +43,7 @@ static int32_t mndAddTaskToTaskSet(SArray* pArray, SStreamTask* pTask) {
}
}
int32_t
mndConvertRsmaTask
(
char
**
pDst
,
int32_t
*
pDstLen
,
const
char
*
ast
,
int64_t
uid
,
int8_t
triggerType
,
int32_t
mndConvertRsmaTask
(
char
**
pDst
,
int32_t
*
pDstLen
,
const
char
*
ast
,
int64_t
uid
,
int8_t
triggerType
,
int64_t
watermark
,
double
filesFactor
)
{
int64_t
watermark
)
{
SNode
*
pAst
=
NULL
;
SNode
*
pAst
=
NULL
;
SQueryPlan
*
pPlan
=
NULL
;
SQueryPlan
*
pPlan
=
NULL
;
terrno
=
TSDB_CODE_SUCCESS
;
terrno
=
TSDB_CODE_SUCCESS
;
...
@@ -63,9 +63,8 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64
...
@@ -63,9 +63,8 @@ int32_t mndConvertRsmaTask(char** pDst, int32_t* pDstLen, const char* ast, int64
.
topicQuery
=
false
,
.
topicQuery
=
false
,
.
streamQuery
=
true
,
.
streamQuery
=
true
,
.
rSmaQuery
=
true
,
.
rSmaQuery
=
true
,
.
triggerType
=
STREAM_TRIGGER_AT_ONCE
,
.
triggerType
=
triggerType
,
.
watermark
=
watermark
,
.
watermark
=
watermark
,
/*.filesFactor = filesFactor,*/
};
};
if
(
qCreateQueryPlan
(
&
cxt
,
&
pPlan
,
NULL
)
<
0
)
{
if
(
qCreateQueryPlan
(
&
cxt
,
&
pPlan
,
NULL
)
<
0
)
{
...
@@ -205,9 +204,11 @@ int32_t mndAssignTaskToVg(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask, SS
...
@@ -205,9 +204,11 @@ int32_t mndAssignTaskToVg(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask, SS
return
0
;
return
0
;
}
}
SSnodeObj
*
mndSchedFetchSnode
(
SMnode
*
pMnode
)
{
SSnodeObj
*
mndSchedFetch
One
Snode
(
SMnode
*
pMnode
)
{
SSnodeObj
*
pObj
=
NULL
;
SSnodeObj
*
pObj
=
NULL
;
pObj
=
sdbFetch
(
pMnode
->
pSdb
,
SDB_SNODE
,
NULL
,
(
void
**
)
&
pObj
);
void
*
pIter
=
NULL
;
// TODO random fetch
pIter
=
sdbFetch
(
pMnode
->
pSdb
,
SDB_SNODE
,
pIter
,
(
void
**
)
&
pObj
);
return
pObj
;
return
pObj
;
}
}
...
@@ -215,7 +216,7 @@ int32_t mndAssignTaskToSnode(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask,
...
@@ -215,7 +216,7 @@ int32_t mndAssignTaskToSnode(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask,
const
SSnodeObj
*
pSnode
)
{
const
SSnodeObj
*
pSnode
)
{
int32_t
msgLen
;
int32_t
msgLen
;
pTask
->
nodeId
=
0
;
pTask
->
nodeId
=
SNODE_HANDLE
;
pTask
->
epSet
=
mndAcquireEpFromSnode
(
pMnode
,
pSnode
);
pTask
->
epSet
=
mndAcquireEpFromSnode
(
pMnode
,
pSnode
);
plan
->
execNode
.
nodeId
=
0
;
plan
->
execNode
.
nodeId
=
0
;
...
@@ -225,7 +226,7 @@ int32_t mndAssignTaskToSnode(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask,
...
@@ -225,7 +226,7 @@ int32_t mndAssignTaskToSnode(SMnode* pMnode, STrans* pTrans, SStreamTask* pTask,
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
-
1
;
return
-
1
;
}
}
mndPersistTaskDeployReq
(
pTrans
,
pTask
,
&
plan
->
execNode
.
epSet
,
TDMT_STREAM_TASK_DEPLOY
,
0
);
mndPersistTaskDeployReq
(
pTrans
,
pTask
,
&
plan
->
execNode
.
epSet
,
TDMT_STREAM_TASK_DEPLOY
,
SNODE_HANDLE
);
return
0
;
return
0
;
}
}
...
@@ -270,7 +271,6 @@ int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, STrans* pTrans, SStreamOb
...
@@ -270,7 +271,6 @@ int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, STrans* pTrans, SStreamOb
pTask
->
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
pTask
->
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
// source
// source
pTask
->
sourceType
=
TASK_SOURCE__MERGE
;
pTask
->
inputType
=
TASK_INPUT_TYPE__DATA_BLOCK
;
pTask
->
inputType
=
TASK_INPUT_TYPE__DATA_BLOCK
;
// exec
// exec
...
@@ -316,7 +316,6 @@ int32_t mndAddFixedSinkTaskToStream(SMnode* pMnode, STrans* pTrans, SStreamObj*
...
@@ -316,7 +316,6 @@ int32_t mndAddFixedSinkTaskToStream(SMnode* pMnode, STrans* pTrans, SStreamObj*
#endif
#endif
pTask
->
epSet
=
mndGetVgroupEpset
(
pMnode
,
&
pStream
->
fixedSinkVg
);
pTask
->
epSet
=
mndGetVgroupEpset
(
pMnode
,
&
pStream
->
fixedSinkVg
);
// source
// source
pTask
->
sourceType
=
TASK_SOURCE__MERGE
;
pTask
->
inputType
=
TASK_INPUT_TYPE__DATA_BLOCK
;
pTask
->
inputType
=
TASK_INPUT_TYPE__DATA_BLOCK
;
// exec
// exec
...
@@ -373,8 +372,8 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -373,8 +372,8 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
}
}
if
(
totLevel
>
1
)
{
if
(
totLevel
>
1
)
{
SStreamTask
*
p
Final
Task
;
SStreamTask
*
p
Inner
Task
;
// inner
plan
// inner
level
{
{
SArray
*
taskInnerLevel
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
SArray
*
taskInnerLevel
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
taosArrayPush
(
pStream
->
tasks
,
&
taskInnerLevel
);
taosArrayPush
(
pStream
->
tasks
,
&
taskInnerLevel
);
...
@@ -383,31 +382,51 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -383,31 +382,51 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
SSubplan
*
plan
=
(
SSubplan
*
)
nodesListGetNode
(
inner
->
pNodeList
,
0
);
SSubplan
*
plan
=
(
SSubplan
*
)
nodesListGetNode
(
inner
->
pNodeList
,
0
);
ASSERT
(
plan
->
subplanType
==
SUBPLAN_TYPE_MERGE
);
ASSERT
(
plan
->
subplanType
==
SUBPLAN_TYPE_MERGE
);
p
Final
Task
=
tNewSStreamTask
(
pStream
->
uid
);
p
Inner
Task
=
tNewSStreamTask
(
pStream
->
uid
);
mndAddTaskToTaskSet
(
taskInnerLevel
,
p
Final
Task
);
mndAddTaskToTaskSet
(
taskInnerLevel
,
p
Inner
Task
);
// input
// input
p
Final
Task
->
inputType
=
TASK_INPUT_TYPE__DATA_BLOCK
;
p
Inner
Task
->
inputType
=
TASK_INPUT_TYPE__DATA_BLOCK
;
// trigger
// trigger
p
Final
Task
->
triggerParam
=
pStream
->
triggerParam
;
p
Inner
Task
->
triggerParam
=
pStream
->
triggerParam
;
// dispatch
// dispatch
if
(
mndAddDispatcherToInnerTask
(
pMnode
,
pTrans
,
pStream
,
p
Final
Task
)
<
0
)
{
if
(
mndAddDispatcherToInnerTask
(
pMnode
,
pTrans
,
pStream
,
p
Inner
Task
)
<
0
)
{
qDestroyQueryPlan
(
pPlan
);
qDestroyQueryPlan
(
pPlan
);
return
-
1
;
return
-
1
;
}
}
// exec
// exec
pFinalTask
->
execType
=
TASK_EXEC__PIPE
;
pInnerTask
->
execType
=
TASK_EXEC__PIPE
;
SVgObj
*
pVgroup
=
mndSchedFetchOneVg
(
pMnode
,
pStream
->
sourceDbUid
);
if
(
mndAssignTaskToVg
(
pMnode
,
pTrans
,
pFinalTask
,
plan
,
pVgroup
)
<
0
)
{
if
(
tsSchedStreamToSnode
)
{
sdbRelease
(
pSdb
,
pVgroup
);
SSnodeObj
*
pSnode
=
mndSchedFetchOneSnode
(
pMnode
);
qDestroyQueryPlan
(
pPlan
);
if
(
pSnode
==
NULL
)
{
return
-
1
;
SVgObj
*
pVgroup
=
mndSchedFetchOneVg
(
pMnode
,
pStream
->
sourceDbUid
);
if
(
mndAssignTaskToVg
(
pMnode
,
pTrans
,
pInnerTask
,
plan
,
pVgroup
)
<
0
)
{
sdbRelease
(
pSdb
,
pVgroup
);
qDestroyQueryPlan
(
pPlan
);
return
-
1
;
}
}
else
{
if
(
mndAssignTaskToSnode
(
pMnode
,
pTrans
,
pInnerTask
,
plan
,
pSnode
)
<
0
)
{
ASSERT
(
0
);
sdbRelease
(
pSdb
,
pSnode
);
qDestroyQueryPlan
(
pPlan
);
return
-
1
;
}
}
}
else
{
SVgObj
*
pVgroup
=
mndSchedFetchOneVg
(
pMnode
,
pStream
->
sourceDbUid
);
if
(
mndAssignTaskToVg
(
pMnode
,
pTrans
,
pInnerTask
,
plan
,
pVgroup
)
<
0
)
{
sdbRelease
(
pSdb
,
pVgroup
);
qDestroyQueryPlan
(
pPlan
);
return
-
1
;
}
}
}
}
}
// source
plan
// source
level
SArray
*
taskSourceLevel
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
SArray
*
taskSourceLevel
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
taosArrayPush
(
pStream
->
tasks
,
&
taskSourceLevel
);
taosArrayPush
(
pStream
->
tasks
,
&
taskSourceLevel
);
...
@@ -427,6 +446,8 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -427,6 +446,8 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
SStreamTask
*
pTask
=
tNewSStreamTask
(
pStream
->
uid
);
SStreamTask
*
pTask
=
tNewSStreamTask
(
pStream
->
uid
);
mndAddTaskToTaskSet
(
taskSourceLevel
,
pTask
);
mndAddTaskToTaskSet
(
taskSourceLevel
,
pTask
);
pTask
->
dataScan
=
1
;
// input
// input
pTask
->
inputType
=
TASK_INPUT_TYPE__SUMBIT_BLOCK
;
pTask
->
inputType
=
TASK_INPUT_TYPE__SUMBIT_BLOCK
;
...
@@ -435,9 +456,9 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -435,9 +456,9 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
pTask
->
dispatchMsgType
=
TDMT_STREAM_TASK_DISPATCH
;
pTask
->
dispatchMsgType
=
TDMT_STREAM_TASK_DISPATCH
;
pTask
->
dispatchType
=
TASK_DISPATCH__FIXED
;
pTask
->
dispatchType
=
TASK_DISPATCH__FIXED
;
pTask
->
fixedEpDispatcher
.
taskId
=
p
Final
Task
->
taskId
;
pTask
->
fixedEpDispatcher
.
taskId
=
p
Inner
Task
->
taskId
;
pTask
->
fixedEpDispatcher
.
nodeId
=
p
Final
Task
->
nodeId
;
pTask
->
fixedEpDispatcher
.
nodeId
=
p
Inner
Task
->
nodeId
;
pTask
->
fixedEpDispatcher
.
epSet
=
p
Final
Task
->
epSet
;
pTask
->
fixedEpDispatcher
.
epSet
=
p
Inner
Task
->
epSet
;
// exec
// exec
pTask
->
execType
=
TASK_EXEC__PIPE
;
pTask
->
execType
=
TASK_EXEC__PIPE
;
...
@@ -470,9 +491,14 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -470,9 +491,14 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
SStreamTask
*
pTask
=
tNewSStreamTask
(
pStream
->
uid
);
SStreamTask
*
pTask
=
tNewSStreamTask
(
pStream
->
uid
);
mndAddTaskToTaskSet
(
taskOneLevel
,
pTask
);
mndAddTaskToTaskSet
(
taskOneLevel
,
pTask
);
pTask
->
dataScan
=
1
;
// input
// input
pTask
->
inputType
=
TASK_INPUT_TYPE__SUMBIT_BLOCK
;
pTask
->
inputType
=
TASK_INPUT_TYPE__SUMBIT_BLOCK
;
// trigger
pTask
->
triggerParam
=
pStream
->
triggerParam
;
// sink or dispatch
// sink or dispatch
if
(
hasExtraSink
)
{
if
(
hasExtraSink
)
{
mndAddDispatcherToInnerTask
(
pMnode
,
pTrans
,
pStream
,
pTask
);
mndAddDispatcherToInnerTask
(
pMnode
,
pTrans
,
pStream
,
pTask
);
...
...
source/dnode/mnode/impl/src/mndSnode.c
浏览文件 @
c79be2da
...
@@ -408,6 +408,7 @@ static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
...
@@ -408,6 +408,7 @@ static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
goto
_OVER
;
goto
_OVER
;
}
}
// check deletable
code
=
mndDropSnode
(
pMnode
,
pReq
,
pObj
);
code
=
mndDropSnode
(
pMnode
,
pReq
,
pObj
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
c79be2da
...
@@ -89,8 +89,10 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
...
@@ -89,8 +89,10 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
tagVer
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
tagVer
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
colVer
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
colVer
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
nextColId
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
nextColId
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
(
int32_t
)(
pStb
->
xFilesFactor
*
10000
),
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
maxdelay
[
0
],
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
delay
,
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
maxdelay
[
1
],
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
watermark
[
0
],
_OVER
)
SDB_SET_INT64
(
pRaw
,
dataPos
,
pStb
->
watermark
[
1
],
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ttl
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
ttl
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfColumns
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfColumns
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfTags
,
_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pStb
->
numOfTags
,
_OVER
)
...
@@ -168,10 +170,10 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
...
@@ -168,10 +170,10 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
tagVer
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
tagVer
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
colVer
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
colVer
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
nextColId
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
nextColId
,
_OVER
)
int32_t
xFilesFactor
=
0
;
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pStb
->
maxdelay
[
0
],
_OVER
)
SDB_GET_INT
32
(
pRaw
,
dataPos
,
&
xFilesFactor
,
_OVER
)
SDB_GET_INT
64
(
pRaw
,
dataPos
,
&
pStb
->
maxdelay
[
1
]
,
_OVER
)
pStb
->
xFilesFactor
=
xFilesFactor
/
10000
.
0
f
;
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pStb
->
watermark
[
0
],
_OVER
)
SDB_GET_INT
32
(
pRaw
,
dataPos
,
&
pStb
->
delay
,
_OVER
)
SDB_GET_INT
64
(
pRaw
,
dataPos
,
&
pStb
->
watermark
[
1
]
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ttl
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
ttl
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfColumns
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfColumns
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfTags
,
_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pStb
->
numOfTags
,
_OVER
)
...
@@ -399,18 +401,18 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
...
@@ -399,18 +401,18 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
req
.
schemaTag
.
pSchema
=
pStb
->
pTags
;
req
.
schemaTag
.
pSchema
=
pStb
->
pTags
;
if
(
req
.
rollup
)
{
if
(
req
.
rollup
)
{
req
.
pRSmaParam
.
xFilesFactor
=
pStb
->
xFilesFactor
;
req
.
pRSmaParam
.
maxdelay
[
0
]
=
pStb
->
maxdelay
[
0
]
;
req
.
pRSmaParam
.
delay
=
pStb
->
delay
;
req
.
pRSmaParam
.
maxdelay
[
1
]
=
pStb
->
maxdelay
[
1
]
;
if
(
pStb
->
ast1Len
>
0
)
{
if
(
pStb
->
ast1Len
>
0
)
{
if
(
mndConvertRsmaTask
(
&
req
.
pRSmaParam
.
qmsg
1
,
&
req
.
pRSmaParam
.
qmsg1Len
,
pStb
->
pAst1
,
pStb
->
uid
,
if
(
mndConvertRsmaTask
(
&
req
.
pRSmaParam
.
qmsg
[
0
],
&
req
.
pRSmaParam
.
qmsgLen
[
0
]
,
pStb
->
pAst1
,
pStb
->
uid
,
STREAM_TRIGGER_
AT_ONCE
,
0
,
req
.
pRSmaParam
.
xFilesFactor
)
!=
TSDB_CODE_SUCCESS
)
{
STREAM_TRIGGER_
WINDOW_CLOSE
,
req
.
pRSmaParam
.
watermark
[
0
])
<
0
)
{
return
NULL
;
goto
_err
;
}
}
}
}
if
(
pStb
->
ast2Len
>
0
)
{
if
(
pStb
->
ast2Len
>
0
)
{
if
(
mndConvertRsmaTask
(
&
req
.
pRSmaParam
.
qmsg
2
,
&
req
.
pRSmaParam
.
qmsg2Len
,
pStb
->
pAst2
,
pStb
->
uid
,
if
(
mndConvertRsmaTask
(
&
req
.
pRSmaParam
.
qmsg
[
1
],
&
req
.
pRSmaParam
.
qmsgLen
[
1
]
,
pStb
->
pAst2
,
pStb
->
uid
,
STREAM_TRIGGER_
AT_ONCE
,
0
,
req
.
pRSmaParam
.
xFilesFactor
)
!=
TSDB_CODE_SUCCESS
)
{
STREAM_TRIGGER_
WINDOW_CLOSE
,
req
.
pRSmaParam
.
watermark
[
1
])
<
0
)
{
return
NULL
;
goto
_err
;
}
}
}
}
}
}
...
@@ -418,17 +420,15 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
...
@@ -418,17 +420,15 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
int32_t
ret
=
0
;
int32_t
ret
=
0
;
tEncodeSize
(
tEncodeSVCreateStbReq
,
&
req
,
contLen
,
ret
);
tEncodeSize
(
tEncodeSVCreateStbReq
,
&
req
,
contLen
,
ret
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
return
NULL
;
goto
_err
;
}
}
contLen
+=
sizeof
(
SMsgHead
);
contLen
+=
sizeof
(
SMsgHead
);
SMsgHead
*
pHead
=
taosMemoryMalloc
(
contLen
);
SMsgHead
*
pHead
=
taosMemoryMalloc
(
contLen
);
if
(
pHead
==
NULL
)
{
if
(
pHead
==
NULL
)
{
taosMemoryFreeClear
(
req
.
pRSmaParam
.
qmsg1
);
taosMemoryFreeClear
(
req
.
pRSmaParam
.
qmsg2
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
goto
_err
;
}
}
pHead
->
contLen
=
htonl
(
contLen
);
pHead
->
contLen
=
htonl
(
contLen
);
...
@@ -438,17 +438,19 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
...
@@ -438,17 +438,19 @@ static void *mndBuildVCreateStbReq(SMnode *pMnode, SVgObj *pVgroup, SStbObj *pSt
tEncoderInit
(
&
encoder
,
pBuf
,
contLen
-
sizeof
(
SMsgHead
));
tEncoderInit
(
&
encoder
,
pBuf
,
contLen
-
sizeof
(
SMsgHead
));
if
(
tEncodeSVCreateStbReq
(
&
encoder
,
&
req
)
<
0
)
{
if
(
tEncodeSVCreateStbReq
(
&
encoder
,
&
req
)
<
0
)
{
taosMemoryFreeClear
(
pHead
);
taosMemoryFreeClear
(
pHead
);
taosMemoryFreeClear
(
req
.
pRSmaParam
.
qmsg1
);
taosMemoryFreeClear
(
req
.
pRSmaParam
.
qmsg2
);
tEncoderClear
(
&
encoder
);
tEncoderClear
(
&
encoder
);
return
NULL
;
goto
_err
;
}
}
tEncoderClear
(
&
encoder
);
tEncoderClear
(
&
encoder
);
*
pContLen
=
contLen
;
*
pContLen
=
contLen
;
taosMemoryFreeClear
(
req
.
pRSmaParam
.
qmsg
1
);
taosMemoryFreeClear
(
req
.
pRSmaParam
.
qmsg
[
0
]
);
taosMemoryFreeClear
(
req
.
pRSmaParam
.
qmsg
2
);
taosMemoryFreeClear
(
req
.
pRSmaParam
.
qmsg
[
1
]
);
return
pHead
;
return
pHead
;
_err:
taosMemoryFreeClear
(
req
.
pRSmaParam
.
qmsg
[
0
]);
taosMemoryFreeClear
(
req
.
pRSmaParam
.
qmsg
[
1
]);
return
NULL
;
}
}
static
void
*
mndBuildVDropStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
static
void
*
mndBuildVDropStbReq
(
SMnode
*
pMnode
,
SVgObj
*
pVgroup
,
SStbObj
*
pStb
,
int32_t
*
pContLen
)
{
...
@@ -670,8 +672,10 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
...
@@ -670,8 +672,10 @@ int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreat
pDst
->
tagVer
=
1
;
pDst
->
tagVer
=
1
;
pDst
->
colVer
=
1
;
pDst
->
colVer
=
1
;
pDst
->
nextColId
=
1
;
pDst
->
nextColId
=
1
;
// pDst->xFilesFactor = pCreate->xFilesFactor;
pDst
->
maxdelay
[
0
]
=
pCreate
->
delay1
;
// pDst->delay = pCreate->delay;
pDst
->
maxdelay
[
1
]
=
pCreate
->
delay2
;
pDst
->
watermark
[
0
]
=
pCreate
->
watermark1
;
pDst
->
watermark
[
1
]
=
pCreate
->
watermark2
;
pDst
->
ttl
=
pCreate
->
ttl
;
pDst
->
ttl
=
pCreate
->
ttl
;
pDst
->
numOfColumns
=
pCreate
->
numOfColumns
;
pDst
->
numOfColumns
=
pCreate
->
numOfColumns
;
pDst
->
numOfTags
=
pCreate
->
numOfTags
;
pDst
->
numOfTags
=
pCreate
->
numOfTags
;
...
@@ -897,7 +901,7 @@ static int32_t mndUpdateStbCommentAndTTL(const SStbObj *pOld, SStbObj *pNew, cha
...
@@ -897,7 +901,7 @@ static int32_t mndUpdateStbCommentAndTTL(const SStbObj *pOld, SStbObj *pNew, cha
return
-
1
;
return
-
1
;
}
}
memcpy
(
pNew
->
comment
,
pComment
,
commentLen
+
1
);
memcpy
(
pNew
->
comment
,
pComment
,
commentLen
+
1
);
}
else
if
(
commentLen
==
0
)
{
}
else
if
(
commentLen
==
0
)
{
pNew
->
commentLen
=
0
;
pNew
->
commentLen
=
0
;
}
}
...
@@ -1849,7 +1853,7 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
...
@@ -1849,7 +1853,7 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
char
comment
[
TSDB_TB_COMMENT_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
comment
[
TSDB_TB_COMMENT_LEN
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
comment
,
pStb
->
comment
);
STR_TO_VARSTR
(
comment
,
pStb
->
comment
);
colDataAppend
(
pColInfo
,
numOfRows
,
comment
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
comment
,
false
);
}
else
if
(
pStb
->
commentLen
==
0
)
{
}
else
if
(
pStb
->
commentLen
==
0
)
{
char
comment
[
VARSTR_HEADER_SIZE
+
VARSTR_HEADER_SIZE
]
=
{
0
};
char
comment
[
VARSTR_HEADER_SIZE
+
VARSTR_HEADER_SIZE
]
=
{
0
};
STR_TO_VARSTR
(
comment
,
""
);
STR_TO_VARSTR
(
comment
,
""
);
colDataAppend
(
pColInfo
,
numOfRows
,
comment
,
false
);
colDataAppend
(
pColInfo
,
numOfRows
,
comment
,
false
);
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
c79be2da
...
@@ -518,7 +518,6 @@ static int32_t mndCreateStream(SMnode *pMnode, SRpcMsg *pReq, SCMCreateStreamReq
...
@@ -518,7 +518,6 @@ static int32_t mndCreateStream(SMnode *pMnode, SRpcMsg *pReq, SCMCreateStreamReq
// TODO
// TODO
streamObj
.
fixedSinkVgId
=
0
;
streamObj
.
fixedSinkVgId
=
0
;
streamObj
.
smaId
=
0
;
streamObj
.
smaId
=
0
;
/*streamObj.physicalPlan = "";*/
streamObj
.
trigger
=
pCreate
->
triggerType
;
streamObj
.
trigger
=
pCreate
->
triggerType
;
streamObj
.
watermark
=
pCreate
->
watermark
;
streamObj
.
watermark
=
pCreate
->
watermark
;
streamObj
.
triggerParam
=
pCreate
->
maxDelay
;
streamObj
.
triggerParam
=
pCreate
->
maxDelay
;
...
@@ -607,17 +606,6 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
...
@@ -607,17 +606,6 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
}
}
#endif
#endif
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_DB_INSIDE
,
pReq
);
if
(
pTrans
==
NULL
)
{
mError
(
"stream:%s, failed to create since %s"
,
createStreamReq
.
name
,
terrstr
());
goto
_OVER
;
}
mndTransSetDbName
(
pTrans
,
createStreamReq
.
sourceDB
,
NULL
);
// TODO
/*mndTransSetDbName(pTrans, streamObj.targetDb, NULL);*/
mDebug
(
"trans:%d, used to create stream:%s"
,
pTrans
->
id
,
createStreamReq
.
name
);
// build stream obj from request
// build stream obj from request
SStreamObj
streamObj
=
{
0
};
SStreamObj
streamObj
=
{
0
};
if
(
mndBuildStreamObjFromCreateReq
(
pMnode
,
&
streamObj
,
&
createStreamReq
)
<
0
)
{
if
(
mndBuildStreamObjFromCreateReq
(
pMnode
,
&
streamObj
,
&
createStreamReq
)
<
0
)
{
...
@@ -626,6 +614,14 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
...
@@ -626,6 +614,14 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
goto
_OVER
;
goto
_OVER
;
}
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_DB_INSIDE
,
pReq
);
if
(
pTrans
==
NULL
)
{
mError
(
"stream:%s, failed to create since %s"
,
createStreamReq
.
name
,
terrstr
());
goto
_OVER
;
}
mndTransSetDbName
(
pTrans
,
createStreamReq
.
sourceDB
,
streamObj
.
targetDb
);
mDebug
(
"trans:%d, used to create stream:%s"
,
pTrans
->
id
,
createStreamReq
.
name
);
// create stb for stream
// create stb for stream
if
(
mndCreateStbForStream
(
pMnode
,
pTrans
,
&
streamObj
,
pReq
->
info
.
conn
.
user
)
<
0
)
{
if
(
mndCreateStbForStream
(
pMnode
,
pTrans
,
&
streamObj
,
pReq
->
info
.
conn
.
user
)
<
0
)
{
mError
(
"trans:%d, failed to create stb for stream %s since %s"
,
pTrans
->
id
,
createStreamReq
.
name
,
terrstr
());
mError
(
"trans:%d, failed to create stb for stream %s since %s"
,
pTrans
->
id
,
createStreamReq
.
name
,
terrstr
());
...
...
source/dnode/mnode/impl/src/mndSync.c
浏览文件 @
c79be2da
...
@@ -68,12 +68,21 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
...
@@ -68,12 +68,21 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM
mndTransExecute
(
pMnode
,
pTrans
);
mndTransExecute
(
pMnode
,
pTrans
);
mndReleaseTrans
(
pMnode
,
pTrans
);
mndReleaseTrans
(
pMnode
,
pTrans
);
}
}
#if 0
sdbWriteFile(pMnode->pSdb, SDB_WRITE_DELTA);
sdbWriteFile(pMnode->pSdb, SDB_WRITE_DELTA);
#endif
}
}
}
}
int32_t
mndSyncGetSnapshot
(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
)
{
int32_t
mndSyncGetSnapshot
(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
,
void
*
pReaderParam
,
void
**
ppReader
)
{
mInfo
(
"start to read snapshot from sdb in atomic way"
);
SMnode
*
pMnode
=
pFsm
->
data
;
return
sdbStartRead
(
pMnode
->
pSdb
,
(
SSdbIter
**
)
ppReader
,
&
pSnapshot
->
lastApplyIndex
,
&
pSnapshot
->
lastApplyTerm
,
&
pSnapshot
->
lastConfigIndex
);
return
0
;
}
int32_t
mndSyncGetSnapshotInfo
(
struct
SSyncFSM
*
pFsm
,
SSnapshot
*
pSnapshot
)
{
SMnode
*
pMnode
=
pFsm
->
data
;
SMnode
*
pMnode
=
pFsm
->
data
;
sdbGetCommitInfo
(
pMnode
->
pSdb
,
&
pSnapshot
->
lastApplyIndex
,
&
pSnapshot
->
lastApplyTerm
,
&
pSnapshot
->
lastConfigIndex
);
sdbGetCommitInfo
(
pMnode
->
pSdb
,
&
pSnapshot
->
lastApplyIndex
,
&
pSnapshot
->
lastApplyTerm
,
&
pSnapshot
->
lastConfigIndex
);
return
0
;
return
0
;
...
@@ -95,14 +104,6 @@ void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta cbM
...
@@ -95,14 +104,6 @@ void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta cbM
SMnode
*
pMnode
=
pFsm
->
data
;
SMnode
*
pMnode
=
pFsm
->
data
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
SSyncMgmt
*
pMgmt
=
&
pMnode
->
syncMgmt
;
#if 0
// send response
SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen, .conn.applyIndex = cbMeta.index};
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
memcpy(rpcMsg.pCont, pMsg->pCont, pMsg->contLen);
syncGetAndDelRespRpc(pMnode->syncMgmt.sync, cbMeta.seqNum, &rpcMsg.info);
#endif
pMgmt
->
errCode
=
cbMeta
.
code
;
pMgmt
->
errCode
=
cbMeta
.
code
;
mInfo
(
"trans:-1, sync reconfig is proposed, saved:%d code:0x%x, index:%"
PRId64
" term:%"
PRId64
,
pMgmt
->
transId
,
mInfo
(
"trans:-1, sync reconfig is proposed, saved:%d code:0x%x, index:%"
PRId64
" term:%"
PRId64
,
pMgmt
->
transId
,
cbMeta
.
code
,
cbMeta
.
index
,
cbMeta
.
term
);
cbMeta
.
code
,
cbMeta
.
index
,
cbMeta
.
term
);
...
@@ -119,7 +120,7 @@ void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta cbM
...
@@ -119,7 +120,7 @@ void mndReConfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReConfigCbMeta cbM
int32_t
mndSnapshotStartRead
(
struct
SSyncFSM
*
pFsm
,
void
**
ppReader
)
{
int32_t
mndSnapshotStartRead
(
struct
SSyncFSM
*
pFsm
,
void
**
ppReader
)
{
mInfo
(
"start to read snapshot from sdb"
);
mInfo
(
"start to read snapshot from sdb"
);
SMnode
*
pMnode
=
pFsm
->
data
;
SMnode
*
pMnode
=
pFsm
->
data
;
return
sdbStartRead
(
pMnode
->
pSdb
,
(
SSdbIter
**
)
ppReader
);
return
sdbStartRead
(
pMnode
->
pSdb
,
(
SSdbIter
**
)
ppReader
,
NULL
,
NULL
,
NULL
);
}
}
int32_t
mndSnapshotStopRead
(
struct
SSyncFSM
*
pFsm
,
void
*
pReader
)
{
int32_t
mndSnapshotStopRead
(
struct
SSyncFSM
*
pFsm
,
void
*
pReader
)
{
...
@@ -159,6 +160,7 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
...
@@ -159,6 +160,7 @@ SSyncFSM *mndSyncMakeFsm(SMnode *pMnode) {
pFsm
->
FpRestoreFinishCb
=
mndRestoreFinish
;
pFsm
->
FpRestoreFinishCb
=
mndRestoreFinish
;
pFsm
->
FpReConfigCb
=
mndReConfig
;
pFsm
->
FpReConfigCb
=
mndReConfig
;
pFsm
->
FpGetSnapshot
=
mndSyncGetSnapshot
;
pFsm
->
FpGetSnapshot
=
mndSyncGetSnapshot
;
pFsm
->
FpGetSnapshotInfo
=
mndSyncGetSnapshotInfo
;
pFsm
->
FpSnapshotStartRead
=
mndSnapshotStartRead
;
pFsm
->
FpSnapshotStartRead
=
mndSnapshotStartRead
;
pFsm
->
FpSnapshotStopRead
=
mndSnapshotStopRead
;
pFsm
->
FpSnapshotStopRead
=
mndSnapshotStopRead
;
pFsm
->
FpSnapshotDoRead
=
mndSnapshotDoRead
;
pFsm
->
FpSnapshotDoRead
=
mndSnapshotDoRead
;
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
c79be2da
...
@@ -22,8 +22,8 @@
...
@@ -22,8 +22,8 @@
#include "mndSync.h"
#include "mndSync.h"
#include "mndUser.h"
#include "mndUser.h"
#define TRANS_VER_NUMBER
1
#define TRANS_VER_NUMBER 1
#define TRANS_ARRAY_SIZE
8
#define TRANS_ARRAY_SIZE 8
#define TRANS_RESERVE_SIZE 64
#define TRANS_RESERVE_SIZE 64
static
SSdbRaw
*
mndTransActionEncode
(
STrans
*
pTrans
);
static
SSdbRaw
*
mndTransActionEncode
(
STrans
*
pTrans
);
...
@@ -804,7 +804,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
...
@@ -804,7 +804,7 @@ static void mndTransSendRpcRsp(SMnode *pMnode, STrans *pTrans) {
sendRsp
=
true
;
sendRsp
=
true
;
}
}
}
else
{
}
else
{
if
(
pTrans
->
stage
==
TRN_STAGE_REDO_ACTION
&&
pTrans
->
failedTimes
>
2
)
{
if
(
pTrans
->
stage
==
TRN_STAGE_REDO_ACTION
&&
pTrans
->
failedTimes
>
3
)
{
if
(
code
==
0
)
code
=
TSDB_CODE_MND_TRANS_UNKNOW_ERROR
;
if
(
code
==
0
)
code
=
TSDB_CODE_MND_TRANS_UNKNOW_ERROR
;
sendRsp
=
true
;
sendRsp
=
true
;
}
}
...
@@ -896,7 +896,7 @@ static void mndTransResetActions(SMnode *pMnode, STrans *pTrans, SArray *pArray)
...
@@ -896,7 +896,7 @@ static void mndTransResetActions(SMnode *pMnode, STrans *pTrans, SArray *pArray)
pAction
->
rawWritten
=
0
;
pAction
->
rawWritten
=
0
;
pAction
->
msgSent
=
0
;
pAction
->
msgSent
=
0
;
pAction
->
msgReceived
=
0
;
pAction
->
msgReceived
=
0
;
if
(
pAction
->
errCode
==
TSDB_CODE_RPC_REDIRECT
||
pAction
->
errCode
==
TSDB_CODE_SYN_N
OT_IN_NEW_CONFIG
||
if
(
pAction
->
errCode
==
TSDB_CODE_RPC_REDIRECT
||
pAction
->
errCode
==
TSDB_CODE_SYN_N
EW_CONFIG_ERROR
||
pAction
->
errCode
==
TSDB_CODE_SYN_INTERNAL_ERROR
||
pAction
->
errCode
==
TSDB_CODE_SYN_NOT_LEADER
)
{
pAction
->
errCode
==
TSDB_CODE_SYN_INTERNAL_ERROR
||
pAction
->
errCode
==
TSDB_CODE_SYN_NOT_LEADER
)
{
pAction
->
epSet
.
inUse
=
(
pAction
->
epSet
.
inUse
+
1
)
%
pAction
->
epSet
.
numOfEps
;
pAction
->
epSet
.
inUse
=
(
pAction
->
epSet
.
inUse
+
1
)
%
pAction
->
epSet
.
numOfEps
;
mDebug
(
"trans:%d, %s:%d execute status is reset and set epset inuse:%d"
,
pTrans
->
id
,
mndTransStr
(
pAction
->
stage
),
mDebug
(
"trans:%d, %s:%d execute status is reset and set epset inuse:%d"
,
pTrans
->
id
,
mndTransStr
(
pAction
->
stage
),
...
@@ -1127,6 +1127,7 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
...
@@ -1127,6 +1127,7 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
}
}
if
(
code
==
0
)
{
if
(
code
==
0
)
{
pTrans
->
failedTimes
=
0
;
pTrans
->
lastAction
=
action
;
pTrans
->
lastAction
=
action
;
pTrans
->
lastMsgType
=
0
;
pTrans
->
lastMsgType
=
0
;
pTrans
->
lastErrorNo
=
0
;
pTrans
->
lastErrorNo
=
0
;
...
@@ -1430,8 +1431,7 @@ void mndTransPullup(SMnode *pMnode) {
...
@@ -1430,8 +1431,7 @@ void mndTransPullup(SMnode *pMnode) {
mndReleaseTrans
(
pMnode
,
pTrans
);
mndReleaseTrans
(
pMnode
,
pTrans
);
}
}
// todo, set to SDB_WRITE_DELTA
sdbWriteFile
(
pMnode
->
pSdb
,
SDB_WRITE_DELTA
);
sdbWriteFile
(
pMnode
->
pSdb
,
0
);
taosArrayDestroy
(
pArray
);
taosArrayDestroy
(
pArray
);
}
}
...
...
source/dnode/mnode/impl/test/sdb/sdbTest.cpp
浏览文件 @
c79be2da
...
@@ -910,7 +910,7 @@ TEST_F(MndTestSdb, 01_Read_Str) {
...
@@ -910,7 +910,7 @@ TEST_F(MndTestSdb, 01_Read_Str) {
int32_t
len
=
0
;
int32_t
len
=
0
;
int32_t
code
=
0
;
int32_t
code
=
0
;
code
=
sdbStartRead
(
pSdb
,
&
pReader
);
code
=
sdbStartRead
(
pSdb
,
&
pReader
,
NULL
,
NULL
,
NULL
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
code
=
sdbStartWrite
(
pSdb
,
&
pWritter
);
code
=
sdbStartWrite
(
pSdb
,
&
pWritter
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
code
,
0
);
...
...
source/dnode/mnode/sdb/inc/sdb.h
浏览文件 @
c79be2da
...
@@ -37,7 +37,7 @@ extern "C" {
...
@@ -37,7 +37,7 @@ extern "C" {
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
// clang-format on
// clang-format on
#define SDB_WRITE_DELTA
10
0
#define SDB_WRITE_DELTA
2
0
#define SDB_GET_VAL(pData, dataPos, val, pos, func, type) \
#define SDB_GET_VAL(pData, dataPos, val, pos, func, type) \
{ \
{ \
...
@@ -388,7 +388,7 @@ SSdbRow *sdbAllocRow(int32_t objSize);
...
@@ -388,7 +388,7 @@ SSdbRow *sdbAllocRow(int32_t objSize);
void
*
sdbGetRowObj
(
SSdbRow
*
pRow
);
void
*
sdbGetRowObj
(
SSdbRow
*
pRow
);
void
sdbFreeRow
(
SSdb
*
pSdb
,
SSdbRow
*
pRow
,
bool
callFunc
);
void
sdbFreeRow
(
SSdb
*
pSdb
,
SSdbRow
*
pRow
,
bool
callFunc
);
int32_t
sdbStartRead
(
SSdb
*
pSdb
,
SSdbIter
**
ppIter
);
int32_t
sdbStartRead
(
SSdb
*
pSdb
,
SSdbIter
**
ppIter
,
int64_t
*
index
,
int64_t
*
term
,
int64_t
*
config
);
int32_t
sdbStopRead
(
SSdb
*
pSdb
,
SSdbIter
*
pIter
);
int32_t
sdbStopRead
(
SSdb
*
pSdb
,
SSdbIter
*
pIter
);
int32_t
sdbDoRead
(
SSdb
*
pSdb
,
SSdbIter
*
pIter
,
void
**
ppBuf
,
int32_t
*
len
);
int32_t
sdbDoRead
(
SSdb
*
pSdb
,
SSdbIter
*
pIter
,
void
**
ppBuf
,
int32_t
*
len
);
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
c79be2da
...
@@ -161,9 +161,11 @@ static int32_t sdbCreateDir(SSdb *pSdb) {
...
@@ -161,9 +161,11 @@ static int32_t sdbCreateDir(SSdb *pSdb) {
}
}
void
sdbSetApplyInfo
(
SSdb
*
pSdb
,
int64_t
index
,
int64_t
term
,
int64_t
config
)
{
void
sdbSetApplyInfo
(
SSdb
*
pSdb
,
int64_t
index
,
int64_t
term
,
int64_t
config
)
{
mTrace
(
"mnode apply info changed, from index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
", to index:%"
PRId64
#if 1
mTrace
(
"mnode apply info changed from index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
" to index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
,
" term:%"
PRId64
" config:%"
PRId64
,
pSdb
->
applyIndex
,
pSdb
->
applyTerm
,
pSdb
->
applyConfig
,
index
,
term
,
config
);
pSdb
->
applyIndex
,
pSdb
->
applyTerm
,
pSdb
->
applyConfig
,
index
,
term
,
config
);
#endif
pSdb
->
applyIndex
=
index
;
pSdb
->
applyIndex
=
index
;
pSdb
->
applyTerm
=
term
;
pSdb
->
applyTerm
=
term
;
pSdb
->
applyConfig
=
config
;
pSdb
->
applyConfig
=
config
;
...
@@ -173,7 +175,9 @@ void sdbGetCommitInfo(SSdb *pSdb, int64_t *index, int64_t *term, int64_t *config
...
@@ -173,7 +175,9 @@ void sdbGetCommitInfo(SSdb *pSdb, int64_t *index, int64_t *term, int64_t *config
*
index
=
pSdb
->
commitIndex
;
*
index
=
pSdb
->
commitIndex
;
*
term
=
pSdb
->
commitTerm
;
*
term
=
pSdb
->
commitTerm
;
*
config
=
pSdb
->
commitConfig
;
*
config
=
pSdb
->
commitConfig
;
#if 0
mTrace("mnode current info, apply index:%" PRId64 " term:%" PRId64 " config:%" PRId64 ", commit index:%" PRId64
mTrace("mnode current info, apply index:%" PRId64 " term:%" PRId64 " config:%" PRId64 ", commit index:%" PRId64
" term:%" PRId64 " config:%" PRId64,
" term:%" PRId64 " config:%" PRId64,
pSdb->applyIndex, pSdb->applyTerm, pSdb->applyConfig, *index, *term, *config);
pSdb->applyIndex, pSdb->applyTerm, pSdb->applyConfig, *index, *term, *config);
#endif
}
}
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
c79be2da
...
@@ -523,7 +523,7 @@ static void sdbCloseIter(SSdbIter *pIter) {
...
@@ -523,7 +523,7 @@ static void sdbCloseIter(SSdbIter *pIter) {
taosMemoryFree
(
pIter
);
taosMemoryFree
(
pIter
);
}
}
int32_t
sdbStartRead
(
SSdb
*
pSdb
,
SSdbIter
**
ppIter
)
{
int32_t
sdbStartRead
(
SSdb
*
pSdb
,
SSdbIter
**
ppIter
,
int64_t
*
index
,
int64_t
*
term
,
int64_t
*
config
)
{
SSdbIter
*
pIter
=
sdbCreateIter
(
pSdb
);
SSdbIter
*
pIter
=
sdbCreateIter
(
pSdb
);
if
(
pIter
==
NULL
)
return
-
1
;
if
(
pIter
==
NULL
)
return
-
1
;
...
@@ -552,6 +552,10 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter) {
...
@@ -552,6 +552,10 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter) {
}
}
*
ppIter
=
pIter
;
*
ppIter
=
pIter
;
if
(
index
!=
NULL
)
*
index
=
commitIndex
;
if
(
term
!=
NULL
)
*
term
=
commitTerm
;
if
(
config
!=
NULL
)
*
config
=
commitConfig
;
mInfo
(
"sdbiter:%p, is created to read snapshot, commit index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
" file:%s"
,
mInfo
(
"sdbiter:%p, is created to read snapshot, commit index:%"
PRId64
" term:%"
PRId64
" config:%"
PRId64
" file:%s"
,
pIter
,
commitIndex
,
commitTerm
,
commitConfig
,
pIter
->
name
);
pIter
,
commitIndex
,
commitTerm
,
commitConfig
,
pIter
->
name
);
return
0
;
return
0
;
...
...
source/dnode/snode/inc/sndInt.h
浏览文件 @
c79be2da
...
@@ -56,7 +56,6 @@ SStreamTask* sndMetaGetTask(SStreamMeta* pMeta, int32_t taskId);
...
@@ -56,7 +56,6 @@ SStreamTask* sndMetaGetTask(SStreamMeta* pMeta, int32_t taskId);
int32_t
sndMetaRemoveTask
(
SStreamMeta
*
pMeta
,
int32_t
taskId
);
int32_t
sndMetaRemoveTask
(
SStreamMeta
*
pMeta
,
int32_t
taskId
);
int32_t
sndDropTaskOfStream
(
SStreamMeta
*
pMeta
,
int64_t
streamId
);
int32_t
sndDropTaskOfStream
(
SStreamMeta
*
pMeta
,
int64_t
streamId
);
int32_t
sndStopTaskOfStream
(
SStreamMeta
*
pMeta
,
int64_t
streamId
);
int32_t
sndStopTaskOfStream
(
SStreamMeta
*
pMeta
,
int64_t
streamId
);
int32_t
sndResumeTaskOfStream
(
SStreamMeta
*
pMeta
,
int64_t
streamId
);
int32_t
sndResumeTaskOfStream
(
SStreamMeta
*
pMeta
,
int64_t
streamId
);
...
...
source/dnode/snode/src/snode.c
浏览文件 @
c79be2da
...
@@ -76,45 +76,157 @@ int32_t sndMetaRemoveTask(SStreamMeta *pMeta, int32_t taskId) {
...
@@ -76,45 +76,157 @@ int32_t sndMetaRemoveTask(SStreamMeta *pMeta, int32_t taskId) {
return
taosHashRemove
(
pMeta
->
pHash
,
&
taskId
,
sizeof
(
int32_t
));
return
taosHashRemove
(
pMeta
->
pHash
,
&
taskId
,
sizeof
(
int32_t
));
}
}
static
int32_t
sndProcessTaskExecReq
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
)
{
static
int32_t
sndProcessTaskDeployReq
(
SSnode
*
pNode
,
SRpcMsg
*
pMsg
)
{
/*SStreamExecMsgHead *pHead = pMsg->pCont;*/
SStreamMeta
*
pMeta
=
pNode
->
pMeta
;
/*int32_t taskId = pHead->streamTaskId;*/
char
*
msg
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
/*SStreamTask *pTask = sndMetaGetTask(pSnode->pMeta, taskId);*/
int32_t
msgLen
=
pMsg
->
contLen
-
sizeof
(
SMsgHead
);
/*if (pTask == NULL) {*/
/*return -1;*/
SStreamTask
*
pTask
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamTask
));
/*}*/
if
(
pTask
==
NULL
)
{
return
-
1
;
}
SDecoder
decoder
;
tDecoderInit
(
&
decoder
,
(
uint8_t
*
)
msg
,
msgLen
);
if
(
tDecodeSStreamTask
(
&
decoder
,
pTask
)
<
0
)
{
ASSERT
(
0
);
}
tDecoderClear
(
&
decoder
);
pTask
->
status
=
TASK_STATUS__IDLE
;
pTask
->
inputQueue
=
streamQueueOpen
();
pTask
->
outputQueue
=
streamQueueOpen
();
pTask
->
inputStatus
=
TASK_INPUT_STATUS__NORMAL
;
pTask
->
outputStatus
=
TASK_INPUT_STATUS__NORMAL
;
if
(
pTask
->
inputQueue
==
NULL
||
pTask
->
outputQueue
==
NULL
)
goto
FAIL
;
pTask
->
pMsgCb
=
&
pNode
->
msgCb
;
ASSERT
(
pTask
->
execType
!=
TASK_EXEC__NONE
);
ASSERT
(
pTask
->
dataScan
==
0
);
pTask
->
exec
.
executor
=
qCreateStreamExecTaskInfo
(
pTask
->
exec
.
qmsg
,
NULL
);
ASSERT
(
pTask
->
exec
.
executor
);
streamSetupTrigger
(
pTask
);
qInfo
(
"deploy stream: stream id %ld task id %d child id %d on snode"
,
pTask
->
streamId
,
pTask
->
taskId
,
pTask
->
childId
);
taosHashPut
(
pMeta
->
pHash
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
&
pTask
,
sizeof
(
void
*
));
return
0
;
FAIL:
if
(
pTask
->
inputQueue
)
streamQueueClose
(
pTask
->
inputQueue
);
if
(
pTask
->
outputQueue
)
streamQueueClose
(
pTask
->
outputQueue
);
if
(
pTask
)
taosMemoryFree
(
pTask
);
return
-
1
;
}
static
int32_t
sndProcessTaskRunReq
(
SSnode
*
pNode
,
SRpcMsg
*
pMsg
)
{
SStreamMeta
*
pMeta
=
pNode
->
pMeta
;
SStreamTaskRunReq
*
pReq
=
pMsg
->
pCont
;
int32_t
taskId
=
pReq
->
taskId
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pMeta
->
pHash
,
&
taskId
,
sizeof
(
int32_t
));
streamProcessRunReq
(
pTask
);
return
0
;
}
static
int32_t
sndProcessTaskDispatchReq
(
SSnode
*
pNode
,
SRpcMsg
*
pMsg
)
{
SStreamMeta
*
pMeta
=
pNode
->
pMeta
;
char
*
msgStr
=
pMsg
->
pCont
;
char
*
msgBody
=
POINTER_SHIFT
(
msgStr
,
sizeof
(
SMsgHead
));
int32_t
msgLen
=
pMsg
->
contLen
-
sizeof
(
SMsgHead
);
SStreamDispatchReq
req
;
SDecoder
decoder
;
tDecoderInit
(
&
decoder
,
msgBody
,
msgLen
);
tDecodeStreamDispatchReq
(
&
decoder
,
&
req
);
int32_t
taskId
=
req
.
taskId
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pMeta
->
pHash
,
&
taskId
,
sizeof
(
int32_t
));
SRpcMsg
rsp
=
{
.
info
=
pMsg
->
info
,
.
code
=
0
,
};
streamProcessDispatchReq
(
pTask
,
&
req
,
&
rsp
);
return
0
;
}
static
int32_t
sndProcessTaskRecoverReq
(
SSnode
*
pNode
,
SRpcMsg
*
pMsg
)
{
SStreamMeta
*
pMeta
=
pNode
->
pMeta
;
SStreamTaskRecoverReq
*
pReq
=
pMsg
->
pCont
;
int32_t
taskId
=
pReq
->
taskId
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pMeta
->
pHash
,
&
taskId
,
sizeof
(
int32_t
));
streamProcessRecoverReq
(
pTask
,
pReq
,
pMsg
);
return
0
;
}
static
int32_t
sndProcessTaskDispatchRsp
(
SSnode
*
pNode
,
SRpcMsg
*
pMsg
)
{
SStreamMeta
*
pMeta
=
pNode
->
pMeta
;
SStreamDispatchRsp
*
pRsp
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
int32_t
taskId
=
pRsp
->
taskId
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pMeta
->
pHash
,
&
taskId
,
sizeof
(
int32_t
));
streamProcessDispatchRsp
(
pTask
,
pRsp
);
return
0
;
}
static
int32_t
sndProcessTaskRecoverRsp
(
SSnode
*
pNode
,
SRpcMsg
*
pMsg
)
{
SStreamMeta
*
pMeta
=
pNode
->
pMeta
;
SStreamTaskRecoverRsp
*
pRsp
=
pMsg
->
pCont
;
int32_t
taskId
=
pRsp
->
taskId
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pMeta
->
pHash
,
&
taskId
,
sizeof
(
int32_t
));
streamProcessRecoverRsp
(
pTask
,
pRsp
);
return
0
;
return
0
;
}
}
void
sndProcessUMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
)
{
static
int32_t
sndProcessTaskDropReq
(
SSnode
*
pNode
,
SRpcMsg
*
pMsg
)
{
SStreamMeta
*
pMeta
=
pNode
->
pMeta
;
char
*
msg
=
pMsg
->
pCont
;
int32_t
msgLen
=
pMsg
->
contLen
;
SVDropStreamTaskReq
*
pReq
=
(
SVDropStreamTaskReq
*
)
msg
;
int32_t
code
=
taosHashRemove
(
pMeta
->
pHash
,
&
pReq
->
taskId
,
sizeof
(
int32_t
));
ASSERT
(
code
==
0
);
if
(
code
==
0
)
{
// sendrsp
}
return
code
;
}
int32_t
sndProcessUMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
)
{
// stream deploy
// stream deploy
// stream stop/resume
// stream stop/resume
// operator exec
// operator exec
if
(
pMsg
->
msgType
==
TDMT_STREAM_TASK_DEPLOY
)
{
switch
(
pMsg
->
msgType
)
{
void
*
msg
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
case
TDMT_STREAM_TASK_DEPLOY
:
SStreamTask
*
pTask
=
taosMemoryMalloc
(
sizeof
(
SStreamTask
));
return
sndProcessTaskDeployReq
(
pSnode
,
pMsg
);
if
(
pTask
==
NULL
)
{
case
TDMT_VND_STREAM_TASK_DROP
:
return
sndProcessTaskDropReq
(
pSnode
,
pMsg
);
default:
ASSERT
(
0
);
ASSERT
(
0
);
return
;
}
SDecoder
decoder
;
tDecoderInit
(
&
decoder
,
msg
,
pMsg
->
contLen
-
sizeof
(
SMsgHead
));
tDecodeSStreamTask
(
&
decoder
,
pTask
);
tDecoderClear
(
&
decoder
);
sndMetaDeployTask
(
pSnode
->
pMeta
,
pTask
);
/*} else if (pMsg->msgType == TDMT_SND_TASK_EXEC) {*/
/*sndProcessTaskExecReq(pSnode, pMsg);*/
}
else
{
ASSERT
(
0
);
}
}
return
0
;
}
}
void
sndProcessSMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
)
{
int32_t
sndProcessSMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
)
{
// operator exec
switch
(
pMsg
->
msgType
)
{
/*if (pMsg->msgType == TDMT_SND_TASK_EXEC) {*/
case
TDMT_STREAM_TASK_RUN
:
/*sndProcessTaskExecReq(pSnode, pMsg);*/
return
sndProcessTaskRunReq
(
pSnode
,
pMsg
);
/*} else {*/
case
TDMT_STREAM_TASK_DISPATCH
:
ASSERT
(
0
);
return
sndProcessTaskDispatchReq
(
pSnode
,
pMsg
);
/*}*/
case
TDMT_STREAM_TASK_RECOVER
:
return
sndProcessTaskRecoverReq
(
pSnode
,
pMsg
);
case
TDMT_STREAM_TASK_DISPATCH_RSP
:
return
sndProcessTaskDispatchRsp
(
pSnode
,
pMsg
);
case
TDMT_STREAM_TASK_RECOVER_RSP
:
return
sndProcessTaskRecoverRsp
(
pSnode
,
pMsg
);
default:
ASSERT
(
0
);
}
return
0
;
}
}
source/dnode/vnode/inc/vnode.h
浏览文件 @
c79be2da
...
@@ -116,7 +116,7 @@ typedef void *tsdbReaderT;
...
@@ -116,7 +116,7 @@ typedef void *tsdbReaderT;
#define BLOCK_LOAD_TABLE_SEQ_ORDER 2
#define BLOCK_LOAD_TABLE_SEQ_ORDER 2
#define BLOCK_LOAD_TABLE_RR_ORDER 3
#define BLOCK_LOAD_TABLE_RR_ORDER 3
tsdbReaderT
*
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableInfoGroup
,
uint64_t
qId
,
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableInfoGroup
,
uint64_t
qId
,
uint64_t
taskId
);
uint64_t
taskId
);
tsdbReaderT
tsdbQueryCacheLast
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
groupList
,
uint64_t
qId
,
tsdbReaderT
tsdbQueryCacheLast
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
groupList
,
uint64_t
qId
,
void
*
pMemRef
);
void
*
pMemRef
);
...
...
source/dnode/vnode/src/inc/sma.h
浏览文件 @
c79be2da
...
@@ -32,11 +32,12 @@ extern "C" {
...
@@ -32,11 +32,12 @@ extern "C" {
#define smaTrace(...) do { if (smaDebugFlag & DEBUG_TRACE) { taosPrintLog("SMA ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
#define smaTrace(...) do { if (smaDebugFlag & DEBUG_TRACE) { taosPrintLog("SMA ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); }} while(0)
// clang-format on
// clang-format on
typedef
struct
SSmaEnv
SSmaEnv
;
typedef
struct
SSmaEnv
SSmaEnv
;
typedef
struct
SSmaStat
SSmaStat
;
typedef
struct
SSmaStat
SSmaStat
;
typedef
struct
SSmaStatItem
SSmaStatItem
;
typedef
struct
SSmaStatItem
SSmaStatItem
;
typedef
struct
SSmaKey
SSmaKey
;
typedef
struct
SSmaKey
SSmaKey
;
typedef
struct
SRSmaInfo
SRSmaInfo
;
typedef
struct
SRSmaInfo
SRSmaInfo
;
typedef
struct
SRSmaInfoItem
SRSmaInfoItem
;
struct
SSmaEnv
{
struct
SSmaEnv
{
TdThreadRwlock
lock
;
TdThreadRwlock
lock
;
...
...
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
c79be2da
...
@@ -87,7 +87,7 @@ int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* p
...
@@ -87,7 +87,7 @@ int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* p
int
metaDropSTable
(
SMeta
*
pMeta
,
int64_t
verison
,
SVDropStbReq
*
pReq
);
int
metaDropSTable
(
SMeta
*
pMeta
,
int64_t
verison
,
SVDropStbReq
*
pReq
);
int
metaCreateTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateTbReq
*
pReq
);
int
metaCreateTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVCreateTbReq
*
pReq
);
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
);
int
metaDropTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVDropTbReq
*
pReq
,
SArray
*
tbUids
);
int
metaTtlDropTable
(
SMeta
*
pMeta
,
int64_t
ttl
,
SArray
*
tbUids
);
int
metaTtlDropTable
(
SMeta
*
pMeta
,
int64_t
ttl
,
SArray
*
tbUids
);
int
metaAlterTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pReq
,
STableMetaRsp
*
pMetaRsp
);
int
metaAlterTable
(
SMeta
*
pMeta
,
int64_t
version
,
SVAlterTbReq
*
pReq
,
STableMetaRsp
*
pMetaRsp
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
...
@@ -106,28 +106,28 @@ int32_t metaSnapshotReaderClose(SMetaSnapshotReader* pReader);
...
@@ -106,28 +106,28 @@ int32_t metaSnapshotReaderClose(SMetaSnapshotReader* pReader);
int32_t
metaSnapshotRead
(
SMetaSnapshotReader
*
pReader
,
void
**
ppData
,
uint32_t
*
nData
);
int32_t
metaSnapshotRead
(
SMetaSnapshotReader
*
pReader
,
void
**
ppData
,
uint32_t
*
nData
);
void
*
metaGetIdx
(
SMeta
*
pMeta
);
void
*
metaGetIdx
(
SMeta
*
pMeta
);
void
*
metaGetIvtIdx
(
SMeta
*
pMeta
);
void
*
metaGetIvtIdx
(
SMeta
*
pMeta
);
int
metaTtlSmaller
(
SMeta
*
pMeta
,
uint64_t
time
,
SArray
*
uidList
);
int
metaTtlSmaller
(
SMeta
*
pMeta
,
uint64_t
time
,
SArray
*
uidList
);
int32_t
metaCreateTSma
(
SMeta
*
pMeta
,
int64_t
version
,
SSmaCfg
*
pCfg
);
int32_t
metaCreateTSma
(
SMeta
*
pMeta
,
int64_t
version
,
SSmaCfg
*
pCfg
);
int32_t
metaDropTSma
(
SMeta
*
pMeta
,
int64_t
indexUid
);
int32_t
metaDropTSma
(
SMeta
*
pMeta
,
int64_t
indexUid
);
// tsdb
// tsdb
int
tsdbOpen
(
SVnode
*
pVnode
,
STsdb
**
ppTsdb
,
const
char
*
dir
,
STsdbKeepCfg
*
pKeepCfg
);
int
tsdbOpen
(
SVnode
*
pVnode
,
STsdb
**
ppTsdb
,
const
char
*
dir
,
STsdbKeepCfg
*
pKeepCfg
);
int
tsdbClose
(
STsdb
**
pTsdb
);
int
tsdbClose
(
STsdb
**
pTsdb
);
int32_t
tsdbBegin
(
STsdb
*
pTsdb
);
int32_t
tsdbBegin
(
STsdb
*
pTsdb
);
int32_t
tsdbCommit
(
STsdb
*
pTsdb
);
int32_t
tsdbCommit
(
STsdb
*
pTsdb
);
int
tsdbScanAndConvertSubmitMsg
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
);
int
tsdbScanAndConvertSubmitMsg
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
);
int
tsdbInsertData
(
STsdb
*
pTsdb
,
int64_t
version
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
);
int
tsdbInsertData
(
STsdb
*
pTsdb
,
int64_t
version
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
);
int32_t
tsdbInsertTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
SSubmitMsgIter
*
pMsgIter
,
SSubmitBlk
*
pBlock
,
int32_t
tsdbInsertTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
SSubmitMsgIter
*
pMsgIter
,
SSubmitBlk
*
pBlock
,
SSubmitBlkRsp
*
pRsp
);
SSubmitBlkRsp
*
pRsp
);
int32_t
tsdbDeleteTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
tb_uid_t
suid
,
tb_uid_t
uid
,
TSKEY
sKey
,
TSKEY
eKey
);
int32_t
tsdbDeleteTableData
(
STsdb
*
pTsdb
,
int64_t
version
,
tb_uid_t
suid
,
tb_uid_t
uid
,
TSKEY
sKey
,
TSKEY
eKey
);
tsdbReaderT
*
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableList
,
uint64_t
qId
,
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableList
,
uint64_t
qId
,
uint64_t
taskId
);
uint64_t
taskId
);
tsdbReaderT
tsdbQueryCacheLastT
(
STsdb
*
tsdb
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableList
,
uint64_t
qId
,
tsdbReaderT
tsdbQueryCacheLastT
(
STsdb
*
tsdb
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableList
,
uint64_t
qId
,
void
*
pMemRef
);
void
*
pMemRef
);
int32_t
tsdbSnapshotReaderOpen
(
STsdb
*
pTsdb
,
STsdbSnapshotReader
**
ppReader
,
int64_t
sver
,
int64_t
ever
);
int32_t
tsdbSnapshotReaderOpen
(
STsdb
*
pTsdb
,
STsdbSnapshotReader
**
ppReader
,
int64_t
sver
,
int64_t
ever
);
int32_t
tsdbSnapshotReaderClose
(
STsdbSnapshotReader
*
pReader
);
int32_t
tsdbSnapshotReaderClose
(
STsdbSnapshotReader
*
pReader
);
int32_t
tsdbSnapshotRead
(
STsdbSnapshotReader
*
pReader
,
void
**
ppData
,
uint32_t
*
nData
);
int32_t
tsdbSnapshotRead
(
STsdbSnapshotReader
*
pReader
,
void
**
ppData
,
uint32_t
*
nData
);
// tq
// tq
int
tqInit
();
int
tqInit
();
...
@@ -141,7 +141,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen);
...
@@ -141,7 +141,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen);
int32_t
tqProcessVgDeleteReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessVgDeleteReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessOffsetCommitReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessOffsetCommitReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
,
int32_t
workerId
);
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
,
int32_t
workerId
);
int32_t
tqProcessTaskDeploy
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessTaskDeploy
Req
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessTaskDropReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessTaskDropReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessStreamTrigger
(
STQ
*
pTq
,
SSubmitReq
*
data
);
int32_t
tqProcessStreamTrigger
(
STQ
*
pTq
,
SSubmitReq
*
data
);
int32_t
tqProcessTaskRunReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
int32_t
tqProcessTaskRunReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
...
@@ -262,7 +262,7 @@ struct SSma {
...
@@ -262,7 +262,7 @@ struct SSma {
#define SMA_CFG(s) (&(s)->pVnode->config)
#define SMA_CFG(s) (&(s)->pVnode->config)
#define SMA_TSDB_CFG(s) (&(s)->pVnode->config.tsdbCfg)
#define SMA_TSDB_CFG(s) (&(s)->pVnode->config.tsdbCfg)
#define SMA_RETENTION(s) ((SRetention
*)&(s)->pVnode->config.tsdbCfg.retentions)
#define SMA_RETENTION(s) ((SRetention*)&(s)->pVnode->config.tsdbCfg.retentions)
#define SMA_LOCKED(s) ((s)->locked)
#define SMA_LOCKED(s) ((s)->locked)
#define SMA_META(s) ((s)->pVnode->pMeta)
#define SMA_META(s) ((s)->pVnode->pMeta)
#define SMA_VID(s) TD_VID((s)->pVnode)
#define SMA_VID(s) TD_VID((s)->pVnode)
...
...
source/dnode/vnode/src/sma/sma.c
浏览文件 @
c79be2da
...
@@ -15,6 +15,8 @@
...
@@ -15,6 +15,8 @@
#include "sma.h"
#include "sma.h"
// functions for external invocation
// TODO: Who is responsible for resource allocate and release?
// TODO: Who is responsible for resource allocate and release?
int32_t
tdProcessTSmaInsert
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
)
{
int32_t
tdProcessTSmaInsert
(
SSma
*
pSma
,
int64_t
indexUid
,
const
char
*
msg
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
@@ -45,6 +47,9 @@ int32_t smaGetTSmaDays(SVnodeCfg* pCfg, void* pCont, uint32_t contLen, int32_t*
...
@@ -45,6 +47,9 @@ int32_t smaGetTSmaDays(SVnodeCfg* pCfg, void* pCont, uint32_t contLen, int32_t*
return
code
;
return
code
;
}
}
// functions for internal invocation
#if 0
#if 0
/**
/**
...
...
source/dnode/vnode/src/sma/smaEnv.c
浏览文件 @
c79be2da
...
@@ -208,7 +208,6 @@ int32_t tdUnLockSma(SSma *pSma) {
...
@@ -208,7 +208,6 @@ int32_t tdUnLockSma(SSma *pSma) {
int32_t
tdCheckAndInitSmaEnv
(
SSma
*
pSma
,
int8_t
smaType
)
{
int32_t
tdCheckAndInitSmaEnv
(
SSma
*
pSma
,
int8_t
smaType
)
{
SSmaEnv
*
pEnv
=
NULL
;
SSmaEnv
*
pEnv
=
NULL
;
// return if already init
switch
(
smaType
)
{
switch
(
smaType
)
{
case
TSDB_SMA_TYPE_TIME_RANGE
:
case
TSDB_SMA_TYPE_TIME_RANGE
:
if
((
pEnv
=
(
SSmaEnv
*
)
atomic_load_ptr
(
&
SMA_TSMA_ENV
(
pSma
))))
{
if
((
pEnv
=
(
SSmaEnv
*
)
atomic_load_ptr
(
&
SMA_TSMA_ENV
(
pSma
))))
{
...
@@ -244,3 +243,34 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) {
...
@@ -244,3 +243,34 @@ int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
};
};
int32_t
smaTimerInit
(
void
**
timer
,
int8_t
*
initFlag
,
const
char
*
label
)
{
int8_t
old
;
while
(
1
)
{
old
=
atomic_val_compare_exchange_8
(
initFlag
,
0
,
2
);
if
(
old
!=
2
)
break
;
}
if
(
old
==
0
)
{
*
timer
=
taosTmrInit
(
10000
,
100
,
10000
,
label
);
if
(
!
(
*
timer
))
{
atomic_store_8
(
initFlag
,
0
);
return
-
1
;
}
atomic_store_8
(
initFlag
,
1
);
}
return
0
;
}
void
smaTimerCleanUp
(
void
*
timer
,
int8_t
*
initFlag
)
{
int8_t
old
;
while
(
1
)
{
old
=
atomic_val_compare_exchange_8
(
initFlag
,
1
,
2
);
if
(
old
!=
2
)
break
;
}
if
(
old
==
1
)
{
taosTmrCleanUp
(
timer
);
atomic_store_8
(
initFlag
,
0
);
}
}
source/dnode/vnode/src/sma/smaRollup.c
浏览文件 @
c79be2da
...
@@ -14,14 +14,61 @@
...
@@ -14,14 +14,61 @@
*/
*/
#include "sma.h"
#include "sma.h"
#include "tstream.h"
static
FORCE_INLINE
int32_t
tdUidStorePut
(
STbUidStore
*
pStore
,
tb_uid_t
suid
,
tb_uid_t
*
uid
);
static
FORCE_INLINE
int32_t
tdUidStorePut
(
STbUidStore
*
pStore
,
tb_uid_t
suid
,
tb_uid_t
*
uid
);
static
FORCE_INLINE
int32_t
tdUpdateTbUidListImpl
(
SSma
*
pSma
,
tb_uid_t
*
suid
,
SArray
*
tbUids
);
static
FORCE_INLINE
int32_t
tdUpdateTbUidListImpl
(
SSma
*
pSma
,
tb_uid_t
*
suid
,
SArray
*
tbUids
);
static
FORCE_INLINE
int32_t
tdExecuteRSmaImpl
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
inputType
,
qTaskInfo_t
*
taskInfo
,
static
FORCE_INLINE
int32_t
tdExecuteRSmaImpl
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
inputType
,
SRSmaInfoItem
*
rsmaItem
,
STSchema
*
pTSchema
,
tb_uid_t
suid
,
int8_t
level
);
tb_uid_t
suid
,
int8_t
level
);
#define SET_RSMA_INFO_ITEM_PARAMS(__idx, __level) \
if (param->qmsg[__idx]) { \
pRSmaInfo->items[__idx].pRsmaInfo = pRSmaInfo; \
pRSmaInfo->items[__idx].taskInfo = qCreateStreamExecTaskInfo(param->qmsg[0], &handle); \
if (!pRSmaInfo->items[__idx].taskInfo) { \
goto _err; \
} \
pRSmaInfo->items[__idx].triggerStatus = TASK_TRIGGER_STATUS__IN_ACTIVE; \
if (param->maxdelay[__idx] < 1) { \
int64_t msInterval = \
convertTimeFromPrecisionToUnit(pRetention[__level].freq, pTsdbCfg->precision, TIME_UNIT_MILLISECOND); \
pRSmaInfo->items[__idx].maxDelay = msInterval; \
} else { \
pRSmaInfo->items[__idx].maxDelay = param->maxdelay[__idx]; \
} \
if (pRSmaInfo->items[__idx].maxDelay > TSDB_MAX_ROLLUP_MAX_DELAY) { \
pRSmaInfo->items[__idx].maxDelay = TSDB_MAX_ROLLUP_MAX_DELAY; \
} \
pRSmaInfo->items[__idx].level = TSDB_RETENTION_L##__level; \
pRSmaInfo->items[__idx].tmrHandle = taosTmrInit(10000, 100, 10000, "RSMA"); \
if (!pRSmaInfo->items[__idx].tmrHandle) { \
goto _err; \
} \
}
struct
SRSmaInfoItem
{
SRSmaInfo
*
pRsmaInfo
;
void
*
taskInfo
;
// qTaskInfo_t
void
*
tmrHandle
;
tmr_h
tmrId
;
int8_t
level
;
int8_t
tmrInitFlag
;
int8_t
triggerStatus
;
// TASK_TRIGGER_STATUS__IN_ACTIVE/TASK_TRIGGER_STATUS__ACTIVE
int32_t
maxDelay
;
};
typedef
struct
{
int64_t
suid
;
SRSmaInfoItem
*
pItem
;
SSma
*
pSma
;
STSchema
*
pTSchema
;
}
SRSmaTriggerParam
;
struct
SRSmaInfo
{
struct
SRSmaInfo
{
void
*
taskInfo
[
TSDB_RETENTION_L2
];
// qTaskInfo_t
STSchema
*
pTSchema
;
SSma
*
pSma
;
int64_t
suid
;
SRSmaInfoItem
items
[
TSDB_RETENTION_L2
];
};
};
static
FORCE_INLINE
void
tdFreeTaskHandle
(
qTaskInfo_t
*
taskHandle
)
{
static
FORCE_INLINE
void
tdFreeTaskHandle
(
qTaskInfo_t
*
taskHandle
)
{
...
@@ -33,11 +80,20 @@ static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle) {
...
@@ -33,11 +80,20 @@ static FORCE_INLINE void tdFreeTaskHandle(qTaskInfo_t *taskHandle) {
}
}
void
*
tdFreeRSmaInfo
(
SRSmaInfo
*
pInfo
)
{
void
*
tdFreeRSmaInfo
(
SRSmaInfo
*
pInfo
)
{
for
(
int32_t
i
=
0
;
i
<
TSDB_RETENTION_MAX
;
++
i
)
{
if
(
pInfo
)
{
if
(
pInfo
->
taskInfo
[
i
])
{
for
(
int32_t
i
=
0
;
i
<
TSDB_RETENTION_MAX
;
++
i
)
{
tdFreeTaskHandle
(
pInfo
->
taskInfo
[
i
]);
SRSmaInfoItem
*
pItem
=
&
pInfo
->
items
[
i
];
if
(
pItem
->
taskInfo
)
{
tdFreeTaskHandle
(
pItem
->
taskInfo
);
}
if
(
pItem
->
tmrHandle
)
{
taosTmrCleanUp
(
pItem
->
tmrHandle
);
}
}
}
taosMemoryFree
(
pInfo
->
pTSchema
);
taosMemoryFree
(
pInfo
);
}
}
return
NULL
;
return
NULL
;
}
}
...
@@ -69,20 +125,20 @@ static FORCE_INLINE int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SA
...
@@ -69,20 +125,20 @@ static FORCE_INLINE int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SA
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
if
(
pRSmaInfo
->
taskInfo
[
0
]
&&
(
qUpdateQualifiedTableId
(
pRSmaInfo
->
taskInfo
[
0
],
tbUids
,
true
)
!=
0
))
{
if
(
pRSmaInfo
->
items
[
0
].
taskInfo
&&
(
qUpdateQualifiedTableId
(
pRSmaInfo
->
items
[
0
].
taskInfo
,
tbUids
,
true
)
<
0
))
{
smaError
(
"vgId:%d, update tbUidList failed for uid:%"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
*
suid
,
terrstr
(
terrno
));
smaError
(
"vgId:%d, update tbUidList failed for uid:%"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
*
suid
,
terrstr
(
terrno
));
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
else
{
}
else
{
smaDebug
(
"vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%"
PRIi64
", uid:%"
PRIi64
,
SMA_VID
(
pSma
),
smaDebug
(
"vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%"
PRIi64
", uid:%"
PRIi64
,
SMA_VID
(
pSma
),
pRSmaInfo
->
taskInfo
[
0
]
,
*
suid
,
*
(
int64_t
*
)
taosArrayGet
(
tbUids
,
0
));
pRSmaInfo
->
items
[
0
].
taskInfo
,
*
suid
,
*
(
int64_t
*
)
taosArrayGet
(
tbUids
,
0
));
}
}
if
(
pRSmaInfo
->
taskInfo
[
1
]
&&
(
qUpdateQualifiedTableId
(
pRSmaInfo
->
taskInfo
[
1
],
tbUids
,
true
)
!=
0
))
{
if
(
pRSmaInfo
->
items
[
1
].
taskInfo
&&
(
qUpdateQualifiedTableId
(
pRSmaInfo
->
items
[
1
].
taskInfo
,
tbUids
,
true
)
<
0
))
{
smaError
(
"vgId:%d, update tbUidList failed for uid:%"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
*
suid
,
terrstr
(
terrno
));
smaError
(
"vgId:%d, update tbUidList failed for uid:%"
PRIi64
" since %s"
,
SMA_VID
(
pSma
),
*
suid
,
terrstr
(
terrno
));
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
else
{
}
else
{
smaDebug
(
"vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%"
PRIi64
", uid:%"
PRIi64
,
SMA_VID
(
pSma
),
smaDebug
(
"vgId:%d, update tbUidList succeed for qTaskInfo:%p with suid:%"
PRIi64
", uid:%"
PRIi64
,
SMA_VID
(
pSma
),
pRSmaInfo
->
taskInfo
[
1
]
,
*
suid
,
*
(
int64_t
*
)
taosArrayGet
(
tbUids
,
0
));
pRSmaInfo
->
items
[
1
].
taskInfo
,
*
suid
,
*
(
int64_t
*
)
taosArrayGet
(
tbUids
,
0
));
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -144,12 +200,12 @@ int32_t tdFetchTbUidList(SSma *pSma, STbUidStore **ppStore, tb_uid_t suid, tb_ui
...
@@ -144,12 +200,12 @@ int32_t tdFetchTbUidList(SSma *pSma, STbUidStore **ppStore, tb_uid_t suid, tb_ui
ASSERT
(
ppStore
!=
NULL
);
ASSERT
(
ppStore
!=
NULL
);
if
(
!
(
*
ppStore
))
{
if
(
!
(
*
ppStore
))
{
if
(
tdUidStoreInit
(
ppStore
)
!=
0
)
{
if
(
tdUidStoreInit
(
ppStore
)
<
0
)
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
}
}
if
(
tdUidStorePut
(
*
ppStore
,
suid
,
&
uid
)
!=
0
)
{
if
(
tdUidStorePut
(
*
ppStore
,
suid
,
&
uid
)
<
0
)
{
*
ppStore
=
tdUidStoreFree
(
*
ppStore
);
*
ppStore
=
tdUidStoreFree
(
*
ppStore
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
@@ -172,11 +228,11 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) {
...
@@ -172,11 +228,11 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
SMeta
*
pMeta
=
pVnode
->
pMeta
;
SMeta
*
pMeta
=
pVnode
->
pMeta
;
SMsgCb
*
pMsgCb
=
&
pVnode
->
msgCb
;
SMsgCb
*
pMsgCb
=
&
pVnode
->
msgCb
;
SRSmaParam
*
param
=
&
pReq
->
pRSmaParam
;
SRSmaParam
*
param
=
&
pReq
->
pRSmaParam
;
if
((
param
->
qmsg
1Len
==
0
)
&&
(
param
->
qmsg2Len
==
0
))
{
if
((
param
->
qmsg
Len
[
0
]
==
0
)
&&
(
param
->
qmsgLen
[
1
]
==
0
))
{
smaWarn
(
"vgId:%d, no qmsg1/qmsg2 for rollup stable %s %"
PRIi64
,
SMA_VID
(
pSma
),
pReq
->
name
,
pReq
->
suid
);
smaWarn
(
"vgId:%d, no qmsg1/qmsg2 for rollup stable %s %"
PRIi64
,
SMA_VID
(
pSma
),
pReq
->
name
,
pReq
->
suid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -192,10 +248,12 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) {
...
@@ -192,10 +248,12 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) {
pRSmaInfo
=
taosHashGet
(
SMA_STAT_INFO_HASH
(
pStat
),
&
pReq
->
suid
,
sizeof
(
tb_uid_t
));
pRSmaInfo
=
taosHashGet
(
SMA_STAT_INFO_HASH
(
pStat
),
&
pReq
->
suid
,
sizeof
(
tb_uid_t
));
if
(
pRSmaInfo
)
{
if
(
pRSmaInfo
)
{
ASSERT
(
0
);
// TODO: free original pRSmaInfo is exists abnormally
smaWarn
(
"vgId:%d, rsma info already exists for stb: %s, %"
PRIi64
,
SMA_VID
(
pSma
),
pReq
->
name
,
pReq
->
suid
);
smaWarn
(
"vgId:%d, rsma info already exists for stb: %s, %"
PRIi64
,
SMA_VID
(
pSma
),
pReq
->
name
,
pReq
->
suid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
// from write queue: single thead
pRSmaInfo
=
(
SRSmaInfo
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SRSmaInfo
));
pRSmaInfo
=
(
SRSmaInfo
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SRSmaInfo
));
if
(
!
pRSmaInfo
)
{
if
(
!
pRSmaInfo
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -204,9 +262,8 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) {
...
@@ -204,9 +262,8 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) {
STqReadHandle
*
pReadHandle
=
tqInitSubmitMsgScanner
(
pMeta
);
STqReadHandle
*
pReadHandle
=
tqInitSubmitMsgScanner
(
pMeta
);
if
(
!
pReadHandle
)
{
if
(
!
pReadHandle
)
{
taosMemoryFree
(
pRSmaInfo
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_FAILED
;
goto
_err
;
}
}
SReadHandle
handle
=
{
SReadHandle
handle
=
{
...
@@ -216,32 +273,33 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) {
...
@@ -216,32 +273,33 @@ int32_t tdProcessRSmaCreate(SVnode *pVnode, SVCreateStbReq *pReq) {
.
vnode
=
pVnode
,
.
vnode
=
pVnode
,
};
};
if
(
param
->
qmsg1
)
{
STSchema
*
pTSchema
=
metaGetTbTSchema
(
SMA_META
(
pSma
),
pReq
->
suid
,
-
1
);
pRSmaInfo
->
taskInfo
[
0
]
=
qCreateStreamExecTaskInfo
(
param
->
qmsg1
,
&
handle
);
if
(
!
pTSchema
)
{
if
(
!
pRSmaInfo
->
taskInfo
[
0
])
{
terrno
=
TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION
;
taosMemoryFree
(
pRSmaInfo
);
goto
_err
;
taosMemoryFree
(
pReadHandle
);
return
TSDB_CODE_FAILED
;
}
}
}
pRSmaInfo
->
pTSchema
=
pTSchema
;
pRSmaInfo
->
pSma
=
pSma
;
pRSmaInfo
->
suid
=
pReq
->
suid
;
if
(
param
->
qmsg2
)
{
SRetention
*
pRetention
=
SMA_RETENTION
(
pSma
);
pRSmaInfo
->
taskInfo
[
1
]
=
qCreateStreamExecTaskInfo
(
param
->
qmsg2
,
&
handle
);
STsdbCfg
*
pTsdbCfg
=
SMA_TSDB_CFG
(
pSma
);
if
(
!
pRSmaInfo
->
taskInfo
[
1
])
{
taosMemoryFree
(
pRSmaInfo
);
SET_RSMA_INFO_ITEM_PARAMS
(
0
,
1
);
taosMemoryFree
(
pReadHandle
);
SET_RSMA_INFO_ITEM_PARAMS
(
1
,
2
);
return
TSDB_CODE_FAILED
;
}
}
if
(
taosHashPut
(
SMA_STAT_INFO_HASH
(
pStat
),
&
pReq
->
suid
,
sizeof
(
tb_uid_t
),
&
pRSmaInfo
,
sizeof
(
pRSmaInfo
))
!=
if
(
taosHashPut
(
SMA_STAT_INFO_HASH
(
pStat
),
&
pReq
->
suid
,
sizeof
(
tb_uid_t
),
&
pRSmaInfo
,
sizeof
(
pRSmaInfo
))
!=
TSDB_CODE_SUCCESS
)
{
TSDB_CODE_SUCCESS
)
{
return
TSDB_CODE_FAILED
;
goto
_err
;
}
else
{
}
else
{
smaDebug
(
"vgId:%d, register rsma info succeed for suid:%"
PRIi64
,
SMA_VID
(
pSma
),
pReq
->
suid
);
smaDebug
(
"vgId:%d, register rsma info succeed for suid:%"
PRIi64
,
SMA_VID
(
pSma
),
pReq
->
suid
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
_err:
tdFreeRSmaInfo
(
pRSmaInfo
);
taosMemoryFree
(
pReadHandle
);
return
TSDB_CODE_FAILED
;
}
}
/**
/**
...
@@ -291,12 +349,12 @@ static int32_t tdUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid)
...
@@ -291,12 +349,12 @@ static int32_t tdUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid)
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
if
(
taosHashPut
(
pStore
->
uidHash
,
&
suid
,
sizeof
(
suid
),
&
pUidArray
,
sizeof
(
pUidArray
))
!=
0
)
{
if
(
taosHashPut
(
pStore
->
uidHash
,
&
suid
,
sizeof
(
suid
),
&
pUidArray
,
sizeof
(
pUidArray
))
<
0
)
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
}
}
}
else
{
}
else
{
if
(
taosHashPut
(
pStore
->
uidHash
,
&
suid
,
sizeof
(
suid
),
NULL
,
0
)
!=
0
)
{
if
(
taosHashPut
(
pStore
->
uidHash
,
&
suid
,
sizeof
(
suid
),
NULL
,
0
)
<
0
)
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
}
}
...
@@ -367,22 +425,15 @@ static int32_t tdFetchSubmitReqSuids(SSubmitReq *pMsg, STbUidStore *pStore) {
...
@@ -367,22 +425,15 @@ static int32_t tdFetchSubmitReqSuids(SSubmitReq *pMsg, STbUidStore *pStore) {
return
0
;
return
0
;
}
}
static
FORCE_INLINE
int32_t
tdExecuteRSmaImpl
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
inputType
,
qTaskInfo_t
*
taskInfo
,
static
int32_t
tdFetchAndSubmitRSmaResult
(
SRSmaInfoItem
*
pItem
,
int8_t
blkType
)
{
STSchema
*
pTSchema
,
tb_uid_t
suid
,
int8_t
level
)
{
SArray
*
pResult
=
NULL
;
SArray
*
pResult
=
NULL
;
SRSmaInfo
*
pRSmaInfo
=
pItem
->
pRsmaInfo
;
SSma
*
pSma
=
pRSmaInfo
->
pSma
;
if
(
!
taskInfo
)
{
smaDebug
(
"vgId:%d, no qTaskInfo to execute rsma %"
PRIi8
" task for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
level
,
suid
);
return
TSDB_CODE_SUCCESS
;
}
smaDebug
(
"vgId:%d, execute rsma %"
PRIi8
" task for qTaskInfo:%p suid:%"
PRIu64
,
SMA_VID
(
pSma
),
level
,
taskInfo
,
suid
);
qSetStreamInput
(
taskInfo
,
pMsg
,
inputType
,
true
);
while
(
1
)
{
while
(
1
)
{
SSDataBlock
*
output
=
NULL
;
SSDataBlock
*
output
=
NULL
;
uint64_t
ts
;
uint64_t
ts
;
if
(
qExecTask
(
taskInfo
,
&
output
,
&
ts
)
<
0
)
{
if
(
qExecTask
(
pItem
->
taskInfo
,
&
output
,
&
ts
)
<
0
)
{
ASSERT
(
false
);
ASSERT
(
false
);
}
}
if
(
!
output
)
{
if
(
!
output
)
{
...
@@ -402,16 +453,16 @@ static FORCE_INLINE int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int3
...
@@ -402,16 +453,16 @@ static FORCE_INLINE int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int3
if
(
taosArrayGetSize
(
pResult
)
>
0
)
{
if
(
taosArrayGetSize
(
pResult
)
>
0
)
{
#if 0
#if 0
char flag[10] = {0};
char flag[10] = {0};
snprintf(flag, 10, "level %" PRIi8, level);
snprintf(flag, 10, "level %" PRIi8,
pItem->
level);
blockDebugShowData(pResult, flag);
blockDebugShowData(pResult, flag);
#endif
#endif
STsdb
*
sinkTsdb
=
(
level
==
TSDB_RETENTION_L1
?
pSma
->
pRSmaTsdb1
:
pSma
->
pRSmaTsdb2
);
STsdb
*
sinkTsdb
=
(
pItem
->
level
==
TSDB_RETENTION_L1
?
pSma
->
pRSmaTsdb1
:
pSma
->
pRSmaTsdb2
);
SSubmitReq
*
pReq
=
NULL
;
SSubmitReq
*
pReq
=
NULL
;
if
(
buildSubmitReqFromDataBlock
(
&
pReq
,
pResult
,
p
TSchema
,
SMA_VID
(
pSma
),
suid
)
<
0
)
{
if
(
buildSubmitReqFromDataBlock
(
&
pReq
,
pResult
,
p
RSmaInfo
->
pTSchema
,
SMA_VID
(
pSma
),
pRSmaInfo
->
suid
)
<
0
)
{
taosArrayDestroy
(
pResult
);
taosArrayDestroy
(
pResult
);
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
if
(
pReq
&&
tdProcessSubmitReq
(
sinkTsdb
,
INT64_MAX
,
pReq
)
<
0
)
{
if
(
pReq
&&
tdProcessSubmitReq
(
sinkTsdb
,
INT64_MAX
,
pReq
)
<
0
)
{
taosArrayDestroy
(
pResult
);
taosArrayDestroy
(
pResult
);
taosMemoryFreeClear
(
pReq
);
taosMemoryFreeClear
(
pReq
);
...
@@ -420,10 +471,63 @@ static FORCE_INLINE int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int3
...
@@ -420,10 +471,63 @@ static FORCE_INLINE int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int3
taosMemoryFreeClear
(
pReq
);
taosMemoryFreeClear
(
pReq
);
}
else
{
}
else
{
smaDebug
(
"vgId:%d, no rsma % "
PRIi8
" data generated since %s"
,
SMA_VID
(
pSma
),
level
,
tstrerror
(
terrno
));
smaDebug
(
"vgId:%d, no rsma % "
PRIi8
" data generated since %s"
,
SMA_VID
(
pSma
),
pItem
->
level
,
tstrerror
(
terrno
));
}
if
(
blkType
==
STREAM_DATA_TYPE_SUBMIT_BLOCK
)
{
atomic_store_8
(
&
pItem
->
triggerStatus
,
TASK_TRIGGER_STATUS__ACTIVE
);
}
}
taosArrayDestroy
(
pResult
);
taosArrayDestroy
(
pResult
);
return
0
;
}
/**
* @brief trigger to get rsma result
*
* @param param
* @param tmrId
*/
static
void
rsmaTriggerByTimer
(
void
*
param
,
void
*
tmrId
)
{
// SRSmaTriggerParam *pParam = (SRSmaTriggerParam *)param;
// SRSmaInfoItem *pItem = pParam->pItem;
SRSmaInfoItem
*
pItem
=
param
;
if
(
atomic_load_8
(
&
pItem
->
triggerStatus
)
==
TASK_TRIGGER_STATUS__ACTIVE
)
{
smaTrace
(
"level %"
PRIi8
" status is active for tb suid:%"
PRIi64
,
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
SSDataBlock
dataBlock
=
{.
info
.
type
=
STREAM_GET_ALL
};
atomic_store_8
(
&
pItem
->
triggerStatus
,
TASK_TRIGGER_STATUS__IN_ACTIVE
);
qSetStreamInput
(
pItem
->
taskInfo
,
&
dataBlock
,
STREAM_DATA_TYPE_SSDATA_BLOCK
,
false
);
tdFetchAndSubmitRSmaResult
(
pItem
,
STREAM_DATA_TYPE_SSDATA_BLOCK
);
}
else
{
smaTrace
(
"level %"
PRIi8
" status is inactive for tb suid:%"
PRIi64
,
pItem
->
level
,
pItem
->
pRsmaInfo
->
suid
);
}
// taosTmrReset(rsmaTriggerByTimer, pItem->maxDelay, pItem, pItem->tmrHandle, &pItem->tmrId);
}
static
FORCE_INLINE
int32_t
tdExecuteRSmaImpl
(
SSma
*
pSma
,
const
void
*
pMsg
,
int32_t
inputType
,
SRSmaInfoItem
*
pItem
,
tb_uid_t
suid
,
int8_t
level
)
{
if
(
!
pItem
||
!
pItem
->
taskInfo
)
{
smaDebug
(
"vgId:%d, no qTaskInfo to execute rsma %"
PRIi8
" task for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
level
,
suid
);
return
TSDB_CODE_SUCCESS
;
}
smaDebug
(
"vgId:%d, execute rsma %"
PRIi8
" task for qTaskInfo:%p suid:%"
PRIu64
,
SMA_VID
(
pSma
),
level
,
pItem
->
taskInfo
,
suid
);
// inputType = STREAM_DATA_TYPE_SUBMIT_BLOCK(1)
if
(
qSetStreamInput
(
pItem
->
taskInfo
,
pMsg
,
inputType
,
true
)
<
0
)
{
smaError
(
"vgId:%d, rsma % "
PRIi8
" qSetStreamInput failed since %s"
,
SMA_VID
(
pSma
),
level
,
tstrerror
(
terrno
));
return
TSDB_CODE_FAILED
;
}
// SRSmaTriggerParam triggerParam = {.suid = suid, .pItem = pItem, .pSma = pSma, .pTSchema = pTSchema};
tdFetchAndSubmitRSmaResult
(
pItem
,
STREAM_DATA_TYPE_SUBMIT_BLOCK
);
atomic_store_8
(
&
pItem
->
triggerStatus
,
TASK_TRIGGER_STATUS__ACTIVE
);
taosTmrReset
(
rsmaTriggerByTimer
,
pItem
->
maxDelay
,
pItem
,
pItem
->
tmrHandle
,
&
pItem
->
tmrId
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -441,24 +545,18 @@ static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb
...
@@ -441,24 +545,18 @@ static int32_t tdExecuteRSma(SSma *pSma, const void *pMsg, int32_t inputType, tb
pRSmaInfo
=
taosHashGet
(
SMA_STAT_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
));
pRSmaInfo
=
taosHashGet
(
SMA_STAT_INFO_HASH
(
pStat
),
&
suid
,
sizeof
(
tb_uid_t
));
if
(
!
pRSmaInfo
||
!
(
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pRSmaInfo
))
{
if
(
!
pRSmaInfo
||
!
(
pRSmaInfo
=
*
(
SRSmaInfo
**
)
pRSmaInfo
))
{
smaDebug
(
"vgId:%d, no rsma info for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
suid
);
smaDebug
(
"vgId:%d,
return as
no rsma info for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
suid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
!
pRSmaInfo
->
taskInfo
[
0
])
{
smaDebug
(
"vgId:%d, no rsma qTaskInfo for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
suid
);
if
(
!
pRSmaInfo
->
items
[
0
].
taskInfo
)
{
smaDebug
(
"vgId:%d, return as no rsma qTaskInfo for suid:%"
PRIu64
,
SMA_VID
(
pSma
),
suid
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
if
(
inputType
==
STREAM_DATA_TYPE_SUBMIT_BLOCK
)
{
if
(
inputType
==
STREAM_DATA_TYPE_SUBMIT_BLOCK
)
{
// TODO: cache STSchema
tdExecuteRSmaImpl
(
pSma
,
pMsg
,
inputType
,
&
pRSmaInfo
->
items
[
0
],
suid
,
TSDB_RETENTION_L1
);
STSchema
*
pTSchema
=
metaGetTbTSchema
(
SMA_META
(
pSma
),
suid
,
-
1
);
tdExecuteRSmaImpl
(
pSma
,
pMsg
,
inputType
,
&
pRSmaInfo
->
items
[
1
],
suid
,
TSDB_RETENTION_L2
);
if
(
!
pTSchema
)
{
terrno
=
TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION
;
return
TSDB_CODE_FAILED
;
}
tdExecuteRSmaImpl
(
pSma
,
pMsg
,
inputType
,
pRSmaInfo
->
taskInfo
[
0
],
pTSchema
,
suid
,
TSDB_RETENTION_L1
);
tdExecuteRSmaImpl
(
pSma
,
pMsg
,
inputType
,
pRSmaInfo
->
taskInfo
[
1
],
pTSchema
,
suid
,
TSDB_RETENTION_L2
);
taosMemoryFree
(
pTSchema
);
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
c79be2da
...
@@ -125,10 +125,10 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -125,10 +125,10 @@ int32_t tqProcessOffsetCommitReq(STQ* pTq, char* msg, int32_t msgLen) {
if
(
offset
.
type
==
TMQ_OFFSET__SNAPSHOT
)
{
if
(
offset
.
type
==
TMQ_OFFSET__SNAPSHOT
)
{
tqDebug
(
"receive offset commit msg to %s on vg %d, offset(type:snapshot) uid: %ld, ts: %ld"
,
offset
.
subKey
,
tqDebug
(
"receive offset commit msg to %s on vg %d, offset(type:snapshot) uid: %ld, ts: %ld"
,
offset
.
subKey
,
pTq
->
pVnode
->
config
.
vgId
,
offset
.
uid
,
offset
.
ts
);
TD_VID
(
pTq
->
pVnode
)
,
offset
.
uid
,
offset
.
ts
);
}
else
if
(
offset
.
type
==
TMQ_OFFSET__LOG
)
{
}
else
if
(
offset
.
type
==
TMQ_OFFSET__LOG
)
{
tqDebug
(
"receive offset commit msg to %s on vg %d, offset(type:log) version: %ld"
,
offset
.
subKey
,
tqDebug
(
"receive offset commit msg to %s on vg %d, offset(type:log) version: %ld"
,
offset
.
subKey
,
pTq
->
pVnode
->
config
.
vgId
,
offset
.
version
);
TD_VID
(
pTq
->
pVnode
)
,
offset
.
version
);
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
@@ -159,7 +159,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -159,7 +159,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
if
(
pOffset
!=
NULL
)
{
if
(
pOffset
!=
NULL
)
{
ASSERT
(
pOffset
->
type
==
TMQ_OFFSET__LOG
);
ASSERT
(
pOffset
->
type
==
TMQ_OFFSET__LOG
);
tqDebug
(
"consumer %ld, restore offset of %s on vg %d, offset(type:log) version: %ld"
,
consumerId
,
pReq
->
subKey
,
tqDebug
(
"consumer %ld, restore offset of %s on vg %d, offset(type:log) version: %ld"
,
consumerId
,
pReq
->
subKey
,
pTq
->
pVnode
->
config
.
vgId
,
pOffset
->
version
);
TD_VID
(
pTq
->
pVnode
)
,
pOffset
->
version
);
fetchOffset
=
pOffset
->
version
+
1
;
fetchOffset
=
pOffset
->
version
+
1
;
}
else
{
}
else
{
if
(
pReq
->
currentOffset
==
TMQ_CONF__RESET_OFFSET__EARLIEAST
)
{
if
(
pReq
->
currentOffset
==
TMQ_CONF__RESET_OFFSET__EARLIEAST
)
{
...
@@ -167,13 +167,13 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -167,13 +167,13 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
}
else
if
(
pReq
->
currentOffset
==
TMQ_CONF__RESET_OFFSET__LATEST
)
{
}
else
if
(
pReq
->
currentOffset
==
TMQ_CONF__RESET_OFFSET__LATEST
)
{
fetchOffset
=
walGetCommittedVer
(
pTq
->
pWal
);
fetchOffset
=
walGetCommittedVer
(
pTq
->
pWal
);
}
else
if
(
pReq
->
currentOffset
==
TMQ_CONF__RESET_OFFSET__NONE
)
{
}
else
if
(
pReq
->
currentOffset
==
TMQ_CONF__RESET_OFFSET__NONE
)
{
tqError
(
"tmq poll: no offset committed for consumer %ld in vg %d, subkey %s"
,
consumerId
,
tqError
(
"tmq poll: no offset committed for consumer %ld in vg %d, subkey %s"
,
consumerId
,
TD_VID
(
pTq
->
pVnode
),
p
Tq
->
pVnode
->
config
.
vgId
,
p
Req
->
subKey
);
pReq
->
subKey
);
terrno
=
TSDB_CODE_TQ_NO_COMMITTED_OFFSET
;
terrno
=
TSDB_CODE_TQ_NO_COMMITTED_OFFSET
;
return
-
1
;
return
-
1
;
}
}
tqDebug
(
"consumer %ld, restore offset of %s on vg %d failed, config is %ld, set to %ld"
,
consumerId
,
pReq
->
subKey
,
tqDebug
(
"consumer %ld, restore offset of %s on vg %d failed, config is %ld, set to %ld"
,
consumerId
,
pReq
->
subKey
,
pTq
->
pVnode
->
config
.
vgId
,
pReq
->
currentOffset
,
fetchOffset
);
TD_VID
(
pTq
->
pVnode
)
,
pReq
->
currentOffset
,
fetchOffset
);
}
}
}
}
...
@@ -183,14 +183,14 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
...
@@ -183,14 +183,14 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg, int32_t workerId) {
STqHandle
*
pHandle
=
taosHashGet
(
pTq
->
handles
,
pReq
->
subKey
,
strlen
(
pReq
->
subKey
));
STqHandle
*
pHandle
=
taosHashGet
(
pTq
->
handles
,
pReq
->
subKey
,
strlen
(
pReq
->
subKey
));
/*ASSERT(pHandle);*/
/*ASSERT(pHandle);*/
if
(
pHandle
==
NULL
)
{
if
(
pHandle
==
NULL
)
{
tqError
(
"tmq poll: no consumer handle for consumer %ld in vg %d, subkey %s"
,
consumerId
,
pTq
->
pVnode
->
config
.
vgId
,
tqError
(
"tmq poll: no consumer handle for consumer %ld in vg %d, subkey %s"
,
consumerId
,
TD_VID
(
pTq
->
pVnode
)
,
pReq
->
subKey
);
pReq
->
subKey
);
return
-
1
;
return
-
1
;
}
}
if
(
pHandle
->
consumerId
!=
consumerId
)
{
if
(
pHandle
->
consumerId
!=
consumerId
)
{
tqError
(
"tmq poll: consumer handle mismatch for consumer %ld in vg %d, subkey %s, handle consumer id %ld"
,
tqError
(
"tmq poll: consumer handle mismatch for consumer %ld in vg %d, subkey %s, handle consumer id %ld"
,
consumerId
,
pTq
->
pVnode
->
config
.
vgId
,
pReq
->
subKey
,
pHandle
->
consumerId
);
consumerId
,
TD_VID
(
pTq
->
pVnode
)
,
pReq
->
subKey
,
pHandle
->
consumerId
);
return
-
1
;
return
-
1
;
}
}
...
@@ -304,7 +304,6 @@ int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -304,7 +304,6 @@ int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen) {
return
0
;
return
0
;
}
}
// TODO: persist meta into tdb
int32_t
tqProcessVgChangeReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
)
{
int32_t
tqProcessVgChangeReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
)
{
SMqRebVgReq
req
=
{
0
};
SMqRebVgReq
req
=
{
0
};
tDecodeSMqRebVgReq
(
msg
,
&
req
);
tDecodeSMqRebVgReq
(
msg
,
&
req
);
...
@@ -334,7 +333,6 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -334,7 +333,6 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
SReadHandle
handle
=
{
SReadHandle
handle
=
{
.
reader
=
pHandle
->
execHandle
.
pExecReader
[
i
],
.
reader
=
pHandle
->
execHandle
.
pExecReader
[
i
],
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
pMsgCb
=
&
pTq
->
pVnode
->
msgCb
,
};
};
pHandle
->
execHandle
.
execCol
.
task
[
i
]
=
qCreateStreamExecTaskInfo
(
pHandle
->
execHandle
.
execCol
.
qmsg
,
&
handle
);
pHandle
->
execHandle
.
execCol
.
task
[
i
]
=
qCreateStreamExecTaskInfo
(
pHandle
->
execHandle
.
execCol
.
qmsg
,
&
handle
);
ASSERT
(
pHandle
->
execHandle
.
execCol
.
task
[
i
]);
ASSERT
(
pHandle
->
execHandle
.
execCol
.
task
[
i
]);
...
@@ -346,10 +344,10 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -346,10 +344,10 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
pHandle
->
execHandle
.
execTb
.
suid
=
req
.
suid
;
pHandle
->
execHandle
.
execTb
.
suid
=
req
.
suid
;
SArray
*
tbUidList
=
taosArrayInit
(
0
,
sizeof
(
int64_t
));
SArray
*
tbUidList
=
taosArrayInit
(
0
,
sizeof
(
int64_t
));
tsdbGetCtbIdList
(
pTq
->
pVnode
->
pMeta
,
req
.
suid
,
tbUidList
);
tsdbGetCtbIdList
(
pTq
->
pVnode
->
pMeta
,
req
.
suid
,
tbUidList
);
tqDebug
(
"vg %d, tq try get suid: %ld"
,
pTq
->
pVnode
->
config
.
vgId
,
req
.
suid
);
tqDebug
(
"vg %d, tq try get suid: %ld"
,
TD_VID
(
pTq
->
pVnode
)
,
req
.
suid
);
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
tbUidList
);
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
taosArrayGetSize
(
tbUidList
);
i
++
)
{
int64_t
tbUid
=
*
(
int64_t
*
)
taosArrayGet
(
tbUidList
,
i
);
int64_t
tbUid
=
*
(
int64_t
*
)
taosArrayGet
(
tbUidList
,
i
);
tqDebug
(
"vg %d, idx %d, uid: %ld"
,
pTq
->
pVnode
->
config
.
vgId
,
i
,
tbUid
);
tqDebug
(
"vg %d, idx %d, uid: %ld"
,
TD_VID
(
pTq
->
pVnode
)
,
i
,
tbUid
);
}
}
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
5
;
i
++
)
{
tqReadHandleSetTbUidList
(
pHandle
->
execHandle
.
pExecReader
[
i
],
tbUidList
);
tqReadHandleSetTbUidList
(
pHandle
->
execHandle
.
pExecReader
[
i
],
tbUidList
);
...
@@ -374,7 +372,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -374,7 +372,7 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) {
return
0
;
return
0
;
}
}
int32_t
tqProcessTaskDeploy
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
)
{
int32_t
tqProcessTaskDeploy
Req
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
)
{
SStreamTask
*
pTask
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamTask
));
SStreamTask
*
pTask
=
taosMemoryCalloc
(
1
,
sizeof
(
SStreamTask
));
if
(
pTask
==
NULL
)
{
if
(
pTask
==
NULL
)
{
return
-
1
;
return
-
1
;
...
@@ -400,16 +398,20 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -400,16 +398,20 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
// exec
// exec
if
(
pTask
->
execType
!=
TASK_EXEC__NONE
)
{
if
(
pTask
->
execType
!=
TASK_EXEC__NONE
)
{
// expand runners
// expand runners
STqReadHandle
*
pStreamReader
=
tqInitSubmitMsgScanner
(
pTq
->
pVnode
->
pMeta
);
if
(
pTask
->
dataScan
)
{
SReadHandle
handle
=
{
STqReadHandle
*
pStreamReader
=
tqInitSubmitMsgScanner
(
pTq
->
pVnode
->
pMeta
);
.
reader
=
pStreamReader
,
SReadHandle
handle
=
{
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
reader
=
pStreamReader
,
.
pMsgCb
=
&
pTq
->
pVnode
->
msgCb
,
.
meta
=
pTq
->
pVnode
->
pMeta
,
.
vnode
=
pTq
->
pVnode
,
.
vnode
=
pTq
->
pVnode
,
};
};
pTask
->
exec
.
inputHandle
=
pStreamReader
;
/*pTask->exec.inputHandle = pStreamReader;*/
pTask
->
exec
.
executor
=
qCreateStreamExecTaskInfo
(
pTask
->
exec
.
qmsg
,
&
handle
);
pTask
->
exec
.
executor
=
qCreateStreamExecTaskInfo
(
pTask
->
exec
.
qmsg
,
&
handle
);
ASSERT
(
pTask
->
exec
.
executor
);
ASSERT
(
pTask
->
exec
.
executor
);
}
else
{
pTask
->
exec
.
executor
=
qCreateStreamExecTaskInfo
(
pTask
->
exec
.
qmsg
,
NULL
);
ASSERT
(
pTask
->
exec
.
executor
);
}
}
}
// sink
// sink
...
@@ -431,7 +433,7 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
...
@@ -431,7 +433,7 @@ int32_t tqProcessTaskDeploy(STQ* pTq, char* msg, int32_t msgLen) {
streamSetupTrigger
(
pTask
);
streamSetupTrigger
(
pTask
);
tqInfo
(
"deploy stream task id %d child id %d on vg %d"
,
pTask
->
taskId
,
pTask
->
childId
,
pTq
->
pVnode
->
config
.
vgId
);
tqInfo
(
"deploy stream task id %d child id %d on vg %d"
,
pTask
->
taskId
,
pTask
->
childId
,
TD_VID
(
pTq
->
pVnode
)
);
taosHashPut
(
pTq
->
pStreamTasks
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
&
pTask
,
sizeof
(
void
*
));
taosHashPut
(
pTq
->
pStreamTasks
,
&
pTask
->
taskId
,
sizeof
(
int32_t
),
&
pTask
,
sizeof
(
void
*
));
...
@@ -464,7 +466,7 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq) {
...
@@ -464,7 +466,7 @@ int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq) {
continue
;
continue
;
}
}
if
(
streamLaunchByWrite
(
pTask
,
pTq
->
pVnode
->
config
.
vgId
,
&
pTq
->
pVnode
->
msgCb
)
<
0
)
{
if
(
streamLaunchByWrite
(
pTask
,
TD_VID
(
pTq
->
pVnode
)
)
<
0
)
{
continue
;
continue
;
}
}
}
else
{
}
else
{
...
@@ -485,7 +487,7 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -485,7 +487,7 @@ int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg) {
SStreamTaskRunReq
*
pReq
=
pMsg
->
pCont
;
SStreamTaskRunReq
*
pReq
=
pMsg
->
pCont
;
int32_t
taskId
=
pReq
->
taskId
;
int32_t
taskId
=
pReq
->
taskId
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
stream
TaskProcessRunReq
(
pTask
,
&
pTq
->
pVnode
->
msgCb
);
stream
ProcessRunReq
(
pTask
);
return
0
;
return
0
;
}
}
...
@@ -503,7 +505,7 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -503,7 +505,7 @@ int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg) {
.
info
=
pMsg
->
info
,
.
info
=
pMsg
->
info
,
.
code
=
0
,
.
code
=
0
,
};
};
streamProcessDispatchReq
(
pTask
,
&
pTq
->
pVnode
->
msgCb
,
&
req
,
&
rsp
);
streamProcessDispatchReq
(
pTask
,
&
req
,
&
rsp
);
return
0
;
return
0
;
}
}
...
@@ -511,7 +513,7 @@ int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -511,7 +513,7 @@ int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg) {
SStreamTaskRecoverReq
*
pReq
=
pMsg
->
pCont
;
SStreamTaskRecoverReq
*
pReq
=
pMsg
->
pCont
;
int32_t
taskId
=
pReq
->
taskId
;
int32_t
taskId
=
pReq
->
taskId
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
streamProcessRecoverReq
(
pTask
,
&
pTq
->
pVnode
->
msgCb
,
pReq
,
pMsg
);
streamProcessRecoverReq
(
pTask
,
pReq
,
pMsg
);
return
0
;
return
0
;
}
}
...
@@ -519,7 +521,7 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -519,7 +521,7 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg) {
SStreamDispatchRsp
*
pRsp
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
SStreamDispatchRsp
*
pRsp
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
int32_t
taskId
=
pRsp
->
taskId
;
int32_t
taskId
=
pRsp
->
taskId
;
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
SStreamTask
*
pTask
=
*
(
SStreamTask
**
)
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
streamProcessDispatchRsp
(
pTask
,
&
pTq
->
pVnode
->
msgCb
,
pRsp
);
streamProcessDispatchRsp
(
pTask
,
pRsp
);
return
0
;
return
0
;
}
}
...
@@ -534,9 +536,9 @@ int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) {
...
@@ -534,9 +536,9 @@ int32_t tqProcessTaskRecoverRsp(STQ* pTq, SRpcMsg* pMsg) {
int32_t
tqProcessTaskDropReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
)
{
int32_t
tqProcessTaskDropReq
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
)
{
SVDropStreamTaskReq
*
pReq
=
(
SVDropStreamTaskReq
*
)
msg
;
SVDropStreamTaskReq
*
pReq
=
(
SVDropStreamTaskReq
*
)
msg
;
int32_t
code
=
taosHashRemove
(
pTq
->
pStreamTasks
,
&
pReq
->
taskId
,
sizeof
(
int32_t
));
int32_t
code
=
taosHashRemove
(
pTq
->
pStreamTasks
,
&
pReq
->
taskId
,
sizeof
(
int32_t
));
ASSERT
(
code
==
0
);
if
(
code
==
0
)
{
if
(
code
==
0
)
{
// sendrsp
// sendrsp
}
}
ASSERT
(
code
==
0
);
return
code
;
return
code
;
}
}
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
c79be2da
...
@@ -500,7 +500,7 @@ static int32_t setCurrentSchema(SVnode* pVnode, STsdbReadHandle* pTsdbReadHandle
...
@@ -500,7 +500,7 @@ static int32_t setCurrentSchema(SVnode* pVnode, STsdbReadHandle* pTsdbReadHandle
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
tsdbReaderT
*
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableList
,
uint64_t
qId
,
tsdbReaderT
tsdbReaderOpen
(
SVnode
*
pVnode
,
SQueryTableDataCond
*
pCond
,
STableListInfo
*
tableList
,
uint64_t
qId
,
uint64_t
taskId
)
{
uint64_t
taskId
)
{
STsdbReadHandle
*
pTsdbReadHandle
=
tsdbQueryTablesImpl
(
pVnode
,
pCond
,
qId
,
taskId
);
STsdbReadHandle
*
pTsdbReadHandle
=
tsdbQueryTablesImpl
(
pVnode
,
pCond
,
qId
,
taskId
);
if
(
pTsdbReadHandle
==
NULL
)
{
if
(
pTsdbReadHandle
==
NULL
)
{
...
@@ -508,7 +508,7 @@ tsdbReaderT* tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, STableLi
...
@@ -508,7 +508,7 @@ tsdbReaderT* tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, STableLi
}
}
if
(
emptyQueryTimewindow
(
pTsdbReadHandle
))
{
if
(
emptyQueryTimewindow
(
pTsdbReadHandle
))
{
return
(
tsdbReaderT
*
)
pTsdbReadHandle
;
return
(
tsdbReaderT
)
pTsdbReadHandle
;
}
}
// todo apply the lastkey of table check to avoid to load header file
// todo apply the lastkey of table check to avoid to load header file
...
...
source/dnode/vnode/src/vnd/vnodeSvr.c
浏览文件 @
c79be2da
...
@@ -106,7 +106,7 @@ int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
...
@@ -106,7 +106,7 @@ int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
int32_t
len
;
int32_t
len
;
int32_t
ret
;
int32_t
ret
;
v
Error
(
"vgId:%d, start to process write request %s, index:%"
PRId64
,
TD_VID
(
pVnode
),
TMSG_INFO
(
pMsg
->
msgType
),
v
Trace
(
"vgId:%d, start to process write request %s, index:%"
PRId64
,
TD_VID
(
pVnode
),
TMSG_INFO
(
pMsg
->
msgType
),
version
);
version
);
pVnode
->
state
.
applied
=
version
;
pVnode
->
state
.
applied
=
version
;
...
@@ -167,8 +167,8 @@ int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
...
@@ -167,8 +167,8 @@ int32_t vnodeProcessWriteReq(SVnode *pVnode, SRpcMsg *pMsg, int64_t version, SRp
}
}
break
;
break
;
case
TDMT_STREAM_TASK_DEPLOY
:
{
case
TDMT_STREAM_TASK_DEPLOY
:
{
if
(
tqProcessTaskDeploy
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
if
(
tqProcessTaskDeploy
Req
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
pMsg
->
contLen
-
sizeof
(
SMsgHead
))
<
0
)
{
pMsg
->
contLen
-
sizeof
(
SMsgHead
))
<
0
)
{
goto
_err
;
goto
_err
;
}
}
}
break
;
}
break
;
...
@@ -304,18 +304,17 @@ void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) {
...
@@ -304,18 +304,17 @@ void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) {
pMetaRsp
->
precision
=
pVnode
->
config
.
tsdbCfg
.
precision
;
pMetaRsp
->
precision
=
pVnode
->
config
.
tsdbCfg
.
precision
;
}
}
static
int32_t
vnodeProcessDropTtlTbReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
){
static
int32_t
vnodeProcessDropTtlTbReq
(
SVnode
*
pVnode
,
int64_t
version
,
void
*
pReq
,
int32_t
len
,
SRpcMsg
*
pRsp
)
{
SArray
*
tbUids
=
taosArrayInit
(
8
,
sizeof
(
int64_t
));
SArray
*
tbUids
=
taosArrayInit
(
8
,
sizeof
(
int64_t
));
if
(
tbUids
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
if
(
tbUids
==
NULL
)
return
TSDB_CODE_OUT_OF_MEMORY
;
int32_t
t
=
ntohl
(
*
(
int32_t
*
)
pReq
);
int32_t
t
=
ntohl
(
*
(
int32_t
*
)
pReq
);
vError
(
"rec ttl time:%d"
,
t
);
vError
(
"rec ttl time:%d"
,
t
);
int32_t
ret
=
metaTtlDropTable
(
pVnode
->
pMeta
,
t
,
tbUids
);
int32_t
ret
=
metaTtlDropTable
(
pVnode
->
pMeta
,
t
,
tbUids
);
if
(
ret
!=
0
)
{
if
(
ret
!=
0
)
{
goto
end
;
goto
end
;
}
}
if
(
taosArrayGetSize
(
tbUids
)
>
0
)
{
if
(
taosArrayGetSize
(
tbUids
)
>
0
)
{
tqUpdateTbUidList
(
pVnode
->
pTq
,
tbUids
,
false
);
tqUpdateTbUidList
(
pVnode
->
pTq
,
tbUids
,
false
);
}
}
...
@@ -346,7 +345,10 @@ static int32_t vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *p
...
@@ -346,7 +345,10 @@ static int32_t vnodeProcessCreateStbReq(SVnode *pVnode, int64_t version, void *p
goto
_err
;
goto
_err
;
}
}
tdProcessRSmaCreate
(
pVnode
,
&
req
);
if
(
tdProcessRSmaCreate
(
pVnode
,
&
req
)
<
0
)
{
pRsp
->
code
=
terrno
;
goto
_err
;
}
tDecoderClear
(
&
coder
);
tDecoderClear
(
&
coder
);
return
0
;
return
0
;
...
...
source/dnode/vnode/src/vnd/vnodeSync.c
浏览文件 @
c79be2da
...
@@ -119,7 +119,7 @@ static int32_t vnodeProcessAlterReplicaReq(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -119,7 +119,7 @@ static int32_t vnodeProcessAlterReplicaReq(SVnode *pVnode, SRpcMsg *pMsg) {
}
}
void
vnodeProposeMsg
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
void
vnodeProposeMsg
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
SVnode
*
pVnode
=
pInfo
->
ahandle
;
SVnode
*
pVnode
=
pInfo
->
ahandle
;
int32_t
vgId
=
pVnode
->
config
.
vgId
;
int32_t
vgId
=
pVnode
->
config
.
vgId
;
int32_t
code
=
0
;
int32_t
code
=
0
;
SRpcMsg
*
pMsg
=
NULL
;
SRpcMsg
*
pMsg
=
NULL
;
...
@@ -174,7 +174,7 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
...
@@ -174,7 +174,7 @@ void vnodeProposeMsg(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
}
}
void
vnodeApplyMsg
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
void
vnodeApplyMsg
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
SVnode
*
pVnode
=
pInfo
->
ahandle
;
SVnode
*
pVnode
=
pInfo
->
ahandle
;
int32_t
vgId
=
pVnode
->
config
.
vgId
;
int32_t
vgId
=
pVnode
->
config
.
vgId
;
int32_t
code
=
0
;
int32_t
code
=
0
;
SRpcMsg
*
pMsg
=
NULL
;
SRpcMsg
*
pMsg
=
NULL
;
...
@@ -211,21 +211,23 @@ int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -211,21 +211,23 @@ int32_t vnodeProcessSyncReq(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
pVnode
->
sync
);
SSyncNode
*
pSyncNode
=
syncNodeAcquire
(
pVnode
->
sync
);
assert
(
pSyncNode
!=
NULL
);
assert
(
pSyncNode
!=
NULL
);
ESyncState
state
=
syncGetMyRole
(
pVnode
->
sync
);
SyncTerm
currentTerm
=
syncGetMyTerm
(
pVnode
->
sync
);
SMsgHead
*
pHead
=
pMsg
->
pCont
;
SMsgHead
*
pHead
=
pMsg
->
pCont
;
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
char
logBuf
[
512
]
=
{
0
};
do
{
char
*
syncNodeStr
=
sync2SimpleStr
(
pVnode
->
sync
);
char
*
syncNodeStr
=
sync2SimpleStr
(
pVnode
->
sync
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==vnodeProcessSyncReq== msgType:%d, syncNode: %s"
,
pMsg
->
msgType
,
syncNodeStr
);
static
int64_t
vndTick
=
0
;
static
int64_t
vndTick
=
0
;
if
(
++
vndTick
%
10
==
1
)
{
STraceId
*
trace
=
&
pMsg
->
info
.
traceId
;
vGTrace
(
"vgId:%d, sync heartbeat msg:%s, %s"
,
syncGetVgId
(
pVnode
->
sync
),
TMSG_INFO
(
pMsg
->
msgType
),
syncNodeStr
);
if
(
++
vndTick
%
10
==
1
)
{
}
vGTrace
(
"sync trace msg:%s, %s"
,
TMSG_INFO
(
pMsg
->
msgType
),
syncNodeStr
);
if
(
gRaftDetailLog
)
{
}
char
logBuf
[
512
]
=
{
0
};
syncRpcMsgLog2
(
logBuf
,
pMsg
);
snprintf
(
logBuf
,
sizeof
(
logBuf
),
"==vnodeProcessSyncReq== msgType:%d, syncNode: %s"
,
pMsg
->
msgType
,
taosMemoryFree
(
syncNodeStr
);
syncNodeStr
);
syncRpcMsgLog2
(
logBuf
,
pMsg
);
}
taosMemoryFree
(
syncNodeStr
);
}
while
(
0
);
SRpcMsg
*
pRpcMsg
=
pMsg
;
SRpcMsg
*
pRpcMsg
=
pMsg
;
...
@@ -348,13 +350,13 @@ static void vnodeSyncReconfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReCon
...
@@ -348,13 +350,13 @@ static void vnodeSyncReconfig(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SReCon
}
}
static
void
vnodeSyncCommitMsg
(
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
static
void
vnodeSyncCommitMsg
(
SSyncFSM
*
pFsm
,
const
SRpcMsg
*
pMsg
,
SFsmCbMeta
cbMeta
)
{
SVnode
*
pVnode
=
pFsm
->
data
;
SVnode
*
pVnode
=
pFsm
->
data
;
SSnapshot
snapshot
=
{
0
};
SSnapshot
snapshot
=
{
0
};
SyncIndex
beginIndex
=
SYNC_INDEX_INVALID
;
SyncIndex
beginIndex
=
SYNC_INDEX_INVALID
;
char
logBuf
[
256
]
=
{
0
};
char
logBuf
[
256
]
=
{
0
};
if
(
pFsm
->
FpGetSnapshot
!=
NULL
)
{
if
(
pFsm
->
FpGetSnapshot
Info
!=
NULL
)
{
(
*
pFsm
->
FpGetSnapshot
)(
pFsm
,
&
snapshot
);
(
*
pFsm
->
FpGetSnapshot
Info
)(
pFsm
,
&
snapshot
);
beginIndex
=
snapshot
.
lastApplyIndex
;
beginIndex
=
snapshot
.
lastApplyIndex
;
}
}
...
@@ -416,7 +418,7 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
...
@@ -416,7 +418,7 @@ static SSyncFSM *vnodeSyncMakeFsm(SVnode *pVnode) {
pFsm
->
FpCommitCb
=
vnodeSyncCommitMsg
;
pFsm
->
FpCommitCb
=
vnodeSyncCommitMsg
;
pFsm
->
FpPreCommitCb
=
vnodeSyncPreCommitMsg
;
pFsm
->
FpPreCommitCb
=
vnodeSyncPreCommitMsg
;
pFsm
->
FpRollBackCb
=
vnodeSyncRollBackMsg
;
pFsm
->
FpRollBackCb
=
vnodeSyncRollBackMsg
;
pFsm
->
FpGetSnapshot
=
vnodeSyncGetSnapshot
;
pFsm
->
FpGetSnapshot
Info
=
vnodeSyncGetSnapshot
;
pFsm
->
FpRestoreFinishCb
=
NULL
;
pFsm
->
FpRestoreFinishCb
=
NULL
;
pFsm
->
FpReConfigCb
=
vnodeSyncReconfig
;
pFsm
->
FpReConfigCb
=
vnodeSyncReconfig
;
pFsm
->
FpSnapshotStartRead
=
vnodeSnapshotStartRead
;
pFsm
->
FpSnapshotStartRead
=
vnodeSnapshotStartRead
;
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
c79be2da
...
@@ -1121,6 +1121,10 @@ _return:
...
@@ -1121,6 +1121,10 @@ _return:
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
}
int32_t
catalogGetDnodeList
(
SCatalog
*
pCatalog
,
SRequestConnInfo
*
pConn
,
SArray
**
pDnodeList
)
{
return
TSDB_CODE_CTG_INVALID_INPUT
;
}
int32_t
catalogGetExpiredSTables
(
SCatalog
*
pCtg
,
SSTableVersion
**
stables
,
uint32_t
*
num
)
{
int32_t
catalogGetExpiredSTables
(
SCatalog
*
pCtg
,
SSTableVersion
**
stables
,
uint32_t
*
num
)
{
CTG_API_ENTER
();
CTG_API_ENTER
();
...
...
source/libs/command/src/command.c
浏览文件 @
c79be2da
...
@@ -131,6 +131,8 @@ static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt) { return TSDB_C
...
@@ -131,6 +131,8 @@ static int32_t execShowCreateSTable(SShowCreateTableStmt* pStmt) { return TSDB_C
static
int32_t
execAlterLocal
(
SAlterLocalStmt
*
pStmt
)
{
return
TSDB_CODE_FAILED
;
}
static
int32_t
execAlterLocal
(
SAlterLocalStmt
*
pStmt
)
{
return
TSDB_CODE_FAILED
;
}
static
int32_t
execShowLocalVariables
()
{
return
TSDB_CODE_FAILED
;
}
int32_t
qExecCommand
(
SNode
*
pStmt
,
SRetrieveTableRsp
**
pRsp
)
{
int32_t
qExecCommand
(
SNode
*
pStmt
,
SRetrieveTableRsp
**
pRsp
)
{
switch
(
nodeType
(
pStmt
))
{
switch
(
nodeType
(
pStmt
))
{
case
QUERY_NODE_DESCRIBE_STMT
:
case
QUERY_NODE_DESCRIBE_STMT
:
...
@@ -145,6 +147,8 @@ int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp) {
...
@@ -145,6 +147,8 @@ int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp) {
return
execShowCreateSTable
((
SShowCreateTableStmt
*
)
pStmt
);
return
execShowCreateSTable
((
SShowCreateTableStmt
*
)
pStmt
);
case
QUERY_NODE_ALTER_LOCAL_STMT
:
case
QUERY_NODE_ALTER_LOCAL_STMT
:
return
execAlterLocal
((
SAlterLocalStmt
*
)
pStmt
);
return
execAlterLocal
((
SAlterLocalStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT
:
return
execShowLocalVariables
();
default:
default:
break
;
break
;
}
}
...
...
source/libs/command/src/explain.c
浏览文件 @
c79be2da
...
@@ -412,6 +412,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
...
@@ -412,6 +412,7 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
QRY_ERR_RET
(
qExplainBufAppendExecInfo
(
pResNode
->
pExecInfo
,
tbuf
,
&
tlen
));
QRY_ERR_RET
(
qExplainBufAppendExecInfo
(
pResNode
->
pExecInfo
,
tbuf
,
&
tlen
));
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
}
}
EXPLAIN_ROW_APPEND
(
EXPLAIN_COLUMNS_FORMAT
,
pTblScanNode
->
scan
.
pScanCols
->
length
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_COLUMNS_FORMAT
,
pTblScanNode
->
scan
.
pScanCols
->
length
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_WIDTH_FORMAT
,
pTblScanNode
->
scan
.
node
.
pOutputDataBlockDesc
->
totalRowSize
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_WIDTH_FORMAT
,
pTblScanNode
->
scan
.
node
.
pOutputDataBlockDesc
->
totalRowSize
);
...
@@ -426,27 +427,57 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
...
@@ -426,27 +427,57 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i
EXPLAIN_ROW_NEW
(
level
+
1
,
"I/O: "
);
EXPLAIN_ROW_NEW
(
level
+
1
,
"I/O: "
);
int32_t
nodeNum
=
taosArrayGetSize
(
pResNode
->
pExecInfo
);
int32_t
nodeNum
=
taosArrayGetSize
(
pResNode
->
pExecInfo
);
for
(
int32_t
i
=
0
;
i
<
nodeNum
;
++
i
)
{
struct
STableScanAnalyzeInfo
info
=
{
0
};
int32_t
maxIndex
=
0
;
int32_t
totalRows
=
0
;
for
(
int32_t
i
=
0
;
i
<
nodeNum
;
++
i
)
{
SExplainExecInfo
*
execInfo
=
taosArrayGet
(
pResNode
->
pExecInfo
,
i
);
SExplainExecInfo
*
execInfo
=
taosArrayGet
(
pResNode
->
pExecInfo
,
i
);
STableScanAnalyzeInfo
*
pScanInfo
=
(
STableScanAnalyzeInfo
*
)
execInfo
->
verboseInfo
;
STableScanAnalyzeInfo
*
pScanInfo
=
(
STableScanAnalyzeInfo
*
)
execInfo
->
verboseInfo
;
EXPLAIN_ROW_APPEND
(
"total_blocks=%d"
,
pScanInfo
->
totalBlocks
);
info
.
totalBlocks
+=
pScanInfo
->
totalBlocks
;
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
info
.
loadBlocks
+=
pScanInfo
->
loadBlocks
;
info
.
totalRows
+=
pScanInfo
->
totalRows
;
info
.
skipBlocks
+=
pScanInfo
->
skipBlocks
;
info
.
filterTime
+=
pScanInfo
->
filterTime
;
info
.
loadBlockStatis
+=
pScanInfo
->
loadBlockStatis
;
info
.
totalCheckedRows
+=
pScanInfo
->
totalCheckedRows
;
info
.
filterOutBlocks
+=
pScanInfo
->
filterOutBlocks
;
if
(
pScanInfo
->
totalRows
>
totalRows
)
{
totalRows
=
pScanInfo
->
totalRows
;
maxIndex
=
i
;
}
}
EXPLAIN_ROW_APPEND
(
"load_blocks=%d"
,
pScanInfo
->
loadBlocks
);
EXPLAIN_ROW_APPEND
(
"total_blocks=%.1f"
,
((
double
)
info
.
totalBlocks
)
/
nodeNum
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
EXPLAIN_ROW_APPEND
(
"load_block_SMAs=%d"
,
pScanInfo
->
loadBlockStatis
);
EXPLAIN_ROW_APPEND
(
"load_blocks=%.1f"
,
((
double
)
info
.
loadBlocks
)
/
nodeNum
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
EXPLAIN_ROW_APPEND
(
"total_rows=%"
PRIu64
,
pScanInfo
->
totalRows
);
EXPLAIN_ROW_APPEND
(
"load_block_SMAs=%.1f"
,
((
double
)
info
.
loadBlockStatis
)
/
nodeNum
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
EXPLAIN_ROW_APPEND
(
"check_rows=%"
PRIu64
,
pScanInfo
->
totalCheckedRows
);
EXPLAIN_ROW_APPEND
(
"total_rows=%.1f"
,
((
double
)
info
.
totalRows
)
/
nodeNum
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
}
EXPLAIN_ROW_APPEND
(
"check_rows=%.1f"
,
((
double
)
info
.
totalCheckedRows
)
/
nodeNum
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
EXPLAIN_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
ctx
,
tbuf
,
tlen
,
level
+
1
));
//Rows out: Avg 4166.7 rows x 24 workers. Max 4187 rows (seg7) with 0.220 ms to first row, 1.738 ms to end, start offset by 1.470 ms.
SExplainExecInfo
*
execInfo
=
taosArrayGet
(
pResNode
->
pExecInfo
,
maxIndex
);
STableScanAnalyzeInfo
*
p1
=
(
STableScanAnalyzeInfo
*
)
execInfo
->
verboseInfo
;
EXPLAIN_ROW_NEW
(
level
+
1
,
" "
);
EXPLAIN_ROW_APPEND
(
"max_row_task=%d, total_rows:%"
PRId64
", ep:%s (cost=%.3f..%.3f)"
,
maxIndex
,
p1
->
totalRows
,
"tbd"
,
execInfo
->
startupCost
,
execInfo
->
totalCost
);
EXPLAIN_ROW_APPEND
(
EXPLAIN_BLANK_FORMAT
);
EXPLAIN_ROW_END
();
EXPLAIN_ROW_END
();
QRY_ERR_RET
(
qExplainResAppendRow
(
ctx
,
tbuf
,
tlen
,
level
+
1
));
QRY_ERR_RET
(
qExplainResAppendRow
(
ctx
,
tbuf
,
tlen
,
level
+
1
));
}
}
...
...
source/libs/executor/inc/executil.h
浏览文件 @
c79be2da
...
@@ -114,7 +114,7 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
...
@@ -114,7 +114,7 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
SExprInfo
*
createExprInfo
(
SNodeList
*
pNodeList
,
SNodeList
*
pGroupKeys
,
int32_t
*
numOfExprs
);
SExprInfo
*
createExprInfo
(
SNodeList
*
pNodeList
,
SNodeList
*
pGroupKeys
,
int32_t
*
numOfExprs
);
SqlFunctionCtx
*
createSqlFunctionCtx
(
SExprInfo
*
pExprInfo
,
int32_t
numOfOutput
,
int32_t
**
rowEntryInfoOffset
);
SqlFunctionCtx
*
createSqlFunctionCtx
(
SExprInfo
*
pExprInfo
,
int32_t
numOfOutput
,
int32_t
**
rowEntryInfoOffset
);
void
relocateColumnData
(
SSDataBlock
*
pBlock
,
const
SArray
*
pColMatchInfo
,
SArray
*
pCols
);
void
relocateColumnData
(
SSDataBlock
*
pBlock
,
const
SArray
*
pColMatchInfo
,
SArray
*
pCols
,
bool
outputEveryColumn
);
void
initExecTimeWindowInfo
(
SColumnInfoData
*
pColData
,
STimeWindow
*
pQueryWindow
);
void
initExecTimeWindowInfo
(
SColumnInfoData
*
pColData
,
STimeWindow
*
pQueryWindow
);
SInterval
extractIntervalInfo
(
const
STableScanPhysiNode
*
pTableScanNode
);
SInterval
extractIntervalInfo
(
const
STableScanPhysiNode
*
pTableScanNode
);
...
@@ -123,4 +123,6 @@ SColumn extractColumnFromColumnNode(SColumnNode* pColNode);
...
@@ -123,4 +123,6 @@ SColumn extractColumnFromColumnNode(SColumnNode* pColNode);
int32_t
initQueryTableDataCond
(
SQueryTableDataCond
*
pCond
,
const
STableScanPhysiNode
*
pTableScanNode
);
int32_t
initQueryTableDataCond
(
SQueryTableDataCond
*
pCond
,
const
STableScanPhysiNode
*
pTableScanNode
);
void
cleanupQueryTableDataCond
(
SQueryTableDataCond
*
pCond
);
void
cleanupQueryTableDataCond
(
SQueryTableDataCond
*
pCond
);
int32_t
convertFillType
(
int32_t
mode
);
#endif // TDENGINE_QUERYUTIL_H
#endif // TDENGINE_QUERYUTIL_H
source/libs/executor/inc/executorimpl.h
浏览文件 @
c79be2da
...
@@ -368,6 +368,8 @@ typedef struct SSysTableScanInfo {
...
@@ -368,6 +368,8 @@ typedef struct SSysTableScanInfo {
typedef
struct
SBlockDistInfo
{
typedef
struct
SBlockDistInfo
{
SSDataBlock
*
pResBlock
;
SSDataBlock
*
pResBlock
;
void
*
pHandle
;
void
*
pHandle
;
SReadHandle
readHandle
;
uint64_t
uid
;
// table uid
}
SBlockDistInfo
;
}
SBlockDistInfo
;
// todo remove this
// todo remove this
...
@@ -503,7 +505,8 @@ typedef struct SPartitionOperatorInfo {
...
@@ -503,7 +505,8 @@ typedef struct SPartitionOperatorInfo {
SDiskbasedBuf
*
pBuf
;
// query result buffer based on blocked-wised disk file
SDiskbasedBuf
*
pBuf
;
// query result buffer based on blocked-wised disk file
int32_t
rowCapacity
;
// maximum number of rows for each buffer page
int32_t
rowCapacity
;
// maximum number of rows for each buffer page
int32_t
*
columnOffset
;
// start position for each column data
int32_t
*
columnOffset
;
// start position for each column data
void
*
pGroupIter
;
// group iterator
SArray
*
sortedGroupArray
;
// SDataGroupInfo sorted by group id
int32_t
groupIndex
;
// group index
int32_t
pageIndex
;
// page index of current group
int32_t
pageIndex
;
// page index of current group
SSDataBlock
*
pUpdateRes
;
SSDataBlock
*
pUpdateRes
;
SExprSupp
scalarSup
;
SExprSupp
scalarSup
;
...
@@ -562,13 +565,14 @@ typedef struct SStreamSessionAggOperatorInfo {
...
@@ -562,13 +565,14 @@ typedef struct SStreamSessionAggOperatorInfo {
}
SStreamSessionAggOperatorInfo
;
}
SStreamSessionAggOperatorInfo
;
typedef
struct
STimeSliceOperatorInfo
{
typedef
struct
STimeSliceOperatorInfo
{
S
OptrBasicInfo
binfo
;
S
SDataBlock
*
pRes
;
STimeWindow
win
;
STimeWindow
win
;
SInterval
interval
;
SInterval
interval
;
int64_t
current
;
int64_t
current
;
SArray
*
pPrevRow
;
// SArray<SGroupValue>
SArray
*
pPrevRow
;
// SArray<SGroupValue>
SArray
*
pCols
;
// SArray<SColumn>
int32_t
fillType
;
// fill type
int32_t
fillType
;
// fill type
SColumn
tsCol
;
// primary timestamp column
SExprSupp
scalarSup
;
// scalar calculation
struct
SFillColInfo
*
pFillColInfo
;
// fill column info
struct
SFillColInfo
*
pFillColInfo
;
// fill column info
}
STimeSliceOperatorInfo
;
}
STimeSliceOperatorInfo
;
...
@@ -666,7 +670,7 @@ int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t
...
@@ -666,7 +670,7 @@ int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t
void
initBasicInfo
(
SOptrBasicInfo
*
pInfo
,
SSDataBlock
*
pBlock
);
void
initBasicInfo
(
SOptrBasicInfo
*
pInfo
,
SSDataBlock
*
pBlock
);
void
cleanupBasicInfo
(
SOptrBasicInfo
*
pInfo
);
void
cleanupBasicInfo
(
SOptrBasicInfo
*
pInfo
);
void
initExprSupp
(
SExprSupp
*
pSup
,
SExprInfo
*
pExprInfo
,
int32_t
numOfExpr
);
int32_t
initExprSupp
(
SExprSupp
*
pSup
,
SExprInfo
*
pExprInfo
,
int32_t
numOfExpr
);
void
cleanupExprSup
(
SExprSupp
*
pSup
);
void
cleanupExprSup
(
SExprSupp
*
pSup
);
int32_t
initAggInfo
(
SExprSupp
*
pSup
,
SAggSupporter
*
pAggSup
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
size_t
keyBufSize
,
int32_t
initAggInfo
(
SExprSupp
*
pSup
,
SAggSupporter
*
pAggSup
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
size_t
keyBufSize
,
const
char
*
pkey
);
const
char
*
pkey
);
...
@@ -739,7 +743,8 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo
...
@@ -739,7 +743,8 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo
SOperatorInfo
*
createGroupOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SOperatorInfo
*
createGroupOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SArray
*
pGroupColList
,
SNode
*
pCondition
,
SSDataBlock
*
pResultBlock
,
SArray
*
pGroupColList
,
SNode
*
pCondition
,
SExprInfo
*
pScalarExprInfo
,
int32_t
numOfScalarExpr
,
SExecTaskInfo
*
pTaskInfo
);
SExprInfo
*
pScalarExprInfo
,
int32_t
numOfScalarExpr
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createDataBlockInfoScanOperator
(
void
*
dataReader
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createDataBlockInfoScanOperator
(
void
*
dataReader
,
SReadHandle
*
readHandle
,
uint64_t
uid
,
SBlockDistScanPhysiNode
*
pBlockScanNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createStreamScanOperatorInfo
(
void
*
pDataReader
,
SReadHandle
*
pHandle
,
SOperatorInfo
*
createStreamScanOperatorInfo
(
void
*
pDataReader
,
SReadHandle
*
pHandle
,
STableScanPhysiNode
*
pTableScanNode
,
SExecTaskInfo
*
pTaskInfo
,
STimeWindowAggSupp
*
pTwSup
);
STableScanPhysiNode
*
pTableScanNode
,
SExecTaskInfo
*
pTaskInfo
,
STimeWindowAggSupp
*
pTwSup
);
...
@@ -752,8 +757,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
...
@@ -752,8 +757,8 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SExprInf
SOperatorInfo
*
createPartitionOperatorInfo
(
SOperatorInfo
*
downstream
,
SPartitionPhysiNode
*
pPartNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createPartitionOperatorInfo
(
SOperatorInfo
*
downstream
,
SPartitionPhysiNode
*
pPartNode
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTimeSliceOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SOperatorInfo
*
createTimeSliceOperatorInfo
(
SOperatorInfo
*
downstream
,
S
PhysiNode
*
pNode
,
/*S
ExprInfo* pExprInfo, int32_t numOfCols,
SSDataBlock
*
pResultBlock
,
const
SNodeListNode
*
pValNode
,
SExecTaskInfo
*
pTaskInfo
);
SSDataBlock* pResultBlock, const SNodeListNode* pValNode,
*/
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createMergeJoinOperatorInfo
(
SOperatorInfo
**
pDownstream
,
int32_t
numOfDownstream
,
SJoinPhysiNode
*
pJoinNode
,
SOperatorInfo
*
createMergeJoinOperatorInfo
(
SOperatorInfo
**
pDownstream
,
int32_t
numOfDownstream
,
SJoinPhysiNode
*
pJoinNode
,
SExecTaskInfo
*
pTaskInfo
);
SExecTaskInfo
*
pTaskInfo
);
...
...
source/libs/executor/src/dataDispatcher.c
浏览文件 @
c79be2da
...
@@ -75,12 +75,18 @@ static bool needCompress(const SSDataBlock* pData, int32_t numOfCols) {
...
@@ -75,12 +75,18 @@ static bool needCompress(const SSDataBlock* pData, int32_t numOfCols) {
// The length of bitmap is decided by number of rows of this data block, and the length of each column data is
// The length of bitmap is decided by number of rows of this data block, and the length of each column data is
// recorded in the first segment, next to the struct header
// recorded in the first segment, next to the struct header
static
void
toDataCacheEntry
(
SDataDispatchHandle
*
pHandle
,
const
SInputData
*
pInput
,
SDataDispatchBuf
*
pBuf
)
{
static
void
toDataCacheEntry
(
SDataDispatchHandle
*
pHandle
,
const
SInputData
*
pInput
,
SDataDispatchBuf
*
pBuf
)
{
int32_t
numOfCols
=
LIST_LENGTH
(
pHandle
->
pSchema
->
pSlots
);
int32_t
numOfCols
=
0
;
SNode
*
pNode
;
FOREACH
(
pNode
,
pHandle
->
pSchema
->
pSlots
)
{
SSlotDescNode
*
pSlotDesc
=
(
SSlotDescNode
*
)
pNode
;
if
(
pSlotDesc
->
output
)
{
++
numOfCols
;
}
}
SDataCacheEntry
*
pEntry
=
(
SDataCacheEntry
*
)
pBuf
->
pData
;
SDataCacheEntry
*
pEntry
=
(
SDataCacheEntry
*
)
pBuf
->
pData
;
pEntry
->
compressed
=
(
int8_t
)
needCompress
(
pInput
->
pData
,
numOfCols
);
pEntry
->
compressed
=
(
int8_t
)
needCompress
(
pInput
->
pData
,
numOfCols
);
pEntry
->
numOfRows
=
pInput
->
pData
->
info
.
rows
;
pEntry
->
numOfRows
=
pInput
->
pData
->
info
.
rows
;
pEntry
->
numOfCols
=
pInput
->
pData
->
info
.
numOfCols
;
pEntry
->
numOfCols
=
numOfCols
;
pEntry
->
dataLen
=
0
;
pEntry
->
dataLen
=
0
;
pBuf
->
useSize
=
sizeof
(
SDataCacheEntry
);
pBuf
->
useSize
=
sizeof
(
SDataCacheEntry
);
...
...
source/libs/executor/src/executil.c
浏览文件 @
c79be2da
...
@@ -193,9 +193,9 @@ SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) {
...
@@ -193,9 +193,9 @@ SSDataBlock* createResDataBlock(SDataBlockDescNode* pNode) {
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
idata
=
{{
0
}};
SColumnInfoData
idata
=
{{
0
}};
SSlotDescNode
*
pDescNode
=
(
SSlotDescNode
*
)
nodesListGetNode
(
pNode
->
pSlots
,
i
);
SSlotDescNode
*
pDescNode
=
(
SSlotDescNode
*
)
nodesListGetNode
(
pNode
->
pSlots
,
i
);
// if (!pDescNode->output) { // todo disable it temporarily
// if (!pDescNode->output) { // todo disable it temporarily
// continue;
// continue;
// }
// }
idata
.
info
.
type
=
pDescNode
->
dataType
.
type
;
idata
.
info
.
type
=
pDescNode
->
dataType
.
type
;
idata
.
info
.
bytes
=
pDescNode
->
dataType
.
bytes
;
idata
.
info
.
bytes
=
pDescNode
->
dataType
.
bytes
;
...
@@ -235,7 +235,7 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo
...
@@ -235,7 +235,7 @@ int32_t getTableList(void* metaHandle, SScanPhysiNode* pScanNode, STableListInfo
terrno
=
code
;
terrno
=
code
;
return
code
;
return
code
;
}
else
{
}
else
{
qDebug
(
"sucess to get tableIds, size: %d, suid: %"
PRIu64
""
,
(
int
)
taosArrayGetSize
(
res
),
tableUid
);
qDebug
(
"suc
c
ess to get tableIds, size: %d, suid: %"
PRIu64
""
,
(
int
)
taosArrayGetSize
(
res
),
tableUid
);
}
}
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
res
);
i
++
)
{
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
res
);
i
++
)
{
...
@@ -319,7 +319,14 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
...
@@ -319,7 +319,14 @@ SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNod
continue
;
continue
;
}
}
SColMatchInfo
*
info
=
taosArrayGet
(
pList
,
pNode
->
slotId
);
SColMatchInfo
*
info
=
NULL
;
for
(
int32_t
j
=
0
;
j
<
taosArrayGetSize
(
pList
);
++
j
)
{
info
=
taosArrayGet
(
pList
,
j
);
if
(
info
->
targetSlotId
==
pNode
->
slotId
)
{
break
;
}
}
if
(
pNode
->
output
)
{
if
(
pNode
->
output
)
{
(
*
numOfOutputCols
)
+=
1
;
(
*
numOfOutputCols
)
+=
1
;
}
else
{
}
else
{
...
@@ -578,14 +585,15 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
...
@@ -578,14 +585,15 @@ SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput,
}
}
// NOTE: sources columns are more than the destination SSDatablock columns.
// NOTE: sources columns are more than the destination SSDatablock columns.
void
relocateColumnData
(
SSDataBlock
*
pBlock
,
const
SArray
*
pColMatchInfo
,
SArray
*
pCols
)
{
// doFilter in table scan needs every column even its output is false
void
relocateColumnData
(
SSDataBlock
*
pBlock
,
const
SArray
*
pColMatchInfo
,
SArray
*
pCols
,
bool
outputEveryColumn
)
{
size_t
numOfSrcCols
=
taosArrayGetSize
(
pCols
);
size_t
numOfSrcCols
=
taosArrayGetSize
(
pCols
);
int32_t
i
=
0
,
j
=
0
;
int32_t
i
=
0
,
j
=
0
;
while
(
i
<
numOfSrcCols
&&
j
<
taosArrayGetSize
(
pColMatchInfo
))
{
while
(
i
<
numOfSrcCols
&&
j
<
taosArrayGetSize
(
pColMatchInfo
))
{
SColumnInfoData
*
p
=
taosArrayGet
(
pCols
,
i
);
SColumnInfoData
*
p
=
taosArrayGet
(
pCols
,
i
);
SColMatchInfo
*
pmInfo
=
taosArrayGet
(
pColMatchInfo
,
j
);
SColMatchInfo
*
pmInfo
=
taosArrayGet
(
pColMatchInfo
,
j
);
if
(
!
pmInfo
->
output
)
{
if
(
!
outputEveryColumn
&&
!
pmInfo
->
output
)
{
j
++
;
j
++
;
continue
;
continue
;
}
}
...
@@ -686,4 +694,32 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi
...
@@ -686,4 +694,32 @@ int32_t initQueryTableDataCond(SQueryTableDataCond* pCond, const STableScanPhysi
void
cleanupQueryTableDataCond
(
SQueryTableDataCond
*
pCond
)
{
void
cleanupQueryTableDataCond
(
SQueryTableDataCond
*
pCond
)
{
taosMemoryFree
(
pCond
->
twindows
);
taosMemoryFree
(
pCond
->
twindows
);
taosMemoryFree
(
pCond
->
colList
);
taosMemoryFree
(
pCond
->
colList
);
}
}
\ No newline at end of file
int32_t
convertFillType
(
int32_t
mode
)
{
int32_t
type
=
TSDB_FILL_NONE
;
switch
(
mode
)
{
case
FILL_MODE_PREV
:
type
=
TSDB_FILL_PREV
;
break
;
case
FILL_MODE_NONE
:
type
=
TSDB_FILL_NONE
;
break
;
case
FILL_MODE_NULL
:
type
=
TSDB_FILL_NULL
;
break
;
case
FILL_MODE_NEXT
:
type
=
TSDB_FILL_NEXT
;
break
;
case
FILL_MODE_VALUE
:
type
=
TSDB_FILL_SET_VALUE
;
break
;
case
FILL_MODE_LINEAR
:
type
=
TSDB_FILL_LINEAR
;
break
;
default:
type
=
TSDB_FILL_NONE
;
}
return
type
;
}
source/libs/executor/src/executor.c
浏览文件 @
c79be2da
...
@@ -41,12 +41,18 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
...
@@ -41,12 +41,18 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
pInfo
->
assignBlockUid
=
assignUid
;
pInfo
->
assignBlockUid
=
assignUid
;
// the block type can not be changed in the streamscan operators
// the block type can not be changed in the streamscan operators
#if 0
if (pInfo->blockType == 0) {
if (pInfo->blockType == 0) {
pInfo->blockType = type;
pInfo->blockType = type;
} else if (pInfo->blockType != type) {
} else if (pInfo->blockType != type) {
ASSERT(0);
ASSERT(0);
return TSDB_CODE_QRY_APP_ERROR;
return TSDB_CODE_QRY_APP_ERROR;
}
}
#endif
// rollup sma, the same qTaskInfo is used to insert data by SubmitReq and fetch result by SSDataBlock
if
(
pInfo
->
blockType
!=
type
)
{
pInfo
->
blockType
=
type
;
}
if
(
type
==
STREAM_DATA_TYPE_SUBMIT_BLOCK
)
{
if
(
type
==
STREAM_DATA_TYPE_SUBMIT_BLOCK
)
{
if
(
tqReadHandleSetMsg
(
pInfo
->
streamBlockReader
,
input
,
0
)
<
0
)
{
if
(
tqReadHandleSetMsg
(
pInfo
->
streamBlockReader
,
input
,
0
)
<
0
)
{
...
@@ -99,7 +105,7 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO
...
@@ -99,7 +105,7 @@ int32_t qSetMultiStreamInput(qTaskInfo_t tinfo, const void* pBlocks, size_t numO
}
}
qTaskInfo_t
qCreateStreamExecTaskInfo
(
void
*
msg
,
void
*
streamReadHandle
)
{
qTaskInfo_t
qCreateStreamExecTaskInfo
(
void
*
msg
,
void
*
streamReadHandle
)
{
if
(
msg
==
NULL
||
streamReadHandle
==
NULL
)
{
if
(
msg
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
...
source/libs/executor/src/executorMain.c
浏览文件 @
c79be2da
...
@@ -13,10 +13,10 @@
...
@@ -13,10 +13,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "os.h"
#include "tref.h"
#include "dataSinkMgt.h"
#include "dataSinkMgt.h"
#include "os.h"
#include "tmsg.h"
#include "tmsg.h"
#include "tref.h"
#include "tudf.h"
#include "tudf.h"
#include "executor.h"
#include "executor.h"
...
@@ -24,15 +24,13 @@
...
@@ -24,15 +24,13 @@
#include "query.h"
#include "query.h"
static
TdThreadOnce
initPoolOnce
=
PTHREAD_ONCE_INIT
;
static
TdThreadOnce
initPoolOnce
=
PTHREAD_ONCE_INIT
;
int32_t
exchangeObjRefPool
=
-
1
;
int32_t
exchangeObjRefPool
=
-
1
;
static
void
initRefPool
()
{
static
void
initRefPool
()
{
exchangeObjRefPool
=
taosOpenRef
(
1024
,
doDestroyExchangeOperatorInfo
);
}
exchangeObjRefPool
=
taosOpenRef
(
1024
,
doDestroyExchangeOperatorInfo
);
}
int32_t
qCreateExecTask
(
SReadHandle
*
readHandle
,
int32_t
vgId
,
uint64_t
taskId
,
SSubplan
*
pSubplan
,
int32_t
qCreateExecTask
(
SReadHandle
*
readHandle
,
int32_t
vgId
,
uint64_t
taskId
,
SSubplan
*
pSubplan
,
qTaskInfo_t
*
pTaskInfo
,
DataSinkHandle
*
handle
,
const
char
*
sql
,
EOPTR_EXEC_MODEL
model
)
{
qTaskInfo_t
*
pTaskInfo
,
DataSinkHandle
*
handle
,
const
char
*
sql
,
EOPTR_EXEC_MODEL
model
)
{
assert
(
readHandle
!=
NULL
&&
pSubplan
!=
NULL
);
assert
(
pSubplan
!=
NULL
);
SExecTaskInfo
**
pTask
=
(
SExecTaskInfo
**
)
pTaskInfo
;
SExecTaskInfo
**
pTask
=
(
SExecTaskInfo
**
)
pTaskInfo
;
taosThreadOnce
(
&
initPoolOnce
,
initRefPool
);
taosThreadOnce
(
&
initPoolOnce
,
initRefPool
);
...
@@ -47,57 +45,57 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
...
@@ -47,57 +45,57 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
goto
_error
;
}
}
if
(
handle
)
{
if
(
handle
)
{
void
*
pSinkParam
=
NULL
;
void
*
pSinkParam
=
NULL
;
code
=
createDataSinkParam
(
pSubplan
->
pDataSink
,
&
pSinkParam
,
pTaskInfo
);
code
=
createDataSinkParam
(
pSubplan
->
pDataSink
,
&
pSinkParam
,
pTaskInfo
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
goto
_error
;
}
}
code
=
dsCreateDataSinker
(
pSubplan
->
pDataSink
,
handle
,
pSinkParam
);
code
=
dsCreateDataSinker
(
pSubplan
->
pDataSink
,
handle
,
pSinkParam
);
}
}
_error:
_error:
// if failed to add ref for all tables in this query, abort current query
// if failed to add ref for all tables in this query, abort current query
return
code
;
return
code
;
}
}
#ifdef TEST_IMPL
#ifdef TEST_IMPL
// wait moment
// wait moment
int
waitMoment
(
SQInfo
*
pQInfo
){
int
waitMoment
(
SQInfo
*
pQInfo
)
{
if
(
pQInfo
->
sql
)
{
if
(
pQInfo
->
sql
)
{
int
ms
=
0
;
int
ms
=
0
;
char
*
pcnt
=
strstr
(
pQInfo
->
sql
,
" count(*)"
);
char
*
pcnt
=
strstr
(
pQInfo
->
sql
,
" count(*)"
);
if
(
pcnt
)
return
0
;
if
(
pcnt
)
return
0
;
char
*
pos
=
strstr
(
pQInfo
->
sql
,
" t_"
);
char
*
pos
=
strstr
(
pQInfo
->
sql
,
" t_"
);
if
(
pos
)
{
if
(
pos
)
{
pos
+=
3
;
pos
+=
3
;
ms
=
atoi
(
pos
);
ms
=
atoi
(
pos
);
while
(
*
pos
>=
'0'
&&
*
pos
<=
'9'
)
{
while
(
*
pos
>=
'0'
&&
*
pos
<=
'9'
)
{
pos
++
;
pos
++
;
}
}
char
unit_char
=
*
pos
;
char
unit_char
=
*
pos
;
if
(
unit_char
==
'h'
)
{
if
(
unit_char
==
'h'
)
{
ms
*=
3600
*
1000
;
ms
*=
3600
*
1000
;
}
else
if
(
unit_char
==
'm'
)
{
}
else
if
(
unit_char
==
'm'
)
{
ms
*=
60
*
1000
;
ms
*=
60
*
1000
;
}
else
if
(
unit_char
==
's'
)
{
}
else
if
(
unit_char
==
's'
)
{
ms
*=
1000
;
ms
*=
1000
;
}
}
}
}
if
(
ms
==
0
)
return
0
;
if
(
ms
==
0
)
return
0
;
printf
(
"test wait sleep %dms. sql=%s ...
\n
"
,
ms
,
pQInfo
->
sql
);
printf
(
"test wait sleep %dms. sql=%s ...
\n
"
,
ms
,
pQInfo
->
sql
);
if
(
ms
<
1000
)
{
if
(
ms
<
1000
)
{
taosMsleep
(
ms
);
taosMsleep
(
ms
);
}
else
{
}
else
{
int
used_ms
=
0
;
int
used_ms
=
0
;
while
(
used_ms
<
ms
)
{
while
(
used_ms
<
ms
)
{
taosMsleep
(
1000
);
taosMsleep
(
1000
);
used_ms
+=
1000
;
used_ms
+=
1000
;
if
(
isTaskKilled
(
pQInfo
))
{
if
(
isTaskKilled
(
pQInfo
))
{
printf
(
"test check query is canceled, sleep break.%s
\n
"
,
pQInfo
->
sql
);
printf
(
"test check query is canceled, sleep break.%s
\n
"
,
pQInfo
->
sql
);
break
;
break
;
}
}
...
@@ -108,15 +106,14 @@ int waitMoment(SQInfo* pQInfo){
...
@@ -108,15 +106,14 @@ int waitMoment(SQInfo* pQInfo){
}
}
#endif
#endif
int32_t
qExecTask
(
qTaskInfo_t
tinfo
,
SSDataBlock
**
pRes
,
uint64_t
*
useconds
)
{
int32_t
qExecTask
(
qTaskInfo_t
tinfo
,
SSDataBlock
**
pRes
,
uint64_t
*
useconds
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
int64_t
threadId
=
taosGetSelfPthreadId
();
int64_t
threadId
=
taosGetSelfPthreadId
();
*
pRes
=
NULL
;
*
pRes
=
NULL
;
int64_t
curOwner
=
0
;
int64_t
curOwner
=
0
;
if
((
curOwner
=
atomic_val_compare_exchange_64
(
&
pTaskInfo
->
owner
,
0
,
threadId
))
!=
0
)
{
if
((
curOwner
=
atomic_val_compare_exchange_64
(
&
pTaskInfo
->
owner
,
0
,
threadId
))
!=
0
)
{
qError
(
"%s-%p execTask is now executed by thread:%p"
,
GET_TASKID
(
pTaskInfo
),
pTaskInfo
,
qError
(
"%s-%p execTask is now executed by thread:%p"
,
GET_TASKID
(
pTaskInfo
),
pTaskInfo
,
(
void
*
)
curOwner
);
(
void
*
)
curOwner
);
pTaskInfo
->
code
=
TSDB_CODE_QRY_IN_EXEC
;
pTaskInfo
->
code
=
TSDB_CODE_QRY_IN_EXEC
;
return
pTaskInfo
->
code
;
return
pTaskInfo
->
code
;
}
}
...
@@ -152,18 +149,18 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
...
@@ -152,18 +149,18 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) {
cleanUpUdfs
();
cleanUpUdfs
();
int32_t
current
=
(
*
pRes
!=
NULL
)
?
(
*
pRes
)
->
info
.
rows
:
0
;
int32_t
current
=
(
*
pRes
!=
NULL
)
?
(
*
pRes
)
->
info
.
rows
:
0
;
uint64_t
total
=
pTaskInfo
->
pRoot
->
resultInfo
.
totalRows
;
uint64_t
total
=
pTaskInfo
->
pRoot
->
resultInfo
.
totalRows
;
qDebug
(
"%s task suspended, %d rows returned, total:%"
PRId64
" rows, in sinkNode:%d, elapsed:%.2f ms"
,
qDebug
(
"%s task suspended, %d rows returned, total:%"
PRId64
" rows, in sinkNode:%d, elapsed:%.2f ms"
,
GET_TASKID
(
pTaskInfo
),
current
,
total
,
0
,
el
/
1000
.
0
);
GET_TASKID
(
pTaskInfo
),
current
,
total
,
0
,
el
/
1000
.
0
);
atomic_store_64
(
&
pTaskInfo
->
owner
,
0
);
atomic_store_64
(
&
pTaskInfo
->
owner
,
0
);
return
pTaskInfo
->
code
;
return
pTaskInfo
->
code
;
}
}
int32_t
qKillTask
(
qTaskInfo_t
qinfo
)
{
int32_t
qKillTask
(
qTaskInfo_t
qinfo
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qinfo
;
if
(
pTaskInfo
==
NULL
)
{
if
(
pTaskInfo
==
NULL
)
{
return
TSDB_CODE_QRY_INVALID_QHANDLE
;
return
TSDB_CODE_QRY_INVALID_QHANDLE
;
...
@@ -182,7 +179,7 @@ int32_t qKillTask(qTaskInfo_t qinfo) {
...
@@ -182,7 +179,7 @@ int32_t qKillTask(qTaskInfo_t qinfo) {
}
}
int32_t
qAsyncKillTask
(
qTaskInfo_t
qinfo
)
{
int32_t
qAsyncKillTask
(
qTaskInfo_t
qinfo
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qinfo
;
if
(
pTaskInfo
==
NULL
)
{
if
(
pTaskInfo
==
NULL
)
{
return
TSDB_CODE_QRY_INVALID_QHANDLE
;
return
TSDB_CODE_QRY_INVALID_QHANDLE
;
...
@@ -195,7 +192,7 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo) {
...
@@ -195,7 +192,7 @@ int32_t qAsyncKillTask(qTaskInfo_t qinfo) {
}
}
int32_t
qIsTaskCompleted
(
qTaskInfo_t
qinfo
)
{
int32_t
qIsTaskCompleted
(
qTaskInfo_t
qinfo
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qinfo
;
if
(
pTaskInfo
==
NULL
)
{
if
(
pTaskInfo
==
NULL
)
{
return
TSDB_CODE_QRY_INVALID_QHANDLE
;
return
TSDB_CODE_QRY_INVALID_QHANDLE
;
...
@@ -205,18 +202,18 @@ int32_t qIsTaskCompleted(qTaskInfo_t qinfo) {
...
@@ -205,18 +202,18 @@ int32_t qIsTaskCompleted(qTaskInfo_t qinfo) {
}
}
void
qDestroyTask
(
qTaskInfo_t
qTaskHandle
)
{
void
qDestroyTask
(
qTaskInfo_t
qTaskHandle
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qTaskHandle
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
qTaskHandle
;
qDebug
(
"%s execTask completed, numOfRows:%"
PRId64
,
GET_TASKID
(
pTaskInfo
),
pTaskInfo
->
pRoot
->
resultInfo
.
totalRows
);
qDebug
(
"%s execTask completed, numOfRows:%"
PRId64
,
GET_TASKID
(
pTaskInfo
),
pTaskInfo
->
pRoot
->
resultInfo
.
totalRows
);
queryCostStatis
(
pTaskInfo
);
// print the query cost summary
queryCostStatis
(
pTaskInfo
);
// print the query cost summary
doDestroyTask
(
pTaskInfo
);
doDestroyTask
(
pTaskInfo
);
}
}
int32_t
qGetExplainExecInfo
(
qTaskInfo_t
tinfo
,
int32_t
*
resNum
,
SExplainExecInfo
**
pRes
)
{
int32_t
qGetExplainExecInfo
(
qTaskInfo_t
tinfo
,
int32_t
*
resNum
,
SExplainExecInfo
**
pRes
)
{
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
int32_t
capacity
=
0
;
int32_t
capacity
=
0
;
return
getOperatorExplainExecInfo
(
pTaskInfo
->
pRoot
,
pRes
,
&
capacity
,
resNum
);
return
getOperatorExplainExecInfo
(
pTaskInfo
->
pRoot
,
pRes
,
&
capacity
,
resNum
);
}
}
int32_t
qSerializeTaskStatus
(
qTaskInfo_t
tinfo
,
char
**
pOutput
,
int32_t
*
len
)
{
int32_t
qSerializeTaskStatus
(
qTaskInfo_t
tinfo
,
char
**
pOutput
,
int32_t
*
len
)
{
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/executor/src/groupoperator.c
浏览文件 @
c79be2da
...
@@ -387,11 +387,12 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
...
@@ -387,11 +387,12 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
pInfo
->
pGroupCols
=
pGroupColList
;
pInfo
->
pGroupCols
=
pGroupColList
;
pInfo
->
pCondition
=
pCondition
;
pInfo
->
pCondition
=
pCondition
;
pInfo
->
scalarSup
.
pExprInfo
=
pScalarExprInfo
;
int32_t
code
=
initExprSupp
(
&
pInfo
->
scalarSup
,
pScalarExprInfo
,
numOfScalarExpr
);
pInfo
->
scalarSup
.
numOfExprs
=
numOfScalarExpr
;
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
pInfo
->
scalarSup
.
pCtx
=
createSqlFunctionCtx
(
pScalarExprInfo
,
numOfScalarExpr
,
&
pInfo
->
scalarSup
.
rowEntryInfoOffset
);
goto
_error
;
}
int32_t
code
=
initGroupOptrInfo
(
&
pInfo
->
pGroupColVals
,
&
pInfo
->
groupKeyLen
,
&
pInfo
->
keyBuf
,
pGroupColList
);
code
=
initGroupOptrInfo
(
&
pInfo
->
pGroupColVals
,
&
pInfo
->
groupKeyLen
,
&
pInfo
->
keyBuf
,
pGroupColList
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
goto
_error
;
}
}
...
@@ -586,24 +587,30 @@ static void clearPartitionOperator(SPartitionOperatorInfo* pInfo) {
...
@@ -586,24 +587,30 @@ static void clearPartitionOperator(SPartitionOperatorInfo* pInfo) {
while
(
(
ite
=
taosHashIterate
(
pInfo
->
pGroupSet
,
ite
))
!=
NULL
)
{
while
(
(
ite
=
taosHashIterate
(
pInfo
->
pGroupSet
,
ite
))
!=
NULL
)
{
taosArrayDestroy
(
((
SDataGroupInfo
*
)
ite
)
->
pPageList
);
taosArrayDestroy
(
((
SDataGroupInfo
*
)
ite
)
->
pPageList
);
}
}
taos
HashClear
(
pInfo
->
pGroupSet
);
taos
ArrayClear
(
pInfo
->
sortedGroupArray
);
clearDiskbasedBuf
(
pInfo
->
pBuf
);
clearDiskbasedBuf
(
pInfo
->
pBuf
);
}
}
static
int
compareDataGroupInfo
(
const
void
*
group1
,
const
void
*
group2
)
{
const
SDataGroupInfo
*
pGroupInfo1
=
group1
;
const
SDataGroupInfo
*
pGroupInfo2
=
group2
;
return
pGroupInfo1
->
groupId
-
pGroupInfo2
->
groupId
;
}
static
SSDataBlock
*
buildPartitionResult
(
SOperatorInfo
*
pOperator
)
{
static
SSDataBlock
*
buildPartitionResult
(
SOperatorInfo
*
pOperator
)
{
SPartitionOperatorInfo
*
pInfo
=
pOperator
->
info
;
SPartitionOperatorInfo
*
pInfo
=
pOperator
->
info
;
SDataGroupInfo
*
pGroupInfo
=
pInfo
->
pGroupIter
;
SDataGroupInfo
*
pGroupInfo
=
(
pInfo
->
groupIndex
!=
-
1
)
?
taosArrayGet
(
pInfo
->
sortedGroupArray
,
pInfo
->
groupIndex
)
:
NULL
;
if
(
pInfo
->
pGroupIter
==
NULL
||
pInfo
->
pageIndex
>=
taosArrayGetSize
(
pGroupInfo
->
pPageList
))
{
if
(
pInfo
->
groupIndex
==
-
1
||
pInfo
->
pageIndex
>=
taosArrayGetSize
(
pGroupInfo
->
pPageList
))
{
// try next group data
// try next group data
pInfo
->
pGroupIter
=
taosHashIterate
(
pInfo
->
pGroupSet
,
pInfo
->
pGroupIter
)
;
++
pInfo
->
groupIndex
;
if
(
pInfo
->
pGroupIter
==
NULL
)
{
if
(
pInfo
->
groupIndex
>=
taosArrayGetSize
(
pInfo
->
sortedGroupArray
)
)
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
clearPartitionOperator
(
pInfo
);
clearPartitionOperator
(
pInfo
);
return
NULL
;
return
NULL
;
}
}
pGroupInfo
=
pInfo
->
pGroupIter
;
pGroupInfo
=
taosArrayGet
(
pInfo
->
sortedGroupArray
,
pInfo
->
groupIndex
)
;
pInfo
->
pageIndex
=
0
;
pInfo
->
pageIndex
=
0
;
}
}
...
@@ -657,6 +664,20 @@ static SSDataBlock* hashPartition(SOperatorInfo* pOperator) {
...
@@ -657,6 +664,20 @@ static SSDataBlock* hashPartition(SOperatorInfo* pOperator) {
doHashPartition
(
pOperator
,
pBlock
);
doHashPartition
(
pOperator
,
pBlock
);
}
}
SArray
*
groupArray
=
taosArrayInit
(
taosHashGetSize
(
pInfo
->
pGroupSet
),
sizeof
(
SDataGroupInfo
));
void
*
pGroupIter
=
NULL
;
pGroupIter
=
taosHashIterate
(
pInfo
->
pGroupSet
,
NULL
);
while
(
pGroupIter
!=
NULL
)
{
SDataGroupInfo
*
pGroupInfo
=
pGroupIter
;
taosArrayPush
(
groupArray
,
pGroupInfo
);
pGroupIter
=
taosHashIterate
(
pInfo
->
pGroupSet
,
pGroupIter
);
}
taosArraySort
(
groupArray
,
compareDataGroupInfo
);
pInfo
->
sortedGroupArray
=
groupArray
;
pInfo
->
groupIndex
=
-
1
;
taosHashClear
(
pInfo
->
pGroupSet
);
pOperator
->
cost
.
openCost
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
pOperator
->
cost
.
openCost
=
(
taosGetTimestampUs
()
-
st
)
/
1000
.
0
;
pOperator
->
status
=
OP_RES_TO_RETURN
;
pOperator
->
status
=
OP_RES_TO_RETURN
;
...
@@ -676,6 +697,7 @@ static void destroyPartitionOperatorInfo(void* param, int32_t numOfOutput) {
...
@@ -676,6 +697,7 @@ static void destroyPartitionOperatorInfo(void* param, int32_t numOfOutput) {
taosArrayDestroy
(
pInfo
->
pGroupColVals
);
taosArrayDestroy
(
pInfo
->
pGroupColVals
);
taosMemoryFree
(
pInfo
->
keyBuf
);
taosMemoryFree
(
pInfo
->
keyBuf
);
taosArrayDestroy
(
pInfo
->
sortedGroupArray
);
taosHashCleanup
(
pInfo
->
pGroupSet
);
taosHashCleanup
(
pInfo
->
pGroupSet
);
taosMemoryFree
(
pInfo
->
columnOffset
);
taosMemoryFree
(
pInfo
->
columnOffset
);
...
@@ -697,10 +719,12 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
...
@@ -697,10 +719,12 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
pInfo
->
pGroupCols
=
extractPartitionColInfo
(
pPartNode
->
pPartitionKeys
);
pInfo
->
pGroupCols
=
extractPartitionColInfo
(
pPartNode
->
pPartitionKeys
);
if
(
pPartNode
->
pExprs
!=
NULL
)
{
if
(
pPartNode
->
pExprs
!=
NULL
)
{
pInfo
->
scalarSup
.
numOfExprs
=
0
;
int32_t
num
=
0
;
pInfo
->
scalarSup
.
pExprInfo
=
createExprInfo
(
pPartNode
->
pExprs
,
NULL
,
&
pInfo
->
scalarSup
.
numOfExprs
);
SExprInfo
*
pExprInfo1
=
createExprInfo
(
pPartNode
->
pExprs
,
NULL
,
&
num
);
pInfo
->
scalarSup
.
pCtx
=
createSqlFunctionCtx
(
int32_t
code
=
initExprSupp
(
&
pInfo
->
scalarSup
,
pExprInfo1
,
num
);
pInfo
->
scalarSup
.
pExprInfo
,
pInfo
->
scalarSup
.
numOfExprs
,
&
pInfo
->
scalarSup
.
rowEntryInfoOffset
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
}
}
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
_hash_fn_t
hashFn
=
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_BINARY
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/executor/src/timewindowoperator.c
浏览文件 @
c79be2da
...
@@ -1705,7 +1705,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
...
@@ -1705,7 +1705,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo* pOperator) {
return
(
rows
==
0
)
?
NULL
:
pBInfo
->
pRes
;
return
(
rows
==
0
)
?
NULL
:
pBInfo
->
pRes
;
}
}
static
void
doKeepPrevRows
(
STimeSliceOperatorInfo
*
pSliceInfo
,
const
SSDataBlock
*
pBlock
)
{
static
void
doKeepPrevRows
(
STimeSliceOperatorInfo
*
pSliceInfo
,
const
SSDataBlock
*
pBlock
,
int32_t
rowIndex
)
{
int32_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
int32_t
numOfCols
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
SColumnInfoData
*
pColInfoData
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
...
@@ -1715,21 +1715,140 @@ static void doKeepPrevRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock
...
@@ -1715,21 +1715,140 @@ static void doKeepPrevRows(STimeSliceOperatorInfo* pSliceInfo, const SSDataBlock
SGroupKeys
*
pkey
=
taosArrayGet
(
pSliceInfo
->
pPrevRow
,
i
);
SGroupKeys
*
pkey
=
taosArrayGet
(
pSliceInfo
->
pPrevRow
,
i
);
pkey
->
isNull
=
false
;
pkey
->
isNull
=
false
;
char
*
val
=
colDataGetData
(
pColInfoData
,
i
);
char
*
val
=
colDataGetData
(
pColInfoData
,
rowIndex
);
memcpy
(
pkey
->
pData
,
val
,
pkey
->
bytes
);
memcpy
(
pkey
->
pData
,
val
,
pkey
->
bytes
);
}
}
}
}
}
}
static
void
genInterpolationResult
(
STimeSliceOperatorInfo
*
pSliceInfo
,
SExprSupp
*
pExprSup
,
SSDataBlock
*
pBlock
,
int32_t
rowIndex
,
SSDataBlock
*
pResBlock
)
{
int32_t
rows
=
pResBlock
->
info
.
rows
;
// todo set the correct primary timestamp column
// output the result
for
(
int32_t
j
=
0
;
j
<
pExprSup
->
numOfExprs
;
++
j
)
{
SExprInfo
*
pExprInfo
=
&
pExprSup
->
pExprInfo
[
j
];
int32_t
dstSlot
=
pExprInfo
->
base
.
resSchema
.
slotId
;
int32_t
srcSlot
=
pExprInfo
->
base
.
pParam
[
0
].
pCol
->
slotId
;
SColumnInfoData
*
pSrc
=
taosArrayGet
(
pBlock
->
pDataBlock
,
srcSlot
);
SColumnInfoData
*
pDst
=
taosArrayGet
(
pResBlock
->
pDataBlock
,
dstSlot
);
switch
(
pSliceInfo
->
fillType
)
{
case
TSDB_FILL_NULL
:
colDataAppendNULL
(
pDst
,
rows
);
break
;
case
TSDB_FILL_SET_VALUE
:
{
SVariant
*
pVar
=
&
pSliceInfo
->
pFillColInfo
[
j
].
fillVal
;
if
(
pDst
->
info
.
type
==
TSDB_DATA_TYPE_FLOAT
)
{
float
v
=
0
;
GET_TYPED_DATA
(
v
,
float
,
pVar
->
nType
,
&
pVar
->
i
);
colDataAppend
(
pDst
,
rows
,
(
char
*
)
&
v
,
false
);
}
else
if
(
pDst
->
info
.
type
==
TSDB_DATA_TYPE_DOUBLE
)
{
double
v
=
0
;
GET_TYPED_DATA
(
v
,
double
,
pVar
->
nType
,
&
pVar
->
i
);
colDataAppend
(
pDst
,
rows
,
(
char
*
)
&
v
,
false
);
}
else
if
(
IS_SIGNED_NUMERIC_TYPE
(
pDst
->
info
.
type
))
{
int64_t
v
=
0
;
GET_TYPED_DATA
(
v
,
int64_t
,
pVar
->
nType
,
&
pVar
->
i
);
colDataAppend
(
pDst
,
rows
,
(
char
*
)
&
v
,
false
);
}
}
break
;
case
TSDB_FILL_LINEAR
:
#if 0
if (pCtx->start.key == INT64_MIN || pCtx->start.key > pCtx->startTs
|| pCtx->end.key == INT64_MIN || pCtx->end.key < pCtx->startTs) {
// goto interp_exit;
}
double v1 = -1, v2 = -1;
GET_TYPED_DATA(v1, double, pCtx->inputType, &pCtx->start.val);
GET_TYPED_DATA(v2, double, pCtx->inputType, &pCtx->end.val);
SPoint point1 = {.key = ts, .val = &v1};
SPoint point2 = {.key = nextTs, .val = &v2};
SPoint point = {.key = pCtx->startTs, .val = pCtx->pOutput};
int32_t srcType = pCtx->inputType;
if (isNull((char *)&pCtx->start.val, srcType) || isNull((char *)&pCtx->end.val, srcType)) {
setNull(pCtx->pOutput, srcType, pCtx->inputBytes);
} else {
bool exceedMax = false, exceedMin = false;
taosGetLinearInterpolationVal(&point, pCtx->outputType, &point1, &point2, TSDB_DATA_TYPE_DOUBLE, &exceedMax, &exceedMin);
if (exceedMax || exceedMin) {
__compar_fn_t func = getComparFunc((int32_t)pCtx->inputType, 0);
if (func(&pCtx->start.val, &pCtx->end.val) <= 0) {
COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, exceedMax ? &pCtx->start.val : &pCtx->end.val);
} else {
COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, exceedMax ? &pCtx->end.val : &pCtx->start.val);
}
}
}
#endif
break
;
case
TSDB_FILL_PREV
:
{
SGroupKeys
*
pkey
=
taosArrayGet
(
pSliceInfo
->
pPrevRow
,
srcSlot
);
colDataAppend
(
pDst
,
rows
,
pkey
->
pData
,
false
);
}
break
;
case
TSDB_FILL_NEXT
:
{
char
*
p
=
colDataGetData
(
pSrc
,
rowIndex
);
colDataAppend
(
pDst
,
rows
,
p
,
colDataIsNull_s
(
pSrc
,
rowIndex
));
}
break
;
case
TSDB_FILL_NONE
:
default:
break
;
}
}
pResBlock
->
info
.
rows
+=
1
;
}
static
int32_t
initPrevRowsKeeper
(
STimeSliceOperatorInfo
*
pInfo
,
SSDataBlock
*
pBlock
)
{
if
(
pInfo
->
pPrevRow
!=
NULL
)
{
return
TSDB_CODE_SUCCESS
;
}
pInfo
->
pPrevRow
=
taosArrayInit
(
4
,
sizeof
(
SGroupKeys
));
if
(
pInfo
->
pPrevRow
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
int32_t
numOfCols
=
pBlock
->
info
.
numOfCols
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pColInfo
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
SGroupKeys
key
=
{
0
};
key
.
bytes
=
pColInfo
->
info
.
bytes
;
key
.
type
=
pColInfo
->
info
.
type
;
key
.
isNull
=
false
;
key
.
pData
=
taosMemoryCalloc
(
1
,
pColInfo
->
info
.
bytes
);
taosArrayPush
(
pInfo
->
pPrevRow
,
&
key
);
}
return
TSDB_CODE_SUCCESS
;
}
static
SSDataBlock
*
doTimeslice
(
SOperatorInfo
*
pOperator
)
{
static
SSDataBlock
*
doTimeslice
(
SOperatorInfo
*
pOperator
)
{
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
if
(
pOperator
->
status
==
OP_EXEC_DONE
)
{
return
NULL
;
return
NULL
;
}
}
SExecTaskInfo
*
pTaskInfo
=
pOperator
->
pTaskInfo
;
STimeSliceOperatorInfo
*
pSliceInfo
=
pOperator
->
info
;
STimeSliceOperatorInfo
*
pSliceInfo
=
pOperator
->
info
;
SSDataBlock
*
pResBlock
=
pSliceInfo
->
binfo
.
pRes
;
SSDataBlock
*
pResBlock
=
pSliceInfo
->
pRes
;
SExprSupp
*
pSup
=
&
pOperator
->
exprSupp
;
SExprSupp
*
pSup
=
&
pOperator
->
exprSupp
;
blockDataEnsureCapacity
(
pResBlock
,
pOperator
->
resultInfo
.
capacity
);
// if (pOperator->status == OP_RES_TO_RETURN) {
// if (pOperator->status == OP_RES_TO_RETURN) {
// // doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes);
// // doBuildResultDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes);
// if (pResBlock->info.rows == 0 || !hasDataInGroupInfo(&pSliceInfo->groupResInfo)) {
// if (pResBlock->info.rows == 0 || !hasDataInGroupInfo(&pSliceInfo->groupResInfo)) {
...
@@ -1750,10 +1869,15 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
...
@@ -1750,10 +1869,15 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
break
;
break
;
}
}
int32_t
code
=
initPrevRowsKeeper
(
pSliceInfo
,
pBlock
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
code
);
}
// the pDataBlock are always the same one, no need to call this again
// the pDataBlock are always the same one, no need to call this again
setInputDataBlock
(
pOperator
,
pSup
->
pCtx
,
pBlock
,
order
,
MAIN_SCAN
,
true
);
setInputDataBlock
(
pOperator
,
pSup
->
pCtx
,
pBlock
,
order
,
MAIN_SCAN
,
true
);
SColumnInfoData
*
pTsCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
0
);
SColumnInfoData
*
pTsCol
=
taosArrayGet
(
pBlock
->
pDataBlock
,
pSliceInfo
->
tsCol
.
slotId
);
for
(
int32_t
i
=
0
;
i
<
pBlock
->
info
.
rows
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pBlock
->
info
.
rows
;
++
i
)
{
int64_t
ts
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
);
int64_t
ts
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
);
...
@@ -1764,114 +1888,60 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
...
@@ -1764,114 +1888,60 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
int32_t
srcSlot
=
pExprInfo
->
base
.
pParam
[
0
].
pCol
->
slotId
;
int32_t
srcSlot
=
pExprInfo
->
base
.
pParam
[
0
].
pCol
->
slotId
;
SColumnInfoData
*
pSrc
=
taosArrayGet
(
pBlock
->
pDataBlock
,
srcSlot
);
SColumnInfoData
*
pSrc
=
taosArrayGet
(
pBlock
->
pDataBlock
,
srcSlot
);
SColumnInfoData
*
pDst
=
taosArrayGet
(
pBlock
->
pDataBlock
,
dstSlot
);
SColumnInfoData
*
pDst
=
taosArrayGet
(
p
Res
Block
->
pDataBlock
,
dstSlot
);
char
*
v
=
colDataGetData
(
pSrc
,
i
);
char
*
v
=
colDataGetData
(
pSrc
,
i
);
colDataAppend
(
pDst
,
numOfRows
,
v
,
false
);
colDataAppend
(
pDst
,
numOfRows
,
v
,
false
);
}
}
numOfRows
+=
1
;
pResBlock
->
info
.
rows
+=
1
;
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
pSliceInfo
->
current
+
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
doSetOperatorCompleted
(
pOperator
);
doSetOperatorCompleted
(
pOperator
);
break
;
break
;
}
}
if
(
pResBlock
->
info
.
rows
>=
pResBlock
->
info
.
capacity
)
{
break
;
}
}
else
if
(
ts
<
pSliceInfo
->
current
)
{
}
else
if
(
ts
<
pSliceInfo
->
current
)
{
if
(
i
!=
pBlock
->
info
.
window
.
ekey
)
{
if
(
i
<
pBlock
->
info
.
rows
-
1
)
{
int64_t
nextTs
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
+
1
);
int64_t
nextTs
=
*
(
int64_t
*
)
colDataGetData
(
pTsCol
,
i
+
1
);
if
(
nextTs
>
pSliceInfo
->
current
)
{
if
(
nextTs
>
pSliceInfo
->
current
)
{
// output the result
while
(
pSliceInfo
->
current
<
nextTs
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
for
(
int32_t
j
=
0
;
j
<
pOperator
->
exprSupp
.
numOfExprs
;
++
j
)
{
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pBlock
,
i
,
pResBlock
);
SExprInfo
*
pExprInfo
=
&
pOperator
->
exprSupp
.
pExprInfo
[
j
];
pSliceInfo
->
current
=
int32_t
dstSlot
=
pExprInfo
->
base
.
resSchema
.
slotId
;
int32_t
srcSlot
=
pExprInfo
->
base
.
pParam
[
0
].
pCol
->
slotId
;
SColumnInfoData
*
pSrc
=
taosArrayGet
(
pBlock
->
pDataBlock
,
srcSlot
);
SColumnInfoData
*
pDst
=
taosArrayGet
(
pBlock
->
pDataBlock
,
dstSlot
);
switch
(
pSliceInfo
->
fillType
)
{
case
TSDB_FILL_NULL
:
colDataAppendNULL
(
pDst
,
numOfRows
);
break
;
case
TSDB_FILL_SET_VALUE
:
{
SVariant
*
pVar
=
&
pSliceInfo
->
pFillColInfo
[
i
].
fillVal
;
if
(
pDst
->
info
.
type
==
TSDB_DATA_TYPE_FLOAT
)
{
float
v
=
0
;
GET_TYPED_DATA
(
v
,
float
,
pVar
->
nType
,
&
pVar
->
i
);
colDataAppend
(
pDst
,
numOfRows
,
(
char
*
)
&
v
,
false
);
}
else
if
(
pDst
->
info
.
type
==
TSDB_DATA_TYPE_DOUBLE
)
{
double
v
=
0
;
GET_TYPED_DATA
(
v
,
double
,
pVar
->
nType
,
&
pVar
->
i
);
colDataAppend
(
pDst
,
numOfRows
,
(
char
*
)
&
v
,
false
);
}
else
if
(
IS_SIGNED_NUMERIC_TYPE
(
pDst
->
info
.
type
))
{
int64_t
v
=
0
;
GET_TYPED_DATA
(
v
,
int64_t
,
pVar
->
nType
,
&
pVar
->
i
);
colDataAppend
(
pDst
,
numOfRows
,
(
char
*
)
&
v
,
false
);
}
}
break
;
case
TSDB_FILL_LINEAR
:
#if 0
if (pCtx->start.key == INT64_MIN || pCtx->start.key > pCtx->startTs
|| pCtx->end.key == INT64_MIN || pCtx->end.key < pCtx->startTs) {
// goto interp_exit;
}
double v1 = -1, v2 = -1;
GET_TYPED_DATA(v1, double, pCtx->inputType, &pCtx->start.val);
GET_TYPED_DATA(v2, double, pCtx->inputType, &pCtx->end.val);
SPoint point1 = {.key = ts, .val = &v1};
SPoint point2 = {.key = nextTs, .val = &v2};
SPoint point = {.key = pCtx->startTs, .val = pCtx->pOutput};
int32_t srcType = pCtx->inputType;
if (isNull((char *)&pCtx->start.val, srcType) || isNull((char *)&pCtx->end.val, srcType)) {
setNull(pCtx->pOutput, srcType, pCtx->inputBytes);
} else {
bool exceedMax = false, exceedMin = false;
taosGetLinearInterpolationVal(&point, pCtx->outputType, &point1, &point2, TSDB_DATA_TYPE_DOUBLE, &exceedMax, &exceedMin);
if (exceedMax || exceedMin) {
__compar_fn_t func = getComparFunc((int32_t)pCtx->inputType, 0);
if (func(&pCtx->start.val, &pCtx->end.val) <= 0) {
COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, exceedMax ? &pCtx->start.val : &pCtx->end.val);
} else {
COPY_TYPED_DATA(pCtx->pOutput, pCtx->inputType, exceedMax ? &pCtx->end.val : &pCtx->start.val);
}
}
}
#endif
break
;
case
TSDB_FILL_PREV
:
{
SGroupKeys
*
pkey
=
taosArrayGet
(
pSliceInfo
->
pPrevRow
,
srcSlot
);
colDataAppend
(
pDst
,
numOfRows
,
pkey
->
pData
,
false
);
}
break
;
case
TSDB_FILL_NEXT
:
{
}
break
;
case
TSDB_FILL_NONE
:
default:
break
;
}
pSliceInfo
->
current
+=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
if
(
pResBlock
->
info
.
rows
>=
pResBlock
->
info
.
capacity
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
break
;
}
}
}
}
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
}
}
else
{
}
else
{
// ignore current row, and do nothing
// ignore current row, and do nothing
}
}
}
else
{
// it is the last row of current block
}
else
{
// it is the last row of current block
doKeepPrevRows
(
pSliceInfo
,
pBlock
);
doKeepPrevRows
(
pSliceInfo
,
pBlock
,
i
);
}
}
else
{
// ts > pSliceInfo->current
while
(
pSliceInfo
->
current
<
ts
&&
pSliceInfo
->
current
<=
pSliceInfo
->
win
.
ekey
)
{
genInterpolationResult
(
pSliceInfo
,
&
pOperator
->
exprSupp
,
pBlock
,
i
,
pResBlock
);
pSliceInfo
->
current
=
taosTimeAdd
(
pSliceInfo
->
current
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
pInterval
->
precision
);
if
(
pResBlock
->
info
.
rows
>=
pResBlock
->
info
.
capacity
)
{
break
;
}
}
if
(
pSliceInfo
->
current
>
pSliceInfo
->
win
.
ekey
)
{
doSetOperatorCompleted
(
pOperator
);
break
;
}
}
}
}
}
}
...
@@ -1886,59 +1956,46 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
...
@@ -1886,59 +1956,46 @@ static SSDataBlock* doTimeslice(SOperatorInfo* pOperator) {
return
pResBlock
->
info
.
rows
==
0
?
NULL
:
pResBlock
;
return
pResBlock
->
info
.
rows
==
0
?
NULL
:
pResBlock
;
}
}
static
int32_t
initTimesliceInfo
(
STimeSliceOperatorInfo
*
pInfo
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfCols
)
{
SOperatorInfo
*
createTimeSliceOperatorInfo
(
SOperatorInfo
*
downstream
,
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
)
{
pInfo
->
pPrevRow
=
taosArrayInit
(
4
,
sizeof
(
SGroupKeys
));
pInfo
->
pCols
=
taosArrayInit
(
4
,
sizeof
(
SColumn
));
if
(
pInfo
->
pPrevRow
==
NULL
||
pInfo
->
pCols
==
NULL
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SExprInfo
*
pExpr
=
pCtx
[
i
].
pExpr
;
SFunctParam
*
pParam
=
&
pExpr
->
base
.
pParam
[
0
];
SColumn
c
=
*
pParam
->
pCol
;
taosArrayPush
(
pInfo
->
pCols
,
&
c
);
SGroupKeys
key
=
{
0
};
key
.
bytes
=
c
.
bytes
;
key
.
type
=
c
.
type
;
key
.
isNull
=
false
;
key
.
pData
=
taosMemoryCalloc
(
1
,
c
.
bytes
);
taosArrayPush
(
pInfo
->
pPrevRow
,
&
key
);
}
return
TSDB_CODE_SUCCESS
;
}
SOperatorInfo
*
createTimeSliceOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
const
SNodeListNode
*
pValNode
,
SExecTaskInfo
*
pTaskInfo
)
{
STimeSliceOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STimeSliceOperatorInfo
));
STimeSliceOperatorInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STimeSliceOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pOperator
==
NULL
||
pInfo
==
NULL
)
{
if
(
pOperator
==
NULL
||
pInfo
==
NULL
)
{
goto
_error
;
goto
_error
;
}
}
SInterpFuncPhysiNode
*
pInterpPhyNode
=
(
SInterpFuncPhysiNode
*
)
pPhyNode
;
SExprSupp
*
pSup
=
&
pOperator
->
exprSupp
;
SExprSupp
*
pSup
=
&
pOperator
->
exprSupp
;
int32_t
code
=
initTimesliceInfo
(
pInfo
,
pSup
->
pCtx
,
numOfCols
);
int32_t
numOfExprs
=
0
;
SExprInfo
*
pExprInfo
=
createExprInfo
(
pInterpPhyNode
->
pFuncs
,
NULL
,
&
numOfExprs
);
int32_t
code
=
initExprSupp
(
pSup
,
pExprInfo
,
numOfExprs
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
goto
_error
;
}
}
initResultRowInfo
(
&
pInfo
->
binfo
.
resultRowInfo
);
if
(
pInterpPhyNode
->
pExprs
!=
NULL
)
{
pInfo
->
pFillColInfo
=
createFillColInfo
(
pExprInfo
,
numOfCols
,
pValNode
);
int32_t
num
=
0
;
SExprInfo
*
pScalarExprInfo
=
createExprInfo
(
pInterpPhyNode
->
pExprs
,
NULL
,
&
num
);
code
=
initExprSupp
(
&
pInfo
->
scalarSup
,
pScalarExprInfo
,
num
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
goto
_error
;
}
}
pInfo
->
tsCol
=
extractColumnFromColumnNode
((
SColumnNode
*
)
pInterpPhyNode
->
pTimeSeries
);
pInfo
->
fillType
=
convertFillType
(
pInterpPhyNode
->
fillMode
);
initResultSizeInfo
(
pOperator
,
4096
);
pInfo
->
binfo
.
pRes
=
pResultBlock
;
pInfo
->
pFillColInfo
=
createFillColInfo
(
pExprInfo
,
numOfExprs
,
(
SNodeListNode
*
)
pInterpPhyNode
->
pFillValues
);
pInfo
->
pRes
=
createResDataBlock
(
pPhyNode
->
pOutputDataBlockDesc
);
pInfo
->
win
=
pInterpPhyNode
->
timeRange
;
pInfo
->
interval
.
interval
=
pInterpPhyNode
->
interval
;
pInfo
->
current
=
pInfo
->
win
.
skey
;
pOperator
->
name
=
"TimeSliceOperator"
;
pOperator
->
name
=
"TimeSliceOperator"
;
// pOperator->operatorType = OP_AllTimeWindow
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC
;
pOperator
->
blocking
=
tru
e
;
pOperator
->
blocking
=
fals
e
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
exprSupp
.
pExprInfo
=
pExprInfo
;
pOperator
->
exprSupp
.
numOfExprs
=
numOfCols
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
...
@@ -2360,9 +2417,6 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
...
@@ -2360,9 +2417,6 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
}
}
}
}
// semi interval operator does not catch result
// semi interval operator does not catch result
if
(
!
IS_FINAL_OP
(
pInfo
))
{
pInfo
->
twAggSup
.
calTrigger
=
STREAM_TRIGGER_AT_ONCE
;
}
pInfo
->
pUpdateRes
=
createResDataBlock
(
pPhyNode
->
pOutputDataBlockDesc
);
pInfo
->
pUpdateRes
=
createResDataBlock
(
pPhyNode
->
pOutputDataBlockDesc
);
pInfo
->
pUpdateRes
->
info
.
type
=
STREAM_REPROCESS
;
pInfo
->
pUpdateRes
->
info
.
type
=
STREAM_REPROCESS
;
blockDataEnsureCapacity
(
pInfo
->
pUpdateRes
,
128
);
blockDataEnsureCapacity
(
pInfo
->
pUpdateRes
,
128
);
...
@@ -2376,6 +2430,10 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
...
@@ -2376,6 +2430,10 @@ SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream,
pOperator
->
name
=
"StreamSemiIntervalOperator"
;
pOperator
->
name
=
"StreamSemiIntervalOperator"
;
}
}
if
(
!
IS_FINAL_OP
(
pInfo
))
{
pInfo
->
twAggSup
.
calTrigger
=
STREAM_TRIGGER_AT_ONCE
;
}
pOperator
->
operatorType
=
pPhyNode
->
type
;
pOperator
->
operatorType
=
pPhyNode
->
type
;
pOperator
->
blocking
=
true
;
pOperator
->
blocking
=
true
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
...
@@ -2432,7 +2490,11 @@ void destroyStreamSessionAggOperatorInfo(void* param, int32_t numOfOutput) {
...
@@ -2432,7 +2490,11 @@ void destroyStreamSessionAggOperatorInfo(void* param, int32_t numOfOutput) {
}
}
int32_t
initBasicInfoEx
(
SOptrBasicInfo
*
pBasicInfo
,
SExprSupp
*
pSup
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
)
{
int32_t
initBasicInfoEx
(
SOptrBasicInfo
*
pBasicInfo
,
SExprSupp
*
pSup
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
)
{
initExprSupp
(
pSup
,
pExprInfo
,
numOfCols
);
int32_t
code
=
initExprSupp
(
pSup
,
pExprInfo
,
numOfCols
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
initBasicInfo
(
pBasicInfo
,
pResultBlock
);
initBasicInfo
(
pBasicInfo
,
pResultBlock
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
...
@@ -2892,7 +2954,10 @@ static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWin
...
@@ -2892,7 +2954,10 @@ static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWin
SArray
*
pChWins
=
getWinInfos
(
&
pChInfo
->
streamAggSup
,
groupId
);
SArray
*
pChWins
=
getWinInfos
(
&
pChInfo
->
streamAggSup
,
groupId
);
int32_t
chWinSize
=
taosArrayGetSize
(
pChWins
);
int32_t
chWinSize
=
taosArrayGetSize
(
pChWins
);
int32_t
index
=
binarySearch
(
pChWins
,
chWinSize
,
pParentWin
->
win
.
skey
,
TSDB_ORDER_DESC
,
getSessionWindowEndkey
);
int32_t
index
=
binarySearch
(
pChWins
,
chWinSize
,
pParentWin
->
win
.
skey
,
TSDB_ORDER_DESC
,
getSessionWindowEndkey
);
for
(
int32_t
k
=
index
;
k
>
0
&&
k
<
chWinSize
;
k
++
)
{
if
(
index
<
0
)
{
index
=
0
;
}
for
(
int32_t
k
=
index
;
k
<
chWinSize
;
k
++
)
{
SResultWindowInfo
*
pcw
=
taosArrayGet
(
pChWins
,
k
);
SResultWindowInfo
*
pcw
=
taosArrayGet
(
pChWins
,
k
);
if
(
pParentWin
->
win
.
skey
<=
pcw
->
win
.
skey
&&
pcw
->
win
.
ekey
<=
pParentWin
->
win
.
ekey
)
{
if
(
pParentWin
->
win
.
skey
<=
pcw
->
win
.
skey
&&
pcw
->
win
.
ekey
<=
pParentWin
->
win
.
ekey
)
{
SResultRow
*
pChResult
=
NULL
;
SResultRow
*
pChResult
=
NULL
;
...
...
source/libs/function/inc/builtinsimpl.h
浏览文件 @
c79be2da
...
@@ -192,6 +192,8 @@ int32_t twaFunction(SqlFunctionCtx *pCtx);
...
@@ -192,6 +192,8 @@ int32_t twaFunction(SqlFunctionCtx *pCtx);
int32_t
twaFinalize
(
struct
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
twaFinalize
(
struct
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
bool
getSelectivityFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
getSelectivityFuncEnv
(
SFunctionNode
*
pFunc
,
SFuncExecEnv
*
pEnv
);
bool
blockDistSetup
(
SqlFunctionCtx
*
pCtx
,
SResultRowEntryInfo
*
pResultInfo
);
int32_t
blockDistFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
blockDistFunction
(
SqlFunctionCtx
*
pCtx
);
int32_t
blockDistFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
int32_t
blockDistFinalize
(
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
);
...
...
source/libs/function/src/builtins.c
浏览文件 @
c79be2da
...
@@ -419,7 +419,7 @@ static int32_t translateTopBot(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
...
@@ -419,7 +419,7 @@ static int32_t translateTopBot(SFunctionNode* pFunc, char* pErrBuf, int32_t len)
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
topCreateMergePara
(
SNodeList
*
pRawParameters
,
SNode
*
pPartialRes
,
SNodeList
**
pParameters
)
{
int32_t
top
Bot
CreateMergePara
(
SNodeList
*
pRawParameters
,
SNode
*
pPartialRes
,
SNodeList
**
pParameters
)
{
int32_t
code
=
nodesListMakeAppend
(
pParameters
,
pPartialRes
);
int32_t
code
=
nodesListMakeAppend
(
pParameters
,
pPartialRes
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodesListStrictAppend
(
*
pParameters
,
nodesCloneNode
(
nodesListGetNode
(
pRawParameters
,
1
)));
code
=
nodesListStrictAppend
(
*
pParameters
,
nodesCloneNode
(
nodesListGetNode
(
pRawParameters
,
1
)));
...
@@ -427,65 +427,6 @@ int32_t topCreateMergePara(SNodeList* pRawParameters, SNode* pPartialRes, SNodeL
...
@@ -427,65 +427,6 @@ int32_t topCreateMergePara(SNodeList* pRawParameters, SNode* pPartialRes, SNodeL
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
translateTopBotImpl
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
,
bool
isPartial
)
{
int32_t
numOfParams
=
LIST_LENGTH
(
pFunc
->
pParameterList
);
if
(
isPartial
)
{
if
(
2
!=
numOfParams
)
{
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
uint8_t
para1Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
uint8_t
para2Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
1
))
->
resType
.
type
;
if
(
!
IS_NUMERIC_TYPE
(
para1Type
)
||
!
IS_INTEGER_TYPE
(
para2Type
))
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
// param1
SNode
*
pParamNode1
=
nodesListGetNode
(
pFunc
->
pParameterList
,
1
);
if
(
nodeType
(
pParamNode1
)
!=
QUERY_NODE_VALUE
)
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
SValueNode
*
pValue
=
(
SValueNode
*
)
pParamNode1
;
if
(
pValue
->
node
.
resType
.
type
!=
TSDB_DATA_TYPE_BIGINT
)
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
if
(
pValue
->
datum
.
i
<
1
||
pValue
->
datum
.
i
>
100
)
{
return
invaildFuncParaValueErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
pValue
->
notReserved
=
true
;
// set result type
pFunc
->
node
.
resType
=
(
SDataType
){.
bytes
=
getTopBotInfoSize
(
pValue
->
datum
.
i
)
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_BINARY
};
}
else
{
if
(
1
!=
numOfParams
)
{
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
uint8_t
para1Type
=
((
SExprNode
*
)
nodesListGetNode
(
pFunc
->
pParameterList
,
0
))
->
resType
.
type
;
if
(
TSDB_DATA_TYPE_BINARY
!=
para1Type
)
{
return
invaildFuncParaTypeErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
}
// Do nothing. We can only access output of partial functions as input,
// so original input type cannot be obtained, resType will be set same
// as original function input type after merge function created.
}
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateTopBotPartial
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
return
translateTopBotImpl
(
pFunc
,
pErrBuf
,
len
,
true
);
}
static
int32_t
translateTopBotMerge
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
return
translateTopBotImpl
(
pFunc
,
pErrBuf
,
len
,
false
);
}
static
int32_t
translateSpread
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
static
int32_t
translateSpread
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
if
(
1
!=
LIST_LENGTH
(
pFunc
->
pParameterList
))
{
if
(
1
!=
LIST_LENGTH
(
pFunc
->
pParameterList
))
{
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
return
invaildFuncParaNumErrMsg
(
pErrBuf
,
len
,
pFunc
->
functionName
);
...
@@ -1735,31 +1676,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -1735,31 +1676,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
processFunc
=
topFunction
,
.
processFunc
=
topFunction
,
.
finalizeFunc
=
topBotFinalize
,
.
finalizeFunc
=
topBotFinalize
,
.
combineFunc
=
topCombine
,
.
combineFunc
=
topCombine
,
.
pPartialFunc
=
"_top_partial"
,
.
pPartialFunc
=
"top"
,
.
pMergeFunc
=
"_top_merge"
,
.
pMergeFunc
=
"top"
,
// .createMergeParaFuc = topCreateMergePara
.
createMergeParaFuc
=
topBotCreateMergePara
},
{
.
name
=
"_top_partial"
,
.
type
=
FUNCTION_TYPE_TOP_PARTIAL
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_INDEFINITE_ROWS_FUNC
,
.
translateFunc
=
translateTopBotPartial
,
.
getEnvFunc
=
getTopBotFuncEnv
,
.
initFunc
=
topBotFunctionSetup
,
.
processFunc
=
topFunction
,
.
finalizeFunc
=
topBotPartialFinalize
,
.
combineFunc
=
topCombine
,
},
{
.
name
=
"_top_merge"
,
.
type
=
FUNCTION_TYPE_TOP_MERGE
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_INDEFINITE_ROWS_FUNC
,
.
translateFunc
=
translateTopBotMerge
,
.
getEnvFunc
=
getTopBotMergeFuncEnv
,
.
initFunc
=
functionSetup
,
.
processFunc
=
topFunctionMerge
,
.
finalizeFunc
=
topBotMergeFinalize
,
.
combineFunc
=
topCombine
,
},
},
{
{
.
name
=
"bottom"
,
.
name
=
"bottom"
,
...
@@ -1771,30 +1690,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -1771,30 +1690,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
processFunc
=
bottomFunction
,
.
processFunc
=
bottomFunction
,
.
finalizeFunc
=
topBotFinalize
,
.
finalizeFunc
=
topBotFinalize
,
.
combineFunc
=
bottomCombine
,
.
combineFunc
=
bottomCombine
,
.
pPartialFunc
=
"_bottom_partial"
,
.
pPartialFunc
=
"bottom"
,
.
pMergeFunc
=
"_bottom_merge"
.
pMergeFunc
=
"bottom"
,
},
.
createMergeParaFuc
=
topBotCreateMergePara
{
.
name
=
"_bottom_partial"
,
.
type
=
FUNCTION_TYPE_BOTTOM_PARTIAL
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_INDEFINITE_ROWS_FUNC
,
.
translateFunc
=
translateTopBotPartial
,
.
getEnvFunc
=
getTopBotFuncEnv
,
.
initFunc
=
topBotFunctionSetup
,
.
processFunc
=
bottomFunction
,
.
finalizeFunc
=
topBotPartialFinalize
,
.
combineFunc
=
bottomCombine
,
},
{
.
name
=
"_bottom_merge"
,
.
type
=
FUNCTION_TYPE_BOTTOM_MERGE
,
.
classification
=
FUNC_MGT_AGG_FUNC
|
FUNC_MGT_SELECT_FUNC
|
FUNC_MGT_INDEFINITE_ROWS_FUNC
,
.
translateFunc
=
translateTopBotMerge
,
.
getEnvFunc
=
getTopBotMergeFuncEnv
,
.
initFunc
=
functionSetup
,
.
processFunc
=
bottomFunctionMerge
,
.
finalizeFunc
=
topBotMergeFinalize
,
.
combineFunc
=
bottomCombine
,
},
},
{
{
.
name
=
"spread"
,
.
name
=
"spread"
,
...
@@ -2524,7 +2422,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -2524,7 +2422,9 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
getEnvFunc
=
getSelectivityFuncEnv
,
// todo remove this function later.
.
getEnvFunc
=
getSelectivityFuncEnv
,
// todo remove this function later.
.
initFunc
=
functionSetup
,
.
initFunc
=
functionSetup
,
.
processFunc
=
NULL
,
.
processFunc
=
NULL
,
.
finalizeFunc
=
NULL
.
finalizeFunc
=
NULL
,
.
pPartialFunc
=
"_select_value"
,
.
pMergeFunc
=
"_select_value"
},
},
{
{
.
name
=
"_block_dist"
,
.
name
=
"_block_dist"
,
...
@@ -2532,6 +2432,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
...
@@ -2532,6 +2432,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.
classification
=
FUNC_MGT_AGG_FUNC
,
.
classification
=
FUNC_MGT_AGG_FUNC
,
.
translateFunc
=
translateBlockDistFunc
,
.
translateFunc
=
translateBlockDistFunc
,
.
getEnvFunc
=
getBlockDistFuncEnv
,
.
getEnvFunc
=
getBlockDistFuncEnv
,
.
initFunc
=
blockDistSetup
,
.
processFunc
=
blockDistFunction
,
.
processFunc
=
blockDistFunction
,
.
finalizeFunc
=
blockDistFinalize
.
finalizeFunc
=
blockDistFinalize
},
},
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/function/src/tudf.c
浏览文件 @
c79be2da
...
@@ -972,6 +972,11 @@ void releaseUdfFuncHandle(char* udfName) {
...
@@ -972,6 +972,11 @@ void releaseUdfFuncHandle(char* udfName) {
}
}
int32_t
cleanUpUdfs
()
{
int32_t
cleanUpUdfs
()
{
int8_t
initialized
=
atomic_load_8
(
&
gUdfdProxy
.
initialized
);
if
(
!
initialized
)
{
return
TSDB_CODE_SUCCESS
;
}
uv_mutex_lock
(
&
gUdfdProxy
.
udfStubsMutex
);
uv_mutex_lock
(
&
gUdfdProxy
.
udfStubsMutex
);
int32_t
i
=
0
;
int32_t
i
=
0
;
SArray
*
udfStubs
=
taosArrayInit
(
16
,
sizeof
(
SUdfcFuncStub
));
SArray
*
udfStubs
=
taosArrayInit
(
16
,
sizeof
(
SUdfcFuncStub
));
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
c79be2da
...
@@ -464,6 +464,9 @@ static SNode* logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFuncL
...
@@ -464,6 +464,9 @@ static SNode* logicInterpFuncCopy(const SInterpFuncLogicNode* pSrc, SInterpFuncL
CLONE_NODE_LIST_FIELD
(
pFuncs
);
CLONE_NODE_LIST_FIELD
(
pFuncs
);
COPY_OBJECT_FIELD
(
timeRange
,
sizeof
(
STimeWindow
));
COPY_OBJECT_FIELD
(
timeRange
,
sizeof
(
STimeWindow
));
COPY_SCALAR_FIELD
(
interval
);
COPY_SCALAR_FIELD
(
interval
);
COPY_SCALAR_FIELD
(
fillMode
);
CLONE_NODE_FIELD
(
pFillValues
);
CLONE_NODE_FIELD
(
pTimeSeries
);
return
(
SNode
*
)
pDst
;
return
(
SNode
*
)
pDst
;
}
}
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
c79be2da
...
@@ -2133,6 +2133,9 @@ static const char* jkInterpFuncPhysiPlanFuncs = "Funcs";
...
@@ -2133,6 +2133,9 @@ static const char* jkInterpFuncPhysiPlanFuncs = "Funcs";
static
const
char
*
jkInterpFuncPhysiPlanStartTime
=
"StartTime"
;
static
const
char
*
jkInterpFuncPhysiPlanStartTime
=
"StartTime"
;
static
const
char
*
jkInterpFuncPhysiPlanEndTime
=
"EndTime"
;
static
const
char
*
jkInterpFuncPhysiPlanEndTime
=
"EndTime"
;
static
const
char
*
jkInterpFuncPhysiPlanInterval
=
"Interval"
;
static
const
char
*
jkInterpFuncPhysiPlanInterval
=
"Interval"
;
static
const
char
*
jkInterpFuncPhysiPlanFillMode
=
"FillMode"
;
static
const
char
*
jkInterpFuncPhysiPlanFillValues
=
"FillValues"
;
static
const
char
*
jkInterpFuncPhysiPlanTimeSeries
=
"TimeSeries"
;
static
int32_t
physiInterpFuncNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
physiInterpFuncNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SInterpFuncPhysiNode
*
pNode
=
(
const
SInterpFuncPhysiNode
*
)
pObj
;
const
SInterpFuncPhysiNode
*
pNode
=
(
const
SInterpFuncPhysiNode
*
)
pObj
;
...
@@ -2153,6 +2156,15 @@ static int32_t physiInterpFuncNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -2153,6 +2156,15 @@ static int32_t physiInterpFuncNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkInterpFuncPhysiPlanInterval
,
pNode
->
interval
);
code
=
tjsonAddIntegerToObject
(
pJson
,
jkInterpFuncPhysiPlanInterval
,
pNode
->
interval
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkInterpFuncPhysiPlanFillMode
,
pNode
->
fillMode
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkInterpFuncPhysiPlanFillValues
,
nodeToJson
,
pNode
->
pFillValues
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkInterpFuncPhysiPlanTimeSeries
,
nodeToJson
,
pNode
->
pTimeSeries
);
}
return
code
;
return
code
;
}
}
...
@@ -2176,6 +2188,15 @@ static int32_t jsonToPhysiInterpFuncNode(const SJson* pJson, void* pObj) {
...
@@ -2176,6 +2188,15 @@ static int32_t jsonToPhysiInterpFuncNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkInterpFuncPhysiPlanInterval
,
&
pNode
->
interval
);
code
=
tjsonGetBigIntValue
(
pJson
,
jkInterpFuncPhysiPlanInterval
,
&
pNode
->
interval
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
tjsonGetNumberValue
(
pJson
,
jkInterpFuncPhysiPlanFillMode
,
pNode
->
fillMode
,
code
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkInterpFuncPhysiPlanFillValues
,
&
pNode
->
pFillValues
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkInterpFuncPhysiPlanTimeSeries
,
&
pNode
->
pTimeSeries
);
}
return
code
;
return
code
;
}
}
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
c79be2da
...
@@ -207,9 +207,12 @@ SNode* nodesMakeNode(ENodeType type) {
...
@@ -207,9 +207,12 @@ SNode* nodesMakeNode(ENodeType type) {
case
QUERY_NODE_SHOW_VNODES_STMT
:
case
QUERY_NODE_SHOW_VNODES_STMT
:
case
QUERY_NODE_SHOW_APPS_STMT
:
case
QUERY_NODE_SHOW_APPS_STMT
:
case
QUERY_NODE_SHOW_SCORES_STMT
:
case
QUERY_NODE_SHOW_SCORES_STMT
:
case
QUERY_NODE_SHOW_VARIABLE_STMT
:
case
QUERY_NODE_SHOW_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
case
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
:
return
makeNode
(
type
,
sizeof
(
SShowDnodeVariablesStmt
));
case
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
:
case
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
:
return
makeNode
(
type
,
sizeof
(
SShowCreateDatabaseStmt
));
return
makeNode
(
type
,
sizeof
(
SShowCreateDatabaseStmt
));
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
...
@@ -637,13 +640,16 @@ void nodesDestroyNode(SNode* pNode) {
...
@@ -637,13 +640,16 @@ void nodesDestroyNode(SNode* pNode) {
case
QUERY_NODE_SHOW_VNODES_STMT
:
case
QUERY_NODE_SHOW_VNODES_STMT
:
case
QUERY_NODE_SHOW_APPS_STMT
:
case
QUERY_NODE_SHOW_APPS_STMT
:
case
QUERY_NODE_SHOW_SCORES_STMT
:
case
QUERY_NODE_SHOW_SCORES_STMT
:
case
QUERY_NODE_SHOW_VARIABLE_STMT
:
case
QUERY_NODE_SHOW_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT
:
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
{
case
QUERY_NODE_SHOW_TRANSACTIONS_STMT
:
{
SShowStmt
*
pStmt
=
(
SShowStmt
*
)
pNode
;
SShowStmt
*
pStmt
=
(
SShowStmt
*
)
pNode
;
nodesDestroyNode
(
pStmt
->
pDbName
);
nodesDestroyNode
(
pStmt
->
pDbName
);
nodesDestroyNode
(
pStmt
->
pTbName
);
nodesDestroyNode
(
pStmt
->
pTbName
);
break
;
break
;
}
}
case
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
:
// no pointer field
break
;
case
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
:
case
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
:
taosMemoryFreeClear
(((
SShowCreateDatabaseStmt
*
)
pNode
)
->
pCfg
);
taosMemoryFreeClear
(((
SShowCreateDatabaseStmt
*
)
pNode
)
->
pCfg
);
break
;
break
;
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
c79be2da
...
@@ -161,6 +161,7 @@ SNode* createShowStmtWithCond(SAstCreateContext* pCxt, ENodeType type, SNode* pD
...
@@ -161,6 +161,7 @@ SNode* createShowStmtWithCond(SAstCreateContext* pCxt, ENodeType type, SNode* pD
SNode
*
createShowCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
);
SNode
*
createShowCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
);
SNode
*
createShowCreateTableStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
SNode
*
pRealTable
);
SNode
*
createShowCreateTableStmt
(
SAstCreateContext
*
pCxt
,
ENodeType
type
,
SNode
*
pRealTable
);
SNode
*
createShowTableDistributedStmt
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
);
SNode
*
createShowTableDistributedStmt
(
SAstCreateContext
*
pCxt
,
SNode
*
pRealTable
);
SNode
*
createShowDnodeVariablesStmt
(
SAstCreateContext
*
pCxt
,
SNode
*
pDnodeId
);
SNode
*
createCreateUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
,
const
SToken
*
pPassword
);
SNode
*
createCreateUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
,
const
SToken
*
pPassword
);
SNode
*
createAlterUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
,
int8_t
alterType
,
const
SToken
*
pVal
);
SNode
*
createAlterUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
,
int8_t
alterType
,
const
SToken
*
pVal
);
SNode
*
createDropUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
);
SNode
*
createDropUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
);
...
...
source/libs/parser/inc/parUtil.h
浏览文件 @
c79be2da
...
@@ -47,6 +47,8 @@ typedef struct SParseMetaCache {
...
@@ -47,6 +47,8 @@ typedef struct SParseMetaCache {
SHashObj
*
pUserAuth
;
// key is SUserAuthInfo serialized string, element is bool indicating whether or not to pass
SHashObj
*
pUserAuth
;
// key is SUserAuthInfo serialized string, element is bool indicating whether or not to pass
SHashObj
*
pUdf
;
// key is funcName, element is SFuncInfo*
SHashObj
*
pUdf
;
// key is funcName, element is SFuncInfo*
SHashObj
*
pTableIndex
;
// key is tbFName, element is SArray<STableIndexInfo>*
SHashObj
*
pTableIndex
;
// key is tbFName, element is SArray<STableIndexInfo>*
SArray
*
pDnodes
;
// element is SEpSet
bool
dnodeRequired
;
}
SParseMetaCache
;
}
SParseMetaCache
;
int32_t
generateSyntaxErrMsg
(
SMsgBuf
*
pBuf
,
int32_t
errCode
,
...);
int32_t
generateSyntaxErrMsg
(
SMsgBuf
*
pBuf
,
int32_t
errCode
,
...);
...
@@ -77,6 +79,7 @@ int32_t reserveUserAuthInCache(int32_t acctId, const char* pUser, const char* pD
...
@@ -77,6 +79,7 @@ int32_t reserveUserAuthInCache(int32_t acctId, const char* pUser, const char* pD
int32_t
reserveUserAuthInCacheExt
(
const
char
*
pUser
,
const
SName
*
pName
,
AUTH_TYPE
type
,
SParseMetaCache
*
pMetaCache
);
int32_t
reserveUserAuthInCacheExt
(
const
char
*
pUser
,
const
SName
*
pName
,
AUTH_TYPE
type
,
SParseMetaCache
*
pMetaCache
);
int32_t
reserveUdfInCache
(
const
char
*
pFunc
,
SParseMetaCache
*
pMetaCache
);
int32_t
reserveUdfInCache
(
const
char
*
pFunc
,
SParseMetaCache
*
pMetaCache
);
int32_t
reserveTableIndexInCache
(
int32_t
acctId
,
const
char
*
pDb
,
const
char
*
pTable
,
SParseMetaCache
*
pMetaCache
);
int32_t
reserveTableIndexInCache
(
int32_t
acctId
,
const
char
*
pDb
,
const
char
*
pTable
,
SParseMetaCache
*
pMetaCache
);
int32_t
reserveDnodeRequiredInCache
(
SParseMetaCache
*
pMetaCache
);
int32_t
getTableMetaFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
STableMeta
**
pMeta
);
int32_t
getTableMetaFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
STableMeta
**
pMeta
);
int32_t
getDbVgInfoFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pDbFName
,
SArray
**
pVgInfo
);
int32_t
getDbVgInfoFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pDbFName
,
SArray
**
pVgInfo
);
int32_t
getTableVgroupFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
SVgroupInfo
*
pVgroup
);
int32_t
getTableVgroupFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
SVgroupInfo
*
pVgroup
);
...
@@ -87,6 +90,7 @@ int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, const char* pUser, con
...
@@ -87,6 +90,7 @@ int32_t getUserAuthFromCache(SParseMetaCache* pMetaCache, const char* pUser, con
bool
*
pPass
);
bool
*
pPass
);
int32_t
getUdfInfoFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pFunc
,
SFuncInfo
*
pInfo
);
int32_t
getUdfInfoFromCache
(
SParseMetaCache
*
pMetaCache
,
const
char
*
pFunc
,
SFuncInfo
*
pInfo
);
int32_t
getTableIndexFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
SArray
**
pIndexes
);
int32_t
getTableIndexFromCache
(
SParseMetaCache
*
pMetaCache
,
const
SName
*
pName
,
SArray
**
pIndexes
);
int32_t
getDnodeListFromCache
(
SParseMetaCache
*
pMetaCache
,
SArray
**
pDnodes
);
void
destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
);
void
destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
source/libs/parser/inc/sql.y
浏览文件 @
c79be2da
...
@@ -373,7 +373,9 @@ cmd ::= SHOW CREATE STABLE full_table_name(A).
...
@@ -373,7 +373,9 @@ cmd ::= SHOW CREATE STABLE full_table_name(A).
cmd ::= SHOW QUERIES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); }
cmd ::= SHOW QUERIES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); }
cmd ::= SHOW SCORES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); }
cmd ::= SHOW SCORES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); }
cmd ::= SHOW TOPICS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); }
cmd ::= SHOW TOPICS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); }
cmd ::= SHOW VARIABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLE_STMT); }
cmd ::= SHOW VARIABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); }
cmd ::= SHOW LOCAL VARIABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); }
cmd ::= SHOW DNODE NK_INTEGER(A) VARIABLES. { pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &A)); }
cmd ::= SHOW BNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); }
cmd ::= SHOW BNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); }
cmd ::= SHOW SNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); }
cmd ::= SHOW SNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); }
cmd ::= SHOW CLUSTER. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); }
cmd ::= SHOW CLUSTER. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
c79be2da
...
@@ -700,8 +700,11 @@ SNode* addEveryClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pEvery) {
...
@@ -700,8 +700,11 @@ SNode* addEveryClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pEvery) {
SNode
*
addFillClause
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
SNode
*
pFill
)
{
SNode
*
addFillClause
(
SAstCreateContext
*
pCxt
,
SNode
*
pStmt
,
SNode
*
pFill
)
{
CHECK_PARSER_STATUS
(
pCxt
);
CHECK_PARSER_STATUS
(
pCxt
);
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
))
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pStmt
)
&&
NULL
!=
pFill
)
{
((
SSelectStmt
*
)
pStmt
)
->
pFill
=
pFill
;
SFillNode
*
pFillClause
=
(
SFillNode
*
)
pFill
;
nodesDestroyNode
(
pFillClause
->
pWStartTs
);
pFillClause
->
pWStartTs
=
createPrimaryKeyCol
(
pCxt
);
((
SSelectStmt
*
)
pStmt
)
->
pFill
=
(
SNode
*
)
pFillClause
;
}
}
return
pStmt
;
return
pStmt
;
}
}
...
@@ -909,7 +912,7 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) {
...
@@ -909,7 +912,7 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) {
pOptions
->
watermark1
=
TSDB_DEFAULT_ROLLUP_WATERMARK
;
pOptions
->
watermark1
=
TSDB_DEFAULT_ROLLUP_WATERMARK
;
pOptions
->
watermark2
=
TSDB_DEFAULT_ROLLUP_WATERMARK
;
pOptions
->
watermark2
=
TSDB_DEFAULT_ROLLUP_WATERMARK
;
pOptions
->
ttl
=
TSDB_DEFAULT_TABLE_TTL
;
pOptions
->
ttl
=
TSDB_DEFAULT_TABLE_TTL
;
pOptions
->
commentNull
=
true
;
// mark null
pOptions
->
commentNull
=
true
;
// mark null
return
(
SNode
*
)
pOptions
;
return
(
SNode
*
)
pOptions
;
}
}
...
@@ -918,7 +921,7 @@ SNode* createAlterTableOptions(SAstCreateContext* pCxt) {
...
@@ -918,7 +921,7 @@ SNode* createAlterTableOptions(SAstCreateContext* pCxt) {
STableOptions
*
pOptions
=
(
STableOptions
*
)
nodesMakeNode
(
QUERY_NODE_TABLE_OPTIONS
);
STableOptions
*
pOptions
=
(
STableOptions
*
)
nodesMakeNode
(
QUERY_NODE_TABLE_OPTIONS
);
CHECK_OUT_OF_MEM
(
pOptions
);
CHECK_OUT_OF_MEM
(
pOptions
);
pOptions
->
ttl
=
-
1
;
pOptions
->
ttl
=
-
1
;
pOptions
->
commentNull
=
true
;
// mark null
pOptions
->
commentNull
=
true
;
// mark null
return
(
SNode
*
)
pOptions
;
return
(
SNode
*
)
pOptions
;
}
}
...
@@ -940,9 +943,9 @@ SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType
...
@@ -940,9 +943,9 @@ SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType
case
TABLE_OPTION_ROLLUP
:
case
TABLE_OPTION_ROLLUP
:
((
STableOptions
*
)
pOptions
)
->
pRollupFuncs
=
pVal
;
((
STableOptions
*
)
pOptions
)
->
pRollupFuncs
=
pVal
;
break
;
break
;
case
TABLE_OPTION_TTL
:{
case
TABLE_OPTION_TTL
:
{
int64_t
ttl
=
taosStr2Int64
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
);
int64_t
ttl
=
taosStr2Int64
(((
SToken
*
)
pVal
)
->
z
,
NULL
,
10
);
if
(
ttl
>
INT32_MAX
){
if
(
ttl
>
INT32_MAX
)
{
ttl
=
INT32_MAX
;
ttl
=
INT32_MAX
;
}
}
// ttl can not be smaller than 0, because there is a limitation in sql.y (TTL NK_INTEGER)
// ttl can not be smaller than 0, because there is a limitation in sql.y (TTL NK_INTEGER)
...
@@ -1194,6 +1197,14 @@ SNode* createShowTableDistributedStmt(SAstCreateContext* pCxt, SNode* pRealTable
...
@@ -1194,6 +1197,14 @@ SNode* createShowTableDistributedStmt(SAstCreateContext* pCxt, SNode* pRealTable
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
SNode
*
createShowDnodeVariablesStmt
(
SAstCreateContext
*
pCxt
,
SNode
*
pDnodeId
)
{
CHECK_PARSER_STATUS
(
pCxt
);
SShowDnodeVariablesStmt
*
pStmt
=
(
SShowDnodeVariablesStmt
*
)
nodesMakeNode
(
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
pDnodeId
=
pDnodeId
;
return
(
SNode
*
)
pStmt
;
}
SNode
*
createCreateUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
,
const
SToken
*
pPassword
)
{
SNode
*
createCreateUserStmt
(
SAstCreateContext
*
pCxt
,
SToken
*
pUserName
,
const
SToken
*
pPassword
)
{
CHECK_PARSER_STATUS
(
pCxt
);
CHECK_PARSER_STATUS
(
pCxt
);
char
password
[
TSDB_USET_PASSWORD_LEN
]
=
{
0
};
char
password
[
TSDB_USET_PASSWORD_LEN
]
=
{
0
};
...
...
source/libs/parser/src/parAstParser.c
浏览文件 @
c79be2da
...
@@ -397,6 +397,15 @@ static int32_t collectMetaKeyFromShowVariables(SCollectMetaKeyCxt* pCxt, SShowSt
...
@@ -397,6 +397,15 @@ static int32_t collectMetaKeyFromShowVariables(SCollectMetaKeyCxt* pCxt, SShowSt
pCxt
->
pMetaCache
);
pCxt
->
pMetaCache
);
}
}
static
int32_t
collectMetaKeyFromShowDnodeVariables
(
SCollectMetaKeyCxt
*
pCxt
,
SShowDnodeVariablesStmt
*
pStmt
)
{
int32_t
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
TSDB_INFORMATION_SCHEMA_DB
,
TSDB_INS_TABLE_DNODE_VARIABLES
,
pCxt
->
pMetaCache
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveDnodeRequiredInCache
(
pCxt
->
pMetaCache
);
}
return
code
;
}
static
int32_t
collectMetaKeyFromShowCreateDatabase
(
SCollectMetaKeyCxt
*
pCxt
,
SShowCreateDatabaseStmt
*
pStmt
)
{
static
int32_t
collectMetaKeyFromShowCreateDatabase
(
SCollectMetaKeyCxt
*
pCxt
,
SShowCreateDatabaseStmt
*
pStmt
)
{
return
reserveDbCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pCxt
->
pMetaCache
);
return
reserveDbCfgInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pCxt
->
pMetaCache
);
}
}
...
@@ -419,6 +428,24 @@ static int32_t collectMetaKeyFromDelete(SCollectMetaKeyCxt* pCxt, SDeleteStmt* p
...
@@ -419,6 +428,24 @@ static int32_t collectMetaKeyFromDelete(SCollectMetaKeyCxt* pCxt, SDeleteStmt* p
return
collectMetaKeyFromRealTableImpl
(
pCxt
,
(
SRealTableNode
*
)
pStmt
->
pFromTable
,
AUTH_TYPE_WRITE
);
return
collectMetaKeyFromRealTableImpl
(
pCxt
,
(
SRealTableNode
*
)
pStmt
->
pFromTable
,
AUTH_TYPE_WRITE
);
}
}
static
int32_t
collectMetaKeyFromShowBlockDist
(
SCollectMetaKeyCxt
*
pCxt
,
SShowTableDistributedStmt
*
pStmt
)
{
SName
name
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
pCxt
->
pParseCxt
->
acctId
};
strcpy
(
name
.
dbname
,
pStmt
->
dbName
);
strcpy
(
name
.
tname
,
pStmt
->
tableName
);
int32_t
code
=
catalogRemoveTableMeta
(
pCxt
->
pParseCxt
->
pCatalog
,
&
name
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveTableMetaInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveTableVgroupInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pStmt
->
tableName
,
pCxt
->
pMetaCache
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
reserveDbVgInfoInCache
(
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
pCxt
->
pMetaCache
);
}
return
code
;
}
static
int32_t
collectMetaKeyFromQuery
(
SCollectMetaKeyCxt
*
pCxt
,
SNode
*
pStmt
)
{
static
int32_t
collectMetaKeyFromQuery
(
SCollectMetaKeyCxt
*
pCxt
,
SNode
*
pStmt
)
{
pCxt
->
pStmt
=
pStmt
;
pCxt
->
pStmt
=
pStmt
;
switch
(
nodeType
(
pStmt
))
{
switch
(
nodeType
(
pStmt
))
{
...
@@ -484,8 +511,10 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
...
@@ -484,8 +511,10 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
return
collectMetaKeyFromShowConnections
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
return
collectMetaKeyFromShowConnections
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_QUERIES_STMT
:
case
QUERY_NODE_SHOW_QUERIES_STMT
:
return
collectMetaKeyFromShowQueries
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
return
collectMetaKeyFromShowQueries
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_VARIABLE_STMT
:
case
QUERY_NODE_SHOW_VARIABLE
S
_STMT
:
return
collectMetaKeyFromShowVariables
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
return
collectMetaKeyFromShowVariables
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_DNODE_VARIABLES_STMT
:
return
collectMetaKeyFromShowDnodeVariables
(
pCxt
,
(
SShowDnodeVariablesStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
:
case
QUERY_NODE_SHOW_CREATE_DATABASE_STMT
:
return
collectMetaKeyFromShowCreateDatabase
(
pCxt
,
(
SShowCreateDatabaseStmt
*
)
pStmt
);
return
collectMetaKeyFromShowCreateDatabase
(
pCxt
,
(
SShowCreateDatabaseStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
case
QUERY_NODE_SHOW_CREATE_TABLE_STMT
:
...
@@ -497,6 +526,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
...
@@ -497,6 +526,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) {
return
collectMetaKeyFromShowTransactions
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
return
collectMetaKeyFromShowTransactions
(
pCxt
,
(
SShowStmt
*
)
pStmt
);
case
QUERY_NODE_DELETE_STMT
:
case
QUERY_NODE_DELETE_STMT
:
return
collectMetaKeyFromDelete
(
pCxt
,
(
SDeleteStmt
*
)
pStmt
);
return
collectMetaKeyFromDelete
(
pCxt
,
(
SDeleteStmt
*
)
pStmt
);
case
QUERY_NODE_SHOW_TABLE_DISTRIBUTED_STMT
:
return
collectMetaKeyFromShowBlockDist
(
pCxt
,
(
SShowTableDistributedStmt
*
)
pStmt
);
default:
default:
break
;
break
;
}
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/parser/src/parUtil.c
浏览文件 @
c79be2da
...
@@ -196,6 +196,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
...
@@ -196,6 +196,8 @@ static char* getSyntaxErrFormat(int32_t errCode) {
return
"%s function does not supportted in group query"
;
return
"%s function does not supportted in group query"
;
case
TSDB_CODE_PAR_INVALID_TABLE_OPTION
:
case
TSDB_CODE_PAR_INVALID_TABLE_OPTION
:
return
"Invalid option %s"
;
return
"Invalid option %s"
;
case
TSDB_CODE_PAR_INVALID_INTERP_CLAUSE
:
return
"Invalid usage of RANGE clause, EVERY clause or FILL clause"
;
case
TSDB_CODE_OUT_OF_MEMORY
:
case
TSDB_CODE_OUT_OF_MEMORY
:
return
"Out of memory"
;
return
"Out of memory"
;
default:
default:
...
@@ -559,6 +561,7 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog
...
@@ -559,6 +561,7 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
buildTableReq
(
pMetaCache
->
pTableIndex
,
&
pCatalogReq
->
pTableIndex
);
code
=
buildTableReq
(
pMetaCache
->
pTableIndex
,
&
pCatalogReq
->
pTableIndex
);
}
}
pCatalogReq
->
dNodeRequired
=
pMetaCache
->
dnodeRequired
;
return
code
;
return
code
;
}
}
...
@@ -654,6 +657,7 @@ int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMet
...
@@ -654,6 +657,7 @@ int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMet
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
putTableDataToCache
(
pCatalogReq
->
pTableIndex
,
pMetaData
->
pTableIndex
,
&
pMetaCache
->
pTableIndex
);
code
=
putTableDataToCache
(
pCatalogReq
->
pTableIndex
,
pMetaData
->
pTableIndex
,
&
pMetaCache
->
pTableIndex
);
}
}
pMetaCache
->
pDnodes
=
pMetaData
->
pDnodeList
;
return
code
;
return
code
;
}
}
...
@@ -873,6 +877,19 @@ int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName,
...
@@ -873,6 +877,19 @@ int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName,
return
code
;
return
code
;
}
}
int32_t
reserveDnodeRequiredInCache
(
SParseMetaCache
*
pMetaCache
)
{
pMetaCache
->
dnodeRequired
=
true
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
getDnodeListFromCache
(
SParseMetaCache
*
pMetaCache
,
SArray
**
pDnodes
)
{
*
pDnodes
=
taosArrayDup
(
pMetaCache
->
pDnodes
);
if
(
NULL
==
*
pDnodes
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
return
TSDB_CODE_SUCCESS
;
}
void
destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
)
{
void
destoryParseMetaCache
(
SParseMetaCache
*
pMetaCache
)
{
taosHashCleanup
(
pMetaCache
->
pTableMeta
);
taosHashCleanup
(
pMetaCache
->
pTableMeta
);
taosHashCleanup
(
pMetaCache
->
pDbVgroup
);
taosHashCleanup
(
pMetaCache
->
pDbVgroup
);
...
...
source/libs/parser/src/sql.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalog.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/parser/test/mockCatalogService.h
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/parser/test/parInitialDTest.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/parser/test/parSelectTest.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/parser/test/parShowToUse.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/planner/src/planLogicCreater.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/planner/src/planOptimizer.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/planner/src/planUtil.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/planner/test/planOptimizeTest.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/planner/test/planOtherTest.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/qworker/inc/qwMsg.h
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/qworker/src/qwMsg.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/qworker/src/qworker.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/stream/src/stream.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/stream/src/streamDispatch.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/stream/src/streamExec.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/stream/src/streamTask.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncInt.h
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncRaftCfg.h
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncSnapshot.h
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/src/syncAppendEntriesReply.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/src/syncCommit.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMain.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMessage.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRaftCfg.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/src/syncReplication.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/src/syncSnapshot.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/src/syncUtil.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/test/CMakeLists.txt
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/test/syncConfigChangeSnapshotTest.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/test/syncConfigChangeTest.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRaftCfgTest.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRaftLogTest2.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRaftLogTest3.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/test/syncReconfigFinishTest.cpp
0 → 100644
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/test/syncReplicateTest.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/test/syncSnapshotSenderTest.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/test/syncSnapshotTest.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/sync/test/syncTestTool.cpp
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/tdb/src/db/tdbPage.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/tdb/src/inc/tdbInt.h
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/tdb/test/CMakeLists.txt
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/libs/tdb/test/tdbExOVFLTest.cpp
0 → 100644
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
source/util/src/terror.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/pytest/util/common.py
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/script/jenkins/basic.txt
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/script/tsim/dnode/redistribute_vgroup_replica3_v1_leader.sim
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/script/tsim/mnode/basic5.sim
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/script/tsim/sma/rsmaCreateInsertQuery.sim
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/script/tsim/stream/distributeInterval0.sim
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/script/tsim/stream/distributesession0.sim
0 → 100644
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/script/tsim/stream/schedSnode.sim
0 → 100644
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/script/tsim/stream/windowClose.sim
0 → 100644
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/system-test/1-insert/create_table_comment.py
已删除
100644 → 0
浏览文件 @
8494bf17
此差异已折叠。
点击以展开。
tests/system-test/1-insert/table_comment.py
0 → 100644
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/system-test/2-query/Today.py
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/5dnode3mnodeDrop.py
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/5dnode3mnodeStop.py
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/system-test/6-cluster/5dnode3mnodeStopInsert.py
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeDb3.py
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeDb4.py
0 → 100644
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/subscribeStb4.py
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/system-test/7-tmq/tmqCommon.py
0 → 100644
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/system-test/fulltest.sh
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/test/c/sdbDump.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
tests/test/c/tmqSim.c
浏览文件 @
c79be2da
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录