Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
db970c79
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1193
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
db970c79
编写于
3月 15, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/shm
上级
882575fd
7f9521b3
变更
125
展开全部
隐藏空白更改
内联
并排
Showing
125 changed file
with
6679 addition
and
4460 deletion
+6679
-4460
contrib/CMakeLists.txt
contrib/CMakeLists.txt
+5
-0
include/common/taosdef.h
include/common/taosdef.h
+13
-2
include/common/tcommon.h
include/common/tcommon.h
+28
-28
include/common/tdatablock.h
include/common/tdatablock.h
+1
-1
include/common/tmsg.h
include/common/tmsg.h
+24
-8
include/common/ttime.h
include/common/ttime.h
+11
-0
include/common/ttokendef.h
include/common/ttokendef.h
+107
-102
include/dnode/snode/snode.h
include/dnode/snode/snode.h
+4
-0
include/libs/function/function.h
include/libs/function/function.h
+0
-11
include/libs/nodes/cmdnodes.h
include/libs/nodes/cmdnodes.h
+31
-2
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+11
-0
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+31
-1
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-0
include/libs/parser/parser.h
include/libs/parser/parser.h
+1
-0
include/libs/planner/planner.h
include/libs/planner/planner.h
+1
-0
include/libs/transport/trpc.h
include/libs/transport/trpc.h
+7
-0
include/os/osLocale.h
include/os/osLocale.h
+5
-1
include/util/taoserror.h
include/util/taoserror.h
+1
-0
include/util/tdef.h
include/util/tdef.h
+13
-10
include/util/tjson.h
include/util/tjson.h
+1
-0
include/util/tuuid.h
include/util/tuuid.h
+39
-0
source/client/inc/clientInt.h
source/client/inc/clientInt.h
+2
-0
source/client/src/clientImpl.c
source/client/src/clientImpl.c
+1
-8
source/client/src/tmq.c
source/client/src/tmq.c
+7
-9
source/common/src/tdatablock.c
source/common/src/tdatablock.c
+4
-2
source/common/src/tmsg.c
source/common/src/tmsg.c
+0
-1
source/dnode/mgmt/container/src/dndWorker.c
source/dnode/mgmt/container/src/dndWorker.c
+1
-1
source/dnode/mgmt/snode/inc/smInt.h
source/dnode/mgmt/snode/inc/smInt.h
+3
-3
source/dnode/mgmt/snode/src/smMgmt.c
source/dnode/mgmt/snode/src/smMgmt.c
+115
-10
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+11
-3
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+8
-8
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+77
-2
source/dnode/mnode/impl/src/mnode.c
source/dnode/mnode/impl/src/mnode.c
+2
-0
source/dnode/mnode/impl/test/db/db.cpp
source/dnode/mnode/impl/test/db/db.cpp
+6
-6
source/dnode/snode/inc/sndInt.h
source/dnode/snode/inc/sndInt.h
+21
-20
source/dnode/snode/src/snode.c
source/dnode/snode/src/snode.c
+23
-0
source/dnode/vnode/inc/tsdb.h
source/dnode/vnode/inc/tsdb.h
+7
-0
source/dnode/vnode/src/inc/tsdbDBDef.h
source/dnode/vnode/src/inc/tsdbDBDef.h
+44
-0
source/dnode/vnode/src/inc/tsdbDef.h
source/dnode/vnode/src/inc/tsdbDef.h
+13
-4
source/dnode/vnode/src/inc/tsdbFile.h
source/dnode/vnode/src/inc/tsdbFile.h
+7
-5
source/dnode/vnode/src/inc/tsdbSma.h
source/dnode/vnode/src/inc/tsdbSma.h
+41
-12
source/dnode/vnode/src/meta/metaBDBImpl.c
source/dnode/vnode/src/meta/metaBDBImpl.c
+17
-16
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+2
-2
source/dnode/vnode/src/tsdb/tsdbBDBImpl.c
source/dnode/vnode/src/tsdb/tsdbBDBImpl.c
+159
-0
source/dnode/vnode/src/tsdb/tsdbMain.c
source/dnode/vnode/src/tsdb/tsdbMain.c
+28
-1
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+415
-121
source/dnode/vnode/src/tsdb/tsdbWrite.c
source/dnode/vnode/src/tsdb/tsdbWrite.c
+12
-1
source/dnode/vnode/test/tsdbSmaTest.cpp
source/dnode/vnode/test/tsdbSmaTest.cpp
+110
-13
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+10
-10
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+123
-148
source/libs/executor/src/dataDispatcher.c
source/libs/executor/src/dataDispatcher.c
+2
-1
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+3
-144
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+558
-436
source/libs/executor/src/tsort.c
source/libs/executor/src/tsort.c
+8
-5
source/libs/executor/test/executorTests.cpp
source/libs/executor/test/executorTests.cpp
+4
-6
source/libs/function/inc/taggfunction.h
source/libs/function/inc/taggfunction.h
+0
-12
source/libs/function/src/builtinsimpl.c
source/libs/function/src/builtinsimpl.c
+1
-5
source/libs/function/src/tfunction.c
source/libs/function/src/tfunction.c
+0
-415
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+21
-0
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+134
-2
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+29
-0
source/libs/parser/inc/parAst.h
source/libs/parser/inc/parAst.h
+10
-7
source/libs/parser/inc/sql.y
source/libs/parser/inc/sql.y
+30
-8
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+55
-19
source/libs/parser/src/parTokenizer.c
source/libs/parser/src/parTokenizer.c
+4
-1
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+135
-41
source/libs/parser/src/sql.c
source/libs/parser/src/sql.c
+1612
-1539
source/libs/parser/test/parserAstTest.cpp
source/libs/parser/test/parserAstTest.cpp
+21
-0
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+50
-0
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+52
-2
source/libs/planner/test/plannerTest.cpp
source/libs/planner/test/plannerTest.cpp
+7
-0
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+331
-342
source/libs/sync/inc/syncElection.h
source/libs/sync/inc/syncElection.h
+0
-1
source/libs/sync/inc/syncEnv.h
source/libs/sync/inc/syncEnv.h
+16
-4
source/libs/sync/inc/syncIO.h
source/libs/sync/inc/syncIO.h
+17
-8
source/libs/sync/inc/syncInt.h
source/libs/sync/inc/syncInt.h
+36
-12
source/libs/sync/inc/syncMessage.h
source/libs/sync/inc/syncMessage.h
+4
-1
source/libs/sync/inc/syncRaftLog.h
source/libs/sync/inc/syncRaftLog.h
+3
-0
source/libs/sync/inc/syncRaftStore.h
source/libs/sync/inc/syncRaftStore.h
+6
-0
source/libs/sync/inc/syncReplication.h
source/libs/sync/inc/syncReplication.h
+0
-1
source/libs/sync/inc/syncUtil.h
source/libs/sync/inc/syncUtil.h
+3
-0
source/libs/sync/src/syncAppendEntries.c
source/libs/sync/src/syncAppendEntries.c
+123
-1
source/libs/sync/src/syncAppendEntriesReply.c
source/libs/sync/src/syncAppendEntriesReply.c
+44
-1
source/libs/sync/src/syncElection.c
source/libs/sync/src/syncElection.c
+14
-1
source/libs/sync/src/syncEnv.c
source/libs/sync/src/syncEnv.c
+55
-25
source/libs/sync/src/syncIO.c
source/libs/sync/src/syncIO.c
+191
-147
source/libs/sync/src/syncMain.c
source/libs/sync/src/syncMain.c
+316
-258
source/libs/sync/src/syncMessage.c
source/libs/sync/src/syncMessage.c
+32
-5
source/libs/sync/src/syncRaftLog.c
source/libs/sync/src/syncRaftLog.c
+1
-1
source/libs/sync/src/syncRaftStore.c
source/libs/sync/src/syncRaftStore.c
+29
-0
source/libs/sync/src/syncReplication.c
source/libs/sync/src/syncReplication.c
+36
-0
source/libs/sync/src/syncRequestVote.c
source/libs/sync/src/syncRequestVote.c
+35
-1
source/libs/sync/src/syncRequestVoteReply.c
source/libs/sync/src/syncRequestVoteReply.c
+34
-1
source/libs/sync/src/syncTimeout.c
source/libs/sync/src/syncTimeout.c
+1
-9
source/libs/sync/src/syncUtil.c
source/libs/sync/src/syncUtil.c
+12
-0
source/libs/sync/test/CMakeLists.txt
source/libs/sync/test/CMakeLists.txt
+10
-10
source/libs/sync/test/syncEnqTest.cpp
source/libs/sync/test/syncEnqTest.cpp
+45
-38
source/libs/sync/test/syncEnvTest.cpp
source/libs/sync/test/syncEnvTest.cpp
+12
-14
source/libs/sync/test/syncIOClientTest.cpp
source/libs/sync/test/syncIOClientTest.cpp
+12
-12
source/libs/sync/test/syncIOSendMsgTest.cpp
source/libs/sync/test/syncIOSendMsgTest.cpp
+81
-20
source/libs/sync/test/syncIOServerTest.cpp
source/libs/sync/test/syncIOServerTest.cpp
+0
-0
source/libs/sync/test/syncIOTickPingTest.cpp
source/libs/sync/test/syncIOTickPingTest.cpp
+9
-2
source/libs/sync/test/syncIOTickQTest.cpp
source/libs/sync/test/syncIOTickQTest.cpp
+11
-4
source/libs/sync/test/syncLogStoreTest.cpp
source/libs/sync/test/syncLogStoreTest.cpp
+10
-1
source/libs/sync/test/syncRequestVoteTest.cpp
source/libs/sync/test/syncRequestVoteTest.cpp
+1
-1
source/libs/sync/test/syncRpcMsgTest.cpp
source/libs/sync/test/syncRpcMsgTest.cpp
+8
-8
source/libs/sync/test/syncUtilTest.cpp
source/libs/sync/test/syncUtilTest.cpp
+1
-0
source/libs/transport/CMakeLists.txt
source/libs/transport/CMakeLists.txt
+1
-1
source/libs/transport/inc/transComm.h
source/libs/transport/inc/transComm.h
+17
-2
source/libs/transport/inc/transportInt.h
source/libs/transport/inc/transportInt.h
+1
-0
source/libs/transport/src/trans.c
source/libs/transport/src/trans.c
+26
-12
source/libs/transport/src/transCli.c
source/libs/transport/src/transCli.c
+116
-99
source/libs/transport/src/transComm.c
source/libs/transport/src/transComm.c
+1
-97
source/libs/transport/src/transSrv.c
source/libs/transport/src/transSrv.c
+36
-40
source/libs/transport/test/transUT.cc
source/libs/transport/test/transUT.cc
+111
-50
source/os/src/osLocale.c
source/os/src/osLocale.c
+1
-0
source/util/src/terror.c
source/util/src/terror.c
+1
-0
source/util/src/tjson.c
source/util/src/tjson.c
+8
-0
source/util/src/tuuid.c
source/util/src/tuuid.c
+57
-0
source/util/src/tworker.c
source/util/src/tworker.c
+1
-1
tests/script/jenkins/basic.txt
tests/script/jenkins/basic.txt
+2
-0
tests/script/sh/massiveTable/compileVersion.sh
tests/script/sh/massiveTable/compileVersion.sh
+0
-4
tests/script/tsim/db/basic6.sim
tests/script/tsim/db/basic6.sim
+19
-6
tests/script/tsim/insert/basic0.sim
tests/script/tsim/insert/basic0.sim
+334
-0
tests/script/tsim/table/basic1.sim
tests/script/tsim/table/basic1.sim
+68
-4
未找到文件。
contrib/CMakeLists.txt
浏览文件 @
db970c79
...
@@ -127,6 +127,11 @@ target_include_directories(
...
@@ -127,6 +127,11 @@ target_include_directories(
# zlib
# zlib
set
(
CMAKE_PROJECT_INCLUDE_BEFORE
"
${
CMAKE_SUPPORT_DIR
}
/EnableCMP0048.txt.in"
)
set
(
CMAKE_PROJECT_INCLUDE_BEFORE
"
${
CMAKE_SUPPORT_DIR
}
/EnableCMP0048.txt.in"
)
add_subdirectory
(
zlib
)
add_subdirectory
(
zlib
)
target_include_directories
(
zlibstatic
PUBLIC
${
CMAKE_CURRENT_BINARY_DIR
}
/zlib
PUBLIC
${
CMAKE_CURRENT_SOURCE_DIR
}
/zlib
)
target_include_directories
(
target_include_directories
(
zlib
zlib
PUBLIC
${
CMAKE_CURRENT_BINARY_DIR
}
/zlib
PUBLIC
${
CMAKE_CURRENT_BINARY_DIR
}
/zlib
...
...
include/common/taosdef.h
浏览文件 @
db970c79
...
@@ -33,7 +33,7 @@ typedef enum {
...
@@ -33,7 +33,7 @@ typedef enum {
TSDB_SUPER_TABLE
=
1
,
// super table
TSDB_SUPER_TABLE
=
1
,
// super table
TSDB_CHILD_TABLE
=
2
,
// table created from super table
TSDB_CHILD_TABLE
=
2
,
// table created from super table
TSDB_NORMAL_TABLE
=
3
,
// ordinary table
TSDB_NORMAL_TABLE
=
3
,
// ordinary table
TSDB_STREAM_TABLE
=
4
,
// table created
from stream comput
ing
TSDB_STREAM_TABLE
=
4
,
// table created
by stream process
ing
TSDB_TEMP_TABLE
=
5
,
// temp table created by nest query
TSDB_TEMP_TABLE
=
5
,
// temp table created by nest query
TSDB_TABLE_MAX
=
6
TSDB_TABLE_MAX
=
6
}
ETableType
;
}
ETableType
;
...
@@ -50,7 +50,12 @@ typedef enum {
...
@@ -50,7 +50,12 @@ typedef enum {
TSDB_CHECK_ITEM_MAX
TSDB_CHECK_ITEM_MAX
}
ECheckItemType
;
}
ECheckItemType
;
typedef
enum
{
TD_ROW_DISCARD_UPDATE
=
0
,
TD_ROW_OVERWRITE_UPDATE
=
1
,
TD_ROW_PARTIAL_UPDATE
=
2
}
TDUpdateConfig
;
typedef
enum
{
TD_ROW_DISCARD_UPDATE
=
0
,
TD_ROW_OVERWRITE_UPDATE
=
1
,
TD_ROW_PARTIAL_UPDATE
=
2
,
}
TDUpdateConfig
;
typedef
enum
{
typedef
enum
{
TSDB_STATIS_OK
=
0
,
// statis part exist and load successfully
TSDB_STATIS_OK
=
0
,
// statis part exist and load successfully
TSDB_STATIS_NONE
=
1
,
// statis part not exist
TSDB_STATIS_NONE
=
1
,
// statis part not exist
...
@@ -61,6 +66,12 @@ typedef enum {
...
@@ -61,6 +66,12 @@ typedef enum {
TSDB_SMA_STAT_EXPIRED
=
1
,
// not ready or expired
TSDB_SMA_STAT_EXPIRED
=
1
,
// not ready or expired
}
ETsdbSmaStat
;
}
ETsdbSmaStat
;
typedef
enum
{
TSDB_SMA_TYPE_BLOCK
=
0
,
// Block-wise SMA
TSDB_SMA_TYPE_TIME_RANGE
=
1
,
// Time-range-wise SMA
TSDB_SMA_TYPE_ROLLUP
=
2
,
// Rollup SMA
}
ETsdbSmaType
;
extern
char
*
qtypeStr
[];
extern
char
*
qtypeStr
[];
#define TSDB_PORT_HTTP 11
#define TSDB_PORT_HTTP 11
...
...
include/common/tcommon.h
浏览文件 @
db970c79
...
@@ -54,10 +54,11 @@ typedef struct SColumnDataAgg {
...
@@ -54,10 +54,11 @@ typedef struct SColumnDataAgg {
}
SColumnDataAgg
;
}
SColumnDataAgg
;
typedef
struct
SDataBlockInfo
{
typedef
struct
SDataBlockInfo
{
STimeWindow
window
;
STimeWindow
window
;
int32_t
rows
;
int32_t
rows
;
int32_t
rowSize
;
int32_t
rowSize
;
int32_t
numOfCols
;
int16_t
numOfCols
;
int16_t
hasVarCol
;
union
{
int64_t
uid
;
int64_t
blockId
;};
union
{
int64_t
uid
;
int64_t
blockId
;};
}
SDataBlockInfo
;
}
SDataBlockInfo
;
...
@@ -96,13 +97,15 @@ typedef struct SColumnInfoData {
...
@@ -96,13 +97,15 @@ typedef struct SColumnInfoData {
static
FORCE_INLINE
int32_t
tEncodeDataBlock
(
void
**
buf
,
const
SSDataBlock
*
pBlock
)
{
static
FORCE_INLINE
int32_t
tEncodeDataBlock
(
void
**
buf
,
const
SSDataBlock
*
pBlock
)
{
int64_t
tbUid
=
pBlock
->
info
.
uid
;
int64_t
tbUid
=
pBlock
->
info
.
uid
;
int32_t
numOfCols
=
pBlock
->
info
.
numOfCols
;
int16_t
numOfCols
=
pBlock
->
info
.
numOfCols
;
int16_t
hasVarCol
=
pBlock
->
info
.
hasVarCol
;
int32_t
rows
=
pBlock
->
info
.
rows
;
int32_t
rows
=
pBlock
->
info
.
rows
;
int32_t
sz
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
int32_t
sz
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI64
(
buf
,
tbUid
);
tlen
+=
taosEncodeFixedI64
(
buf
,
tbUid
);
tlen
+=
taosEncodeFixedI32
(
buf
,
numOfCols
);
tlen
+=
taosEncodeFixedI16
(
buf
,
numOfCols
);
tlen
+=
taosEncodeFixedI16
(
buf
,
hasVarCol
);
tlen
+=
taosEncodeFixedI32
(
buf
,
rows
);
tlen
+=
taosEncodeFixedI32
(
buf
,
rows
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
tlen
+=
taosEncodeFixedI32
(
buf
,
sz
);
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
...
@@ -120,7 +123,8 @@ static FORCE_INLINE void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock)
...
@@ -120,7 +123,8 @@ static FORCE_INLINE void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock)
int32_t
sz
;
int32_t
sz
;
buf
=
taosDecodeFixedI64
(
buf
,
&
pBlock
->
info
.
uid
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pBlock
->
info
.
uid
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pBlock
->
info
.
numOfCols
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pBlock
->
info
.
numOfCols
);
buf
=
taosDecodeFixedI16
(
buf
,
&
pBlock
->
info
.
hasVarCol
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pBlock
->
info
.
rows
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pBlock
->
info
.
rows
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pBlock
->
pDataBlock
=
taosArrayInit
(
sz
,
sizeof
(
SColumnInfoData
));
pBlock
->
pDataBlock
=
taosArrayInit
(
sz
,
sizeof
(
SColumnInfoData
));
...
@@ -136,6 +140,23 @@ static FORCE_INLINE void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock)
...
@@ -136,6 +140,23 @@ static FORCE_INLINE void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock)
return
(
void
*
)
buf
;
return
(
void
*
)
buf
;
}
}
static
FORCE_INLINE
void
tDeleteSSDataBlock
(
SSDataBlock
*
pBlock
)
{
if
(
pBlock
==
NULL
)
{
return
;
}
// int32_t numOfOutput = pBlock->info.numOfCols;
int32_t
sz
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
sz
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
tfree
(
pColInfoData
->
pData
);
}
taosArrayDestroy
(
pBlock
->
pDataBlock
);
tfree
(
pBlock
->
pBlockAgg
);
// tfree(pBlock);
}
static
FORCE_INLINE
int32_t
tEncodeSMqPollRsp
(
void
**
buf
,
const
SMqPollRsp
*
pRsp
)
{
static
FORCE_INLINE
int32_t
tEncodeSMqPollRsp
(
void
**
buf
,
const
SMqPollRsp
*
pRsp
)
{
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
int32_t
sz
=
0
;
int32_t
sz
=
0
;
...
@@ -178,23 +199,6 @@ static FORCE_INLINE void* tDecodeSMqPollRsp(void* buf, SMqPollRsp* pRsp) {
...
@@ -178,23 +199,6 @@ static FORCE_INLINE void* tDecodeSMqPollRsp(void* buf, SMqPollRsp* pRsp) {
return
buf
;
return
buf
;
}
}
static
FORCE_INLINE
void
tDeleteSSDataBlock
(
SSDataBlock
*
pBlock
)
{
if
(
pBlock
==
NULL
)
{
return
;
}
// int32_t numOfOutput = pBlock->info.numOfCols;
int32_t
sz
=
taosArrayGetSize
(
pBlock
->
pDataBlock
);
for
(
int32_t
i
=
0
;
i
<
sz
;
++
i
)
{
SColumnInfoData
*
pColInfoData
=
(
SColumnInfoData
*
)
taosArrayGet
(
pBlock
->
pDataBlock
,
i
);
tfree
(
pColInfoData
->
pData
);
}
taosArrayDestroy
(
pBlock
->
pDataBlock
);
tfree
(
pBlock
->
pBlockAgg
);
// tfree(pBlock);
}
static
FORCE_INLINE
void
tDeleteSMqConsumeRsp
(
SMqPollRsp
*
pRsp
)
{
static
FORCE_INLINE
void
tDeleteSMqConsumeRsp
(
SMqPollRsp
*
pRsp
)
{
if
(
pRsp
->
schemas
)
{
if
(
pRsp
->
schemas
)
{
if
(
pRsp
->
schemas
->
nCols
)
{
if
(
pRsp
->
schemas
->
nCols
)
{
...
@@ -204,10 +208,6 @@ static FORCE_INLINE void tDeleteSMqConsumeRsp(SMqPollRsp* pRsp) {
...
@@ -204,10 +208,6 @@ static FORCE_INLINE void tDeleteSMqConsumeRsp(SMqPollRsp* pRsp) {
}
}
taosArrayDestroyEx
(
pRsp
->
pBlockData
,
(
void
(
*
)(
void
*
))
tDeleteSSDataBlock
);
taosArrayDestroyEx
(
pRsp
->
pBlockData
,
(
void
(
*
)(
void
*
))
tDeleteSSDataBlock
);
pRsp
->
pBlockData
=
NULL
;
pRsp
->
pBlockData
=
NULL
;
// for (int32_t i = 0; i < taosArrayGetSize(pRsp->pBlockData); i++) {
// SSDataBlock* pDataBlock = (SSDataBlock*)taosArrayGet(pRsp->pBlockData, i);
// tDeleteSSDataBlock(pDataBlock);
//}
}
}
//======================================================================================================================
//======================================================================================================================
...
...
include/common/tdatablock.h
浏览文件 @
db970c79
...
@@ -117,7 +117,7 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF
...
@@ -117,7 +117,7 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF
int32_t
blockDataEnsureColumnCapacity
(
SColumnInfoData
*
pColumn
,
uint32_t
numOfRows
);
int32_t
blockDataEnsureColumnCapacity
(
SColumnInfoData
*
pColumn
,
uint32_t
numOfRows
);
int32_t
blockDataEnsureCapacity
(
SSDataBlock
*
pDataBlock
,
uint32_t
numOfRows
);
int32_t
blockDataEnsureCapacity
(
SSDataBlock
*
pDataBlock
,
uint32_t
numOfRows
);
void
blockDataClearup
(
SSDataBlock
*
pDataBlock
,
bool
hasVarCol
);
void
blockDataClearup
(
SSDataBlock
*
pDataBlock
);
SSDataBlock
*
createOneDataBlock
(
const
SSDataBlock
*
pDataBlock
);
SSDataBlock
*
createOneDataBlock
(
const
SSDataBlock
*
pDataBlock
);
size_t
blockDataGetCapacityInRow
(
const
SSDataBlock
*
pBlock
,
size_t
pageSize
);
size_t
blockDataGetCapacityInRow
(
const
SSDataBlock
*
pBlock
,
size_t
pageSize
);
void
*
blockDataDestroy
(
SSDataBlock
*
pBlock
);
void
*
blockDataDestroy
(
SSDataBlock
*
pBlock
);
...
...
include/common/tmsg.h
浏览文件 @
db970c79
...
@@ -190,7 +190,10 @@ typedef struct SEp {
...
@@ -190,7 +190,10 @@ typedef struct SEp {
typedef
struct
{
typedef
struct
{
int32_t
contLen
;
int32_t
contLen
;
int32_t
vgId
;
union
{
int32_t
vgId
;
int32_t
streamTaskId
;
};
}
SMsgHead
;
}
SMsgHead
;
// Submit message for one table
// Submit message for one table
...
@@ -1139,6 +1142,17 @@ int32_t tSerializeSCMCreateStreamReq(void* buf, int32_t bufLen, const SCMCreateS
...
@@ -1139,6 +1142,17 @@ int32_t tSerializeSCMCreateStreamReq(void* buf, int32_t bufLen, const SCMCreateS
int32_t
tDeserializeSCMCreateStreamReq
(
void
*
buf
,
int32_t
bufLen
,
SCMCreateStreamReq
*
pReq
);
int32_t
tDeserializeSCMCreateStreamReq
(
void
*
buf
,
int32_t
bufLen
,
SCMCreateStreamReq
*
pReq
);
void
tFreeSCMCreateStreamReq
(
SCMCreateStreamReq
*
pReq
);
void
tFreeSCMCreateStreamReq
(
SCMCreateStreamReq
*
pReq
);
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
int64_t
streamId
;
char
*
sql
;
char
*
executorMsg
;
}
SMVCreateStreamReq
,
SMSCreateStreamReq
;
typedef
struct
{
int64_t
streamId
;
}
SMVCreateStreamRsp
,
SMSCreateStreamRsp
;
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
name
[
TSDB_TOPIC_FNAME_LEN
];
int8_t
igExists
;
int8_t
igExists
;
...
@@ -1903,11 +1917,12 @@ typedef struct {
...
@@ -1903,11 +1917,12 @@ typedef struct {
int8_t
slidingUnit
;
int8_t
slidingUnit
;
char
indexName
[
TSDB_INDEX_NAME_LEN
];
char
indexName
[
TSDB_INDEX_NAME_LEN
];
char
timezone
[
TD_TIMEZONE_LEN
];
// sma data is invalid if timezone change.
char
timezone
[
TD_TIMEZONE_LEN
];
// sma data is invalid if timezone change.
uint16_t
exprLen
;
int32_t
exprLen
;
uint16_t
tagsFilterLen
;
int32_t
tagsFilterLen
;
int64_t
indexUid
;
int64_t
indexUid
;
tb_uid_t
tableUid
;
// super/child/common table uid
tb_uid_t
tableUid
;
// super/child/common table uid
int64_t
interval
;
int64_t
interval
;
int64_t
offset
;
int64_t
sliding
;
int64_t
sliding
;
char
*
expr
;
// sma expression
char
*
expr
;
// sma expression
char
*
tagsFilter
;
char
*
tagsFilter
;
...
@@ -2009,11 +2024,12 @@ static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) {
...
@@ -2009,11 +2024,12 @@ static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) {
tlen
+=
taosEncodeFixedI8
(
buf
,
pSma
->
slidingUnit
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSma
->
slidingUnit
);
tlen
+=
taosEncodeString
(
buf
,
pSma
->
indexName
);
tlen
+=
taosEncodeString
(
buf
,
pSma
->
indexName
);
tlen
+=
taosEncodeString
(
buf
,
pSma
->
timezone
);
tlen
+=
taosEncodeString
(
buf
,
pSma
->
timezone
);
tlen
+=
taosEncodeFixed
U16
(
buf
,
pSma
->
exprLen
);
tlen
+=
taosEncodeFixed
I32
(
buf
,
pSma
->
exprLen
);
tlen
+=
taosEncodeFixed
U16
(
buf
,
pSma
->
tagsFilterLen
);
tlen
+=
taosEncodeFixed
I32
(
buf
,
pSma
->
tagsFilterLen
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pSma
->
indexUid
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pSma
->
indexUid
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pSma
->
tableUid
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pSma
->
tableUid
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pSma
->
interval
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pSma
->
interval
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pSma
->
offset
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pSma
->
sliding
);
tlen
+=
taosEncodeFixedI64
(
buf
,
pSma
->
sliding
);
if
(
pSma
->
exprLen
>
0
)
{
if
(
pSma
->
exprLen
>
0
)
{
...
@@ -2043,14 +2059,14 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) {
...
@@ -2043,14 +2059,14 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) {
buf
=
taosDecodeFixedI8
(
buf
,
&
pSma
->
slidingUnit
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSma
->
slidingUnit
);
buf
=
taosDecodeStringTo
(
buf
,
pSma
->
indexName
);
buf
=
taosDecodeStringTo
(
buf
,
pSma
->
indexName
);
buf
=
taosDecodeStringTo
(
buf
,
pSma
->
timezone
);
buf
=
taosDecodeStringTo
(
buf
,
pSma
->
timezone
);
buf
=
taosDecodeFixed
U16
(
buf
,
&
pSma
->
exprLen
);
buf
=
taosDecodeFixed
I32
(
buf
,
&
pSma
->
exprLen
);
buf
=
taosDecodeFixed
U16
(
buf
,
&
pSma
->
tagsFilterLen
);
buf
=
taosDecodeFixed
I32
(
buf
,
&
pSma
->
tagsFilterLen
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pSma
->
indexUid
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pSma
->
indexUid
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pSma
->
tableUid
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pSma
->
tableUid
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pSma
->
interval
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pSma
->
interval
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pSma
->
offset
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pSma
->
sliding
);
buf
=
taosDecodeFixedI64
(
buf
,
&
pSma
->
sliding
);
if
(
pSma
->
exprLen
>
0
)
{
if
(
pSma
->
exprLen
>
0
)
{
pSma
->
expr
=
(
char
*
)
calloc
(
pSma
->
exprLen
,
1
);
pSma
->
expr
=
(
char
*
)
calloc
(
pSma
->
exprLen
,
1
);
if
(
pSma
->
expr
!=
NULL
)
{
if
(
pSma
->
expr
!=
NULL
)
{
...
...
include/common/ttime.h
浏览文件 @
db970c79
...
@@ -25,6 +25,17 @@ extern "C" {
...
@@ -25,6 +25,17 @@ extern "C" {
#define TIME_IS_VAR_DURATION(_t) ((_t) == 'n' || (_t) == 'y' || (_t) == 'N' || (_t) == 'Y')
#define TIME_IS_VAR_DURATION(_t) ((_t) == 'n' || (_t) == 'y' || (_t) == 'N' || (_t) == 'Y')
#define TIME_UNIT_NANOSECOND 'b'
#define TIME_UNIT_MICROSECOND 'u'
#define TIME_UNIT_MILLISECOND 'a'
#define TIME_UNIT_SECOND 's'
#define TIME_UNIT_MINUTE 'm'
#define TIME_UNIT_HOUR 'h'
#define TIME_UNIT_DAY 'd'
#define TIME_UNIT_WEEK 'w'
#define TIME_UNIT_MONTH 'n'
#define TIME_UNIT_YEAR 'y'
/*
/*
* @return timestamp decided by global conf variable, tsTimePrecision
* @return timestamp decided by global conf variable, tsTimePrecision
* if precision == TSDB_TIME_PRECISION_MICRO, it returns timestamp in microsecond.
* if precision == TSDB_TIME_PRECISION_MICRO, it returns timestamp in microsecond.
...
...
include/common/ttokendef.h
浏览文件 @
db970c79
...
@@ -48,108 +48,113 @@
...
@@ -48,108 +48,113 @@
#define TK_DNODES 30
#define TK_DNODES 30
#define TK_NK_ID 31
#define TK_NK_ID 31
#define TK_NK_IPTOKEN 32
#define TK_NK_IPTOKEN 32
#define TK_DATABASE 33
#define TK_QNODE 33
#define TK_DATABASES 34
#define TK_ON 34
#define TK_USE 35
#define TK_QNODES 35
#define TK_IF 36
#define TK_DATABASE 36
#define TK_NOT 37
#define TK_DATABASES 37
#define TK_EXISTS 38
#define TK_USE 38
#define TK_BLOCKS 39
#define TK_IF 39
#define TK_CACHE 40
#define TK_NOT 40
#define TK_CACHELAST 41
#define TK_EXISTS 41
#define TK_COMP 42
#define TK_BLOCKS 42
#define TK_DAYS 43
#define TK_CACHE 43
#define TK_FSYNC 44
#define TK_CACHELAST 44
#define TK_MAXROWS 45
#define TK_COMP 45
#define TK_MINROWS 46
#define TK_DAYS 46
#define TK_KEEP 47
#define TK_FSYNC 47
#define TK_PRECISION 48
#define TK_MAXROWS 48
#define TK_QUORUM 49
#define TK_MINROWS 49
#define TK_REPLICA 50
#define TK_KEEP 50
#define TK_TTL 51
#define TK_PRECISION 51
#define TK_WAL 52
#define TK_QUORUM 52
#define TK_VGROUPS 53
#define TK_REPLICA 53
#define TK_SINGLE_STABLE 54
#define TK_TTL 54
#define TK_STREAM_MODE 55
#define TK_WAL 55
#define TK_TABLE 56
#define TK_VGROUPS 56
#define TK_NK_LP 57
#define TK_SINGLE_STABLE 57
#define TK_NK_RP 58
#define TK_STREAM_MODE 58
#define TK_STABLE 59
#define TK_TABLE 59
#define TK_TABLES 60
#define TK_NK_LP 60
#define TK_STABLES 61
#define TK_NK_RP 61
#define TK_USING 62
#define TK_STABLE 62
#define TK_TAGS 63
#define TK_TABLES 63
#define TK_NK_DOT 64
#define TK_STABLES 64
#define TK_NK_COMMA 65
#define TK_USING 65
#define TK_COMMENT 66
#define TK_TAGS 66
#define TK_BOOL 67
#define TK_NK_DOT 67
#define TK_TINYINT 68
#define TK_NK_COMMA 68
#define TK_SMALLINT 69
#define TK_COMMENT 69
#define TK_INT 70
#define TK_BOOL 70
#define TK_INTEGER 71
#define TK_TINYINT 71
#define TK_BIGINT 72
#define TK_SMALLINT 72
#define TK_FLOAT 73
#define TK_INT 73
#define TK_DOUBLE 74
#define TK_INTEGER 74
#define TK_BINARY 75
#define TK_BIGINT 75
#define TK_TIMESTAMP 76
#define TK_FLOAT 76
#define TK_NCHAR 77
#define TK_DOUBLE 77
#define TK_UNSIGNED 78
#define TK_BINARY 78
#define TK_JSON 79
#define TK_TIMESTAMP 79
#define TK_VARCHAR 80
#define TK_NCHAR 80
#define TK_MEDIUMBLOB 81
#define TK_UNSIGNED 81
#define TK_BLOB 82
#define TK_JSON 82
#define TK_VARBINARY 83
#define TK_VARCHAR 83
#define TK_DECIMAL 84
#define TK_MEDIUMBLOB 84
#define TK_SMA 85
#define TK_BLOB 85
#define TK_MNODES 86
#define TK_VARBINARY 86
#define TK_NK_FLOAT 87
#define TK_DECIMAL 87
#define TK_NK_BOOL 88
#define TK_SMA 88
#define TK_NK_VARIABLE 89
#define TK_INDEX 89
#define TK_BETWEEN 90
#define TK_FULLTEXT 90
#define TK_IS 91
#define TK_FUNCTION 91
#define TK_NULL 92
#define TK_INTERVAL 92
#define TK_NK_LT 93
#define TK_MNODES 93
#define TK_NK_GT 94
#define TK_NK_FLOAT 94
#define TK_NK_LE 95
#define TK_NK_BOOL 95
#define TK_NK_GE 96
#define TK_NK_VARIABLE 96
#define TK_NK_NE 97
#define TK_BETWEEN 97
#define TK_NK_EQ 98
#define TK_IS 98
#define TK_LIKE 99
#define TK_NULL 99
#define TK_MATCH 100
#define TK_NK_LT 100
#define TK_NMATCH 101
#define TK_NK_GT 101
#define TK_IN 102
#define TK_NK_LE 102
#define TK_FROM 103
#define TK_NK_GE 103
#define TK_AS 104
#define TK_NK_NE 104
#define TK_JOIN 105
#define TK_NK_EQ 105
#define TK_ON 106
#define TK_LIKE 106
#define TK_INNER 107
#define TK_MATCH 107
#define TK_SELECT 108
#define TK_NMATCH 108
#define TK_DISTINCT 109
#define TK_IN 109
#define TK_WHERE 110
#define TK_FROM 110
#define TK_PARTITION 111
#define TK_AS 111
#define TK_BY 112
#define TK_JOIN 112
#define TK_SESSION 113
#define TK_INNER 113
#define TK_STATE_WINDOW 114
#define TK_SELECT 114
#define TK_INTERVAL 115
#define TK_DISTINCT 115
#define TK_SLIDING 116
#define TK_WHERE 116
#define TK_FILL 117
#define TK_PARTITION 117
#define TK_VALUE 118
#define TK_BY 118
#define TK_NONE 119
#define TK_SESSION 119
#define TK_PREV 120
#define TK_STATE_WINDOW 120
#define TK_LINEAR 121
#define TK_SLIDING 121
#define TK_NEXT 122
#define TK_FILL 122
#define TK_GROUP 123
#define TK_VALUE 123
#define TK_HAVING 124
#define TK_NONE 124
#define TK_ORDER 125
#define TK_PREV 125
#define TK_SLIMIT 126
#define TK_LINEAR 126
#define TK_SOFFSET 127
#define TK_NEXT 127
#define TK_LIMIT 128
#define TK_GROUP 128
#define TK_OFFSET 129
#define TK_HAVING 129
#define TK_ASC 130
#define TK_ORDER 130
#define TK_DESC 131
#define TK_SLIMIT 131
#define TK_NULLS 132
#define TK_SOFFSET 132
#define TK_FIRST 133
#define TK_LIMIT 133
#define TK_LAST 134
#define TK_OFFSET 134
#define TK_ASC 135
#define TK_DESC 136
#define TK_NULLS 137
#define TK_FIRST 138
#define TK_LAST 139
#define TK_NK_SPACE 300
#define TK_NK_SPACE 300
#define TK_NK_COMMENT 301
#define TK_NK_COMMENT 301
...
...
include/dnode/snode/snode.h
浏览文件 @
db970c79
...
@@ -80,6 +80,10 @@ int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad);
...
@@ -80,6 +80,10 @@ int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad);
*/
*/
int32_t
sndProcessMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int32_t
sndProcessMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
pRsp
);
int32_t
sndProcessUMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
);
int32_t
sndProcessSMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
);
/**
/**
* @brief Drop a snode.
* @brief Drop a snode.
*
*
...
...
include/libs/function/function.h
浏览文件 @
db970c79
...
@@ -295,19 +295,8 @@ typedef struct SMultiFunctionsDesc {
...
@@ -295,19 +295,8 @@ typedef struct SMultiFunctionsDesc {
int32_t
getResultDataInfo
(
int32_t
dataType
,
int32_t
dataBytes
,
int32_t
functionId
,
int32_t
param
,
SResultDataInfo
*
pInfo
,
int16_t
extLength
,
int32_t
getResultDataInfo
(
int32_t
dataType
,
int32_t
dataBytes
,
int32_t
functionId
,
int32_t
param
,
SResultDataInfo
*
pInfo
,
int16_t
extLength
,
bool
isSuperTable
);
bool
isSuperTable
);
/**
* If the given name is a valid built-in sql function, the value of true will be returned.
* @param name
* @param len
* @return
*/
int32_t
qIsBuiltinFunction
(
const
char
*
name
,
int32_t
len
,
bool
*
scalarFunction
);
bool
qIsValidUdf
(
SArray
*
pUdfInfo
,
const
char
*
name
,
int32_t
len
,
int32_t
*
functionId
);
bool
qIsValidUdf
(
SArray
*
pUdfInfo
,
const
char
*
name
,
int32_t
len
,
int32_t
*
functionId
);
bool
qIsAggregateFunction
(
const
char
*
functionName
);
bool
qIsSelectivityFunction
(
const
char
*
functionName
);
tExprNode
*
exprTreeFromBinary
(
const
void
*
data
,
size_t
size
);
tExprNode
*
exprTreeFromBinary
(
const
void
*
data
,
size_t
size
);
void
extractFunctionDesc
(
SArray
*
pFunctionIdList
,
SMultiFunctionsDesc
*
pDesc
);
void
extractFunctionDesc
(
SArray
*
pFunctionIdList
,
SMultiFunctionsDesc
*
pDesc
);
...
...
include/libs/nodes/cmdnodes.h
浏览文件 @
db970c79
...
@@ -23,6 +23,7 @@ extern "C" {
...
@@ -23,6 +23,7 @@ extern "C" {
#include "querynodes.h"
#include "querynodes.h"
typedef
struct
SDatabaseOptions
{
typedef
struct
SDatabaseOptions
{
ENodeType
type
;
int32_t
numOfBlocks
;
int32_t
numOfBlocks
;
int32_t
cacheBlockSize
;
int32_t
cacheBlockSize
;
int8_t
cachelast
;
int8_t
cachelast
;
...
@@ -46,7 +47,7 @@ typedef struct SCreateDatabaseStmt {
...
@@ -46,7 +47,7 @@ typedef struct SCreateDatabaseStmt {
ENodeType
type
;
ENodeType
type
;
char
dbName
[
TSDB_DB_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
bool
ignoreExists
;
bool
ignoreExists
;
SDatabaseOptions
o
ptions
;
SDatabaseOptions
*
pO
ptions
;
}
SCreateDatabaseStmt
;
}
SCreateDatabaseStmt
;
typedef
struct
SUseDatabaseStmt
{
typedef
struct
SUseDatabaseStmt
{
...
@@ -61,6 +62,7 @@ typedef struct SDropDatabaseStmt {
...
@@ -61,6 +62,7 @@ typedef struct SDropDatabaseStmt {
}
SDropDatabaseStmt
;
}
SDropDatabaseStmt
;
typedef
struct
STableOptions
{
typedef
struct
STableOptions
{
ENodeType
type
;
int32_t
keep
;
int32_t
keep
;
int32_t
ttl
;
int32_t
ttl
;
char
comments
[
TSDB_STB_COMMENT_LEN
];
char
comments
[
TSDB_STB_COMMENT_LEN
];
...
@@ -81,7 +83,7 @@ typedef struct SCreateTableStmt {
...
@@ -81,7 +83,7 @@ typedef struct SCreateTableStmt {
bool
ignoreExists
;
bool
ignoreExists
;
SNodeList
*
pCols
;
SNodeList
*
pCols
;
SNodeList
*
pTags
;
SNodeList
*
pTags
;
STableOptions
o
ptions
;
STableOptions
*
pO
ptions
;
}
SCreateTableStmt
;
}
SCreateTableStmt
;
typedef
struct
SCreateSubTableClause
{
typedef
struct
SCreateSubTableClause
{
...
@@ -155,6 +157,33 @@ typedef struct SShowStmt {
...
@@ -155,6 +157,33 @@ typedef struct SShowStmt {
char
dbName
[
TSDB_DB_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
}
SShowStmt
;
}
SShowStmt
;
typedef
enum
EIndexType
{
INDEX_TYPE_SMA
=
1
,
INDEX_TYPE_FULLTEXT
}
EIndexType
;
typedef
struct
SIndexOptions
{
ENodeType
type
;
SNodeList
*
pFuncs
;
SNode
*
pInterval
;
SNode
*
pOffset
;
SNode
*
pSliding
;
}
SIndexOptions
;
typedef
struct
SCreateIndexStmt
{
ENodeType
type
;
EIndexType
indexType
;
char
indexName
[
TSDB_INDEX_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
SNodeList
*
pCols
;
SIndexOptions
*
pOptions
;
}
SCreateIndexStmt
;
typedef
struct
SCreateQnodeStmt
{
ENodeType
type
;
int32_t
dnodeId
;
}
SCreateQnodeStmt
;
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/libs/nodes/nodes.h
浏览文件 @
db970c79
...
@@ -67,6 +67,9 @@ typedef enum ENodeType {
...
@@ -67,6 +67,9 @@ typedef enum ENodeType {
QUERY_NODE_SLOT_DESC
,
QUERY_NODE_SLOT_DESC
,
QUERY_NODE_COLUMN_DEF
,
QUERY_NODE_COLUMN_DEF
,
QUERY_NODE_DOWNSTREAM_SOURCE
,
QUERY_NODE_DOWNSTREAM_SOURCE
,
QUERY_NODE_DATABASE_OPTIONS
,
QUERY_NODE_TABLE_OPTIONS
,
QUERY_NODE_INDEX_OPTIONS
,
// Statement nodes are used in parser and planner module.
// Statement nodes are used in parser and planner module.
QUERY_NODE_SET_OPERATOR
,
QUERY_NODE_SET_OPERATOR
,
...
@@ -93,6 +96,9 @@ typedef enum ENodeType {
...
@@ -93,6 +96,9 @@ typedef enum ENodeType {
QUERY_NODE_SHOW_DNODES_STMT
,
QUERY_NODE_SHOW_DNODES_STMT
,
QUERY_NODE_SHOW_VGROUPS_STMT
,
QUERY_NODE_SHOW_VGROUPS_STMT
,
QUERY_NODE_SHOW_MNODES_STMT
,
QUERY_NODE_SHOW_MNODES_STMT
,
QUERY_NODE_SHOW_QNODES_STMT
,
QUERY_NODE_CREATE_INDEX_STMT
,
QUERY_NODE_CREATE_QNODE_STMT
,
// logic plan node
// logic plan node
QUERY_NODE_LOGIC_PLAN_SCAN
,
QUERY_NODE_LOGIC_PLAN_SCAN
,
...
@@ -101,6 +107,7 @@ typedef enum ENodeType {
...
@@ -101,6 +107,7 @@ typedef enum ENodeType {
QUERY_NODE_LOGIC_PLAN_PROJECT
,
QUERY_NODE_LOGIC_PLAN_PROJECT
,
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
,
QUERY_NODE_LOGIC_PLAN_VNODE_MODIF
,
QUERY_NODE_LOGIC_PLAN_EXCHANGE
,
QUERY_NODE_LOGIC_PLAN_EXCHANGE
,
QUERY_NODE_LOGIC_PLAN_WINDOW
,
QUERY_NODE_LOGIC_SUBPLAN
,
QUERY_NODE_LOGIC_SUBPLAN
,
QUERY_NODE_LOGIC_PLAN
,
QUERY_NODE_LOGIC_PLAN
,
...
@@ -115,6 +122,7 @@ typedef enum ENodeType {
...
@@ -115,6 +122,7 @@ typedef enum ENodeType {
QUERY_NODE_PHYSICAL_PLAN_AGG
,
QUERY_NODE_PHYSICAL_PLAN_AGG
,
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
,
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
,
QUERY_NODE_PHYSICAL_PLAN_SORT
,
QUERY_NODE_PHYSICAL_PLAN_SORT
,
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
,
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
,
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
,
QUERY_NODE_PHYSICAL_PLAN_INSERT
,
QUERY_NODE_PHYSICAL_PLAN_INSERT
,
QUERY_NODE_PHYSICAL_SUBPLAN
,
QUERY_NODE_PHYSICAL_SUBPLAN
,
...
@@ -183,6 +191,9 @@ const char* nodesNodeName(ENodeType type);
...
@@ -183,6 +191,9 @@ const char* nodesNodeName(ENodeType type);
int32_t
nodesNodeToString
(
const
SNodeptr
pNode
,
bool
format
,
char
**
pStr
,
int32_t
*
pLen
);
int32_t
nodesNodeToString
(
const
SNodeptr
pNode
,
bool
format
,
char
**
pStr
,
int32_t
*
pLen
);
int32_t
nodesStringToNode
(
const
char
*
pStr
,
SNode
**
pNode
);
int32_t
nodesStringToNode
(
const
char
*
pStr
,
SNode
**
pNode
);
int32_t
nodesListToString
(
const
SNodeList
*
pList
,
bool
format
,
char
**
pStr
,
int32_t
*
pLen
);
int32_t
nodesStringToList
(
const
char
*
pStr
,
SNodeList
**
pList
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/libs/nodes/plannodes.h
浏览文件 @
db970c79
...
@@ -80,6 +80,24 @@ typedef struct SExchangeLogicNode {
...
@@ -80,6 +80,24 @@ typedef struct SExchangeLogicNode {
int32_t
srcGroupId
;
int32_t
srcGroupId
;
}
SExchangeLogicNode
;
}
SExchangeLogicNode
;
typedef
enum
EWindowType
{
WINDOW_TYPE_INTERVAL
=
1
,
WINDOW_TYPE_SESSION
,
WINDOW_TYPE_STATE
}
EWindowType
;
typedef
struct
SWindowLogicNode
{
SLogicNode
node
;
EWindowType
winType
;
SNodeList
*
pFuncs
;
int64_t
interval
;
int64_t
offset
;
int64_t
sliding
;
int8_t
intervalUnit
;
int8_t
slidingUnit
;
SFillNode
*
pFill
;
}
SWindowLogicNode
;
typedef
enum
ESubplanType
{
typedef
enum
ESubplanType
{
SUBPLAN_TYPE_MERGE
=
1
,
SUBPLAN_TYPE_MERGE
=
1
,
SUBPLAN_TYPE_PARTIAL
,
SUBPLAN_TYPE_PARTIAL
,
...
@@ -187,10 +205,22 @@ typedef struct SDownstreamSourceNode {
...
@@ -187,10 +205,22 @@ typedef struct SDownstreamSourceNode {
typedef
struct
SExchangePhysiNode
{
typedef
struct
SExchangePhysiNode
{
SPhysiNode
node
;
SPhysiNode
node
;
int32_t
srcGroupId
;
// group id of datasource suplans
int32_t
srcGroupId
;
// group id of datasource suplans
SNodeList
*
pSrcEndPoints
;
// element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
SNodeList
*
pSrcEndPoints
;
// element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
}
SExchangePhysiNode
;
}
SExchangePhysiNode
;
typedef
struct
SIntervalPhysiNode
{
SPhysiNode
node
;
SNodeList
*
pExprs
;
// these are expression list of parameter expression of function
SNodeList
*
pFuncs
;
int64_t
interval
;
int64_t
offset
;
int64_t
sliding
;
int8_t
intervalUnit
;
int8_t
slidingUnit
;
SFillNode
*
pFill
;
}
SIntervalPhysiNode
;
typedef
struct
SDataSinkNode
{
typedef
struct
SDataSinkNode
{
ENodeType
type
;
ENodeType
type
;
SDataBlockDescNode
*
pInputDataBlockDesc
;
SDataBlockDescNode
*
pInputDataBlockDesc
;
...
...
include/libs/nodes/querynodes.h
浏览文件 @
db970c79
...
@@ -82,6 +82,7 @@ typedef struct SValueNode {
...
@@ -82,6 +82,7 @@ typedef struct SValueNode {
double
d
;
double
d
;
char
*
p
;
char
*
p
;
}
datum
;
}
datum
;
char
unit
;
}
SValueNode
;
}
SValueNode
;
typedef
struct
SOperatorNode
{
typedef
struct
SOperatorNode
{
...
...
include/libs/parser/parser.h
浏览文件 @
db970c79
...
@@ -51,6 +51,7 @@ typedef struct SQuery {
...
@@ -51,6 +51,7 @@ typedef struct SQuery {
SSchema
*
pResSchema
;
SSchema
*
pResSchema
;
SCmdMsgInfo
*
pCmdMsg
;
SCmdMsgInfo
*
pCmdMsg
;
int32_t
msgType
;
int32_t
msgType
;
bool
streamQuery
;
}
SQuery
;
}
SQuery
;
int32_t
qParseQuerySql
(
SParseContext
*
pCxt
,
SQuery
**
pQuery
);
int32_t
qParseQuerySql
(
SParseContext
*
pCxt
,
SQuery
**
pQuery
);
...
...
include/libs/planner/planner.h
浏览文件 @
db970c79
...
@@ -26,6 +26,7 @@ typedef struct SPlanContext {
...
@@ -26,6 +26,7 @@ typedef struct SPlanContext {
uint64_t
queryId
;
uint64_t
queryId
;
int32_t
acctId
;
int32_t
acctId
;
SNode
*
pAstRoot
;
SNode
*
pAstRoot
;
bool
streamQuery
;
}
SPlanContext
;
}
SPlanContext
;
// Create the physical plan for the query, according to the AST.
// Create the physical plan for the query, according to the AST.
...
...
include/libs/transport/trpc.h
浏览文件 @
db970c79
...
@@ -78,6 +78,10 @@ typedef struct SRpcInit {
...
@@ -78,6 +78,10 @@ typedef struct SRpcInit {
// call back to keep conn or not
// call back to keep conn or not
bool
(
*
pfp
)(
void
*
parent
,
tmsg_t
msgType
);
bool
(
*
pfp
)(
void
*
parent
,
tmsg_t
msgType
);
// to support Send messages multiple times on a link
//
void
*
(
*
mfp
)(
void
*
parent
,
tmsg_t
msgType
);
void
*
parent
;
void
*
parent
;
}
SRpcInit
;
}
SRpcInit
;
...
@@ -96,6 +100,9 @@ void rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp)
...
@@ -96,6 +100,9 @@ void rpcSendRecv(void *shandle, SEpSet *pEpSet, SRpcMsg *pReq, SRpcMsg *pRsp)
int
rpcReportProgress
(
void
*
pConn
,
char
*
pCont
,
int
contLen
);
int
rpcReportProgress
(
void
*
pConn
,
char
*
pCont
,
int
contLen
);
void
rpcCancelRequest
(
int64_t
rid
);
void
rpcCancelRequest
(
int64_t
rid
);
// just release client conn to rpc instance, no close sock
void
rpcReleaseHandle
(
void
*
handle
);
void
rpcRefHandle
(
void
*
handle
,
int8_t
type
);
void
rpcRefHandle
(
void
*
handle
,
int8_t
type
);
void
rpcUnrefHandle
(
void
*
handle
,
int8_t
type
);
void
rpcUnrefHandle
(
void
*
handle
,
int8_t
type
);
...
...
include/os/osLocale.h
浏览文件 @
db970c79
...
@@ -17,12 +17,16 @@
...
@@ -17,12 +17,16 @@
#define _TD_OS_LOCALE_H_
#define _TD_OS_LOCALE_H_
#include "os.h"
#include "os.h"
#include "osString.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
// If the error is in a third-party library, place this header file under the third-party library header file.
#ifndef ALLOW_FORBID_FUNC
#define setlocale SETLOCALE_FUNC_TAOS_FORBID
#endif
char
*
taosCharsetReplace
(
char
*
charsetstr
);
char
*
taosCharsetReplace
(
char
*
charsetstr
);
void
taosGetSystemLocale
(
char
*
outLocale
,
char
*
outCharset
);
void
taosGetSystemLocale
(
char
*
outLocale
,
char
*
outCharset
);
void
taosSetSystemLocale
(
const
char
*
inLocale
,
const
char
*
inCharSet
);
void
taosSetSystemLocale
(
const
char
*
inLocale
,
const
char
*
inCharSet
);
...
...
include/util/taoserror.h
浏览文件 @
db970c79
...
@@ -354,6 +354,7 @@ int32_t* taosGetErrno();
...
@@ -354,6 +354,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0614)
#define TSDB_CODE_TDB_MESSED_MSG TAOS_DEF_ERROR_CODE(0, 0x0614)
#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615)
#define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615)
#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616)
#define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616)
#define TSDB_CODE_TDB_NO_SMA_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x0617)
// query
// query
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
...
...
include/util/tdef.h
浏览文件 @
db970c79
...
@@ -345,19 +345,19 @@ typedef enum ELogicConditionType {
...
@@ -345,19 +345,19 @@ typedef enum ELogicConditionType {
#define TSDB_MAX_DB_QUORUM_OPTION 2
#define TSDB_MAX_DB_QUORUM_OPTION 2
#define TSDB_DEFAULT_DB_QUORUM_OPTION 1
#define TSDB_DEFAULT_DB_QUORUM_OPTION 1
#define TSDB_MIN_DB_TTL_OPTION
1
#define TSDB_MIN_DB_TTL_OPTION 1
#define TSDB_DEFAULT_DB_TTL_OPTION
0
#define TSDB_DEFAULT_DB_TTL_OPTION 0
#define TSDB_MIN_DB_SINGLE_STABLE_OPTION
0
#define TSDB_MIN_DB_SINGLE_STABLE_OPTION 0
#define TSDB_MAX_DB_SINGLE_STABLE_OPTION
1
#define TSDB_MAX_DB_SINGLE_STABLE_OPTION 1
#define TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION
0
#define TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION 0
#define TSDB_MIN_DB_STREAM_MODE_OPTION
0
#define TSDB_MIN_DB_STREAM_MODE_OPTION 0
#define TSDB_MAX_DB_STREAM_MODE_OPTION
1
#define TSDB_MAX_DB_STREAM_MODE_OPTION 1
#define TSDB_DEFAULT_DB_STREAM_MODE_OPTION
0
#define TSDB_DEFAULT_DB_STREAM_MODE_OPTION 0
#define TSDB_MAX_JOIN_TABLE_NUM
10
#define TSDB_MAX_JOIN_TABLE_NUM 10
#define TSDB_MAX_UNION_CLAUSE
5
#define TSDB_MAX_UNION_CLAUSE 5
#define TSDB_MIN_DB_UPDATE 0
#define TSDB_MIN_DB_UPDATE 0
#define TSDB_MAX_DB_UPDATE 2
#define TSDB_MAX_DB_UPDATE 2
...
@@ -445,6 +445,9 @@ typedef struct {
...
@@ -445,6 +445,9 @@ typedef struct {
#define TMQ_SEPARATOR ':'
#define TMQ_SEPARATOR ':'
#define SND_UNIQUE_THREAD_NUM 2
#define SND_SHARED_THREAD_NUM 2
#ifdef __cplusplus
#ifdef __cplusplus
}
}
#endif
#endif
...
...
include/util/tjson.h
浏览文件 @
db970c79
...
@@ -25,6 +25,7 @@ extern "C" {
...
@@ -25,6 +25,7 @@ extern "C" {
typedef
void
SJson
;
typedef
void
SJson
;
SJson
*
tjsonCreateObject
();
SJson
*
tjsonCreateObject
();
SJson
*
tjsonCreateArray
();
void
tjsonDelete
(
SJson
*
pJson
);
void
tjsonDelete
(
SJson
*
pJson
);
SJson
*
tjsonAddArrayToObject
(
SJson
*
pJson
,
const
char
*
pName
);
SJson
*
tjsonAddArrayToObject
(
SJson
*
pJson
,
const
char
*
pName
);
...
...
include/util/tuuid.h
0 → 100644
浏览文件 @
db970c79
/*
* 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 "os.h"
#include "taoserror.h"
#include "thash.h"
/**
* Generate an non-negative signed 32bit id
*+------------+-----+-----------+---------------+
*| uid|localIp| PId | timestamp | serial number |
*+------------+-----+-----------+---------------+
*| 6bit |6bit | 12bit | 8bit |
*+------------+-----+-----------+---------------+
* @return
*/
int32_t
tGenIdPI32
(
void
);
/**
* Generate an non-negative signed 64bit id
*+------------+-----+-----------+---------------+
*| uid|localIp| PId | timestamp | serial number |
*+------------+-----+-----------+---------------+
*| 12bit |12bit|24bit |16bit |
*+------------+-----+-----------+---------------+
* @return
*/
int64_t
tGenIdPI64
(
void
);
source/client/inc/clientInt.h
浏览文件 @
db970c79
...
@@ -21,6 +21,7 @@ extern "C" {
...
@@ -21,6 +21,7 @@ extern "C" {
#endif
#endif
#include "parser.h"
#include "parser.h"
#include "planner.h"
#include "query.h"
#include "query.h"
#include "taos.h"
#include "taos.h"
#include "tcommon.h"
#include "tcommon.h"
...
@@ -229,6 +230,7 @@ void setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t
...
@@ -229,6 +230,7 @@ void setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t
int32_t
buildRequest
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
,
SRequestObj
**
pRequest
);
int32_t
buildRequest
(
STscObj
*
pTscObj
,
const
char
*
sql
,
int
sqlLen
,
SRequestObj
**
pRequest
);
int32_t
parseSql
(
SRequestObj
*
pRequest
,
SQuery
**
pQuery
);
int32_t
parseSql
(
SRequestObj
*
pRequest
,
SQuery
**
pQuery
);
int32_t
getPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SQueryPlan
**
pPlan
,
SArray
*
pNodeList
);
// --- heartbeat
// --- heartbeat
// global, called by mgmt
// global, called by mgmt
...
...
source/client/src/clientImpl.c
浏览文件 @
db970c79
#include "clientInt.h"
#include "clientInt.h"
#include "clientLog.h"
#include "clientLog.h"
#include "parser.h"
#include "planner.h"
#include "scheduler.h"
#include "scheduler.h"
#include "tdatablock.h"
#include "tdatablock.h"
#include "tdef.h"
#include "tdef.h"
...
@@ -195,11 +193,7 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
...
@@ -195,11 +193,7 @@ int32_t execDdlQuery(SRequestObj* pRequest, SQuery* pQuery) {
int32_t
getPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SQueryPlan
**
pPlan
,
SArray
*
pNodeList
)
{
int32_t
getPlan
(
SRequestObj
*
pRequest
,
SQuery
*
pQuery
,
SQueryPlan
**
pPlan
,
SArray
*
pNodeList
)
{
pRequest
->
type
=
pQuery
->
msgType
;
pRequest
->
type
=
pQuery
->
msgType
;
SPlanContext
cxt
=
{
.
queryId
=
pRequest
->
requestId
,
.
pAstRoot
=
pQuery
->
pRoot
,
.
acctId
=
pRequest
->
pTscObj
->
acctId
};
SPlanContext
cxt
=
{
.
queryId
=
pRequest
->
requestId
,
.
pAstRoot
=
pQuery
->
pRoot
,
.
acctId
=
pRequest
->
pTscObj
->
acctId
};
int32_t
code
=
qCreateQueryPlan
(
&
cxt
,
pPlan
,
pNodeList
);
return
qCreateQueryPlan
(
&
cxt
,
pPlan
,
pNodeList
);
if
(
code
!=
0
)
{
return
code
;
}
return
code
;
}
}
void
setResSchemaInfo
(
SReqResultInfo
*
pResInfo
,
const
SSchema
*
pSchema
,
int32_t
numOfCols
)
{
void
setResSchemaInfo
(
SReqResultInfo
*
pResInfo
,
const
SSchema
*
pSchema
,
int32_t
numOfCols
)
{
...
@@ -215,7 +209,6 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
...
@@ -215,7 +209,6 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t
}
}
}
}
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
)
{
int32_t
scheduleQuery
(
SRequestObj
*
pRequest
,
SQueryPlan
*
pDag
,
SArray
*
pNodeList
)
{
void
*
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
;
void
*
pTransporter
=
pRequest
->
pTscObj
->
pAppInfo
->
pTransporter
;
...
...
source/client/src/tmq.c
浏览文件 @
db970c79
...
@@ -459,7 +459,7 @@ void tmq_conf_set_offset_commit_cb(tmq_conf_t* conf, tmq_commit_cb* cb) { conf->
...
@@ -459,7 +459,7 @@ void tmq_conf_set_offset_commit_cb(tmq_conf_t* conf, tmq_commit_cb* cb) { conf->
TAOS_RES
*
tmq_create_topic
(
TAOS
*
taos
,
const
char
*
topicName
,
const
char
*
sql
,
int
sqlLen
)
{
TAOS_RES
*
tmq_create_topic
(
TAOS
*
taos
,
const
char
*
topicName
,
const
char
*
sql
,
int
sqlLen
)
{
STscObj
*
pTscObj
=
(
STscObj
*
)
taos
;
STscObj
*
pTscObj
=
(
STscObj
*
)
taos
;
SRequestObj
*
pRequest
=
NULL
;
SRequestObj
*
pRequest
=
NULL
;
SQuery
*
pQueryNode
=
NULL
;
SQuery
*
pQueryNode
=
NULL
;
char
*
pStr
=
NULL
;
char
*
pStr
=
NULL
;
terrno
=
TSDB_CODE_SUCCESS
;
terrno
=
TSDB_CODE_SUCCESS
;
...
@@ -482,21 +482,19 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
...
@@ -482,21 +482,19 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
}
}
tscDebug
(
"start to create topic, %s"
,
topicName
);
tscDebug
(
"start to create topic, %s"
,
topicName
);
#if 0
CHECK_CODE_GOTO
(
buildRequest
(
pTscObj
,
sql
,
sqlLen
,
&
pRequest
),
_return
);
CHECK_CODE_GOTO
(
buildRequest
(
pTscObj
,
sql
,
sqlLen
,
&
pRequest
),
_return
);
CHECK_CODE_GOTO
(
parseSql
(
pRequest
,
&
pQueryNode
),
_return
);
CHECK_CODE_GOTO
(
parseSql
(
pRequest
,
&
pQueryNode
),
_return
);
SQueryStmtInfo* pQueryStmtInfo = (SQueryStmtInfo*)pQueryNode;
pQueryNode
->
streamQuery
=
true
;
pQueryStmtInfo->info.continueQuery = true;
// todo check for invalid sql statement and return with error code
// todo check for invalid sql statement and return with error code
SSchema
*
schema
=
NULL
;
SSchema
*
schema
=
NULL
;
int32_t
numOfCols
=
0
;
int32_t
numOfCols
=
0
;
CHECK_CODE_GOTO(qCreateQueryDag(pQueryNode, &pRequest->body.pDag, &schema, &numOfCols, NULL, pRequest->requestId),
CHECK_CODE_GOTO
(
getPlan
(
pRequest
,
pQueryNode
,
&
pRequest
->
body
.
pDag
,
NULL
),
_return
);
_return);
pStr = q
Dag
ToString(pRequest->body.pDag);
pStr
=
q
QueryPlan
ToString
(
pRequest
->
body
.
pDag
);
if
(
pStr
==
NULL
)
{
if
(
pStr
==
NULL
)
{
goto
_return
;
goto
_return
;
}
}
...
@@ -506,7 +504,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
...
@@ -506,7 +504,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
// The topic should be related to a database that the queried table is belonged to.
// The topic should be related to a database that the queried table is belonged to.
SName
name
=
{
0
};
SName
name
=
{
0
};
char
dbName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
char
dbName
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
tNameGetFullDbName(&((SQueryStmtInfo*)pQueryNode)->pTableMetaInfo[0]->name, dbName);
//
tNameGetFullDbName(&((SQueryStmtInfo*)pQueryNode)->pTableMetaInfo[0]->name, dbName);
tNameFromString
(
&
name
,
dbName
,
T_NAME_ACCT
|
T_NAME_DB
);
tNameFromString
(
&
name
,
dbName
,
T_NAME_ACCT
|
T_NAME_DB
);
tNameFromString
(
&
name
,
topicName
,
T_NAME_TABLE
);
tNameFromString
(
&
name
,
topicName
,
T_NAME_TABLE
);
...
@@ -538,7 +536,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
...
@@ -538,7 +536,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i
asyncSendMsgToServer
(
pTscObj
->
pAppInfo
->
pTransporter
,
&
epSet
,
&
transporterId
,
sendInfo
);
asyncSendMsgToServer
(
pTscObj
->
pAppInfo
->
pTransporter
,
&
epSet
,
&
transporterId
,
sendInfo
);
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
tsem_wait
(
&
pRequest
->
body
.
rspSem
);
#endif
_return:
_return:
qDestroyQuery
(
pQueryNode
);
qDestroyQuery
(
pQueryNode
);
/*if (sendInfo != NULL) {*/
/*if (sendInfo != NULL) {*/
...
...
source/common/src/tdatablock.c
浏览文件 @
db970c79
...
@@ -1059,10 +1059,10 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF
...
@@ -1059,10 +1059,10 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF
// destroyTupleIndex(index);
// destroyTupleIndex(index);
}
}
void
blockDataClearup
(
SSDataBlock
*
pDataBlock
,
bool
hasVarCol
)
{
void
blockDataClearup
(
SSDataBlock
*
pDataBlock
)
{
pDataBlock
->
info
.
rows
=
0
;
pDataBlock
->
info
.
rows
=
0
;
if
(
hasVarCol
)
{
if
(
pDataBlock
->
info
.
hasVarCol
)
{
for
(
int32_t
i
=
0
;
i
<
pDataBlock
->
info
.
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pDataBlock
->
info
.
numOfCols
;
++
i
)
{
SColumnInfoData
*
p
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
i
);
SColumnInfoData
*
p
=
taosArrayGet
(
pDataBlock
->
pDataBlock
,
i
);
...
@@ -1148,7 +1148,9 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) {
...
@@ -1148,7 +1148,9 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) {
SSDataBlock
*
pBlock
=
calloc
(
1
,
sizeof
(
SSDataBlock
));
SSDataBlock
*
pBlock
=
calloc
(
1
,
sizeof
(
SSDataBlock
));
pBlock
->
pDataBlock
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColumnInfoData
));
pBlock
->
pDataBlock
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColumnInfoData
));
pBlock
->
info
.
numOfCols
=
numOfCols
;
pBlock
->
info
.
numOfCols
=
numOfCols
;
pBlock
->
info
.
hasVarCol
=
pDataBlock
->
info
.
hasVarCol
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
colInfo
=
{
0
};
SColumnInfoData
colInfo
=
{
0
};
...
...
source/common/src/tmsg.c
浏览文件 @
db970c79
...
@@ -2666,7 +2666,6 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
...
@@ -2666,7 +2666,6 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
sql
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
sql
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
physicalPlan
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
physicalPlan
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
logicalPlan
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
&
encoder
,
pReq
->
logicalPlan
)
<
0
)
return
-
1
;
tEndEncode
(
&
encoder
);
tEndEncode
(
&
encoder
);
int32_t
tlen
=
encoder
.
pos
;
int32_t
tlen
=
encoder
.
pos
;
...
...
source/dnode/mgmt/container/src/dndWorker.c
浏览文件 @
db970c79
...
@@ -111,4 +111,4 @@ int32_t dndWriteMsgToWorker(SDnodeWorker *pWorker, void *pCont, int32_t contLen)
...
@@ -111,4 +111,4 @@ int32_t dndWriteMsgToWorker(SDnodeWorker *pWorker, void *pCont, int32_t contLen)
}
}
return
0
;
return
0
;
}
}
\ No newline at end of file
source/dnode/mgmt/snode/inc/smInt.h
浏览文件 @
db970c79
...
@@ -26,11 +26,11 @@ typedef struct SSnodeMgmt {
...
@@ -26,11 +26,11 @@ typedef struct SSnodeMgmt {
int32_t
refCount
;
int32_t
refCount
;
int8_t
deployed
;
int8_t
deployed
;
int8_t
dropped
;
int8_t
dropped
;
int8_t
uniqueWorkerInUse
;
SSnode
*
pSnode
;
SSnode
*
pSnode
;
SRWLatch
latch
;
SRWLatch
latch
;
SDnodeWorker
writeWorker
;
SArray
*
uniqueWorkers
;
// SArray<SDnodeWorker*>
SProcObj
*
pProcess
;
SDnodeWorker
sharedWorker
;
bool
singleProc
;
}
SSnodeMgmt
;
}
SSnodeMgmt
;
void
smGetMgmtFp
(
SMgmtWrapper
*
pMgmt
);
void
smGetMgmtFp
(
SMgmtWrapper
*
pMgmt
);
...
...
source/dnode/mgmt/snode/src/smMgmt.c
浏览文件 @
db970c79
...
@@ -20,7 +20,21 @@
...
@@ -20,7 +20,21 @@
// #include "dndWorker.h"
// #include "dndWorker.h"
#if 0
#if 0
static void dndProcessSnodeQueue(SDnode *pDnode, SRpcMsg *pMsg);
typedef struct {
int32_t vgId;
int32_t refCount;
int32_t snVersion;
int8_t dropped;
char *path;
SSnode *pImpl;
STaosQueue *pSharedQ;
STaosQueue *pUniqueQ;
} SSnodeObj;
static void dndProcessSnodeSharedQueue(SDnode *pDnode, SRpcMsg *pMsg);
static void dndProcessSnodeUniqueQueue(SDnode *pDnode, STaosQall *qall, int32_t numOfMsgs);
static SSnode *dndAcquireSnode(SDnode *pDnode) {
static SSnode *dndAcquireSnode(SDnode *pDnode) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
SSnodeMgmt *pMgmt = &pDnode->smgmt;
...
@@ -153,8 +167,21 @@ static int32_t dndWriteSnodeFile(SDnode *pDnode) {
...
@@ -153,8 +167,21 @@ static int32_t dndWriteSnodeFile(SDnode *pDnode) {
static int32_t dndStartSnodeWorker(SDnode *pDnode) {
static int32_t dndStartSnodeWorker(SDnode *pDnode) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
SSnodeMgmt *pMgmt = &pDnode->smgmt;
if (dndInitWorker(pDnode, &pMgmt->writeWorker, DND_WORKER_SINGLE, "snode-write", 0, 1, dndProcessSnodeQueue) != 0) {
pMgmt->uniqueWorkers = taosArrayInit(0, sizeof(void *));
dError("failed to start snode write worker since %s", terrstr());
for (int32_t i = 0; i < SND_UNIQUE_THREAD_NUM; i++) {
SDnodeWorker *pUniqueWorker = malloc(sizeof(SDnodeWorker));
if (pUniqueWorker == NULL) {
return -1;
}
if (dndInitWorker(pDnode, pUniqueWorker, DND_WORKER_MULTI, "snode-unique", 1, 1, dndProcessSnodeSharedQueue) != 0) {
dError("failed to start snode unique worker since %s", terrstr());
return -1;
}
taosArrayPush(pMgmt->uniqueWorkers, &pUniqueWorker);
}
if (dndInitWorker(pDnode, &pMgmt->sharedWorker, DND_WORKER_SINGLE, "snode-shared", SND_SHARED_THREAD_NUM,
SND_SHARED_THREAD_NUM, dndProcessSnodeSharedQueue)) {
dError("failed to start snode shared worker since %s", terrstr());
return -1;
return -1;
}
}
...
@@ -170,9 +197,13 @@ static void dndStopSnodeWorker(SDnode *pDnode) {
...
@@ -170,9 +197,13 @@ static void dndStopSnodeWorker(SDnode *pDnode) {
while (pMgmt->refCount > 0) {
while (pMgmt->refCount > 0) {
taosMsleep(10);
taosMsleep(10);
}
}
dndCleanupWorker(&pMgmt->writeWorker);
for (int32_t i = 0; i < taosArrayGetSize(pMgmt->uniqueWorkers); i++) {
SDnodeWorker *worker = taosArrayGetP(pMgmt->uniqueWorkers, i);
dndCleanupWorker(worker);
}
taosArrayDestroy(pMgmt->uniqueWorkers);
}
}
static void dndBuildSnodeOption(SDnode *pDnode, SSnodeOpt *pOption) {
static void dndBuildSnodeOption(SDnode *pDnode, SSnodeOpt *pOption) {
...
@@ -293,17 +324,36 @@ int32_t smProcessDropReq(SDnode *pDnode, SRpcMsg *pReq) {
...
@@ -293,17 +324,36 @@ int32_t smProcessDropReq(SDnode *pDnode, SRpcMsg *pReq) {
}
}
}
}
static void dndProcessSnode
Queue(SDnode *pDnode, SRpcMsg *pMsg
) {
static void dndProcessSnode
UniqueQueue(SDnode *pDnode, STaosQall *qall, int32_t numOfMsgs
) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
SSnodeMgmt *pMgmt = &pDnode->smgmt;
SRpcMsg *pRsp = NULL;
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
SSnode *pSnode = dndAcquireSnode(pDnode);
SSnode *pSnode = dndAcquireSnode(pDnode);
if (pSnode != NULL) {
if (pSnode != NULL) {
code = sndProcessMsg(pSnode, pMsg, &pRsp);
for (int32_t i = 0; i < numOfMsgs; i++) {
SRpcMsg *pMsg = NULL;
taosGetQitem(qall, (void **)&pMsg);
sndProcessUMsg(pSnode, pMsg);
rpcFreeCont(pMsg->pCont);
taosFreeQitem(pMsg);
}
}
}
dndReleaseSnode(pDnode, pSnode);
dndReleaseSnode(pDnode, pSnode);
}
static void dndProcessSnodeSharedQueue(SDnode *pDnode, SRpcMsg *pMsg) {
SSnodeMgmt *pMgmt = &pDnode->smgmt;
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
SSnode *pSnode = dndAcquireSnode(pDnode);
if (pSnode != NULL) {
code = sndProcessSMsg(pSnode, pMsg);
}
dndReleaseSnode(pDnode, pSnode);
#if 0
if (pMsg->msgType & 1u) {
if (pMsg->msgType & 1u) {
if (pRsp != NULL) {
if (pRsp != NULL) {
pRsp->ahandle = pMsg->ahandle;
pRsp->ahandle = pMsg->ahandle;
...
@@ -315,11 +365,58 @@ static void dndProcessSnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) {
...
@@ -315,11 +365,58 @@ static void dndProcessSnodeQueue(SDnode *pDnode, SRpcMsg *pMsg) {
rpcSendResponse(&rpcRsp);
rpcSendResponse(&rpcRsp);
}
}
}
}
#endif
rpcFreeCont(pMsg->pCont);
rpcFreeCont(pMsg->pCont);
taosFreeQitem(pMsg);
taosFreeQitem(pMsg);
}
}
static FORCE_INLINE int32_t dndGetSWIdFromMsg(SRpcMsg *pMsg) {
SMsgHead *pHead = pMsg->pCont;
pHead->streamTaskId = htonl(pHead->streamTaskId);
return pHead->streamTaskId % SND_UNIQUE_THREAD_NUM;
}
static void dndWriteSnodeMsgToWorkerByMsg(SDnode *pDnode, SRpcMsg *pMsg) {
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
SSnode *pSnode = dndAcquireSnode(pDnode);
if (pSnode != NULL) {
int32_t index = dndGetSWIdFromMsg(pMsg);
SDnodeWorker *pWorker = taosArrayGetP(pDnode->smgmt.uniqueWorkers, index);
code = dndWriteMsgToWorker(pWorker, pMsg, sizeof(SRpcMsg));
}
dndReleaseSnode(pDnode, pSnode);
if (code != 0) {
if (pMsg->msgType & 1u) {
SRpcMsg rsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code};
rpcSendResponse(&rsp);
}
rpcFreeCont(pMsg->pCont);
}
}
static void dndWriteSnodeMsgToMgmtWorker(SDnode *pDnode, SRpcMsg *pMsg) {
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
SSnode *pSnode = dndAcquireSnode(pDnode);
if (pSnode != NULL) {
SDnodeWorker *pWorker = taosArrayGet(pDnode->smgmt.uniqueWorkers, 0);
code = dndWriteMsgToWorker(pWorker, pMsg, sizeof(SRpcMsg));
}
dndReleaseSnode(pDnode, pSnode);
if (code != 0) {
if (pMsg->msgType & 1u) {
SRpcMsg rsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code};
rpcSendResponse(&rsp);
}
rpcFreeCont(pMsg->pCont);
}
}
static void dndWriteSnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpcMsg *pMsg) {
static void dndWriteSnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpcMsg *pMsg) {
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED;
...
@@ -338,8 +435,16 @@ static void dndWriteSnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpc
...
@@ -338,8 +435,16 @@ static void dndWriteSnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpc
}
}
}
}
void dndProcessSnodeWriteMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
void dndProcessSnodeMgmtMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
dndWriteSnodeMsgToWorker(pDnode, &pDnode->smgmt.writeWorker, pMsg);
dndWriteSnodeMsgToMgmtWorker(pDnode, pMsg);
}
void dndProcessSnodeUniqueMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
dndWriteSnodeMsgToWorkerByMsg(pDnode, pMsg);
}
void dndProcessSnodeSharedMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
dndWriteSnodeMsgToWorker(pDnode, &pDnode->smgmt.sharedWorker, pMsg);
}
}
int32_t dndInitSnode(SDnode *pDnode) {
int32_t dndInitSnode(SDnode *pDnode) {
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
db970c79
...
@@ -679,6 +679,12 @@ static FORCE_INLINE void* tDecodeSMqConsumerObj(void* buf, SMqConsumerObj* pCons
...
@@ -679,6 +679,12 @@ static FORCE_INLINE void* tDecodeSMqConsumerObj(void* buf, SMqConsumerObj* pCons
return
buf
;
return
buf
;
}
}
typedef
struct
{
int32_t
taskId
;
int32_t
level
;
SSubplan
*
plan
;
}
SStreamTaskMeta
;
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
name
[
TSDB_TOPIC_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
char
db
[
TSDB_DB_FNAME_LEN
];
...
@@ -687,12 +693,14 @@ typedef struct {
...
@@ -687,12 +693,14 @@ typedef struct {
int64_t
uid
;
int64_t
uid
;
int64_t
dbUid
;
int64_t
dbUid
;
int32_t
version
;
int32_t
version
;
int32_t
vgNum
;
SRWLatch
lock
;
SRWLatch
lock
;
int8_t
status
;
int8_t
status
;
// int32_t sqlLen;
// int32_t sqlLen;
char
*
sql
;
char
*
sql
;
char
*
logicalPlan
;
char
*
logicalPlan
;
char
*
physicalPlan
;
char
*
physicalPlan
;
SArray
*
tasks
;
// SArray<SArray<SStreamTaskMeta>>
}
SStreamObj
;
}
SStreamObj
;
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
);
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
);
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
db970c79
...
@@ -1292,11 +1292,11 @@ static int32_t mndGetDbMeta(SMndMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta
...
@@ -1292,11 +1292,11 @@ static int32_t mndGetDbMeta(SMndMsg *pReq, SShowObj *pShow, STableMetaRsp *pMeta
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
cols
++
;
cols
++
;
pShow
->
bytes
[
cols
]
=
1
;
//
pShow->bytes[cols] = 1;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TINYINT
;
//
pSchema[cols].type = TSDB_DATA_TYPE_TINYINT;
strcpy
(
pSchema
[
cols
].
name
,
"update"
);
//
strcpy(pSchema[cols].name, "update");
pSchema
[
cols
].
bytes
=
pShow
->
bytes
[
cols
];
//
pSchema[cols].bytes = pShow->bytes[cols];
cols
++
;
//
cols++;
pMeta
->
numOfColumns
=
cols
;
pMeta
->
numOfColumns
=
cols
;
pShow
->
numOfColumns
=
cols
;
pShow
->
numOfColumns
=
cols
;
...
@@ -1432,9 +1432,9 @@ static int32_t mndRetrieveDbs(SMndMsg *pReq, SShowObj *pShow, char *data, int32_
...
@@ -1432,9 +1432,9 @@ static int32_t mndRetrieveDbs(SMndMsg *pReq, SShowObj *pShow, char *data, int32_
STR_WITH_SIZE_TO_VARSTR
(
pWrite
,
prec
,
2
);
STR_WITH_SIZE_TO_VARSTR
(
pWrite
,
prec
,
2
);
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
//
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
*
(
int8_t
*
)
pWrite
=
pDb
->
cfg
.
update
;
//
*(int8_t *)pWrite = pDb->cfg.update;
cols
++
;
//
cols++;
numOfRows
++
;
numOfRows
++
;
sdbRelease
(
pSdb
,
pDb
);
sdbRelease
(
pSdb
,
pDb
);
...
...
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
db970c79
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "mndOffset.h"
#include "mndOffset.h"
#include "mndShow.h"
#include "mndShow.h"
#include "mndStb.h"
#include "mndStb.h"
#include "mndStream.h"
#include "mndSubscribe.h"
#include "mndSubscribe.h"
#include "mndTopic.h"
#include "mndTopic.h"
#include "mndTrans.h"
#include "mndTrans.h"
...
@@ -28,10 +29,84 @@
...
@@ -28,10 +29,84 @@
#include "mndVgroup.h"
#include "mndVgroup.h"
#include "tcompare.h"
#include "tcompare.h"
#include "tname.h"
#include "tname.h"
#include "tuuid.h"
int32_t
mndScheduleStream
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SVgObj
*
pVgroup
=
NULL
;
SQueryPlan
*
pPlan
=
qStringToQueryPlan
(
pStream
->
physicalPlan
);
if
(
pPlan
==
NULL
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
return
-
1
;
}
ASSERT
(
pStream
->
vgNum
==
0
);
int32_t
levelNum
=
LIST_LENGTH
(
pPlan
->
pSubplans
);
pStream
->
tasks
=
taosArrayInit
(
levelNum
,
sizeof
(
SArray
));
for
(
int32_t
i
=
0
;
i
<
levelNum
;
i
++
)
{
SArray
*
taskOneLevel
=
taosArrayInit
(
0
,
sizeof
(
SStreamTaskMeta
));
SNodeListNode
*
inner
=
nodesListGetNode
(
pPlan
->
pSubplans
,
i
);
int32_t
opNum
=
LIST_LENGTH
(
inner
->
pNodeList
);
ASSERT
(
opNum
==
1
);
SSubplan
*
plan
=
nodesListGetNode
(
inner
->
pNodeList
,
0
);
if
(
i
==
0
)
{
ASSERT
(
plan
->
type
==
SUBPLAN_TYPE_SCAN
);
void
*
pIter
=
NULL
;
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_VGROUP
,
pIter
,
(
void
**
)
&
pVgroup
);
if
(
pIter
==
NULL
)
break
;
if
(
pVgroup
->
dbUid
!=
pStream
->
dbUid
)
{
sdbRelease
(
pSdb
,
pVgroup
);
continue
;
}
pStream
->
vgNum
++
;
plan
->
execNode
.
nodeId
=
pVgroup
->
vgId
;
plan
->
execNode
.
epSet
=
mndGetVgroupEpset
(
pMnode
,
pVgroup
);
SStreamTaskMeta
task
=
{
.
taskId
=
tGenIdPI32
(),
.
level
=
i
,
.
plan
=
plan
,
};
// send to vnode
taosArrayPush
(
taskOneLevel
,
&
task
);
}
}
else
if
(
plan
->
subplanType
==
SUBPLAN_TYPE_SCAN
)
{
// duplicatable
int32_t
parallel
=
0
;
// if no snode, parallel set to fetch thread num in vnode
// if has snode, set to shared thread num in snode
parallel
=
SND_SHARED_THREAD_NUM
;
for
(
int32_t
j
=
0
;
j
<
parallel
;
j
++
)
{
SStreamTaskMeta
task
=
{
.
taskId
=
tGenIdPI32
(),
.
level
=
i
,
.
plan
=
plan
,
};
taosArrayPush
(
taskOneLevel
,
&
task
);
}
}
else
{
// not duplicatable
SStreamTaskMeta
task
=
{
.
taskId
=
tGenIdPI32
(),
.
level
=
i
,
.
plan
=
plan
,
};
taosArrayPush
(
taskOneLevel
,
&
task
);
}
taosArrayPush
(
pStream
->
tasks
,
taskOneLevel
);
}
return
0
;
}
int32_t
mndSchedInitSubEp
(
SMnode
*
pMnode
,
const
SMqTopicObj
*
pTopic
,
SMqSubscribeObj
*
pSub
)
{
int32_t
mndSchedInitSubEp
(
SMnode
*
pMnode
,
const
SMqTopicObj
*
pTopic
,
SMqSubscribeObj
*
pSub
)
{
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
SVgObj
*
pVgroup
=
NULL
;
SVgObj
*
pVgroup
=
NULL
;
SQueryPlan
*
pPlan
=
qStringToQueryPlan
(
pTopic
->
physicalPlan
);
SQueryPlan
*
pPlan
=
qStringToQueryPlan
(
pTopic
->
physicalPlan
);
if
(
pPlan
==
NULL
)
{
if
(
pPlan
==
NULL
)
{
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
terrno
=
TSDB_CODE_QRY_INVALID_INPUT
;
...
...
source/dnode/mnode/impl/src/mnode.c
浏览文件 @
db970c79
...
@@ -30,6 +30,7 @@
...
@@ -30,6 +30,7 @@
#include "mndShow.h"
#include "mndShow.h"
#include "mndSnode.h"
#include "mndSnode.h"
#include "mndStb.h"
#include "mndStb.h"
#include "mndStream.h"
#include "mndSubscribe.h"
#include "mndSubscribe.h"
#include "mndSync.h"
#include "mndSync.h"
#include "mndTelem.h"
#include "mndTelem.h"
...
@@ -214,6 +215,7 @@ static int32_t mndInitSteps(SMnode *pMnode) {
...
@@ -214,6 +215,7 @@ static int32_t mndInitSteps(SMnode *pMnode) {
if
(
mndAllocStep
(
pMnode
,
"mnode-user"
,
mndInitUser
,
mndCleanupUser
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-user"
,
mndInitUser
,
mndCleanupUser
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-auth"
,
mndInitAuth
,
mndCleanupAuth
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-auth"
,
mndInitAuth
,
mndCleanupAuth
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-acct"
,
mndInitAcct
,
mndCleanupAcct
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-acct"
,
mndInitAcct
,
mndCleanupAcct
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-stream"
,
mndInitStream
,
mndCleanupStream
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-topic"
,
mndInitTopic
,
mndCleanupTopic
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-topic"
,
mndInitTopic
,
mndCleanupTopic
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-consumer"
,
mndInitConsumer
,
mndCleanupConsumer
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-consumer"
,
mndInitConsumer
,
mndCleanupConsumer
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-subscribe"
,
mndInitSubscribe
,
mndCleanupSubscribe
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-subscribe"
,
mndInitSubscribe
,
mndCleanupSubscribe
)
!=
0
)
return
-
1
;
...
...
source/dnode/mnode/impl/test/db/db.cpp
浏览文件 @
db970c79
...
@@ -27,7 +27,7 @@ Testbase MndTestDb::test;
...
@@ -27,7 +27,7 @@ Testbase MndTestDb::test;
TEST_F
(
MndTestDb
,
01
_ShowDb
)
{
TEST_F
(
MndTestDb
,
01
_ShowDb
)
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
1
8
);
CHECK_META
(
"show databases"
,
1
7
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
-
1
+
VARSTR_HEADER_SIZE
,
"name"
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
-
1
+
VARSTR_HEADER_SIZE
,
"name"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"vgroups"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"vgroups"
);
...
@@ -45,7 +45,7 @@ TEST_F(MndTestDb, 01_ShowDb) {
...
@@ -45,7 +45,7 @@ TEST_F(MndTestDb, 01_ShowDb) {
CHECK_SCHEMA
(
14
,
TSDB_DATA_TYPE_TINYINT
,
1
,
"comp"
);
CHECK_SCHEMA
(
14
,
TSDB_DATA_TYPE_TINYINT
,
1
,
"comp"
);
CHECK_SCHEMA
(
15
,
TSDB_DATA_TYPE_TINYINT
,
1
,
"cachelast"
);
CHECK_SCHEMA
(
15
,
TSDB_DATA_TYPE_TINYINT
,
1
,
"cachelast"
);
CHECK_SCHEMA
(
16
,
TSDB_DATA_TYPE_BINARY
,
3
+
VARSTR_HEADER_SIZE
,
"precision"
);
CHECK_SCHEMA
(
16
,
TSDB_DATA_TYPE_BINARY
,
3
+
VARSTR_HEADER_SIZE
,
"precision"
);
CHECK_SCHEMA
(
17
,
TSDB_DATA_TYPE_TINYINT
,
1
,
"update"
);
//
CHECK_SCHEMA(17, TSDB_DATA_TYPE_TINYINT, 1, "update");
test
.
SendShowRetrieveReq
();
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
...
@@ -85,7 +85,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
...
@@ -85,7 +85,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
}
}
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
1
8
);
CHECK_META
(
"show databases"
,
1
7
);
test
.
SendShowRetrieveReq
();
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
...
@@ -173,7 +173,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
...
@@ -173,7 +173,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
test
.
Restart
();
test
.
Restart
();
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
1
8
);
CHECK_META
(
"show databases"
,
1
7
);
test
.
SendShowRetrieveReq
();
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
...
@@ -215,7 +215,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
...
@@ -215,7 +215,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) {
}
}
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
1
8
);
CHECK_META
(
"show databases"
,
1
7
);
test
.
SendShowRetrieveReq
();
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
...
@@ -255,7 +255,7 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
...
@@ -255,7 +255,7 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) {
}
}
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
1
8
);
CHECK_META
(
"show databases"
,
1
7
);
test
.
SendShowRetrieveReq
();
test
.
SendShowRetrieveReq
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
...
...
source/dnode/snode/inc/sndInt.h
浏览文件 @
db970c79
...
@@ -30,47 +30,48 @@ extern "C" {
...
@@ -30,47 +30,48 @@ extern "C" {
#endif
#endif
enum
{
enum
{
STREAM_STATUS__R
EADY
=
1
,
STREAM_STATUS__R
UNNING
=
1
,
STREAM_STATUS__STOPPED
,
STREAM_STATUS__STOPPED
,
STREAM_STATUS__CREATING
,
STREAM_STATUS__CREATING
,
STREAM_STATUS__STOPING
,
STREAM_STATUS__STOPING
,
STREAM_STATUS__RES
UM
ING
,
STREAM_STATUS__RES
TOR
ING
,
STREAM_STATUS__DELETING
,
STREAM_STATUS__DELETING
,
};
};
enum
{
enum
{
STREAM_
RUNNER
__RUNNING
=
1
,
STREAM_
TASK_STATUS
__RUNNING
=
1
,
STREAM_
RUNNER
__STOP
,
STREAM_
TASK_STATUS
__STOP
,
};
};
typedef
struct
{
SHashObj
*
pHash
;
// taskId -> streamTask
}
SStreamMeta
;
typedef
struct
SSnode
{
typedef
struct
SSnode
{
SSnodeOpt
cfg
;
SStreamMeta
*
pMeta
;
SSnodeOpt
cfg
;
}
SSnode
;
}
SSnode
;
typedef
struct
{
typedef
struct
{
int64_t
streamId
;
int64_t
streamId
;
int32_t
taskId
;
int32_t
IdxInLevel
;
int32_t
IdxInLevel
;
int32_t
level
;
int32_t
level
;
}
SStreamInfo
;
}
SStream
Task
Info
;
typedef
struct
{
typedef
struct
{
SStreamInfo
meta
;
SStreamTaskInfo
meta
;
int8_t
status
;
int8_t
status
;
void
*
executor
;
void
*
executor
;
STaosQueue
*
queue
;
void
*
stateStore
;
void
*
stateStore
;
// storage handle
// storage handle
}
SStreamRunner
;
}
SStreamTask
;
typedef
struct
{
SHashObj
*
pHash
;
}
SStreamMeta
;
int32_t
sndCreate
Stream
();
int32_t
sndCreate
Task
();
int32_t
sndDrop
Stream
(
);
int32_t
sndDrop
TaskOfStream
(
int64_t
streamId
);
int32_t
sndStop
Stream
(
);
int32_t
sndStop
TaskOfStream
(
int64_t
streamId
);
int32_t
sndResume
Stream
(
);
int32_t
sndResume
TaskOfStream
(
int64_t
streamId
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/snode/src/snode.c
浏览文件 @
db970c79
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
*/
*/
#include "sndInt.h"
#include "sndInt.h"
#include "tuuid.h"
SSnode
*
sndOpen
(
const
char
*
path
,
const
SSnodeOpt
*
pOption
)
{
SSnode
*
sndOpen
(
const
char
*
path
,
const
SSnodeOpt
*
pOption
)
{
SSnode
*
pSnode
=
calloc
(
1
,
sizeof
(
SSnode
));
SSnode
*
pSnode
=
calloc
(
1
,
sizeof
(
SSnode
));
...
@@ -31,3 +32,25 @@ int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -31,3 +32,25 @@ int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
}
}
void
sndDestroy
(
const
char
*
path
)
{}
void
sndDestroy
(
const
char
*
path
)
{}
static
int32_t
sndDeployTask
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
)
{
SStreamTask
*
task
=
malloc
(
sizeof
(
SStreamTask
));
if
(
task
==
NULL
)
{
return
-
1
;
}
task
->
meta
.
taskId
=
tGenIdPI32
();
taosHashPut
(
pSnode
->
pMeta
->
pHash
,
&
task
->
meta
.
taskId
,
sizeof
(
int32_t
),
&
task
,
sizeof
(
void
*
));
return
0
;
}
int32_t
sndProcessUMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
)
{
// stream deployment
// stream stop/resume
// operator exec
return
0
;
}
int32_t
sndProcessSMsg
(
SSnode
*
pSnode
,
SRpcMsg
*
pMsg
)
{
// operator exec
return
0
;
}
source/dnode/vnode/inc/tsdb.h
浏览文件 @
db970c79
...
@@ -95,6 +95,7 @@ int tsdbCommit(STsdb *pTsdb);
...
@@ -95,6 +95,7 @@ int tsdbCommit(STsdb *pTsdb);
* @return int32_t
* @return int32_t
*/
*/
int32_t
tsdbInsertTSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
int32_t
tsdbInsertTSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
int32_t
tsdbUpdateSmaWindow
(
STsdb
*
pTsdb
,
int8_t
smaType
,
char
*
msg
);
/**
/**
* @brief Insert RSma(Time-range-wise Rollup SMA) data.
* @brief Insert RSma(Time-range-wise Rollup SMA) data.
...
@@ -105,6 +106,12 @@ int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg);
...
@@ -105,6 +106,12 @@ int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg);
*/
*/
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
int32_t
tsdbInsertRSmaData
(
STsdb
*
pTsdb
,
char
*
msg
);
// TODO: This is the basic params, and should wrap the params to a queryHandle.
int32_t
tsdbGetTSmaData
(
STsdb
*
pTsdb
,
STSmaDataWrapper
*
pData
,
int64_t
indexUid
,
int64_t
interval
,
int8_t
intervalUnit
,
tb_uid_t
tableUid
,
col_id_t
colId
,
TSKEY
querySkey
,
int32_t
nMaxResult
);
// STsdbCfg
// STsdbCfg
int
tsdbOptionsInit
(
STsdbCfg
*
);
int
tsdbOptionsInit
(
STsdbCfg
*
);
void
tsdbOptionsClear
(
STsdbCfg
*
);
void
tsdbOptionsClear
(
STsdbCfg
*
);
...
...
source/dnode/vnode/src/inc/tsdbDBDef.h
0 → 100644
浏览文件 @
db970c79
/*
* 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_TSDB_DB_DEF_H_
#define _TD_TSDB_DB_DEF_H_
#include "db.h"
#ifdef __cplusplus
extern
"C"
{
#endif
typedef
struct
SDBFile
SDBFile
;
typedef
DB_ENV
*
TDBEnv
;
struct
SDBFile
{
DB
*
pDB
;
char
*
path
;
};
int32_t
tsdbOpenDBF
(
TDBEnv
pEnv
,
SDBFile
*
pDBF
);
void
tsdbCloseDBF
(
SDBFile
*
pDBF
);
int32_t
tsdbOpenBDBEnv
(
DB_ENV
**
ppEnv
,
const
char
*
path
);
void
tsdbCloseBDBEnv
(
DB_ENV
*
pEnv
);
int32_t
tsdbSaveSmaToDB
(
SDBFile
*
pDBF
,
void
*
key
,
uint32_t
keySize
,
void
*
data
,
uint32_t
dataSize
);
void
*
tsdbGetSmaDataByKey
(
SDBFile
*
pDBF
,
void
*
key
,
uint32_t
keySize
,
uint32_t
*
valueSize
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_TSDB_DB_DEF_H_*/
source/dnode/vnode/src/inc/tsdbDef.h
浏览文件 @
db970c79
...
@@ -27,6 +27,7 @@
...
@@ -27,6 +27,7 @@
#include "ttime.h"
#include "ttime.h"
#include "tsdb.h"
#include "tsdb.h"
#include "tsdbDBDef.h"
#include "tsdbCommit.h"
#include "tsdbCommit.h"
#include "tsdbFS.h"
#include "tsdbFS.h"
#include "tsdbFile.h"
#include "tsdbFile.h"
...
@@ -37,12 +38,15 @@
...
@@ -37,12 +38,15 @@
#include "tsdbReadImpl.h"
#include "tsdbReadImpl.h"
#include "tsdbSma.h"
#include "tsdbSma.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
struct
STsdb
{
struct
STsdb
{
int32_t
vgId
;
int32_t
vgId
;
bool
repoLocked
;
pthread_mutex_t
mutex
;
char
*
path
;
char
*
path
;
STsdbCfg
config
;
STsdbCfg
config
;
STsdbMemTable
*
mem
;
STsdbMemTable
*
mem
;
...
@@ -52,12 +56,17 @@ struct STsdb {
...
@@ -52,12 +56,17 @@ struct STsdb {
STsdbFS
*
fs
;
STsdbFS
*
fs
;
SMeta
*
pMeta
;
SMeta
*
pMeta
;
STfs
*
pTfs
;
STfs
*
pTfs
;
SSmaStat
*
pSmaStat
;
SSmaEnv
*
pTSmaEnv
;
SSmaEnv
*
pRSmaEnv
;
};
};
#define REPO_ID(r) ((r)->vgId)
#define REPO_ID(r) ((r)->vgId)
#define REPO_CFG(r) (&(r)->config)
#define REPO_CFG(r) (&(r)->config)
#define REPO_FS(r) (r)->fs
#define REPO_FS(r) (r)->fs
#define IS_REPO_LOCKED(r) (r)->repoLocked
int
tsdbLockRepo
(
STsdb
*
pTsdb
);
int
tsdbUnlockRepo
(
STsdb
*
pTsdb
);
static
FORCE_INLINE
STSchema
*
tsdbGetTableSchemaImpl
(
STable
*
pTable
,
bool
lock
,
bool
copy
,
int32_t
version
)
{
static
FORCE_INLINE
STSchema
*
tsdbGetTableSchemaImpl
(
STable
*
pTable
,
bool
lock
,
bool
copy
,
int32_t
version
)
{
return
pTable
->
pSchema
;
return
pTable
->
pSchema
;
...
...
source/dnode/vnode/src/inc/tsdbFile.h
浏览文件 @
db970c79
...
@@ -329,21 +329,23 @@ static FORCE_INLINE int tsdbCopyDFile(SDFile* pSrc, SDFile* pDest) {
...
@@ -329,21 +329,23 @@ static FORCE_INLINE int tsdbCopyDFile(SDFile* pSrc, SDFile* pDest) {
// =============== SDFileSet
// =============== SDFileSet
typedef
struct
{
typedef
struct
{
int
fid
;
int
fid
;
int8_t
state
;
// -128~127
int8_t
state
;
// -128~127
uint8_t
ver
;
// 0~255, DFileSet version
uint8_t
ver
;
// 0~255, DFileSet version
uint16_t
reserve
;
uint16_t
reserve
;
SDFile
files
[
TSDB_FILE_MAX
];
SDFile
files
[
TSDB_FILE_MAX
];
}
SDFileSet
;
}
SDFileSet
;
typedef
struct
{
typedef
struct
{
int
fid
;
int
fid
;
int8_t
state
;
int8_t
state
;
uint8_t
ver
;
uint8_t
ver
;
uint16_t
reserve
;
#if 0
#if 0
SDFInfo info;
SDFInfo info;
#endif
#endif
STfsFile
f
;
STfsFile
f
;
TdFilePtr
pFile
;
TdFilePtr
pFile
;
}
SSFile
;
// files split by days with fid
}
SSFile
;
// files split by days with fid
#define TSDB_LATEST_FSET_VER 0
#define TSDB_LATEST_FSET_VER 0
...
...
source/dnode/vnode/src/inc/tsdbSma.h
浏览文件 @
db970c79
...
@@ -17,27 +17,29 @@
...
@@ -17,27 +17,29 @@
#define _TD_TSDB_SMA_H_
#define _TD_TSDB_SMA_H_
typedef
struct
SSmaStat
SSmaStat
;
typedef
struct
SSmaStat
SSmaStat
;
typedef
struct
SSmaEnv
SSmaEnv
;
// insert/update interface
struct
SSmaEnv
{
int32_t
tsdbInsertTSmaDataImpl
(
STsdb
*
pTsdb
,
char
*
msg
);
pthread_rwlock_t
lock
;
int32_t
tsdbInsertRSmaDataImpl
(
STsdb
*
pTsdb
,
char
*
msg
);
TDBEnv
dbEnv
;
char
*
path
;
SSmaStat
*
pStat
;
};
#define SMA_ENV_LOCK(env) ((env)->lock)
#define SMA_ENV_ENV(env) ((env)->dbEnv)
#define SMA_ENV_PATH(env) ((env)->path)
#define SMA_ENV_STAT(env) ((env)->pStat)
#define SMA_ENV_STAT_ITEMS(env) ((env)->pStat->smaStatItems)
// query interface
void
tsdbDestroySmaEnv
(
SSmaEnv
*
pSmaEnv
);
// TODO: This is the basic params, and should wrap the params to a queryHandle.
void
*
tsdbFreeSmaEnv
(
SSmaEnv
*
pSmaEnv
);
int32_t
tsdbGetTSmaDataImpl
(
STsdb
*
pTsdb
,
STSmaDataWrapper
*
pData
,
STimeWindow
*
queryWin
,
int32_t
nMaxResult
);
// management interface
int32_t
tsdbUpdateExpiredWindow
(
STsdb
*
pTsdb
,
char
*
msg
);
int32_t
tsdbDestroySmaState
(
SSmaStat
*
pSmaStat
);
#if 0
#if 0
int32_t tsdbGetTSmaStatus(STsdb *pTsdb, STSma *param, void *result);
int32_t tsdbGetTSmaStatus(STsdb *pTsdb, STSma *param, void *result);
int32_t tsdbRemoveTSmaData(STsdb *pTsdb, STSma *param, STimeWindow *pWin);
int32_t tsdbRemoveTSmaData(STsdb *pTsdb, STSma *param, STimeWindow *pWin);
#endif
#endif
// internal func
// internal func
static
FORCE_INLINE
int32_t
tsdbEncodeTSmaKey
(
tb_uid_t
tableUid
,
col_id_t
colId
,
TSKEY
tsKey
,
void
**
pData
)
{
static
FORCE_INLINE
int32_t
tsdbEncodeTSmaKey
(
tb_uid_t
tableUid
,
col_id_t
colId
,
TSKEY
tsKey
,
void
**
pData
)
{
int32_t
len
=
0
;
int32_t
len
=
0
;
len
+=
taosEncodeFixedI64
(
pData
,
tableUid
);
len
+=
taosEncodeFixedI64
(
pData
,
tableUid
);
...
@@ -46,4 +48,31 @@ static FORCE_INLINE int32_t tsdbEncodeTSmaKey(tb_uid_t tableUid, col_id_t colId,
...
@@ -46,4 +48,31 @@ static FORCE_INLINE int32_t tsdbEncodeTSmaKey(tb_uid_t tableUid, col_id_t colId,
return
len
;
return
len
;
}
}
static
FORCE_INLINE
int
tsdbRLockSma
(
SSmaEnv
*
pEnv
)
{
int
code
=
pthread_rwlock_rdlock
(
&
(
pEnv
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
static
FORCE_INLINE
int
tsdbWLockSma
(
SSmaEnv
*
pEnv
)
{
int
code
=
pthread_rwlock_wrlock
(
&
(
pEnv
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
static
FORCE_INLINE
int
tsdbUnLockSma
(
SSmaEnv
*
pEnv
)
{
int
code
=
pthread_rwlock_unlock
(
&
(
pEnv
->
lock
));
if
(
code
!=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
#endif
/* _TD_TSDB_SMA_H_ */
#endif
/* _TD_TSDB_SMA_H_ */
\ No newline at end of file
source/dnode/vnode/src/meta/metaBDBImpl.c
浏览文件 @
db970c79
...
@@ -231,30 +231,31 @@ int metaSaveSmaToDB(SMeta *pMeta, STSma *pSmaCfg) {
...
@@ -231,30 +231,31 @@ int metaSaveSmaToDB(SMeta *pMeta, STSma *pSmaCfg) {
void
*
pBuf
=
NULL
,
*
qBuf
=
NULL
;
void
*
pBuf
=
NULL
,
*
qBuf
=
NULL
;
DBT
key1
=
{
0
},
value1
=
{
0
};
DBT
key1
=
{
0
},
value1
=
{
0
};
{
// save sma info
// save sma info
int32_t
len
=
tEncodeTSma
(
NULL
,
pSmaCfg
);
int32_t
len
=
tEncodeTSma
(
NULL
,
pSmaCfg
);
pBuf
=
calloc
(
len
,
1
);
pBuf
=
calloc
(
len
,
1
);
if
(
pBuf
==
NULL
)
{
if
(
pBuf
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
}
}
key1
.
data
=
(
void
*
)
&
pSmaCfg
->
indexUid
;
key1
.
data
=
(
void
*
)
&
pSmaCfg
->
indexUid
;
key1
.
size
=
sizeof
(
pSmaCfg
->
indexUid
);
key1
.
size
=
sizeof
(
pSmaCfg
->
indexUid
);
qBuf
=
pBuf
;
qBuf
=
pBuf
;
tEncodeTSma
(
&
qBuf
,
pSmaCfg
);
tEncodeTSma
(
&
qBuf
,
pSmaCfg
);
value1
.
data
=
pBuf
;
value1
.
data
=
pBuf
;
value1
.
size
=
POINTER_DISTANCE
(
qBuf
,
pBuf
);
value1
.
size
=
POINTER_DISTANCE
(
qBuf
,
pBuf
);
value1
.
app_data
=
pSmaCfg
;
value1
.
app_data
=
pSmaCfg
;
}
metaDBWLock
(
pMeta
->
pDB
);
metaDBWLock
(
pMeta
->
pDB
);
pMeta
->
pDB
->
pSmaDB
->
put
(
pMeta
->
pDB
->
pSmaDB
,
NULL
,
&
key1
,
&
value1
,
0
);
pMeta
->
pDB
->
pSmaDB
->
put
(
pMeta
->
pDB
->
pSmaDB
,
NULL
,
&
key1
,
&
value1
,
0
);
metaDBULock
(
pMeta
->
pDB
);
metaDBULock
(
pMeta
->
pDB
);
// release
tfree
(
pBuf
);
return
0
;
return
0
;
}
}
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
db970c79
...
@@ -83,8 +83,8 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
...
@@ -83,8 +83,8 @@ bool tqNextDataBlock(STqReadHandle* pHandle) {
}
}
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
)
{
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
)
{
/
*int32_t sversion = pHandle->pBlock->sversion;*/
/
/ currently only rows are used
/*SSchemaWrapper* pSchema = metaGetTableSchema(pHandle->pMeta, pHandle->pBlock->uid, sversion, false);*/
pBlockInfo
->
numOfCols
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
pBlockInfo
->
numOfCols
=
taosArrayGetSize
(
pHandle
->
pColIdList
);
pBlockInfo
->
rows
=
pHandle
->
pBlock
->
numOfRows
;
pBlockInfo
->
rows
=
pHandle
->
pBlock
->
numOfRows
;
pBlockInfo
->
uid
=
pHandle
->
pBlock
->
uid
;
pBlockInfo
->
uid
=
pHandle
->
pBlock
->
uid
;
...
...
source/dnode/vnode/src/tsdb/tsdbBDBImpl.c
浏览文件 @
db970c79
...
@@ -12,3 +12,162 @@
...
@@ -12,3 +12,162 @@
* You should have received a copy of the GNU Affero General Public License
* 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/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#define ALLOW_FORBID_FUNC
#include "db.h"
#include "taoserror.h"
#include "tcoding.h"
#include "thash.h"
#include "tsdbDBDef.h"
#include "tsdbLog.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
;
}
tfree
(
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
)
{
// BDB_PERR("Failed to open tsdb env", ret);
tsdbWarn
(
"Failed to open tsdb env for path %s since %d"
,
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
=
calloc
(
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/tsdb/tsdbMain.c
浏览文件 @
db970c79
...
@@ -80,6 +80,8 @@ static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg,
...
@@ -80,6 +80,8 @@ static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg,
pTsdb
->
pmaf
=
pMAF
;
pTsdb
->
pmaf
=
pMAF
;
pTsdb
->
pMeta
=
pMeta
;
pTsdb
->
pMeta
=
pMeta
;
pTsdb
->
pTfs
=
pTfs
;
pTsdb
->
pTfs
=
pTfs
;
pTsdb
->
pTSmaEnv
=
NULL
;
pTsdb
->
pRSmaEnv
=
NULL
;
pTsdb
->
fs
=
tsdbNewFS
(
pTsdbCfg
);
pTsdb
->
fs
=
tsdbNewFS
(
pTsdbCfg
);
...
@@ -88,8 +90,9 @@ static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg,
...
@@ -88,8 +90,9 @@ static STsdb *tsdbNew(const char *path, int32_t vgId, const STsdbCfg *pTsdbCfg,
static
void
tsdbFree
(
STsdb
*
pTsdb
)
{
static
void
tsdbFree
(
STsdb
*
pTsdb
)
{
if
(
pTsdb
)
{
if
(
pTsdb
)
{
tsdbFreeSmaEnv
(
pTsdb
->
pRSmaEnv
);
tsdbFreeSmaEnv
(
pTsdb
->
pTSmaEnv
);
tsdbFreeFS
(
pTsdb
->
fs
);
tsdbFreeFS
(
pTsdb
->
fs
);
tsdbDestroySmaState
(
pTsdb
->
pSmaStat
);
tfree
(
pTsdb
->
path
);
tfree
(
pTsdb
->
path
);
free
(
pTsdb
);
free
(
pTsdb
);
}
}
...
@@ -105,6 +108,30 @@ static void tsdbCloseImpl(STsdb *pTsdb) {
...
@@ -105,6 +108,30 @@ static void tsdbCloseImpl(STsdb *pTsdb) {
tsdbCloseFS
(
pTsdb
);
tsdbCloseFS
(
pTsdb
);
// TODO
// TODO
}
}
int
tsdbLockRepo
(
STsdb
*
pTsdb
)
{
int
code
=
pthread_mutex_lock
(
&
pTsdb
->
mutex
);
if
(
code
!=
0
)
{
tsdbError
(
"vgId:%d failed to lock tsdb since %s"
,
REPO_ID
(
pTsdb
),
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
pTsdb
->
repoLocked
=
true
;
return
0
;
}
int
tsdbUnlockRepo
(
STsdb
*
pTsdb
)
{
ASSERT
(
IS_REPO_LOCKED
(
pTsdb
));
pTsdb
->
repoLocked
=
false
;
int
code
=
pthread_mutex_unlock
(
&
pTsdb
->
mutex
);
if
(
code
!=
0
)
{
tsdbError
(
"vgId:%d failed to unlock tsdb since %s"
,
REPO_ID
(
pTsdb
),
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
code
);
return
-
1
;
}
return
0
;
}
#if 0
#if 0
/*
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/dnode/vnode/src/tsdb/tsdbWrite.c
浏览文件 @
db970c79
...
@@ -34,6 +34,7 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp) {
...
@@ -34,6 +34,7 @@ int tsdbInsertData(STsdb *pTsdb, SSubmitReq *pMsg, SSubmitRsp *pRsp) {
return
tsdbMemTableInsert
(
pTsdb
,
pTsdb
->
mem
,
pMsg
,
NULL
);
return
tsdbMemTableInsert
(
pTsdb
,
pTsdb
->
mem
,
pMsg
,
NULL
);
}
}
#if 0
/**
/**
* @brief Insert/Update tSma(Time-range-wise SMA) data from stream computing engine
* @brief Insert/Update tSma(Time-range-wise SMA) data from stream computing engine
*
*
...
@@ -51,6 +52,14 @@ int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg) {
...
@@ -51,6 +52,14 @@ int32_t tsdbInsertTSmaData(STsdb *pTsdb, char *msg) {
return code;
return code;
}
}
int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, int8_t smaType, char *msg) {
int32_t code = TSDB_CODE_SUCCESS;
if ((code = tsdbUpdateExpiredWindow(pTsdb, smaType, msg)) < 0) {
tsdbWarn("vgId:%d update expired sma window failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
}
return code;
}
/**
/**
* @brief Insert Time-range-wise Rollup Sma(RSma) data
* @brief Insert Time-range-wise Rollup Sma(RSma) data
*
*
...
@@ -65,4 +74,6 @@ int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg) {
...
@@ -65,4 +74,6 @@ int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg) {
tsdbWarn("vgId:%d insert rSma data failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
tsdbWarn("vgId:%d insert rSma data failed since %s", REPO_ID(pTsdb), tstrerror(terrno));
}
}
return code;
return code;
}
}
\ No newline at end of file
#endif
\ No newline at end of file
source/dnode/vnode/test/tsdbSmaTest.cpp
浏览文件 @
db970c79
...
@@ -33,7 +33,7 @@ int main(int argc, char **argv) {
...
@@ -33,7 +33,7 @@ int main(int argc, char **argv) {
return
RUN_ALL_TESTS
();
return
RUN_ALL_TESTS
();
}
}
TEST
(
testCase
,
tSma
EncodeDecode
Test
)
{
TEST
(
testCase
,
tSma
_Meta_Encode_Decode_
Test
)
{
// encode
// encode
STSma
tSma
=
{
0
};
STSma
tSma
=
{
0
};
tSma
.
version
=
0
;
tSma
.
version
=
0
;
...
@@ -87,8 +87,9 @@ TEST(testCase, tSmaEncodeDecodeTest) {
...
@@ -87,8 +87,9 @@ TEST(testCase, tSmaEncodeDecodeTest) {
tdDestroyTSma
(
&
tSma
);
tdDestroyTSma
(
&
tSma
);
tdDestroyTSmaWrapper
(
&
dstTSmaWrapper
);
tdDestroyTSmaWrapper
(
&
dstTSmaWrapper
);
}
}
#if 1
#if 1
TEST
(
testCase
,
tSma_DB_Put_Get_Del_Test
)
{
TEST
(
testCase
,
tSma_
meta
DB_Put_Get_Del_Test
)
{
const
char
*
smaIndexName1
=
"sma_index_test_1"
;
const
char
*
smaIndexName1
=
"sma_index_test_1"
;
const
char
*
smaIndexName2
=
"sma_index_test_2"
;
const
char
*
smaIndexName2
=
"sma_index_test_2"
;
const
char
*
timezone
=
"Asia/Shanghai"
;
const
char
*
timezone
=
"Asia/Shanghai"
;
...
@@ -220,13 +221,84 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) {
...
@@ -220,13 +221,84 @@ TEST(testCase, tSma_DB_Put_Get_Del_Test) {
#endif
#endif
#if 1
#if 1
TEST
(
testCase
,
tSmaInsertTest
)
{
TEST
(
testCase
,
tSma_Data_Insert_Query_Test
)
{
const
int64_t
indexUid
=
2000000002
;
// step 1: prepare meta
const
char
*
smaIndexName1
=
"sma_index_test_1"
;
const
char
*
timezone
=
"Asia/Shanghai"
;
const
char
*
expr
=
"select count(a,b, top 20), from table interval 1d, sliding 1h;"
;
const
char
*
tagsFilter
=
"where tags.location='Beijing' and tags.district='ChaoYang'"
;
const
char
*
smaTestDir
=
"./smaTest"
;
const
tb_uid_t
tbUid
=
1234567890
;
const
int64_t
indexUid1
=
2000000001
;
const
int64_t
interval1
=
1
;
const
int8_t
intervalUnit1
=
TD_TIME_UNIT_DAY
;
const
uint32_t
nCntTSma
=
2
;
TSKEY
skey1
=
1646987196
;
const
int64_t
testSmaData1
=
100
;
const
int64_t
testSmaData2
=
200
;
// encode
STSma
tSma
=
{
0
};
tSma
.
version
=
0
;
tSma
.
intervalUnit
=
TD_TIME_UNIT_DAY
;
tSma
.
interval
=
1
;
tSma
.
slidingUnit
=
TD_TIME_UNIT_HOUR
;
tSma
.
sliding
=
0
;
tSma
.
indexUid
=
indexUid1
;
tstrncpy
(
tSma
.
indexName
,
smaIndexName1
,
TSDB_INDEX_NAME_LEN
);
tstrncpy
(
tSma
.
timezone
,
timezone
,
TD_TIMEZONE_LEN
);
tSma
.
tableUid
=
tbUid
;
tSma
.
exprLen
=
strlen
(
expr
);
tSma
.
expr
=
(
char
*
)
calloc
(
tSma
.
exprLen
+
1
,
1
);
tstrncpy
(
tSma
.
expr
,
expr
,
tSma
.
exprLen
+
1
);
tSma
.
tagsFilterLen
=
strlen
(
tagsFilter
);
tSma
.
tagsFilter
=
(
char
*
)
calloc
(
tSma
.
tagsFilterLen
+
1
,
1
);
tstrncpy
(
tSma
.
tagsFilter
,
tagsFilter
,
tSma
.
tagsFilterLen
+
1
);
SMeta
*
pMeta
=
NULL
;
STSma
*
pSmaCfg
=
&
tSma
;
const
SMetaCfg
*
pMetaCfg
=
&
defaultMetaOptions
;
taosRemoveDir
(
smaTestDir
);
pMeta
=
metaOpen
(
smaTestDir
,
pMetaCfg
,
NULL
);
assert
(
pMeta
!=
NULL
);
// save index 1
EXPECT_EQ
(
metaSaveSmaToDB
(
pMeta
,
pSmaCfg
),
0
);
// step 2: insert data
STSmaDataWrapper
*
pSmaData
=
NULL
;
STSmaDataWrapper
*
pSmaData
=
NULL
;
STsdb
tsdb
=
{
0
};
STsdb
tsdb
=
{
0
};
STsdbCfg
*
pCfg
=
&
tsdb
.
config
;
STsdbCfg
*
pCfg
=
&
tsdb
.
config
;
pCfg
->
daysPerFile
=
1
;
tsdb
.
pMeta
=
pMeta
;
tsdb
.
vgId
=
2
;
tsdb
.
config
.
daysPerFile
=
10
;
// default days is 10
tsdb
.
config
.
keep1
=
30
;
tsdb
.
config
.
keep2
=
90
;
tsdb
.
config
.
keep
=
365
;
tsdb
.
config
.
precision
=
TSDB_TIME_PRECISION_MILLI
;
tsdb
.
config
.
update
=
TD_ROW_OVERWRITE_UPDATE
;
tsdb
.
config
.
compression
=
TWO_STAGE_COMP
;
switch
(
tsdb
.
config
.
precision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
skey1
*=
1e3
;
break
;
case
TSDB_TIME_PRECISION_MICRO
:
skey1
*=
1e6
;
break
;
case
TSDB_TIME_PRECISION_NANO
:
skey1
*=
1e9
;
break
;
default:
// ms
skey1
*=
1e3
;
break
;
}
char
*
msg
=
(
char
*
)
calloc
(
100
,
1
);
EXPECT_EQ
(
tsdbUpdateSmaWindow
(
&
tsdb
,
TSDB_SMA_TYPE_TIME_RANGE
,
msg
),
0
);
// init
// init
int32_t
allocCnt
=
0
;
int32_t
allocCnt
=
0
;
...
@@ -235,21 +307,21 @@ TEST(testCase, tSmaInsertTest) {
...
@@ -235,21 +307,21 @@ TEST(testCase, tSmaInsertTest) {
void
*
buf
=
NULL
;
void
*
buf
=
NULL
;
EXPECT_EQ
(
tsdbMakeRoom
(
&
buf
,
allocStep
),
0
);
EXPECT_EQ
(
tsdbMakeRoom
(
&
buf
,
allocStep
),
0
);
int32_t
bufSize
=
taosTSizeof
(
buf
);
int32_t
bufSize
=
taosTSizeof
(
buf
);
int32_t
numOfTables
=
25
;
int32_t
numOfTables
=
10
;
col_id_t
numOfCols
=
4096
;
col_id_t
numOfCols
=
4096
;
EXPECT_GT
(
numOfCols
,
0
);
EXPECT_GT
(
numOfCols
,
0
);
pSmaData
=
(
STSmaDataWrapper
*
)
buf
;
pSmaData
=
(
STSmaDataWrapper
*
)
buf
;
printf
(
">> allocate [%d] time to %d and addr is %p
\n
"
,
++
allocCnt
,
bufSize
,
pSmaData
);
printf
(
">> allocate [%d] time to %d and addr is %p
\n
"
,
++
allocCnt
,
bufSize
,
pSmaData
);
pSmaData
->
skey
=
1646987196
;
pSmaData
->
skey
=
skey1
;
pSmaData
->
interval
=
10
;
pSmaData
->
interval
=
interval1
;
pSmaData
->
intervalUnit
=
TD_TIME_UNIT_MINUTE
;
pSmaData
->
intervalUnit
=
intervalUnit1
;
pSmaData
->
indexUid
=
indexUid
;
pSmaData
->
indexUid
=
indexUid
1
;
int32_t
len
=
sizeof
(
STSmaDataWrapper
);
int32_t
len
=
sizeof
(
STSmaDataWrapper
);
for
(
int32_t
t
=
0
;
t
<
numOfTables
;
++
t
)
{
for
(
int32_t
t
=
0
;
t
<
numOfTables
;
++
t
)
{
STSmaTbData
*
pTbData
=
(
STSmaTbData
*
)
POINTER_SHIFT
(
pSmaData
,
len
);
STSmaTbData
*
pTbData
=
(
STSmaTbData
*
)
POINTER_SHIFT
(
pSmaData
,
len
);
pTbData
->
tableUid
=
t
;
pTbData
->
tableUid
=
t
bUid
+
t
;
int32_t
tableDataLen
=
sizeof
(
STSmaTbData
);
int32_t
tableDataLen
=
sizeof
(
STSmaTbData
);
for
(
col_id_t
c
=
0
;
c
<
numOfCols
;
++
c
)
{
for
(
col_id_t
c
=
0
;
c
<
numOfCols
;
++
c
)
{
...
@@ -262,8 +334,17 @@ TEST(testCase, tSmaInsertTest) {
...
@@ -262,8 +334,17 @@ TEST(testCase, tSmaInsertTest) {
}
}
STSmaColData
*
pColData
=
(
STSmaColData
*
)
POINTER_SHIFT
(
pSmaData
,
len
+
tableDataLen
);
STSmaColData
*
pColData
=
(
STSmaColData
*
)
POINTER_SHIFT
(
pSmaData
,
len
+
tableDataLen
);
pColData
->
colId
=
c
+
PRIMARYKEY_TIMESTAMP_COL_ID
;
pColData
->
colId
=
c
+
PRIMARYKEY_TIMESTAMP_COL_ID
;
pColData
->
blockSize
=
((
c
&
1
)
==
0
)
?
8
:
16
;
// TODO: fill col data
// TODO: fill col data
if
((
c
&
1
)
==
0
)
{
pColData
->
blockSize
=
8
;
memcpy
(
pColData
->
data
,
&
testSmaData1
,
8
);
}
else
{
pColData
->
blockSize
=
16
;
memcpy
(
pColData
->
data
,
&
testSmaData1
,
8
);
memcpy
(
POINTER_SHIFT
(
pColData
->
data
,
8
),
&
testSmaData2
,
8
);
}
tableDataLen
+=
(
sizeof
(
STSmaColData
)
+
pColData
->
blockSize
);
tableDataLen
+=
(
sizeof
(
STSmaColData
)
+
pColData
->
blockSize
);
}
}
pTbData
->
dataLen
=
(
tableDataLen
-
sizeof
(
STSmaTbData
));
pTbData
->
dataLen
=
(
tableDataLen
-
sizeof
(
STSmaTbData
));
...
@@ -277,8 +358,24 @@ TEST(testCase, tSmaInsertTest) {
...
@@ -277,8 +358,24 @@ TEST(testCase, tSmaInsertTest) {
// execute
// execute
EXPECT_EQ
(
tsdbInsertTSmaData
(
&
tsdb
,
(
char
*
)
pSmaData
),
TSDB_CODE_SUCCESS
);
EXPECT_EQ
(
tsdbInsertTSmaData
(
&
tsdb
,
(
char
*
)
pSmaData
),
TSDB_CODE_SUCCESS
);
// release
// step 3: query
uint32_t
checkDataCnt
=
0
;
for
(
int32_t
t
=
0
;
t
<
numOfTables
;
++
t
)
{
for
(
col_id_t
c
=
0
;
c
<
numOfCols
;
++
c
)
{
EXPECT_EQ
(
tsdbGetTSmaData
(
&
tsdb
,
NULL
,
indexUid1
,
interval1
,
intervalUnit1
,
tbUid
+
t
,
c
+
PRIMARYKEY_TIMESTAMP_COL_ID
,
skey1
,
1
),
TSDB_CODE_SUCCESS
);
++
checkDataCnt
;
}
}
printf
(
"%s:%d The sma data check count for insert and query is %"
PRIu32
"
\n
"
,
__FILE__
,
__LINE__
,
checkDataCnt
);
// release data
taosTZfree
(
buf
);
taosTZfree
(
buf
);
// release meta
tdDestroyTSma
(
&
tSma
);
metaClose
(
pMeta
);
}
}
#endif
#endif
...
...
source/libs/executor/inc/executil.h
浏览文件 @
db970c79
...
@@ -50,7 +50,7 @@ typedef struct SGroupResInfo {
...
@@ -50,7 +50,7 @@ typedef struct SGroupResInfo {
int32_t
totalGroup
;
int32_t
totalGroup
;
int32_t
currentGroup
;
int32_t
currentGroup
;
int32_t
index
;
int32_t
index
;
SArray
*
pRows
;
// SArray<SResultRow*>
SArray
*
pRows
;
// SArray<SResultRow
Position
*>
bool
ordered
;
bool
ordered
;
int32_t
position
;
int32_t
position
;
}
SGroupResInfo
;
}
SGroupResInfo
;
...
@@ -67,10 +67,15 @@ typedef struct SResultRow {
...
@@ -67,10 +67,15 @@ typedef struct SResultRow {
char
*
key
;
// start key of current result row
char
*
key
;
// start key of current result row
}
SResultRow
;
}
SResultRow
;
typedef
struct
SResultRowPosition
{
int32_t
pageId
;
int32_t
offset
;
}
SResultRowPosition
;
typedef
struct
SResultRowInfo
{
typedef
struct
SResultRowInfo
{
SList
*
pRows
;
SList
*
pRows
;
SResultRow
**
pResult
;
// result list
SResultRow
Position
*
pPosition
;
// int16_t type:8; // data type for hash key
SResultRow
**
pResult
;
// result list
int32_t
size
;
// number of result set
int32_t
size
;
// number of result set
int32_t
capacity
;
// max capacity
int32_t
capacity
;
// max capacity
int32_t
curPos
;
// current active result row index of pResult list
int32_t
curPos
;
// current active result row index of pResult list
...
@@ -131,7 +136,7 @@ static FORCE_INLINE char* getPosInResultPage_rv(SFilePage* page, int32_t rowOffs
...
@@ -131,7 +136,7 @@ static FORCE_INLINE char* getPosInResultPage_rv(SFilePage* page, int32_t rowOffs
assert
(
rowOffset
>=
0
);
assert
(
rowOffset
>=
0
);
int32_t
numOfRows
=
1
;
//(int32_t)getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery);
int32_t
numOfRows
=
1
;
//(int32_t)getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery);
return
(
(
char
*
)
page
->
data
)
+
rowOffset
+
offset
*
numOfRows
;
return
(
char
*
)
page
+
rowOffset
+
offset
*
numOfRows
;
}
}
//bool isNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type);
//bool isNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type);
...
@@ -139,12 +144,7 @@ static FORCE_INLINE char* getPosInResultPage_rv(SFilePage* page, int32_t rowOffs
...
@@ -139,12 +144,7 @@ static FORCE_INLINE char* getPosInResultPage_rv(SFilePage* page, int32_t rowOffs
__filter_func_t
getFilterOperator
(
int32_t
lowerOptr
,
int32_t
upperOptr
);
__filter_func_t
getFilterOperator
(
int32_t
lowerOptr
,
int32_t
upperOptr
);
SResultRowPool
*
initResultRowPool
(
size_t
size
);
SResultRow
*
getNewResultRow
(
SResultRowPool
*
p
);
SResultRow
*
getNewResultRow
(
SResultRowPool
*
p
);
int64_t
getResultRowPoolMemSize
(
SResultRowPool
*
p
);
void
*
destroyResultRowPool
(
SResultRowPool
*
p
);
int32_t
getNumOfAllocatedResultRows
(
SResultRowPool
*
p
);
int32_t
getNumOfUsedResultRows
(
SResultRowPool
*
p
);
typedef
struct
{
typedef
struct
{
SArray
*
pResult
;
// SArray<SResPair>
SArray
*
pResult
;
// SArray<SResPair>
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
db970c79
...
@@ -240,12 +240,12 @@ typedef struct STaskAttr {
...
@@ -240,12 +240,12 @@ typedef struct STaskAttr {
SArray
*
pUdfInfo
;
// no need to free
SArray
*
pUdfInfo
;
// no need to free
}
STaskAttr
;
}
STaskAttr
;
typedef
int32_t
(
*
__optr_open_fn_t
)(
void
*
param
);
typedef
SSDataBlock
*
(
*
__optr_fn_t
)(
void
*
param
,
bool
*
newgroup
);
typedef
void
(
*
__optr_close_fn_t
)(
void
*
param
,
int32_t
num
);
struct
SOperatorInfo
;
struct
SOperatorInfo
;
typedef
int32_t
(
*
__optr_open_fn_t
)(
struct
SOperatorInfo
*
param
);
typedef
SSDataBlock
*
(
*
__optr_fn_t
)(
struct
SOperatorInfo
*
param
,
bool
*
newgroup
);
typedef
void
(
*
__optr_close_fn_t
)(
void
*
param
,
int32_t
num
);
typedef
struct
STaskIdInfo
{
typedef
struct
STaskIdInfo
{
uint64_t
queryId
;
// this is also a request id
uint64_t
queryId
;
// this is also a request id
uint64_t
subplanId
;
uint64_t
subplanId
;
...
@@ -275,36 +275,36 @@ typedef struct SExecTaskInfo {
...
@@ -275,36 +275,36 @@ typedef struct SExecTaskInfo {
}
SExecTaskInfo
;
}
SExecTaskInfo
;
typedef
struct
STaskRuntimeEnv
{
typedef
struct
STaskRuntimeEnv
{
jmp_buf
env
;
jmp_buf
env
;
STaskAttr
*
pQueryAttr
;
STaskAttr
*
pQueryAttr
;
uint32_t
status
;
// query status
uint32_t
status
;
// query status
void
*
qinfo
;
void
*
qinfo
;
uint8_t
scanFlag
;
// denotes reversed scan of data or not
uint8_t
scanFlag
;
// denotes reversed scan of data or not
void
*
pTsdbReadHandle
;
void
*
pTsdbReadHandle
;
int32_t
prevGroupId
;
// previous executed group id
int32_t
prevGroupId
;
// previous executed group id
bool
enableGroupData
;
bool
enableGroupData
;
SDiskbasedBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
SDiskbasedBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
SHashObj
*
pResultRowHashTable
;
// quick locate the window object for each result
SHashObj
*
pResultRowHashTable
;
// quick locate the window object for each result
SHashObj
*
pResultRowListSet
;
// used to check if current ResultRowInfo has ResultRow object or not
SHashObj
*
pResultRowListSet
;
// used to check if current ResultRowInfo has ResultRow object or not
SArray
*
pResultRowArrayList
;
// The array list that contains the Result rows
SArray
*
pResultRowArrayList
;
// The array list that contains the Result rows
char
*
keyBuf
;
// window key buffer
char
*
keyBuf
;
// window key buffer
// The window result objects pool, all the resultRow Objects are allocated and managed by this object.
// The window result objects pool, all the resultRow Objects are allocated and managed by this object.
char
**
prevRow
;
char
**
prevRow
;
SResultRowPool
*
pool
;
SResultRowPool
*
pool
;
SArray
*
prevResult
;
// intermediate result, SArray<SInterResult>
SArray
*
prevResult
;
// intermediate result, SArray<SInterResult>
STSBuf
*
pTsBuf
;
// timestamp filter list
STSBuf
*
pTsBuf
;
// timestamp filter list
STSCursor
cur
;
STSCursor
cur
;
char
*
tagVal
;
// tag value of current data block
char
*
tagVal
;
// tag value of current data block
struct
SScalarFunctionSupport
*
scalarSup
;
struct
SScalarFunctionSupport
*
scalarSup
;
SSDataBlock
*
outputBuf
;
SSDataBlock
*
outputBuf
;
STableGroupInfo
tableqinfoGroupInfo
;
// this is a group array list, including SArray<STableQueryInfo*> structure
STableGroupInfo
tableqinfoGroupInfo
;
// this is a group array list, including SArray<STableQueryInfo*> structure
struct
SOperatorInfo
*
proot
;
struct
SOperatorInfo
*
proot
;
SGroupResInfo
groupResInfo
;
SGroupResInfo
groupResInfo
;
int64_t
currentOffset
;
// dynamic offset value
int64_t
currentOffset
;
// dynamic offset value
STableQueryInfo
*
current
;
STableQueryInfo
*
current
;
SRspResultInfo
resultInfo
;
SRspResultInfo
resultInfo
;
...
@@ -328,7 +328,7 @@ typedef struct SOperatorInfo {
...
@@ -328,7 +328,7 @@ typedef struct SOperatorInfo {
char
*
name
;
// name, used to show the query execution plan
char
*
name
;
// name, used to show the query execution plan
void
*
info
;
// extension attribution
void
*
info
;
// extension attribution
SExprInfo
*
pExpr
;
SExprInfo
*
pExpr
;
STaskRuntimeEnv
*
pRuntimeEnv
;
// todo remove it
STaskRuntimeEnv
*
pRuntimeEnv
;
// todo remove it
SExecTaskInfo
*
pTaskInfo
;
SExecTaskInfo
*
pTaskInfo
;
SOperatorCostInfo
cost
;
SOperatorCostInfo
cost
;
...
@@ -365,28 +365,6 @@ typedef struct SQInfo {
...
@@ -365,28 +365,6 @@ typedef struct SQInfo {
STaskCostInfo
summary
;
STaskCostInfo
summary
;
}
SQInfo
;
}
SQInfo
;
typedef
struct
STaskParam
{
char
*
sql
;
char
*
tagCond
;
char
*
colCond
;
char
*
tbnameCond
;
char
*
prevResult
;
SArray
*
pTableIdList
;
SExprBasicInfo
**
pExpr
;
SExprBasicInfo
**
pSecExpr
;
SExprInfo
*
pExprs
;
SExprInfo
*
pSecExprs
;
SFilterInfo
*
pFilters
;
SColIndex
*
pGroupColIndex
;
SColumnInfo
*
pTagColumnInfo
;
SGroupbyExpr
*
pGroupbyExpr
;
int32_t
tableScanOperator
;
SArray
*
pOperator
;
struct
SUdfInfo
*
pUdfInfo
;
}
STaskParam
;
enum
{
enum
{
EX_SOURCE_DATA_NOT_READY
=
0x1
,
EX_SOURCE_DATA_NOT_READY
=
0x1
,
EX_SOURCE_DATA_READY
=
0x2
,
EX_SOURCE_DATA_READY
=
0x2
,
...
@@ -472,75 +450,75 @@ typedef struct SSysTableScanInfo {
...
@@ -472,75 +450,75 @@ typedef struct SSysTableScanInfo {
}
SSysTableScanInfo
;
}
SSysTableScanInfo
;
typedef
struct
SOptrBasicInfo
{
typedef
struct
SOptrBasicInfo
{
SResultRowInfo
resultRowInfo
;
SResultRowInfo
resultRowInfo
;
int32_t
*
rowCellInfoOffset
;
// offset value for each row result cell info
int32_t
*
rowCellInfoOffset
;
// offset value for each row result cell info
SqlFunctionCtx
*
pCtx
;
SqlFunctionCtx
*
pCtx
;
SSDataBlock
*
pRes
;
SSDataBlock
*
pRes
;
int32_t
capacity
;
int32_t
capacity
;
}
SOptrBasicInfo
;
}
SOptrBasicInfo
;
//TODO move the resultrowsiz together with SOptrBasicInfo:rowCellInfoOffset
//TODO move the resultrowsiz together with SOptrBasicInfo:rowCellInfoOffset
typedef
struct
SAggSupporter
{
typedef
struct
SAggSupporter
{
SHashObj
*
pResultRowHashTable
;
// quick locate the window object for each result
SHashObj
*
pResultRowHashTable
;
// quick locate the window object for each result
SHashObj
*
pResultRowListSet
;
// used to check if current ResultRowInfo has ResultRow object or not
SHashObj
*
pResultRowListSet
;
// used to check if current ResultRowInfo has ResultRow object or not
SArray
*
pResultRowArrayList
;
// The array list that contains the Result rows
SArray
*
pResultRowArrayList
;
// The array list that contains the Result rows
char
*
keyBuf
;
// window key buffer
char
*
keyBuf
;
// window key buffer
S
ResultRowPool
*
pool
;
// The window result objects pool, all the resultRow Objects are allocated and managed by this object.
S
DiskbasedBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
int32_t
resultRowSize
;
// the result buffer size for each result row, with the meta data size for each row
int32_t
resultRowSize
;
// the result buffer size for each result row, with the meta data size for each row
}
SAggSupporter
;
}
SAggSupporter
;
typedef
struct
STableIntervalOperatorInfo
{
typedef
struct
STableIntervalOperatorInfo
{
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
SDiskbasedBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
SGroupResInfo
groupResInfo
;
SGroupResInfo
groupResInfo
;
SInterval
interval
;
SInterval
interval
;
STimeWindow
win
;
STimeWindow
win
;
int32_t
precision
;
int32_t
precision
;
bool
timeWindowInterpo
;
bool
timeWindowInterpo
;
char
**
pRow
;
char
**
pRow
;
SAggSupporter
aggSup
;
SAggSupporter
aggSup
;
STableQueryInfo
*
pCurrent
;
STableQueryInfo
*
pCurrent
;
int32_t
order
;
int32_t
order
;
}
STableIntervalOperatorInfo
;
}
STableIntervalOperatorInfo
;
typedef
struct
SAggOperatorInfo
{
typedef
struct
SAggOperatorInfo
{
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
SDiskbasedBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
SDiskbasedBuf
*
pResultBuf
;
// query result buffer based on blocked-wised disk file
SAggSupporter
aggSup
;
SAggSupporter
aggSup
;
STableQueryInfo
*
current
;
STableQueryInfo
*
current
;
uint32_t
groupId
;
uint32_t
groupId
;
SGroupResInfo
groupResInfo
;
SGroupResInfo
groupResInfo
;
STableQueryInfo
*
pTableQueryInfo
;
STableQueryInfo
*
pTableQueryInfo
;
}
SAggOperatorInfo
;
}
SAggOperatorInfo
;
typedef
struct
SProjectOperatorInfo
{
typedef
struct
SProjectOperatorInfo
{
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
SSDataBlock
*
existDataBlock
;
SSDataBlock
*
existDataBlock
;
int32_t
threshold
;
bool
hasVarCol
;
}
SProjectOperatorInfo
;
}
SProjectOperatorInfo
;
typedef
struct
SLimitOperatorInfo
{
typedef
struct
SLimitOperatorInfo
{
int64_t
limit
;
SLimit
limit
;
int64_t
total
;
int64_t
currentOffset
;
int64_t
currentRows
;
}
SLimitOperatorInfo
;
}
SLimitOperatorInfo
;
typedef
struct
SSLimitOperatorInfo
{
typedef
struct
SSLimitOperatorInfo
{
int64_t
groupTotal
;
int64_t
groupTotal
;
int64_t
currentGroupOffset
;
int64_t
currentGroupOffset
;
int64_t
rowsTotal
;
int64_t
rowsTotal
;
int64_t
currentOffset
;
int64_t
currentOffset
;
SLimit
limit
;
SLimit
limit
;
SLimit
slimit
;
SLimit
slimit
;
char
**
prevRow
;
SArray
*
orderColumnList
;
char
**
prevRow
;
bool
hasPrev
;
SArray
*
orderColumnList
;
bool
ignoreCurrentGroup
;
bool
hasPrev
;
bool
multigroupResult
;
bool
ignoreCurrentGroup
;
SSDataBlock
*
pRes
;
// result buffer
bool
multigroupResult
;
SSDataBlock
*
pPrevBlock
;
SSDataBlock
*
pRes
;
// result buffer
int64_t
capacity
;
SSDataBlock
*
pPrevBlock
;
int64_t
threshold
;
int64_t
capacity
;
int64_t
threshold
;
}
SSLimitOperatorInfo
;
}
SSLimitOperatorInfo
;
typedef
struct
SFilterOperatorInfo
{
typedef
struct
SFilterOperatorInfo
{
...
@@ -563,14 +541,15 @@ typedef struct SGroupbyOperatorInfo {
...
@@ -563,14 +541,15 @@ typedef struct SGroupbyOperatorInfo {
char
*
prevData
;
// previous group by value
char
*
prevData
;
// previous group by value
}
SGroupbyOperatorInfo
;
}
SGroupbyOperatorInfo
;
typedef
struct
SS
Window
OperatorInfo
{
typedef
struct
SS
essionAgg
OperatorInfo
{
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
SAggSupporter
aggSup
;
STimeWindow
curWindow
;
// current time window
STimeWindow
curWindow
;
// current time window
TSKEY
prevTs
;
// previous timestamp
TSKEY
prevTs
;
// previous timestamp
int32_t
numOfRows
;
// number of rows
int32_t
numOfRows
;
// number of rows
int32_t
start
;
// start row index
int32_t
start
;
// start row index
bool
reptScan
;
// next round scan
bool
reptScan
;
// next round scan
}
SS
Window
OperatorInfo
;
}
SS
essionAgg
OperatorInfo
;
typedef
struct
SStateWindowOperatorInfo
{
typedef
struct
SStateWindowOperatorInfo
{
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
...
@@ -582,23 +561,6 @@ typedef struct SStateWindowOperatorInfo {
...
@@ -582,23 +561,6 @@ typedef struct SStateWindowOperatorInfo {
bool
reptScan
;
bool
reptScan
;
}
SStateWindowOperatorInfo
;
}
SStateWindowOperatorInfo
;
typedef
struct
SDistinctDataInfo
{
int32_t
index
;
int32_t
type
;
int32_t
bytes
;
}
SDistinctDataInfo
;
typedef
struct
SDistinctOperatorInfo
{
SHashObj
*
pSet
;
SSDataBlock
*
pRes
;
bool
recordNullVal
;
// has already record the null value, no need to try again
int64_t
threshold
;
int64_t
outputCapacity
;
int32_t
totalBytes
;
char
*
buf
;
SArray
*
pDistinctDataInfo
;
}
SDistinctOperatorInfo
;
typedef
struct
SSortedMergeOperatorInfo
{
typedef
struct
SSortedMergeOperatorInfo
{
SOptrBasicInfo
binfo
;
SOptrBasicInfo
binfo
;
bool
hasVarCol
;
bool
hasVarCol
;
...
@@ -624,45 +586,61 @@ typedef struct SSortedMergeOperatorInfo {
...
@@ -624,45 +586,61 @@ typedef struct SSortedMergeOperatorInfo {
}
SSortedMergeOperatorInfo
;
}
SSortedMergeOperatorInfo
;
typedef
struct
SOrderOperatorInfo
{
typedef
struct
SOrderOperatorInfo
{
uint32_t
sortBufSize
;
// max buffer size for in-memory sort
uint32_t
sortBufSize
;
// max buffer size for in-memory sort
SSDataBlock
*
pDataBlock
;
SSDataBlock
*
pDataBlock
;
bool
hasVarCol
;
// has variable length column, such as binary/varchar/nchar
bool
hasVarCol
;
// has variable length column, such as binary/varchar/nchar
SArray
*
orderInfo
;
SArray
*
orderInfo
;
bool
nullFirst
;
bool
nullFirst
;
SSortHandle
*
pSortHandle
;
SSortHandle
*
pSortHandle
;
int32_t
bufPageSize
;
int32_t
bufPageSize
;
int32_t
numOfRowsInRes
;
int32_t
numOfRowsInRes
;
// TODO extact struct
// TODO extact struct
int64_t
startTs
;
// sort start time
int64_t
startTs
;
// sort start time
uint64_t
sortElapsed
;
// sort elapsed time, time to flush to disk not included.
uint64_t
sortElapsed
;
// sort elapsed time, time to flush to disk not included.
uint64_t
totalSize
;
// total load bytes from remote
uint64_t
totalSize
;
// total load bytes from remote
uint64_t
totalRows
;
// total number of rows
uint64_t
totalRows
;
// total number of rows
uint64_t
totalElapsed
;
// total elapsed time
uint64_t
totalElapsed
;
// total elapsed time
}
SOrderOperatorInfo
;
}
SOrderOperatorInfo
;
typedef
struct
SDistinctDataInfo
{
int32_t
index
;
int32_t
type
;
int32_t
bytes
;
}
SDistinctDataInfo
;
typedef
struct
SDistinctOperatorInfo
{
SHashObj
*
pSet
;
SSDataBlock
*
pRes
;
bool
recordNullVal
;
// has already record the null value, no need to try again
int64_t
threshold
;
int64_t
outputCapacity
;
int32_t
totalBytes
;
char
*
buf
;
SArray
*
pDistinctDataInfo
;
}
SDistinctOperatorInfo
;
SOperatorInfo
*
createExchangeOperatorInfo
(
const
SNodeList
*
pSources
,
SSDataBlock
*
pBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createExchangeOperatorInfo
(
const
SNodeList
*
pSources
,
SSDataBlock
*
pBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createTableScanOperatorInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOfOutput
,
SOperatorInfo
*
createTableScanOperatorInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
int32_t
reverseTime
,
SExecTaskInfo
*
pTaskInfo
);
int32_t
repeatTime
,
int32_t
reverseTime
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
create
TableSeqScanOperatorInfo
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
create
AggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SSDataBlock
*
pResultBlock
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createMultiTableAggOperatorInfo
(
SOperatorInfo
*
downstream
,
S
Array
*
pExprInfo
,
SSDataBlock
*
pResult
Block
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createMultiTableAggOperatorInfo
(
SOperatorInfo
*
downstream
,
S
ExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pRes
Block
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
S
Array
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createProjectOperatorInfo
(
SOperatorInfo
*
downstream
,
S
ExprInfo
*
pExprInfo
,
int32_t
num
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createOrderOperatorInfo
(
SOperatorInfo
*
downstream
,
S
Array
*
pExprInfo
,
SArray
*
pOrderVal
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createOrderOperatorInfo
(
SOperatorInfo
*
downstream
,
S
ExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SArray
*
pOrderVal
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortedMergeOperatorInfo
(
SOperatorInfo
**
downstream
,
int32_t
numOfDownstream
,
S
Array
*
pExprInfo
,
SArray
*
pOrderVal
,
SArray
*
pGroupInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSortedMergeOperatorInfo
(
SOperatorInfo
**
downstream
,
int32_t
numOfDownstream
,
S
ExprInfo
*
pExprInfo
,
int32_t
num
,
SArray
*
pOrderVal
,
SArray
*
pGroupInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSysTableScanOperatorInfo
(
void
*
pSysTableReadHandle
,
const
SArray
*
pExprInfo
,
const
SSchema
*
pSchema
,
SOperatorInfo
*
createSysTableScanOperatorInfo
(
void
*
pSysTableReadHandle
,
const
SArray
*
pExprInfo
,
const
SSchema
*
pSchema
,
int32_t
tableType
,
SEpSet
epset
,
SExecTaskInfo
*
pTaskInfo
);
int32_t
tableType
,
SEpSet
epset
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createLimitOperatorInfo
(
SOperatorInfo
*
downstream
,
int32_t
numOfDownstream
,
SLimit
*
pLimit
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createLimitOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
);
SOperatorInfo
*
createIntervalOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SInterval
*
pInterval
,
SOperatorInfo
*
createIntervalOperatorInfo
(
SOperatorInfo
*
downstream
,
SArray
*
pExprInfo
,
SInterval
*
pInterval
,
SExecTaskInfo
*
pTaskInfo
);
const
STableGroupInfo
*
pTableGroupInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createSessionAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createLimitOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
);
SOperatorInfo
*
createTableSeqScanOperatorInfo
(
void
*
pTsdbReadHandle
,
STaskRuntimeEnv
*
pRuntimeEnv
);
SOperatorInfo
*
createAllTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SOperatorInfo
*
createAllTimeIntervalOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createSWindowOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
);
SOperatorInfo
*
createFillOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
SOperatorInfo
*
createFillOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
int32_t
numOfOutput
,
bool
multigroupResult
);
int32_t
numOfOutput
,
bool
multigroupResult
);
SOperatorInfo
*
createGroupbyOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
SOperatorInfo
*
createGroupbyOperatorInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SOperatorInfo
*
downstream
,
SExprInfo
*
pExpr
,
...
@@ -699,16 +677,13 @@ SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numO
...
@@ -699,16 +677,13 @@ SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numO
void
*
doDestroyFilterInfo
(
SSingleColumnFilterInfo
*
pFilterInfo
,
int32_t
numOfFilterCols
);
void
*
doDestroyFilterInfo
(
SSingleColumnFilterInfo
*
pFilterInfo
,
int32_t
numOfFilterCols
);
void
setInputDataBlock
(
SOperatorInfo
*
pOperator
,
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
);
void
setInputDataBlock
(
SOperatorInfo
*
pOperator
,
SqlFunctionCtx
*
pCtx
,
SSDataBlock
*
pBlock
,
int32_t
order
);
void
finalizeQueryResult
(
S
OperatorInfo
*
pOperator
,
SqlFunctionCtx
*
pCtx
,
SResultRowInfo
*
pResultRowInfo
,
void
finalizeQueryResult
(
S
qlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
);
int32_t
*
rowCellInfoOffset
);
void
clearOutputBuf
(
SOptrBasicInfo
*
pBInfo
,
int32_t
*
bufCapacity
);
void
clearOutputBuf
(
SOptrBasicInfo
*
pBInfo
,
int32_t
*
bufCapacity
);
void
copyTsColoum
(
SSDataBlock
*
pRes
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
);
void
copyTsColoum
(
SSDataBlock
*
pRes
,
SqlFunctionCtx
*
pCtx
,
int32_t
numOfOutput
);
int32_t
createQueryFilter
(
char
*
data
,
uint16_t
len
,
SFilterInfo
**
pFilters
);
int32_t
createQueryFilter
(
char
*
data
,
uint16_t
len
,
SFilterInfo
**
pFilters
);
int32_t
initQInfo
(
STsBufInfo
*
pTsBufInfo
,
void
*
tsdb
,
void
*
sourceOptr
,
SQInfo
*
pQInfo
,
STaskParam
*
param
,
char
*
start
,
int32_t
prevResultLen
,
void
*
merger
);
int32_t
createFilterInfo
(
STaskAttr
*
pQueryAttr
,
uint64_t
qId
);
int32_t
createFilterInfo
(
STaskAttr
*
pQueryAttr
,
uint64_t
qId
);
void
freeColumnFilterInfo
(
SColumnFilterInfo
*
pFilter
,
int32_t
numOfFilters
);
void
freeColumnFilterInfo
(
SColumnFilterInfo
*
pFilter
,
int32_t
numOfFilters
);
...
...
source/libs/executor/src/dataDispatcher.c
浏览文件 @
db970c79
...
@@ -115,7 +115,8 @@ static bool allocBuf(SDataDispatchHandle* pDispatcher, const SInputData* pInput,
...
@@ -115,7 +115,8 @@ static bool allocBuf(SDataDispatchHandle* pDispatcher, const SInputData* pInput,
return
false
;
return
false
;
}
}
pBuf
->
allocSize
=
sizeof
(
SRetrieveTableRsp
)
+
pDispatcher
->
pSchema
->
resultRowSize
*
pInput
->
pData
->
info
.
rows
;
// struct size + data payload + length for each column
pBuf
->
allocSize
=
sizeof
(
SRetrieveTableRsp
)
+
pDispatcher
->
pSchema
->
resultRowSize
*
pInput
->
pData
->
info
.
rows
+
pInput
->
pData
->
info
.
numOfCols
*
sizeof
(
int32_t
);
pBuf
->
pData
=
malloc
(
pBuf
->
allocSize
);
pBuf
->
pData
=
malloc
(
pBuf
->
allocSize
);
if
(
pBuf
->
pData
==
NULL
)
{
if
(
pBuf
->
pData
==
NULL
)
{
qError
(
"SinkNode failed to malloc memory, size:%d, code:%d"
,
pBuf
->
allocSize
,
TAOS_SYSTEM_ERROR
(
errno
));
qError
(
"SinkNode failed to malloc memory, size:%d, code:%d"
,
pBuf
->
allocSize
,
TAOS_SYSTEM_ERROR
(
errno
));
...
...
source/libs/executor/src/executil.c
浏览文件 @
db970c79
...
@@ -59,7 +59,8 @@ int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size) {
...
@@ -59,7 +59,8 @@ int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size) {
pResultRowInfo
->
capacity
=
size
;
pResultRowInfo
->
capacity
=
size
;
pResultRowInfo
->
pResult
=
calloc
(
pResultRowInfo
->
capacity
,
POINTER_BYTES
);
pResultRowInfo
->
pResult
=
calloc
(
pResultRowInfo
->
capacity
,
POINTER_BYTES
);
if
(
pResultRowInfo
->
pResult
==
NULL
)
{
pResultRowInfo
->
pPosition
=
calloc
(
pResultRowInfo
->
capacity
,
sizeof
(
SResultRowPosition
));
if
(
pResultRowInfo
->
pResult
==
NULL
||
pResultRowInfo
->
pPosition
==
NULL
)
{
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
}
...
@@ -182,22 +183,6 @@ size_t getResultRowSize(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
...
@@ -182,22 +183,6 @@ size_t getResultRowSize(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
return
rowSize
;
return
rowSize
;
}
}
SResultRowPool
*
initResultRowPool
(
size_t
size
)
{
SResultRowPool
*
p
=
calloc
(
1
,
sizeof
(
SResultRowPool
));
if
(
p
==
NULL
)
{
return
NULL
;
}
p
->
numOfElemPerBlock
=
128
;
p
->
elemSize
=
(
int32_t
)
size
;
p
->
blockSize
=
p
->
numOfElemPerBlock
*
p
->
elemSize
;
p
->
position
.
pos
=
0
;
p
->
pData
=
taosArrayInit
(
8
,
POINTER_BYTES
);
return
p
;
}
SResultRow
*
getNewResultRow
(
SResultRowPool
*
p
)
{
SResultRow
*
getNewResultRow
(
SResultRowPool
*
p
)
{
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
return
NULL
;
return
NULL
;
...
@@ -221,132 +206,6 @@ SResultRow* getNewResultRow(SResultRowPool* p) {
...
@@ -221,132 +206,6 @@ SResultRow* getNewResultRow(SResultRowPool* p) {
return
ptr
;
return
ptr
;
}
}
int64_t
getResultRowPoolMemSize
(
SResultRowPool
*
p
)
{
if
(
p
==
NULL
)
{
return
0
;
}
return
taosArrayGetSize
(
p
->
pData
)
*
p
->
blockSize
;
}
int32_t
getNumOfAllocatedResultRows
(
SResultRowPool
*
p
)
{
return
(
int32_t
)
taosArrayGetSize
(
p
->
pData
)
*
p
->
numOfElemPerBlock
;
}
int32_t
getNumOfUsedResultRows
(
SResultRowPool
*
p
)
{
return
getNumOfAllocatedResultRows
(
p
)
-
p
->
numOfElemPerBlock
+
p
->
position
.
pos
;
}
void
*
destroyResultRowPool
(
SResultRowPool
*
p
)
{
if
(
p
==
NULL
)
{
return
NULL
;
}
size_t
size
=
taosArrayGetSize
(
p
->
pData
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
void
**
ptr
=
taosArrayGet
(
p
->
pData
,
i
);
tfree
(
*
ptr
);
}
taosArrayDestroy
(
p
->
pData
);
tfree
(
p
);
return
NULL
;
}
void
interResToBinary
(
SBufferWriter
*
bw
,
SArray
*
pRes
,
int32_t
tagLen
)
{
uint32_t
numOfGroup
=
(
uint32_t
)
taosArrayGetSize
(
pRes
);
tbufWriteUint32
(
bw
,
numOfGroup
);
tbufWriteUint16
(
bw
,
tagLen
);
for
(
int32_t
i
=
0
;
i
<
numOfGroup
;
++
i
)
{
SInterResult
*
pOne
=
taosArrayGet
(
pRes
,
i
);
if
(
tagLen
>
0
)
{
tbufWriteBinary
(
bw
,
pOne
->
tags
,
tagLen
);
}
uint32_t
numOfCols
=
(
uint32_t
)
taosArrayGetSize
(
pOne
->
pResult
);
tbufWriteUint32
(
bw
,
numOfCols
);
for
(
int32_t
j
=
0
;
j
<
numOfCols
;
++
j
)
{
SStddevInterResult
*
p
=
taosArrayGet
(
pOne
->
pResult
,
j
);
uint32_t
numOfRows
=
(
uint32_t
)
taosArrayGetSize
(
p
->
pResult
);
tbufWriteUint16
(
bw
,
p
->
colId
);
tbufWriteUint32
(
bw
,
numOfRows
);
for
(
int32_t
k
=
0
;
k
<
numOfRows
;
++
k
)
{
// SResPair v = *(SResPair*) taosArrayGet(p->pResult, k);
// tbufWriteDouble(bw, v.avg);
// tbufWriteInt64(bw, v.key);
}
}
}
}
SArray
*
interResFromBinary
(
const
char
*
data
,
int32_t
len
)
{
SBufferReader
br
=
tbufInitReader
(
data
,
len
,
false
);
uint32_t
numOfGroup
=
tbufReadUint32
(
&
br
);
uint16_t
tagLen
=
tbufReadUint16
(
&
br
);
char
*
tag
=
NULL
;
if
(
tagLen
>
0
)
{
tag
=
calloc
(
1
,
tagLen
);
}
SArray
*
pResult
=
taosArrayInit
(
4
,
sizeof
(
SInterResult
));
for
(
int32_t
i
=
0
;
i
<
numOfGroup
;
++
i
)
{
if
(
tagLen
>
0
)
{
memset
(
tag
,
0
,
tagLen
);
tbufReadToBinary
(
&
br
,
tag
,
tagLen
);
}
uint32_t
numOfCols
=
tbufReadUint32
(
&
br
);
SArray
*
p
=
taosArrayInit
(
numOfCols
,
sizeof
(
SStddevInterResult
));
for
(
int32_t
j
=
0
;
j
<
numOfCols
;
++
j
)
{
// int16_t colId = tbufReadUint16(&br);
int32_t
numOfRows
=
tbufReadUint32
(
&
br
);
// SStddevInterResult interRes = {.colId = colId, .pResult = taosArrayInit(4, sizeof(struct SResPair)),};
for
(
int32_t
k
=
0
;
k
<
numOfRows
;
++
k
)
{
// SResPair px = {0};
// px.avg = tbufReadDouble(&br);
// px.key = tbufReadInt64(&br);
//
// taosArrayPush(interRes.pResult, &px);
}
// taosArrayPush(p, &interRes);
}
char
*
p1
=
NULL
;
if
(
tagLen
>
0
)
{
p1
=
malloc
(
tagLen
);
memcpy
(
p1
,
tag
,
tagLen
);
}
SInterResult
d
=
{.
pResult
=
p
,
.
tags
=
p1
,};
taosArrayPush
(
pResult
,
&
d
);
}
tfree
(
tag
);
return
pResult
;
}
void
freeInterResult
(
void
*
param
)
{
SInterResult
*
pResult
=
(
SInterResult
*
)
param
;
tfree
(
pResult
->
tags
);
int32_t
numOfCols
=
(
int32_t
)
taosArrayGetSize
(
pResult
->
pResult
);
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SStddevInterResult
*
p
=
taosArrayGet
(
pResult
->
pResult
,
i
);
taosArrayDestroy
(
p
->
pResult
);
}
taosArrayDestroy
(
pResult
->
pResult
);
}
void
cleanupGroupResInfo
(
SGroupResInfo
*
pGroupResInfo
)
{
void
cleanupGroupResInfo
(
SGroupResInfo
*
pGroupResInfo
)
{
assert
(
pGroupResInfo
!=
NULL
);
assert
(
pGroupResInfo
!=
NULL
);
...
@@ -360,7 +219,7 @@ void initGroupResInfo(SGroupResInfo* pGroupResInfo, SResultRowInfo* pResultInfo)
...
@@ -360,7 +219,7 @@ void initGroupResInfo(SGroupResInfo* pGroupResInfo, SResultRowInfo* pResultInfo)
taosArrayDestroy
(
pGroupResInfo
->
pRows
);
taosArrayDestroy
(
pGroupResInfo
->
pRows
);
}
}
pGroupResInfo
->
pRows
=
taosArrayFromList
(
pResultInfo
->
p
Result
,
pResultInfo
->
size
,
POINTER_BYTES
);
pGroupResInfo
->
pRows
=
taosArrayFromList
(
pResultInfo
->
p
Position
,
pResultInfo
->
size
,
sizeof
(
SResultRowPosition
)
);
pGroupResInfo
->
index
=
0
;
pGroupResInfo
->
index
=
0
;
assert
(
pGroupResInfo
->
index
<=
getNumOfTotalRes
(
pGroupResInfo
));
assert
(
pGroupResInfo
->
index
<=
getNumOfTotalRes
(
pGroupResInfo
));
}
}
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/executor/src/tsort.c
浏览文件 @
db970c79
...
@@ -37,7 +37,6 @@ typedef struct SSortHandle {
...
@@ -37,7 +37,6 @@ typedef struct SSortHandle {
SArray
*
pOrderInfo
;
SArray
*
pOrderInfo
;
bool
nullFirst
;
bool
nullFirst
;
bool
hasVarCol
;
SArray
*
pOrderedSource
;
SArray
*
pOrderedSource
;
_sort_fetch_block_fn_t
fetchfp
;
_sort_fetch_block_fn_t
fetchfp
;
...
@@ -77,6 +76,10 @@ static SSDataBlock* createDataBlock_rv(SSchema* pSchema, int32_t numOfCols) {
...
@@ -77,6 +76,10 @@ static SSDataBlock* createDataBlock_rv(SSchema* pSchema, int32_t numOfCols) {
colInfo
.
info
.
bytes
=
pSchema
[
i
].
bytes
;
colInfo
.
info
.
bytes
=
pSchema
[
i
].
bytes
;
colInfo
.
info
.
colId
=
pSchema
[
i
].
colId
;
colInfo
.
info
.
colId
=
pSchema
[
i
].
colId
;
taosArrayPush
(
pBlock
->
pDataBlock
,
&
colInfo
);
taosArrayPush
(
pBlock
->
pDataBlock
,
&
colInfo
);
if
(
IS_VAR_DATA_TYPE
(
colInfo
.
info
.
type
))
{
pBlock
->
info
.
hasVarCol
=
true
;
}
}
}
return
pBlock
;
return
pBlock
;
...
@@ -155,7 +158,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
...
@@ -155,7 +158,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
while
(
start
<
pDataBlock
->
info
.
rows
)
{
while
(
start
<
pDataBlock
->
info
.
rows
)
{
int32_t
stop
=
0
;
int32_t
stop
=
0
;
blockDataSplitRows
(
pDataBlock
,
p
Handle
->
hasVarCol
,
start
,
&
stop
,
pHandle
->
pageSize
);
blockDataSplitRows
(
pDataBlock
,
p
DataBlock
->
info
.
hasVarCol
,
start
,
&
stop
,
pHandle
->
pageSize
);
SSDataBlock
*
p
=
blockDataExtractBlock
(
pDataBlock
,
start
,
stop
-
start
+
1
);
SSDataBlock
*
p
=
blockDataExtractBlock
(
pDataBlock
,
start
,
stop
-
start
+
1
);
if
(
p
==
NULL
)
{
if
(
p
==
NULL
)
{
return
terrno
;
return
terrno
;
...
@@ -179,7 +182,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
...
@@ -179,7 +182,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) {
start
=
stop
+
1
;
start
=
stop
+
1
;
}
}
blockDataClearup
(
pDataBlock
,
pHandle
->
hasVarCol
);
blockDataClearup
(
pDataBlock
);
SSDataBlock
*
pBlock
=
createOneDataBlock
(
pDataBlock
);
SSDataBlock
*
pBlock
=
createOneDataBlock
(
pDataBlock
);
int32_t
code
=
doAddNewExternalMemSource
(
pHandle
->
pBuf
,
pHandle
->
pOrderedSource
,
pBlock
,
&
pHandle
->
sourceId
);
int32_t
code
=
doAddNewExternalMemSource
(
pHandle
->
pBuf
,
pHandle
->
pOrderedSource
,
pBlock
,
&
pHandle
->
sourceId
);
...
@@ -309,7 +312,7 @@ static int32_t adjustMergeTreeForNextTuple(SExternalMemSource *pSource, SMultiwa
...
@@ -309,7 +312,7 @@ static int32_t adjustMergeTreeForNextTuple(SExternalMemSource *pSource, SMultiwa
}
}
static
SSDataBlock
*
getSortedBlockData
(
SSortHandle
*
pHandle
,
SMsortComparParam
*
cmpParam
,
int32_t
capacity
)
{
static
SSDataBlock
*
getSortedBlockData
(
SSortHandle
*
pHandle
,
SMsortComparParam
*
cmpParam
,
int32_t
capacity
)
{
blockDataClearup
(
pHandle
->
pDataBlock
,
pHandle
->
hasVarCol
);
blockDataClearup
(
pHandle
->
pDataBlock
);
while
(
1
)
{
while
(
1
)
{
if
(
cmpParam
->
numOfSources
==
pHandle
->
numOfCompletedSources
)
{
if
(
cmpParam
->
numOfSources
==
pHandle
->
numOfCompletedSources
)
{
...
@@ -475,7 +478,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
...
@@ -475,7 +478,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) {
setBufPageDirty
(
pPage
,
true
);
setBufPageDirty
(
pPage
,
true
);
releaseBufPage
(
pHandle
->
pBuf
,
pPage
);
releaseBufPage
(
pHandle
->
pBuf
,
pPage
);
blockDataClearup
(
pDataBlock
,
pHandle
->
hasVarCol
);
blockDataClearup
(
pDataBlock
);
}
}
tMergeTreeDestroy
(
pHandle
->
pMergeTree
);
tMergeTreeDestroy
(
pHandle
->
pMergeTree
);
...
...
source/libs/executor/test/executorTests.cpp
浏览文件 @
db970c79
...
@@ -55,8 +55,7 @@ typedef struct SDummyInputInfo {
...
@@ -55,8 +55,7 @@ typedef struct SDummyInputInfo {
SSDataBlock
*
pBlock
;
SSDataBlock
*
pBlock
;
}
SDummyInputInfo
;
}
SDummyInputInfo
;
SSDataBlock
*
getDummyBlock
(
void
*
param
,
bool
*
newgroup
)
{
SSDataBlock
*
getDummyBlock
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
SOperatorInfo
*
pOperator
=
static_cast
<
SOperatorInfo
*>
(
param
);
SDummyInputInfo
*
pInfo
=
static_cast
<
SDummyInputInfo
*>
(
pOperator
->
info
);
SDummyInputInfo
*
pInfo
=
static_cast
<
SDummyInputInfo
*>
(
pOperator
->
info
);
if
(
pInfo
->
current
>=
pInfo
->
totalPages
)
{
if
(
pInfo
->
current
>=
pInfo
->
totalPages
)
{
return
NULL
;
return
NULL
;
...
@@ -87,7 +86,7 @@ SSDataBlock* getDummyBlock(void* param, bool* newgroup) {
...
@@ -87,7 +86,7 @@ SSDataBlock* getDummyBlock(void* param, bool* newgroup) {
//
//
// taosArrayPush(pInfo->pBlock->pDataBlock, &colInfo1);
// taosArrayPush(pInfo->pBlock->pDataBlock, &colInfo1);
}
else
{
}
else
{
blockDataClearup
(
pInfo
->
pBlock
,
true
);
blockDataClearup
(
pInfo
->
pBlock
);
}
}
SSDataBlock
*
pBlock
=
pInfo
->
pBlock
;
SSDataBlock
*
pBlock
=
pInfo
->
pBlock
;
...
@@ -122,8 +121,7 @@ SSDataBlock* getDummyBlock(void* param, bool* newgroup) {
...
@@ -122,8 +121,7 @@ SSDataBlock* getDummyBlock(void* param, bool* newgroup) {
return
pBlock
;
return
pBlock
;
}
}
SSDataBlock
*
get2ColsDummyBlock
(
void
*
param
,
bool
*
newgroup
)
{
SSDataBlock
*
get2ColsDummyBlock
(
SOperatorInfo
*
pOperator
,
bool
*
newgroup
)
{
SOperatorInfo
*
pOperator
=
static_cast
<
SOperatorInfo
*>
(
param
);
SDummyInputInfo
*
pInfo
=
static_cast
<
SDummyInputInfo
*>
(
pOperator
->
info
);
SDummyInputInfo
*
pInfo
=
static_cast
<
SDummyInputInfo
*>
(
pOperator
->
info
);
if
(
pInfo
->
current
>=
pInfo
->
totalPages
)
{
if
(
pInfo
->
current
>=
pInfo
->
totalPages
)
{
return
NULL
;
return
NULL
;
...
@@ -153,7 +151,7 @@ SSDataBlock* get2ColsDummyBlock(void* param, bool* newgroup) {
...
@@ -153,7 +151,7 @@ SSDataBlock* get2ColsDummyBlock(void* param, bool* newgroup) {
taosArrayPush
(
pInfo
->
pBlock
->
pDataBlock
,
&
colInfo1
);
taosArrayPush
(
pInfo
->
pBlock
->
pDataBlock
,
&
colInfo1
);
}
else
{
}
else
{
blockDataClearup
(
pInfo
->
pBlock
,
false
);
blockDataClearup
(
pInfo
->
pBlock
);
}
}
SSDataBlock
*
pBlock
=
pInfo
->
pBlock
;
SSDataBlock
*
pBlock
=
pInfo
->
pBlock
;
...
...
source/libs/function/inc/taggfunction.h
浏览文件 @
db970c79
...
@@ -46,13 +46,6 @@ extern SAggFunctionInfo aggFunc[35];
...
@@ -46,13 +46,6 @@ extern SAggFunctionInfo aggFunc[35];
#define DATA_SET_FLAG ',' // to denote the output area has data, not null value
#define DATA_SET_FLAG ',' // to denote the output area has data, not null value
#define DATA_SET_FLAG_SIZE sizeof(DATA_SET_FLAG)
#define DATA_SET_FLAG_SIZE sizeof(DATA_SET_FLAG)
#define TOP_BOTTOM_QUERY_LIMIT 100
#define QUERY_IS_STABLE_QUERY(type) (((type)&TSDB_QUERY_TYPE_STABLE_QUERY) != 0)
#define QUERY_IS_JOIN_QUERY(type) (TSDB_QUERY_HAS_TYPE(type, TSDB_QUERY_TYPE_JOIN_QUERY))
#define QUERY_IS_PROJECTION_QUERY(type) (((type)&TSDB_QUERY_TYPE_PROJECTION_QUERY) != 0)
#define QUERY_IS_FREE_RESOURCE(type) (((type)&TSDB_QUERY_TYPE_FREE_RESOURCE) != 0)
typedef
struct
SInterpInfoDetail
{
typedef
struct
SInterpInfoDetail
{
TSKEY
ts
;
// interp specified timestamp
TSKEY
ts
;
// interp specified timestamp
int8_t
type
;
int8_t
type
;
...
@@ -61,9 +54,6 @@ typedef struct SInterpInfoDetail {
...
@@ -61,9 +54,6 @@ typedef struct SInterpInfoDetail {
#define GET_ROWCELL_INTERBUF(_c) ((void*) ((char*)(_c) + sizeof(SResultRowEntryInfo)))
#define GET_ROWCELL_INTERBUF(_c) ((void*) ((char*)(_c) + sizeof(SResultRowEntryInfo)))
#define IS_STREAM_QUERY_VALID(x) (((x)&TSDB_FUNCSTATE_STREAM) != 0)
#define IS_MULTIOUTPUT(x) (((x)&TSDB_FUNCSTATE_MO) != 0)
typedef
struct
STwaInfo
{
typedef
struct
STwaInfo
{
int8_t
hasResult
;
// flag to denote has value
int8_t
hasResult
;
// flag to denote has value
double
dOutput
;
double
dOutput
;
...
@@ -71,8 +61,6 @@ typedef struct STwaInfo {
...
@@ -71,8 +61,6 @@ typedef struct STwaInfo {
STimeWindow
win
;
STimeWindow
win
;
}
STwaInfo
;
}
STwaInfo
;
extern
int32_t
functionCompatList
[];
// compatible check array list
bool
topbot_datablock_filter
(
SqlFunctionCtx
*
pCtx
,
const
char
*
minval
,
const
char
*
maxval
);
bool
topbot_datablock_filter
(
SqlFunctionCtx
*
pCtx
,
const
char
*
minval
,
const
char
*
maxval
);
/**
/**
...
...
source/libs/function/src/builtinsimpl.c
浏览文件 @
db970c79
...
@@ -52,10 +52,6 @@ static void doFinalizer(SResultRowEntryInfo* pResInfo) { cleanupResultRowEntry(p
...
@@ -52,10 +52,6 @@ static void doFinalizer(SResultRowEntryInfo* pResInfo) { cleanupResultRowEntry(p
void
functionFinalizer
(
SqlFunctionCtx
*
pCtx
)
{
void
functionFinalizer
(
SqlFunctionCtx
*
pCtx
)
{
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
SResultRowEntryInfo
*
pResInfo
=
GET_RES_INFO
(
pCtx
);
if
(
pResInfo
->
hasResult
!=
DATA_SET_FLAG
)
{
// setNull(pCtx->pOutput, pCtx->resDataInfo.type, pCtx->resDataInfo.bytes);
}
doFinalizer
(
pResInfo
);
doFinalizer
(
pResInfo
);
}
}
...
@@ -398,7 +394,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
...
@@ -398,7 +394,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) {
int32_t
*
pData
=
(
int32_t
*
)
pCol
->
pData
;
int32_t
*
pData
=
(
int32_t
*
)
pCol
->
pData
;
int32_t
*
val
=
(
int32_t
*
)
buf
;
int32_t
*
val
=
(
int32_t
*
)
buf
;
for
(
int32_t
i
=
0
;
i
<
pCtx
->
size
;
++
i
)
{
for
(
int32_t
i
=
start
;
i
<
start
+
numOfRows
;
++
i
)
{
if
((
pCol
->
hasNull
)
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
if
((
pCol
->
hasNull
)
&&
colDataIsNull_f
(
pCol
->
nullbitmap
,
i
))
{
continue
;
continue
;
}
}
...
...
source/libs/function/src/tfunction.c
已删除
100644 → 0
浏览文件 @
882575fd
#include "os.h"
#include "tarray.h"
#include "function.h"
#include "thash.h"
#include "taggfunction.h"
static
SHashObj
*
functionHashTable
=
NULL
;
static
SHashObj
*
udfHashTable
=
NULL
;
static
void
doInitFunctionHashTable
()
{
int
numOfEntries
=
tListLen
(
aggFunc
);
functionHashTable
=
taosHashInit
(
numOfEntries
,
MurmurHash3_32
,
false
,
false
);
for
(
int32_t
i
=
0
;
i
<
numOfEntries
;
i
++
)
{
int32_t
len
=
(
uint32_t
)
strlen
(
aggFunc
[
i
].
name
);
SAggFunctionInfo
*
ptr
=
&
aggFunc
[
i
];
taosHashPut
(
functionHashTable
,
aggFunc
[
i
].
name
,
len
,
(
void
*
)
&
ptr
,
POINTER_BYTES
);
}
/*
numOfEntries = tListLen(scalarFunc);
for(int32_t i = 0; i < numOfEntries; ++i) {
int32_t len = (int32_t) strlen(scalarFunc[i].name);
SScalarFunctionInfo* ptr = &scalarFunc[i];
taosHashPut(functionHashTable, scalarFunc[i].name, len, (void*)&ptr, POINTER_BYTES);
}
*/
udfHashTable
=
taosHashInit
(
numOfEntries
,
MurmurHash3_32
,
true
,
true
);
}
static
pthread_once_t
functionHashTableInit
=
PTHREAD_ONCE_INIT
;
int32_t
qIsBuiltinFunction
(
const
char
*
name
,
int32_t
len
,
bool
*
scalarFunction
)
{
pthread_once
(
&
functionHashTableInit
,
doInitFunctionHashTable
);
SAggFunctionInfo
**
pInfo
=
taosHashGet
(
functionHashTable
,
name
,
len
);
if
(
pInfo
!=
NULL
)
{
*
scalarFunction
=
((
*
pInfo
)
->
type
==
FUNCTION_TYPE_SCALAR
);
return
(
*
pInfo
)
->
functionId
;
}
else
{
return
-
1
;
}
}
bool
qIsValidUdf
(
SArray
*
pUdfInfo
,
const
char
*
name
,
int32_t
len
,
int32_t
*
functionId
)
{
return
true
;
}
bool
qIsAggregateFunction
(
const
char
*
functionName
)
{
assert
(
functionName
!=
NULL
);
bool
scalarfunc
=
false
;
qIsBuiltinFunction
(
functionName
,
strlen
(
functionName
),
&
scalarfunc
);
return
!
scalarfunc
;
}
bool
qIsSelectivityFunction
(
const
char
*
functionName
)
{
assert
(
functionName
!=
NULL
);
pthread_once
(
&
functionHashTableInit
,
doInitFunctionHashTable
);
size_t
len
=
strlen
(
functionName
);
SAggFunctionInfo
**
pInfo
=
taosHashGet
(
functionHashTable
,
functionName
,
len
);
if
(
pInfo
!=
NULL
)
{
return
((
*
pInfo
)
->
status
|
FUNCSTATE_SELECTIVITY
)
!=
0
;
}
return
false
;
}
SAggFunctionInfo
*
qGetFunctionInfo
(
const
char
*
name
,
int32_t
len
)
{
pthread_once
(
&
functionHashTableInit
,
doInitFunctionHashTable
);
SAggFunctionInfo
**
pInfo
=
taosHashGet
(
functionHashTable
,
name
,
len
);
if
(
pInfo
!=
NULL
)
{
return
(
*
pInfo
);
}
else
{
return
NULL
;
}
}
void
qAddUdfInfo
(
uint64_t
id
,
SUdfInfo
*
pUdfInfo
)
{
int32_t
len
=
(
uint32_t
)
strlen
(
pUdfInfo
->
name
);
taosHashPut
(
udfHashTable
,
pUdfInfo
->
name
,
len
,
(
void
*
)
&
pUdfInfo
,
POINTER_BYTES
);
}
void
qRemoveUdfInfo
(
uint64_t
id
,
SUdfInfo
*
pUdfInfo
)
{
int32_t
len
=
(
uint32_t
)
strlen
(
pUdfInfo
->
name
);
taosHashRemove
(
udfHashTable
,
pUdfInfo
->
name
,
len
);
}
bool
isTagsQuery
(
SArray
*
pFunctionIdList
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
char
*
f
=
*
(
char
**
)
taosArrayGet
(
pFunctionIdList
,
i
);
// todo handle count(tbname) query
if
(
strcmp
(
f
,
"project"
)
!=
0
&&
strcmp
(
f
,
"count"
)
!=
0
)
{
return
false
;
}
// "select count(tbname)" query
// if (functId == FUNCTION_COUNT && pExpr->base.colpDesc->colId == TSDB_TBNAME_COLUMN_INDEX) {
// continue;
// }
}
return
true
;
}
//bool tscMultiRoundQuery(SArray* pFunctionIdList, int32_t index) {
// if (!UTIL_TABLE_IS_SUPER_TABLE(pQueryInfo->pTableMetaInfo[index])) {
// return false;
// }
//
// size_t numOfExprs = (int32_t) getNumOfExprs(pQueryInfo);
// for(int32_t i = 0; i < numOfExprs; ++i) {
// SExprInfo* pExpr = getExprInfo(pQueryInfo, i);
// if (pExpr->base.functionId == FUNCTION_STDDEV_DST) {
// return true;
// }
// }
//
// return false;
//}
bool
isProjectionQuery
(
SArray
*
pFunctionIdList
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
char
*
f
=
*
(
char
**
)
taosArrayGet
(
pFunctionIdList
,
i
);
if
(
strcmp
(
f
,
"project"
)
==
0
)
{
return
true
;
}
}
return
false
;
}
bool
isDiffDerivativeQuery
(
SArray
*
pFunctionIdList
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int32_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
if
(
f
==
FUNCTION_TS_DUMMY
)
{
continue
;
}
if
(
f
==
FUNCTION_DIFF
||
f
==
FUNCTION_DERIVATIVE
)
{
return
true
;
}
}
return
false
;
}
bool
isInterpQuery
(
SArray
*
pFunctionIdList
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int32_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
if
(
f
==
FUNCTION_TAG
||
f
==
FUNCTION_TS
)
{
continue
;
}
if
(
f
!=
FUNCTION_INTERP
)
{
return
false
;
}
}
return
true
;
}
bool
isArithmeticQueryOnAggResult
(
SArray
*
pFunctionIdList
)
{
if
(
isProjectionQuery
(
pFunctionIdList
))
{
return
false
;
}
assert
(
0
);
// size_t numOfOutput = getNumOfFields(pQueryInfo);
// for(int32_t i = 0; i < numOfOutput; ++i) {
// SExprInfo* pExprInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, i)->pExpr;
// if (pExprInfo->pExpr != NULL) {
// return true;
// }
// }
return
false
;
}
bool
isGroupbyColumn
(
SGroupbyExpr
*
pGroupby
)
{
return
!
pGroupby
->
groupbyTag
;
}
bool
isTopBotQuery
(
SArray
*
pFunctionIdList
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
char
*
f
=
*
(
char
**
)
taosArrayGet
(
pFunctionIdList
,
i
);
if
(
strcmp
(
f
,
"project"
)
==
0
)
{
continue
;
}
if
(
strcmp
(
f
,
"top"
)
==
0
||
strcmp
(
f
,
"bottom"
)
==
0
)
{
return
true
;
}
}
return
false
;
}
bool
isTsCompQuery
(
SArray
*
pFunctionIdList
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
if
(
num
!=
1
)
{
return
false
;
}
int32_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
0
);
return
f
==
FUNCTION_TS_COMP
;
}
bool
isTWAQuery
(
SArray
*
pFunctionIdList
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int32_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
if
(
f
==
FUNCTION_TWA
)
{
return
true
;
}
}
return
false
;
}
bool
isIrateQuery
(
SArray
*
pFunctionIdList
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int32_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
if
(
f
==
FUNCTION_IRATE
)
{
return
true
;
}
}
return
false
;
}
bool
isStabledev
(
SArray
*
pFunctionIdList
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int32_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
if
(
f
==
FUNCTION_STDDEV_DST
)
{
return
true
;
}
}
return
false
;
}
bool
needReverseScan
(
SArray
*
pFunctionIdList
)
{
assert
(
0
);
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
for
(
int32_t
i
=
0
;
i
<
num
;
++
i
)
{
int32_t
f
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
if
(
f
==
FUNCTION_TS
||
f
==
FUNCTION_TS_DUMMY
||
f
==
FUNCTION_TAG
)
{
continue
;
}
// if ((f == FUNCTION_FIRST || f == FUNCTION_FIRST_DST) && pQueryInfo->order.order == TSDB_ORDER_DESC) {
// return true;
// }
if
(
f
==
FUNCTION_LAST
||
f
==
FUNCTION_LAST_DST
)
{
// the scan order to acquire the last result of the specified column
// int32_t order = (int32_t)pExpr->base.param[0].i64;
// if (order != pQueryInfo->order.order) {
// return true;
// }
}
}
return
false
;
}
bool
isAgg
(
SArray
*
pFunctionIdList
)
{
size_t
size
=
taosArrayGetSize
(
pFunctionIdList
);
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
char
*
f
=
*
(
char
**
)
taosArrayGet
(
pFunctionIdList
,
i
);
if
(
strcmp
(
f
,
"project"
)
==
0
)
{
return
false
;
}
if
(
qIsAggregateFunction
(
f
))
{
return
true
;
}
}
return
false
;
}
bool
isBlockDistQuery
(
SArray
*
pFunctionIdList
)
{
int32_t
num
=
(
int32_t
)
taosArrayGetSize
(
pFunctionIdList
);
char
*
f
=
*
(
char
**
)
taosArrayGet
(
pFunctionIdList
,
0
);
return
(
num
==
1
&&
strcmp
(
f
,
"block_dist"
)
==
0
);
}
bool
isTwoStageSTableQuery
(
SArray
*
pFunctionIdList
,
int32_t
tableIndex
)
{
// if (pQueryInfo == NULL) {
// return false;
// }
//
// STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex);
// if (pTableMetaInfo == NULL) {
// return false;
// }
//
// if ((pQueryInfo->type & TSDB_QUERY_TYPE_FREE_RESOURCE) == TSDB_QUERY_TYPE_FREE_RESOURCE) {
// return false;
// }
//
// // for ordered projection query, iterate all qualified vnodes sequentially
// if (tscNonOrderedProjectionQueryOnSTable(pQueryInfo, tableIndex)) {
// return false;
// }
//
// if (!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_STABLE_SUBQUERY) && pQueryInfo->command == TSDB_SQL_SELECT) {
// return UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo);
// }
return
false
;
}
bool
isProjectionQueryOnSTable
(
SArray
*
pFunctionIdList
,
int32_t
tableIndex
)
{
// STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex);
//
// /*
// * In following cases, return false for non ordered project query on super table
// * 1. failed to get tableMeta from server; 2. not a super table; 3. limitation is 0;
// * 4. show queries, instead of a select query
// */
// size_t numOfExprs = getNumOfExprs(pQueryInfo);
// if (pTableMetaInfo == NULL || !UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo) ||
// pQueryInfo->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT || numOfExprs == 0) {
// return false;
// }
//
// for (int32_t i = 0; i < numOfExprs; ++i) {
// int32_t functionId = getExprInfo(pQueryInfo, i)->base.functionId;
//
// if (functionId < 0) {
// SUdfInfo* pUdfInfo = taosArrayGet(pQueryInfo->pUdfInfo, -1 * functionId - 1);
// if (pUdfInfo->funcType == TSDB_FUNC_TYPE_AGGREGATE) {
// return false;
// }
//
// continue;
// }
//
// if (functionId != FUNCTION_PRJ &&
// functionId != FUNCTION_TAGPRJ &&
// functionId != FUNCTION_TAG &&
// functionId != FUNCTION_TS &&
// functionId != FUNCTION_ARITHM &&
// functionId != FUNCTION_TS_COMP &&
// functionId != FUNCTION_DIFF &&
// functionId != FUNCTION_DERIVATIVE &&
// functionId != FUNCTION_TS_DUMMY &&
// functionId != FUNCTION_TID_TAG) {
// return false;
// }
// }
return
true
;
}
bool
hasTagValOutput
(
SArray
*
pFunctionIdList
)
{
size_t
size
=
taosArrayGetSize
(
pFunctionIdList
);
// if (numOfExprs == 1 && pExpr1->base.functionId == FUNCTION_TS_COMP) {
// return true;
// }
for
(
int32_t
i
=
0
;
i
<
size
;
++
i
)
{
int32_t
functionId
=
*
(
int16_t
*
)
taosArrayGet
(
pFunctionIdList
,
i
);
// ts_comp column required the tag value for join filter
if
(
functionId
==
FUNCTION_TAG
||
functionId
==
FUNCTION_TAGPRJ
)
{
return
true
;
}
}
return
false
;
}
//bool timeWindowInterpoRequired(SArray* pFunctionIdList) {
// int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList);
// for (int32_t i = 0; i < num; ++i) {
// int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i);
// if (f == FUNCTION_TWA || f == FUNCTION_INTERP) {
// return true;
// }
// }
//
// return false;
//}
void
extractFunctionDesc
(
SArray
*
pFunctionIdList
,
SMultiFunctionsDesc
*
pDesc
)
{
assert
(
pFunctionIdList
!=
NULL
);
pDesc
->
blockDistribution
=
isBlockDistQuery
(
pFunctionIdList
);
if
(
pDesc
->
blockDistribution
)
{
return
;
}
// pDesc->projectionQuery = isProjectionQuery(pFunctionIdList);
// pDesc->onlyTagQuery = isTagsQuery(pFunctionIdList);
pDesc
->
interpQuery
=
isInterpQuery
(
pFunctionIdList
);
pDesc
->
topbotQuery
=
isTopBotQuery
(
pFunctionIdList
);
pDesc
->
agg
=
isAgg
(
pFunctionIdList
);
}
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
db970c79
...
@@ -183,6 +183,12 @@ static SNode* groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode
...
@@ -183,6 +183,12 @@ static SNode* groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode
return
(
SNode
*
)
pDst
;
return
(
SNode
*
)
pDst
;
}
}
static
SNode
*
fillNodeCopy
(
const
SFillNode
*
pSrc
,
SFillNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
mode
);
CLONE_NODE_FIELD
(
pValues
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicNodeCopy
(
const
SLogicNode
*
pSrc
,
SLogicNode
*
pDst
)
{
static
SNode
*
logicNodeCopy
(
const
SLogicNode
*
pSrc
,
SLogicNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
id
);
COPY_SCALAR_FIELD
(
id
);
CLONE_NODE_LIST_FIELD
(
pTargets
);
CLONE_NODE_LIST_FIELD
(
pTargets
);
...
@@ -248,6 +254,17 @@ static SNode* logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNo
...
@@ -248,6 +254,17 @@ static SNode* logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNo
return
(
SNode
*
)
pDst
;
return
(
SNode
*
)
pDst
;
}
}
static
SNode
*
logicWindowCopy
(
const
SWindowLogicNode
*
pSrc
,
SWindowLogicNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
COPY_SCALAR_FIELD
(
winType
);
CLONE_NODE_LIST_FIELD
(
pFuncs
);
COPY_SCALAR_FIELD
(
interval
);
COPY_SCALAR_FIELD
(
offset
);
COPY_SCALAR_FIELD
(
sliding
);
CLONE_NODE_FIELD
(
pFill
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicSubplanCopy
(
const
SSubLogicPlan
*
pSrc
,
SSubLogicPlan
*
pDst
)
{
static
SNode
*
logicSubplanCopy
(
const
SSubLogicPlan
*
pSrc
,
SSubLogicPlan
*
pDst
)
{
CLONE_NODE_FIELD
(
pNode
);
CLONE_NODE_FIELD
(
pNode
);
COPY_SCALAR_FIELD
(
subplanType
);
COPY_SCALAR_FIELD
(
subplanType
);
...
@@ -309,6 +326,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
...
@@ -309,6 +326,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
case
QUERY_NODE_ORDER_BY_EXPR
:
case
QUERY_NODE_ORDER_BY_EXPR
:
case
QUERY_NODE_LIMIT
:
case
QUERY_NODE_LIMIT
:
break
;
break
;
case
QUERY_NODE_FILL
:
return
fillNodeCopy
((
const
SFillNode
*
)
pNode
,
(
SFillNode
*
)
pDst
);
case
QUERY_NODE_DATABLOCK_DESC
:
case
QUERY_NODE_DATABLOCK_DESC
:
return
dataBlockDescCopy
((
const
SDataBlockDescNode
*
)
pNode
,
(
SDataBlockDescNode
*
)
pDst
);
return
dataBlockDescCopy
((
const
SDataBlockDescNode
*
)
pNode
,
(
SDataBlockDescNode
*
)
pDst
);
case
QUERY_NODE_SLOT_DESC
:
case
QUERY_NODE_SLOT_DESC
:
...
@@ -325,6 +344,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
...
@@ -325,6 +344,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
return
logicVnodeModifCopy
((
const
SVnodeModifLogicNode
*
)
pNode
,
(
SVnodeModifLogicNode
*
)
pDst
);
return
logicVnodeModifCopy
((
const
SVnodeModifLogicNode
*
)
pNode
,
(
SVnodeModifLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_PLAN_EXCHANGE
:
case
QUERY_NODE_LOGIC_PLAN_EXCHANGE
:
return
logicExchangeCopy
((
const
SExchangeLogicNode
*
)
pNode
,
(
SExchangeLogicNode
*
)
pDst
);
return
logicExchangeCopy
((
const
SExchangeLogicNode
*
)
pNode
,
(
SExchangeLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
return
logicWindowCopy
((
const
SWindowLogicNode
*
)
pNode
,
(
SWindowLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
logicSubplanCopy
((
const
SSubLogicPlan
*
)
pNode
,
(
SSubLogicPlan
*
)
pDst
);
return
logicSubplanCopy
((
const
SSubLogicPlan
*
)
pNode
,
(
SSubLogicPlan
*
)
pDst
);
default:
default:
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
db970c79
...
@@ -117,6 +117,8 @@ const char* nodesNodeName(ENodeType type) {
...
@@ -117,6 +117,8 @@ const char* nodesNodeName(ENodeType type) {
return
"PhysiExchange"
;
return
"PhysiExchange"
;
case
QUERY_NODE_PHYSICAL_PLAN_SORT
:
case
QUERY_NODE_PHYSICAL_PLAN_SORT
:
return
"PhysiSort"
;
return
"PhysiSort"
;
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
"PhysiInterval"
;
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
"PhysiDispatch"
;
return
"PhysiDispatch"
;
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
...
@@ -149,8 +151,7 @@ static int32_t nodeListToJson(SJson* pJson, const char* pName, const SNodeList*
...
@@ -149,8 +151,7 @@ static int32_t nodeListToJson(SJson* pJson, const char* pName, const SNodeList*
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
jsonToNodeList
(
const
SJson
*
pJson
,
const
char
*
pName
,
SNodeList
**
pList
)
{
static
int32_t
jsonToNodeListImpl
(
const
SJson
*
pJsonArray
,
SNodeList
**
pList
)
{
const
SJson
*
pJsonArray
=
tjsonGetObjectItem
(
pJson
,
pName
);
int32_t
size
=
(
NULL
==
pJsonArray
?
0
:
tjsonGetArraySize
(
pJsonArray
));
int32_t
size
=
(
NULL
==
pJsonArray
?
0
:
tjsonGetArraySize
(
pJsonArray
));
if
(
size
>
0
)
{
if
(
size
>
0
)
{
*
pList
=
nodesMakeList
();
*
pList
=
nodesMakeList
();
...
@@ -174,6 +175,10 @@ static int32_t jsonToNodeList(const SJson* pJson, const char* pName, SNodeList**
...
@@ -174,6 +175,10 @@ static int32_t jsonToNodeList(const SJson* pJson, const char* pName, SNodeList**
return
code
;
return
code
;
}
}
static
int32_t
jsonToNodeList
(
const
SJson
*
pJson
,
const
char
*
pName
,
SNodeList
**
pList
)
{
return
jsonToNodeListImpl
(
tjsonGetObjectItem
(
pJson
,
pName
),
pList
);
}
static
const
char
*
jkTableMetaUid
=
"TableMetaUid"
;
static
const
char
*
jkTableMetaUid
=
"TableMetaUid"
;
static
const
char
*
jkTableMetaSuid
=
"TableMetaSuid"
;
static
const
char
*
jkTableMetaSuid
=
"TableMetaSuid"
;
...
@@ -573,6 +578,79 @@ static int32_t jsonToPhysiExchangeNode(const SJson* pJson, void* pObj) {
...
@@ -573,6 +578,79 @@ static int32_t jsonToPhysiExchangeNode(const SJson* pJson, void* pObj) {
return
code
;
return
code
;
}
}
static
const
char
*
jkIntervalPhysiPlanExprs
=
"Exprs"
;
static
const
char
*
jkIntervalPhysiPlanFuncs
=
"Funcs"
;
static
const
char
*
jkIntervalPhysiPlanInterval
=
"Interval"
;
static
const
char
*
jkIntervalPhysiPlanOffset
=
"Offset"
;
static
const
char
*
jkIntervalPhysiPlanSliding
=
"Sliding"
;
static
const
char
*
jkIntervalPhysiPlanIntervalUnit
=
"intervalUnit"
;
static
const
char
*
jkIntervalPhysiPlanSlidingUnit
=
"slidingUnit"
;
static
const
char
*
jkIntervalPhysiPlanFill
=
"Fill"
;
static
int32_t
physiIntervalNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SIntervalPhysiNode
*
pNode
=
(
const
SIntervalPhysiNode
*
)
pObj
;
int32_t
code
=
physicPlanNodeToJson
(
pObj
,
pJson
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkIntervalPhysiPlanExprs
,
pNode
->
pExprs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkIntervalPhysiPlanFuncs
,
pNode
->
pFuncs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkIntervalPhysiPlanInterval
,
pNode
->
interval
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkIntervalPhysiPlanOffset
,
pNode
->
offset
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkIntervalPhysiPlanSliding
,
pNode
->
sliding
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkIntervalPhysiPlanIntervalUnit
,
pNode
->
intervalUnit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkIntervalPhysiPlanSlidingUnit
,
pNode
->
slidingUnit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkIntervalPhysiPlanFill
,
nodeToJson
,
pNode
->
pFill
);
}
return
code
;
}
static
int32_t
jsonToPhysiIntervalNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SIntervalPhysiNode
*
pNode
=
(
SIntervalPhysiNode
*
)
pObj
;
int32_t
code
=
jsonToPhysicPlanNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkIntervalPhysiPlanExprs
,
&
pNode
->
pExprs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkIntervalPhysiPlanFuncs
,
&
pNode
->
pFuncs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkIntervalPhysiPlanInterval
,
&
pNode
->
interval
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkIntervalPhysiPlanOffset
,
&
pNode
->
offset
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetBigIntValue
(
pJson
,
jkIntervalPhysiPlanSliding
,
&
pNode
->
sliding
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetTinyIntValue
(
pJson
,
jkIntervalPhysiPlanIntervalUnit
,
&
pNode
->
intervalUnit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetTinyIntValue
(
pJson
,
jkIntervalPhysiPlanSlidingUnit
,
&
pNode
->
slidingUnit
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkIntervalPhysiPlanFill
,
(
SNode
**
)
&
pNode
->
pFill
);
}
return
code
;
}
static
const
char
*
jkDataSinkInputDataBlockDesc
=
"InputDataBlockDesc"
;
static
const
char
*
jkDataSinkInputDataBlockDesc
=
"InputDataBlockDesc"
;
static
int32_t
physicDataSinkNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
physicDataSinkNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
...
@@ -1500,6 +1578,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -1500,6 +1578,8 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
return
physiExchangeNodeToJson
(
pObj
,
pJson
);
return
physiExchangeNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_SORT
:
case
QUERY_NODE_PHYSICAL_PLAN_SORT
:
break
;
break
;
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
physiIntervalNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
physiDispatchNodeToJson
(
pObj
,
pJson
);
return
physiDispatchNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
...
@@ -1581,7 +1661,10 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
...
@@ -1581,7 +1661,10 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return
jsonToSubplan
(
pJson
,
pObj
);
return
jsonToSubplan
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN
:
case
QUERY_NODE_PHYSICAL_PLAN
:
return
jsonToPlan
(
pJson
,
pObj
);
return
jsonToPlan
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
jsonToPhysiIntervalNode
(
pJson
,
pObj
);
default:
default:
assert
(
0
);
break
;
break
;
}
}
nodesWarn
(
"jsonToSpecificNode unknown node = %s"
,
nodesNodeName
(
nodeType
(
pObj
)));
nodesWarn
(
"jsonToSpecificNode unknown node = %s"
,
nodesNodeName
(
nodeType
(
pObj
)));
...
@@ -1687,3 +1770,52 @@ int32_t nodesStringToNode(const char* pStr, SNode** pNode) {
...
@@ -1687,3 +1770,52 @@ int32_t nodesStringToNode(const char* pStr, SNode** pNode) {
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
nodesListToString
(
const
SNodeList
*
pList
,
bool
format
,
char
**
pStr
,
int32_t
*
pLen
)
{
if
(
NULL
==
pList
||
NULL
==
pStr
||
NULL
==
pLen
)
{
terrno
=
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
if
(
0
==
LIST_LENGTH
(
pList
))
{
return
TSDB_CODE_SUCCESS
;
}
SJson
*
pJson
=
tjsonCreateArray
();
if
(
NULL
==
pJson
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SNode
*
pNode
;
FOREACH
(
pNode
,
pList
)
{
int32_t
code
=
tjsonAddItem
(
pJson
,
nodeToJson
,
pNode
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
terrno
=
code
;
return
code
;
}
}
*
pStr
=
format
?
tjsonToString
(
pJson
)
:
tjsonToUnformattedString
(
pJson
);
tjsonDelete
(
pJson
);
*
pLen
=
strlen
(
*
pStr
)
+
1
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
nodesStringToList
(
const
char
*
pStr
,
SNodeList
**
pList
)
{
if
(
NULL
==
pStr
||
NULL
==
pList
)
{
return
TSDB_CODE_SUCCESS
;
}
SJson
*
pJson
=
tjsonParse
(
pStr
);
if
(
NULL
==
pJson
)
{
return
TSDB_CODE_FAILED
;
}
int32_t
code
=
jsonToNodeListImpl
(
pJson
,
pList
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
nodesDestroyList
(
*
pList
);
terrno
=
code
;
return
code
;
}
return
TSDB_CODE_SUCCESS
;
}
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
db970c79
...
@@ -76,6 +76,12 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -76,6 +76,12 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SColumnDefNode
));
return
makeNode
(
type
,
sizeof
(
SColumnDefNode
));
case
QUERY_NODE_DOWNSTREAM_SOURCE
:
case
QUERY_NODE_DOWNSTREAM_SOURCE
:
return
makeNode
(
type
,
sizeof
(
SDownstreamSourceNode
));
return
makeNode
(
type
,
sizeof
(
SDownstreamSourceNode
));
case
QUERY_NODE_DATABASE_OPTIONS
:
return
makeNode
(
type
,
sizeof
(
SDatabaseOptions
));
case
QUERY_NODE_TABLE_OPTIONS
:
return
makeNode
(
type
,
sizeof
(
STableOptions
));
case
QUERY_NODE_INDEX_OPTIONS
:
return
makeNode
(
type
,
sizeof
(
SIndexOptions
));
case
QUERY_NODE_SET_OPERATOR
:
case
QUERY_NODE_SET_OPERATOR
:
return
makeNode
(
type
,
sizeof
(
SSetOperator
));
return
makeNode
(
type
,
sizeof
(
SSetOperator
));
case
QUERY_NODE_SELECT_STMT
:
case
QUERY_NODE_SELECT_STMT
:
...
@@ -121,7 +127,12 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -121,7 +127,12 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_QNODES_STMT
:
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
return
makeNode
(
type
,
sizeof
(
SShowStmt
));
case
QUERY_NODE_CREATE_INDEX_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateIndexStmt
));
case
QUERY_NODE_CREATE_QNODE_STMT
:
return
makeNode
(
type
,
sizeof
(
SCreateQnodeStmt
));
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
case
QUERY_NODE_LOGIC_PLAN_SCAN
:
return
makeNode
(
type
,
sizeof
(
SScanLogicNode
));
return
makeNode
(
type
,
sizeof
(
SScanLogicNode
));
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
case
QUERY_NODE_LOGIC_PLAN_JOIN
:
...
@@ -134,6 +145,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -134,6 +145,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SVnodeModifLogicNode
));
return
makeNode
(
type
,
sizeof
(
SVnodeModifLogicNode
));
case
QUERY_NODE_LOGIC_PLAN_EXCHANGE
:
case
QUERY_NODE_LOGIC_PLAN_EXCHANGE
:
return
makeNode
(
type
,
sizeof
(
SExchangeLogicNode
));
return
makeNode
(
type
,
sizeof
(
SExchangeLogicNode
));
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
return
makeNode
(
type
,
sizeof
(
SWindowLogicNode
));
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
makeNode
(
type
,
sizeof
(
SSubLogicPlan
));
return
makeNode
(
type
,
sizeof
(
SSubLogicPlan
));
case
QUERY_NODE_LOGIC_PLAN
:
case
QUERY_NODE_LOGIC_PLAN
:
...
@@ -156,6 +169,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -156,6 +169,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SExchangePhysiNode
));
return
makeNode
(
type
,
sizeof
(
SExchangePhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_SORT
:
case
QUERY_NODE_PHYSICAL_PLAN_SORT
:
return
makeNode
(
type
,
sizeof
(
SNode
));
return
makeNode
(
type
,
sizeof
(
SNode
));
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
makeNode
(
type
,
sizeof
(
SIntervalPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
case
QUERY_NODE_PHYSICAL_PLAN_DISPATCH
:
return
makeNode
(
type
,
sizeof
(
SDataDispatcherNode
));
return
makeNode
(
type
,
sizeof
(
SDataDispatcherNode
));
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
case
QUERY_NODE_PHYSICAL_PLAN_INSERT
:
...
@@ -204,6 +219,14 @@ static EDealRes destroyNode(SNode** pNode, void* pContext) {
...
@@ -204,6 +219,14 @@ static EDealRes destroyNode(SNode** pNode, void* pContext) {
case
QUERY_NODE_NODE_LIST
:
case
QUERY_NODE_NODE_LIST
:
nodesClearList
(((
SNodeListNode
*
)(
*
pNode
))
->
pNodeList
);
nodesClearList
(((
SNodeListNode
*
)(
*
pNode
))
->
pNodeList
);
break
;
break
;
case
QUERY_NODE_INDEX_OPTIONS
:
{
SIndexOptions
*
pStmt
=
(
SIndexOptions
*
)
*
pNode
;
nodesDestroyList
(
pStmt
->
pFuncs
);
nodesDestroyNode
(
pStmt
->
pInterval
);
nodesDestroyNode
(
pStmt
->
pOffset
);
nodesDestroyNode
(
pStmt
->
pSliding
);
break
;
}
case
QUERY_NODE_SELECT_STMT
:
{
case
QUERY_NODE_SELECT_STMT
:
{
SSelectStmt
*
pStmt
=
(
SSelectStmt
*
)
*
pNode
;
SSelectStmt
*
pStmt
=
(
SSelectStmt
*
)
*
pNode
;
nodesDestroyList
(
pStmt
->
pProjectionList
);
nodesDestroyList
(
pStmt
->
pProjectionList
);
...
@@ -244,6 +267,12 @@ static EDealRes destroyNode(SNode** pNode, void* pContext) {
...
@@ -244,6 +267,12 @@ static EDealRes destroyNode(SNode** pNode, void* pContext) {
case
QUERY_NODE_CREATE_MULTI_TABLE_STMT
:
case
QUERY_NODE_CREATE_MULTI_TABLE_STMT
:
nodesDestroyList
(((
SCreateMultiTableStmt
*
)(
*
pNode
))
->
pSubTables
);
nodesDestroyList
(((
SCreateMultiTableStmt
*
)(
*
pNode
))
->
pSubTables
);
break
;
break
;
case
QUERY_NODE_CREATE_INDEX_STMT
:
{
SCreateIndexStmt
*
pStmt
=
(
SCreateIndexStmt
*
)
*
pNode
;
nodesDestroyNode
(
pStmt
->
pOptions
);
nodesDestroyList
(
pStmt
->
pCols
);
break
;
}
default:
default:
break
;
break
;
}
}
...
...
source/libs/parser/inc/parAst.h
浏览文件 @
db970c79
...
@@ -109,17 +109,17 @@ SNode* addLimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pLimit);
...
@@ -109,17 +109,17 @@ SNode* addLimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pLimit);
SNode
*
createSelectStmt
(
SAstCreateContext
*
pCxt
,
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
);
SNode
*
createSelectStmt
(
SAstCreateContext
*
pCxt
,
bool
isDistinct
,
SNodeList
*
pProjectionList
,
SNode
*
pTable
);
SNode
*
createSetOperator
(
SAstCreateContext
*
pCxt
,
ESetOperatorType
type
,
SNode
*
pLeft
,
SNode
*
pRight
);
SNode
*
createSetOperator
(
SAstCreateContext
*
pCxt
,
ESetOperatorType
type
,
SNode
*
pLeft
,
SNode
*
pRight
);
S
DatabaseOptions
*
createDefaultDatabaseOptions
(
SAstCreateContext
*
pCxt
);
S
Node
*
createDefaultDatabaseOptions
(
SAstCreateContext
*
pCxt
);
S
DatabaseOptions
*
setDatabaseOption
(
SAstCreateContext
*
pCxt
,
SDatabaseOptions
*
pOptions
,
EDatabaseOptionType
type
,
const
SToken
*
pVal
);
S
Node
*
setDatabaseOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
EDatabaseOptionType
type
,
const
SToken
*
pVal
);
SNode
*
createCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pDbName
,
S
DatabaseOptions
*
pOptions
);
SNode
*
createCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pDbName
,
S
Node
*
pOptions
);
SNode
*
createDropDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pDbName
);
SNode
*
createDropDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
const
SToken
*
pDbName
);
S
TableOptions
*
createDefaultTableOptions
(
SAstCreateContext
*
pCxt
);
S
Node
*
createDefaultTableOptions
(
SAstCreateContext
*
pCxt
);
S
TableOptions
*
setTableOption
(
SAstCreateContext
*
pCxt
,
STableOptions
*
pOptions
,
ETableOptionType
type
,
const
SToken
*
pVal
);
S
Node
*
setTableOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
ETableOptionType
type
,
const
SToken
*
pVal
);
S
TableOptions
*
setTableSmaOption
(
SAstCreateContext
*
pCxt
,
STableOptions
*
pOptions
,
SNodeList
*
pSma
);
S
Node
*
setTableSmaOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SNodeList
*
pSma
);
SNode
*
createColumnDefNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pColName
,
SDataType
dataType
,
const
SToken
*
pComment
);
SNode
*
createColumnDefNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pColName
,
SDataType
dataType
,
const
SToken
*
pComment
);
SDataType
createDataType
(
uint8_t
type
);
SDataType
createDataType
(
uint8_t
type
);
SDataType
createVarLenDataType
(
uint8_t
type
,
const
SToken
*
pLen
);
SDataType
createVarLenDataType
(
uint8_t
type
,
const
SToken
*
pLen
);
SNode
*
createCreateTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNodeList
*
pCols
,
SNodeList
*
pTags
,
S
TableOptions
*
pOptions
);
SNode
*
createCreateTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNodeList
*
pCols
,
SNodeList
*
pTags
,
S
Node
*
pOptions
);
SNode
*
createCreateSubTableClause
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNode
*
pUseRealTable
,
SNodeList
*
pSpecificTags
,
SNodeList
*
pValsOfTags
);
SNode
*
createCreateSubTableClause
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNode
*
pUseRealTable
,
SNodeList
*
pSpecificTags
,
SNodeList
*
pValsOfTags
);
SNode
*
createCreateMultiTableStmt
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pSubTables
);
SNode
*
createCreateMultiTableStmt
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pSubTables
);
SNode
*
createDropTableClause
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SNode
*
pRealTable
);
SNode
*
createDropTableClause
(
SAstCreateContext
*
pCxt
,
bool
ignoreNotExists
,
SNode
*
pRealTable
);
...
@@ -132,6 +132,9 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, const SToken* pUserName, int
...
@@ -132,6 +132,9 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, const SToken* pUserName, int
SNode
*
createDropUserStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pUserName
);
SNode
*
createDropUserStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pUserName
);
SNode
*
createCreateDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFqdn
,
const
SToken
*
pPort
);
SNode
*
createCreateDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pFqdn
,
const
SToken
*
pPort
);
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
);
SNode
*
createDropDnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnode
);
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
const
SToken
*
pIndexName
,
const
SToken
*
pTableName
,
SNodeList
*
pCols
,
SNode
*
pOptions
);
SNode
*
createIndexOption
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pFuncs
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
);
SNode
*
createCreateQnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnodeId
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/parser/inc/sql.y
浏览文件 @
db970c79
...
@@ -64,6 +64,10 @@ dnode_endpoint(A) ::= NK_STRING(B).
...
@@ -64,6 +64,10 @@ dnode_endpoint(A) ::= NK_STRING(B).
dnode_host_name(A) ::= NK_ID(B). { A = B; }
dnode_host_name(A) ::= NK_ID(B). { A = B; }
dnode_host_name(A) ::= NK_IPTOKEN(B). { A = B; }
dnode_host_name(A) ::= NK_IPTOKEN(B). { A = B; }
/************************************************ create qnode ********************************************************/
cmd ::= CREATE QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateQnodeStmt(pCxt, &A); }
cmd ::= SHOW QNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); }
/************************************************ create/drop/show/use database ***************************************/
/************************************************ create/drop/show/use database ***************************************/
cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C);}
cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C);}
cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); }
cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); }
...
@@ -80,8 +84,6 @@ not_exists_opt(A) ::= .
...
@@ -80,8 +84,6 @@ not_exists_opt(A) ::= .
exists_opt(A) ::= IF EXISTS. { A = true; }
exists_opt(A) ::= IF EXISTS. { A = true; }
exists_opt(A) ::= . { A = false; }
exists_opt(A) ::= . { A = false; }
%type db_options { SDatabaseOptions* }
%destructor db_options { tfree($$); }
db_options(A) ::= . { A = createDefaultDatabaseOptions(pCxt); }
db_options(A) ::= . { A = createDefaultDatabaseOptions(pCxt); }
db_options(A) ::= db_options(B) BLOCKS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_BLOCKS, &C); }
db_options(A) ::= db_options(B) BLOCKS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_BLOCKS, &C); }
db_options(A) ::= db_options(B) CACHE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_CACHE, &C); }
db_options(A) ::= db_options(B) CACHE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_CACHE, &C); }
...
@@ -179,8 +181,6 @@ tags_def_opt(A) ::= tags_def(B).
...
@@ -179,8 +181,6 @@ tags_def_opt(A) ::= tags_def(B).
%destructor tags_def { nodesDestroyList($$); }
%destructor tags_def { nodesDestroyList($$); }
tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP. { A = B; }
tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP. { A = B; }
%type table_options { STableOptions* }
%destructor table_options { tfree($$); }
table_options(A) ::= . { A = createDefaultTableOptions(pCxt);}
table_options(A) ::= . { A = createDefaultTableOptions(pCxt);}
table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); }
table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); }
table_options(A) ::= table_options(B) KEEP NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_KEEP, &C); }
table_options(A) ::= table_options(B) KEEP NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_KEEP, &C); }
...
@@ -194,11 +194,29 @@ col_name_list(A) ::= col_name_list(B) NK_COMMA col_name(C).
...
@@ -194,11 +194,29 @@ col_name_list(A) ::= col_name_list(B) NK_COMMA col_name(C).
col_name(A) ::= column_name(B). { A = createColumnNode(pCxt, NULL, &B); }
col_name(A) ::= column_name(B). { A = createColumnNode(pCxt, NULL, &B); }
/************************************************ create index ********************************************************/
cmd ::= CREATE SMA INDEX index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &A, &B, NULL, C); }
cmd ::= CREATE FULLTEXT INDEX
index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &A, &B, C, NULL); }
index_options(A) ::= . { A = NULL; }
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
NK_LP duration_literal(C) NK_RP sliding_opt(D). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D); }
index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL
NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E); }
%type func_list { SNodeList* }
%destructor func_list { nodesDestroyList($$); }
func_list(A) ::= func(B). { A = createNodeList(pCxt, B); }
func_list(A) ::= func_list(B) NK_COMMA func(C). { A = addNodeToList(pCxt, B, C); }
func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); }
/************************************************ show vgroups ********************************************************/
/************************************************ show vgroups ********************************************************/
cmd ::= SHOW VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); }
cmd ::= SHOW VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); }
cmd ::= SHOW db_name(B) NK_DOT VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &B); }
cmd ::= SHOW db_name(B) NK_DOT VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &B); }
/************************************************ show
vgroups
********************************************************/
/************************************************ show
mnodes *
********************************************************/
cmd ::= SHOW MNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL); }
cmd ::= SHOW MNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL); }
/************************************************ select **************************************************************/
/************************************************ select **************************************************************/
...
@@ -248,6 +266,10 @@ column_alias(A) ::= NK_ID(B).
...
@@ -248,6 +266,10 @@ column_alias(A) ::= NK_ID(B).
%destructor user_name { }
%destructor user_name { }
user_name(A) ::= NK_ID(B). { A = B; }
user_name(A) ::= NK_ID(B). { A = B; }
%type index_name { SToken }
%destructor index_name { }
index_name(A) ::= NK_ID(B). { A = B; }
/************************************************ expression **********************************************************/
/************************************************ expression **********************************************************/
expression(A) ::= literal(B). { A = B; }
expression(A) ::= literal(B). { A = B; }
//expression(A) ::= NK_QUESTION(B). { A = B; }
//expression(A) ::= NK_QUESTION(B). { A = B; }
...
@@ -463,13 +485,13 @@ twindow_clause_opt(A) ::=
...
@@ -463,13 +485,13 @@ twindow_clause_opt(A) ::=
SESSION NK_LP column_reference(B) NK_COMMA NK_INTEGER(C) NK_RP. { A = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, B), &C); }
SESSION NK_LP column_reference(B) NK_COMMA NK_INTEGER(C) NK_RP. { A = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, B), &C); }
twindow_clause_opt(A) ::= STATE_WINDOW NK_LP column_reference(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); }
twindow_clause_opt(A) ::= STATE_WINDOW NK_LP column_reference(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); }
twindow_clause_opt(A) ::=
twindow_clause_opt(A) ::=
INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt,
B
, NULL, C, D); }
INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt,
releaseRawExprNode(pCxt, B)
, NULL, C, D); }
twindow_clause_opt(A) ::=
twindow_clause_opt(A) ::=
INTERVAL NK_LP duration_literal(B) NK_COMMA duration_literal(C) NK_RP
INTERVAL NK_LP duration_literal(B) NK_COMMA duration_literal(C) NK_RP
sliding_opt(D) fill_opt(E). { A = createIntervalWindowNode(pCxt,
B, C
, D, E); }
sliding_opt(D) fill_opt(E). { A = createIntervalWindowNode(pCxt,
releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C)
, D, E); }
sliding_opt(A) ::= . { A = NULL; }
sliding_opt(A) ::= . { A = NULL; }
sliding_opt(A) ::= SLIDING NK_LP duration_literal(B) NK_RP. { A =
B
; }
sliding_opt(A) ::= SLIDING NK_LP duration_literal(B) NK_RP. { A =
releaseRawExprNode(pCxt, B)
; }
fill_opt(A) ::= . { A = NULL; }
fill_opt(A) ::= . { A = NULL; }
fill_opt(A) ::= FILL NK_LP fill_mode(B) NK_RP. { A = createFillNode(pCxt, B, NULL); }
fill_opt(A) ::= FILL NK_LP fill_mode(B) NK_RP. { A = createFillNode(pCxt, B, NULL); }
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
db970c79
...
@@ -420,6 +420,14 @@ static bool checkColumnName(SAstCreateContext* pCxt, const SToken* pColumnName)
...
@@ -420,6 +420,14 @@ static bool checkColumnName(SAstCreateContext* pCxt, const SToken* pColumnName)
return
pCxt
->
valid
;
return
pCxt
->
valid
;
}
}
static
bool
checkIndexName
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pIndexName
)
{
if
(
NULL
==
pIndexName
)
{
return
false
;
}
pCxt
->
valid
=
pIndexName
->
n
<
TSDB_INDEX_NAME_LEN
?
true
:
false
;
return
pCxt
->
valid
;
}
SNode
*
createRawExprNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pToken
,
SNode
*
pNode
)
{
SNode
*
createRawExprNode
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pToken
,
SNode
*
pNode
)
{
SRawExprNode
*
target
=
(
SRawExprNode
*
)
nodesMakeNode
(
QUERY_NODE_RAW_EXPR
);
SRawExprNode
*
target
=
(
SRawExprNode
*
)
nodesMakeNode
(
QUERY_NODE_RAW_EXPR
);
CHECK_OUT_OF_MEM
(
target
);
CHECK_OUT_OF_MEM
(
target
);
...
@@ -741,8 +749,8 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode*
...
@@ -741,8 +749,8 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode*
return
(
SNode
*
)
setOp
;
return
(
SNode
*
)
setOp
;
}
}
S
DatabaseOptions
*
createDefaultDatabaseOptions
(
SAstCreateContext
*
pCxt
)
{
S
Node
*
createDefaultDatabaseOptions
(
SAstCreateContext
*
pCxt
)
{
SDatabaseOptions
*
pOptions
=
calloc
(
1
,
sizeof
(
SDatabaseOptions
)
);
SDatabaseOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_DATABASE_OPTIONS
);
CHECK_OUT_OF_MEM
(
pOptions
);
CHECK_OUT_OF_MEM
(
pOptions
);
pOptions
->
numOfBlocks
=
TSDB_DEFAULT_TOTAL_BLOCKS
;
pOptions
->
numOfBlocks
=
TSDB_DEFAULT_TOTAL_BLOCKS
;
pOptions
->
cacheBlockSize
=
TSDB_DEFAULT_CACHE_BLOCK_SIZE
;
pOptions
->
cacheBlockSize
=
TSDB_DEFAULT_CACHE_BLOCK_SIZE
;
...
@@ -761,14 +769,14 @@ SDatabaseOptions* createDefaultDatabaseOptions(SAstCreateContext* pCxt) {
...
@@ -761,14 +769,14 @@ SDatabaseOptions* createDefaultDatabaseOptions(SAstCreateContext* pCxt) {
pOptions
->
numOfVgroups
=
TSDB_DEFAULT_VN_PER_DB
;
pOptions
->
numOfVgroups
=
TSDB_DEFAULT_VN_PER_DB
;
pOptions
->
singleStable
=
TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION
;
pOptions
->
singleStable
=
TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION
;
pOptions
->
streamMode
=
TSDB_DEFAULT_DB_STREAM_MODE_OPTION
;
pOptions
->
streamMode
=
TSDB_DEFAULT_DB_STREAM_MODE_OPTION
;
return
pOptions
;
return
(
SNode
*
)
pOptions
;
}
}
S
DatabaseOptions
*
setDatabaseOption
(
SAstCreateContext
*
pCxt
,
SDatabaseOptions
*
pOptions
,
EDatabaseOptionType
type
,
const
SToken
*
pVal
)
{
S
Node
*
setDatabaseOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
EDatabaseOptionType
type
,
const
SToken
*
pVal
)
{
return
setDbOptionFuncs
[
type
](
pCxt
,
pOptions
,
pVal
);
return
(
SNode
*
)
setDbOptionFuncs
[
type
](
pCxt
,
(
SDatabaseOptions
*
)
pOptions
,
pVal
);
}
}
SNode
*
createCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pDbName
,
S
DatabaseOptions
*
pOptions
)
{
SNode
*
createCreateDatabaseStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
const
SToken
*
pDbName
,
S
Node
*
pOptions
)
{
if
(
!
checkDbName
(
pCxt
,
pDbName
))
{
if
(
!
checkDbName
(
pCxt
,
pDbName
))
{
return
NULL
;
return
NULL
;
}
}
...
@@ -776,8 +784,7 @@ SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, cons
...
@@ -776,8 +784,7 @@ SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, cons
CHECK_OUT_OF_MEM
(
pStmt
);
CHECK_OUT_OF_MEM
(
pStmt
);
strncpy
(
pStmt
->
dbName
,
pDbName
->
z
,
pDbName
->
n
);
strncpy
(
pStmt
->
dbName
,
pDbName
->
z
,
pDbName
->
n
);
pStmt
->
ignoreExists
=
ignoreExists
;
pStmt
->
ignoreExists
=
ignoreExists
;
pStmt
->
options
=
*
pOptions
;
pStmt
->
pOptions
=
(
SDatabaseOptions
*
)
pOptions
;
tfree
(
pOptions
);
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
...
@@ -792,20 +799,20 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con
...
@@ -792,20 +799,20 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
S
TableOptions
*
createDefaultTableOptions
(
SAstCreateContext
*
pCxt
)
{
S
Node
*
createDefaultTableOptions
(
SAstCreateContext
*
pCxt
)
{
STableOptions
*
pOptions
=
calloc
(
1
,
sizeof
(
STableOptions
)
);
STableOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_TABLE_OPTIONS
);
CHECK_OUT_OF_MEM
(
pOptions
);
CHECK_OUT_OF_MEM
(
pOptions
);
pOptions
->
keep
=
TSDB_DEFAULT_KEEP
;
pOptions
->
keep
=
TSDB_DEFAULT_KEEP
;
pOptions
->
ttl
=
TSDB_DEFAULT_DB_TTL_OPTION
;
pOptions
->
ttl
=
TSDB_DEFAULT_DB_TTL_OPTION
;
return
pOptions
;
return
(
SNode
*
)
pOptions
;
}
}
S
TableOptions
*
setTableOption
(
SAstCreateContext
*
pCxt
,
STableOptions
*
pOptions
,
ETableOptionType
type
,
const
SToken
*
pVal
)
{
S
Node
*
setTableOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
ETableOptionType
type
,
const
SToken
*
pVal
)
{
return
setTableOptionFuncs
[
type
](
pCxt
,
pOptions
,
pVal
);
return
(
SNode
*
)
setTableOptionFuncs
[
type
](
pCxt
,
(
STableOptions
*
)
pOptions
,
pVal
);
}
}
S
TableOptions
*
setTableSmaOption
(
SAstCreateContext
*
pCxt
,
STableOptions
*
pOptions
,
SNodeList
*
pSma
)
{
S
Node
*
setTableSmaOption
(
SAstCreateContext
*
pCxt
,
SNode
*
pOptions
,
SNodeList
*
pSma
)
{
pOptions
->
pSma
=
pSma
;
((
STableOptions
*
)
pOptions
)
->
pSma
=
pSma
;
return
pOptions
;
return
pOptions
;
}
}
...
@@ -831,7 +838,7 @@ SDataType createVarLenDataType(uint8_t type, const SToken* pLen) {
...
@@ -831,7 +838,7 @@ SDataType createVarLenDataType(uint8_t type, const SToken* pLen) {
}
}
SNode
*
createCreateTableStmt
(
SAstCreateContext
*
pCxt
,
SNode
*
createCreateTableStmt
(
SAstCreateContext
*
pCxt
,
bool
ignoreExists
,
SNode
*
pRealTable
,
SNodeList
*
pCols
,
SNodeList
*
pTags
,
S
TableOptions
*
pOptions
)
{
bool
ignoreExists
,
SNode
*
pRealTable
,
SNodeList
*
pCols
,
SNodeList
*
pTags
,
S
Node
*
pOptions
)
{
SCreateTableStmt
*
pStmt
=
(
SCreateTableStmt
*
)
nodesMakeNode
(
QUERY_NODE_CREATE_TABLE_STMT
);
SCreateTableStmt
*
pStmt
=
(
SCreateTableStmt
*
)
nodesMakeNode
(
QUERY_NODE_CREATE_TABLE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
CHECK_OUT_OF_MEM
(
pStmt
);
strcpy
(
pStmt
->
dbName
,
((
SRealTableNode
*
)
pRealTable
)
->
table
.
dbName
);
strcpy
(
pStmt
->
dbName
,
((
SRealTableNode
*
)
pRealTable
)
->
table
.
dbName
);
...
@@ -839,9 +846,7 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt,
...
@@ -839,9 +846,7 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt,
pStmt
->
ignoreExists
=
ignoreExists
;
pStmt
->
ignoreExists
=
ignoreExists
;
pStmt
->
pCols
=
pCols
;
pStmt
->
pCols
=
pCols
;
pStmt
->
pTags
=
pTags
;
pStmt
->
pTags
=
pTags
;
pStmt
->
options
=
*
pOptions
;
pStmt
->
pOptions
=
(
STableOptions
*
)
pOptions
;
nodesDestroyList
(
pOptions
->
pSma
);
tfree
(
pOptions
);
nodesDestroyNode
(
pRealTable
);
nodesDestroyNode
(
pRealTable
);
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
...
@@ -992,3 +997,34 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) {
...
@@ -992,3 +997,34 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) {
}
}
return
(
SNode
*
)
pStmt
;
return
(
SNode
*
)
pStmt
;
}
}
SNode
*
createCreateIndexStmt
(
SAstCreateContext
*
pCxt
,
EIndexType
type
,
const
SToken
*
pIndexName
,
const
SToken
*
pTableName
,
SNodeList
*
pCols
,
SNode
*
pOptions
)
{
if
(
!
checkIndexName
(
pCxt
,
pIndexName
)
||
!
checkTableName
(
pCxt
,
pTableName
))
{
return
NULL
;
}
SCreateIndexStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_CREATE_INDEX_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
indexType
=
type
;
strncpy
(
pStmt
->
indexName
,
pIndexName
->
z
,
pIndexName
->
n
);
strncpy
(
pStmt
->
tableName
,
pTableName
->
z
,
pTableName
->
n
);
pStmt
->
pCols
=
pCols
;
pStmt
->
pOptions
=
(
SIndexOptions
*
)
pOptions
;
return
(
SNode
*
)
pStmt
;
}
SNode
*
createIndexOption
(
SAstCreateContext
*
pCxt
,
SNodeList
*
pFuncs
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
)
{
SIndexOptions
*
pOptions
=
nodesMakeNode
(
QUERY_NODE_INDEX_OPTIONS
);
CHECK_OUT_OF_MEM
(
pOptions
);
pOptions
->
pFuncs
=
pFuncs
;
pOptions
->
pInterval
=
pInterval
;
pOptions
->
pOffset
=
pOffset
;
pOptions
->
pSliding
=
pSliding
;
return
(
SNode
*
)
pOptions
;
}
SNode
*
createCreateQnodeStmt
(
SAstCreateContext
*
pCxt
,
const
SToken
*
pDnodeId
)
{
SCreateQnodeStmt
*
pStmt
=
nodesMakeNode
(
QUERY_NODE_CREATE_QNODE_STMT
);
CHECK_OUT_OF_MEM
(
pStmt
);
pStmt
->
dnodeId
=
strtol
(
pDnodeId
->
z
,
NULL
,
10
);;
return
(
SNode
*
)
pStmt
;
}
source/libs/parser/src/parTokenizer.c
浏览文件 @
db970c79
...
@@ -59,11 +59,13 @@ static SKeyword keywordTable[] = {
...
@@ -59,11 +59,13 @@ static SKeyword keywordTable[] = {
{
"FLOAT"
,
TK_FLOAT
},
{
"FLOAT"
,
TK_FLOAT
},
{
"FROM"
,
TK_FROM
},
{
"FROM"
,
TK_FROM
},
{
"FSYNC"
,
TK_FSYNC
},
{
"FSYNC"
,
TK_FSYNC
},
{
"FUNCTION"
,
TK_FUNCTION
},
{
"GROUP"
,
TK_GROUP
},
{
"GROUP"
,
TK_GROUP
},
{
"HAVING"
,
TK_HAVING
},
{
"HAVING"
,
TK_HAVING
},
{
"IF"
,
TK_IF
},
{
"IF"
,
TK_IF
},
{
"IMPORT"
,
TK_IMPORT
},
{
"IMPORT"
,
TK_IMPORT
},
{
"IN"
,
TK_IN
},
{
"IN"
,
TK_IN
},
{
"INDEX"
,
TK_INDEX
},
{
"INNER"
,
TK_INNER
},
{
"INNER"
,
TK_INNER
},
{
"INT"
,
TK_INT
},
{
"INT"
,
TK_INT
},
{
"INSERT"
,
TK_INSERT
},
{
"INSERT"
,
TK_INSERT
},
...
@@ -97,6 +99,8 @@ static SKeyword keywordTable[] = {
...
@@ -97,6 +99,8 @@ static SKeyword keywordTable[] = {
{
"PRECISION"
,
TK_PRECISION
},
{
"PRECISION"
,
TK_PRECISION
},
{
"PRIVILEGE"
,
TK_PRIVILEGE
},
{
"PRIVILEGE"
,
TK_PRIVILEGE
},
{
"PREV"
,
TK_PREV
},
{
"PREV"
,
TK_PREV
},
{
"QNODE"
,
TK_QNODE
},
{
"QNODES"
,
TK_QNODES
},
{
"QUORUM"
,
TK_QUORUM
},
{
"QUORUM"
,
TK_QUORUM
},
{
"REPLICA"
,
TK_REPLICA
},
{
"REPLICA"
,
TK_REPLICA
},
{
"SELECT"
,
TK_SELECT
},
{
"SELECT"
,
TK_SELECT
},
...
@@ -230,7 +234,6 @@ static SKeyword keywordTable[] = {
...
@@ -230,7 +234,6 @@ static SKeyword keywordTable[] = {
// {"TOPICS", TK_TOPICS},
// {"TOPICS", TK_TOPICS},
// {"COMPACT", TK_COMPACT},
// {"COMPACT", TK_COMPACT},
// {"MODIFY", TK_MODIFY},
// {"MODIFY", TK_MODIFY},
// {"FUNCTION", TK_FUNCTION},
// {"FUNCTIONS", TK_FUNCTIONS},
// {"FUNCTIONS", TK_FUNCTIONS},
// {"OUTPUTTYPE", TK_OUTPUTTYPE},
// {"OUTPUTTYPE", TK_OUTPUTTYPE},
// {"AGGREGATE", TK_AGGREGATE},
// {"AGGREGATE", TK_AGGREGATE},
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
db970c79
...
@@ -254,8 +254,7 @@ static int32_t trimStringWithVarFormat(const char* src, int32_t len, bool format
...
@@ -254,8 +254,7 @@ static int32_t trimStringWithVarFormat(const char* src, int32_t len, bool format
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
static
EDealRes
translateValue
(
STranslateContext
*
pCxt
,
SValueNode
*
pVal
)
{
if
(
pVal
->
isDuration
)
{
if
(
pVal
->
isDuration
)
{
char
unit
=
0
;
if
(
parseAbsoluteDuration
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
&
pVal
->
datum
.
i
,
&
pVal
->
unit
,
pVal
->
node
.
resType
.
precision
)
!=
TSDB_CODE_SUCCESS
)
{
if
(
parseAbsoluteDuration
(
pVal
->
literal
,
strlen
(
pVal
->
literal
),
&
pVal
->
datum
.
i
,
&
unit
,
pVal
->
node
.
resType
.
precision
)
!=
TSDB_CODE_SUCCESS
)
{
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
return
generateDealNodeErrMsg
(
pCxt
,
TSDB_CODE_PAR_WRONG_VALUE_TYPE
,
pVal
->
literal
);
}
}
}
else
{
}
else
{
...
@@ -706,9 +705,17 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SNodeList* pGroupByList
...
@@ -706,9 +705,17 @@ static int32_t translateGroupBy(STranslateContext* pCxt, SNodeList* pGroupByList
return
translateExprList
(
pCxt
,
pGroupByList
);
return
translateExprList
(
pCxt
,
pGroupByList
);
}
}
static
int32_t
doTranslateWindow
(
STranslateContext
*
pCxt
,
SNode
*
pWindow
)
{
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateWindow
(
STranslateContext
*
pCxt
,
SNode
*
pWindow
)
{
static
int32_t
translateWindow
(
STranslateContext
*
pCxt
,
SNode
*
pWindow
)
{
pCxt
->
currClause
=
SQL_CLAUSE_WINDOW
;
pCxt
->
currClause
=
SQL_CLAUSE_WINDOW
;
return
translateExpr
(
pCxt
,
pWindow
);
int32_t
code
=
translateExpr
(
pCxt
,
pWindow
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
doTranslateWindow
(
pCxt
,
pWindow
);
}
return
code
;
}
}
static
int32_t
translatePartitionBy
(
STranslateContext
*
pCxt
,
SNodeList
*
pPartitionByList
)
{
static
int32_t
translatePartitionBy
(
STranslateContext
*
pCxt
,
SNodeList
*
pPartitionByList
)
{
...
@@ -760,26 +767,26 @@ static void buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt
...
@@ -760,26 +767,26 @@ static void buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt
SName
name
=
{
0
};
SName
name
=
{
0
};
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
strlen
(
pStmt
->
dbName
));
tNameSetDbName
(
&
name
,
pCxt
->
pParseCxt
->
acctId
,
pStmt
->
dbName
,
strlen
(
pStmt
->
dbName
));
tNameGetFullDbName
(
&
name
,
pReq
->
db
);
tNameGetFullDbName
(
&
name
,
pReq
->
db
);
pReq
->
numOfVgroups
=
pStmt
->
options
.
numOfVgroups
;
pReq
->
numOfVgroups
=
pStmt
->
pOptions
->
numOfVgroups
;
pReq
->
cacheBlockSize
=
pStmt
->
options
.
cacheBlockSize
;
pReq
->
cacheBlockSize
=
pStmt
->
pOptions
->
cacheBlockSize
;
pReq
->
totalBlocks
=
pStmt
->
options
.
numOfBlocks
;
pReq
->
totalBlocks
=
pStmt
->
pOptions
->
numOfBlocks
;
pReq
->
daysPerFile
=
pStmt
->
options
.
daysPerFile
;
pReq
->
daysPerFile
=
pStmt
->
pOptions
->
daysPerFile
;
pReq
->
daysToKeep0
=
pStmt
->
options
.
keep
;
pReq
->
daysToKeep0
=
pStmt
->
pOptions
->
keep
;
pReq
->
daysToKeep1
=
-
1
;
pReq
->
daysToKeep1
=
-
1
;
pReq
->
daysToKeep2
=
-
1
;
pReq
->
daysToKeep2
=
-
1
;
pReq
->
minRows
=
pStmt
->
options
.
minRowsPerBlock
;
pReq
->
minRows
=
pStmt
->
pOptions
->
minRowsPerBlock
;
pReq
->
maxRows
=
pStmt
->
options
.
maxRowsPerBlock
;
pReq
->
maxRows
=
pStmt
->
pOptions
->
maxRowsPerBlock
;
pReq
->
commitTime
=
-
1
;
pReq
->
commitTime
=
-
1
;
pReq
->
fsyncPeriod
=
pStmt
->
options
.
fsyncPeriod
;
pReq
->
fsyncPeriod
=
pStmt
->
pOptions
->
fsyncPeriod
;
pReq
->
walLevel
=
pStmt
->
options
.
walLevel
;
pReq
->
walLevel
=
pStmt
->
pOptions
->
walLevel
;
pReq
->
precision
=
pStmt
->
options
.
precision
;
pReq
->
precision
=
pStmt
->
pOptions
->
precision
;
pReq
->
compression
=
pStmt
->
options
.
compressionLevel
;
pReq
->
compression
=
pStmt
->
pOptions
->
compressionLevel
;
pReq
->
replications
=
pStmt
->
options
.
replica
;
pReq
->
replications
=
pStmt
->
pOptions
->
replica
;
pReq
->
quorum
=
pStmt
->
options
.
quorum
;
pReq
->
quorum
=
pStmt
->
pOptions
->
quorum
;
pReq
->
update
=
-
1
;
pReq
->
update
=
-
1
;
pReq
->
cacheLastRow
=
pStmt
->
options
.
cachelast
;
pReq
->
cacheLastRow
=
pStmt
->
pOptions
->
cachelast
;
pReq
->
ignoreExist
=
pStmt
->
ignoreExists
;
pReq
->
ignoreExist
=
pStmt
->
ignoreExists
;
pReq
->
streamMode
=
pStmt
->
options
.
streamMode
;
pReq
->
streamMode
=
pStmt
->
pOptions
->
streamMode
;
return
;
return
;
}
}
...
@@ -788,14 +795,14 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS
...
@@ -788,14 +795,14 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS
buildCreateDbReq
(
pCxt
,
pStmt
,
&
createReq
);
buildCreateDbReq
(
pCxt
,
pStmt
,
&
createReq
);
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_CREATE_DB
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_CREATE_DB
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSCreateDbReq
(
NULL
,
0
,
&
createReq
);
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSCreateDbReq
(
NULL
,
0
,
&
createReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
tSerializeSCreateDbReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
createReq
);
tSerializeSCreateDbReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
createReq
);
...
@@ -811,14 +818,14 @@ static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt*
...
@@ -811,14 +818,14 @@ static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt*
dropReq
.
ignoreNotExists
=
pStmt
->
ignoreNotExists
;
dropReq
.
ignoreNotExists
=
pStmt
->
ignoreNotExists
;
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_DROP_DB
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_DROP_DB
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSDropDbReq
(
NULL
,
0
,
&
dropReq
);
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSDropDbReq
(
NULL
,
0
,
&
dropReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
tSerializeSDropDbReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
dropReq
);
tSerializeSDropDbReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
dropReq
);
...
@@ -852,7 +859,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt
...
@@ -852,7 +859,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt
tNameExtractFullName
(
&
tableName
,
createReq
.
name
);
tNameExtractFullName
(
&
tableName
,
createReq
.
name
);
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
tFreeSMCreateStbReq
(
&
createReq
);
tFreeSMCreateStbReq
(
&
createReq
);
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
...
@@ -860,7 +867,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt
...
@@ -860,7 +867,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_CREATE_STB
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_CREATE_STB
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSMCreateStbReq
(
NULL
,
0
,
&
createReq
);
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSMCreateStbReq
(
NULL
,
0
,
&
createReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
tFreeSMCreateStbReq
(
&
createReq
);
tFreeSMCreateStbReq
(
&
createReq
);
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
...
@@ -876,14 +883,14 @@ static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* p
...
@@ -876,14 +883,14 @@ static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* p
dropReq
.
igNotExists
=
ignoreNotExists
;
dropReq
.
igNotExists
=
ignoreNotExists
;
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_DROP_STB
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_DROP_STB
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSMDropStbReq
(
NULL
,
0
,
&
dropReq
);
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSMDropStbReq
(
NULL
,
0
,
&
dropReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
tSerializeSMDropStbReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
dropReq
);
tSerializeSMDropStbReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
dropReq
);
...
@@ -929,14 +936,14 @@ static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* p
...
@@ -929,14 +936,14 @@ static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* p
catalogGetDBVgVersion
(
pCxt
->
pParseCxt
->
pCatalog
,
usedbReq
.
db
,
&
usedbReq
.
vgVersion
,
&
usedbReq
.
dbId
,
&
usedbReq
.
numOfTable
);
catalogGetDBVgVersion
(
pCxt
->
pParseCxt
->
pCatalog
,
usedbReq
.
db
,
&
usedbReq
.
vgVersion
,
&
usedbReq
.
dbId
,
&
usedbReq
.
numOfTable
);
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_USE_DB
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_USE_DB
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSUseDbReq
(
NULL
,
0
,
&
usedbReq
);
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSUseDbReq
(
NULL
,
0
,
&
usedbReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
tSerializeSUseDbReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
usedbReq
);
tSerializeSUseDbReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
usedbReq
);
...
@@ -952,14 +959,14 @@ static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pSt
...
@@ -952,14 +959,14 @@ static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pSt
strcpy
(
createReq
.
pass
,
pStmt
->
password
);
strcpy
(
createReq
.
pass
,
pStmt
->
password
);
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_CREATE_USER
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_CREATE_USER
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
tSerializeSCreateUserReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
createReq
);
tSerializeSCreateUserReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
createReq
);
...
@@ -978,14 +985,14 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt
...
@@ -978,14 +985,14 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt
}
}
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_ALTER_USER
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_ALTER_USER
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
tSerializeSAlterUserReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
alterReq
);
tSerializeSAlterUserReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
alterReq
);
...
@@ -998,14 +1005,14 @@ static int32_t translateDropUser(STranslateContext* pCxt, SDropUserStmt* pStmt)
...
@@ -998,14 +1005,14 @@ static int32_t translateDropUser(STranslateContext* pCxt, SDropUserStmt* pStmt)
strcpy
(
dropReq
.
user
,
pStmt
->
useName
);
strcpy
(
dropReq
.
user
,
pStmt
->
useName
);
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_DROP_USER
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_DROP_USER
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
tSerializeSDropUserReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
dropReq
);
tSerializeSDropUserReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
dropReq
);
...
@@ -1019,14 +1026,14 @@ static int32_t translateCreateDnode(STranslateContext* pCxt, SCreateDnodeStmt* p
...
@@ -1019,14 +1026,14 @@ static int32_t translateCreateDnode(STranslateContext* pCxt, SCreateDnodeStmt* p
createReq
.
port
=
pStmt
->
port
;
createReq
.
port
=
pStmt
->
port
;
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_CREATE_DNODE
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_CREATE_DNODE
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSCreateDnodeReq
(
NULL
,
0
,
&
createReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
tSerializeSCreateDnodeReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
createReq
);
tSerializeSCreateDnodeReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
createReq
);
...
@@ -1041,14 +1048,14 @@ static int32_t translateDropDnode(STranslateContext* pCxt, SDropDnodeStmt* pStmt
...
@@ -1041,14 +1048,14 @@ static int32_t translateDropDnode(STranslateContext* pCxt, SDropDnodeStmt* pStmt
dropReq
.
port
=
pStmt
->
port
;
dropReq
.
port
=
pStmt
->
port
;
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_DROP_DNODE
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_DROP_DNODE
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSDropDnodeReq
(
NULL
,
0
,
&
dropReq
);
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSDropDnodeReq
(
NULL
,
0
,
&
dropReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
tSerializeSDropDnodeReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
dropReq
);
tSerializeSDropDnodeReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
dropReq
);
...
@@ -1070,6 +1077,8 @@ static int32_t nodeTypeToShowType(ENodeType nt) {
...
@@ -1070,6 +1077,8 @@ static int32_t nodeTypeToShowType(ENodeType nt) {
return
TSDB_MGMT_TABLE_VGROUP
;
return
TSDB_MGMT_TABLE_VGROUP
;
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
return
TSDB_MGMT_TABLE_MNODE
;
return
TSDB_MGMT_TABLE_MNODE
;
case
QUERY_NODE_SHOW_QNODES_STMT
:
return
TSDB_MGMT_TABLE_QNODE
;
default:
default:
break
;
break
;
}
}
...
@@ -1086,14 +1095,14 @@ static int32_t translateShow(STranslateContext* pCxt, SShowStmt* pStmt) {
...
@@ -1086,14 +1095,14 @@ static int32_t translateShow(STranslateContext* pCxt, SShowStmt* pStmt) {
}
}
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_SHOW
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_MND_SHOW
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSShowReq
(
NULL
,
0
,
&
showReq
);
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSShowReq
(
NULL
,
0
,
&
showReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
tSerializeSShowReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
showReq
);
tSerializeSShowReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
showReq
);
...
@@ -1121,7 +1130,7 @@ static int32_t translateShowTables(STranslateContext* pCxt) {
...
@@ -1121,7 +1130,7 @@ static int32_t translateShowTables(STranslateContext* pCxt) {
pShowReq
->
head
.
vgId
=
htonl
(
info
->
vgId
);
pShowReq
->
head
.
vgId
=
htonl
(
info
->
vgId
);
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pCxt
->
pCmdMsg
->
epSet
=
info
->
epSet
;
pCxt
->
pCmdMsg
->
epSet
=
info
->
epSet
;
...
@@ -1133,6 +1142,84 @@ static int32_t translateShowTables(STranslateContext* pCxt) {
...
@@ -1133,6 +1142,84 @@ static int32_t translateShowTables(STranslateContext* pCxt) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
translateCreateSmaIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
SVCreateTSmaReq
createSmaReq
=
{
0
};
if
(
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
||
(
NULL
!=
pStmt
->
pOptions
->
pOffset
&&
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pOffset
))
||
(
NULL
!=
pStmt
->
pOptions
->
pSliding
&&
DEAL_RES_ERROR
==
translateValue
(
pCxt
,
(
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)))
{
return
pCxt
->
errCode
;
}
createSmaReq
.
tSma
.
intervalUnit
=
((
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
->
unit
;
createSmaReq
.
tSma
.
slidingUnit
=
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
unit
:
0
);
strcpy
(
createSmaReq
.
tSma
.
indexName
,
pStmt
->
indexName
);
SName
name
;
name
.
type
=
TSDB_TABLE_NAME_T
;
name
.
acctId
=
pCxt
->
pParseCxt
->
acctId
;
strcpy
(
name
.
dbname
,
pCxt
->
pParseCxt
->
db
);
strcpy
(
name
.
tname
,
pStmt
->
tableName
);
STableMeta
*
pMeta
=
NULL
;
int32_t
code
=
catalogGetTableMeta
(
pCxt
->
pParseCxt
->
pCatalog
,
pCxt
->
pParseCxt
->
pTransporter
,
&
pCxt
->
pParseCxt
->
mgmtEpSet
,
&
name
,
&
pMeta
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
createSmaReq
.
tSma
.
tableUid
=
pMeta
->
uid
;
createSmaReq
.
tSma
.
interval
=
((
SValueNode
*
)
pStmt
->
pOptions
->
pInterval
)
->
datum
.
i
;
createSmaReq
.
tSma
.
sliding
=
(
NULL
!=
pStmt
->
pOptions
->
pSliding
?
((
SValueNode
*
)
pStmt
->
pOptions
->
pSliding
)
->
datum
.
i
:
0
);
code
=
nodesListToString
(
pStmt
->
pOptions
->
pFuncs
,
false
,
&
createSmaReq
.
tSma
.
expr
,
&
createSmaReq
.
tSma
.
exprLen
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
return
code
;
}
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_VND_CREATE_SMA
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSVCreateTSmaReq
(
NULL
,
&
createSmaReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
void
*
pBuf
=
pCxt
->
pCmdMsg
->
pMsg
;
tSerializeSVCreateTSmaReq
(
&
pBuf
,
&
createSmaReq
);
tdDestroyTSma
(
&
createSmaReq
.
tSma
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateCreateIndex
(
STranslateContext
*
pCxt
,
SCreateIndexStmt
*
pStmt
)
{
if
(
INDEX_TYPE_SMA
==
pStmt
->
indexType
)
{
return
translateCreateSmaIndex
(
pCxt
,
pStmt
);
}
else
{
// todo fulltext index
return
TSDB_CODE_FAILED
;
}
}
static
int32_t
translateCreateQnode
(
STranslateContext
*
pCxt
,
SCreateQnodeStmt
*
pStmt
)
{
SMCreateQnodeReq
createReq
=
{
.
dnodeId
=
pStmt
->
dnodeId
};
pCxt
->
pCmdMsg
=
malloc
(
sizeof
(
SCmdMsgInfo
));
if
(
NULL
==
pCxt
->
pCmdMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pCxt
->
pCmdMsg
->
epSet
=
pCxt
->
pParseCxt
->
mgmtEpSet
;
pCxt
->
pCmdMsg
->
msgType
=
TDMT_DND_CREATE_QNODE
;
pCxt
->
pCmdMsg
->
msgLen
=
tSerializeSMCreateDropQSBNodeReq
(
NULL
,
0
,
&
createReq
);
pCxt
->
pCmdMsg
->
pMsg
=
malloc
(
pCxt
->
pCmdMsg
->
msgLen
);
if
(
NULL
==
pCxt
->
pCmdMsg
->
pMsg
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
tSerializeSMCreateDropQSBNodeReq
(
pCxt
->
pCmdMsg
->
pMsg
,
pCxt
->
pCmdMsg
->
msgLen
,
&
createReq
);
return
TSDB_CODE_SUCCESS
;
}
static
int32_t
translateQuery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
)
{
static
int32_t
translateQuery
(
STranslateContext
*
pCxt
,
SNode
*
pNode
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
pNode
))
{
switch
(
nodeType
(
pNode
))
{
...
@@ -1178,11 +1265,18 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
...
@@ -1178,11 +1265,18 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) {
case
QUERY_NODE_SHOW_DNODES_STMT
:
case
QUERY_NODE_SHOW_DNODES_STMT
:
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
case
QUERY_NODE_SHOW_VGROUPS_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_MNODES_STMT
:
case
QUERY_NODE_SHOW_QNODES_STMT
:
code
=
translateShow
(
pCxt
,
(
SShowStmt
*
)
pNode
);
code
=
translateShow
(
pCxt
,
(
SShowStmt
*
)
pNode
);
break
;
break
;
case
QUERY_NODE_SHOW_TABLES_STMT
:
case
QUERY_NODE_SHOW_TABLES_STMT
:
code
=
translateShowTables
(
pCxt
);
code
=
translateShowTables
(
pCxt
);
break
;
break
;
case
QUERY_NODE_CREATE_INDEX_STMT
:
code
=
translateCreateIndex
(
pCxt
,
(
SCreateIndexStmt
*
)
pNode
);
break
;
case
QUERY_NODE_CREATE_QNODE_STMT
:
code
=
translateCreateQnode
(
pCxt
,
(
SCreateQnodeStmt
*
)
pNode
);
break
;
default:
default:
break
;
break
;
}
}
...
...
source/libs/parser/src/sql.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/parser/test/parserAstTest.cpp
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/planner/src/planLogicCreater.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/planner/test/plannerTest.cpp
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/scheduler/src/scheduler.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncElection.h
浏览文件 @
db970c79
...
@@ -39,7 +39,6 @@ extern "C" {
...
@@ -39,7 +39,6 @@ extern "C" {
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
// /\ UNCHANGED <<serverVars, candidateVars, leaderVars, logVars>>
//
//
int32_t
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRequestVotePeers
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeElect
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeElect
(
SSyncNode
*
pSyncNode
);
int32_t
syncNodeRequestVote
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
const
SyncRequestVote
*
pMsg
);
int32_t
syncNodeRequestVote
(
SSyncNode
*
pSyncNode
,
const
SRaftId
*
destRaftId
,
const
SyncRequestVote
*
pMsg
);
...
...
source/libs/sync/inc/syncEnv.h
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncIO.h
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncInt.h
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncMessage.h
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncRaftLog.h
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncRaftStore.h
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncReplication.h
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/inc/syncUtil.h
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/src/syncAppendEntries.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/src/syncAppendEntriesReply.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/src/syncElection.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/src/syncEnv.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/src/syncIO.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMain.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/src/syncMessage.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRaftLog.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRaftStore.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/src/syncReplication.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRequestVote.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/src/syncRequestVoteReply.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/src/syncTimeout.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/src/syncUtil.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/test/CMakeLists.txt
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/test/syncEnqTest.cpp
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/test/syncEnvTest.cpp
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIO
SendMsg
ClientTest.cpp
→
source/libs/sync/test/syncIOClientTest.cpp
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIOSendMsgTest.cpp
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIOSe
ndMsgSe
rverTest.cpp
→
source/libs/sync/test/syncIOServerTest.cpp
浏览文件 @
db970c79
文件已移动
source/libs/sync/test/syncIOTickPingTest.cpp
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/test/syncIOTickQTest.cpp
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/test/syncLogStoreTest.cpp
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRequestVoteTest.cpp
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/test/syncRpcMsgTest.cpp
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/sync/test/syncUtilTest.cpp
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/transport/CMakeLists.txt
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/transport/inc/transComm.h
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/transport/inc/transportInt.h
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/transport/src/trans.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/transport/src/transCli.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/transport/src/transComm.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/transport/src/transSrv.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/libs/transport/test/transUT.cc
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/os/src/osLocale.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/util/src/terror.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/util/src/tjson.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/util/src/tuuid.c
0 → 100644
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
source/util/src/tworker.c
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
tests/script/jenkins/basic.txt
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
tests/script/sh/massiveTable/compileVersion.sh
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
tests/script/tsim/db/basic6.sim
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
tests/script/tsim/insert/basic0.sim
0 → 100644
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
tests/script/tsim/table/basic1.sim
浏览文件 @
db970c79
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录