Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
83a824a1
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1191
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看板
提交
83a824a1
编写于
4月 14, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/check
上级
2635df08
a908d3f1
变更
87
展开全部
隐藏空白更改
内联
并排
Showing
87 changed file
with
3599 addition
and
4360 deletion
+3599
-4360
.devcontainer/Dockerfile
.devcontainer/Dockerfile
+1
-1
.devcontainer/devcontainer.json
.devcontainer/devcontainer.json
+1
-1
cmake/cmake.define
cmake/cmake.define
+15
-11
include/common/tdatablock.h
include/common/tdatablock.h
+1
-2
include/common/tmsg.h
include/common/tmsg.h
+0
-3
include/common/ttokendef.h
include/common/ttokendef.h
+44
-43
include/common/ttypes.h
include/common/ttypes.h
+1
-0
include/libs/function/functionMgt.h
include/libs/function/functionMgt.h
+1
-1
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+5
-0
include/util/taoserror.h
include/util/taoserror.h
+6
-3
include/util/tencode.h
include/util/tencode.h
+0
-1
include/util/tmacro.h
include/util/tmacro.h
+0
-40
packaging/install.sh
packaging/install.sh
+7
-7
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+3
-0
source/client/src/clientMain.c
source/client/src/clientMain.c
+23
-21
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+8
-4
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+20
-1
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
+1
-1
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
+3
-3
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+19
-18
source/dnode/mnode/impl/src/mndGrant.c
source/dnode/mnode/impl/src/mndGrant.c
+6
-1
source/dnode/mnode/impl/src/mndOffset.c
source/dnode/mnode/impl/src/mndOffset.c
+1
-0
source/dnode/mnode/impl/src/mndSubscribe.c
source/dnode/mnode/impl/src/mndSubscribe.c
+2
-1
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+46
-36
source/dnode/mnode/impl/test/topic/topic.cpp
source/dnode/mnode/impl/test/topic/topic.cpp
+3
-0
source/dnode/vnode/CMakeLists.txt
source/dnode/vnode/CMakeLists.txt
+3
-7
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+8
-82
source/dnode/vnode/src/inc/meta.h
source/dnode/vnode/src/inc/meta.h
+42
-18
source/dnode/vnode/src/inc/tq.h
source/dnode/vnode/src/inc/tq.h
+59
-42
source/dnode/vnode/src/inc/tsdb.h
source/dnode/vnode/src/inc/tsdb.h
+177
-117
source/dnode/vnode/src/inc/tsdbSma.h
source/dnode/vnode/src/inc/tsdbSma.h
+0
-68
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+93
-0
source/dnode/vnode/src/inc/vnodeInt.h
source/dnode/vnode/src/inc/vnodeInt.h
+8
-134
source/dnode/vnode/src/meta/metaCache.c
source/dnode/vnode/src/meta/metaCache.c
+0
-40
source/dnode/vnode/src/meta/metaCfg.c
source/dnode/vnode/src/meta/metaCfg.c
+0
-29
source/dnode/vnode/src/meta/metaMain.c
source/dnode/vnode/src/meta/metaMain.c
+0
-22
source/dnode/vnode/src/meta/metaQuery.c
source/dnode/vnode/src/meta/metaQuery.c
+0
-16
source/dnode/vnode/src/meta/metaTbCfg.c
source/dnode/vnode/src/meta/metaTbCfg.c
+0
-48
source/dnode/vnode/src/meta/metaTbTag.c
source/dnode/vnode/src/meta/metaTbTag.c
+0
-16
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+2
-5
source/dnode/vnode/src/tsdb/tsdbBDBImpl.c
source/dnode/vnode/src/tsdb/tsdbBDBImpl.c
+0
-169
source/dnode/vnode/src/vnd/vnodeBufferPool2.c
source/dnode/vnode/src/vnd/vnodeBufferPool2.c
+149
-0
source/dnode/vnode/src/vnd/vnodeCommit.c
source/dnode/vnode/src/vnd/vnodeCommit.c
+2
-8
source/dnode/vnode/src/vnd/vnodeInt.c
source/dnode/vnode/src/vnd/vnodeInt.c
+1
-22
source/dnode/vnode/src/vnd/vnodeModule.c
source/dnode/vnode/src/vnd/vnodeModule.c
+158
-0
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+17
-52
source/dnode/vnode/src/vnd/vnodeSvr.c
source/dnode/vnode/src/vnd/vnodeSvr.c
+302
-0
source/dnode/vnode/src/vnd/vnodeWrite.c
source/dnode/vnode/src/vnd/vnodeWrite.c
+0
-273
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+58
-150
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+8
-7
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+1
-1
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+22
-125
source/libs/executor/src/groupoperator.c
source/libs/executor/src/groupoperator.c
+2
-2
source/libs/executor/src/scanoperator.c
source/libs/executor/src/scanoperator.c
+53
-58
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+4
-4
source/libs/function/inc/builtins.h
source/libs/function/inc/builtins.h
+2
-2
source/libs/function/src/builtins.c
source/libs/function/src/builtins.c
+399
-214
source/libs/function/src/functionMgt.c
source/libs/function/src/functionMgt.c
+2
-2
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+1
-1
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+1
-7
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+12
-28
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+107
-307
source/libs/parser/src/parUtil.c
source/libs/parser/src/parUtil.c
+0
-4
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+1602
-2012
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+3
-6
source/libs/planner/test/plannerTest.cpp
source/libs/planner/test/plannerTest.cpp
+4
-4
source/libs/scalar/src/sclfunc.c
source/libs/scalar/src/sclfunc.c
+22
-5
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+1
-1
tests/pytest/concurrent_inquiry.sh
tests/pytest/concurrent_inquiry.sh
+2
-2
tests/pytest/crash_gen.sh
tests/pytest/crash_gen.sh
+2
-2
tests/pytest/perf_gen.sh
tests/pytest/perf_gen.sh
+2
-2
tests/pytest/test.sh
tests/pytest/test.sh
+1
-1
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+1
-1
tests/script/sh/cfg.sh
tests/script/sh/cfg.sh
+3
-3
tests/script/sh/clear.sh
tests/script/sh/clear.sh
+3
-3
tests/script/sh/deploy.sh
tests/script/sh/deploy.sh
+1
-1
tests/script/sh/exec-default.sh
tests/script/sh/exec-default.sh
+3
-3
tests/script/sh/exec-no-random-fail.sh
tests/script/sh/exec-no-random-fail.sh
+3
-3
tests/script/sh/exec-random-fail.sh
tests/script/sh/exec-random-fail.sh
+3
-3
tests/script/sh/exec.sh
tests/script/sh/exec.sh
+1
-1
tests/script/sh/exec_tarbitrator.sh
tests/script/sh/exec_tarbitrator.sh
+3
-3
tests/script/sh/move_dnode.sh
tests/script/sh/move_dnode.sh
+3
-3
tests/script/sh/mv_old_data.sh
tests/script/sh/mv_old_data.sh
+3
-3
tests/script/test.sh
tests/script/test.sh
+1
-1
tests/script/tsim/query/charScalarFunction.sim
tests/script/tsim/query/charScalarFunction.sim
+14
-14
tests/test/c/tmqDemo.c
tests/test/c/tmqDemo.c
+8
-4
tools/taosTools-1.4.1-Linux-x64.tar.gz
tools/taosTools-1.4.1-Linux-x64.tar.gz
+0
-0
未找到文件。
.devcontainer/Dockerfile
浏览文件 @
83a824a1
...
@@ -7,4 +7,4 @@ FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT}
...
@@ -7,4 +7,4 @@ FROM mcr.microsoft.com/vscode/devcontainers/cpp:0-${VARIANT}
# [Optional] Uncomment this section to install additional packages.
# [Optional] Uncomment this section to install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# && apt-get -y install --no-install-recommends <your-package-list-here>
RUN
apt-get update
&&
apt-get
-y
install
tree vim
RUN
apt-get update
&&
apt-get
-y
install
tree vim
tmux
.devcontainer/devcontainer.json
浏览文件 @
83a824a1
...
@@ -32,7 +32,7 @@
...
@@ -32,7 +32,7 @@
//
Use
'forwardPorts'
to
make
a
list
of
ports
inside
the
container
available
locally.
//
Use
'forwardPorts'
to
make
a
list
of
ports
inside
the
container
available
locally.
//
"forwardPorts"
:
[],
//
"forwardPorts"
:
[],
//
Use
'postCreateCommand'
to
run
commands
after
the
container
is
created.
//
Use
'postCreateCommand'
to
run
commands
after
the
container
is
created.
//
"postCreateCommand"
:
"gcc -v
"
,
"postCreateCommand"
:
"wget https://raw.githubusercontent.com/hzcheng/config/master/.tmux.conf -P /root
"
,
//
Comment
out
connect
as
root
instead.
More
info:
https://aka.ms/vscode-remote/containers/non-root.
//
Comment
out
connect
as
root
instead.
More
info:
https://aka.ms/vscode-remote/containers/non-root.
"remoteUser"
:
"root"
"remoteUser"
:
"root"
}
}
\ No newline at end of file
cmake/cmake.define
浏览文件 @
83a824a1
...
@@ -46,16 +46,20 @@ IF (TD_WINDOWS)
...
@@ -46,16 +46,20 @@ IF (TD_WINDOWS)
ENDIF ()
ENDIF ()
ELSE ()
ELSE ()
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
IF (${SANITIZER} MATCHES "true")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3")
#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3")
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fno-sanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -static-libasan -g3")
MESSAGE(STATUS "Will compile with Address Sanitizer!")
ELSE ()
MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3")
ADD_DEFINITIONS("-D_TD_ARM_")
ENDIF ()
ELSE ()
ADD_DEFINITIONS("-msse4.2 -mfma")
MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}")
ENDIF ()
IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
ADD_DEFINITIONS("-D_TD_ARM_")
ELSE ()
ADD_DEFINITIONS("-msse4.2 -mfma")
ENDIF ()
ENDIF ()
ENDIF ()
include/common/tdatablock.h
浏览文件 @
83a824a1
...
@@ -203,11 +203,10 @@ void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows);
...
@@ -203,11 +203,10 @@ void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows);
void
blockDataCleanup
(
SSDataBlock
*
pDataBlock
);
void
blockDataCleanup
(
SSDataBlock
*
pDataBlock
);
size_t
blockDataGetCapacityInRow
(
const
SSDataBlock
*
pBlock
,
size_t
pageSize
);
size_t
blockDataGetCapacityInRow
(
const
SSDataBlock
*
pBlock
,
size_t
pageSize
);
void
*
blockDataDestroy
(
SSDataBlock
*
pBlock
);
int32_t
blockDataTrimFirstNRows
(
SSDataBlock
*
pBlock
,
size_t
n
);
int32_t
blockDataTrimFirstNRows
(
SSDataBlock
*
pBlock
,
size_t
n
);
SSDataBlock
*
createOneDataBlock
(
const
SSDataBlock
*
pDataBlock
);
SSDataBlock
*
createOneDataBlock
(
const
SSDataBlock
*
pDataBlock
,
bool
copyData
);
void
blockDebugShowData
(
const
SArray
*
dataBlocks
);
void
blockDebugShowData
(
const
SArray
*
dataBlocks
);
...
...
include/common/tmsg.h
浏览文件 @
83a824a1
...
@@ -1885,7 +1885,6 @@ typedef struct {
...
@@ -1885,7 +1885,6 @@ typedef struct {
char
topicName
[
TSDB_TOPIC_FNAME_LEN
];
char
topicName
[
TSDB_TOPIC_FNAME_LEN
];
char
cgroup
[
TSDB_CGROUP_LEN
];
char
cgroup
[
TSDB_CGROUP_LEN
];
char
*
sql
;
char
*
sql
;
char
*
logicalPlan
;
char
*
physicalPlan
;
char
*
physicalPlan
;
char
*
qmsg
;
char
*
qmsg
;
}
SMqSetCVgReq
;
}
SMqSetCVgReq
;
...
@@ -1899,7 +1898,6 @@ static FORCE_INLINE int32_t tEncodeSMqSetCVgReq(void** buf, const SMqSetCVgReq*
...
@@ -1899,7 +1898,6 @@ static FORCE_INLINE int32_t tEncodeSMqSetCVgReq(void** buf, const SMqSetCVgReq*
tlen
+=
taosEncodeString
(
buf
,
pReq
->
topicName
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
topicName
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
cgroup
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
cgroup
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
sql
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
sql
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
logicalPlan
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
physicalPlan
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
physicalPlan
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
qmsg
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
qmsg
);
return
tlen
;
return
tlen
;
...
@@ -1913,7 +1911,6 @@ static FORCE_INLINE void* tDecodeSMqSetCVgReq(void* buf, SMqSetCVgReq* pReq) {
...
@@ -1913,7 +1911,6 @@ static FORCE_INLINE void* tDecodeSMqSetCVgReq(void* buf, SMqSetCVgReq* pReq) {
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
topicName
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
topicName
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
cgroup
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
cgroup
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
sql
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
sql
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
logicalPlan
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
physicalPlan
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
physicalPlan
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
qmsg
);
buf
=
taosDecodeString
(
buf
,
&
pReq
->
qmsg
);
return
buf
;
return
buf
;
...
...
include/common/ttokendef.h
浏览文件 @
83a824a1
...
@@ -181,49 +181,50 @@
...
@@ -181,49 +181,50 @@
#define TK_NULL 163
#define TK_NULL 163
#define TK_FIRST 164
#define TK_FIRST 164
#define TK_LAST 165
#define TK_LAST 165
#define TK_NOW 166
#define TK_CAST 166
#define TK_TODAY 167
#define TK_NOW 167
#define TK_ROWTS 168
#define TK_TODAY 168
#define TK_TBNAME 169
#define TK_ROWTS 169
#define TK_QSTARTTS 170
#define TK_TBNAME 170
#define TK_QENDTS 171
#define TK_QSTARTTS 171
#define TK_WSTARTTS 172
#define TK_QENDTS 172
#define TK_WENDTS 173
#define TK_WSTARTTS 173
#define TK_WDURATION 174
#define TK_WENDTS 174
#define TK_BETWEEN 175
#define TK_WDURATION 175
#define TK_IS 176
#define TK_BETWEEN 176
#define TK_NK_LT 177
#define TK_IS 177
#define TK_NK_GT 178
#define TK_NK_LT 178
#define TK_NK_LE 179
#define TK_NK_GT 179
#define TK_NK_GE 180
#define TK_NK_LE 180
#define TK_NK_NE 181
#define TK_NK_GE 181
#define TK_MATCH 182
#define TK_NK_NE 182
#define TK_NMATCH 183
#define TK_MATCH 183
#define TK_JOIN 184
#define TK_NMATCH 184
#define TK_INNER 185
#define TK_JOIN 185
#define TK_SELECT 186
#define TK_INNER 186
#define TK_DISTINCT 187
#define TK_SELECT 187
#define TK_WHERE 188
#define TK_DISTINCT 188
#define TK_PARTITION 189
#define TK_WHERE 189
#define TK_BY 190
#define TK_PARTITION 190
#define TK_SESSION 191
#define TK_BY 191
#define TK_STATE_WINDOW 192
#define TK_SESSION 192
#define TK_SLIDING 193
#define TK_STATE_WINDOW 193
#define TK_FILL 194
#define TK_SLIDING 194
#define TK_VALUE 195
#define TK_FILL 195
#define TK_NONE 196
#define TK_VALUE 196
#define TK_PREV 197
#define TK_NONE 197
#define TK_LINEAR 198
#define TK_PREV 198
#define TK_NEXT 199
#define TK_LINEAR 199
#define TK_GROUP 200
#define TK_NEXT 200
#define TK_HAVING 201
#define TK_GROUP 201
#define TK_ORDER 202
#define TK_HAVING 202
#define TK_SLIMIT 203
#define TK_ORDER 203
#define TK_SOFFSET 204
#define TK_SLIMIT 204
#define TK_LIMIT 205
#define TK_SOFFSET 205
#define TK_OFFSET 206
#define TK_LIMIT 206
#define TK_ASC 207
#define TK_OFFSET 207
#define TK_NULLS 208
#define TK_ASC 208
#define TK_NULLS 209
#define TK_NK_SPACE 300
#define TK_NK_SPACE 300
#define TK_NK_COMMENT 301
#define TK_NK_COMMENT 301
...
...
include/common/ttypes.h
浏览文件 @
83a824a1
...
@@ -181,6 +181,7 @@ typedef struct {
...
@@ -181,6 +181,7 @@ typedef struct {
#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT)
#define IS_SIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_TINYINT && (_t) <= TSDB_DATA_TYPE_BIGINT)
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
#define IS_UNSIGNED_NUMERIC_TYPE(_t) ((_t) >= TSDB_DATA_TYPE_UTINYINT && (_t) <= TSDB_DATA_TYPE_UBIGINT)
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
#define IS_FLOAT_TYPE(_t) ((_t) == TSDB_DATA_TYPE_FLOAT || (_t) == TSDB_DATA_TYPE_DOUBLE)
#define IS_INTEGER_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)))
#define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t)))
#define IS_NUMERIC_TYPE(_t) ((IS_SIGNED_NUMERIC_TYPE(_t)) || (IS_UNSIGNED_NUMERIC_TYPE(_t)) || (IS_FLOAT_TYPE(_t)))
#define IS_MATHABLE_TYPE(_t) (IS_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
#define IS_MATHABLE_TYPE(_t) (IS_NUMERIC_TYPE(_t) || (_t) == (TSDB_DATA_TYPE_BOOL) || (_t) == (TSDB_DATA_TYPE_TIMESTAMP))
...
...
include/libs/function/functionMgt.h
浏览文件 @
83a824a1
...
@@ -123,7 +123,7 @@ void fmFuncMgtDestroy();
...
@@ -123,7 +123,7 @@ void fmFuncMgtDestroy();
int32_t
fmGetFuncInfo
(
const
char
*
pFuncName
,
int32_t
*
pFuncId
,
int32_t
*
pFuncType
);
int32_t
fmGetFuncInfo
(
const
char
*
pFuncName
,
int32_t
*
pFuncId
,
int32_t
*
pFuncType
);
int32_t
fmGetFuncResultType
(
SFunctionNode
*
pFunc
);
int32_t
fmGetFuncResultType
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
);
bool
fmIsAggFunc
(
int32_t
funcId
);
bool
fmIsAggFunc
(
int32_t
funcId
);
bool
fmIsScalarFunc
(
int32_t
funcId
);
bool
fmIsScalarFunc
(
int32_t
funcId
);
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
83a824a1
...
@@ -267,6 +267,11 @@ typedef struct SDescribeStmt {
...
@@ -267,6 +267,11 @@ typedef struct SDescribeStmt {
STableMeta
*
pMeta
;
STableMeta
*
pMeta
;
}
SDescribeStmt
;
}
SDescribeStmt
;
typedef
struct
SKillStmt
{
ENodeType
type
;
int32_t
targetId
;
}
SKillStmt
;
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/util/taoserror.h
浏览文件 @
83a824a1
...
@@ -566,8 +566,6 @@ int32_t* taosGetErrno();
...
@@ -566,8 +566,6 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_AMBIGUOUS_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2603)
#define TSDB_CODE_PAR_AMBIGUOUS_COLUMN TAOS_DEF_ERROR_CODE(0, 0x2603)
#define TSDB_CODE_PAR_WRONG_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x2604)
#define TSDB_CODE_PAR_WRONG_VALUE_TYPE TAOS_DEF_ERROR_CODE(0, 0x2604)
#define TSDB_CODE_PAR_INVALID_FUNTION TAOS_DEF_ERROR_CODE(0, 0x2605)
#define TSDB_CODE_PAR_INVALID_FUNTION TAOS_DEF_ERROR_CODE(0, 0x2605)
#define TSDB_CODE_PAR_FUNTION_PARA_NUM TAOS_DEF_ERROR_CODE(0, 0x2606)
#define TSDB_CODE_PAR_FUNTION_PARA_TYPE TAOS_DEF_ERROR_CODE(0, 0x2607)
#define TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION TAOS_DEF_ERROR_CODE(0, 0x2608)
#define TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION TAOS_DEF_ERROR_CODE(0, 0x2608)
#define TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT TAOS_DEF_ERROR_CODE(0, 0x2609)
#define TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT TAOS_DEF_ERROR_CODE(0, 0x2609)
#define TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION TAOS_DEF_ERROR_CODE(0, 0x260A)
#define TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION TAOS_DEF_ERROR_CODE(0, 0x260A)
...
@@ -601,7 +599,12 @@ int32_t* taosGetErrno();
...
@@ -601,7 +599,12 @@ int32_t* taosGetErrno();
#define TSDB_CODE_PAR_INVALID_KEEP_UNIT TAOS_DEF_ERROR_CODE(0, 0x2626)
#define TSDB_CODE_PAR_INVALID_KEEP_UNIT TAOS_DEF_ERROR_CODE(0, 0x2626)
//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)
//function
#define TSDB_CODE_FUNC_FUNTION_ERROR TAOS_DEF_ERROR_CODE(0, 0x2800)
#define TSDB_CODE_FUNC_FUNTION_PARA_NUM TAOS_DEF_ERROR_CODE(0, 0x2801)
#define TSDB_CODE_FUNC_FUNTION_PARA_TYPE TAOS_DEF_ERROR_CODE(0, 0x2802)
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/util/tencode.h
浏览文件 @
83a824a1
...
@@ -18,7 +18,6 @@
...
@@ -18,7 +18,6 @@
#include "tcoding.h"
#include "tcoding.h"
#include "tfreelist.h"
#include "tfreelist.h"
#include "tmacro.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
...
...
include/util/tmacro.h
已删除
100644 → 0
浏览文件 @
2635df08
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_UTIL_MACRO_H_
#define _TD_UTIL_MACRO_H_
#include "os.h"
#ifdef __cplusplus
extern
"C"
{
#endif
// Module init/clear MACRO definitions
#define TD_MOD_UNINITIALIZED 0
#define TD_MOD_INITIALIZED 1
typedef
int8_t
td_mode_flag_t
;
#define TD_CHECK_AND_SET_MODE_INIT(FLAG) atomic_val_compare_exchange_8((FLAG), TD_MOD_UNINITIALIZED, TD_MOD_INITIALIZED)
#define TD_CHECK_AND_SET_MOD_CLEAR(FLAG) atomic_val_compare_exchange_8((FLAG), TD_MOD_INITIALIZED, TD_MOD_UNINITIALIZED)
#define TD_IS_NULL(PTR) ((PTR) == NULL)
#ifdef __cplusplus
}
#endif
#endif
/*_TD_UTIL_MACRO_H_*/
\ No newline at end of file
packaging/install.sh
浏览文件 @
83a824a1
...
@@ -460,14 +460,14 @@ function install_service_on_systemd() {
...
@@ -460,14 +460,14 @@ function install_service_on_systemd() {
}
}
function
install_service
()
{
function
install_service
()
{
if
((
${
service_mod
}
==
0
))
;
then
#
if ((${service_mod}==0)); then
install_service_on_systemd
#
install_service_on_systemd
elif
((
${
service_mod
}
==
1
))
;
then
#
elif ((${service_mod}==1)); then
install_service_on_sysvinit
#
install_service_on_sysvinit
else
#
else
# must manual stop taosd
#
# must manual stop taosd
kill_process taosd
kill_process taosd
fi
#
fi
}
}
function
install_TDengine
()
{
function
install_TDengine
()
{
...
...
source/client/src/clientImpl.c
浏览文件 @
83a824a1
...
@@ -596,12 +596,15 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
...
@@ -596,12 +596,15 @@ void doSetOneRowPtr(SReqResultInfo* pResultInfo) {
pResultInfo
->
row
[
i
]
=
varDataVal
(
pStart
);
pResultInfo
->
row
[
i
]
=
varDataVal
(
pStart
);
}
else
{
}
else
{
pResultInfo
->
row
[
i
]
=
NULL
;
pResultInfo
->
row
[
i
]
=
NULL
;
pResultInfo
->
length
[
i
]
=
0
;
}
}
}
else
{
}
else
{
if
(
!
colDataIsNull_f
(
pCol
->
nullbitmap
,
pResultInfo
->
current
))
{
if
(
!
colDataIsNull_f
(
pCol
->
nullbitmap
,
pResultInfo
->
current
))
{
pResultInfo
->
row
[
i
]
=
pResultInfo
->
pCol
[
i
].
pData
+
bytes
*
pResultInfo
->
current
;
pResultInfo
->
row
[
i
]
=
pResultInfo
->
pCol
[
i
].
pData
+
bytes
*
pResultInfo
->
current
;
pResultInfo
->
length
[
i
]
=
bytes
;
}
else
{
}
else
{
pResultInfo
->
row
[
i
]
=
NULL
;
pResultInfo
->
row
[
i
]
=
NULL
;
pResultInfo
->
length
[
i
]
=
0
;
}
}
}
}
}
}
...
...
source/client/src/clientMain.c
浏览文件 @
83a824a1
...
@@ -410,7 +410,11 @@ bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) {
...
@@ -410,7 +410,11 @@ bool taos_is_null(TAOS_RES *res, int32_t row, int32_t col) {
}
}
SResultColumn
*
pCol
=
&
pResultInfo
->
pCol
[
col
];
SResultColumn
*
pCol
=
&
pResultInfo
->
pCol
[
col
];
return
colDataIsNull_f
(
pCol
->
nullbitmap
,
row
);
if
(
IS_VAR_DATA_TYPE
(
pResultInfo
->
fields
[
col
].
type
))
{
return
(
pCol
->
offset
[
row
]
==
-
1
);
}
else
{
return
colDataIsNull_f
(
pCol
->
nullbitmap
,
row
);
}
}
}
bool
taos_is_update_query
(
TAOS_RES
*
res
)
{
return
taos_num_fields
(
res
)
==
0
;
}
bool
taos_is_update_query
(
TAOS_RES
*
res
)
{
return
taos_num_fields
(
res
)
==
0
;
}
...
@@ -463,37 +467,35 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
...
@@ -463,37 +467,35 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
if
(
res
==
NULL
)
{
if
(
res
==
NULL
)
{
return
0
;
return
0
;
}
}
if
(
TD_RES_QUERY
(
res
))
{
if
(
TD_RES_TMQ
(
res
))
{
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
res
;
SReqResultInfo
*
pResultInfo
=
tmqGetNextResInfo
(
res
);
if
(
pResultInfo
==
NULL
)
{
if
(
pRequest
->
type
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
||
pRequest
->
type
==
TSDB_SQL_INSERT
||
(
*
numOfRows
)
=
0
;
pRequest
->
code
!=
TSDB_CODE_SUCCESS
||
taos_num_fields
(
res
)
==
0
)
{
return
0
;
return
0
;
}
}
doFetchRows
(
pRequest
,
false
,
false
);
SReqResultInfo
*
pResultInfo
=
&
pRequest
->
body
.
resInfo
;
pResultInfo
->
current
=
pResultInfo
->
numOfRows
;
pResultInfo
->
current
=
pResultInfo
->
numOfRows
;
(
*
numOfRows
)
=
pResultInfo
->
numOfRows
;
(
*
numOfRows
)
=
pResultInfo
->
numOfRows
;
(
*
pData
)
=
(
void
*
)
pResultInfo
->
pData
;
(
*
pData
)
=
(
void
*
)
pResultInfo
->
pData
;
return
0
;
return
0
;
}
}
else
if
(
TD_RES_TMQ
(
res
))
{
SRequestObj
*
pRequest
=
(
SRequestObj
*
)
res
;
SReqResultInfo
*
pResultInfo
=
tmqGetNextResInfo
(
res
);
if
(
pResultInfo
==
NULL
)
return
-
1
;
pResultInfo
->
current
=
pResultInfo
->
numOfRows
;
if
(
pRequest
->
type
==
TSDB_SQL_RETRIEVE_EMPTY_RESULT
||
pRequest
->
type
==
TSDB_SQL_INSERT
||
(
*
numOfRows
)
=
pResultInfo
->
numOfRows
;
pRequest
->
code
!=
TSDB_CODE_SUCCESS
||
taos_num_fields
(
res
)
==
0
)
{
(
*
pData
)
=
(
void
*
)
pResultInfo
->
pData
;
return
0
;
return
0
;
}
else
{
ASSERT
(
0
);
return
-
1
;
}
}
doFetchRows
(
pRequest
,
false
,
false
);
SReqResultInfo
*
pResultInfo
=
&
pRequest
->
body
.
resInfo
;
pResultInfo
->
current
=
pResultInfo
->
numOfRows
;
(
*
numOfRows
)
=
pResultInfo
->
numOfRows
;
(
*
pData
)
=
(
void
*
)
pResultInfo
->
pData
;
return
0
;
}
}
int
*
taos_get_column_data_offset
(
TAOS_RES
*
res
,
int
columnIndex
)
{
int
*
taos_get_column_data_offset
(
TAOS_RES
*
res
,
int
columnIndex
)
{
...
...
source/client/test/clientTests.cpp
浏览文件 @
83a824a1
...
@@ -459,11 +459,10 @@ TEST(testCase, create_multiple_tables) {
...
@@ -459,11 +459,10 @@ TEST(testCase, create_multiple_tables) {
taos_free_result(pRes);
taos_free_result(pRes);
for (int32_t i = 0; i <
25000; ++i
) {
for (int32_t i = 0; i <
500; i += 2
) {
char sql[512] = {0};
char sql[512] = {0};
snprintf(sql, tListLen(sql),
snprintf(sql, tListLen(sql),
"create table t_x_%d using st1 tags(2) t_x_%d using st1 tags(5) t_x_%d using st1 tags(911)", i,
"create table t_x_%d using st1 tags(2) t_x_%d using st1 tags(5)", i, i + 1);
(i + 1) * 30, (i + 2) * 40);
TAOS_RES* pres = taos_query(pConn, sql);
TAOS_RES* pres = taos_query(pConn, sql);
if (taos_errno(pres) != 0) {
if (taos_errno(pres) != 0) {
printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres));
printf("failed to create table %d\n, reason:%s", i, taos_errstr(pres));
...
@@ -653,6 +652,7 @@ TEST(testCase, projection_query_stables) {
...
@@ -653,6 +652,7 @@ TEST(testCase, projection_query_stables) {
taos_free_result(pRes);
taos_free_result(pRes);
taos_close(pConn);
taos_close(pConn);
}
}
#endif
#endif
TEST
(
testCase
,
agg_query_tables
)
{
TEST
(
testCase
,
agg_query_tables
)
{
...
@@ -662,7 +662,7 @@ TEST(testCase, agg_query_tables) {
...
@@ -662,7 +662,7 @@ TEST(testCase, agg_query_tables) {
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"select
length('abc') from tu
"
);
pRes
=
taos_query
(
pConn
,
"select
* from test_block_raw.all_type
"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to select from table, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"failed to select from table, reason:%s
\n
"
,
taos_errstr
(
pRes
));
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
...
@@ -673,6 +673,10 @@ TEST(testCase, agg_query_tables) {
...
@@ -673,6 +673,10 @@ TEST(testCase, agg_query_tables) {
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
int32_t
n
=
0
;
void
*
data
=
NULL
;
int32_t
code
=
taos_fetch_raw_block
(
pRes
,
&
n
,
&
data
);
char
str
[
512
]
=
{
0
};
char
str
[
512
]
=
{
0
};
while
((
pRow
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
while
((
pRow
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
int32_t
*
length
=
taos_fetch_lengths
(
pRes
);
int32_t
*
length
=
taos_fetch_lengths
(
pRes
);
...
...
source/common/src/tdatablock.c
浏览文件 @
83a824a1
...
@@ -1149,10 +1149,11 @@ void* blockDataDestroy(SSDataBlock* pBlock) {
...
@@ -1149,10 +1149,11 @@ void* blockDataDestroy(SSDataBlock* pBlock) {
return
NULL
;
return
NULL
;
}
}
SSDataBlock
*
createOneDataBlock
(
const
SSDataBlock
*
pDataBlock
)
{
SSDataBlock
*
createOneDataBlock
(
const
SSDataBlock
*
pDataBlock
,
bool
copyData
)
{
if
(
pDataBlock
==
NULL
){
if
(
pDataBlock
==
NULL
){
return
NULL
;
return
NULL
;
}
}
int32_t
numOfCols
=
pDataBlock
->
info
.
numOfCols
;
int32_t
numOfCols
=
pDataBlock
->
info
.
numOfCols
;
SSDataBlock
*
pBlock
=
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
SSDataBlock
*
pBlock
=
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
...
@@ -1160,6 +1161,7 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) {
...
@@ -1160,6 +1161,7 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) {
pBlock
->
info
.
numOfCols
=
numOfCols
;
pBlock
->
info
.
numOfCols
=
numOfCols
;
pBlock
->
info
.
hasVarCol
=
pDataBlock
->
info
.
hasVarCol
;
pBlock
->
info
.
hasVarCol
=
pDataBlock
->
info
.
hasVarCol
;
pBlock
->
info
.
rowSize
=
pDataBlock
->
info
.
rows
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
colInfo
=
{
0
};
SColumnInfoData
colInfo
=
{
0
};
...
@@ -1168,6 +1170,23 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) {
...
@@ -1168,6 +1170,23 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) {
taosArrayPush
(
pBlock
->
pDataBlock
,
&
colInfo
);
taosArrayPush
(
pBlock
->
pDataBlock
,
&
colInfo
);
}
}
if
(
copyData
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
pDst
=
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
SColumnInfoData
*
pSrc
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
i
);
int32_t
code
=
colInfoDataEnsureCapacity
(
pDst
,
pDataBlock
->
info
.
rows
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
NULL
;
}
colDataAssign
(
pDst
,
pSrc
,
pDataBlock
->
info
.
rows
);
}
pBlock
->
info
.
rows
=
pDataBlock
->
info
.
rows
;
pBlock
->
info
.
capacity
=
pDataBlock
->
info
.
rows
;
}
return
pBlock
;
return
pBlock
;
}
}
...
...
source/dnode/mgmt/mgmt_vnode/src/vmInt.c
浏览文件 @
83a824a1
...
@@ -299,7 +299,7 @@ static int32_t vmInit(SMgmtWrapper *pWrapper) {
...
@@ -299,7 +299,7 @@ static int32_t vmInit(SMgmtWrapper *pWrapper) {
goto
_OVER
;
goto
_OVER
;
}
}
if
(
vnodeInit
()
!=
0
)
{
if
(
vnodeInit
(
tsNumOfCommitThreads
)
!=
0
)
{
dError
(
"failed to init vnode since %s"
,
terrstr
());
dError
(
"failed to init vnode since %s"
,
terrstr
());
goto
_OVER
;
goto
_OVER
;
}
}
...
...
source/dnode/mgmt/mgmt_vnode/src/vmWorker.c
浏览文件 @
83a824a1
...
@@ -115,7 +115,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
...
@@ -115,7 +115,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
}
}
}
}
vnodePr
ocessWMsg
s
(
pVnode
->
pImpl
,
pArray
);
vnodePr
eprocessWriteReq
s
(
pVnode
->
pImpl
,
pArray
);
numOfMsgs
=
taosArrayGetSize
(
pArray
);
numOfMsgs
=
taosArrayGetSize
(
pArray
);
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
i
++
)
{
...
@@ -123,7 +123,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
...
@@ -123,7 +123,7 @@ static void vmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
SRpcMsg
*
pRpc
=
&
pMsg
->
rpcMsg
;
SRpcMsg
*
pRpc
=
&
pMsg
->
rpcMsg
;
SRpcMsg
*
pRsp
=
NULL
;
SRpcMsg
*
pRsp
=
NULL
;
int32_t
code
=
vnode
ApplyWMsg
(
pVnode
->
pImpl
,
pRpc
,
&
pRsp
);
int32_t
code
=
vnode
ProcessWriteReq
(
pVnode
->
pImpl
,
pRpc
,
&
pRsp
);
if
(
pRsp
!=
NULL
)
{
if
(
pRsp
!=
NULL
)
{
pRsp
->
ahandle
=
pRpc
->
ahandle
;
pRsp
->
ahandle
=
pRpc
->
ahandle
;
tmsgSendRsp
(
pRsp
);
tmsgSendRsp
(
pRsp
);
...
@@ -153,7 +153,7 @@ static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
...
@@ -153,7 +153,7 @@ static void vmProcessApplyQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numO
// todo
// todo
SRpcMsg
*
pRsp
=
NULL
;
SRpcMsg
*
pRsp
=
NULL
;
(
void
)
vnode
ApplyWMsg
(
pVnode
->
pImpl
,
&
pMsg
->
rpcMsg
,
&
pRsp
);
(
void
)
vnode
ProcessWriteReq
(
pVnode
->
pImpl
,
&
pMsg
->
rpcMsg
,
&
pRsp
);
}
}
}
}
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
83a824a1
...
@@ -379,20 +379,20 @@ typedef struct {
...
@@ -379,20 +379,20 @@ typedef struct {
}
SFuncObj
;
}
SFuncObj
;
typedef
struct
{
typedef
struct
{
int64_t
id
;
int64_t
id
;
int8_t
type
;
int8_t
type
;
int8_t
replica
;
int8_t
replica
;
int16_t
numOfColumns
;
int16_t
numOfColumns
;
int32_t
rowSize
;
int32_t
rowSize
;
int32_t
numOfRows
;
int32_t
numOfRows
;
int32_t
payloadLen
;
int32_t
payloadLen
;
void
*
pIter
;
void
*
pIter
;
SMnode
*
pMnode
;
SMnode
*
pMnode
;
STableMetaRsp
*
pMeta
;
STableMetaRsp
*
pMeta
;
bool
sysDbRsp
;
bool
sysDbRsp
;
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
int16_t
offset
[
TSDB_MAX_COLUMNS
];
int16_t
offset
[
TSDB_MAX_COLUMNS
];
int32_t
bytes
[
TSDB_MAX_COLUMNS
];
int32_t
bytes
[
TSDB_MAX_COLUMNS
];
}
SShowObj
;
}
SShowObj
;
typedef
struct
{
typedef
struct
{
...
@@ -625,14 +625,14 @@ static FORCE_INLINE void* tDecodeSubscribeObj(void* buf, SMqSubscribeObj* pSub)
...
@@ -625,14 +625,14 @@ static FORCE_INLINE void* tDecodeSubscribeObj(void* buf, SMqSubscribeObj* pSub)
static
FORCE_INLINE
void
tDeleteSMqSubscribeObj
(
SMqSubscribeObj
*
pSub
)
{
static
FORCE_INLINE
void
tDeleteSMqSubscribeObj
(
SMqSubscribeObj
*
pSub
)
{
if
(
pSub
->
consumers
)
{
if
(
pSub
->
consumers
)
{
//taosArrayDestroyEx(pSub->consumers, (void (*)(void*))tDeleteSMqSubConsumer);
//
taosArrayDestroyEx(pSub->consumers, (void (*)(void*))tDeleteSMqSubConsumer);
// taosArrayDestroy(pSub->consumers);
//
taosArrayDestroy(pSub->consumers);
pSub
->
consumers
=
NULL
;
pSub
->
consumers
=
NULL
;
}
}
if
(
pSub
->
unassignedVg
)
{
if
(
pSub
->
unassignedVg
)
{
//taosArrayDestroyEx(pSub->unassignedVg, (void (*)(void*))tDeleteSMqConsumerEp);
//
taosArrayDestroyEx(pSub->unassignedVg, (void (*)(void*))tDeleteSMqConsumerEp);
// taosArrayDestroy(pSub->unassignedVg);
//
taosArrayDestroy(pSub->unassignedVg);
pSub
->
unassignedVg
=
NULL
;
pSub
->
unassignedVg
=
NULL
;
}
}
}
}
...
@@ -647,8 +647,9 @@ typedef struct {
...
@@ -647,8 +647,9 @@ typedef struct {
int32_t
version
;
int32_t
version
;
SRWLatch
lock
;
SRWLatch
lock
;
int32_t
sqlLen
;
int32_t
sqlLen
;
int32_t
astLen
;
char
*
sql
;
char
*
sql
;
char
*
logicalPlan
;
char
*
ast
;
char
*
physicalPlan
;
char
*
physicalPlan
;
SSchemaWrapper
schema
;
SSchemaWrapper
schema
;
}
SMqTopicObj
;
}
SMqTopicObj
;
...
...
source/dnode/mnode/impl/src/mndGrant.c
浏览文件 @
83a824a1
...
@@ -18,10 +18,15 @@
...
@@ -18,10 +18,15 @@
#include "taoserror.h"
#include "taoserror.h"
#include "mndGrant.h"
#include "mndGrant.h"
#include "mndInt.h"
#include "mndInt.h"
#include "mndShow.h"
#ifndef _GRANT
#ifndef _GRANT
static
int32_t
mndRetrieveGrant
(
SNodeMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
return
TSDB_CODE_OPS_NOT_SUPPORT
;
}
int32_t
mndInitGrant
(
SMnode
*
pMnode
)
{
return
TSDB_CODE_SUCCESS
;
}
int32_t
mndInitGrant
(
SMnode
*
pMnode
)
{
mndAddShowRetrieveHandle
(
pMnode
,
TSDB_MGMT_TABLE_GRANTS
,
mndRetrieveGrant
);
return
TSDB_CODE_SUCCESS
;
}
void
mndCleanupGrant
()
{}
void
mndCleanupGrant
()
{}
void
grantParseParameter
()
{
mError
(
"can't parsed parameter k"
);
}
void
grantParseParameter
()
{
mError
(
"can't parsed parameter k"
);
}
int32_t
grantCheck
(
EGrantType
grant
)
{
return
TSDB_CODE_SUCCESS
;
}
int32_t
grantCheck
(
EGrantType
grant
)
{
return
TSDB_CODE_SUCCESS
;
}
...
...
source/dnode/mnode/impl/src/mndOffset.c
浏览文件 @
83a824a1
...
@@ -201,6 +201,7 @@ static int32_t mndOffsetActionDelete(SSdb *pSdb, SMqOffsetObj *pOffset) {
...
@@ -201,6 +201,7 @@ static int32_t mndOffsetActionDelete(SSdb *pSdb, SMqOffsetObj *pOffset) {
static
int32_t
mndOffsetActionUpdate
(
SSdb
*
pSdb
,
SMqOffsetObj
*
pOldOffset
,
SMqOffsetObj
*
pNewOffset
)
{
static
int32_t
mndOffsetActionUpdate
(
SSdb
*
pSdb
,
SMqOffsetObj
*
pOldOffset
,
SMqOffsetObj
*
pNewOffset
)
{
mTrace
(
"offset:%s, perform update action"
,
pOldOffset
->
key
);
mTrace
(
"offset:%s, perform update action"
,
pOldOffset
->
key
);
pOldOffset
->
offset
=
pNewOffset
->
offset
;
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/src/mndSubscribe.c
浏览文件 @
83a824a1
...
@@ -469,6 +469,7 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) {
...
@@ -469,6 +469,7 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) {
ASSERT
(
pConsumerEp
!=
NULL
);
ASSERT
(
pConsumerEp
!=
NULL
);
ASSERT
(
pConsumerEp
->
consumerId
==
pSubConsumer
->
consumerId
);
ASSERT
(
pConsumerEp
->
consumerId
==
pSubConsumer
->
consumerId
);
taosArrayPush
(
pSub
->
unassignedVg
,
pConsumerEp
);
taosArrayPush
(
pSub
->
unassignedVg
,
pConsumerEp
);
mDebug
(
"mq rebalance: vg %d push to unassignedVg"
,
pConsumerEp
->
vgId
);
}
}
SMqConsumerObj
*
pRebConsumer
=
mndAcquireConsumer
(
pMnode
,
pSubConsumer
->
consumerId
);
SMqConsumerObj
*
pRebConsumer
=
mndAcquireConsumer
(
pMnode
,
pSubConsumer
->
consumerId
);
...
@@ -512,6 +513,7 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) {
...
@@ -512,6 +513,7 @@ static int32_t mndProcessDoRebalanceMsg(SNodeMsg *pMsg) {
while
(
taosArrayGetSize
(
pSubConsumer
->
vgInfo
)
<
vgThisConsumerAfterRb
)
{
while
(
taosArrayGetSize
(
pSubConsumer
->
vgInfo
)
<
vgThisConsumerAfterRb
)
{
SMqConsumerEp
*
pConsumerEp
=
taosArrayPop
(
pSub
->
unassignedVg
);
SMqConsumerEp
*
pConsumerEp
=
taosArrayPop
(
pSub
->
unassignedVg
);
mDebug
(
"mq rebalance: vg %d pop from unassignedVg"
,
pConsumerEp
->
vgId
);
ASSERT
(
pConsumerEp
!=
NULL
);
ASSERT
(
pConsumerEp
!=
NULL
);
pConsumerEp
->
oldConsumerId
=
pConsumerEp
->
consumerId
;
pConsumerEp
->
oldConsumerId
=
pConsumerEp
->
consumerId
;
...
@@ -570,7 +572,6 @@ static int32_t mndPersistMqSetConnReq(SMnode *pMnode, STrans *pTrans, const SMqT
...
@@ -570,7 +572,6 @@ static int32_t mndPersistMqSetConnReq(SMnode *pMnode, STrans *pTrans, const SMqT
.
vgId
=
vgId
,
.
vgId
=
vgId
,
.
consumerId
=
pConsumerEp
->
consumerId
,
.
consumerId
=
pConsumerEp
->
consumerId
,
.
sql
=
pTopic
->
sql
,
.
sql
=
pTopic
->
sql
,
.
logicalPlan
=
pTopic
->
logicalPlan
,
.
physicalPlan
=
pTopic
->
physicalPlan
,
.
physicalPlan
=
pTopic
->
physicalPlan
,
.
qmsg
=
pConsumerEp
->
qmsg
,
.
qmsg
=
pConsumerEp
->
qmsg
,
};
};
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
83a824a1
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
#include "parser.h"
#include "parser.h"
#include "tname.h"
#include "tname.h"
#define MND_TOPIC_VER_NUMBER 1
#define MND_TOPIC_VER_NUMBER
1
#define MND_TOPIC_RESERVE_SIZE 64
#define MND_TOPIC_RESERVE_SIZE 64
static
int32_t
mndTopicActionInsert
(
SSdb
*
pSdb
,
SMqTopicObj
*
pTopic
);
static
int32_t
mndTopicActionInsert
(
SSdb
*
pSdb
,
SMqTopicObj
*
pTopic
);
...
@@ -51,7 +51,7 @@ int32_t mndInitTopic(SMnode *pMnode) {
...
@@ -51,7 +51,7 @@ int32_t mndInitTopic(SMnode *pMnode) {
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_TOPIC
,
mndProcessDropTopicReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_MND_DROP_TOPIC
,
mndProcessDropTopicReq
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_DROP_TOPIC_RSP
,
mndProcessDropTopicInRsp
);
mndSetMsgHandle
(
pMnode
,
TDMT_VND_DROP_TOPIC_RSP
,
mndProcessDropTopicInRsp
);
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveTopic);
// mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TOPICS, mndRetrieveTopic);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_TOPICS
,
mndCancelGetNextTopic
);
mndAddShowFreeIterHandle
(
pMnode
,
TSDB_MGMT_TABLE_TOPICS
,
mndCancelGetNextTopic
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
return
sdbSetTable
(
pMnode
->
pSdb
,
table
);
...
@@ -62,11 +62,10 @@ void mndCleanupTopic(SMnode *pMnode) {}
...
@@ -62,11 +62,10 @@ void mndCleanupTopic(SMnode *pMnode) {}
SSdbRaw
*
mndTopicActionEncode
(
SMqTopicObj
*
pTopic
)
{
SSdbRaw
*
mndTopicActionEncode
(
SMqTopicObj
*
pTopic
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
int32_t
logicalPlanLen
=
strlen
(
pTopic
->
logicalPlan
)
+
1
;
int32_t
physicalPlanLen
=
strlen
(
pTopic
->
physicalPlan
)
+
1
;
int32_t
physicalPlanLen
=
strlen
(
pTopic
->
physicalPlan
)
+
1
;
int32_t
s
w
Len
=
taosEncodeSSchemaWrapper
(
NULL
,
&
pTopic
->
schema
);
int32_t
s
chema
Len
=
taosEncodeSSchemaWrapper
(
NULL
,
&
pTopic
->
schema
);
int32_t
size
=
int32_t
size
=
sizeof
(
SMqTopicObj
)
+
logicalPlanLen
+
physicalPlanLen
+
pTopic
->
sqlLen
+
sw
Len
+
MND_TOPIC_RESERVE_SIZE
;
sizeof
(
SMqTopicObj
)
+
physicalPlanLen
+
pTopic
->
sqlLen
+
pTopic
->
astLen
+
schema
Len
+
MND_TOPIC_RESERVE_SIZE
;
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_TOPIC
,
MND_TOPIC_VER_NUMBER
,
size
);
SSdbRaw
*
pRaw
=
sdbAllocRaw
(
SDB_TOPIC
,
MND_TOPIC_VER_NUMBER
,
size
);
if
(
pRaw
==
NULL
)
goto
TOPIC_ENCODE_OVER
;
if
(
pRaw
==
NULL
)
goto
TOPIC_ENCODE_OVER
;
...
@@ -80,19 +79,19 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
...
@@ -80,19 +79,19 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
version
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
version
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
logicalPlan
Len
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
pTopic
->
ast
Len
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
logicalPlan
,
logicalPlan
Len
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
ast
,
pTopic
->
ast
Len
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
physicalPlanLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
physicalPlanLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
physicalPlan
,
physicalPlanLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
physicalPlan
,
physicalPlanLen
,
TOPIC_ENCODE_OVER
);
void
*
swBuf
=
taosMemoryMalloc
(
s
w
Len
);
void
*
swBuf
=
taosMemoryMalloc
(
s
chema
Len
);
if
(
swBuf
==
NULL
)
{
if
(
swBuf
==
NULL
)
{
goto
TOPIC_ENCODE_OVER
;
goto
TOPIC_ENCODE_OVER
;
}
}
void
*
aswBuf
=
swBuf
;
void
*
aswBuf
=
swBuf
;
taosEncodeSSchemaWrapper
(
&
aswBuf
,
&
pTopic
->
schema
);
taosEncodeSSchemaWrapper
(
&
aswBuf
,
&
pTopic
->
schema
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
s
w
Len
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
s
chema
Len
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
swBuf
,
s
w
Len
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
swBuf
,
s
chema
Len
,
TOPIC_ENCODE_OVER
);
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_ENCODE_OVER
);
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_ENCODE_OVER
);
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
TOPIC_ENCODE_OVER
);
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
TOPIC_ENCODE_OVER
);
...
@@ -136,23 +135,25 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
...
@@ -136,23 +135,25 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
uid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
uid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
dbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT64
(
pRaw
,
dataPos
,
&
pTopic
->
dbUid
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
version
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
version
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
pTopic
->
sql
=
taosMemoryCalloc
(
pTopic
->
sqlLen
+
1
,
sizeof
(
char
));
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
pTopic
->
sql
=
taosMemoryCalloc
(
pTopic
->
sqlLen
,
sizeof
(
char
));
if
(
pTopic
->
sql
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
TOPIC_DECODE_OVER
;
}
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
l
en
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
astL
en
,
TOPIC_DECODE_OVER
);
pTopic
->
logicalPlan
=
taosMemoryCalloc
(
len
+
1
,
sizeof
(
char
));
pTopic
->
ast
=
taosMemoryCalloc
(
pTopic
->
astLen
,
sizeof
(
char
));
if
(
pTopic
->
logicalPlan
==
NULL
)
{
if
(
pTopic
->
ast
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
TOPIC_DECODE_OVER
;
goto
TOPIC_DECODE_OVER
;
}
}
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
logicalPlan
,
len
,
TOPIC_DECODE_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
ast
,
pTopic
->
astLen
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
len
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
len
,
TOPIC_DECODE_OVER
);
pTopic
->
physicalPlan
=
taosMemoryCalloc
(
len
+
1
,
sizeof
(
char
));
pTopic
->
physicalPlan
=
taosMemoryCalloc
(
len
,
sizeof
(
char
));
if
(
pTopic
->
physicalPlan
==
NULL
)
{
if
(
pTopic
->
physicalPlan
==
NULL
)
{
taosMemoryFree
(
pTopic
->
logicalPlan
);
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
TOPIC_DECODE_OVER
;
goto
TOPIC_DECODE_OVER
;
}
}
...
@@ -256,6 +257,7 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) {
...
@@ -256,6 +257,7 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) {
return
0
;
return
0
;
}
}
#if 0
static int32_t mndGetPlanString(const SCMCreateTopicReq *pCreate, char **pStr) {
static int32_t mndGetPlanString(const SCMCreateTopicReq *pCreate, char **pStr) {
if (NULL == pCreate->ast) {
if (NULL == pCreate->ast) {
return TSDB_CODE_SUCCESS;
return TSDB_CODE_SUCCESS;
...
@@ -278,6 +280,7 @@ static int32_t mndGetPlanString(const SCMCreateTopicReq *pCreate, char **pStr) {
...
@@ -278,6 +280,7 @@ static int32_t mndGetPlanString(const SCMCreateTopicReq *pCreate, char **pStr) {
terrno = code;
terrno = code;
return code;
return code;
}
}
#endif
static
int32_t
mndCreateTopic
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SCMCreateTopicReq
*
pCreate
,
SDbObj
*
pDb
)
{
static
int32_t
mndCreateTopic
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SCMCreateTopicReq
*
pCreate
,
SDbObj
*
pDb
)
{
mDebug
(
"topic:%s to create"
,
pCreate
->
name
);
mDebug
(
"topic:%s to create"
,
pCreate
->
name
);
...
@@ -289,32 +292,39 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
...
@@ -289,32 +292,39 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
topicObj
.
uid
=
mndGenerateUid
(
pCreate
->
name
,
strlen
(
pCreate
->
name
));
topicObj
.
uid
=
mndGenerateUid
(
pCreate
->
name
,
strlen
(
pCreate
->
name
));
topicObj
.
dbUid
=
pDb
->
uid
;
topicObj
.
dbUid
=
pDb
->
uid
;
topicObj
.
version
=
1
;
topicObj
.
version
=
1
;
topicObj
.
sql
=
pCreate
->
sql
;
topicObj
.
sql
=
strdup
(
pCreate
->
sql
)
;
topicObj
.
physicalPlan
=
""
;
topicObj
.
sqlLen
=
strlen
(
pCreate
->
sql
)
+
1
;
topicObj
.
logicalPlan
=
""
;
topicObj
.
ast
=
strdup
(
pCreate
->
ast
)
;
topicObj
.
sqlLen
=
strlen
(
pCreate
->
sql
)
;
topicObj
.
astLen
=
strlen
(
pCreate
->
ast
)
+
1
;
char
*
pPlanStr
=
NULL
;
SNode
*
pAst
=
NULL
;
if
(
TSDB_CODE_SUCCESS
!=
mndGetPlanString
(
pCreate
,
&
pPlanStr
)
)
{
if
(
nodesStringToNode
(
pCreate
->
ast
,
&
pAst
)
!=
0
)
{
mError
(
"topic:%s, failed to
get plan
since %s"
,
pCreate
->
name
,
terrstr
());
mError
(
"topic:%s, failed to
create
since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
if
(
NULL
!=
pPlanStr
)
{
topicObj
.
physicalPlan
=
pPlanStr
;
}
SNode
*
pAst
=
NULL
;
SQueryPlan
*
pPlan
=
NULL
;
if
(
nodesStringToNode
(
pCreate
->
ast
,
&
pAst
)
<
0
)
{
SPlanContext
cxt
=
{.
pAstRoot
=
pAst
,
.
topicQuery
=
true
};
if
(
qCreateQueryPlan
(
&
cxt
,
&
pPlan
,
NULL
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
if
(
qExtractResultSchema
(
pAst
,
&
topicObj
.
schema
.
nCols
,
&
topicObj
.
schema
.
pSchema
)
!=
0
)
{
if
(
qExtractResultSchema
(
pAst
,
&
topicObj
.
schema
.
nCols
,
&
topicObj
.
schema
.
pSchema
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
}
if
(
nodesNodeToString
(
pPlan
,
false
,
&
topicObj
.
physicalPlan
,
NULL
)
!=
0
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
return
-
1
;
return
-
1
;
}
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_TOPIC
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_TOPIC
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
if
(
pTrans
==
NULL
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
taosMemoryFreeClear
(
pPlanStr
);
taosMemoryFreeClear
(
topicObj
.
physicalPlan
);
return
-
1
;
return
-
1
;
}
}
mDebug
(
"trans:%d, used to create topic:%s"
,
pTrans
->
id
,
pCreate
->
name
);
mDebug
(
"trans:%d, used to create topic:%s"
,
pTrans
->
id
,
pCreate
->
name
);
...
@@ -322,7 +332,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
...
@@ -322,7 +332,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
SSdbRaw
*
pRedoRaw
=
mndTopicActionEncode
(
&
topicObj
);
SSdbRaw
*
pRedoRaw
=
mndTopicActionEncode
(
&
topicObj
);
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
if
(
pRedoRaw
==
NULL
||
mndTransAppendRedolog
(
pTrans
,
pRedoRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append redo log since %s"
,
pTrans
->
id
,
terrstr
());
mError
(
"trans:%d, failed to append redo log since %s"
,
pTrans
->
id
,
terrstr
());
taosMemoryFreeClear
(
pPlanStr
);
taosMemoryFreeClear
(
topicObj
.
physicalPlan
);
mndTransDrop
(
pTrans
);
mndTransDrop
(
pTrans
);
return
-
1
;
return
-
1
;
}
}
...
@@ -330,12 +340,12 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
...
@@ -330,12 +340,12 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
taosMemoryFreeClear
(
pPlanStr
);
taosMemoryFreeClear
(
topicObj
.
physicalPlan
);
mndTransDrop
(
pTrans
);
mndTransDrop
(
pTrans
);
return
-
1
;
return
-
1
;
}
}
taosMemoryFreeClear
(
pPlanStr
);
taosMemoryFreeClear
(
topicObj
.
physicalPlan
);
mndTransDrop
(
pTrans
);
mndTransDrop
(
pTrans
);
return
0
;
return
0
;
}
}
...
...
source/dnode/mnode/impl/test/topic/topic.cpp
浏览文件 @
83a824a1
...
@@ -88,6 +88,8 @@ void* MndTestTopic::BuildDropTopicReq(const char* topicName, int32_t* pContLen)
...
@@ -88,6 +88,8 @@ void* MndTestTopic::BuildDropTopicReq(const char* topicName, int32_t* pContLen)
}
}
TEST_F
(
MndTestTopic
,
01
_Create_Topic
)
{
TEST_F
(
MndTestTopic
,
01
_Create_Topic
)
{
// TODO add valid ast for unit test
#if 0
const char* dbname = "1.d1";
const char* dbname = "1.d1";
const char* topicName = "1.d1.t1";
const char* topicName = "1.d1.t1";
...
@@ -171,4 +173,5 @@ TEST_F(MndTestTopic, 01_Create_Topic) {
...
@@ -171,4 +173,5 @@ TEST_F(MndTestTopic, 01_Create_Topic) {
test.SendShowRetrieveReq();
test.SendShowRetrieveReq();
EXPECT_EQ(test.GetShowRows(), 0);
EXPECT_EQ(test.GetShowRows(), 0);
}
}
#endif
}
}
source/dnode/vnode/CMakeLists.txt
浏览文件 @
83a824a1
...
@@ -6,30 +6,26 @@ target_sources(
...
@@ -6,30 +6,26 @@ target_sources(
# vnode
# vnode
"src/vnd/vnodeArenaMAImpl.c"
"src/vnd/vnodeArenaMAImpl.c"
"src/vnd/vnodeBufferPool.c"
"src/vnd/vnodeBufferPool.c"
# "src/vnd/vnodeBufferPool2.c"
"src/vnd/vnodeCfg.c"
"src/vnd/vnodeCfg.c"
"src/vnd/vnodeCommit.c"
"src/vnd/vnodeCommit.c"
"src/vnd/vnodeInt.c"
"src/vnd/vnodeInt.c"
"src/vnd/vnodeMain.c"
"src/vnd/vnodeMain.c"
"src/vnd/vnodeMgr.c"
"src/vnd/vnodeQuery.c"
"src/vnd/vnodeQuery.c"
"src/vnd/vnodeStateMgr.c"
"src/vnd/vnodeStateMgr.c"
"src/vnd/vnodeWrite.c"
"src/vnd/vnodeWrite.c"
"src/vnd/vnodeModule.c"
"src/vnd/vnodeSvr.c"
# meta
# meta
# "src/meta/metaBDBImpl.c"
# "src/meta/metaBDBImpl.c"
"src/meta/metaCache.c"
"src/meta/metaCfg.c"
"src/meta/metaIdx.c"
"src/meta/metaIdx.c"
"src/meta/metaMain.c"
"src/meta/metaMain.c"
"src/meta/metaQuery.c"
"src/meta/metaTable.c"
"src/meta/metaTable.c"
"src/meta/metaTbCfg.c"
"src/meta/metaTbTag.c"
"src/meta/metaTbUid.c"
"src/meta/metaTbUid.c"
"src/meta/metaTDBImpl.c"
"src/meta/metaTDBImpl.c"
# tsdb
# tsdb
# "src/tsdb/tsdbBDBImpl.c"
"src/tsdb/tsdbTDBImpl.c"
"src/tsdb/tsdbTDBImpl.c"
"src/tsdb/tsdbCommit.c"
"src/tsdb/tsdbCommit.c"
"src/tsdb/tsdbCompact.c"
"src/tsdb/tsdbCompact.c"
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
83a824a1
...
@@ -47,8 +47,8 @@ void vnodeCleanup();
...
@@ -47,8 +47,8 @@ void vnodeCleanup();
SVnode
*
vnodeOpen
(
const
char
*
path
,
const
SVnodeCfg
*
pVnodeCfg
);
SVnode
*
vnodeOpen
(
const
char
*
path
,
const
SVnodeCfg
*
pVnodeCfg
);
void
vnodeClose
(
SVnode
*
pVnode
);
void
vnodeClose
(
SVnode
*
pVnode
);
void
vnodeDestroy
(
const
char
*
path
);
void
vnodeDestroy
(
const
char
*
path
);
void
vnodePr
ocessWMsg
s
(
SVnode
*
pVnode
,
SArray
*
pMsgs
);
void
vnodePr
eprocessWriteReq
s
(
SVnode
*
pVnode
,
SArray
*
pMsgs
);
int
vnode
ApplyWMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int
vnode
ProcessWriteReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int
vnodeProcessCMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int
vnodeProcessCMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int
vnodeProcessQueryMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
int
vnodeProcessQueryMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
...
@@ -60,34 +60,15 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
...
@@ -60,34 +60,15 @@ int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad);
int
vnodeValidateTableHash
(
SVnodeCfg
*
pVnodeOptions
,
char
*
tableFName
);
int
vnodeValidateTableHash
(
SVnodeCfg
*
pVnodeOptions
,
char
*
tableFName
);
// meta
// meta
typedef
struct
SMeta
SMeta
;
// todo: remove
typedef
struct
SMeta
SMeta
;
// todo: remove
typedef
struct
SMTbCursor
SMTbCursor
;
// todo: remove
typedef
struct
SMTbCursor
SMTbCursor
;
typedef
struct
SMCtbCursor
SMCtbCursor
;
// todo: remove
typedef
struct
SMSmaCursor
SMSmaCursor
;
// todo: remove
#define META_SUPER_TABLE TD_SUPER_TABLE
#define META_CHILD_TABLE TD_CHILD_TABLE
#define META_NORMAL_TABLE TD_NORMAL_TABLE
typedef
SVCreateTbReq
STbCfg
;
typedef
SVCreateTbReq
STbCfg
;
typedef
SVCreateTSmaReq
SSmaCfg
;
typedef
SVCreateTSmaReq
SSmaCfg
;
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
SMTbCursor
*
metaOpenTbCursor
(
SMeta
*
pMeta
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
void
metaCloseTbCursor
(
SMTbCursor
*
pTbCur
);
void
*
metaGetSmaInfoByIndex
(
SMeta
*
pMeta
,
int64_t
indexUid
,
bool
isDecode
);
char
*
metaTbCursorNext
(
SMTbCursor
*
pTbCur
);
STSmaWrapper
*
metaGetSmaInfoByTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
SArray
*
metaGetSmaTbUids
(
SMeta
*
pMeta
,
bool
isDup
);
int
metaGetTbNum
(
SMeta
*
pMeta
);
SMTbCursor
*
metaOpenTbCursor
(
SMeta
*
pMeta
);
void
metaCloseTbCursor
(
SMTbCursor
*
pTbCur
);
char
*
metaTbCursorNext
(
SMTbCursor
*
pTbCur
);
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseCtbCurosr
(
SMCtbCursor
*
pCtbCur
);
tb_uid_t
metaCtbCursorNext
(
SMCtbCursor
*
pCtbCur
);
SMSmaCursor
*
metaOpenSmaCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseSmaCursor
(
SMSmaCursor
*
pSmaCur
);
int64_t
metaSmaCursorNext
(
SMSmaCursor
*
pSmaCur
);
// tsdb
// tsdb
typedef
struct
STsdb
STsdb
;
typedef
struct
STsdb
STsdb
;
...
@@ -98,18 +79,7 @@ typedef void *tsdbReaderT;
...
@@ -98,18 +79,7 @@ typedef void *tsdbReaderT;
#define BLOCK_LOAD_OFFSET_SEQ_ORDER 1
#define BLOCK_LOAD_OFFSET_SEQ_ORDER 1
#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
#define TABLE_TID(t) (t)->tid
#define TABLE_UID(t) (t)->uid
STsdb
*
tsdbOpen
(
const
char
*
path
,
int32_t
vgId
,
const
STsdbCfg
*
pTsdbCfg
,
SMemAllocatorFactory
*
pMAF
,
SMeta
*
pMeta
,
STfs
*
pTfs
);
void
tsdbClose
(
STsdb
*
);
void
tsdbRemove
(
const
char
*
path
);
int
tsdbInsertData
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
,
SSubmitRsp
*
pRsp
);
int
tsdbPrepareCommit
(
STsdb
*
pTsdb
);
int
tsdbCommit
(
STsdb
*
pTsdb
);
int32_t
tsdbInitSma
(
STsdb
*
pTsdb
);
int32_t
tsdbCreateTSma
(
STsdb
*
pTsdb
,
char
*
pMsg
);
int32_t
tsdbDropTSma
(
STsdb
*
pTsdb
,
char
*
pMsg
);
tsdbReaderT
*
tsdbQueryTables
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
tableInfoGroup
,
uint64_t
qId
,
tsdbReaderT
*
tsdbQueryTables
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
tableInfoGroup
,
uint64_t
qId
,
uint64_t
taskId
);
uint64_t
taskId
);
tsdbReaderT
tsdbQueryCacheLast
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
tsdbReaderT
tsdbQueryCacheLast
(
STsdb
*
tsdb
,
STsdbQueryCond
*
pCond
,
STableGroupInfo
*
groupList
,
uint64_t
qId
,
...
@@ -127,18 +97,8 @@ SArray *tsdbRetrieveDataBlock(tsdbReaderT *pTsdbReadHandle, SArray *pColumn
...
@@ -127,18 +97,8 @@ SArray *tsdbRetrieveDataBlock(tsdbReaderT *pTsdbReadHandle, SArray *pColumn
void
tsdbDestroyTableGroup
(
STableGroupInfo
*
pGroupList
);
void
tsdbDestroyTableGroup
(
STableGroupInfo
*
pGroupList
);
int32_t
tsdbGetOneTableGroup
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
startKey
,
STableGroupInfo
*
pGroupInfo
);
int32_t
tsdbGetOneTableGroup
(
void
*
pMeta
,
uint64_t
uid
,
TSKEY
startKey
,
STableGroupInfo
*
pGroupInfo
);
int32_t
tsdbGetTableGroupFromIdList
(
STsdb
*
tsdb
,
SArray
*
pTableIdList
,
STableGroupInfo
*
pGroupInfo
);
int32_t
tsdbGetTableGroupFromIdList
(
STsdb
*
tsdb
,
SArray
*
pTableIdList
,
STableGroupInfo
*
pGroupInfo
);
void
tsdbCleanupReadHandle
(
tsdbReaderT
queryHandle
);
int32_t
tsdbUpdateSmaWindow
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
,
int64_t
version
);
int32_t
tsdbInsertTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
,
const
char
*
msg
);
int32_t
tsdbDropTSmaData
(
STsdb
*
pTsdb
,
int64_t
indexUid
);
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
// tq
// tq
enum
{
TQ_STREAM_TOKEN__DATA
=
1
,
TQ_STREAM_TOKEN__WATERMARK
,
TQ_STREAM_TOKEN__CHECKPOINT
,
};
typedef
struct
STqReadHandle
STqReadHandle
;
typedef
struct
STqReadHandle
STqReadHandle
;
...
@@ -153,9 +113,6 @@ int tqRetrieveDataBlockInfo(STqReadHandle *pHandle, SDataBlockInfo *pBlockIn
...
@@ -153,9 +113,6 @@ int tqRetrieveDataBlockInfo(STqReadHandle *pHandle, SDataBlockInfo *pBlockIn
SArray
*
tqRetrieveDataBlock
(
STqReadHandle
*
pHandle
);
SArray
*
tqRetrieveDataBlock
(
STqReadHandle
*
pHandle
);
// need to reposition
// need to reposition
typedef
struct
SMgmtWrapper
SMgmtWrapper
;
int32_t
tdScanAndConvertSubmitMsg
(
SSubmitReq
*
pMsg
);
// structs
// structs
struct
SMetaCfg
{
struct
SMetaCfg
{
...
@@ -202,21 +159,6 @@ struct SVnodeCfg {
...
@@ -202,21 +159,6 @@ struct SVnodeCfg {
int8_t
hashMethod
;
int8_t
hashMethod
;
};
};
struct
STqReadHandle
{
int64_t
ver
;
int64_t
tbUid
;
SHashObj
*
tbIdHash
;
const
SSubmitReq
*
pMsg
;
SSubmitBlk
*
pBlock
;
SSubmitMsgIter
msgIter
;
SSubmitBlkIter
blkIter
;
SMeta
*
pVnodeMeta
;
SArray
*
pColIdList
;
// SArray<int32_t>
int32_t
sver
;
SSchemaWrapper
*
pSchemaWrapper
;
STSchema
*
pSchema
;
};
struct
SDataStatis
{
struct
SDataStatis
{
int16_t
colId
;
int16_t
colId
;
int16_t
maxIndex
;
int16_t
maxIndex
;
...
@@ -241,22 +183,6 @@ typedef struct {
...
@@ -241,22 +183,6 @@ typedef struct {
uint64_t
uid
;
uint64_t
uid
;
}
STableKeyInfo
;
}
STableKeyInfo
;
typedef
struct
STable
{
uint64_t
tid
;
uint64_t
uid
;
STSchema
*
pSchema
;
}
STable
;
typedef
struct
{
int8_t
type
;
int8_t
reserved
[
7
];
union
{
void
*
data
;
int64_t
wmTs
;
int64_t
checkpointId
;
};
}
STqStreamToken
;
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/vnode/src/inc/meta.h
浏览文件 @
83a824a1
...
@@ -20,20 +20,48 @@
...
@@ -20,20 +20,48 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
typedef
struct
SMetaCache
SMetaCache
;
typedef
struct
SMetaCache
SMetaCache
;
typedef
struct
SMetaIdx
SMetaIdx
;
typedef
struct
SMetaIdx
SMetaIdx
;
typedef
struct
SMetaDB
SMetaDB
;
typedef
struct
SMetaDB
SMetaDB
;
typedef
struct
SMCtbCursor
SMCtbCursor
;
typedef
struct
SMSmaCursor
SMSmaCursor
;
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMetaCfg
*
pMetaCfg
,
SMemAllocatorFactory
*
pMAF
);
// metaDebug ==================
void
metaClose
(
SMeta
*
pMeta
);
// clang-format off
void
metaRemove
(
const
char
*
path
);
#define metaFatal(...) do { if (metaDebugFlag & DEBUG_FATAL) { taosPrintLog("META FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
);
#define metaError(...) do { if (metaDebugFlag & DEBUG_ERROR) { taosPrintLog("META ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
int
metaDropTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
#define metaWarn(...) do { if (metaDebugFlag & DEBUG_WARN) { taosPrintLog("META WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
int
metaCommit
(
SMeta
*
pMeta
);
#define metaInfo(...) do { if (metaDebugFlag & DEBUG_INFO) { taosPrintLog("META ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
int32_t
metaCreateTSma
(
SMeta
*
pMeta
,
SSmaCfg
*
pCfg
);
#define metaDebug(...) do { if (metaDebugFlag & DEBUG_DEBUG) { taosPrintLog("META ", DEBUG_DEBUG, metaDebugFlag, __VA_ARGS__); }} while(0)
int32_t
metaDropTSma
(
SMeta
*
pMeta
,
int64_t
indexUid
);
#define metaTrace(...) do { if (metaDebugFlag & DEBUG_TRACE) { taosPrintLog("META ", DEBUG_TRACE, metaDebugFlag, __VA_ARGS__); }} while(0)
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
// clang-format on
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
);
#define META_SUPER_TABLE TD_SUPER_TABLE
#define META_CHILD_TABLE TD_CHILD_TABLE
#define META_NORMAL_TABLE TD_NORMAL_TABLE
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMetaCfg
*
pMetaCfg
,
SMemAllocatorFactory
*
pMAF
);
void
metaClose
(
SMeta
*
pMeta
);
void
metaRemove
(
const
char
*
path
);
int
metaCreateTable
(
SMeta
*
pMeta
,
STbCfg
*
pTbCfg
);
int
metaDropTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
int
metaCommit
(
SMeta
*
pMeta
);
int32_t
metaCreateTSma
(
SMeta
*
pMeta
,
SSmaCfg
*
pCfg
);
int32_t
metaDropTSma
(
SMeta
*
pMeta
,
int64_t
indexUid
);
STbCfg
*
metaGetTbInfoByUid
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
STbCfg
*
metaGetTbInfoByName
(
SMeta
*
pMeta
,
char
*
tbname
,
tb_uid_t
*
uid
);
SSchemaWrapper
*
metaGetTableSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
,
bool
isinline
);
STSchema
*
metaGetTbTSchema
(
SMeta
*
pMeta
,
tb_uid_t
uid
,
int32_t
sver
);
void
*
metaGetSmaInfoByIndex
(
SMeta
*
pMeta
,
int64_t
indexUid
,
bool
isDecode
);
STSmaWrapper
*
metaGetSmaInfoByTable
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
SArray
*
metaGetSmaTbUids
(
SMeta
*
pMeta
,
bool
isDup
);
int
metaGetTbNum
(
SMeta
*
pMeta
);
SMSmaCursor
*
metaOpenSmaCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseSmaCursor
(
SMSmaCursor
*
pSmaCur
);
int64_t
metaSmaCursorNext
(
SMSmaCursor
*
pSmaCur
);
SMCtbCursor
*
metaOpenCtbCursor
(
SMeta
*
pMeta
,
tb_uid_t
uid
);
void
metaCloseCtbCurosr
(
SMCtbCursor
*
pCtbCur
);
tb_uid_t
metaCtbCursorNext
(
SMCtbCursor
*
pCtbCur
);
// SMetaDB
// SMetaDB
int
metaOpenDB
(
SMeta
*
pMeta
);
int
metaOpenDB
(
SMeta
*
pMeta
);
...
@@ -47,11 +75,6 @@ int metaRemoveSmaFromDb(SMeta* pMeta, int64_t indexUid);
...
@@ -47,11 +75,6 @@ int metaRemoveSmaFromDb(SMeta* pMeta, int64_t indexUid);
int
metaOpenCache
(
SMeta
*
pMeta
);
int
metaOpenCache
(
SMeta
*
pMeta
);
void
metaCloseCache
(
SMeta
*
pMeta
);
void
metaCloseCache
(
SMeta
*
pMeta
);
// SMetaCfg
extern
const
SMetaCfg
defaultMetaOptions
;
// int metaValidateOptions(const SMetaCfg*);
void
metaOptionsCopy
(
SMetaCfg
*
pDest
,
const
SMetaCfg
*
pSrc
);
// SMetaIdx
// SMetaIdx
int
metaOpenIdx
(
SMeta
*
pMeta
);
int
metaOpenIdx
(
SMeta
*
pMeta
);
void
metaCloseIdx
(
SMeta
*
pMeta
);
void
metaCloseIdx
(
SMeta
*
pMeta
);
...
@@ -73,6 +96,7 @@ tb_uid_t metaGenerateUid(SMeta* pMeta);
...
@@ -73,6 +96,7 @@ tb_uid_t metaGenerateUid(SMeta* pMeta);
struct
SMeta
{
struct
SMeta
{
char
*
path
;
char
*
path
;
SVnode
*
pVnode
;
SMetaCfg
options
;
SMetaCfg
options
;
SMetaDB
*
pDB
;
SMetaDB
*
pDB
;
SMetaIdx
*
pIdx
;
SMetaIdx
*
pIdx
;
...
...
source/dnode/vnode/src/inc/tq.h
浏览文件 @
83a824a1
...
@@ -20,48 +20,21 @@
...
@@ -20,48 +20,21 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
// tqInt.h
// tqDebug ===================
#define tqFatal(...) \
// clang-format off
{ \
#define tqFatal(...) do { if (tqDebugFlag & DEBUG_FATAL) { taosPrintLog("TQ FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
if (tqDebugFlag & DEBUG_FATAL) { \
#define tqError(...) do { if (tqDebugFlag & DEBUG_ERROR) { taosPrintLog("TQ ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
taosPrintLog("TQ FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); \
#define tqWarn(...) do { if (tqDebugFlag & DEBUG_WARN) { taosPrintLog("TQ WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
} \
#define tqInfo(...) do { if (tqDebugFlag & DEBUG_INFO) { taosPrintLog("TQ ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
}
#define tqDebug(...) do { if (tqDebugFlag & DEBUG_DEBUG) { taosPrintLog("TQ ", DEBUG_DEBUG, tqDebugFlag, __VA_ARGS__); }} while(0)
#define tqTrace(...) do { if (tqDebugFlag & DEBUG_TRACE) { taosPrintLog("TQ ", DEBUG_TRACE, tqDebugFlag, __VA_ARGS__); }} while(0)
#define tqError(...) \
// clang-format on
{ \
if (tqDebugFlag & DEBUG_ERROR) { \
enum
{
taosPrintLog("TQ ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); \
TQ_STREAM_TOKEN__DATA
=
1
,
} \
TQ_STREAM_TOKEN__WATERMARK
,
}
TQ_STREAM_TOKEN__CHECKPOINT
,
};
#define tqWarn(...) \
{ \
if (tqDebugFlag & DEBUG_WARN) { \
taosPrintLog("TQ WARN ", DEBUG_WARN, 255, __VA_ARGS__); \
} \
}
#define tqInfo(...) \
{ \
if (tqDebugFlag & DEBUG_INFO) { \
taosPrintLog("TQ ", DEBUG_INFO, 255, __VA_ARGS__); \
} \
}
#define tqDebug(...) \
{ \
if (tqDebugFlag & DEBUG_DEBUG) { \
taosPrintLog("TQ ", DEBUG_DEBUG, tqDebugFlag, __VA_ARGS__); \
} \
}
#define tqTrace(...) \
{ \
if (tqDebugFlag & DEBUG_TRACE) { \
taosPrintLog("TQ ", DEBUG_TRACE, tqDebugFlag, __VA_ARGS__); \
} \
}
#define TQ_BUFFER_SIZE 4
#define TQ_BUFFER_SIZE 4
...
@@ -105,6 +78,31 @@ typedef enum { TQ_ITEM_READY, TQ_ITEM_PROCESS, TQ_ITEM_EMPTY } STqItemStatus;
...
@@ -105,6 +78,31 @@ typedef enum { TQ_ITEM_READY, TQ_ITEM_PROCESS, TQ_ITEM_EMPTY } STqItemStatus;
typedef
struct
STqOffsetCfg
STqOffsetCfg
;
typedef
struct
STqOffsetCfg
STqOffsetCfg
;
typedef
struct
STqOffsetStore
STqOffsetStore
;
typedef
struct
STqOffsetStore
STqOffsetStore
;
struct
STqReadHandle
{
int64_t
ver
;
int64_t
tbUid
;
SHashObj
*
tbIdHash
;
const
SSubmitReq
*
pMsg
;
SSubmitBlk
*
pBlock
;
SSubmitMsgIter
msgIter
;
SSubmitBlkIter
blkIter
;
SMeta
*
pVnodeMeta
;
SArray
*
pColIdList
;
// SArray<int32_t>
int32_t
sver
;
SSchemaWrapper
*
pSchemaWrapper
;
STSchema
*
pSchema
;
};
typedef
struct
{
int8_t
type
;
int8_t
reserved
[
7
];
union
{
void
*
data
;
int64_t
wmTs
;
int64_t
checkpointId
;
};
}
STqStreamToken
;
typedef
struct
{
typedef
struct
{
int16_t
ver
;
int16_t
ver
;
int16_t
action
;
int16_t
action
;
...
@@ -248,6 +246,25 @@ typedef struct {
...
@@ -248,6 +246,25 @@ typedef struct {
static
STqPushMgmt
tqPushMgmt
;
static
STqPushMgmt
tqPushMgmt
;
// init once
int
tqInit
();
void
tqCleanUp
();
// open in each vnode
STQ
*
tqOpen
(
const
char
*
path
,
SVnode
*
pVnode
,
SWal
*
pWal
,
SMeta
*
pMeta
,
STqCfg
*
tqConfig
,
SMemAllocatorFactory
*
allocFac
);
void
tqClose
(
STQ
*
);
// required by vnode
int
tqPushMsg
(
STQ
*
,
void
*
msg
,
int32_t
msgLen
,
tmsg_t
msgType
,
int64_t
version
);
int
tqCommit
(
STQ
*
);
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
,
int32_t
workerId
);
int32_t
tqProcessSetConnReq
(
STQ
*
pTq
,
char
*
msg
);
int32_t
tqProcessRebReq
(
STQ
*
pTq
,
char
*
msg
);
int32_t
tqProcessCancelConnReq
(
STQ
*
pTq
,
char
*
msg
);
int32_t
tqProcessTaskExec
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
,
int32_t
workerId
);
int32_t
tqProcessTaskDeploy
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessStreamTrigger
(
STQ
*
pTq
,
void
*
data
,
int32_t
dataLen
,
int32_t
workerId
);
int32_t
tqSerializeConsumer
(
const
STqConsumer
*
,
STqSerializedHead
**
);
int32_t
tqSerializeConsumer
(
const
STqConsumer
*
,
STqSerializedHead
**
);
int32_t
tqDeserializeConsumer
(
STQ
*
,
const
STqSerializedHead
*
,
STqConsumer
**
);
int32_t
tqDeserializeConsumer
(
STQ
*
,
const
STqSerializedHead
*
,
STqConsumer
**
);
...
...
source/dnode/vnode/src/inc/tsdb.h
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
source/dnode/vnode/src/inc/tsdbSma.h
已删除
100644 → 0
浏览文件 @
2635df08
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_VNODE_TSDB_SMA_H_
#define _TD_VNODE_TSDB_SMA_H_
#include "tdbInt.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SSmaKey
SSmaKey
;
struct
SSmaKey
{
TSKEY
skey
;
int64_t
groupId
;
};
typedef
struct
SDBFile
SDBFile
;
struct
SDBFile
{
int32_t
fid
;
TDB
*
pDB
;
char
*
path
;
};
int32_t
tsdbOpenDBEnv
(
TENV
**
ppEnv
,
const
char
*
path
);
int32_t
tsdbCloseDBEnv
(
TENV
*
pEnv
);
int32_t
tsdbOpenDBF
(
TENV
*
pEnv
,
SDBFile
*
pDBF
);
int32_t
tsdbCloseDBF
(
SDBFile
*
pDBF
);
int32_t
tsdbSaveSmaToDB
(
SDBFile
*
pDBF
,
void
*
pKey
,
int32_t
keyLen
,
void
*
pVal
,
int32_t
valLen
,
TXN
*
txn
);
void
*
tsdbGetSmaDataByKey
(
SDBFile
*
pDBF
,
const
void
*
pKey
,
int32_t
keyLen
,
int32_t
*
valLen
);
void
tsdbDestroySmaEnv
(
SSmaEnv
*
pSmaEnv
);
void
*
tsdbFreeSmaEnv
(
SSmaEnv
*
pSmaEnv
);
#if 0
int32_t tsdbGetTSmaStatus(STsdb *pTsdb, STSma *param, void *result);
int32_t tsdbRemoveTSmaData(STsdb *pTsdb, STSma *param, STimeWindow *pWin);
#endif
// internal func
static
FORCE_INLINE
int32_t
tsdbEncodeTSmaKey
(
int64_t
groupId
,
TSKEY
tsKey
,
void
**
pData
)
{
int32_t
len
=
0
;
len
+=
taosEncodeFixedI64
(
pData
,
tsKey
);
len
+=
taosEncodeFixedI64
(
pData
,
groupId
);
return
len
;
}
#ifdef __cplusplus
}
#endif
#endif
/*_TD_VNODE_TSDB_SMA_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/vnd.h
0 → 100644
浏览文件 @
83a824a1
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_VND_H_
#define _TD_VND_H_
#ifdef __cplusplus
extern
"C"
{
#endif
// vnodeDebug ====================
// clang-format off
#define vFatal(...) do { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("VND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
#define vError(...) do { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("VND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
#define vWarn(...) do { if (vDebugFlag & DEBUG_WARN) { taosPrintLog("VND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
#define vInfo(...) do { if (vDebugFlag & DEBUG_INFO) { taosPrintLog("VND ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
#define vDebug(...) do { if (vDebugFlag & DEBUG_DEBUG) { taosPrintLog("VND ", DEBUG_DEBUG, vDebugFlag, __VA_ARGS__); }} while(0)
#define vTrace(...) do { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", DEBUG_TRACE, vDebugFlag, __VA_ARGS__); }} while(0)
// clang-format on
// vnodeModule ====================
int
vnodeScheduleTask
(
int
(
*
execute
)(
void
*
),
void
*
arg
);
// vnodeQuery ====================
int
vnodeQueryOpen
(
SVnode
*
pVnode
);
void
vnodeQueryClose
(
SVnode
*
pVnode
);
int
vnodeGetTableMeta
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
#if 1
// SVBufPool
int
vnodeOpenBufPool
(
SVnode
*
pVnode
);
void
vnodeCloseBufPool
(
SVnode
*
pVnode
);
int
vnodeBufPoolSwitch
(
SVnode
*
pVnode
);
int
vnodeBufPoolRecycle
(
SVnode
*
pVnode
);
void
*
vnodeMalloc
(
SVnode
*
pVnode
,
uint64_t
size
);
bool
vnodeBufPoolIsFull
(
SVnode
*
pVnode
);
SMemAllocatorFactory
*
vBufPoolGetMAF
(
SVnode
*
pVnode
);
// SVMemAllocator
typedef
struct
SVArenaNode
{
TD_SLIST_NODE
(
SVArenaNode
);
uint64_t
size
;
// current node size
void
*
ptr
;
char
data
[];
}
SVArenaNode
;
typedef
struct
SVMemAllocator
{
T_REF_DECLARE
()
TD_DLIST_NODE
(
SVMemAllocator
);
uint64_t
capacity
;
uint64_t
ssize
;
uint64_t
lsize
;
SVArenaNode
*
pNode
;
TD_SLIST
(
SVArenaNode
)
nlist
;
}
SVMemAllocator
;
SVMemAllocator
*
vmaCreate
(
uint64_t
capacity
,
uint64_t
ssize
,
uint64_t
lsize
);
void
vmaDestroy
(
SVMemAllocator
*
pVMA
);
void
vmaReset
(
SVMemAllocator
*
pVMA
);
void
*
vmaMalloc
(
SVMemAllocator
*
pVMA
,
uint64_t
size
);
void
vmaFree
(
SVMemAllocator
*
pVMA
,
void
*
ptr
);
bool
vmaIsFull
(
SVMemAllocator
*
pVMA
);
// vnodeCfg.h
extern
const
SVnodeCfg
defaultVnodeOptions
;
int
vnodeValidateOptions
(
const
SVnodeCfg
*
);
void
vnodeOptionsCopy
(
SVnodeCfg
*
pDest
,
const
SVnodeCfg
*
pSrc
);
// For commit
#define vnodeShouldCommit vnodeBufPoolIsFull
int
vnodeSyncCommit
(
SVnode
*
pVnode
);
int
vnodeAsyncCommit
(
SVnode
*
pVnode
);
#endif
#ifdef __cplusplus
}
#endif
#endif
/*_TD_VND_H_*/
\ No newline at end of file
source/dnode/vnode/src/inc/vnodeInt.h
浏览文件 @
83a824a1
...
@@ -24,47 +24,32 @@
...
@@ -24,47 +24,32 @@
#include "tcoding.h"
#include "tcoding.h"
#include "tcompression.h"
#include "tcompression.h"
#include "tdatablock.h"
#include "tdatablock.h"
#include "tdbInt.h"
#include "tfs.h"
#include "tfs.h"
#include "tglobal.h"
#include "tglobal.h"
#include "tlist.h"
#include "tlist.h"
#include "tlockfree.h"
#include "tlockfree.h"
#include "tlosertree.h"
#include "tlosertree.h"
#include "tmacro.h"
#include "tmallocator.h"
#include "tmallocator.h"
#include "tskiplist.h"
#include "tskiplist.h"
#include "tstream.h"
#include "tstream.h"
#include "ttime.h"
#include "ttime.h"
#include "ttimer.h"
#include "ttimer.h"
#include "vnode.h"
#include "wal.h"
#include "wal.h"
#include "vnode.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
typedef
struct
STQ
STQ
;
typedef
struct
SMeta
SMeta
;
typedef
struct
STsdb
STsdb
;
typedef
struct
STQ
STQ
;
typedef
struct
SVState
SVState
;
typedef
struct
SVState
SVState
;
typedef
struct
SVBufPool
SVBufPool
;
typedef
struct
SVBufPool
SVBufPool
;
typedef
struct
SQWorkerMgmt
SQHandle
;
typedef
struct
SQWorkerMgmt
SQHandle
;
typedef
struct
SVnodeTask
{
TD_DLIST_NODE
(
SVnodeTask
);
void
*
arg
;
int
(
*
execute
)(
void
*
);
}
SVnodeTask
;
typedef
struct
SVnodeMgr
{
td_mode_flag_t
vnodeInitFlag
;
// For commit
bool
stop
;
uint16_t
nthreads
;
TdThread
*
threads
;
TdThreadMutex
mutex
;
TdThreadCond
hasTask
;
TD_DLIST
(
SVnodeTask
)
queue
;
}
SVnodeMgr
;
typedef
struct
{
typedef
struct
{
int8_t
streamType
;
// sma or other
int8_t
streamType
;
// sma or other
int8_t
dstType
;
int8_t
dstType
;
...
@@ -80,8 +65,6 @@ typedef struct {
...
@@ -80,8 +65,6 @@ typedef struct {
SHashObj
*
pHash
;
// streamId -> SStreamSinkInfo
SHashObj
*
pHash
;
// streamId -> SStreamSinkInfo
}
SSink
;
}
SSink
;
extern
SVnodeMgr
vnodeMgr
;
// SVState
// SVState
struct
SVState
{
struct
SVState
{
int64_t
processed
;
int64_t
processed
;
...
@@ -106,126 +89,17 @@ struct SVnode {
...
@@ -106,126 +89,17 @@ struct SVnode {
STfs
*
pTfs
;
STfs
*
pTfs
;
};
};
int
vnodeScheduleTask
(
SVnodeTask
*
task
);
int
vnodeQueryOpen
(
SVnode
*
pVnode
);
void
vnodeQueryClose
(
SVnode
*
pVnode
);
#define vFatal(...) \
do { \
if (vDebugFlag & DEBUG_FATAL) { \
taosPrintLog("VND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); \
} \
} while (0)
#define vError(...) \
do { \
if (vDebugFlag & DEBUG_ERROR) { \
taosPrintLog("VND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); \
} \
} while (0)
#define vWarn(...) \
do { \
if (vDebugFlag & DEBUG_WARN) { \
taosPrintLog("VND WARN ", DEBUG_WARN, 255, __VA_ARGS__); \
} \
} while (0)
#define vInfo(...) \
do { \
if (vDebugFlag & DEBUG_INFO) { \
taosPrintLog("VND ", DEBUG_INFO, 255, __VA_ARGS__); \
} \
} while (0)
#define vDebug(...) \
do { \
if (vDebugFlag & DEBUG_DEBUG) { \
taosPrintLog("VND ", DEBUG_DEBUG, tsdbDebugFlag, __VA_ARGS__); \
} \
} while (0)
#define vTrace(...) \
do { \
if (vDebugFlag & DEBUG_TRACE) { \
taosPrintLog("VND ", DEBUG_TRACE, tsdbDebugFlag, __VA_ARGS__); \
} \
} while (0)
// vnodeCfg.h
extern
const
SVnodeCfg
defaultVnodeOptions
;
int
vnodeValidateOptions
(
const
SVnodeCfg
*
);
void
vnodeOptionsCopy
(
SVnodeCfg
*
pDest
,
const
SVnodeCfg
*
pSrc
);
// For commit
#define vnodeShouldCommit vnodeBufPoolIsFull
int
vnodeSyncCommit
(
SVnode
*
pVnode
);
int
vnodeAsyncCommit
(
SVnode
*
pVnode
);
// SVBufPool
int
vnodeOpenBufPool
(
SVnode
*
pVnode
);
void
vnodeCloseBufPool
(
SVnode
*
pVnode
);
int
vnodeBufPoolSwitch
(
SVnode
*
pVnode
);
int
vnodeBufPoolRecycle
(
SVnode
*
pVnode
);
void
*
vnodeMalloc
(
SVnode
*
pVnode
,
uint64_t
size
);
bool
vnodeBufPoolIsFull
(
SVnode
*
pVnode
);
SMemAllocatorFactory
*
vBufPoolGetMAF
(
SVnode
*
pVnode
);
// SVMemAllocator
typedef
struct
SVArenaNode
{
TD_SLIST_NODE
(
SVArenaNode
);
uint64_t
size
;
// current node size
void
*
ptr
;
char
data
[];
}
SVArenaNode
;
typedef
struct
SVMemAllocator
{
T_REF_DECLARE
()
TD_DLIST_NODE
(
SVMemAllocator
);
uint64_t
capacity
;
uint64_t
ssize
;
uint64_t
lsize
;
SVArenaNode
*
pNode
;
TD_SLIST
(
SVArenaNode
)
nlist
;
}
SVMemAllocator
;
SVMemAllocator
*
vmaCreate
(
uint64_t
capacity
,
uint64_t
ssize
,
uint64_t
lsize
);
void
vmaDestroy
(
SVMemAllocator
*
pVMA
);
void
vmaReset
(
SVMemAllocator
*
pVMA
);
void
*
vmaMalloc
(
SVMemAllocator
*
pVMA
,
uint64_t
size
);
void
vmaFree
(
SVMemAllocator
*
pVMA
,
void
*
ptr
);
bool
vmaIsFull
(
SVMemAllocator
*
pVMA
);
// init once
int
tqInit
();
void
tqCleanUp
();
// open in each vnode
STQ
*
tqOpen
(
const
char
*
path
,
SVnode
*
pVnode
,
SWal
*
pWal
,
SMeta
*
pMeta
,
STqCfg
*
tqConfig
,
SMemAllocatorFactory
*
allocFac
);
void
tqClose
(
STQ
*
);
// required by vnode
int
tqPushMsg
(
STQ
*
,
void
*
msg
,
int32_t
msgLen
,
tmsg_t
msgType
,
int64_t
version
);
int
tqCommit
(
STQ
*
);
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
,
int32_t
workerId
);
int32_t
tqProcessSetConnReq
(
STQ
*
pTq
,
char
*
msg
);
int32_t
tqProcessRebReq
(
STQ
*
pTq
,
char
*
msg
);
int32_t
tqProcessCancelConnReq
(
STQ
*
pTq
,
char
*
msg
);
int32_t
tqProcessTaskExec
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
,
int32_t
workerId
);
int32_t
tqProcessTaskDeploy
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
);
int32_t
tqProcessStreamTrigger
(
STQ
*
pTq
,
void
*
data
,
int32_t
dataLen
,
int32_t
workerId
);
// sma
// sma
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
);
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
);
#include "vnd.h"
#include "meta.h"
#include "meta.h"
#include "tsdb.h"
#include "tsdb.h"
#include "tq.h"
#include "tq.h"
#include "tsdbSma.h"
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
source/dnode/vnode/src/meta/metaCache.c
已删除
100644 → 0
浏览文件 @
2635df08
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vnodeInt.h"
struct
SMetaCache
{
// TODO
};
int
metaOpenCache
(
SMeta
*
pMeta
)
{
// TODO
// if (pMeta->options.lruSize) {
// pMeta->pCache = rocksdb_cache_create_lru(pMeta->options.lruSize);
// if (pMeta->pCache == NULL) {
// // TODO: handle error
// return -1;
// }
// }
return
0
;
}
void
metaCloseCache
(
SMeta
*
pMeta
)
{
// if (pMeta->pCache) {
// rocksdb_cache_destroy(pMeta->pCache);
// pMeta->pCache = NULL;
// }
}
\ No newline at end of file
source/dnode/vnode/src/meta/metaCfg.c
已删除
100644 → 0
浏览文件 @
2635df08
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vnodeInt.h"
const
SMetaCfg
defaultMetaOptions
=
{.
lruSize
=
0
};
/* ------------------------ EXPOSED METHODS ------------------------ */
int
metaValidateOptions
(
const
SMetaCfg
*
pMetaOptions
)
{
// TODO
return
0
;
}
void
metaOptionsCopy
(
SMetaCfg
*
pDest
,
const
SMetaCfg
*
pSrc
)
{
memcpy
(
pDest
,
pSrc
,
sizeof
(
*
pSrc
));
}
/* ------------------------ STATIC METHODS ------------------------ */
\ No newline at end of file
source/dnode/vnode/src/meta/metaMain.c
浏览文件 @
83a824a1
...
@@ -25,17 +25,6 @@ static void metaCloseImpl(SMeta *pMeta);
...
@@ -25,17 +25,6 @@ static void metaCloseImpl(SMeta *pMeta);
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMetaCfg
*
pMetaCfg
,
SMemAllocatorFactory
*
pMAF
)
{
SMeta
*
metaOpen
(
const
char
*
path
,
const
SMetaCfg
*
pMetaCfg
,
SMemAllocatorFactory
*
pMAF
)
{
SMeta
*
pMeta
=
NULL
;
SMeta
*
pMeta
=
NULL
;
// Set default options
if
(
pMetaCfg
==
NULL
)
{
pMetaCfg
=
&
defaultMetaOptions
;
}
// // Validate the options
// if (metaValidateOptions(pMetaCfg) < 0) {
// // TODO: deal with error
// return NULL;
// }
// Allocate handle
// Allocate handle
pMeta
=
metaNew
(
path
,
pMetaCfg
,
pMAF
);
pMeta
=
metaNew
(
path
,
pMetaCfg
,
pMAF
);
if
(
pMeta
==
NULL
)
{
if
(
pMeta
==
NULL
)
{
...
@@ -80,9 +69,6 @@ static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorF
...
@@ -80,9 +69,6 @@ static SMeta *metaNew(const char *path, const SMetaCfg *pMetaCfg, SMemAllocatorF
return
NULL
;
return
NULL
;
}
}
metaOptionsCopy
(
&
(
pMeta
->
options
),
pMetaCfg
);
pMeta
->
pmaf
=
pMAF
;
return
pMeta
;
return
pMeta
;
};
};
...
@@ -94,13 +80,6 @@ static void metaFree(SMeta *pMeta) {
...
@@ -94,13 +80,6 @@ static void metaFree(SMeta *pMeta) {
}
}
static
int
metaOpenImpl
(
SMeta
*
pMeta
)
{
static
int
metaOpenImpl
(
SMeta
*
pMeta
)
{
// Open meta cache
if
(
metaOpenCache
(
pMeta
)
<
0
)
{
// TODO: handle error
metaCloseImpl
(
pMeta
);
return
-
1
;
}
// Open meta db
// Open meta db
if
(
metaOpenDB
(
pMeta
)
<
0
)
{
if
(
metaOpenDB
(
pMeta
)
<
0
)
{
// TODO: handle error
// TODO: handle error
...
@@ -129,5 +108,4 @@ static void metaCloseImpl(SMeta *pMeta) {
...
@@ -129,5 +108,4 @@ static void metaCloseImpl(SMeta *pMeta) {
metaCloseUidGnrt
(
pMeta
);
metaCloseUidGnrt
(
pMeta
);
metaCloseIdx
(
pMeta
);
metaCloseIdx
(
pMeta
);
metaCloseDB
(
pMeta
);
metaCloseDB
(
pMeta
);
metaCloseCache
(
pMeta
);
}
}
\ No newline at end of file
source/dnode/vnode/src/meta/metaQuery.c
已删除
100644 → 0
浏览文件 @
2635df08
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vnodeInt.h"
\ No newline at end of file
source/dnode/vnode/src/meta/metaTbCfg.c
已删除
100644 → 0
浏览文件 @
2635df08
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vnodeInt.h"
int
metaValidateTbCfg
(
SMeta
*
pMeta
,
const
STbCfg
*
pTbOptions
)
{
// TODO
return
0
;
}
size_t
metaEncodeTbObjFromTbOptions
(
const
STbCfg
*
pTbOptions
,
void
*
pBuf
,
size_t
bsize
)
{
void
**
ppBuf
=
&
pBuf
;
int
tlen
=
0
;
tlen
+=
taosEncodeFixedU8
(
ppBuf
,
pTbOptions
->
type
);
tlen
+=
taosEncodeString
(
ppBuf
,
pTbOptions
->
name
);
tlen
+=
taosEncodeFixedU32
(
ppBuf
,
pTbOptions
->
ttl
);
switch
(
pTbOptions
->
type
)
{
case
META_SUPER_TABLE
:
tlen
+=
taosEncodeFixedU64
(
ppBuf
,
pTbOptions
->
stbCfg
.
suid
);
tlen
+=
tdEncodeSchema
(
ppBuf
,
(
STSchema
*
)
pTbOptions
->
stbCfg
.
pTagSchema
);
// TODO: encode schema version array
break
;
case
META_CHILD_TABLE
:
tlen
+=
taosEncodeFixedU64
(
ppBuf
,
pTbOptions
->
ctbCfg
.
suid
);
break
;
case
META_NORMAL_TABLE
:
// TODO: encode schema version array
break
;
default:
break
;
}
return
tlen
;
}
\ No newline at end of file
source/dnode/vnode/src/meta/metaTbTag.c
已删除
100644 → 0
浏览文件 @
2635df08
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vnodeInt.h"
\ No newline at end of file
source/dnode/vnode/src/tq/tq.c
浏览文件 @
83a824a1
...
@@ -126,8 +126,8 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t versi
...
@@ -126,8 +126,8 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t versi
int
tqCommit
(
STQ
*
pTq
)
{
return
tqStorePersist
(
pTq
->
tqMeta
);
}
int
tqCommit
(
STQ
*
pTq
)
{
return
tqStorePersist
(
pTq
->
tqMeta
);
}
int32_t
tqGetTopicHandleSize
(
const
STqTopic
*
pTopic
)
{
int32_t
tqGetTopicHandleSize
(
const
STqTopic
*
pTopic
)
{
return
strlen
(
pTopic
->
topicName
)
+
strlen
(
pTopic
->
sql
)
+
strlen
(
pTopic
->
logicalPlan
)
+
strlen
(
pTopic
->
physicalPlan
)
+
return
strlen
(
pTopic
->
topicName
)
+
strlen
(
pTopic
->
sql
)
+
strlen
(
pTopic
->
physicalPlan
)
+
strlen
(
pTopic
->
qmsg
)
+
s
trlen
(
pTopic
->
qmsg
)
+
s
izeof
(
int64_t
)
*
3
;
sizeof
(
int64_t
)
*
3
;
}
}
int32_t
tqGetConsumerHandleSize
(
const
STqConsumer
*
pConsumer
)
{
int32_t
tqGetConsumerHandleSize
(
const
STqConsumer
*
pConsumer
)
{
...
@@ -144,7 +144,6 @@ static FORCE_INLINE int32_t tEncodeSTqTopic(void** buf, const STqTopic* pTopic)
...
@@ -144,7 +144,6 @@ static FORCE_INLINE int32_t tEncodeSTqTopic(void** buf, const STqTopic* pTopic)
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeString
(
buf
,
pTopic
->
topicName
);
tlen
+=
taosEncodeString
(
buf
,
pTopic
->
topicName
);
/*tlen += taosEncodeString(buf, pTopic->sql);*/
/*tlen += taosEncodeString(buf, pTopic->sql);*/
/*tlen += taosEncodeString(buf, pTopic->logicalPlan);*/
/*tlen += taosEncodeString(buf, pTopic->physicalPlan);*/
/*tlen += taosEncodeString(buf, pTopic->physicalPlan);*/
tlen
+=
taosEncodeString
(
buf
,
pTopic
->
qmsg
);
tlen
+=
taosEncodeString
(
buf
,
pTopic
->
qmsg
);
/*tlen += taosEncodeFixedI64(buf, pTopic->persistedOffset);*/
/*tlen += taosEncodeFixedI64(buf, pTopic->persistedOffset);*/
...
@@ -156,7 +155,6 @@ static FORCE_INLINE int32_t tEncodeSTqTopic(void** buf, const STqTopic* pTopic)
...
@@ -156,7 +155,6 @@ static FORCE_INLINE int32_t tEncodeSTqTopic(void** buf, const STqTopic* pTopic)
static
FORCE_INLINE
const
void
*
tDecodeSTqTopic
(
const
void
*
buf
,
STqTopic
*
pTopic
)
{
static
FORCE_INLINE
const
void
*
tDecodeSTqTopic
(
const
void
*
buf
,
STqTopic
*
pTopic
)
{
buf
=
taosDecodeStringTo
(
buf
,
pTopic
->
topicName
);
buf
=
taosDecodeStringTo
(
buf
,
pTopic
->
topicName
);
/*buf = taosDecodeString(buf, &pTopic->sql);*/
/*buf = taosDecodeString(buf, &pTopic->sql);*/
/*buf = taosDecodeString(buf, &pTopic->logicalPlan);*/
/*buf = taosDecodeString(buf, &pTopic->physicalPlan);*/
/*buf = taosDecodeString(buf, &pTopic->physicalPlan);*/
buf
=
taosDecodeString
(
buf
,
&
pTopic
->
qmsg
);
buf
=
taosDecodeString
(
buf
,
&
pTopic
->
qmsg
);
/*buf = taosDecodeFixedI64(buf, &pTopic->persistedOffset);*/
/*buf = taosDecodeFixedI64(buf, &pTopic->persistedOffset);*/
...
@@ -722,7 +720,6 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) {
...
@@ -722,7 +720,6 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) {
}
}
strcpy
(
pTopic
->
topicName
,
req
.
topicName
);
strcpy
(
pTopic
->
topicName
,
req
.
topicName
);
pTopic
->
sql
=
req
.
sql
;
pTopic
->
sql
=
req
.
sql
;
pTopic
->
logicalPlan
=
req
.
logicalPlan
;
pTopic
->
physicalPlan
=
req
.
physicalPlan
;
pTopic
->
physicalPlan
=
req
.
physicalPlan
;
pTopic
->
qmsg
=
req
.
qmsg
;
pTopic
->
qmsg
=
req
.
qmsg
;
/*pTopic->committedOffset = -1;*/
/*pTopic->committedOffset = -1;*/
...
...
source/dnode/vnode/src/tsdb/tsdbBDBImpl.c
已删除
100644 → 0
浏览文件 @
2635df08
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define ALLOW_FORBID_FUNC
#include "db.h"
#include "vnodeInt.h"
#define IMPL_WITH_LOCK 1
static
int
tsdbOpenBDBDb
(
DB
**
ppDB
,
DB_ENV
*
pEnv
,
const
char
*
pFName
,
bool
isDup
);
static
void
tsdbCloseBDBDb
(
DB
*
pDB
);
#define BDB_PERR(info, code) fprintf(stderr, "%s:%d " info " reason: %s\n", __FILE__, __LINE__, db_strerror(code))
int32_t
tsdbOpenDBF
(
TDBEnv
pEnv
,
SDBFile
*
pDBF
)
{
// TDBEnv is shared by a group of SDBFile
if
(
!
pEnv
)
{
terrno
=
TSDB_CODE_INVALID_PTR
;
return
-
1
;
}
// Open DBF
if
(
tsdbOpenBDBDb
(
&
(
pDBF
->
pDB
),
pEnv
,
pDBF
->
path
,
false
)
<
0
)
{
terrno
=
TSDB_CODE_TDB_INIT_FAILED
;
tsdbCloseBDBDb
(
pDBF
->
pDB
);
return
-
1
;
}
return
0
;
}
void
tsdbCloseDBF
(
SDBFile
*
pDBF
)
{
if
(
pDBF
->
pDB
)
{
tsdbCloseBDBDb
(
pDBF
->
pDB
);
pDBF
->
pDB
=
NULL
;
}
taosMemoryFreeClear
(
pDBF
->
path
);
}
int32_t
tsdbOpenBDBEnv
(
DB_ENV
**
ppEnv
,
const
char
*
path
)
{
int
ret
=
0
;
DB_ENV
*
pEnv
=
NULL
;
if
(
path
==
NULL
)
return
0
;
ret
=
db_env_create
(
&
pEnv
,
0
);
if
(
ret
!=
0
)
{
BDB_PERR
(
"Failed to create tsdb env"
,
ret
);
return
-
1
;
}
ret
=
pEnv
->
open
(
pEnv
,
path
,
DB_CREATE
|
DB_INIT_CDB
|
DB_INIT_MPOOL
,
0
);
if
(
ret
!=
0
)
{
terrno
=
TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR
;
tsdbWarn
(
"Failed to open tsdb env for path %s since ret %d != 0"
,
path
?
path
:
"NULL"
,
ret
);
return
-
1
;
}
*
ppEnv
=
pEnv
;
return
0
;
}
void
tsdbCloseBDBEnv
(
DB_ENV
*
pEnv
)
{
if
(
pEnv
)
{
pEnv
->
close
(
pEnv
,
0
);
}
}
static
int
tsdbOpenBDBDb
(
DB
**
ppDB
,
DB_ENV
*
pEnv
,
const
char
*
pFName
,
bool
isDup
)
{
int
ret
;
DB
*
pDB
;
ret
=
db_create
(
&
(
pDB
),
pEnv
,
0
);
if
(
ret
!=
0
)
{
BDB_PERR
(
"Failed to create DBP"
,
ret
);
return
-
1
;
}
if
(
isDup
)
{
ret
=
pDB
->
set_flags
(
pDB
,
DB_DUPSORT
);
if
(
ret
!=
0
)
{
BDB_PERR
(
"Failed to set DB flags"
,
ret
);
return
-
1
;
}
}
ret
=
pDB
->
open
(
pDB
,
NULL
,
pFName
,
NULL
,
DB_BTREE
,
DB_CREATE
,
0
);
if
(
ret
)
{
BDB_PERR
(
"Failed to open DBF"
,
ret
);
return
-
1
;
}
*
ppDB
=
pDB
;
return
0
;
}
static
void
tsdbCloseBDBDb
(
DB
*
pDB
)
{
if
(
pDB
)
{
pDB
->
close
(
pDB
,
0
);
}
}
int32_t
tsdbSaveSmaToDB
(
SDBFile
*
pDBF
,
void
*
key
,
uint32_t
keySize
,
void
*
data
,
uint32_t
dataSize
)
{
int
ret
;
DBT
key1
=
{
0
},
value1
=
{
0
};
key1
.
data
=
key
;
key1
.
size
=
keySize
;
value1
.
data
=
data
;
value1
.
size
=
dataSize
;
// TODO: lock
ret
=
pDBF
->
pDB
->
put
(
pDBF
->
pDB
,
NULL
,
&
key1
,
&
value1
,
0
);
if
(
ret
)
{
BDB_PERR
(
"Failed to put data to DBF"
,
ret
);
// TODO: unlock
return
-
1
;
}
// TODO: unlock
return
0
;
}
void
*
tsdbGetSmaDataByKey
(
SDBFile
*
pDBF
,
void
*
key
,
uint32_t
keySize
,
uint32_t
*
valueSize
)
{
void
*
result
=
NULL
;
DBT
key1
=
{
0
};
DBT
value1
=
{
0
};
int
ret
;
// Set key/value
key1
.
data
=
key
;
key1
.
size
=
keySize
;
// Query
// TODO: lock
ret
=
pDBF
->
pDB
->
get
(
pDBF
->
pDB
,
NULL
,
&
key1
,
&
value1
,
0
);
// TODO: unlock
if
(
ret
!=
0
)
{
return
NULL
;
}
result
=
taosMemoryCalloc
(
1
,
value1
.
size
);
if
(
result
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
*
valueSize
=
value1
.
size
;
memcpy
(
result
,
value1
.
data
,
value1
.
size
);
return
result
;
}
\ No newline at end of file
source/dnode/vnode/src/vnd/vnodeBufferPool2.c
0 → 100644
浏览文件 @
83a824a1
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vnodeInt.h"
/* ------------------------ STRUCTURES ------------------------ */
static
int
vnodeBufPoolCreate
(
int
size
,
SVBufPool
**
ppPool
);
static
int
vnodeBufPoolDestroy
(
SVBufPool
*
pPool
);
int
vnodeOpenBufPool
(
SVnode
*
pVnode
,
int64_t
size
)
{
SVBufPool
*
pPool
=
NULL
;
int
ret
;
ASSERT
(
pVnode
->
pPool
==
NULL
);
for
(
int
i
=
0
;
i
<
3
;
i
++
)
{
// create pool
ret
=
vnodeBufPoolCreate
(
size
,
&
pPool
);
if
(
ret
<
0
)
{
vError
(
"vgId:%d failed to open vnode buffer pool since %s"
,
TD_VNODE_ID
(
pVnode
),
tstrerror
(
terrno
));
vnodeCloseBufPool
(
pVnode
);
return
-
1
;
}
// add pool to queue
pPool
->
next
=
pVnode
->
pPool
;
pVnode
->
pPool
=
pPool
;
}
vDebug
(
"vgId:%d vnode buffer pool is opened, pool size: %"
PRId64
,
TD_VNODE_ID
(
pVnode
),
size
);
return
0
;
}
int
vnodeCloseBufPool
(
SVnode
*
pVnode
)
{
SVBufPool
*
pPool
;
for
(
pPool
=
pVnode
->
pPool
;
pPool
;
pPool
=
pVnode
->
pPool
)
{
pVnode
->
pPool
=
pPool
->
next
;
vnodeBufPoolDestroy
(
pPool
);
}
vDebug
(
"vgId:%d vnode buffer pool is closed"
,
TD_VNODE_ID
(
pVnode
));
return
0
;
}
void
vnodeBufPoolReset
(
SVBufPool
*
pPool
)
{
SVBufPoolNode
*
pNode
;
for
(
pNode
=
pPool
->
pTail
;
pNode
->
prev
;
pNode
=
pPool
->
pTail
)
{
ASSERT
(
pNode
->
pnext
==
&
pPool
->
pTail
);
pNode
->
prev
->
pnext
=
&
pPool
->
pTail
;
pPool
->
pTail
=
pNode
->
prev
;
pPool
->
size
=
pPool
->
size
-
sizeof
(
*
pNode
)
-
pNode
->
size
;
taosMemoryFree
(
pNode
);
}
ASSERT
(
pPool
->
size
==
pPool
->
ptr
-
pPool
->
node
.
data
);
pPool
->
size
=
0
;
pPool
->
ptr
=
pPool
->
node
.
data
;
}
void
*
vnodeBufPoolMalloc
(
SVBufPool
*
pPool
,
size_t
size
)
{
SVBufPoolNode
*
pNode
;
void
*
p
;
if
(
pPool
->
node
.
size
>=
pPool
->
ptr
-
pPool
->
node
.
data
+
size
)
{
// allocate from the anchor node
p
=
pPool
->
ptr
;
pPool
->
ptr
=
pPool
->
ptr
+
size
;
pPool
->
size
+=
size
;
}
else
{
// allocate a new node
pNode
=
taosMemoryMalloc
(
sizeof
(
*
pNode
)
+
size
);
if
(
pNode
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
p
=
pNode
->
data
;
pNode
->
size
=
size
;
pNode
->
prev
=
pPool
->
pTail
;
pNode
->
pnext
=
&
pPool
->
pTail
;
pPool
->
pTail
->
pnext
=
&
pNode
->
prev
;
pPool
->
pTail
=
pNode
;
pPool
->
size
=
pPool
->
size
+
sizeof
(
*
pNode
)
+
size
;
}
return
p
;
}
void
vnodeBufPoolFree
(
SVBufPool
*
pPool
,
void
*
p
)
{
uint8_t
*
ptr
=
(
uint8_t
*
)
p
;
SVBufPoolNode
*
pNode
;
if
(
ptr
<
pPool
->
node
.
data
||
ptr
>=
pPool
->
node
.
data
+
pPool
->
node
.
size
)
{
pNode
=
&
((
SVBufPoolNode
*
)
p
)[
-
1
];
*
pNode
->
pnext
=
pNode
->
prev
;
pNode
->
prev
->
pnext
=
pNode
->
pnext
;
pPool
->
size
=
pPool
->
size
-
sizeof
(
*
pNode
)
-
pNode
->
size
;
taosMemoryFree
(
pNode
);
}
}
// STATIC METHODS -------------------
static
int
vnodeBufPoolCreate
(
int
size
,
SVBufPool
**
ppPool
)
{
SVBufPool
*
pPool
;
pPool
=
taosMemoryMalloc
(
sizeof
(
SVBufPool
)
+
size
);
if
(
pPool
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pPool
->
next
=
NULL
;
pPool
->
nRef
=
0
;
pPool
->
size
=
0
;
pPool
->
ptr
=
pPool
->
node
.
data
;
pPool
->
pTail
=
&
pPool
->
node
;
pPool
->
node
.
prev
=
NULL
;
pPool
->
node
.
pnext
=
&
pPool
->
pTail
;
pPool
->
node
.
size
=
size
;
*
ppPool
=
pPool
;
return
0
;
}
static
int
vnodeBufPoolDestroy
(
SVBufPool
*
pPool
)
{
vnodeBufPoolReset
(
pPool
);
taosMemoryFree
(
pPool
);
return
0
;
}
\ No newline at end of file
source/dnode/vnode/src/vnd/vnodeCommit.c
浏览文件 @
83a824a1
...
@@ -24,16 +24,10 @@ int vnodeAsyncCommit(SVnode *pVnode) {
...
@@ -24,16 +24,10 @@ int vnodeAsyncCommit(SVnode *pVnode) {
vnodeWaitCommit
(
pVnode
);
vnodeWaitCommit
(
pVnode
);
vnodeBufPoolSwitch
(
pVnode
);
vnodeBufPoolSwitch
(
pVnode
);
SVnodeTask
*
pTask
=
(
SVnodeTask
*
)
taosMemoryMalloc
(
sizeof
(
*
pTask
));
pTask
->
execute
=
vnodeCommit
;
// TODO
pTask
->
arg
=
pVnode
;
// TODO
tsdbPrepareCommit
(
pVnode
->
pTsdb
);
tsdbPrepareCommit
(
pVnode
->
pTsdb
);
// metaPrepareCommit(pVnode->pMeta);
// walPreapareCommit(pVnode->pWal);
vnodeScheduleTask
(
pTask
);
vnodeScheduleTask
(
vnodeCommit
,
pVnode
);
return
0
;
return
0
;
}
}
...
...
source/dnode/vnode/src/vnd/vnodeInt.c
浏览文件 @
83a824a1
...
@@ -21,25 +21,4 @@ int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg) { return 0; }
...
@@ -21,25 +21,4 @@ int32_t vnodeAlter(SVnode *pVnode, const SVnodeCfg *pCfg) { return 0; }
int32_t
vnodeCompact
(
SVnode
*
pVnode
)
{
return
0
;
}
int32_t
vnodeCompact
(
SVnode
*
pVnode
)
{
return
0
;
}
int32_t
vnodeSync
(
SVnode
*
pVnode
)
{
return
0
;
}
int32_t
vnodeSync
(
SVnode
*
pVnode
)
{
return
0
;
}
\ No newline at end of file
int32_t
vnodeGetLoad
(
SVnode
*
pVnode
,
SVnodeLoad
*
pLoad
)
{
pLoad
->
vgId
=
pVnode
->
vgId
;
pLoad
->
role
=
TAOS_SYNC_STATE_LEADER
;
pLoad
->
numOfTables
=
metaGetTbNum
(
pVnode
->
pMeta
);
pLoad
->
numOfTimeSeries
=
400
;
pLoad
->
totalStorage
=
300
;
pLoad
->
compStorage
=
200
;
pLoad
->
pointsWritten
=
100
;
pLoad
->
numOfSelectReqs
=
1
;
pLoad
->
numOfInsertReqs
=
3
;
pLoad
->
numOfInsertSuccessReqs
=
2
;
pLoad
->
numOfBatchInsertReqs
=
5
;
pLoad
->
numOfBatchInsertSuccessReqs
=
4
;
return
0
;
}
int
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
/*vInfo("sync message is processed");*/
return
0
;
}
source/dnode/vnode/src/vnd/vnodeM
gr
.c
→
source/dnode/vnode/src/vnd/vnodeM
odule
.c
浏览文件 @
83a824a1
...
@@ -15,31 +15,55 @@
...
@@ -15,31 +15,55 @@
#include "vnodeInt.h"
#include "vnodeInt.h"
SVnodeMgr
vnodeMgr
=
{.
vnodeInitFlag
=
TD_MOD_UNINITIALIZED
};
typedef
struct
SVnodeTask
SVnodeTask
;
struct
SVnodeTask
{
SVnodeTask
*
next
;
SVnodeTask
*
prev
;
int
(
*
execute
)(
void
*
);
void
*
arg
;
};
struct
SVnodeGlobal
{
int8_t
init
;
int8_t
stop
;
int
nthreads
;
TdThread
*
threads
;
TdThreadMutex
mutex
;
TdThreadCond
hasTask
;
SVnodeTask
queue
;
};
struct
SVnodeGlobal
vnodeGlobal
;
static
void
*
loop
(
void
*
arg
);
static
void
*
loop
(
void
*
arg
);
int
vnodeInit
()
{
int
vnodeInit
(
int
nthreads
)
{
if
(
TD_CHECK_AND_SET_MODE_INIT
(
&
(
vnodeMgr
.
vnodeInitFlag
))
==
TD_MOD_INITIALIZED
)
{
int8_t
init
;
int
ret
;
init
=
atomic_val_compare_exchange_8
(
&
(
vnodeGlobal
.
init
),
0
,
1
);
if
(
init
)
{
return
0
;
return
0
;
}
}
vnodeMgr
.
stop
=
false
;
vnodeGlobal
.
stop
=
0
;
vnodeGlobal
.
queue
.
next
=
&
vnodeGlobal
.
queue
;
vnodeGlobal
.
queue
.
prev
=
&
vnodeGlobal
.
queue
;
// Start commit handers
vnodeGlobal
.
nthreads
=
nthreads
;
vnodeMgr
.
nthreads
=
tsNumOfCommitThreads
;
vnodeGlobal
.
threads
=
taosMemoryCalloc
(
nthreads
,
sizeof
(
TdThread
));
vnodeMgr
.
threads
=
taosMemoryCalloc
(
vnodeMgr
.
nthreads
,
sizeof
(
TdThread
));
if
(
vnodeGlobal
.
threads
==
NULL
)
{
if
(
vnodeMgr
.
threads
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
vError
(
"failed to init vnode module since: %s"
,
tstrerror
(
terrno
));
return
-
1
;
return
-
1
;
}
}
taosThreadMutexInit
(
&
(
vnodeMgr
.
mutex
),
NULL
);
taosThreadMutexInit
(
&
vnodeGlobal
.
mutex
,
NULL
);
taosThreadCondInit
(
&
(
vnodeMgr
.
hasTask
),
NULL
);
taosThreadCondInit
(
&
vnodeGlobal
.
hasTask
,
NULL
);
TD_DLIST_INIT
(
&
(
vnodeMgr
.
queue
));
for
(
uint16_t
i
=
0
;
i
<
vnodeMgr
.
nthreads
;
i
++
)
{
for
(
int
i
=
0
;
i
<
nthreads
;
i
++
)
{
taosThreadCreate
(
&
(
vnodeMgr
.
threads
[
i
]),
NULL
,
loop
,
NULL
);
taosThreadCreate
(
&
(
vnodeGlobal
.
threads
[
i
]),
NULL
,
loop
,
NULL
);
// pthread_setname_np(vnodeMgr.threads[i], "VND Commit Thread");
}
}
if
(
walInit
()
<
0
)
{
if
(
walInit
()
<
0
)
{
...
@@ -50,62 +74,83 @@ int vnodeInit() {
...
@@ -50,62 +74,83 @@ int vnodeInit() {
}
}
void
vnodeCleanup
()
{
void
vnodeCleanup
()
{
if
(
TD_CHECK_AND_SET_MOD_CLEAR
(
&
(
vnodeMgr
.
vnodeInitFlag
))
==
TD_MOD_UNINITIALIZED
)
{
int8_t
init
;
return
;
}
// Stop commit handler
init
=
atomic_val_compare_exchange_8
(
&
(
vnodeGlobal
.
init
),
1
,
0
);
taosThreadMutexLock
(
&
(
vnodeMgr
.
mutex
));
if
(
init
==
0
)
return
;
vnodeMgr
.
stop
=
true
;
taosThreadCondBroadcast
(
&
(
vnodeMgr
.
hasTask
));
taosThreadMutexUnlock
(
&
(
vnodeMgr
.
mutex
));
for
(
uint16_t
i
=
0
;
i
<
vnodeMgr
.
nthreads
;
i
++
)
{
// set stop
taosThreadJoin
(
vnodeMgr
.
threads
[
i
],
NULL
);
taosThreadMutexLock
(
&
(
vnodeGlobal
.
mutex
));
vnodeGlobal
.
stop
=
1
;
taosThreadCondBroadcast
(
&
(
vnodeGlobal
.
hasTask
));
taosThreadMutexUnlock
(
&
(
vnodeGlobal
.
mutex
));
// wait for threads
for
(
int
i
=
0
;
i
<
vnodeGlobal
.
nthreads
;
i
++
)
{
taosThreadJoin
(
vnodeGlobal
.
threads
[
i
],
NULL
);
}
}
taosMemoryFreeClear
(
vnodeMgr
.
threads
);
// clear source
taosThreadCondDestroy
(
&
(
vnodeMgr
.
hasTask
));
taosMemoryFreeClear
(
vnodeGlobal
.
threads
);
taosThreadMutexDestroy
(
&
(
vnodeMgr
.
mutex
));
taosThreadCondDestroy
(
&
(
vnodeGlobal
.
hasTask
));
taosThreadMutexDestroy
(
&
(
vnodeGlobal
.
mutex
));
}
}
int
vnodeScheduleTask
(
SVnodeTask
*
pTask
)
{
int
vnodeScheduleTask
(
int
(
*
execute
)(
void
*
),
void
*
arg
)
{
taosThreadMutexLock
(
&
(
vnodeMgr
.
mutex
))
;
SVnodeTask
*
pTask
;
TD_DLIST_APPEND
(
&
(
vnodeMgr
.
queue
),
pTask
);
ASSERT
(
!
vnodeGlobal
.
stop
);
taosThreadCondSignal
(
&
(
vnodeMgr
.
hasTask
));
pTask
=
taosMemoryMalloc
(
sizeof
(
*
pTask
));
if
(
pTask
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
pTask
->
execute
=
execute
;
pTask
->
arg
=
arg
;
taosThreadMutexUnlock
(
&
(
vnodeMgr
.
mutex
));
taosThreadMutexLock
(
&
(
vnodeGlobal
.
mutex
));
pTask
->
next
=
&
vnodeGlobal
.
queue
;
pTask
->
prev
=
vnodeGlobal
.
queue
.
prev
;
vnodeGlobal
.
queue
.
prev
->
next
=
pTask
;
vnodeGlobal
.
queue
.
prev
=
pTask
;
taosThreadCondSignal
(
&
(
vnodeGlobal
.
hasTask
));
taosThreadMutexUnlock
(
&
(
vnodeGlobal
.
mutex
));
return
0
;
return
0
;
}
}
/* ------------------------ STATIC METHODS ------------------------ */
/* ------------------------ STATIC METHODS ------------------------ */
static
void
*
loop
(
void
*
arg
)
{
static
void
*
loop
(
void
*
arg
)
{
SVnodeTask
*
pTask
;
int
ret
;
setThreadName
(
"vnode-commit"
);
setThreadName
(
"vnode-commit"
);
SVnodeTask
*
pTask
;
for
(;;)
{
for
(;;)
{
taosThreadMutexLock
(
&
(
vnode
Mgr
.
mutex
));
taosThreadMutexLock
(
&
(
vnode
Global
.
mutex
));
for
(;;)
{
for
(;;)
{
pTask
=
TD_DLIST_HEAD
(
&
(
vnodeMgr
.
queue
));
pTask
=
vnodeGlobal
.
queue
.
next
;
if
(
pTask
==
NULL
)
{
if
(
pTask
==
&
vnodeGlobal
.
queue
)
{
if
(
vnodeMgr
.
stop
)
{
// no task
taosThreadMutexUnlock
(
&
(
vnodeMgr
.
mutex
));
if
(
vnodeGlobal
.
stop
)
{
taosThreadMutexUnlock
(
&
(
vnodeGlobal
.
mutex
));
return
NULL
;
return
NULL
;
}
else
{
}
else
{
taosThreadCondWait
(
&
(
vnode
Mgr
.
hasTask
),
&
(
vnodeMgr
.
mutex
));
taosThreadCondWait
(
&
(
vnode
Global
.
hasTask
),
&
(
vnodeGlobal
.
mutex
));
}
}
}
else
{
}
else
{
TD_DLIST_POP
(
&
(
vnodeMgr
.
queue
),
pTask
);
// has task
pTask
->
prev
->
next
=
pTask
->
next
;
pTask
->
next
->
prev
=
pTask
->
prev
;
break
;
break
;
}
}
}
}
taosThreadMutexUnlock
(
&
(
vnode
Mgr
.
mutex
));
taosThreadMutexUnlock
(
&
(
vnode
Global
.
mutex
));
(
*
(
pTask
->
execute
))
(
pTask
->
arg
);
pTask
->
execute
(
pTask
->
arg
);
taosMemoryFree
(
pTask
);
taosMemoryFree
(
pTask
);
}
}
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
83a824a1
...
@@ -15,64 +15,13 @@
...
@@ -15,64 +15,13 @@
#include "vnodeInt.h"
#include "vnodeInt.h"
static
int
vnodeGetTableMeta
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
);
int
vnodeQueryOpen
(
SVnode
*
pVnode
)
{
int
vnodeQueryOpen
(
SVnode
*
pVnode
)
{
return
qWorkerInit
(
NODE_TYPE_VNODE
,
pVnode
->
vgId
,
NULL
,
(
void
**
)
&
pVnode
->
pQuery
,
&
pVnode
->
msgCb
);
return
qWorkerInit
(
NODE_TYPE_VNODE
,
pVnode
->
vgId
,
NULL
,
(
void
**
)
&
pVnode
->
pQuery
,
&
pVnode
->
msgCb
);
}
}
void
vnodeQueryClose
(
SVnode
*
pVnode
)
{
qWorkerDestroy
((
void
**
)
&
pVnode
->
pQuery
);
}
void
vnodeQueryClose
(
SVnode
*
pVnode
)
{
qWorkerDestroy
((
void
**
)
&
pVnode
->
pQuery
);
}
int
vnodeProcessQueryMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
)
{
int
vnodeGetTableMeta
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
)
{
vTrace
(
"message in query queue is processing"
);
SReadHandle
handle
=
{.
reader
=
pVnode
->
pTsdb
,
.
meta
=
pVnode
->
pMeta
,
.
config
=
&
pVnode
->
config
};
switch
(
pMsg
->
msgType
)
{
case
TDMT_VND_QUERY
:
return
qWorkerProcessQueryMsg
(
&
handle
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_QUERY_CONTINUE
:
return
qWorkerProcessCQueryMsg
(
&
handle
,
pVnode
->
pQuery
,
pMsg
);
default:
vError
(
"unknown msg type:%d in query queue"
,
pMsg
->
msgType
);
return
TSDB_CODE_VND_APP_ERROR
;
}
}
int
vnodeProcessFetchMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SQueueInfo
*
pInfo
)
{
vTrace
(
"message in fetch queue is processing"
);
char
*
msgstr
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
int32_t
msgLen
=
pMsg
->
contLen
-
sizeof
(
SMsgHead
);
switch
(
pMsg
->
msgType
)
{
case
TDMT_VND_FETCH
:
return
qWorkerProcessFetchMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_FETCH_RSP
:
return
qWorkerProcessFetchRsp
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_RES_READY
:
return
qWorkerProcessReadyMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_TASKS_STATUS
:
return
qWorkerProcessStatusMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_CANCEL_TASK
:
return
qWorkerProcessCancelMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_DROP_TASK
:
return
qWorkerProcessDropMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_TABLE_META
:
return
vnodeGetTableMeta
(
pVnode
,
pMsg
);
case
TDMT_VND_CONSUME
:
return
tqProcessPollReq
(
pVnode
->
pTq
,
pMsg
,
pInfo
->
workerId
);
case
TDMT_VND_TASK_PIPE_EXEC
:
case
TDMT_VND_TASK_MERGE_EXEC
:
return
tqProcessTaskExec
(
pVnode
->
pTq
,
msgstr
,
msgLen
,
0
);
case
TDMT_VND_STREAM_TRIGGER
:
return
tqProcessStreamTrigger
(
pVnode
->
pTq
,
pMsg
->
pCont
,
pMsg
->
contLen
,
0
);
case
TDMT_VND_QUERY_HEARTBEAT
:
return
qWorkerProcessHbMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
default:
vError
(
"unknown msg type:%d in fetch queue"
,
pMsg
->
msgType
);
return
TSDB_CODE_VND_APP_ERROR
;
}
}
static
int
vnodeGetTableMeta
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
)
{
STbCfg
*
pTbCfg
=
NULL
;
STbCfg
*
pTbCfg
=
NULL
;
STbCfg
*
pStbCfg
=
NULL
;
STbCfg
*
pStbCfg
=
NULL
;
tb_uid_t
uid
;
tb_uid_t
uid
;
...
@@ -200,3 +149,19 @@ _exit:
...
@@ -200,3 +149,19 @@ _exit:
tmsgSendRsp
(
&
rpcMsg
);
tmsgSendRsp
(
&
rpcMsg
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
vnodeGetLoad
(
SVnode
*
pVnode
,
SVnodeLoad
*
pLoad
)
{
pLoad
->
vgId
=
pVnode
->
vgId
;
pLoad
->
role
=
TAOS_SYNC_STATE_LEADER
;
pLoad
->
numOfTables
=
metaGetTbNum
(
pVnode
->
pMeta
);
pLoad
->
numOfTimeSeries
=
400
;
pLoad
->
totalStorage
=
300
;
pLoad
->
compStorage
=
200
;
pLoad
->
pointsWritten
=
100
;
pLoad
->
numOfSelectReqs
=
1
;
pLoad
->
numOfInsertReqs
=
3
;
pLoad
->
numOfInsertSuccessReqs
=
2
;
pLoad
->
numOfBatchInsertReqs
=
5
;
pLoad
->
numOfBatchInsertSuccessReqs
=
4
;
return
0
;
}
source/dnode/vnode/src/vnd/vnodeSvr.c
0 → 100644
浏览文件 @
83a824a1
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vnodeInt.h"
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
void
*
pReq
);
static
int
vnodeProcessCreateTbReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
void
*
pReq
,
SRpcMsg
**
pRsp
);
static
int
vnodeProcessAlterStbReq
(
SVnode
*
pVnode
,
void
*
pReq
);
void
vnodePreprocessWriteReqs
(
SVnode
*
pVnode
,
SArray
*
pMsgs
)
{
SNodeMsg
*
pMsg
;
SRpcMsg
*
pRpc
;
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pMsgs
);
i
++
)
{
pMsg
=
*
(
SNodeMsg
**
)
taosArrayGet
(
pMsgs
,
i
);
pRpc
=
&
pMsg
->
rpcMsg
;
// set request version
void
*
pBuf
=
POINTER_SHIFT
(
pRpc
->
pCont
,
sizeof
(
SMsgHead
));
int64_t
ver
=
pVnode
->
state
.
processed
++
;
taosEncodeFixedI64
(
&
pBuf
,
ver
);
if
(
walWrite
(
pVnode
->
pWal
,
ver
,
pRpc
->
msgType
,
pRpc
->
pCont
,
pRpc
->
contLen
)
<
0
)
{
// TODO: handle error
/*ASSERT(false);*/
vError
(
"vnode:%d write wal error since %s"
,
pVnode
->
vgId
,
terrstr
());
}
}
walFsync
(
pVnode
->
pWal
,
false
);
}
int
vnodeProcessWriteReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
void
*
ptr
=
NULL
;
int
ret
;
if
(
pVnode
->
config
.
streamMode
==
0
)
{
ptr
=
vnodeMalloc
(
pVnode
,
pMsg
->
contLen
);
if
(
ptr
==
NULL
)
{
// TODO: handle error
}
// TODO: copy here need to be extended
memcpy
(
ptr
,
pMsg
->
pCont
,
pMsg
->
contLen
);
}
// todo: change the interface here
int64_t
ver
;
taosDecodeFixedI64
(
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
&
ver
);
if
(
tqPushMsg
(
pVnode
->
pTq
,
pMsg
->
pCont
,
pMsg
->
contLen
,
pMsg
->
msgType
,
ver
)
<
0
)
{
// TODO: handle error
}
switch
(
pMsg
->
msgType
)
{
case
TDMT_VND_CREATE_STB
:
ret
=
vnodeProcessCreateStbReq
(
pVnode
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)));
return
0
;
case
TDMT_VND_CREATE_TABLE
:
return
vnodeProcessCreateTbReq
(
pVnode
,
pMsg
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
pRsp
);
case
TDMT_VND_ALTER_STB
:
return
vnodeProcessAlterStbReq
(
pVnode
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)));
case
TDMT_VND_DROP_STB
:
vTrace
(
"vgId:%d, process drop stb req"
,
pVnode
->
vgId
);
break
;
case
TDMT_VND_DROP_TABLE
:
break
;
case
TDMT_VND_SUBMIT
:
/*printf("vnode %d write data %ld\n", pVnode->vgId, ver);*/
if
(
pVnode
->
config
.
streamMode
==
0
)
{
if
(
tsdbInsertData
(
pVnode
->
pTsdb
,
(
SSubmitReq
*
)
ptr
,
NULL
)
<
0
)
{
// TODO: handle error
}
}
break
;
case
TDMT_VND_MQ_SET_CONN
:
{
if
(
tqProcessSetConnReq
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
// TODO: handle error
}
}
break
;
case
TDMT_VND_MQ_REB
:
{
if
(
tqProcessRebReq
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
}
}
break
;
case
TDMT_VND_MQ_CANCEL_CONN
:
{
if
(
tqProcessCancelConnReq
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
}
}
break
;
case
TDMT_VND_TASK_DEPLOY
:
{
if
(
tqProcessTaskDeploy
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
pMsg
->
contLen
-
sizeof
(
SMsgHead
))
<
0
)
{
}
}
break
;
case
TDMT_VND_TASK_WRITE_EXEC
:
{
if
(
tqProcessTaskExec
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
pMsg
->
contLen
-
sizeof
(
SMsgHead
),
0
)
<
0
)
{
}
}
break
;
case
TDMT_VND_CREATE_SMA
:
{
// timeRangeSMA
if
(
tsdbCreateTSma
(
pVnode
->
pTsdb
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
// TODO
}
// } break;
// case TDMT_VND_CANCEL_SMA: { // timeRangeSMA
// } break;
// case TDMT_VND_DROP_SMA: { // timeRangeSMA
// if (tsdbDropTSma(pVnode->pTsdb, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) {
// // TODO
// }
}
break
;
default:
ASSERT
(
0
);
break
;
}
pVnode
->
state
.
applied
=
ver
;
// Check if it needs to commit
if
(
vnodeShouldCommit
(
pVnode
))
{
// tsem_wait(&(pVnode->canCommit));
if
(
vnodeAsyncCommit
(
pVnode
)
<
0
)
{
// TODO: handle error
}
}
return
0
;
}
int
vnodeProcessQueryMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
)
{
vTrace
(
"message in query queue is processing"
);
SReadHandle
handle
=
{.
reader
=
pVnode
->
pTsdb
,
.
meta
=
pVnode
->
pMeta
,
.
config
=
&
pVnode
->
config
};
switch
(
pMsg
->
msgType
)
{
case
TDMT_VND_QUERY
:
return
qWorkerProcessQueryMsg
(
&
handle
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_QUERY_CONTINUE
:
return
qWorkerProcessCQueryMsg
(
&
handle
,
pVnode
->
pQuery
,
pMsg
);
default:
vError
(
"unknown msg type:%d in query queue"
,
pMsg
->
msgType
);
return
TSDB_CODE_VND_APP_ERROR
;
}
}
int
vnodeProcessFetchMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SQueueInfo
*
pInfo
)
{
vTrace
(
"message in fetch queue is processing"
);
char
*
msgstr
=
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
));
int32_t
msgLen
=
pMsg
->
contLen
-
sizeof
(
SMsgHead
);
switch
(
pMsg
->
msgType
)
{
case
TDMT_VND_FETCH
:
return
qWorkerProcessFetchMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_FETCH_RSP
:
return
qWorkerProcessFetchRsp
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_RES_READY
:
return
qWorkerProcessReadyMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_TASKS_STATUS
:
return
qWorkerProcessStatusMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_CANCEL_TASK
:
return
qWorkerProcessCancelMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_DROP_TASK
:
return
qWorkerProcessDropMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
case
TDMT_VND_TABLE_META
:
return
vnodeGetTableMeta
(
pVnode
,
pMsg
);
case
TDMT_VND_CONSUME
:
return
tqProcessPollReq
(
pVnode
->
pTq
,
pMsg
,
pInfo
->
workerId
);
case
TDMT_VND_TASK_PIPE_EXEC
:
case
TDMT_VND_TASK_MERGE_EXEC
:
return
tqProcessTaskExec
(
pVnode
->
pTq
,
msgstr
,
msgLen
,
0
);
case
TDMT_VND_STREAM_TRIGGER
:
return
tqProcessStreamTrigger
(
pVnode
->
pTq
,
pMsg
->
pCont
,
pMsg
->
contLen
,
0
);
case
TDMT_VND_QUERY_HEARTBEAT
:
return
qWorkerProcessHbMsg
(
pVnode
,
pVnode
->
pQuery
,
pMsg
);
default:
vError
(
"unknown msg type:%d in fetch queue"
,
pMsg
->
msgType
);
return
TSDB_CODE_VND_APP_ERROR
;
}
}
// TODO: remove the function
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
)
{
// TODO
// blockDebugShowData(data);
tsdbInsertTSmaData
(((
SVnode
*
)
pVnode
)
->
pTsdb
,
smaId
,
(
const
char
*
)
data
);
}
int
vnodeProcessSyncReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
/*vInfo("sync message is processed");*/
return
0
;
}
static
int
vnodeProcessCreateStbReq
(
SVnode
*
pVnode
,
void
*
pReq
)
{
SVCreateTbReq
vCreateTbReq
=
{
0
};
tDeserializeSVCreateTbReq
(
pReq
,
&
vCreateTbReq
);
if
(
metaCreateTable
(
pVnode
->
pMeta
,
&
(
vCreateTbReq
))
<
0
)
{
// TODO
return
-
1
;
}
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pSchema
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pTagSchema
);
if
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
)
{
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
->
pFuncIds
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
);
}
taosMemoryFree
(
vCreateTbReq
.
dbFName
);
taosMemoryFree
(
vCreateTbReq
.
name
);
return
0
;
}
static
int
vnodeProcessCreateTbReq
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
void
*
pReq
,
SRpcMsg
**
pRsp
)
{
SVCreateTbBatchReq
vCreateTbBatchReq
=
{
0
};
SVCreateTbBatchRsp
vCreateTbBatchRsp
=
{
0
};
tDeserializeSVCreateTbBatchReq
(
pReq
,
&
vCreateTbBatchReq
);
int
reqNum
=
taosArrayGetSize
(
vCreateTbBatchReq
.
pArray
);
for
(
int
i
=
0
;
i
<
reqNum
;
i
++
)
{
SVCreateTbReq
*
pCreateTbReq
=
taosArrayGet
(
vCreateTbBatchReq
.
pArray
,
i
);
char
tableFName
[
TSDB_TABLE_FNAME_LEN
];
SMsgHead
*
pHead
=
(
SMsgHead
*
)
pMsg
->
pCont
;
sprintf
(
tableFName
,
"%s.%s"
,
pCreateTbReq
->
dbFName
,
pCreateTbReq
->
name
);
int32_t
code
=
vnodeValidateTableHash
(
&
pVnode
->
config
,
tableFName
);
if
(
code
)
{
SVCreateTbRsp
rsp
;
rsp
.
code
=
code
;
taosArrayPush
(
vCreateTbBatchRsp
.
rspList
,
&
rsp
);
}
if
(
metaCreateTable
(
pVnode
->
pMeta
,
pCreateTbReq
)
<
0
)
{
// TODO: handle error
vError
(
"vgId:%d, failed to create table: %s"
,
pVnode
->
vgId
,
pCreateTbReq
->
name
);
}
// TODO: to encapsule a free API
taosMemoryFree
(
pCreateTbReq
->
name
);
taosMemoryFree
(
pCreateTbReq
->
dbFName
);
if
(
pCreateTbReq
->
type
==
TD_SUPER_TABLE
)
{
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pSchema
);
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pTagSchema
);
if
(
pCreateTbReq
->
stbCfg
.
pRSmaParam
)
{
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pRSmaParam
->
pFuncIds
);
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pRSmaParam
);
}
}
else
if
(
pCreateTbReq
->
type
==
TD_CHILD_TABLE
)
{
taosMemoryFree
(
pCreateTbReq
->
ctbCfg
.
pTag
);
}
else
{
taosMemoryFree
(
pCreateTbReq
->
ntbCfg
.
pSchema
);
if
(
pCreateTbReq
->
ntbCfg
.
pRSmaParam
)
{
taosMemoryFree
(
pCreateTbReq
->
ntbCfg
.
pRSmaParam
->
pFuncIds
);
taosMemoryFree
(
pCreateTbReq
->
ntbCfg
.
pRSmaParam
);
}
}
}
vTrace
(
"vgId:%d process create %"
PRIzu
" tables"
,
pVnode
->
vgId
,
taosArrayGetSize
(
vCreateTbBatchReq
.
pArray
));
taosArrayDestroy
(
vCreateTbBatchReq
.
pArray
);
if
(
vCreateTbBatchRsp
.
rspList
)
{
int32_t
contLen
=
tSerializeSVCreateTbBatchRsp
(
NULL
,
0
,
&
vCreateTbBatchRsp
);
void
*
msg
=
rpcMallocCont
(
contLen
);
tSerializeSVCreateTbBatchRsp
(
msg
,
contLen
,
&
vCreateTbBatchRsp
);
taosArrayDestroy
(
vCreateTbBatchRsp
.
rspList
);
*
pRsp
=
taosMemoryCalloc
(
1
,
sizeof
(
SRpcMsg
));
(
*
pRsp
)
->
msgType
=
TDMT_VND_CREATE_TABLE_RSP
;
(
*
pRsp
)
->
pCont
=
msg
;
(
*
pRsp
)
->
contLen
=
contLen
;
(
*
pRsp
)
->
handle
=
pMsg
->
handle
;
(
*
pRsp
)
->
ahandle
=
pMsg
->
ahandle
;
}
return
0
;
}
static
int
vnodeProcessAlterStbReq
(
SVnode
*
pVnode
,
void
*
pReq
)
{
SVCreateTbReq
vAlterTbReq
=
{
0
};
vTrace
(
"vgId:%d, process alter stb req"
,
pVnode
->
vgId
);
tDeserializeSVCreateTbReq
(
pReq
,
&
vAlterTbReq
);
// TODO: to encapsule a free API
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pSchema
);
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pTagSchema
);
if
(
vAlterTbReq
.
stbCfg
.
pRSmaParam
)
{
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pRSmaParam
->
pFuncIds
);
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pRSmaParam
);
}
taosMemoryFree
(
vAlterTbReq
.
dbFName
);
taosMemoryFree
(
vAlterTbReq
.
name
);
return
0
;
}
\ No newline at end of file
source/dnode/vnode/src/vnd/vnodeWrite.c
浏览文件 @
83a824a1
...
@@ -15,277 +15,4 @@
...
@@ -15,277 +15,4 @@
#include "vnodeInt.h"
#include "vnodeInt.h"
void
smaHandleRes
(
void
*
pVnode
,
int64_t
smaId
,
const
SArray
*
data
)
{
// TODO
// blockDebugShowData(data);
tsdbInsertTSmaData
(((
SVnode
*
)
pVnode
)
->
pTsdb
,
smaId
,
(
const
char
*
)
data
);
}
void
vnodeProcessWMsgs
(
SVnode
*
pVnode
,
SArray
*
pMsgs
)
{
SNodeMsg
*
pMsg
;
SRpcMsg
*
pRpc
;
for
(
int
i
=
0
;
i
<
taosArrayGetSize
(
pMsgs
);
i
++
)
{
pMsg
=
*
(
SNodeMsg
**
)
taosArrayGet
(
pMsgs
,
i
);
pRpc
=
&
pMsg
->
rpcMsg
;
// set request version
void
*
pBuf
=
POINTER_SHIFT
(
pRpc
->
pCont
,
sizeof
(
SMsgHead
));
int64_t
ver
=
pVnode
->
state
.
processed
++
;
taosEncodeFixedI64
(
&
pBuf
,
ver
);
if
(
walWrite
(
pVnode
->
pWal
,
ver
,
pRpc
->
msgType
,
pRpc
->
pCont
,
pRpc
->
contLen
)
<
0
)
{
// TODO: handle error
/*ASSERT(false);*/
vError
(
"vnode:%d write wal error since %s"
,
pVnode
->
vgId
,
terrstr
());
}
}
walFsync
(
pVnode
->
pWal
,
false
);
// TODO: Integrate RAFT module here
// No results are returned because error handling is difficult
// return 0;
}
int
vnodeApplyWMsg
(
SVnode
*
pVnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
)
{
void
*
ptr
=
NULL
;
if
(
pVnode
->
config
.
streamMode
==
0
)
{
ptr
=
vnodeMalloc
(
pVnode
,
pMsg
->
contLen
);
if
(
ptr
==
NULL
)
{
// TODO: handle error
}
// TODO: copy here need to be extended
memcpy
(
ptr
,
pMsg
->
pCont
,
pMsg
->
contLen
);
}
// todo: change the interface here
int64_t
ver
;
taosDecodeFixedI64
(
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
&
ver
);
if
(
tqPushMsg
(
pVnode
->
pTq
,
pMsg
->
pCont
,
pMsg
->
contLen
,
pMsg
->
msgType
,
ver
)
<
0
)
{
// TODO: handle error
}
switch
(
pMsg
->
msgType
)
{
case
TDMT_VND_CREATE_STB
:
{
SVCreateTbReq
vCreateTbReq
=
{
0
};
tDeserializeSVCreateTbReq
(
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
&
vCreateTbReq
);
if
(
metaCreateTable
(
pVnode
->
pMeta
,
&
(
vCreateTbReq
))
<
0
)
{
// TODO: handle error
}
// TODO: to encapsule a free API
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pSchema
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pTagSchema
);
if
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
)
{
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
->
pFuncIds
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
);
}
taosMemoryFree
(
vCreateTbReq
.
dbFName
);
taosMemoryFree
(
vCreateTbReq
.
name
);
break
;
}
case
TDMT_VND_CREATE_TABLE
:
{
SVCreateTbBatchReq
vCreateTbBatchReq
=
{
0
};
SVCreateTbBatchRsp
vCreateTbBatchRsp
=
{
0
};
tDeserializeSVCreateTbBatchReq
(
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
&
vCreateTbBatchReq
);
int
reqNum
=
taosArrayGetSize
(
vCreateTbBatchReq
.
pArray
);
for
(
int
i
=
0
;
i
<
reqNum
;
i
++
)
{
SVCreateTbReq
*
pCreateTbReq
=
taosArrayGet
(
vCreateTbBatchReq
.
pArray
,
i
);
char
tableFName
[
TSDB_TABLE_FNAME_LEN
];
SMsgHead
*
pHead
=
(
SMsgHead
*
)
pMsg
->
pCont
;
sprintf
(
tableFName
,
"%s.%s"
,
pCreateTbReq
->
dbFName
,
pCreateTbReq
->
name
);
int32_t
code
=
vnodeValidateTableHash
(
&
pVnode
->
config
,
tableFName
);
if
(
code
)
{
SVCreateTbRsp
rsp
;
rsp
.
code
=
code
;
taosArrayPush
(
vCreateTbBatchRsp
.
rspList
,
&
rsp
);
}
if
(
metaCreateTable
(
pVnode
->
pMeta
,
pCreateTbReq
)
<
0
)
{
// TODO: handle error
vError
(
"vgId:%d, failed to create table: %s"
,
pVnode
->
vgId
,
pCreateTbReq
->
name
);
}
// TODO: to encapsule a free API
taosMemoryFree
(
pCreateTbReq
->
name
);
taosMemoryFree
(
pCreateTbReq
->
dbFName
);
if
(
pCreateTbReq
->
type
==
TD_SUPER_TABLE
)
{
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pSchema
);
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pTagSchema
);
if
(
pCreateTbReq
->
stbCfg
.
pRSmaParam
)
{
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pRSmaParam
->
pFuncIds
);
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pRSmaParam
);
}
}
else
if
(
pCreateTbReq
->
type
==
TD_CHILD_TABLE
)
{
taosMemoryFree
(
pCreateTbReq
->
ctbCfg
.
pTag
);
}
else
{
taosMemoryFree
(
pCreateTbReq
->
ntbCfg
.
pSchema
);
if
(
pCreateTbReq
->
ntbCfg
.
pRSmaParam
)
{
taosMemoryFree
(
pCreateTbReq
->
ntbCfg
.
pRSmaParam
->
pFuncIds
);
taosMemoryFree
(
pCreateTbReq
->
ntbCfg
.
pRSmaParam
);
}
}
}
vTrace
(
"vgId:%d process create %"
PRIzu
" tables"
,
pVnode
->
vgId
,
taosArrayGetSize
(
vCreateTbBatchReq
.
pArray
));
taosArrayDestroy
(
vCreateTbBatchReq
.
pArray
);
if
(
vCreateTbBatchRsp
.
rspList
)
{
int32_t
contLen
=
tSerializeSVCreateTbBatchRsp
(
NULL
,
0
,
&
vCreateTbBatchRsp
);
void
*
msg
=
rpcMallocCont
(
contLen
);
tSerializeSVCreateTbBatchRsp
(
msg
,
contLen
,
&
vCreateTbBatchRsp
);
taosArrayDestroy
(
vCreateTbBatchRsp
.
rspList
);
*
pRsp
=
taosMemoryCalloc
(
1
,
sizeof
(
SRpcMsg
));
(
*
pRsp
)
->
msgType
=
TDMT_VND_CREATE_TABLE_RSP
;
(
*
pRsp
)
->
pCont
=
msg
;
(
*
pRsp
)
->
contLen
=
contLen
;
(
*
pRsp
)
->
handle
=
pMsg
->
handle
;
(
*
pRsp
)
->
ahandle
=
pMsg
->
ahandle
;
}
break
;
}
case
TDMT_VND_ALTER_STB
:
{
SVCreateTbReq
vAlterTbReq
=
{
0
};
vTrace
(
"vgId:%d, process alter stb req"
,
pVnode
->
vgId
);
tDeserializeSVCreateTbReq
(
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
&
vAlterTbReq
);
// TODO: to encapsule a free API
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pSchema
);
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pTagSchema
);
if
(
vAlterTbReq
.
stbCfg
.
pRSmaParam
)
{
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pRSmaParam
->
pFuncIds
);
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pRSmaParam
);
}
taosMemoryFree
(
vAlterTbReq
.
dbFName
);
taosMemoryFree
(
vAlterTbReq
.
name
);
break
;
}
case
TDMT_VND_DROP_STB
:
vTrace
(
"vgId:%d, process drop stb req"
,
pVnode
->
vgId
);
break
;
case
TDMT_VND_DROP_TABLE
:
// if (metaDropTable(pVnode->pMeta, vReq.dtReq.uid) < 0) {
// // TODO: handle error
// }
break
;
case
TDMT_VND_SUBMIT
:
/*printf("vnode %d write data %ld\n", pVnode->vgId, ver);*/
if
(
pVnode
->
config
.
streamMode
==
0
)
{
if
(
tsdbInsertData
(
pVnode
->
pTsdb
,
(
SSubmitReq
*
)
ptr
,
NULL
)
<
0
)
{
// TODO: handle error
}
}
break
;
case
TDMT_VND_MQ_SET_CONN
:
{
if
(
tqProcessSetConnReq
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
// TODO: handle error
}
}
break
;
case
TDMT_VND_MQ_REB
:
{
if
(
tqProcessRebReq
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
}
}
break
;
case
TDMT_VND_MQ_CANCEL_CONN
:
{
if
(
tqProcessCancelConnReq
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
}
}
break
;
case
TDMT_VND_TASK_DEPLOY
:
{
if
(
tqProcessTaskDeploy
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
pMsg
->
contLen
-
sizeof
(
SMsgHead
))
<
0
)
{
}
}
break
;
case
TDMT_VND_TASK_WRITE_EXEC
:
{
if
(
tqProcessTaskExec
(
pVnode
->
pTq
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
pMsg
->
contLen
-
sizeof
(
SMsgHead
),
0
)
<
0
)
{
}
}
break
;
case
TDMT_VND_CREATE_SMA
:
{
// timeRangeSMA
#if 0
SSmaCfg vCreateSmaReq = {0};
if (tDeserializeSVCreateTSmaReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vCreateSmaReq) == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
vWarn("vgId:%d TDMT_VND_CREATE_SMA received but deserialize failed since %s", pVnode->config.vgId,
terrstr(terrno));
return -1;
}
vDebug("vgId:%d TDMT_VND_CREATE_SMA msg received for %s:%" PRIi64, pVnode->config.vgId,
vCreateSmaReq.tSma.indexName, vCreateSmaReq.tSma.indexUid);
// record current timezone of server side
vCreateSmaReq.tSma.timezoneInt = tsTimezone;
if (metaCreateTSma(pVnode->pMeta, &vCreateSmaReq) < 0) {
// TODO: handle error
tdDestroyTSma(&vCreateSmaReq.tSma);
return -1;
}
tsdbTSmaAdd(pVnode->pTsdb, 1);
tdDestroyTSma(&vCreateSmaReq.tSma);
// TODO: return directly or go on follow steps?
#endif
if
(
tsdbCreateTSma
(
pVnode
->
pTsdb
,
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)))
<
0
)
{
// TODO
}
// } break;
// case TDMT_VND_CANCEL_SMA: { // timeRangeSMA
// } break;
// case TDMT_VND_DROP_SMA: { // timeRangeSMA
// if (tsdbDropTSma(pVnode->pTsdb, POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead))) < 0) {
// // TODO
// }
#if 0
tsdbTSmaSub(pVnode->pTsdb, 1);
SVDropTSmaReq vDropSmaReq = {0};
if (tDeserializeSVDropTSmaReq(POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)), &vDropSmaReq) == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
return -1;
}
// TODO: send msg to stream computing to drop tSma
// if ((send msg to stream computing) < 0) {
// tdDestroyTSma(&vCreateSmaReq);
// return -1;
// }
//
if (metaDropTSma(pVnode->pMeta, vDropSmaReq.indexUid) < 0) {
// TODO: handle error
return -1;
}
if(tsdbDropTSmaData(pVnode->pTsdb, vDropSmaReq.indexUid) < 0) {
// TODO: handle error
return -1;
}
// TODO: return directly or go on follow steps?
#endif
}
break
;
default:
ASSERT
(
0
);
break
;
}
pVnode
->
state
.
applied
=
ver
;
// Check if it needs to commit
if
(
vnodeShouldCommit
(
pVnode
))
{
// tsem_wait(&(pVnode->canCommit));
if
(
vnodeAsyncCommit
(
pVnode
)
<
0
)
{
// TODO: handle error
}
}
return
0
;
}
/* ------------------------ STATIC METHODS ------------------------ */
/* ------------------------ STATIC METHODS ------------------------ */
source/libs/executor/inc/executorimpl.h
浏览文件 @
83a824a1
...
@@ -48,8 +48,6 @@ typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int
...
@@ -48,8 +48,6 @@ typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int
#define GET_TABLEGROUP(q, _index) ((SArray*)taosArrayGetP((q)->tableqinfoGroupInfo.pGroupList, (_index)))
#define GET_TABLEGROUP(q, _index) ((SArray*)taosArrayGetP((q)->tableqinfoGroupInfo.pGroupList, (_index)))
#define GET_NUM_OF_RESULTS(_r) (((_r)->outputBuf) == NULL ? 0 : ((_r)->outputBuf)->info.rows)
#define NEEDTO_COMPRESS_QUERY(size) ((size) > tsCompressColData ? 1 : 0)
#define NEEDTO_COMPRESS_QUERY(size) ((size) > tsCompressColData ? 1 : 0)
enum
{
enum
{
...
@@ -84,21 +82,6 @@ typedef struct SResultInfo { // TODO refactor
...
@@ -84,21 +82,6 @@ typedef struct SResultInfo { // TODO refactor
int32_t
threshold
;
// result size threshold in rows.
int32_t
threshold
;
// result size threshold in rows.
}
SResultInfo
;
}
SResultInfo
;
typedef
struct
SColumnFilterElem
{
int16_t
bytes
;
// column length
__filter_func_t
fp
;
SColumnFilterInfo
filterInfo
;
void
*
q
;
}
SColumnFilterElem
;
typedef
struct
SSingleColumnFilterInfo
{
void
*
pData
;
void
*
pData2
;
// used for nchar column
int32_t
numOfFilters
;
SColumnInfo
info
;
SColumnFilterElem
*
pFilters
;
}
SSingleColumnFilterInfo
;
typedef
struct
STableQueryInfo
{
typedef
struct
STableQueryInfo
{
TSKEY
lastKey
;
// last check ts
TSKEY
lastKey
;
// last check ts
uint64_t
uid
;
// table uid
uint64_t
uid
;
// table uid
...
@@ -169,66 +152,36 @@ typedef struct SOperatorCostInfo {
...
@@ -169,66 +152,36 @@ typedef struct SOperatorCostInfo {
uint64_t
totalCost
;
uint64_t
totalCost
;
}
SOperatorCostInfo
;
}
SOperatorCostInfo
;
typedef
struct
SOrder
{
uint32_t
order
;
SColumn
col
;
}
SOrder
;
// The basic query information extracted from the SQueryInfo tree to support the
// The basic query information extracted from the SQueryInfo tree to support the
// execution of query in a data node.
// execution of query in a data node.
typedef
struct
STaskAttr
{
typedef
struct
STaskAttr
{
SLimit
limit
;
SLimit
limit
;
SLimit
slimit
;
SLimit
slimit
;
bool
stableQuery
;
// super table query or not
// todo comment it
bool
topBotQuery
;
// TODO used bitwise flag
bool
stableQuery
;
// super table query or not
bool
groupbyColumn
;
// denote if this is a groupby normal column query
bool
topBotQuery
;
// TODO used bitwise flag
bool
timeWindowInterpo
;
// if the time window start/end required interpolation
bool
groupbyColumn
;
// denote if this is a groupby normal column query
bool
tsCompQuery
;
// is tscomp query
bool
hasTagResults
;
// if there are tag values in final result or not
bool
diffQuery
;
// is diff query
bool
timeWindowInterpo
;
// if the time window start/end required interpolation
bool
pointInterpQuery
;
// point interpolation query
bool
queryBlockDist
;
// if query data block distribution
int32_t
havingNum
;
// having expr number
bool
stabledev
;
// super table stddev query
int16_t
numOfCols
;
bool
tsCompQuery
;
// is tscomp query
int16_t
numOfTags
;
bool
diffQuery
;
// is diff query
STimeWindow
window
;
bool
simpleAgg
;
SInterval
interval
;
bool
pointInterpQuery
;
// point interpolation query
int16_t
precision
;
bool
needReverseScan
;
// need reverse scan
int16_t
numOfOutput
;
bool
distinct
;
// distinct query or not
int16_t
fillType
;
bool
stateWindow
;
// window State on sub/normal table
int32_t
resultRowSize
;
bool
createFilterOperator
;
// if filter operator is needed
int32_t
tagLen
;
// tag value length of current query
bool
multigroupResult
;
// multigroup result can exist in one SSDataBlock
int32_t
interBufSize
;
// intermediate buffer sizse
SExprInfo
*
pExpr1
;
SColumnInfo
*
tagColList
;
int32_t
havingNum
;
// having expr number
int32_t
numOfFilterCols
;
int64_t
*
fillVal
;
SOrder
order
;
int16_t
numOfCols
;
int16_t
numOfTags
;
STimeWindow
window
;
SInterval
interval
;
int16_t
precision
;
int16_t
numOfOutput
;
int16_t
fillType
;
int32_t
srcRowSize
;
// todo extract struct
int32_t
resultRowSize
;
int32_t
intermediateResultRowSize
;
// intermediate result row size, in case of top-k query.
int32_t
maxTableColumnWidth
;
int32_t
tagLen
;
// tag value length of current query
SExprInfo
*
pExpr1
;
SColumnInfo
*
tableCols
;
SColumnInfo
*
tagColList
;
int32_t
numOfFilterCols
;
int64_t
*
fillVal
;
SSingleColumnFilterInfo
*
pFilterInfo
;
void
*
tsdb
;
void
*
tsdb
;
STableGroupInfo
tableGroupInfo
;
// table <tid, last_key> list SArray<STableKeyInfo>
STableGroupInfo
tableGroupInfo
;
// table <tid, last_key> list SArray<STableKeyInfo>
int32_t
vgId
;
int32_t
vgId
;
SArray
*
pUdfInfo
;
// no need to free
}
STaskAttr
;
}
STaskAttr
;
struct
SOperatorInfo
;
struct
SOperatorInfo
;
...
@@ -252,7 +205,6 @@ typedef struct STaskIdInfo {
...
@@ -252,7 +205,6 @@ typedef struct STaskIdInfo {
typedef
struct
SExecTaskInfo
{
typedef
struct
SExecTaskInfo
{
STaskIdInfo
id
;
STaskIdInfo
id
;
char
*
content
;
uint32_t
status
;
uint32_t
status
;
STimeWindow
window
;
STimeWindow
window
;
STaskCostInfo
cost
;
STaskCostInfo
cost
;
...
@@ -262,7 +214,7 @@ typedef struct SExecTaskInfo {
...
@@ -262,7 +214,7 @@ typedef struct SExecTaskInfo {
STableGroupInfo
tableqinfoGroupInfo
;
// this is a group array list, including SArray<STableQueryInfo*> structure
STableGroupInfo
tableqinfoGroupInfo
;
// this is a group array list, including SArray<STableQueryInfo*> structure
char
*
sql
;
// query sql string
char
*
sql
;
// query sql string
jmp_buf
env
;
// jump to this position when error happens.
jmp_buf
env
;
// jump to this position when error happens.
EOPTR_EXEC_MODEL
execModel
;
// operator execution model [batch model|stream model]
EOPTR_EXEC_MODEL
execModel
;
// operator execution model [batch model|stream model]
struct
SOperatorInfo
*
pRoot
;
struct
SOperatorInfo
*
pRoot
;
}
SExecTaskInfo
;
}
SExecTaskInfo
;
...
@@ -297,7 +249,7 @@ typedef struct STaskRuntimeEnv {
...
@@ -297,7 +249,7 @@ typedef struct STaskRuntimeEnv {
int64_t
currentOffset
;
// dynamic offset value
int64_t
currentOffset
;
// dynamic offset value
STableQueryInfo
*
current
;
STableQueryInfo
*
current
;
SResultInfo
resultInfo
;
SResultInfo
resultInfo
;
SHashObj
*
pTableRetrieveTsMap
;
SHashObj
*
pTableRetrieveTsMap
;
struct
SUdfInfo
*
pUdfInfo
;
struct
SUdfInfo
*
pUdfInfo
;
}
STaskRuntimeEnv
;
}
STaskRuntimeEnv
;
...
@@ -339,25 +291,6 @@ typedef struct {
...
@@ -339,25 +291,6 @@ typedef struct {
SColumnInfo
*
colList
;
SColumnInfo
*
colList
;
}
SQueriedTableInfo
;
}
SQueriedTableInfo
;
typedef
struct
SQInfo
{
void
*
signature
;
uint64_t
qId
;
int32_t
code
;
// error code to returned to client
int64_t
owner
;
// if it is in execution
STaskRuntimeEnv
runtimeEnv
;
STaskAttr
query
;
void
*
pBuf
;
// allocated buffer for STableQueryInfo, sizeof(STableQueryInfo)*numOfTables;
TdThreadMutex
lock
;
// used to synchronize the rsp/query threads
tsem_t
ready
;
int32_t
dataReady
;
// denote if query result is ready or not
void
*
rspContext
;
// response context
int64_t
startExecTs
;
// start to exec timestamp
char
*
sql
;
// query sql string
STaskCostInfo
summary
;
}
SQInfo
;
typedef
enum
{
typedef
enum
{
EX_SOURCE_DATA_NOT_READY
=
0x1
,
EX_SOURCE_DATA_NOT_READY
=
0x1
,
EX_SOURCE_DATA_READY
=
0x2
,
EX_SOURCE_DATA_READY
=
0x2
,
...
@@ -523,24 +456,6 @@ typedef struct SProjectOperatorInfo {
...
@@ -523,24 +456,6 @@ typedef struct SProjectOperatorInfo {
int64_t
curOutput
;
int64_t
curOutput
;
}
SProjectOperatorInfo
;
}
SProjectOperatorInfo
;
typedef
struct
SSLimitOperatorInfo
{
int64_t
groupTotal
;
int64_t
currentGroupOffset
;
int64_t
rowsTotal
;
int64_t
currentOffset
;
SLimit
limit
;
SLimit
slimit
;
char
**
prevRow
;
SArray
*
orderColumnList
;
bool
hasPrev
;
bool
ignoreCurrentGroup
;
bool
multigroupResult
;
SSDataBlock
*
pRes
;
// result buffer
SSDataBlock
*
pPrevBlock
;
int64_t
capacity
;
int64_t
threshold
;
}
SSLimitOperatorInfo
;
typedef
struct
SFillOperatorInfo
{
typedef
struct
SFillOperatorInfo
{
struct
SFillInfo
*
pFillInfo
;
struct
SFillInfo
*
pFillInfo
;
SSDataBlock
*
pRes
;
SSDataBlock
*
pRes
;
...
@@ -553,10 +468,10 @@ typedef struct SFillOperatorInfo {
...
@@ -553,10 +468,10 @@ typedef struct SFillOperatorInfo {
}
SFillOperatorInfo
;
}
SFillOperatorInfo
;
typedef
struct
{
typedef
struct
{
char
*
pData
;
char
*
pData
;
bool
isNull
;
bool
isNull
;
int16_t
type
;
int16_t
type
;
int32_t
bytes
;
int32_t
bytes
;
}
SGroupKeys
,
SStateKeys
;
}
SGroupKeys
,
SStateKeys
;
typedef
struct
SGroupbyOperatorInfo
{
typedef
struct
SGroupbyOperatorInfo
{
...
@@ -582,19 +497,19 @@ typedef struct SDataGroupInfo {
...
@@ -582,19 +497,19 @@ typedef struct SDataGroupInfo {
// The sort in partition may be needed later.
// The sort in partition may be needed later.
typedef
struct
SPartitionOperatorInfo
{
typedef
struct
SPartitionOperatorInfo
{
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
SArray
*
pGroupCols
;
SArray
*
pGroupCols
;
SArray
*
pGroupColVals
;
// current group column values, SArray<SGroupKeys>
SArray
*
pGroupColVals
;
// current group column values, SArray<SGroupKeys>
char
*
keyBuf
;
// group by keys for hash
char
*
keyBuf
;
// group by keys for hash
int32_t
groupKeyLen
;
// total group by column width
int32_t
groupKeyLen
;
// total group by column width
SHashObj
*
pGroupSet
;
// quick locate the window object for each result
SHashObj
*
pGroupSet
;
// quick locate the window object for each result
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
void
*
pGroupIter
;
// group iterator
int32_t
pageIndex
;
// page index of current group
int32_t
pageIndex
;
// page index of current group
}
SPartitionOperatorInfo
;
}
SPartitionOperatorInfo
;
typedef
struct
SWindowRowsSup
{
typedef
struct
SWindowRowsSup
{
...
@@ -633,26 +548,21 @@ typedef struct SStateWindowOperatorInfo {
...
@@ -633,26 +548,21 @@ typedef struct SStateWindowOperatorInfo {
}
SStateWindowOperatorInfo
;
}
SStateWindowOperatorInfo
;
typedef
struct
SSortedMergeOperatorInfo
{
typedef
struct
SSortedMergeOperatorInfo
{
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
bool
hasVarCol
;
bool
hasVarCol
;
SArray
*
pSortInfo
;
SArray
*
pSortInfo
;
int32_t
numOfSources
;
int32_t
numOfSources
;
SSortHandle
*
pSortHandle
;
SSortHandle
*
pSortHandle
;
int32_t
bufPageSize
;
uint32_t
sortBufSize
;
// max buffer size for in-memory sort
int32_t
bufPageSize
;
int32_t
resultRowFactor
;
uint32_t
sortBufSize
;
// max buffer size for in-memory sort
bool
hasGroupVal
;
SDiskbasedBuf
*
pTupleStore
;
// keep the final results
int32_t
resultRowFactor
;
int32_t
numOfResPerPage
;
bool
hasGroupVal
;
char
**
groupVal
;
SArray
*
groupInfo
;
SDiskbasedBuf
*
pTupleStore
;
// keep the final results
SAggSupporter
aggSup
;
int32_t
numOfResPerPage
;
char
**
groupVal
;
SArray
*
groupInfo
;
SAggSupporter
aggSup
;
}
SSortedMergeOperatorInfo
;
}
SSortedMergeOperatorInfo
;
typedef
struct
SSortOperatorInfo
{
typedef
struct
SSortOperatorInfo
{
...
@@ -680,8 +590,7 @@ int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInf
...
@@ -680,8 +590,7 @@ int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInf
void
toSDatablock
(
SSDataBlock
*
pBlock
,
int32_t
rowCapacity
,
SGroupResInfo
*
pGroupResInfo
,
SExprInfo
*
pExprInfo
,
SDiskbasedBuf
*
pBuf
,
int32_t
*
rowCellOffset
);
void
toSDatablock
(
SSDataBlock
*
pBlock
,
int32_t
rowCapacity
,
SGroupResInfo
*
pGroupResInfo
,
SExprInfo
*
pExprInfo
,
SDiskbasedBuf
*
pBuf
,
int32_t
*
rowCellOffset
);
void
finalizeMultiTupleQueryResult
(
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SDiskbasedBuf
*
pBuf
,
SResultRowInfo
*
pResultRowInfo
,
int32_t
*
rowCellInfoOffset
);
void
finalizeMultiTupleQueryResult
(
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
,
SDiskbasedBuf
*
pBuf
,
SResultRowInfo
*
pResultRowInfo
,
int32_t
*
rowCellInfoOffset
);
void
doApplyFunctions
(
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
pWin
,
SColumnInfoData
*
pTimeWindowData
,
int32_t
offset
,
int32_t
forwardStep
,
TSKEY
*
tsCol
,
int32_t
numOfTotal
,
int32_t
numOfOutput
,
int32_t
order
);
void
doApplyFunctions
(
SqlFunctionCtx
*
pCtx
,
STimeWindow
*
pWin
,
SColumnInfoData
*
pTimeWindowData
,
int32_t
offset
,
int32_t
forwardStep
,
TSKEY
*
tsCol
,
int32_t
numOfTotal
,
int32_t
numOfOutput
,
int32_t
order
);
int32_t
setGroupResultOutputBuf_rv
(
SOptrBasicInfo
*
binfo
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
type
,
int32_t
setGroupResultOutputBuf
(
SOptrBasicInfo
*
binfo
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
type
,
int16_t
bytes
,
int32_t
groupId
,
SDiskbasedBuf
*
pBuf
,
SExecTaskInfo
*
pTaskInfo
,
SAggSupporter
*
pAggSup
);
int16_t
bytes
,
int32_t
groupId
,
SDiskbasedBuf
*
pBuf
,
SExecTaskInfo
*
pTaskInfo
,
SAggSupporter
*
pAggSup
);
void
doDestroyBasicInfo
(
SOptrBasicInfo
*
pInfo
,
int32_t
numOfOutput
);
void
doDestroyBasicInfo
(
SOptrBasicInfo
*
pInfo
,
int32_t
numOfOutput
);
int32_t
setSDataBlockFromFetchRsp
(
SSDataBlock
*
pRes
,
SLoadRemoteDataInfo
*
pLoadInfo
,
int32_t
numOfRows
,
int32_t
setSDataBlockFromFetchRsp
(
SSDataBlock
*
pRes
,
SLoadRemoteDataInfo
*
pLoadInfo
,
int32_t
numOfRows
,
char
*
pData
,
int32_t
compLen
,
int32_t
numOfOutput
,
int64_t
startTs
,
char
*
pData
,
int32_t
compLen
,
int32_t
numOfOutput
,
int64_t
startTs
,
...
@@ -748,7 +657,6 @@ void setTaskKilled(SExecTaskInfo* pTaskInfo);
...
@@ -748,7 +657,6 @@ void setTaskKilled(SExecTaskInfo* pTaskInfo);
void
publishOperatorProfEvent
(
SOperatorInfo
*
operatorInfo
,
EQueryProfEventType
eventType
);
void
publishOperatorProfEvent
(
SOperatorInfo
*
operatorInfo
,
EQueryProfEventType
eventType
);
void
publishQueryAbortEvent
(
SExecTaskInfo
*
pTaskInfo
,
int32_t
code
);
void
publishQueryAbortEvent
(
SExecTaskInfo
*
pTaskInfo
,
int32_t
code
);
void
calculateOperatorProfResults
(
SQInfo
*
pQInfo
);
void
queryCostStatis
(
SExecTaskInfo
*
pTaskInfo
);
void
queryCostStatis
(
SExecTaskInfo
*
pTaskInfo
);
void
doDestroyTask
(
SExecTaskInfo
*
pTaskInfo
);
void
doDestroyTask
(
SExecTaskInfo
*
pTaskInfo
);
...
...
source/libs/executor/src/executil.c
浏览文件 @
83a824a1
...
@@ -337,11 +337,11 @@ int32_t tsDescOrder(const void* p1, const void* p2) {
...
@@ -337,11 +337,11 @@ int32_t tsDescOrder(const void* p1, const void* p2) {
void
orderTheResultRows
(
STaskRuntimeEnv
*
pRuntimeEnv
)
{
void
orderTheResultRows
(
STaskRuntimeEnv
*
pRuntimeEnv
)
{
__compar_fn_t
fn
=
NULL
;
__compar_fn_t
fn
=
NULL
;
if
(
pRuntimeEnv
->
pQueryAttr
->
order
.
order
==
TSDB_ORDER_ASC
)
{
//
if (pRuntimeEnv->pQueryAttr->order.order == TSDB_ORDER_ASC) {
fn
=
tsAscOrder
;
//
fn = tsAscOrder;
}
else
{
//
} else {
fn
=
tsDescOrder
;
//
fn = tsDescOrder;
}
//
}
taosArraySort
(
pRuntimeEnv
->
pResultRowArrayList
,
fn
);
taosArraySort
(
pRuntimeEnv
->
pResultRowArrayList
,
fn
);
}
}
...
@@ -377,7 +377,7 @@ static int32_t mergeIntoGroupResultImplRv(STaskRuntimeEnv *pRuntimeEnv, SGroupRe
...
@@ -377,7 +377,7 @@ static int32_t mergeIntoGroupResultImplRv(STaskRuntimeEnv *pRuntimeEnv, SGroupRe
static
UNUSED_FUNC
int32_t
mergeIntoGroupResultImpl
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SGroupResInfo
*
pGroupResInfo
,
SArray
*
pTableList
,
static
UNUSED_FUNC
int32_t
mergeIntoGroupResultImpl
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SGroupResInfo
*
pGroupResInfo
,
SArray
*
pTableList
,
int32_t
*
rowCellInfoOffset
)
{
int32_t
*
rowCellInfoOffset
)
{
bool
ascQuery
=
QUERY_IS_ASC_QUERY
(
pRuntimeEnv
->
pQueryAttr
)
;
bool
ascQuery
=
true
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
...
@@ -413,7 +413,8 @@ static UNUSED_FUNC int32_t mergeIntoGroupResultImpl(STaskRuntimeEnv *pRuntimeEnv
...
@@ -413,7 +413,8 @@ static UNUSED_FUNC int32_t mergeIntoGroupResultImpl(STaskRuntimeEnv *pRuntimeEnv
goto
_end
;
goto
_end
;
}
}
SCompSupporter
cs
=
{
pTableQueryInfoList
,
posList
,
pRuntimeEnv
->
pQueryAttr
->
order
.
order
};
int32_t
order
=
TSDB_ORDER_ASC
;
SCompSupporter
cs
=
{
pTableQueryInfoList
,
posList
,
order
};
int32_t
ret
=
tMergeTreeCreate
(
&
pTree
,
numOfTables
,
&
cs
,
tableResultComparFn
);
int32_t
ret
=
tMergeTreeCreate
(
&
pTree
,
numOfTables
,
&
cs
,
tableResultComparFn
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
...
...
source/libs/executor/src/executor.c
浏览文件 @
83a824a1
...
@@ -52,7 +52,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
...
@@ -52,7 +52,7 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
for
(
int32_t
i
=
0
;
i
<
numOfBlocks
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfBlocks
;
++
i
)
{
SSDataBlock
*
pDataBlock
=
&
((
SSDataBlock
*
)
input
)[
i
];
SSDataBlock
*
pDataBlock
=
&
((
SSDataBlock
*
)
input
)[
i
];
SSDataBlock
*
p
=
createOneDataBlock
(
pDataBlock
);
SSDataBlock
*
p
=
createOneDataBlock
(
pDataBlock
,
false
);
p
->
info
=
pDataBlock
->
info
;
p
->
info
=
pDataBlock
->
info
;
taosArrayClear
(
p
->
pDataBlock
);
taosArrayClear
(
p
->
pDataBlock
);
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
83a824a1
...
@@ -990,7 +990,8 @@ static int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext,
...
@@ -990,7 +990,8 @@ static int32_t getNextQualifiedWindow(SInterval* pInterval, STimeWindow* pNext,
static
FORCE_INLINE
TSKEY
reviseWindowEkey
(
STaskAttr
*
pQueryAttr
,
STimeWindow
*
pWindow
)
{
static
FORCE_INLINE
TSKEY
reviseWindowEkey
(
STaskAttr
*
pQueryAttr
,
STimeWindow
*
pWindow
)
{
TSKEY
ekey
=
-
1
;
TSKEY
ekey
=
-
1
;
if
(
QUERY_IS_ASC_QUERY
(
pQueryAttr
))
{
int32_t
order
=
TSDB_ORDER_ASC
;
if
(
order
==
TSDB_ORDER_ASC
)
{
ekey
=
pWindow
->
ekey
;
ekey
=
pWindow
->
ekey
;
if
(
ekey
>
pQueryAttr
->
window
.
ekey
)
{
if
(
ekey
>
pQueryAttr
->
window
.
ekey
)
{
ekey
=
pQueryAttr
->
window
.
ekey
;
ekey
=
pQueryAttr
->
window
.
ekey
;
...
@@ -1700,9 +1701,8 @@ static void setResultRowKey(SResultRow* pResultRow, char* pData, int16_t type) {
...
@@ -1700,9 +1701,8 @@ static void setResultRowKey(SResultRow* pResultRow, char* pData, int16_t type) {
}
}
}
}
int32_t
setGroupResultOutputBuf_rv
(
SOptrBasicInfo
*
binfo
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
type
,
int32_t
setGroupResultOutputBuf
(
SOptrBasicInfo
*
binfo
,
int32_t
numOfCols
,
char
*
pData
,
int16_t
type
,
int16_t
bytes
,
int16_t
bytes
,
int32_t
groupId
,
SDiskbasedBuf
*
pBuf
,
SExecTaskInfo
*
pTaskInfo
,
int32_t
groupId
,
SDiskbasedBuf
*
pBuf
,
SExecTaskInfo
*
pTaskInfo
,
SAggSupporter
*
pAggSup
)
{
SAggSupporter
*
pAggSup
)
{
SResultRowInfo
*
pResultRowInfo
=
&
binfo
->
resultRowInfo
;
SResultRowInfo
*
pResultRowInfo
=
&
binfo
->
resultRowInfo
;
SqlFunctionCtx
*
pCtx
=
binfo
->
pCtx
;
SqlFunctionCtx
*
pCtx
=
binfo
->
pCtx
;
...
@@ -1961,7 +1961,8 @@ static bool isCachedLastQuery(STaskAttr* pQueryAttr) {
...
@@ -1961,7 +1961,8 @@ static bool isCachedLastQuery(STaskAttr* pQueryAttr) {
return
false
;
return
false
;
}
}
if
(
pQueryAttr
->
order
.
order
!=
TSDB_ORDER_DESC
||
!
TSWINDOW_IS_EQUAL
(
pQueryAttr
->
window
,
TSWINDOW_DESC_INITIALIZER
))
{
int32_t
order
=
TSDB_ORDER_ASC
;
if
(
order
!=
TSDB_ORDER_DESC
||
!
TSWINDOW_IS_EQUAL
(
pQueryAttr
->
window
,
TSWINDOW_DESC_INITIALIZER
))
{
return
false
;
return
false
;
}
}
...
@@ -2187,7 +2188,7 @@ static bool overlapWithTimeWindow(STaskAttr* pQueryAttr, SDataBlockInfo* pBlockI
...
@@ -2187,7 +2188,7 @@ static bool overlapWithTimeWindow(STaskAttr* pQueryAttr, SDataBlockInfo* pBlockI
TSKEY
sk
=
TMIN
(
pQueryAttr
->
window
.
skey
,
pQueryAttr
->
window
.
ekey
);
TSKEY
sk
=
TMIN
(
pQueryAttr
->
window
.
skey
,
pQueryAttr
->
window
.
ekey
);
TSKEY
ek
=
TMAX
(
pQueryAttr
->
window
.
skey
,
pQueryAttr
->
window
.
ekey
);
TSKEY
ek
=
TMAX
(
pQueryAttr
->
window
.
skey
,
pQueryAttr
->
window
.
ekey
);
if
(
QUERY_IS_ASC_QUERY
(
pQueryAttr
)
)
{
if
(
true
)
{
// getAlignQueryTimeWindow(pQueryAttr, pBlockInfo->window.skey, sk, ek, &w);
// getAlignQueryTimeWindow(pQueryAttr, pBlockInfo->window.skey, sk, ek, &w);
assert
(
w
.
ekey
>=
pBlockInfo
->
window
.
skey
);
assert
(
w
.
ekey
>=
pBlockInfo
->
window
.
skey
);
...
@@ -2257,57 +2258,6 @@ static int32_t doTSJoinFilter(STaskRuntimeEnv* pRuntimeEnv, TSKEY key, bool ascQ
...
@@ -2257,57 +2258,6 @@ static int32_t doTSJoinFilter(STaskRuntimeEnv* pRuntimeEnv, TSKEY key, bool ascQ
return
TS_JOIN_TS_EQUAL
;
return
TS_JOIN_TS_EQUAL
;
}
}
bool
doFilterDataBlock
(
SSingleColumnFilterInfo
*
pFilterInfo
,
int32_t
numOfFilterCols
,
int32_t
numOfRows
,
int8_t
*
p
)
{
bool
all
=
true
;
for
(
int32_t
i
=
0
;
i
<
numOfRows
;
++
i
)
{
bool
qualified
=
false
;
for
(
int32_t
k
=
0
;
k
<
numOfFilterCols
;
++
k
)
{
char
*
pElem
=
(
char
*
)
pFilterInfo
[
k
].
pData
+
pFilterInfo
[
k
].
info
.
bytes
*
i
;
qualified
=
false
;
for
(
int32_t
j
=
0
;
j
<
pFilterInfo
[
k
].
numOfFilters
;
++
j
)
{
SColumnFilterElem
*
pFilterElem
=
NULL
;
// SColumnFilterElem* pFilterElem = &pFilterInfo[k].pFilters[j];
bool
isnull
=
isNull
(
pElem
,
pFilterInfo
[
k
].
info
.
type
);
if
(
isnull
)
{
// if (pFilterElem->fp == isNullOperator) {
// qualified = true;
// break;
// } else {
// continue;
// }
}
else
{
// if (pFilterElem->fp == notNullOperator) {
// qualified = true;
// break;
// } else if (pFilterElem->fp == isNullOperator) {
// continue;
// }
}
if
(
pFilterElem
->
fp
(
pFilterElem
,
pElem
,
pElem
,
pFilterInfo
[
k
].
info
.
type
))
{
qualified
=
true
;
break
;
}
}
if
(
!
qualified
)
{
break
;
}
}
p
[
i
]
=
qualified
?
1
:
0
;
if
(
!
qualified
)
{
all
=
false
;
}
}
return
all
;
}
void
doCompactSDataBlock
(
SSDataBlock
*
pBlock
,
int32_t
numOfRows
,
int8_t
*
p
)
{
void
doCompactSDataBlock
(
SSDataBlock
*
pBlock
,
int32_t
numOfRows
,
int8_t
*
p
)
{
int32_t
len
=
0
;
int32_t
len
=
0
;
int32_t
start
=
0
;
int32_t
start
=
0
;
...
@@ -2357,49 +2307,6 @@ void doCompactSDataBlock(SSDataBlock* pBlock, int32_t numOfRows, int8_t* p) {
...
@@ -2357,49 +2307,6 @@ void doCompactSDataBlock(SSDataBlock* pBlock, int32_t numOfRows, int8_t* p) {
}
}
}
}
void
filterRowsInDataBlock
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SSingleColumnFilterInfo
*
pFilterInfo
,
int32_t
numOfFilterCols
,
SSDataBlock
*
pBlock
,
bool
ascQuery
)
{
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
int8_t
*
p
=
taosMemoryCalloc
(
numOfRows
,
sizeof
(
int8_t
));
bool
all
=
true
;
#if 0
if (pRuntimeEnv->pTsBuf != NULL) {
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, 0);
TSKEY* k = (TSKEY*) pColInfoData->pData;
for (int32_t i = 0; i < numOfRows; ++i) {
int32_t offset = ascQuery? i:(numOfRows - i - 1);
int32_t ret = doTSJoinFilter(pRuntimeEnv, k[offset], ascQuery);
if (ret == TS_JOIN_TAG_NOT_EQUALS) {
break;
} else if (ret == TS_JOIN_TS_NOT_EQUALS) {
all = false;
continue;
} else {
assert(ret == TS_JOIN_TS_EQUAL);
p[offset] = true;
}
if (!tsBufNextPos(pRuntimeEnv->pTsBuf)) {
break;
}
}
// save the cursor status
pRuntimeEnv->current->cur = tsBufGetCursor(pRuntimeEnv->pTsBuf);
} else {
all = doFilterDataBlock(pFilterInfo, numOfFilterCols, numOfRows, p);
}
#endif
if
(
!
all
)
{
doCompactSDataBlock
(
pBlock
,
numOfRows
,
p
);
}
taosMemoryFreeClear
(
p
);
}
void
filterColRowsInDataBlock
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SSDataBlock
*
pBlock
,
bool
ascQuery
)
{
void
filterColRowsInDataBlock
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SSDataBlock
*
pBlock
,
bool
ascQuery
)
{
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
int32_t
numOfRows
=
pBlock
->
info
.
rows
;
...
@@ -3131,7 +3038,7 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) {
...
@@ -3131,7 +3038,7 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock) {
bool
keep
=
filterExecute
(
filter
,
pBlock
,
&
rowRes
,
NULL
,
param1
.
numOfCols
);
bool
keep
=
filterExecute
(
filter
,
pBlock
,
&
rowRes
,
NULL
,
param1
.
numOfCols
);
filterFreeInfo
(
filter
);
filterFreeInfo
(
filter
);
SSDataBlock
*
px
=
createOneDataBlock
(
pBlock
);
SSDataBlock
*
px
=
createOneDataBlock
(
pBlock
,
false
);
blockDataEnsureCapacity
(
px
,
pBlock
->
info
.
rows
);
blockDataEnsureCapacity
(
px
,
pBlock
->
info
.
rows
);
// todo extract method
// todo extract method
...
@@ -3509,22 +3416,22 @@ static void doOperatorExecProfOnce(SOperatorStackItem* item, SQueryProfEvent* ev
...
@@ -3509,22 +3416,22 @@ static void doOperatorExecProfOnce(SOperatorStackItem* item, SQueryProfEvent* ev
}
}
}
}
void
calculateOperatorProfResults
(
SQInfo
*
pQInfo
)
{
void
calculateOperatorProfResults
(
void
)
{
if
(
pQInfo
->
summary
.
queryProfEvents
==
NULL
)
{
//
if (pQInfo->summary.queryProfEvents == NULL) {
// qDebug("QInfo:0x%"PRIx64" query prof events array is null", pQInfo->qId);
//
// qDebug("QInfo:0x%"PRIx64" query prof events array is null", pQInfo->qId);
return
;
//
return;
}
//
}
//
if
(
pQInfo
->
summary
.
operatorProfResults
==
NULL
)
{
//
if (pQInfo->summary.operatorProfResults == NULL) {
// qDebug("QInfo:0x%"PRIx64" operator prof results hash is null", pQInfo->qId);
//
// qDebug("QInfo:0x%"PRIx64" operator prof results hash is null", pQInfo->qId);
return
;
//
return;
}
//
}
SArray
*
opStack
=
taosArrayInit
(
32
,
sizeof
(
SOperatorStackItem
));
SArray
*
opStack
=
taosArrayInit
(
32
,
sizeof
(
SOperatorStackItem
));
if
(
opStack
==
NULL
)
{
if
(
opStack
==
NULL
)
{
return
;
return
;
}
}
#if 0
size_t size = taosArrayGetSize(pQInfo->summary.queryProfEvents);
size_t size = taosArrayGetSize(pQInfo->summary.queryProfEvents);
SHashObj* profResults = pQInfo->summary.operatorProfResults;
SHashObj* profResults = pQInfo->summary.operatorProfResults;
...
@@ -3547,7 +3454,7 @@ void calculateOperatorProfResults(SQInfo* pQInfo) {
...
@@ -3547,7 +3454,7 @@ void calculateOperatorProfResults(SQInfo* pQInfo) {
}
}
}
}
}
}
#endif
taosArrayDestroy
(
opStack
);
taosArrayDestroy
(
opStack
);
}
}
...
@@ -4507,13 +4414,6 @@ static void destroySortedMergeOperatorInfo(void* param, int32_t numOfOutput) {
...
@@ -4507,13 +4414,6 @@ static void destroySortedMergeOperatorInfo(void* param, int32_t numOfOutput) {
cleanupAggSup
(
&
pInfo
->
aggSup
);
cleanupAggSup
(
&
pInfo
->
aggSup
);
}
}
static
void
destroySlimitOperatorInfo
(
void
*
param
,
int32_t
numOfOutput
)
{
SSLimitOperatorInfo
*
pInfo
=
(
SSLimitOperatorInfo
*
)
param
;
taosArrayDestroy
(
pInfo
->
orderColumnList
);
pInfo
->
pRes
=
blockDataDestroy
(
pInfo
->
pRes
);
taosMemoryFreeClear
(
pInfo
->
prevRow
);
}
static
void
assignExprInfo
(
SExprInfo
*
dst
,
const
SExprInfo
*
src
)
{
static
void
assignExprInfo
(
SExprInfo
*
dst
,
const
SExprInfo
*
src
)
{
assert
(
dst
!=
NULL
&&
src
!=
NULL
);
assert
(
dst
!=
NULL
&&
src
!=
NULL
);
...
@@ -4713,7 +4613,7 @@ static SSDataBlock* doMerge(SOperatorInfo* pOperator) {
...
@@ -4713,7 +4613,7 @@ static SSDataBlock* doMerge(SOperatorInfo* pOperator) {
SSortedMergeOperatorInfo
*
pInfo
=
pOperator
->
info
;
SSortedMergeOperatorInfo
*
pInfo
=
pOperator
->
info
;
SSortHandle
*
pHandle
=
pInfo
->
pSortHandle
;
SSortHandle
*
pHandle
=
pInfo
->
pSortHandle
;
SSDataBlock
*
pDataBlock
=
createOneDataBlock
(
pInfo
->
binfo
.
pRes
);
SSDataBlock
*
pDataBlock
=
createOneDataBlock
(
pInfo
->
binfo
.
pRes
,
false
);
blockDataEnsureCapacity
(
pDataBlock
,
pInfo
->
binfo
.
capacity
);
blockDataEnsureCapacity
(
pDataBlock
,
pInfo
->
binfo
.
capacity
);
while
(
1
)
{
while
(
1
)
{
...
@@ -5546,8 +5446,6 @@ static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup
...
@@ -5546,8 +5446,6 @@ static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup
}
}
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
int32_t
order
=
pQueryAttr
->
order
.
order
;
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
SOperatorInfo
*
downstream
=
pOperator
->
pDownstream
[
0
];
while
(
1
)
{
while
(
1
)
{
...
@@ -5563,14 +5461,13 @@ static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup
...
@@ -5563,14 +5461,13 @@ static SSDataBlock* doSTableIntervalAgg(SOperatorInfo* pOperator, bool* newgroup
STableQueryInfo
*
pTableQueryInfo
=
pRuntimeEnv
->
current
;
STableQueryInfo
*
pTableQueryInfo
=
pRuntimeEnv
->
current
;
// setTagValue(pOperator, pTableQueryInfo->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput);
// setTagValue(pOperator, pTableQueryInfo->pTable, pIntervalInfo->pCtx, pOperator->numOfOutput);
setInputDataBlock
(
pOperator
,
pIntervalInfo
->
binfo
.
pCtx
,
pBlock
,
pQueryAttr
->
order
.
order
);
setInputDataBlock
(
pOperator
,
pIntervalInfo
->
binfo
.
pCtx
,
pBlock
,
TSDB_ORDER_ASC
);
setIntervalQueryRange
(
pRuntimeEnv
,
pBlock
->
info
.
window
.
skey
);
setIntervalQueryRange
(
pRuntimeEnv
,
pBlock
->
info
.
window
.
skey
);
hashIntervalAgg
(
pOperator
,
&
pTableQueryInfo
->
resInfo
,
pBlock
,
pTableQueryInfo
->
groupIndex
);
hashIntervalAgg
(
pOperator
,
&
pTableQueryInfo
->
resInfo
,
pBlock
,
pTableQueryInfo
->
groupIndex
);
}
}
pOperator
->
status
=
OP_RES_TO_RETURN
;
pOperator
->
status
=
OP_RES_TO_RETURN
;
pQueryAttr
->
order
.
order
=
order
;
// TODO : restore the order
doCloseAllTimeWindow
(
pRuntimeEnv
);
doCloseAllTimeWindow
(
pRuntimeEnv
);
setTaskStatus
(
pOperator
->
pTaskInfo
,
TASK_COMPLETED
);
setTaskStatus
(
pOperator
->
pTaskInfo
,
TASK_COMPLETED
);
...
...
source/libs/executor/src/groupoperator.c
浏览文件 @
83a824a1
...
@@ -227,7 +227,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
...
@@ -227,7 +227,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
}
}
len
=
buildGroupKeys
(
pInfo
->
keyBuf
,
pInfo
->
pGroupColVals
);
len
=
buildGroupKeys
(
pInfo
->
keyBuf
,
pInfo
->
pGroupColVals
);
int32_t
ret
=
setGroupResultOutputBuf
_rv
(
&
(
pInfo
->
binfo
),
pOperator
->
numOfOutput
,
pInfo
->
keyBuf
,
TSDB_DATA_TYPE_VARCHAR
,
len
,
0
,
pInfo
->
aggSup
.
pResultBuf
,
pTaskInfo
,
&
pInfo
->
aggSup
);
int32_t
ret
=
setGroupResultOutputBuf
(
&
(
pInfo
->
binfo
),
pOperator
->
numOfOutput
,
pInfo
->
keyBuf
,
TSDB_DATA_TYPE_VARCHAR
,
len
,
0
,
pInfo
->
aggSup
.
pResultBuf
,
pTaskInfo
,
&
pInfo
->
aggSup
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
// null data, too many state code
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
}
}
...
@@ -244,7 +244,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
...
@@ -244,7 +244,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
if
(
num
>
0
)
{
if
(
num
>
0
)
{
len
=
buildGroupKeys
(
pInfo
->
keyBuf
,
pInfo
->
pGroupColVals
);
len
=
buildGroupKeys
(
pInfo
->
keyBuf
,
pInfo
->
pGroupColVals
);
int32_t
ret
=
int32_t
ret
=
setGroupResultOutputBuf
_rv
(
&
(
pInfo
->
binfo
),
pOperator
->
numOfOutput
,
pInfo
->
keyBuf
,
TSDB_DATA_TYPE_VARCHAR
,
len
,
setGroupResultOutputBuf
(
&
(
pInfo
->
binfo
),
pOperator
->
numOfOutput
,
pInfo
->
keyBuf
,
TSDB_DATA_TYPE_VARCHAR
,
len
,
0
,
pInfo
->
aggSup
.
pResultBuf
,
pTaskInfo
,
&
pInfo
->
aggSup
);
0
,
pInfo
->
aggSup
.
pResultBuf
,
pTaskInfo
,
&
pInfo
->
aggSup
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_APP_ERROR
);
...
...
source/libs/executor/src/scanoperator.c
浏览文件 @
83a824a1
...
@@ -258,16 +258,14 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order,
...
@@ -258,16 +258,14 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order,
return
pOperator
;
return
pOperator
;
}
}
SOperatorInfo
*
createTableSeqScanOperatorInfo
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
)
{
SOperatorInfo
*
createTableSeqScanOperatorInfo
(
void
*
pTsdbReadHandle
)
{
STableScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STableScanInfo
));
STableScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STableScanInfo
));
pInfo
->
dataReader
=
pTsdbReadHandle
;
pInfo
->
dataReader
=
pTsdbReadHandle
;
pInfo
->
times
=
1
;
pInfo
->
times
=
1
;
pInfo
->
reverseTimes
=
0
;
pInfo
->
reverseTimes
=
0
;
pInfo
->
order
=
pRuntimeEnv
->
pQueryAttr
->
order
.
order
;
pInfo
->
current
=
0
;
pInfo
->
current
=
0
;
pInfo
->
prevGroupId
=
-
1
;
pInfo
->
prevGroupId
=
-
1
;
pRuntimeEnv
->
enableGroupData
=
true
;
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
SOperatorInfo
*
pOperator
=
taosMemoryCalloc
(
1
,
sizeof
(
SOperatorInfo
));
pOperator
->
name
=
"TableSeqScanOperator"
;
pOperator
->
name
=
"TableSeqScanOperator"
;
...
@@ -275,8 +273,6 @@ SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntim
...
@@ -275,8 +273,6 @@ SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntim
pOperator
->
blockingOptr
=
false
;
pOperator
->
blockingOptr
=
false
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
status
=
OP_NOT_OPENED
;
pOperator
->
info
=
pInfo
;
pOperator
->
info
=
pInfo
;
pOperator
->
numOfOutput
=
pRuntimeEnv
->
pQueryAttr
->
numOfCols
;
pOperator
->
pRuntimeEnv
=
pRuntimeEnv
;
pOperator
->
getNextFn
=
doTableScanImpl
;
pOperator
->
getNextFn
=
doTableScanImpl
;
return
pOperator
;
return
pOperator
;
...
@@ -594,7 +590,7 @@ static SSDataBlock* doFilterResult(SSysTableScanInfo* pInfo) {
...
@@ -594,7 +590,7 @@ static SSDataBlock* doFilterResult(SSysTableScanInfo* pInfo) {
bool
keep
=
filterExecute
(
filter
,
pInfo
->
pRes
,
&
rowRes
,
NULL
,
param1
.
numOfCols
);
bool
keep
=
filterExecute
(
filter
,
pInfo
->
pRes
,
&
rowRes
,
NULL
,
param1
.
numOfCols
);
filterFreeInfo
(
filter
);
filterFreeInfo
(
filter
);
SSDataBlock
*
px
=
createOneDataBlock
(
pInfo
->
pRes
);
SSDataBlock
*
px
=
createOneDataBlock
(
pInfo
->
pRes
,
false
);
blockDataEnsureCapacity
(
px
,
pInfo
->
pRes
->
info
.
rows
);
blockDataEnsureCapacity
(
px
,
pInfo
->
pRes
->
info
.
rows
);
// TODO refactor
// TODO refactor
...
@@ -683,71 +679,70 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
...
@@ -683,71 +679,70 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator, bool* newgroup) {
return
NULL
;
return
NULL
;
}
}
int64_t
startTs
=
taosGetTimestampUs
();
while
(
1
)
{
int64_t
startTs
=
taosGetTimestampUs
();
_retry:
pInfo
->
req
.
type
=
pInfo
->
type
;
pInfo
->
req
.
type
=
pInfo
->
type
;
strncpy
(
pInfo
->
req
.
tb
,
tNameGetTableName
(
&
pInfo
->
name
),
tListLen
(
pInfo
->
req
.
tb
));
strncpy
(
pInfo
->
req
.
tb
,
tNameGetTableName
(
&
pInfo
->
name
),
tListLen
(
pInfo
->
req
.
tb
));
if
(
pInfo
->
showRewrite
)
{
char
dbName
[
TSDB_DB_NAME_LEN
]
=
{
0
};
getDBNameFromCondition
(
pInfo
->
pCondition
,
dbName
);
sprintf
(
pInfo
->
req
.
db
,
"%d.%s"
,
pInfo
->
accountId
,
dbName
);
}
int32_t
contLen
=
tSerializeSRetrieveTableReq
(
NULL
,
0
,
&
pInfo
->
req
);
if
(
pInfo
->
showRewrite
)
{
char
*
buf1
=
taosMemoryCalloc
(
1
,
contLen
);
char
dbName
[
TSDB_DB_NAME_LEN
]
=
{
0
};
tSerializeSRetrieveTableReq
(
buf1
,
contLen
,
&
pInfo
->
req
);
getDBNameFromCondition
(
pInfo
->
pCondition
,
dbName
);
sprintf
(
pInfo
->
req
.
db
,
"%d.%s"
,
pInfo
->
accountId
,
dbName
);
}
// send the fetch remote task result reques
int32_t
contLen
=
tSerializeSRetrieveTableReq
(
NULL
,
0
,
&
pInfo
->
req
);
SMsgSendInfo
*
pMsgSendInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SMsgSendInfo
));
char
*
buf1
=
taosMemoryCalloc
(
1
,
contLen
);
if
(
NULL
==
pMsgSendInfo
)
{
tSerializeSRetrieveTableReq
(
buf1
,
contLen
,
&
pInfo
->
req
);
qError
(
"%s prepare message %d failed"
,
GET_TASKID
(
pTaskInfo
),
(
int32_t
)
sizeof
(
SMsgSendInfo
));
pTaskInfo
->
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
// send the fetch remote task result reques
return
NULL
;
SMsgSendInfo
*
pMsgSendInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SMsgSendInfo
));
}
if
(
NULL
==
pMsgSendInfo
)
{
qError
(
"%s prepare message %d failed"
,
GET_TASKID
(
pTaskInfo
),
(
int32_t
)
sizeof
(
SMsgSendInfo
));
pTaskInfo
->
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
NULL
;
}
pMsgSendInfo
->
param
=
pOperator
;
pMsgSendInfo
->
param
=
pOperator
;
pMsgSendInfo
->
msgInfo
.
pData
=
buf1
;
pMsgSendInfo
->
msgInfo
.
pData
=
buf1
;
pMsgSendInfo
->
msgInfo
.
len
=
contLen
;
pMsgSendInfo
->
msgInfo
.
len
=
contLen
;
pMsgSendInfo
->
msgType
=
TDMT_MND_SYSTABLE_RETRIEVE
;
pMsgSendInfo
->
msgType
=
TDMT_MND_SYSTABLE_RETRIEVE
;
pMsgSendInfo
->
fp
=
loadSysTableContentCb
;
pMsgSendInfo
->
fp
=
loadSysTableContentCb
;
int64_t
transporterId
=
0
;
int64_t
transporterId
=
0
;
int32_t
code
=
asyncSendMsgToServer
(
pInfo
->
pTransporter
,
&
pInfo
->
epSet
,
&
transporterId
,
pMsgSendInfo
);
int32_t
code
=
asyncSendMsgToServer
(
pInfo
->
pTransporter
,
&
pInfo
->
epSet
,
&
transporterId
,
pMsgSendInfo
);
tsem_wait
(
&
pInfo
->
ready
);
tsem_wait
(
&
pInfo
->
ready
);
if
(
pTaskInfo
->
code
)
{
if
(
pTaskInfo
->
code
)
{
return
NULL
;
qDebug
(
"%s load meta data from mnode failed, totalRows:%"
PRIu64
", code:%s"
,
GET_TASKID
(
pTaskInfo
),
}
pInfo
->
loadInfo
.
totalRows
,
tstrerror
(
pTaskInfo
->
code
));
return
NULL
;
}
SRetrieveMetaTableRsp
*
pRsp
=
pInfo
->
pRsp
;
SRetrieveMetaTableRsp
*
pRsp
=
pInfo
->
pRsp
;
pInfo
->
req
.
showId
=
pRsp
->
handle
;
pInfo
->
req
.
showId
=
pRsp
->
handle
;
if
(
pRsp
->
numOfRows
==
0
||
pRsp
->
completed
)
{
if
(
pRsp
->
numOfRows
==
0
||
pRsp
->
completed
)
{
pOperator
->
status
=
OP_EXEC_DONE
;
pOperator
->
status
=
OP_EXEC_DONE
;
}
qDebug
(
"%s load meta data from mnode completed, rowsOfSource:%d, totalRows:%"
PRIu64
" "
,
GET_TASKID
(
pTaskInfo
),
pRsp
->
numOfRows
,
pInfo
->
loadInfo
.
totalRows
);
if
(
pRsp
->
numOfRows
==
0
)
{
if
(
pRsp
->
numOfRows
==
0
)
{
// qDebug("%s vgId:%d, taskID:0x%"PRIx64" %d of total completed, rowsOfSource:%"PRIu64", totalRows:%"PRIu64"
return
NULL
;
// try next",
}
// GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pExchangeInfo->current + 1,
}
// pDataInfo->totalRows, pExchangeInfo->totalRows);
return
NULL
;
}
SRetrieveMetaTableRsp
*
pTableRsp
=
pInfo
->
pRsp
;
SRetrieveMetaTableRsp
*
pTableRsp
=
pInfo
->
pRsp
;
setSDataBlockFromFetchRsp
(
pInfo
->
pRes
,
&
pInfo
->
loadInfo
,
pTableRsp
->
numOfRows
,
pTableRsp
->
data
,
pTableRsp
->
compLen
,
setSDataBlockFromFetchRsp
(
pInfo
->
pRes
,
&
pInfo
->
loadInfo
,
pTableRsp
->
numOfRows
,
pTableRsp
->
data
,
pOperator
->
numOfOutput
,
startTs
,
NULL
,
pInfo
->
scanCols
);
pTableRsp
->
compLen
,
pOperator
->
numOfOutput
,
startTs
,
NULL
,
pInfo
->
scanCols
);
doFilterResult
(
pInfo
);
// todo log the filter info
if
(
pInfo
->
pRes
->
info
.
rows
==
0
)
{
doFilterResult
(
pInfo
);
goto
_retry
;
if
(
pInfo
->
pRes
->
info
.
rows
>
0
)
{
return
pInfo
->
pRes
;
}
}
}
return
pInfo
->
pRes
;
}
}
return
NULL
;
}
}
SOperatorInfo
*
createSysTableScanOperatorInfo
(
void
*
pSysTableReadHandle
,
SSDataBlock
*
pResBlock
,
const
SName
*
pName
,
SOperatorInfo
*
createSysTableScanOperatorInfo
(
void
*
pSysTableReadHandle
,
SSDataBlock
*
pResBlock
,
const
SName
*
pName
,
...
...
source/libs/executor/src/tsort.c
浏览文件 @
83a824a1
...
@@ -99,7 +99,7 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, SArray* pIndexMap, int32_t
...
@@ -99,7 +99,7 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, SArray* pIndexMap, int32_t
pSortHandle
->
numOfPages
=
numOfPages
;
pSortHandle
->
numOfPages
=
numOfPages
;
pSortHandle
->
pSortInfo
=
pSortInfo
;
pSortHandle
->
pSortInfo
=
pSortInfo
;
pSortHandle
->
pIndexMap
=
pIndexMap
;
pSortHandle
->
pIndexMap
=
pIndexMap
;
pSortHandle
->
pDataBlock
=
createOneDataBlock
(
pBlock
);
pSortHandle
->
pDataBlock
=
createOneDataBlock
(
pBlock
,
false
);
pSortHandle
->
pOrderedSource
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pSortHandle
->
pOrderedSource
=
taosArrayInit
(
4
,
POINTER_BYTES
);
pSortHandle
->
cmpParam
.
orderInfo
=
pSortInfo
;
pSortHandle
->
cmpParam
.
orderInfo
=
pSortInfo
;
...
@@ -206,7 +206,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
...
@@ -206,7 +206,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
blockDataCleanup
(
pDataBlock
);
blockDataCleanup
(
pDataBlock
);
SSDataBlock
*
pBlock
=
createOneDataBlock
(
pDataBlock
);
SSDataBlock
*
pBlock
=
createOneDataBlock
(
pDataBlock
,
false
);
return
doAddNewExternalMemSource
(
pHandle
->
pBuf
,
pHandle
->
pOrderedSource
,
pBlock
,
&
pHandle
->
sourceId
);
return
doAddNewExternalMemSource
(
pHandle
->
pBuf
,
pHandle
->
pOrderedSource
,
pBlock
,
&
pHandle
->
sourceId
);
}
}
...
@@ -488,7 +488,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
...
@@ -488,7 +488,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
tMergeTreeDestroy
(
pHandle
->
pMergeTree
);
tMergeTreeDestroy
(
pHandle
->
pMergeTree
);
pHandle
->
numOfCompletedSources
=
0
;
pHandle
->
numOfCompletedSources
=
0
;
SSDataBlock
*
pBlock
=
createOneDataBlock
(
pHandle
->
pDataBlock
);
SSDataBlock
*
pBlock
=
createOneDataBlock
(
pHandle
->
pDataBlock
,
false
);
code
=
doAddNewExternalMemSource
(
pHandle
->
pBuf
,
pResList
,
pBlock
,
&
pHandle
->
sourceId
);
code
=
doAddNewExternalMemSource
(
pHandle
->
pBuf
,
pResList
,
pBlock
,
&
pHandle
->
sourceId
);
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
return
code
;
return
code
;
...
@@ -531,7 +531,7 @@ static int32_t createInitialSortedMultiSources(SSortHandle* pHandle) {
...
@@ -531,7 +531,7 @@ static int32_t createInitialSortedMultiSources(SSortHandle* pHandle) {
}
}
if
(
pHandle
->
pDataBlock
==
NULL
)
{
if
(
pHandle
->
pDataBlock
==
NULL
)
{
pHandle
->
pDataBlock
=
createOneDataBlock
(
pBlock
);
pHandle
->
pDataBlock
=
createOneDataBlock
(
pBlock
,
false
);
}
}
int32_t
code
=
blockDataMerge
(
pHandle
->
pDataBlock
,
pBlock
,
pHandle
->
pIndexMap
);
int32_t
code
=
blockDataMerge
(
pHandle
->
pDataBlock
,
pBlock
,
pHandle
->
pIndexMap
);
...
...
source/libs/function/inc/builtins.h
浏览文件 @
83a824a1
...
@@ -40,14 +40,14 @@ extern "C" {
...
@@ -40,14 +40,14 @@ extern "C" {
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)
#define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0)
typedef
int32_t
(
*
F
CheckAndGetResultType
)(
SFunctionNode
*
pFunc
);
typedef
int32_t
(
*
F
TranslateFunc
)(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
);
typedef
EFuncDataRequired
(
*
FFuncDataRequired
)(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
);
typedef
EFuncDataRequired
(
*
FFuncDataRequired
)(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
);
typedef
struct
SBuiltinFuncDefinition
{
typedef
struct
SBuiltinFuncDefinition
{
char
name
[
FUNCTION_NAME_MAX_LENGTH
];
char
name
[
FUNCTION_NAME_MAX_LENGTH
];
EFunctionType
type
;
EFunctionType
type
;
uint64_t
classification
;
uint64_t
classification
;
F
CheckAndGetResultType
check
Func
;
F
TranslateFunc
translate
Func
;
FFuncDataRequired
dataRequiredFunc
;
FFuncDataRequired
dataRequiredFunc
;
FExecGetEnv
getEnvFunc
;
FExecGetEnv
getEnvFunc
;
FExecInit
initFunc
;
FExecInit
initFunc
;
...
...
source/libs/function/src/builtins.c
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
source/libs/function/src/functionMgt.c
浏览文件 @
83a824a1
...
@@ -69,11 +69,11 @@ int32_t fmGetFuncInfo(const char* pFuncName, int32_t* pFuncId, int32_t* pFuncTyp
...
@@ -69,11 +69,11 @@ int32_t fmGetFuncInfo(const char* pFuncName, int32_t* pFuncId, int32_t* pFuncTyp
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
fmGetFuncResultType
(
SFunctionNode
*
pFunc
)
{
int32_t
fmGetFuncResultType
(
SFunctionNode
*
pFunc
,
char
*
pErrBuf
,
int32_t
len
)
{
if
(
pFunc
->
funcId
<
0
||
pFunc
->
funcId
>=
funcMgtBuiltinsNum
)
{
if
(
pFunc
->
funcId
<
0
||
pFunc
->
funcId
>=
funcMgtBuiltinsNum
)
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
return
funcMgtBuiltins
[
pFunc
->
funcId
].
checkFunc
(
pFunc
);
return
funcMgtBuiltins
[
pFunc
->
funcId
].
translateFunc
(
pFunc
,
pErrBuf
,
len
);
}
}
EFuncDataRequired
fmFuncDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
)
{
EFuncDataRequired
fmFuncDataRequired
(
SFunctionNode
*
pFunc
,
STimeWindow
*
pTimeWindow
)
{
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
83a824a1
...
@@ -81,7 +81,6 @@ SToken getTokenFromRawExprNode(SAstCreateContext* pCxt, SNode* pNode);
...
@@ -81,7 +81,6 @@ SToken getTokenFromRawExprNode(SAstCreateContext* pCxt, SNode* pNode);
SNodeList
*
createNodeList
(
SAstCreateContext
*
pCxt
,
SNode
*
pNode
);
SNodeList
*
createNodeList
(
SAstCreateContext
*
pCxt
,
SNode
*
pNode
);
SNodeList
*
addNodeToList
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pList
,
SNode
*
pNode
);
SNodeList
*
addNodeToList
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pList
,
SNode
*
pNode
);
SNodeList
*
addValueNodeFromTypeToList
(
SAstCreateContext
*
pCxt
,
SDataType
dataType
,
SNodeList
*
pList
);
SNode
*
createColumnNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pTableAlias
,
SToken
*
pColumnName
);
SNode
*
createColumnNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pTableAlias
,
SToken
*
pColumnName
);
SNode
*
createValueNode
(
SAstCreateContext
*
pCxt
,
int32_t
dataType
,
const
SToken
*
pLiteral
);
SNode
*
createValueNode
(
SAstCreateContext
*
pCxt
,
int32_t
dataType
,
const
SToken
*
pLiteral
);
...
@@ -93,6 +92,7 @@ SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pL
...
@@ -93,6 +92,7 @@ SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pL
SNode
*
createBetweenAnd
(
SAstCreateContext
*
pCxt
,
SNode
*
pExpr
,
SNode
*
pLeft
,
SNode
*
pRight
);
SNode
*
createBetweenAnd
(
SAstCreateContext
*
pCxt
,
SNode
*
pExpr
,
SNode
*
pLeft
,
SNode
*
pRight
);
SNode
*
createNotBetweenAnd
(
SAstCreateContext
*
pCxt
,
SNode
*
pExpr
,
SNode
*
pLeft
,
SNode
*
pRight
);
SNode
*
createNotBetweenAnd
(
SAstCreateContext
*
pCxt
,
SNode
*
pExpr
,
SNode
*
pLeft
,
SNode
*
pRight
);
SNode
*
createFunctionNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFuncName
,
SNodeList
*
pParameterList
);
SNode
*
createFunctionNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFuncName
,
SNodeList
*
pParameterList
);
SNode
*
createCastFunctionNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pExpr
,
SDataType
dt
);
SNode
*
createNodeListNode
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pList
);
SNode
*
createNodeListNode
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pList
);
SNode
*
createNodeListNodeEx
(
SAstCreateContext
*
pCxt
,
SNode
*
p1
,
SNode
*
p2
);
SNode
*
createNodeListNodeEx
(
SAstCreateContext
*
pCxt
,
SNode
*
p1
,
SNode
*
p2
);
SNode
*
createRealTableNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SToken
*
pTableName
,
SToken
*
pTableAlias
);
SNode
*
createRealTableNode
(
SAstCreateContext
*
pCxt
,
SToken
*
pDbName
,
SToken
*
pTableName
,
SToken
*
pTableAlias
);
...
...
source/libs/parser/inc/sql.y
浏览文件 @
83a824a1
...
@@ -535,13 +535,7 @@ expression(A) ::= pseudo_column(B).
...
@@ -535,13 +535,7 @@ expression(A) ::= pseudo_column(B).
expression(A) ::= column_reference(B). { A = B; }
expression(A) ::= column_reference(B). { A = B; }
expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
expression(A) ::= function_name(B) NK_LP expression_list(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, C)); }
expression(A) ::= function_name(B) NK_LP NK_STAR(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, createNodeList(pCxt, createColumnNode(pCxt, NULL, &C)))); }
expression(A) ::= function_name(B) NK_LP NK_STAR(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, createFunctionNode(pCxt, &B, createNodeList(pCxt, createColumnNode(pCxt, NULL, &C)))); }
//for CAST function CAST(expr AS type_name)
expression(A) ::= CAST(B) NK_LP expression(C) AS type_name(D) NK_RP(E). { A = createRawExprNodeExt(pCxt, &B, &E, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, C), D)); }
expression(A) ::= function_name(B) NK_LP expression(C) AS type_name(D) NK_RP(E). {
SNodeList *p = createNodeList(pCxt, releaseRawExprNode(pCxt, C));
p = addValueNodeFromTypeToList(pCxt, D, p);
A = createRawExprNodeExt(pCxt, &B, &E, createFunctionNode(pCxt, &B, p));
}
//expression(A) ::= cast_expression(B). { A = B; }
//expression(A) ::= case_expression(B). { A = B; }
//expression(A) ::= case_expression(B). { A = B; }
expression(A) ::= subquery(B). { A = B; }
expression(A) ::= subquery(B). { A = B; }
expression(A) ::= NK_LP(B) expression(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, releaseRawExprNode(pCxt, C)); }
expression(A) ::= NK_LP(B) expression(C) NK_RP(D). { A = createRawExprNodeExt(pCxt, &B, &D, releaseRawExprNode(pCxt, C)); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
83a824a1
...
@@ -208,7 +208,9 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) {
...
@@ -208,7 +208,9 @@ SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) {
SRawExprNode
*
pRawExpr
=
(
SRawExprNode
*
)
pNode
;
SRawExprNode
*
pRawExpr
=
(
SRawExprNode
*
)
pNode
;
SNode
*
pExpr
=
pRawExpr
->
pNode
;
SNode
*
pExpr
=
pRawExpr
->
pNode
;
if
(
nodesIsExprNode
(
pExpr
))
{
if
(
nodesIsExprNode
(
pExpr
))
{
strncpy
(((
SExprNode
*
)
pExpr
)
->
aliasName
,
pRawExpr
->
p
,
pRawExpr
->
n
);
int32_t
len
=
TMIN
(
sizeof
(((
SExprNode
*
)
pExpr
)
->
aliasName
)
-
1
,
pRawExpr
->
n
);
strncpy
(((
SExprNode
*
)
pExpr
)
->
aliasName
,
pRawExpr
->
p
,
len
);
((
SExprNode
*
)
pExpr
)
->
aliasName
[
len
]
=
'\0'
;
}
}
taosMemoryFreeClear
(
pNode
);
taosMemoryFreeClear
(
pNode
);
return
pExpr
;
return
pExpr
;
...
@@ -253,33 +255,6 @@ SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pC
...
@@ -253,33 +255,6 @@ SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pC
return
(
SNode
*
)
col
;
return
(
SNode
*
)
col
;
}
}
SNodeList
*
addValueNodeFromTypeToList
(
SAstCreateContext
*
pCxt
,
SDataType
dataType
,
SNodeList
*
pList
)
{
char
buf
[
64
]
=
{
0
};
//add value node for type
snprintf
(
buf
,
sizeof
(
buf
),
"%u"
,
dataType
.
type
);
SToken
token
=
{.
type
=
TSDB_DATA_TYPE_SMALLINT
,
.
n
=
strlen
(
buf
),
.
z
=
buf
};
SNode
*
pNode
=
createValueNode
(
pCxt
,
token
.
type
,
&
token
);
addNodeToList
(
pCxt
,
pList
,
pNode
);
//add value node for bytes
memset
(
buf
,
0
,
sizeof
(
buf
));
int32_t
bytes
;
if
(
IS_VAR_DATA_TYPE
(
dataType
.
type
))
{
bytes
=
(
dataType
.
type
==
TSDB_DATA_TYPE_NCHAR
)
?
dataType
.
bytes
*
TSDB_NCHAR_SIZE
:
dataType
.
bytes
;
bytes
+=
VARSTR_HEADER_SIZE
;
}
else
{
bytes
=
dataType
.
bytes
;
}
snprintf
(
buf
,
sizeof
(
buf
),
"%d"
,
bytes
);
token
.
type
=
TSDB_DATA_TYPE_BIGINT
;
token
.
n
=
strlen
(
buf
);
token
.
z
=
buf
;
pNode
=
createValueNode
(
pCxt
,
token
.
type
,
&
token
);
addNodeToList
(
pCxt
,
pList
,
pNode
);
return
pList
;
}
SNode
*
createValueNode
(
SAstCreateContext
*
pCxt
,
int32_t
dataType
,
const
SToken
*
pLiteral
)
{
SNode
*
createValueNode
(
SAstCreateContext
*
pCxt
,
int32_t
dataType
,
const
SToken
*
pLiteral
)
{
SValueNode
*
val
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
SValueNode
*
val
=
(
SValueNode
*
)
nodesMakeNode
(
QUERY_NODE_VALUE
);
CHECK_OUT_OF_MEM
(
val
);
CHECK_OUT_OF_MEM
(
val
);
...
@@ -385,6 +360,15 @@ SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNod
...
@@ -385,6 +360,15 @@ SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNod
return
(
SNode
*
)
func
;
return
(
SNode
*
)
func
;
}
}
SNode
*
createCastFunctionNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pExpr
,
SDataType
dt
)
{
SFunctionNode
*
func
=
(
SFunctionNode
*
)
nodesMakeNode
(
QUERY_NODE_FUNCTION
);
CHECK_OUT_OF_MEM
(
func
);
strcpy
(
func
->
functionName
,
"cast"
);
func
->
node
.
resType
=
dt
;
nodesListMakeAppend
(
&
func
->
pParameterList
,
pExpr
);
return
(
SNode
*
)
func
;
}
SNode
*
createNodeListNode
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pList
)
{
SNode
*
createNodeListNode
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pList
)
{
SNodeListNode
*
list
=
(
SNodeListNode
*
)
nodesMakeNode
(
QUERY_NODE_NODE_LIST
);
SNodeListNode
*
list
=
(
SNodeListNode
*
)
nodesMakeNode
(
QUERY_NODE_NODE_LIST
);
CHECK_OUT_OF_MEM
(
list
);
CHECK_OUT_OF_MEM
(
list
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
source/libs/parser/src/parUtil.c
浏览文件 @
83a824a1
...
@@ -31,10 +31,6 @@ static char* getSyntaxErrFormat(int32_t errCode) {
...
@@ -31,10 +31,6 @@ static char* getSyntaxErrFormat(int32_t errCode) {
return
"Invalid value type : %s"
;
return
"Invalid value type : %s"
;
case
TSDB_CODE_PAR_INVALID_FUNTION
:
case
TSDB_CODE_PAR_INVALID_FUNTION
:
return
"Invalid function name : %s"
;
return
"Invalid function name : %s"
;
case
TSDB_CODE_PAR_FUNTION_PARA_NUM
:
return
"Invalid number of arguments : %s"
;
case
TSDB_CODE_PAR_FUNTION_PARA_TYPE
:
return
"Inconsistent datatypes : %s"
;
case
TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
:
case
TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION
:
return
"There mustn't be aggregation"
;
return
"There mustn't be aggregation"
;
case
TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT
:
case
TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT
:
...
...
source/libs/parser/src/sql.c
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
83a824a1
...
@@ -498,19 +498,16 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
...
@@ -498,19 +498,16 @@ static int32_t createJoinPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
SDataBlockDescNode
*
pLeftDesc
=
((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
0
))
->
pOutputDataBlockDesc
;
SDataBlockDescNode
*
pRightDesc
=
((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
1
))
->
pOutputDataBlockDesc
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
pJoin
->
joinType
=
pJoinLogicNode
->
joinType
;
pJoin
->
joinType
=
pJoinLogicNode
->
joinType
;
if
(
NULL
!=
pJoinLogicNode
->
pOnConditions
)
{
if
(
NULL
!=
pJoinLogicNode
->
pOnConditions
)
{
SDataBlockDescNode
*
pLeftDesc
=
((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
0
))
->
pOutputDataBlockDesc
;
SDataBlockDescNode
*
pRightDesc
=
((
SPhysiNode
*
)
nodesListGetNode
(
pChildren
,
1
))
->
pOutputDataBlockDesc
;
code
=
setNodeSlotId
(
pCxt
,
pLeftDesc
->
dataBlockId
,
pRightDesc
->
dataBlockId
,
pJoinLogicNode
->
pOnConditions
,
&
pJoin
->
pOnConditions
);
code
=
setNodeSlotId
(
pCxt
,
pLeftDesc
->
dataBlockId
,
pRightDesc
->
dataBlockId
,
pJoinLogicNode
->
pOnConditions
,
&
pJoin
->
pOnConditions
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pJoin
->
pTargets
=
nodesCloneList
(
pJoinLogicNode
->
node
.
pTargets
);
code
=
setListSlotId
(
pCxt
,
pLeftDesc
->
dataBlockId
,
pRightDesc
->
dataBlockId
,
pJoinLogicNode
->
node
.
pTargets
,
&
pJoin
->
pTargets
);
if
(
NULL
==
pJoin
->
pTargets
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
addDataBlockSlots
(
pCxt
,
pJoin
->
pTargets
,
pJoin
->
node
.
pOutputDataBlockDesc
);
code
=
addDataBlockSlots
(
pCxt
,
pJoin
->
pTargets
,
pJoin
->
node
.
pOutputDataBlockDesc
);
...
...
source/libs/planner/test/plannerTest.cpp
浏览文件 @
83a824a1
...
@@ -180,11 +180,11 @@ TEST_F(PlannerTest, selectStableBasic) {
...
@@ -180,11 +180,11 @@ TEST_F(PlannerTest, selectStableBasic) {
TEST_F
(
PlannerTest
,
selectJoin
)
{
TEST_F
(
PlannerTest
,
selectJoin
)
{
setDatabase
(
"root"
,
"test"
);
setDatabase
(
"root"
,
"test"
);
//
bind("SELECT t1.c1, t2.c2 FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts");
bind
(
"SELECT t1.c1, t2.c2 FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts"
);
//
ASSERT_TRUE(run());
ASSERT_TRUE
(
run
());
//
bind("SELECT t1.*, t2.* FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts");
bind
(
"SELECT t1.*, t2.* FROM st1s1 t1, st1s2 t2 where t1.ts = t2.ts"
);
//
ASSERT_TRUE(run());
ASSERT_TRUE
(
run
());
bind
(
"SELECT t1.c1, t2.c1 FROM st1s1 t1 join st1s2 t2 on t1.ts = t2.ts where t1.c1 > t2.c1 and t1.c2 = 'abc' and t2.c2 = 'qwe'"
);
bind
(
"SELECT t1.c1, t2.c1 FROM st1s1 t1 join st1s2 t2 on t1.ts = t2.ts where t1.c1 > t2.c1 and t1.c2 = 'abc' and t2.c2 = 'qwe'"
);
ASSERT_TRUE
(
run
());
ASSERT_TRUE
(
run
());
...
...
source/libs/scalar/src/sclfunc.c
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
source/libs/scheduler/src/scheduler.c
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/pytest/concurrent_inquiry.sh
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/pytest/crash_gen.sh
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/pytest/perf_gen.sh
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/pytest/test.sh
浏览文件 @
83a824a1
...
@@ -11,7 +11,7 @@ if [[ "$CURR_DIR" == *"$IN_TDINTERNAL"* ]]; then
...
@@ -11,7 +11,7 @@ if [[ "$CURR_DIR" == *"$IN_TDINTERNAL"* ]]; then
else
else
TAOS_DIR
=
$CURR_DIR
/../..
TAOS_DIR
=
$CURR_DIR
/../..
fi
fi
TAOSD_DIR
=
`
find
$TAOS_DIR
-name
"taosd"
|grep
bin
|head
-n1
`
TAOSD_DIR
=
`
find
$TAOS_DIR
-name
"taosd"
|grep
debug
|head
-n1
`
LIB_DIR
=
`
echo
$TAOSD_DIR
|rev|cut
-d
'/'
-f
3,4,5,6|rev
`
/lib
LIB_DIR
=
`
echo
$TAOSD_DIR
|rev|cut
-d
'/'
-f
3,4,5,6|rev
`
/lib
export
PYTHONPATH
=
$(
pwd
)
/../../src/connector/python
export
PYTHONPATH
=
$(
pwd
)
/../../src/connector/python
export
LD_LIBRARY_PATH
=
$LD_LIBRARY_PATH
:
$LIB_DIR
export
LD_LIBRARY_PATH
=
$LD_LIBRARY_PATH
:
$LIB_DIR
...
...
tests/script/jenkins/basic.txt
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/script/sh/cfg.sh
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/script/sh/clear.sh
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/script/sh/deploy.sh
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/script/sh/exec-default.sh
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/script/sh/exec-no-random-fail.sh
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/script/sh/exec-random-fail.sh
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/script/sh/exec.sh
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/script/sh/exec_tarbitrator.sh
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/script/sh/move_dnode.sh
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/script/sh/mv_old_data.sh
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/script/test.sh
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/script/tsim/query/charScalarFunction.sim
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tests/test/c/tmqDemo.c
浏览文件 @
83a824a1
此差异已折叠。
点击以展开。
tools/taosTools-1.4.1-Linux-x64.tar.gz
已删除
100644 → 0
浏览文件 @
2635df08
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录