Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
a82fc113
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
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看板
提交
a82fc113
编写于
3月 28, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/qnode
上级
9e3f03ad
47fe8bd9
变更
111
展开全部
隐藏空白更改
内联
并排
Showing
111 changed file
with
3005 addition
and
1591 deletion
+3005
-1591
.gitignore
.gitignore
+1
-0
2.0/src/client/inc/tsclient.h
2.0/src/client/inc/tsclient.h
+8
-8
2.0/src/client/src/tscParseInsert.c
2.0/src/client/src/tscParseInsert.c
+10
-10
2.0/src/client/src/tscUtil.c
2.0/src/client/src/tscUtil.c
+1
-1
example/src/tmq.c
example/src/tmq.c
+1
-1
include/client/taos.h
include/client/taos.h
+5
-2
include/common/tcommon.h
include/common/tcommon.h
+2
-2
include/common/tdataformat.h
include/common/tdataformat.h
+9
-6
include/common/tmsg.h
include/common/tmsg.h
+34
-13
include/common/trow.h
include/common/trow.h
+3
-2
include/common/ttypes.h
include/common/ttypes.h
+1
-0
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+1
-0
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+15
-1
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+4
-2
include/libs/qcom/query.h
include/libs/qcom/query.h
+5
-5
include/libs/stream/tstream.h
include/libs/stream/tstream.h
+2
-1
include/os/os.h
include/os/os.h
+2
-2
include/os/osEnv.h
include/os/osEnv.h
+14
-12
include/os/osTimezone.h
include/os/osTimezone.h
+31
-2
include/util/taoserror.h
include/util/taoserror.h
+2
-0
include/util/tdef.h
include/util/tdef.h
+1
-1
include/util/tprocess.h
include/util/tprocess.h
+1
-0
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+2
-2
source/client/src/clientHb.c
source/client/src/clientHb.c
+1
-1
source/client/src/tmq.c
source/client/src/tmq.c
+107
-34
source/common/src/tdataformat.c
source/common/src/tdataformat.c
+5
-5
source/common/src/tglobal.c
source/common/src/tglobal.c
+5
-4
source/common/src/tmsg.c
source/common/src/tmsg.c
+6
-6
source/dnode/mgmt/container/inc/dndInt.h
source/dnode/mgmt/container/inc/dndInt.h
+0
-1
source/dnode/mgmt/container/src/dndExec.c
source/dnode/mgmt/container/src/dndExec.c
+16
-12
source/dnode/mgmt/container/src/dndFile.c
source/dnode/mgmt/container/src/dndFile.c
+14
-14
source/dnode/mgmt/container/src/dndMsg.c
source/dnode/mgmt/container/src/dndMsg.c
+11
-7
source/dnode/mgmt/container/src/dndObj.c
source/dnode/mgmt/container/src/dndObj.c
+1
-1
source/dnode/mgmt/container/src/dndTransport.c
source/dnode/mgmt/container/src/dndTransport.c
+1
-1
source/dnode/mgmt/dnode/src/dmMsg.c
source/dnode/mgmt/dnode/src/dmMsg.c
+1
-1
source/dnode/mgmt/vnode/src/vmWorker.c
source/dnode/mgmt/vnode/src/vmWorker.c
+19
-1
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+19
-18
source/dnode/mnode/impl/src/mndDef.c
source/dnode/mnode/impl/src/mndDef.c
+9
-1
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+3
-3
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+1
-0
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+6
-6
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+9
-10
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+30
-0
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+4
-4
source/dnode/vnode/src/meta/metaBDBImpl.c
source/dnode/vnode/src/meta/metaBDBImpl.c
+5
-3
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+10
-6
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+3
-3
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbMemTable.c
source/dnode/vnode/src/tsdb/tsdbMemTable.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbSma.c
source/dnode/vnode/src/tsdb/tsdbSma.c
+74
-28
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+2
-0
source/dnode/vnode/src/vnd/vnodeWrite.c
source/dnode/vnode/src/vnd/vnodeWrite.c
+12
-1
source/dnode/vnode/test/tsdbSmaTest.cpp
source/dnode/vnode/test/tsdbSmaTest.cpp
+1
-1
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+0
-1
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+3
-2
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+2
-0
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+61
-9
source/libs/nodes/src/nodesCloneFuncs.c
source/libs/nodes/src/nodesCloneFuncs.c
+30
-7
source/libs/nodes/src/nodesCodeFuncs.c
source/libs/nodes/src/nodesCodeFuncs.c
+96
-20
source/libs/nodes/src/nodesTraverseFuncs.c
source/libs/nodes/src/nodesTraverseFuncs.c
+8
-2
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+4
-2
source/libs/parser/inc/parInsertData.h
source/libs/parser/inc/parInsertData.h
+13
-13
source/libs/parser/inc/parUtil.h
source/libs/parser/inc/parUtil.h
+2
-0
source/libs/parser/src/parAstCreater.c
source/libs/parser/src/parAstCreater.c
+13
-0
source/libs/parser/src/parInsert.c
source/libs/parser/src/parInsert.c
+24
-21
source/libs/parser/src/parInsertData.c
source/libs/parser/src/parInsertData.c
+4
-4
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+22
-6
source/libs/parser/test/mockCatalogService.cpp
source/libs/parser/test/mockCatalogService.cpp
+1
-1
source/libs/planner/inc/planInt.h
source/libs/planner/inc/planInt.h
+0
-26
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+63
-20
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+287
-119
source/libs/planner/src/planSpliter.c
source/libs/planner/src/planSpliter.c
+3
-1
source/libs/planner/test/plannerTest.cpp
source/libs/planner/test/plannerTest.cpp
+22
-1
source/libs/qcom/src/queryUtil.c
source/libs/qcom/src/queryUtil.c
+1
-1
source/libs/qcom/src/querymsg.c
source/libs/qcom/src/querymsg.c
+1
-1
source/libs/qworker/src/qworker.c
source/libs/qworker/src/qworker.c
+2
-0
source/libs/qworker/src/qworkerMsg.c
source/libs/qworker/src/qworkerMsg.c
+1
-1
source/libs/stream/src/tstream.c
source/libs/stream/src/tstream.c
+5
-3
source/libs/tdb/CMakeLists.txt
source/libs/tdb/CMakeLists.txt
+0
-1
source/libs/tdb/src/btree/tdbBtreeBalance.c
source/libs/tdb/src/btree/tdbBtreeBalance.c
+14
-0
source/libs/tdb/src/btree/tdbBtreeCommon.c
source/libs/tdb/src/btree/tdbBtreeCommon.c
+14
-0
source/libs/tdb/src/btree/tdbBtreeDelete.c
source/libs/tdb/src/btree/tdbBtreeDelete.c
+14
-0
source/libs/tdb/src/btree/tdbBtreeInsert.c
source/libs/tdb/src/btree/tdbBtreeInsert.c
+14
-0
source/libs/tdb/src/btree/tdbBtreeInt.h
source/libs/tdb/src/btree/tdbBtreeInt.h
+27
-0
source/libs/tdb/src/btree/tdbBtreeOpen.c
source/libs/tdb/src/btree/tdbBtreeOpen.c
+14
-0
source/libs/tdb/src/db/tdbBtree.c
source/libs/tdb/src/db/tdbBtree.c
+711
-326
source/libs/tdb/src/db/tdbDb.c
source/libs/tdb/src/db/tdbDb.c
+55
-11
source/libs/tdb/src/db/tdbEnv.c
source/libs/tdb/src/db/tdbEnv.c
+1
-1
source/libs/tdb/src/db/tdbPCache.c
source/libs/tdb/src/db/tdbPCache.c
+27
-50
source/libs/tdb/src/db/tdbPage.c
source/libs/tdb/src/db/tdbPage.c
+0
-253
source/libs/tdb/src/db/tdbPager.c
source/libs/tdb/src/db/tdbPager.c
+5
-1
source/libs/tdb/src/inc/tdbBtree.h
source/libs/tdb/src/inc/tdbBtree.h
+19
-5
source/libs/tdb/src/inc/tdbDb.h
source/libs/tdb/src/inc/tdbDb.h
+13
-5
source/libs/tdb/src/inc/tdbInt.h
source/libs/tdb/src/inc/tdbInt.h
+3
-3
source/libs/tdb/src/inc/tdbPCache.h
source/libs/tdb/src/inc/tdbPCache.h
+12
-13
source/libs/tdb/src/inc/tdbPage.h
source/libs/tdb/src/inc/tdbPage.h
+50
-38
source/libs/tdb/src/inc/tdbPager.h
source/libs/tdb/src/inc/tdbPager.h
+10
-9
source/libs/tdb/src/inc/tdbUtil.h
source/libs/tdb/src/inc/tdbUtil.h
+32
-0
source/libs/tdb/src/page/tdbPage.c
source/libs/tdb/src/page/tdbPage.c
+351
-117
source/libs/tdb/src/page/tdbPageL.c
source/libs/tdb/src/page/tdbPageL.c
+32
-24
source/libs/tdb/test/tdbTest.cpp
source/libs/tdb/test/tdbTest.cpp
+172
-10
source/libs/wal/src/walMeta.c
source/libs/wal/src/walMeta.c
+23
-24
source/libs/wal/src/walRead.c
source/libs/wal/src/walRead.c
+6
-3
source/libs/wal/src/walSeek.c
source/libs/wal/src/walSeek.c
+2
-3
source/os/src/osEnv.c
source/os/src/osEnv.c
+29
-23
source/os/src/osMemory.c
source/os/src/osMemory.c
+6
-7
source/os/src/osTimezone.c
source/os/src/osTimezone.c
+30
-14
source/util/src/tprocess.c
source/util/src/tprocess.c
+49
-44
tests/pytest/util/dnodes.py
tests/pytest/util/dnodes.py
+60
-59
tests/script/tsim/tmq/basic.sim
tests/script/tsim/tmq/basic.sim
+1
-1
tests/test/c/tmqDemo.c
tests/test/c/tmqDemo.c
+9
-38
未找到文件。
.gitignore
浏览文件 @
a82fc113
...
@@ -89,6 +89,7 @@ tests/examples/JDBC/JDBCDemo/.project
...
@@ -89,6 +89,7 @@ tests/examples/JDBC/JDBCDemo/.project
tests/examples/JDBC/JDBCDemo/.settings/
tests/examples/JDBC/JDBCDemo/.settings/
source/libs/parser/inc/sql.*
source/libs/parser/inc/sql.*
tests/script/tmqResult.txt
tests/script/tmqResult.txt
tests/tmqResult.txt
# Emacs
# Emacs
# -*- mode: gitignore; -*-
# -*- mode: gitignore; -*-
...
...
2.0/src/client/inc/tsclient.h
浏览文件 @
a82fc113
...
@@ -116,7 +116,7 @@ typedef struct SParsedDataColInfo {
...
@@ -116,7 +116,7 @@ typedef struct SParsedDataColInfo {
uint16_t
allNullLen
;
// TODO: get from STSchema(base on SDataRow)
uint16_t
allNullLen
;
// TODO: get from STSchema(base on SDataRow)
uint16_t
extendedVarLen
;
uint16_t
extendedVarLen
;
uint16_t
boundNullLen
;
// bound column len with all NULL value(without VarDataOffsetT/SColIdx part)
uint16_t
boundNullLen
;
// bound column len with all NULL value(without VarDataOffsetT/SColIdx part)
int32_t
*
boundedColumns
;
// bound column idx according to schema
int32_t
*
boundColumns
;
// bound column idx according to schema
SBoundColumn
*
cols
;
SBoundColumn
*
cols
;
SBoundIdxInfo
*
colIdxInfo
;
SBoundIdxInfo
*
colIdxInfo
;
int8_t
orderStatus
;
// bound columns
int8_t
orderStatus
;
// bound columns
...
@@ -125,7 +125,7 @@ typedef struct SParsedDataColInfo {
...
@@ -125,7 +125,7 @@ typedef struct SParsedDataColInfo {
#define IS_DATA_COL_ORDERED(spd) ((spd->orderStatus) == (int8_t)ORDER_STATUS_ORDERED)
#define IS_DATA_COL_ORDERED(spd) ((spd->orderStatus) == (int8_t)ORDER_STATUS_ORDERED)
typedef
struct
{
typedef
struct
{
uint8_t
memR
owType
;
// default is 0, that is SDataRow
uint8_t
r
owType
;
// default is 0, that is SDataRow
int32_t
rowSize
;
int32_t
rowSize
;
}
SMemRowBuilder
;
}
SMemRowBuilder
;
...
@@ -137,17 +137,17 @@ void destroyMemRowBuilder(SMemRowBuilder *pBuilder);
...
@@ -137,17 +137,17 @@ void destroyMemRowBuilder(SMemRowBuilder *pBuilder);
/**
/**
* @brief
* @brief
*
*
* @param
memR
owType
* @param
r
owType
* @param spd
* @param spd
* @param idx the absolute bound index of columns
* @param idx the absolute bound index of columns
* @return FORCE_INLINE
* @return FORCE_INLINE
*/
*/
static
FORCE_INLINE
void
tscGet
MemRowAppendInfo
(
SSchema
*
pSchema
,
uint8_t
memRowType
,
SParsedDataColInfo
*
spd
,
static
FORCE_INLINE
void
tscGet
STSRowAppendInfo
(
SSchema
*
pSchema
,
uint8_t
rowType
,
SParsedDataColInfo
*
spd
,
int32_t
idx
,
int32_t
idx
,
int32_t
*
toffset
,
int16_t
*
colId
)
{
int32_t
*
toffset
,
int16_t
*
colId
)
{
int32_t
schemaIdx
=
0
;
int32_t
schemaIdx
=
0
;
if
(
IS_DATA_COL_ORDERED
(
spd
))
{
if
(
IS_DATA_COL_ORDERED
(
spd
))
{
schemaIdx
=
spd
->
bound
ed
Columns
[
idx
];
schemaIdx
=
spd
->
boundColumns
[
idx
];
if
(
isDataRowT
(
memR
owType
))
{
if
(
isDataRowT
(
r
owType
))
{
*
toffset
=
(
spd
->
cols
+
schemaIdx
)
->
toffset
;
// the offset of firstPart
*
toffset
=
(
spd
->
cols
+
schemaIdx
)
->
toffset
;
// the offset of firstPart
}
else
{
}
else
{
*
toffset
=
idx
*
sizeof
(
SColIdx
);
// the offset of SColIdx
*
toffset
=
idx
*
sizeof
(
SColIdx
);
// the offset of SColIdx
...
@@ -155,7 +155,7 @@ static FORCE_INLINE void tscGetMemRowAppendInfo(SSchema *pSchema, uint8_t memRow
...
@@ -155,7 +155,7 @@ static FORCE_INLINE void tscGetMemRowAppendInfo(SSchema *pSchema, uint8_t memRow
}
else
{
}
else
{
ASSERT
(
idx
==
(
spd
->
colIdxInfo
+
idx
)
->
boundIdx
);
ASSERT
(
idx
==
(
spd
->
colIdxInfo
+
idx
)
->
boundIdx
);
schemaIdx
=
(
spd
->
colIdxInfo
+
idx
)
->
schemaColIdx
;
schemaIdx
=
(
spd
->
colIdxInfo
+
idx
)
->
schemaColIdx
;
if
(
isDataRowT
(
memR
owType
))
{
if
(
isDataRowT
(
r
owType
))
{
*
toffset
=
(
spd
->
cols
+
schemaIdx
)
->
toffset
;
*
toffset
=
(
spd
->
cols
+
schemaIdx
)
->
toffset
;
}
else
{
}
else
{
*
toffset
=
((
spd
->
colIdxInfo
+
idx
)
->
finalIdx
)
*
sizeof
(
SColIdx
);
*
toffset
=
((
spd
->
colIdxInfo
+
idx
)
->
finalIdx
)
*
sizeof
(
SColIdx
);
...
...
2.0/src/client/src/tscParseInsert.c
浏览文件 @
a82fc113
...
@@ -428,7 +428,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
...
@@ -428,7 +428,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
// 1. set the parsed value from sql string
// 1. set the parsed value from sql string
for
(
int
i
=
0
;
i
<
spd
->
numOfBound
;
++
i
)
{
for
(
int
i
=
0
;
i
<
spd
->
numOfBound
;
++
i
)
{
// the start position in data block buffer of current value in sql
// the start position in data block buffer of current value in sql
int32_t
colIndex
=
spd
->
bound
ed
Columns
[
i
];
int32_t
colIndex
=
spd
->
boundColumns
[
i
];
char
*
start
=
row
+
spd
->
cols
[
colIndex
].
offset
;
char
*
start
=
row
+
spd
->
cols
[
colIndex
].
offset
;
...
@@ -495,7 +495,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
...
@@ -495,7 +495,7 @@ int tsParseOneRow(char **str, STableDataBlocks *pDataBlocks, int16_t timePrec, i
bool
isPrimaryKey
=
(
colIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
);
bool
isPrimaryKey
=
(
colIndex
==
PRIMARYKEY_TIMESTAMP_COL_INDEX
);
int32_t
toffset
=
-
1
;
int32_t
toffset
=
-
1
;
int16_t
colId
=
-
1
;
int16_t
colId
=
-
1
;
tscGet
Mem
RowAppendInfo
(
schema
,
pBuilder
->
memRowType
,
spd
,
i
,
&
toffset
,
&
colId
);
tscGet
STS
RowAppendInfo
(
schema
,
pBuilder
->
memRowType
,
spd
,
i
,
&
toffset
,
&
colId
);
int32_t
ret
=
int32_t
ret
=
tsParseOneColumnKV
(
pSchema
,
&
sToken
,
row
,
pInsertParam
->
msg
,
str
,
isPrimaryKey
,
timePrec
,
toffset
,
colId
);
tsParseOneColumnKV
(
pSchema
,
&
sToken
,
row
,
pInsertParam
->
msg
,
str
,
isPrimaryKey
,
timePrec
,
toffset
,
colId
);
...
@@ -630,7 +630,7 @@ void tscSetBoundColumnInfo(SParsedDataColInfo *pColInfo, SSchema *pSchema, int32
...
@@ -630,7 +630,7 @@ void tscSetBoundColumnInfo(SParsedDataColInfo *pColInfo, SSchema *pSchema, int32
pColInfo
->
numOfCols
=
numOfCols
;
pColInfo
->
numOfCols
=
numOfCols
;
pColInfo
->
numOfBound
=
numOfCols
;
pColInfo
->
numOfBound
=
numOfCols
;
pColInfo
->
orderStatus
=
ORDER_STATUS_ORDERED
;
// default is ORDERED for non-bound mode
pColInfo
->
orderStatus
=
ORDER_STATUS_ORDERED
;
// default is ORDERED for non-bound mode
pColInfo
->
bound
ed
Columns
=
calloc
(
pColInfo
->
numOfCols
,
sizeof
(
int32_t
));
pColInfo
->
boundColumns
=
calloc
(
pColInfo
->
numOfCols
,
sizeof
(
int32_t
));
pColInfo
->
cols
=
calloc
(
pColInfo
->
numOfCols
,
sizeof
(
SBoundColumn
));
pColInfo
->
cols
=
calloc
(
pColInfo
->
numOfCols
,
sizeof
(
SBoundColumn
));
pColInfo
->
colIdxInfo
=
NULL
;
pColInfo
->
colIdxInfo
=
NULL
;
pColInfo
->
flen
=
0
;
pColInfo
->
flen
=
0
;
...
@@ -656,7 +656,7 @@ void tscSetBoundColumnInfo(SParsedDataColInfo *pColInfo, SSchema *pSchema, int32
...
@@ -656,7 +656,7 @@ void tscSetBoundColumnInfo(SParsedDataColInfo *pColInfo, SSchema *pSchema, int32
default:
default:
break
;
break
;
}
}
pColInfo
->
bound
ed
Columns
[
i
]
=
i
;
pColInfo
->
boundColumns
[
i
]
=
i
;
}
}
pColInfo
->
allNullLen
+=
pColInfo
->
flen
;
pColInfo
->
allNullLen
+=
pColInfo
->
flen
;
pColInfo
->
boundNullLen
=
pColInfo
->
allNullLen
;
// default set allNullLen
pColInfo
->
boundNullLen
=
pColInfo
->
allNullLen
;
// default set allNullLen
...
@@ -991,7 +991,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
...
@@ -991,7 +991,7 @@ static int32_t tscCheckIfCreateTable(char **sqlstr, SSqlObj *pSql, char** boundC
}
}
for
(
int
i
=
0
;
i
<
spd
.
numOfBound
;
++
i
)
{
for
(
int
i
=
0
;
i
<
spd
.
numOfBound
;
++
i
)
{
SSchema
*
pSchema
=
&
pTagSchema
[
spd
.
bounde
dColumns
[
i
]];
SSchema
*
pSchema
=
&
pTagSchema
[
spd
.
boun
dColumns
[
i
]];
index
=
0
;
index
=
0
;
sToken
=
tStrGetToken
(
sql
,
&
index
,
true
);
sToken
=
tStrGetToken
(
sql
,
&
index
,
true
);
...
@@ -1158,7 +1158,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
...
@@ -1158,7 +1158,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
pColInfo
->
numOfBound
=
0
;
pColInfo
->
numOfBound
=
0
;
pColInfo
->
boundNullLen
=
0
;
pColInfo
->
boundNullLen
=
0
;
memset
(
pColInfo
->
bound
ed
Columns
,
0
,
sizeof
(
int32_t
)
*
nCols
);
memset
(
pColInfo
->
boundColumns
,
0
,
sizeof
(
int32_t
)
*
nCols
);
for
(
int32_t
i
=
0
;
i
<
nCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
nCols
;
++
i
)
{
pColInfo
->
cols
[
i
].
valStat
=
VAL_STAT_NONE
;
pColInfo
->
cols
[
i
].
valStat
=
VAL_STAT_NONE
;
}
}
...
@@ -1205,7 +1205,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
...
@@ -1205,7 +1205,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
}
}
pColInfo
->
cols
[
t
].
valStat
=
VAL_STAT_HAS
;
pColInfo
->
cols
[
t
].
valStat
=
VAL_STAT_HAS
;
pColInfo
->
bound
ed
Columns
[
pColInfo
->
numOfBound
]
=
t
;
pColInfo
->
boundColumns
[
pColInfo
->
numOfBound
]
=
t
;
++
pColInfo
->
numOfBound
;
++
pColInfo
->
numOfBound
;
switch
(
pSchema
[
t
].
type
)
{
switch
(
pSchema
[
t
].
type
)
{
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
...
@@ -1239,7 +1239,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
...
@@ -1239,7 +1239,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
}
}
pColInfo
->
cols
[
t
].
valStat
=
VAL_STAT_HAS
;
pColInfo
->
cols
[
t
].
valStat
=
VAL_STAT_HAS
;
pColInfo
->
bound
ed
Columns
[
pColInfo
->
numOfBound
]
=
t
;
pColInfo
->
boundColumns
[
pColInfo
->
numOfBound
]
=
t
;
++
pColInfo
->
numOfBound
;
++
pColInfo
->
numOfBound
;
switch
(
pSchema
[
t
].
type
)
{
switch
(
pSchema
[
t
].
type
)
{
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
...
@@ -1279,7 +1279,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
...
@@ -1279,7 +1279,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
}
}
SBoundIdxInfo
*
pColIdx
=
pColInfo
->
colIdxInfo
;
SBoundIdxInfo
*
pColIdx
=
pColInfo
->
colIdxInfo
;
for
(
uint16_t
i
=
0
;
i
<
pColInfo
->
numOfBound
;
++
i
)
{
for
(
uint16_t
i
=
0
;
i
<
pColInfo
->
numOfBound
;
++
i
)
{
pColIdx
[
i
].
schemaColIdx
=
(
uint16_t
)
pColInfo
->
bound
ed
Columns
[
i
];
pColIdx
[
i
].
schemaColIdx
=
(
uint16_t
)
pColInfo
->
boundColumns
[
i
];
pColIdx
[
i
].
boundIdx
=
i
;
pColIdx
[
i
].
boundIdx
=
i
;
}
}
qsort
(
pColIdx
,
pColInfo
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
schemaIdxCompar
);
qsort
(
pColIdx
,
pColInfo
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
schemaIdxCompar
);
...
@@ -1289,7 +1289,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
...
@@ -1289,7 +1289,7 @@ static int32_t parseBoundColumns(SInsertStatementParam *pInsertParam, SParsedDat
qsort
(
pColIdx
,
pColInfo
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
boundIdxCompar
);
qsort
(
pColIdx
,
pColInfo
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
boundIdxCompar
);
}
}
memset
(
&
pColInfo
->
bound
ed
Columns
[
pColInfo
->
numOfBound
],
0
,
memset
(
&
pColInfo
->
boundColumns
[
pColInfo
->
numOfBound
],
0
,
sizeof
(
int32_t
)
*
(
pColInfo
->
numOfCols
-
pColInfo
->
numOfBound
));
sizeof
(
int32_t
)
*
(
pColInfo
->
numOfCols
-
pColInfo
->
numOfBound
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
...
2.0/src/client/src/tscUtil.c
浏览文件 @
a82fc113
...
@@ -1554,7 +1554,7 @@ void tscFreeSqlObj(SSqlObj* pSql) {
...
@@ -1554,7 +1554,7 @@ void tscFreeSqlObj(SSqlObj* pSql) {
}
}
void
tscDestroyBoundColumnInfo
(
SParsedDataColInfo
*
pColInfo
)
{
void
tscDestroyBoundColumnInfo
(
SParsedDataColInfo
*
pColInfo
)
{
tfree
(
pColInfo
->
bound
ed
Columns
);
tfree
(
pColInfo
->
boundColumns
);
tfree
(
pColInfo
->
cols
);
tfree
(
pColInfo
->
cols
);
tfree
(
pColInfo
->
colIdxInfo
);
tfree
(
pColInfo
->
colIdxInfo
);
}
}
...
...
example/src/tmq.c
浏览文件 @
a82fc113
...
@@ -44,7 +44,7 @@ int32_t init_env() {
...
@@ -44,7 +44,7 @@ int32_t init_env() {
pRes
=
taos_query
(
pConn
,
"create stable if not exists st1 (ts timestamp, k int) tags(a int)"
);
pRes
=
taos_query
(
pConn
,
"create stable if not exists st1 (ts timestamp, k int) tags(a int)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create super table
123_$^)
, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"failed to create super table
st1
, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
return
-
1
;
}
}
taos_free_result
(
pRes
);
taos_free_result
(
pRes
);
...
...
include/client/taos.h
浏览文件 @
a82fc113
...
@@ -213,9 +213,10 @@ typedef void(tmq_commit_cb(tmq_t *, tmq_resp_err_t, tmq_topic_vgroup_list_t *, v
...
@@ -213,9 +213,10 @@ typedef void(tmq_commit_cb(tmq_t *, tmq_resp_err_t, tmq_topic_vgroup_list_t *, v
DLL_EXPORT
tmq_list_t
*
tmq_list_new
();
DLL_EXPORT
tmq_list_t
*
tmq_list_new
();
DLL_EXPORT
int32_t
tmq_list_append
(
tmq_list_t
*
,
const
char
*
);
DLL_EXPORT
int32_t
tmq_list_append
(
tmq_list_t
*
,
const
char
*
);
DLL_EXPORT
void
tmq_list_destroy
(
tmq_list_t
*
);
DLL_EXPORT
tmq_t
*
tmq_consumer_new
(
void
*
conn
,
tmq_conf_t
*
conf
,
char
*
errstr
,
int32_t
errstrLen
);
DLL_EXPORT
tmq_t
*
tmq_consumer_new
(
void
*
conn
,
tmq_conf_t
*
conf
,
char
*
errstr
,
int32_t
errstrLen
);
DLL_EXPORT
void
tmq_message_destroy
(
tmq_message_t
*
tmq_message
);
DLL_EXPORT
tmq_t
*
tmq_consumer_new1
(
tmq_conf_t
*
conf
,
char
*
errstr
,
int32_t
errstrLen
);
DLL_EXPORT
const
char
*
tmq_err2str
(
tmq_resp_err_t
);
DLL_EXPORT
const
char
*
tmq_err2str
(
tmq_resp_err_t
);
/* ------------------------TMQ CONSUMER INTERFACE------------------------ */
/* ------------------------TMQ CONSUMER INTERFACE------------------------ */
...
@@ -244,8 +245,8 @@ enum tmq_conf_res_t {
...
@@ -244,8 +245,8 @@ enum tmq_conf_res_t {
typedef
enum
tmq_conf_res_t
tmq_conf_res_t
;
typedef
enum
tmq_conf_res_t
tmq_conf_res_t
;
DLL_EXPORT
tmq_conf_t
*
tmq_conf_new
();
DLL_EXPORT
tmq_conf_t
*
tmq_conf_new
();
DLL_EXPORT
void
tmq_conf_destroy
(
tmq_conf_t
*
conf
);
DLL_EXPORT
tmq_conf_res_t
tmq_conf_set
(
tmq_conf_t
*
conf
,
const
char
*
key
,
const
char
*
value
);
DLL_EXPORT
tmq_conf_res_t
tmq_conf_set
(
tmq_conf_t
*
conf
,
const
char
*
key
,
const
char
*
value
);
DLL_EXPORT
void
tmq_conf_destroy
(
tmq_conf_t
*
conf
);
DLL_EXPORT
void
tmq_conf_set_offset_commit_cb
(
tmq_conf_t
*
conf
,
tmq_commit_cb
*
cb
);
DLL_EXPORT
void
tmq_conf_set_offset_commit_cb
(
tmq_conf_t
*
conf
,
tmq_commit_cb
*
cb
);
// temporary used function for demo only
// temporary used function for demo only
...
@@ -256,6 +257,8 @@ int32_t tmqGetSkipLogNum(tmq_message_t *tmq_message);
...
@@ -256,6 +257,8 @@ int32_t tmqGetSkipLogNum(tmq_message_t *tmq_message);
DLL_EXPORT
TAOS_ROW
tmq_get_row
(
tmq_message_t
*
message
);
DLL_EXPORT
TAOS_ROW
tmq_get_row
(
tmq_message_t
*
message
);
DLL_EXPORT
char
*
tmq_get_topic_name
(
tmq_message_t
*
message
);
DLL_EXPORT
char
*
tmq_get_topic_name
(
tmq_message_t
*
message
);
DLL_EXPORT
void
*
tmq_get_topic_schema
(
tmq_t
*
tmq
,
const
char
*
topic
);
DLL_EXPORT
void
tmq_message_destroy
(
tmq_message_t
*
tmq_message
);
/* --------------------TMPORARY INTERFACE FOR TESTING--------------------- */
/* --------------------TMPORARY INTERFACE FOR TESTING--------------------- */
DLL_EXPORT
TAOS_RES
*
tmq_create_topic
(
TAOS
*
taos
,
const
char
*
name
,
const
char
*
sql
,
int
sqlLen
);
DLL_EXPORT
TAOS_RES
*
tmq_create_topic
(
TAOS
*
taos
,
const
char
*
name
,
const
char
*
sql
,
int
sqlLen
);
...
...
include/common/tcommon.h
浏览文件 @
a82fc113
...
@@ -127,7 +127,7 @@ static FORCE_INLINE int32_t tEncodeSMqPollRsp(void** buf, const SMqPollRsp* pRsp
...
@@ -127,7 +127,7 @@ static FORCE_INLINE int32_t tEncodeSMqPollRsp(void** buf, const SMqPollRsp* pRsp
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
skipLogNum
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
skipLogNum
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
numOfTopics
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pRsp
->
numOfTopics
);
if
(
pRsp
->
numOfTopics
==
0
)
return
tlen
;
if
(
pRsp
->
numOfTopics
==
0
)
return
tlen
;
tlen
+=
tEncodeSSchemaWrapper
(
buf
,
pRsp
->
schema
);
tlen
+=
t
aos
EncodeSSchemaWrapper
(
buf
,
pRsp
->
schema
);
if
(
pRsp
->
pBlockData
)
{
if
(
pRsp
->
pBlockData
)
{
sz
=
taosArrayGetSize
(
pRsp
->
pBlockData
);
sz
=
taosArrayGetSize
(
pRsp
->
pBlockData
);
}
}
...
@@ -149,7 +149,7 @@ static FORCE_INLINE void* tDecodeSMqPollRsp(void* buf, SMqPollRsp* pRsp) {
...
@@ -149,7 +149,7 @@ static FORCE_INLINE void* tDecodeSMqPollRsp(void* buf, SMqPollRsp* pRsp) {
if
(
pRsp
->
numOfTopics
==
0
)
return
buf
;
if
(
pRsp
->
numOfTopics
==
0
)
return
buf
;
pRsp
->
schema
=
(
SSchemaWrapper
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSchemaWrapper
));
pRsp
->
schema
=
(
SSchemaWrapper
*
)
taosMemoryCalloc
(
1
,
sizeof
(
SSchemaWrapper
));
if
(
pRsp
->
schema
==
NULL
)
return
NULL
;
if
(
pRsp
->
schema
==
NULL
)
return
NULL
;
buf
=
tDecodeSSchemaWrapper
(
buf
,
pRsp
->
schema
);
buf
=
t
aos
DecodeSSchemaWrapper
(
buf
,
pRsp
->
schema
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
buf
=
taosDecodeFixedI32
(
buf
,
&
sz
);
pRsp
->
pBlockData
=
taosArrayInit
(
sz
,
sizeof
(
SSDataBlock
));
pRsp
->
pBlockData
=
taosArrayInit
(
sz
,
sizeof
(
SSDataBlock
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
...
...
include/common/tdataformat.h
浏览文件 @
a82fc113
...
@@ -59,12 +59,15 @@ extern "C" {
...
@@ -59,12 +59,15 @@ extern "C" {
} while (0);
} while (0);
// ----------------- TSDB COLUMN DEFINITION
// ----------------- TSDB COLUMN DEFINITION
#pragma pack(push, 1)
typedef
struct
{
typedef
struct
{
int8_t
type
;
// Column type
col_id_t
colId
;
// column ID(start from PRIMARYKEY_TIMESTAMP_COL_ID(1))
col_id_t
colId
;
// column ID(start from PRIMARYKEY_TIMESTAMP_COL_ID(1))
int32_t
type
:
8
;
// column type
int16_t
bytes
;
// column bytes (restore to int16_t in case of misuse)
int32_t
bytes
:
24
;
// column bytes (restore to int32_t in case of misuse)
uint16_t
offset
;
// point offset in STpRow after the header part.
int32_t
sma
:
8
;
// block SMA: 0, no SMA, 1, sum/min/max, 2, ...
int32_t
offset
:
24
;
// point offset in STpRow after the header part.
}
STColumn
;
}
STColumn
;
#pragma pack(pop)
#define colType(col) ((col)->type)
#define colType(col) ((col)->type)
#define colColId(col) ((col)->colId)
#define colColId(col) ((col)->colId)
...
@@ -136,7 +139,7 @@ typedef struct {
...
@@ -136,7 +139,7 @@ typedef struct {
int32_t
tdInitTSchemaBuilder
(
STSchemaBuilder
*
pBuilder
,
int32_t
version
);
int32_t
tdInitTSchemaBuilder
(
STSchemaBuilder
*
pBuilder
,
int32_t
version
);
void
tdDestroyTSchemaBuilder
(
STSchemaBuilder
*
pBuilder
);
void
tdDestroyTSchemaBuilder
(
STSchemaBuilder
*
pBuilder
);
void
tdResetTSchemaBuilder
(
STSchemaBuilder
*
pBuilder
,
int32_t
version
);
void
tdResetTSchemaBuilder
(
STSchemaBuilder
*
pBuilder
,
int32_t
version
);
int32_t
tdAddColToSchema
(
STSchemaBuilder
*
pBuilder
,
int8_t
type
,
int16_t
colId
,
int16
_t
bytes
);
int32_t
tdAddColToSchema
(
STSchemaBuilder
*
pBuilder
,
int8_t
type
,
col_id_t
colId
,
col_bytes
_t
bytes
);
STSchema
*
tdGetSchemaFromBuilder
(
STSchemaBuilder
*
pBuilder
);
STSchema
*
tdGetSchemaFromBuilder
(
STSchemaBuilder
*
pBuilder
);
// ----------------- Semantic timestamp key definition
// ----------------- Semantic timestamp key definition
...
@@ -590,7 +593,7 @@ void tdDestroyKVRowBuilder(SKVRowBuilder *pBuilder);
...
@@ -590,7 +593,7 @@ void tdDestroyKVRowBuilder(SKVRowBuilder *pBuilder);
void
tdResetKVRowBuilder
(
SKVRowBuilder
*
pBuilder
);
void
tdResetKVRowBuilder
(
SKVRowBuilder
*
pBuilder
);
SKVRow
tdGetKVRowFromBuilder
(
SKVRowBuilder
*
pBuilder
);
SKVRow
tdGetKVRowFromBuilder
(
SKVRowBuilder
*
pBuilder
);
static
FORCE_INLINE
int32_t
tdAddColToKVRow
(
SKVRowBuilder
*
pBuilder
,
int16
_t
colId
,
int8_t
type
,
const
void
*
value
)
{
static
FORCE_INLINE
int32_t
tdAddColToKVRow
(
SKVRowBuilder
*
pBuilder
,
col_id
_t
colId
,
int8_t
type
,
const
void
*
value
)
{
if
(
pBuilder
->
nCols
>=
pBuilder
->
tCols
)
{
if
(
pBuilder
->
nCols
>=
pBuilder
->
tCols
)
{
pBuilder
->
tCols
*=
2
;
pBuilder
->
tCols
*=
2
;
SColIdx
*
pColIdx
=
(
SColIdx
*
)
taosMemoryRealloc
((
void
*
)(
pBuilder
->
pColIdx
),
sizeof
(
SColIdx
)
*
pBuilder
->
tCols
);
SColIdx
*
pColIdx
=
(
SColIdx
*
)
taosMemoryRealloc
((
void
*
)(
pBuilder
->
pColIdx
),
sizeof
(
SColIdx
)
*
pBuilder
->
tCols
);
...
...
include/common/tmsg.h
浏览文件 @
a82fc113
...
@@ -208,11 +208,11 @@ typedef struct {
...
@@ -208,11 +208,11 @@ typedef struct {
typedef
struct
SSubmitBlk
{
typedef
struct
SSubmitBlk
{
int64_t
uid
;
// table unique id
int64_t
uid
;
// table unique id
int64_t
suid
;
// stable id
int64_t
suid
;
// stable id
int32_t
padding
;
// TODO just for padding here
int32_t
sversion
;
// data schema version
int32_t
sversion
;
// data schema version
int32_t
dataLen
;
// data part length, not including the SSubmitBlk head
int32_t
dataLen
;
// data part length, not including the SSubmitBlk head
int32_t
schemaLen
;
// schema length, if length is 0, no schema exists
int32_t
schemaLen
;
// schema length, if length is 0, no schema exists
int16_t
numOfRows
;
// total number of rows in current submit block
int16_t
numOfRows
;
// total number of rows in current submit block
int16_t
padding
;
// TODO just for padding here
char
data
[];
char
data
[];
}
SSubmitBlk
;
}
SSubmitBlk
;
...
@@ -259,10 +259,10 @@ typedef struct {
...
@@ -259,10 +259,10 @@ typedef struct {
}
SSubmitRsp
;
}
SSubmitRsp
;
typedef
struct
SSchema
{
typedef
struct
SSchema
{
int8_t
type
;
int8_t
type
;
int32
_t
colId
;
col_id
_t
colId
;
int32_t
bytes
;
int32_t
bytes
;
char
name
[
TSDB_COL_NAME_LEN
];
char
name
[
TSDB_COL_NAME_LEN
];
}
SSchema
;
}
SSchema
;
typedef
struct
{
typedef
struct
{
...
@@ -438,8 +438,8 @@ typedef struct {
...
@@ -438,8 +438,8 @@ typedef struct {
*/
*/
typedef
struct
{
typedef
struct
{
union
{
union
{
int16
_t
colId
;
col_id
_t
colId
;
int16_t
slotId
;
int16_t
slotId
;
};
};
int16_t
type
;
int16_t
type
;
...
@@ -1901,7 +1901,7 @@ static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema
...
@@ -1901,7 +1901,7 @@ static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
type
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSchema
->
bytes
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSchema
->
bytes
);
tlen
+=
taosEncodeFixedI
32
(
buf
,
pSchema
->
colId
);
tlen
+=
taosEncodeFixedI
16
(
buf
,
pSchema
->
colId
);
tlen
+=
taosEncodeString
(
buf
,
pSchema
->
name
);
tlen
+=
taosEncodeString
(
buf
,
pSchema
->
name
);
return
tlen
;
return
tlen
;
}
}
...
@@ -1909,7 +1909,7 @@ static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema
...
@@ -1909,7 +1909,7 @@ static FORCE_INLINE int32_t taosEncodeSSchema(void** buf, const SSchema* pSchema
static
FORCE_INLINE
void
*
taosDecodeSSchema
(
void
*
buf
,
SSchema
*
pSchema
)
{
static
FORCE_INLINE
void
*
taosDecodeSSchema
(
void
*
buf
,
SSchema
*
pSchema
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
type
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSchema
->
bytes
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSchema
->
bytes
);
buf
=
taosDecodeFixedI
32
(
buf
,
&
pSchema
->
colId
);
buf
=
taosDecodeFixedI
16
(
buf
,
&
pSchema
->
colId
);
buf
=
taosDecodeStringTo
(
buf
,
pSchema
->
name
);
buf
=
taosDecodeStringTo
(
buf
,
pSchema
->
name
);
return
buf
;
return
buf
;
}
}
...
@@ -1917,7 +1917,7 @@ static FORCE_INLINE void* taosDecodeSSchema(void* buf, SSchema* pSchema) {
...
@@ -1917,7 +1917,7 @@ static FORCE_INLINE void* taosDecodeSSchema(void* buf, SSchema* pSchema) {
static
FORCE_INLINE
int32_t
tEncodeSSchema
(
SCoder
*
pEncoder
,
const
SSchema
*
pSchema
)
{
static
FORCE_INLINE
int32_t
tEncodeSSchema
(
SCoder
*
pEncoder
,
const
SSchema
*
pSchema
)
{
if
(
tEncodeI8
(
pEncoder
,
pSchema
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI8
(
pEncoder
,
pSchema
->
type
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pSchema
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pSchema
->
bytes
)
<
0
)
return
-
1
;
if
(
tEncodeI
32
(
pEncoder
,
pSchema
->
colId
)
<
0
)
return
-
1
;
if
(
tEncodeI
16
(
pEncoder
,
pSchema
->
colId
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pSchema
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pSchema
->
name
)
<
0
)
return
-
1
;
return
0
;
return
0
;
}
}
...
@@ -1925,12 +1925,12 @@ static FORCE_INLINE int32_t tEncodeSSchema(SCoder* pEncoder, const SSchema* pSch
...
@@ -1925,12 +1925,12 @@ static FORCE_INLINE int32_t tEncodeSSchema(SCoder* pEncoder, const SSchema* pSch
static
FORCE_INLINE
int32_t
tDecodeSSchema
(
SCoder
*
pDecoder
,
SSchema
*
pSchema
)
{
static
FORCE_INLINE
int32_t
tDecodeSSchema
(
SCoder
*
pDecoder
,
SSchema
*
pSchema
)
{
if
(
tDecodeI8
(
pDecoder
,
&
pSchema
->
type
)
<
0
)
return
-
1
;
if
(
tDecodeI8
(
pDecoder
,
&
pSchema
->
type
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pSchema
->
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pSchema
->
bytes
)
<
0
)
return
-
1
;
if
(
tDecodeI
32
(
pDecoder
,
&
pSchema
->
colId
)
<
0
)
return
-
1
;
if
(
tDecodeI
16
(
pDecoder
,
&
pSchema
->
colId
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pDecoder
,
pSchema
->
name
)
<
0
)
return
-
1
;
if
(
tDecodeCStrTo
(
pDecoder
,
pSchema
->
name
)
<
0
)
return
-
1
;
return
0
;
return
0
;
}
}
static
FORCE_INLINE
int32_t
tEncodeSSchemaWrapper
(
void
**
buf
,
const
SSchemaWrapper
*
pSW
)
{
static
FORCE_INLINE
int32_t
t
aos
EncodeSSchemaWrapper
(
void
**
buf
,
const
SSchemaWrapper
*
pSW
)
{
int32_t
tlen
=
0
;
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedU32
(
buf
,
pSW
->
nCols
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pSW
->
nCols
);
for
(
int32_t
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
...
@@ -1939,7 +1939,7 @@ static FORCE_INLINE int32_t tEncodeSSchemaWrapper(void** buf, const SSchemaWrapp
...
@@ -1939,7 +1939,7 @@ static FORCE_INLINE int32_t tEncodeSSchemaWrapper(void** buf, const SSchemaWrapp
return
tlen
;
return
tlen
;
}
}
static
FORCE_INLINE
void
*
tDecodeSSchemaWrapper
(
void
*
buf
,
SSchemaWrapper
*
pSW
)
{
static
FORCE_INLINE
void
*
t
aos
DecodeSSchemaWrapper
(
void
*
buf
,
SSchemaWrapper
*
pSW
)
{
buf
=
taosDecodeFixedU32
(
buf
,
&
pSW
->
nCols
);
buf
=
taosDecodeFixedU32
(
buf
,
&
pSW
->
nCols
);
pSW
->
pSchema
=
(
SSchema
*
)
taosMemoryCalloc
(
pSW
->
nCols
,
sizeof
(
SSchema
));
pSW
->
pSchema
=
(
SSchema
*
)
taosMemoryCalloc
(
pSW
->
nCols
,
sizeof
(
SSchema
));
if
(
pSW
->
pSchema
==
NULL
)
{
if
(
pSW
->
pSchema
==
NULL
)
{
...
@@ -1952,6 +1952,27 @@ static FORCE_INLINE void* tDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW)
...
@@ -1952,6 +1952,27 @@ static FORCE_INLINE void* tDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW)
return
buf
;
return
buf
;
}
}
static
FORCE_INLINE
int32_t
tEncodeSSchemaWrapper
(
SCoder
*
pEncoder
,
const
SSchemaWrapper
*
pSW
)
{
if
(
tEncodeU32
(
pEncoder
,
pSW
->
nCols
)
<
0
)
return
-
1
;
for
(
int32_t
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
if
(
tEncodeSSchema
(
pEncoder
,
&
pSW
->
pSchema
[
i
])
<
0
)
return
-
1
;
}
return
pEncoder
->
pos
;
}
static
FORCE_INLINE
int32_t
tDecodeSSchemaWrapper
(
SCoder
*
pDecoder
,
SSchemaWrapper
*
pSW
)
{
if
(
tDecodeU32
(
pDecoder
,
&
pSW
->
nCols
)
<
0
)
return
-
1
;
void
*
ptr
=
taosMemoryRealloc
(
pSW
->
pSchema
,
pSW
->
nCols
*
sizeof
(
SSchema
));
if
(
ptr
==
NULL
)
{
return
-
1
;
}
pSW
->
pSchema
=
(
SSchema
*
)
ptr
;
for
(
int32_t
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
if
(
tDecodeSSchema
(
pDecoder
,
&
pSW
->
pSchema
[
i
])
<
0
)
return
-
1
;
}
return
0
;
}
typedef
struct
{
typedef
struct
{
char
name
[
TSDB_TABLE_FNAME_LEN
];
char
name
[
TSDB_TABLE_FNAME_LEN
];
char
stb
[
TSDB_TABLE_FNAME_LEN
];
char
stb
[
TSDB_TABLE_FNAME_LEN
];
...
...
include/common/trow.h
浏览文件 @
a82fc113
...
@@ -671,8 +671,9 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowVa
...
@@ -671,8 +671,9 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowVa
* @param colIdx sorted column index, start from 0
* @param colIdx sorted column index, start from 0
* @return FORCE_INLINE
* @return FORCE_INLINE
*/
*/
static
FORCE_INLINE
int32_t
tdAppendColValToRow
(
SRowBuilder
*
pBuilder
,
int16_t
colId
,
int8_t
colType
,
TDRowValT
valType
,
static
FORCE_INLINE
int32_t
tdAppendColValToRow
(
SRowBuilder
*
pBuilder
,
col_id_t
colId
,
int8_t
colType
,
const
void
*
val
,
bool
isCopyVarData
,
int32_t
offset
,
int16_t
colIdx
)
{
TDRowValT
valType
,
const
void
*
val
,
bool
isCopyVarData
,
int32_t
offset
,
col_id_t
colIdx
)
{
STSRow
*
pRow
=
pBuilder
->
pBuf
;
STSRow
*
pRow
=
pBuilder
->
pBuf
;
if
(
!
val
)
{
if
(
!
val
)
{
#ifdef TD_SUPPORT_BITMAP
#ifdef TD_SUPPORT_BITMAP
...
...
include/common/ttypes.h
浏览文件 @
a82fc113
...
@@ -29,6 +29,7 @@ typedef uint32_t TDRowLenT;
...
@@ -29,6 +29,7 @@ typedef uint32_t TDRowLenT;
typedef
uint8_t
TDRowValT
;
typedef
uint8_t
TDRowValT
;
typedef
int16_t
col_id_t
;
typedef
int16_t
col_id_t
;
typedef
int8_t
col_type_t
;
typedef
int8_t
col_type_t
;
typedef
int32_t
col_bytes_t
;
#pragma pack(push, 1)
#pragma pack(push, 1)
typedef
struct
{
typedef
struct
{
...
...
include/libs/nodes/nodes.h
浏览文件 @
a82fc113
...
@@ -120,6 +120,7 @@ typedef enum ENodeType {
...
@@ -120,6 +120,7 @@ typedef enum ENodeType {
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_PLAN_WINDOW
,
QUERY_NODE_LOGIC_PLAN_SORT
,
QUERY_NODE_LOGIC_SUBPLAN
,
QUERY_NODE_LOGIC_SUBPLAN
,
QUERY_NODE_LOGIC_PLAN
,
QUERY_NODE_LOGIC_PLAN
,
...
...
include/libs/nodes/plannodes.h
浏览文件 @
a82fc113
...
@@ -66,6 +66,7 @@ typedef struct SAggLogicNode {
...
@@ -66,6 +66,7 @@ typedef struct SAggLogicNode {
typedef
struct
SProjectLogicNode
{
typedef
struct
SProjectLogicNode
{
SLogicNode
node
;
SLogicNode
node
;
SNodeList
*
pProjections
;
SNodeList
*
pProjections
;
char
stmtName
[
TSDB_TABLE_NAME_LEN
];
}
SProjectLogicNode
;
}
SProjectLogicNode
;
typedef
struct
SVnodeModifLogicNode
{
typedef
struct
SVnodeModifLogicNode
{
...
@@ -97,8 +98,14 @@ typedef struct SWindowLogicNode {
...
@@ -97,8 +98,14 @@ typedef struct SWindowLogicNode {
int8_t
slidingUnit
;
int8_t
slidingUnit
;
SFillNode
*
pFill
;
SFillNode
*
pFill
;
int64_t
sessionGap
;
int64_t
sessionGap
;
SNode
*
pTspk
;
}
SWindowLogicNode
;
}
SWindowLogicNode
;
typedef
struct
SSortLogicNode
{
SLogicNode
node
;
SNodeList
*
pSortKeys
;
}
SSortLogicNode
;
typedef
enum
ESubplanType
{
typedef
enum
ESubplanType
{
SUBPLAN_TYPE_MERGE
=
1
,
SUBPLAN_TYPE_MERGE
=
1
,
SUBPLAN_TYPE_PARTIAL
,
SUBPLAN_TYPE_PARTIAL
,
...
@@ -200,7 +207,7 @@ typedef struct SJoinPhysiNode {
...
@@ -200,7 +207,7 @@ typedef struct SJoinPhysiNode {
typedef
struct
SAggPhysiNode
{
typedef
struct
SAggPhysiNode
{
SPhysiNode
node
;
SPhysiNode
node
;
SNodeList
*
pExprs
;
// these are expression list of group_by_clause and parameter expression of aggregate function
SNodeList
*
pExprs
;
// these are expression list of group_by_clause and parameter expression of aggregate function
SNodeList
*
pGroupKeys
;
// SColumnRefNode list
SNodeList
*
pGroupKeys
;
SNodeList
*
pAggFuncs
;
SNodeList
*
pAggFuncs
;
}
SAggPhysiNode
;
}
SAggPhysiNode
;
...
@@ -225,6 +232,7 @@ typedef struct SWinodwPhysiNode {
...
@@ -225,6 +232,7 @@ typedef struct SWinodwPhysiNode {
typedef
struct
SIntervalPhysiNode
{
typedef
struct
SIntervalPhysiNode
{
SWinodwPhysiNode
window
;
SWinodwPhysiNode
window
;
SNode
*
pTspk
;
// timestamp primary key
int64_t
interval
;
int64_t
interval
;
int64_t
offset
;
int64_t
offset
;
int64_t
sliding
;
int64_t
sliding
;
...
@@ -238,6 +246,12 @@ typedef struct SSessionWinodwPhysiNode {
...
@@ -238,6 +246,12 @@ typedef struct SSessionWinodwPhysiNode {
int64_t
gap
;
int64_t
gap
;
}
SSessionWinodwPhysiNode
;
}
SSessionWinodwPhysiNode
;
typedef
struct
SSortPhysiNode
{
SPhysiNode
node
;
SNodeList
*
pExprs
;
// these are expression list of order_by_clause and parameter expression of aggregate function
SNodeList
*
pSortKeys
;
// element is SOrderByExprNode, and SOrderByExprNode::pExpr is SColumnNode
}
SSortPhysiNode
;
typedef
struct
SDataSinkNode
{
typedef
struct
SDataSinkNode
{
ENodeType
type
;
ENodeType
type
;
SDataBlockDescNode
*
pInputDataBlockDesc
;
SDataBlockDescNode
*
pInputDataBlockDesc
;
...
...
include/libs/nodes/querynodes.h
浏览文件 @
a82fc113
...
@@ -56,7 +56,7 @@ typedef enum EColumnType {
...
@@ -56,7 +56,7 @@ typedef enum EColumnType {
typedef
struct
SColumnNode
{
typedef
struct
SColumnNode
{
SExprNode
node
;
// QUERY_NODE_COLUMN
SExprNode
node
;
// QUERY_NODE_COLUMN
uint64_t
tableId
;
uint64_t
tableId
;
int16
_t
colId
;
col_id
_t
colId
;
EColumnType
colType
;
// column or tag
EColumnType
colType
;
// column or tag
char
dbName
[
TSDB_DB_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
char
tableName
[
TSDB_TABLE_NAME_LEN
];
...
@@ -191,12 +191,13 @@ typedef struct SStateWindowNode {
...
@@ -191,12 +191,13 @@ typedef struct SStateWindowNode {
typedef
struct
SSessionWindowNode
{
typedef
struct
SSessionWindowNode
{
ENodeType
type
;
// QUERY_NODE_SESSION_WINDOW
ENodeType
type
;
// QUERY_NODE_SESSION_WINDOW
SNode
*
pCol
;
SNode
*
pCol
;
// timestamp primary key
SNode
*
pGap
;
// gap between two session window(in microseconds)
SNode
*
pGap
;
// gap between two session window(in microseconds)
}
SSessionWindowNode
;
}
SSessionWindowNode
;
typedef
struct
SIntervalWindowNode
{
typedef
struct
SIntervalWindowNode
{
ENodeType
type
;
// QUERY_NODE_INTERVAL_WINDOW
ENodeType
type
;
// QUERY_NODE_INTERVAL_WINDOW
SNode
*
pCol
;
// timestamp primary key
SNode
*
pInterval
;
// SValueNode
SNode
*
pInterval
;
// SValueNode
SNode
*
pOffset
;
// SValueNode
SNode
*
pOffset
;
// SValueNode
SNode
*
pSliding
;
// SValueNode
SNode
*
pSliding
;
// SValueNode
...
@@ -231,6 +232,7 @@ typedef struct SSelectStmt {
...
@@ -231,6 +232,7 @@ typedef struct SSelectStmt {
SNodeList
*
pOrderByList
;
// SOrderByExprNode
SNodeList
*
pOrderByList
;
// SOrderByExprNode
SNode
*
pLimit
;
SNode
*
pLimit
;
SNode
*
pSlimit
;
SNode
*
pSlimit
;
char
stmtName
[
TSDB_TABLE_NAME_LEN
];
}
SSelectStmt
;
}
SSelectStmt
;
typedef
enum
ESetOperatorType
{
typedef
enum
ESetOperatorType
{
...
...
include/libs/qcom/query.h
浏览文件 @
a82fc113
...
@@ -43,10 +43,10 @@ typedef enum {
...
@@ -43,10 +43,10 @@ typedef enum {
}
ETaskType
;
}
ETaskType
;
typedef
struct
STableComInfo
{
typedef
struct
STableComInfo
{
uint8_t
numOfTags
;
// the number of tags in schema
uint8_t
numOfTags
;
// the number of tags in schema
uint8_t
precision
;
// the number of precision
uint8_t
precision
;
// the number of precision
int16
_t
numOfColumns
;
// the number of columns
col_id
_t
numOfColumns
;
// the number of columns
int32_t
rowSize
;
// row size of the schema
int32_t
rowSize
;
// row size of the schema
}
STableComInfo
;
}
STableComInfo
;
typedef
struct
SIndexMeta
{
typedef
struct
SIndexMeta
{
...
@@ -173,7 +173,7 @@ bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_
...
@@ -173,7 +173,7 @@ bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_
int32_t
queryCreateTableMetaFromMsg
(
STableMetaRsp
*
msg
,
bool
isSuperTable
,
STableMeta
**
pMeta
);
int32_t
queryCreateTableMetaFromMsg
(
STableMetaRsp
*
msg
,
bool
isSuperTable
,
STableMeta
**
pMeta
);
char
*
jobTaskStatusStr
(
int32_t
status
);
char
*
jobTaskStatusStr
(
int32_t
status
);
SSchema
createSchema
(
uint8_t
type
,
int32_t
bytes
,
int32
_t
colId
,
const
char
*
name
);
SSchema
createSchema
(
int8_t
type
,
int32_t
bytes
,
col_id
_t
colId
,
const
char
*
name
);
extern
int32_t
(
*
queryBuildMsg
[
TDMT_MAX
])(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
);
extern
int32_t
(
*
queryBuildMsg
[
TDMT_MAX
])(
void
*
input
,
char
**
msg
,
int32_t
msgSize
,
int32_t
*
msgLen
);
extern
int32_t
(
*
queryProcessMsgRsp
[
TDMT_MAX
])(
void
*
output
,
char
*
msg
,
int32_t
msgSize
);
extern
int32_t
(
*
queryProcessMsgRsp
[
TDMT_MAX
])(
void
*
output
,
char
*
msg
,
int32_t
msgSize
);
...
...
include/libs/stream/tstream.h
浏览文件 @
a82fc113
...
@@ -62,10 +62,11 @@ typedef struct {
...
@@ -62,10 +62,11 @@ typedef struct {
}
STaskExec
;
}
STaskExec
;
typedef
struct
{
typedef
struct
{
int
8_t
reserve
d
;
int
32_t
taskI
d
;
}
STaskDispatcherInplace
;
}
STaskDispatcherInplace
;
typedef
struct
{
typedef
struct
{
int32_t
taskId
;
int32_t
nodeId
;
int32_t
nodeId
;
SEpSet
epSet
;
SEpSet
epSet
;
}
STaskDispatcherFixedEp
;
}
STaskDispatcherFixedEp
;
...
...
include/os/os.h
浏览文件 @
a82fc113
...
@@ -75,7 +75,6 @@ extern "C" {
...
@@ -75,7 +75,6 @@ extern "C" {
#include "osDef.h"
#include "osDef.h"
#include "osDir.h"
#include "osDir.h"
#include "osEndian.h"
#include "osEndian.h"
#include "osEnv.h"
#include "osFile.h"
#include "osFile.h"
#include "osLocale.h"
#include "osLocale.h"
#include "osLz4.h"
#include "osLz4.h"
...
@@ -93,8 +92,9 @@ extern "C" {
...
@@ -93,8 +92,9 @@ extern "C" {
#include "osTime.h"
#include "osTime.h"
#include "osTimer.h"
#include "osTimer.h"
#include "osTimezone.h"
#include "osTimezone.h"
#include "osEnv.h"
void
osInit
();
void
os
Default
Init
();
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/os/osEnv.h
浏览文件 @
a82fc113
...
@@ -22,17 +22,18 @@
...
@@ -22,17 +22,18 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
extern
char
tsOsName
[];
extern
char
tsOsName
[];
extern
char
tsTimezone
[];
extern
char
tsTimezoneStr
[];
extern
char
tsCharset
[];
extern
enum
TdTimezone
tsTimezone
;
extern
char
tsLocale
[];
extern
char
tsCharset
[];
extern
int8_t
tsDaylight
;
extern
char
tsLocale
[];
extern
bool
tsEnableCoreFile
;
extern
int8_t
tsDaylight
;
extern
int64_t
tsPageSizeKB
;
extern
bool
tsEnableCoreFile
;
extern
int64_t
tsOpenMax
;
extern
int64_t
tsPageSizeKB
;
extern
int64_t
tsStreamMax
;
extern
int64_t
tsOpenMax
;
extern
float
tsNumOfCores
;
extern
int64_t
tsStreamMax
;
extern
int64_t
tsTotalMemoryKB
;
extern
float
tsNumOfCores
;
extern
int64_t
tsTotalMemoryKB
;
extern
char
configDir
[];
extern
char
configDir
[];
extern
char
tsDataDir
[];
extern
char
tsDataDir
[];
...
@@ -43,11 +44,12 @@ extern SDiskSpace tsDataSpace;
...
@@ -43,11 +44,12 @@ extern SDiskSpace tsDataSpace;
extern
SDiskSpace
tsLogSpace
;
extern
SDiskSpace
tsLogSpace
;
extern
SDiskSpace
tsTempSpace
;
extern
SDiskSpace
tsTempSpace
;
void
osInit
();
void
os
Default
Init
();
void
osUpdate
();
void
osUpdate
();
void
osCleanup
();
void
osCleanup
();
bool
osLogSpaceAvailable
();
bool
osLogSpaceAvailable
();
void
osSetTimezone
(
const
char
*
timezone
);
void
osSetTimezone
(
const
char
*
timezone
);
void
osSetSystemLocale
(
const
char
*
inLocale
,
const
char
*
inCharSet
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/os/osTimezone.h
浏览文件 @
a82fc113
...
@@ -26,8 +26,37 @@ extern "C" {
...
@@ -26,8 +26,37 @@ extern "C" {
#define tzset TZSET_FUNC_TAOS_FORBID
#define tzset TZSET_FUNC_TAOS_FORBID
#endif
#endif
void
taosGetSystemTimezone
(
char
*
outTimezone
);
enum
TdTimezone
void
taosSetSystemTimezone
(
const
char
*
inTimezone
,
char
*
outTimezone
,
int8_t
*
outDaylight
);
{
TdWestZone12
=-
12
,
TdWestZone11
,
TdWestZone10
,
TdWestZone9
,
TdWestZone8
,
TdWestZone7
,
TdWestZone6
,
TdWestZone5
,
TdWestZone4
,
TdWestZone3
,
TdWestZone2
,
TdWestZone1
,
TdZeroZone
,
TdEastZone1
,
TdEastZone2
,
TdEastZone3
,
TdEastZone4
,
TdEastZone5
,
TdEastZone6
,
TdEastZone7
,
TdEastZone8
,
TdEastZone9
,
TdEastZone10
,
TdEastZone11
,
TdEastZone12
};
void
taosGetSystemTimezone
(
char
*
outTimezone
,
enum
TdTimezone
*
tsTimezone
);
void
taosSetSystemTimezone
(
const
char
*
inTimezone
,
char
*
outTimezone
,
int8_t
*
outDaylight
,
enum
TdTimezone
*
tsTimezone
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
include/util/taoserror.h
浏览文件 @
a82fc113
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
#ifndef _TD_UTIL_TAOS_ERROR_H_
#ifndef _TD_UTIL_TAOS_ERROR_H_
#define _TD_UTIL_TAOS_ERROR_H_
#define _TD_UTIL_TAOS_ERROR_H_
#include "os.h"
#ifdef __cplusplus
#ifdef __cplusplus
extern
"C"
{
extern
"C"
{
#endif
#endif
...
...
include/util/tdef.h
浏览文件 @
a82fc113
...
@@ -209,7 +209,7 @@ typedef enum ELogicConditionType {
...
@@ -209,7 +209,7 @@ typedef enum ELogicConditionType {
#define TSDB_FUNC_TYPE_AGGREGATE 2
#define TSDB_FUNC_TYPE_AGGREGATE 2
#define TSDB_FUNC_MAX_RETRIEVE 1024
#define TSDB_FUNC_MAX_RETRIEVE 1024
#define TSDB_INDEX_NAME_LEN
33 // 32
+ 1 '\0'
#define TSDB_INDEX_NAME_LEN
65 // 64
+ 1 '\0'
#define TSDB_TYPE_STR_MAX_LEN 32
#define TSDB_TYPE_STR_MAX_LEN 32
#define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_TABLE_FNAME_LEN (TSDB_DB_FNAME_LEN + TSDB_TABLE_NAME_LEN + TSDB_NAME_DELIMITER_LEN)
#define TSDB_TOPIC_FNAME_LEN TSDB_TABLE_FNAME_LEN
#define TSDB_TOPIC_FNAME_LEN TSDB_TABLE_FNAME_LEN
...
...
include/util/tprocess.h
浏览文件 @
a82fc113
...
@@ -51,6 +51,7 @@ void taosProcCleanup(SProcObj *pProc);
...
@@ -51,6 +51,7 @@ void taosProcCleanup(SProcObj *pProc);
int32_t
taosProcRun
(
SProcObj
*
pProc
);
int32_t
taosProcRun
(
SProcObj
*
pProc
);
void
taosProcStop
(
SProcObj
*
pProc
);
void
taosProcStop
(
SProcObj
*
pProc
);
bool
taosProcIsChild
(
SProcObj
*
pProc
);
bool
taosProcIsChild
(
SProcObj
*
pProc
);
int32_t
taosProcChildId
(
SProcObj
*
pProc
);
int32_t
taosProcPutToChildQueue
(
SProcObj
*
pProc
,
void
*
pHead
,
int32_t
headLen
,
void
*
pBody
,
int32_t
bodyLen
);
int32_t
taosProcPutToChildQueue
(
SProcObj
*
pProc
,
void
*
pHead
,
int32_t
headLen
,
void
*
pBody
,
int32_t
bodyLen
);
int32_t
taosProcPutToParentQueue
(
SProcObj
*
pProc
,
void
*
pHead
,
int32_t
headLen
,
void
*
pBody
,
int32_t
bodyLen
);
int32_t
taosProcPutToParentQueue
(
SProcObj
*
pProc
,
void
*
pHead
,
int32_t
headLen
,
void
*
pBody
,
int32_t
bodyLen
);
...
...
source/client/src/clientEnv.c
浏览文件 @
a82fc113
...
@@ -408,10 +408,10 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
...
@@ -408,10 +408,10 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
assert(cfg != NULL);
assert(cfg != NULL);
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
if (cfg->cfgStatus <= TAOS_CFG_CSTATUS_OPTION) {
tstrncpy(tsTimezone, str, TD_TIMEZONE_LEN);
tstrncpy(tsTimezone
Str
, str, TD_TIMEZONE_LEN);
tsSetTimeZone();
tsSetTimeZone();
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
cfg->cfgStatus = TAOS_CFG_CSTATUS_OPTION;
tscDebug("timezone set:%s, input:%s by taos_options", tsTimezone, str);
tscDebug("timezone set:%s, input:%s by taos_options", tsTimezone
Str
, str);
} else {
} else {
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str,
tscWarn("config option:%s, input value:%s, is configured by %s, use %s", cfg->option, str,
tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
tsCfgStatusStr[cfg->cfgStatus], (char *)cfg->ptr);
...
...
source/client/src/clientHb.c
浏览文件 @
a82fc113
...
@@ -91,7 +91,7 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
...
@@ -91,7 +91,7 @@ static int32_t hbProcessStbInfoRsp(void *value, int32_t valueLen, struct SCatalo
}
else
{
}
else
{
tscDebug
(
"hb update stb, db:%s, stb:%s"
,
rsp
->
dbFName
,
rsp
->
stbName
);
tscDebug
(
"hb update stb, db:%s, stb:%s"
,
rsp
->
dbFName
,
rsp
->
stbName
);
if
(
rsp
->
pSchemas
[
0
].
colId
!=
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
if
(
rsp
->
pSchemas
[
0
].
colId
!=
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
tscError
(
"invalid colId[%
d
] for the first column in table meta rsp msg"
,
rsp
->
pSchemas
[
0
].
colId
);
tscError
(
"invalid colId[%
"
PRIi16
"
] for the first column in table meta rsp msg"
,
rsp
->
pSchemas
[
0
].
colId
);
tFreeSTableMetaBatchRsp
(
&
batchMetaRsp
);
tFreeSTableMetaBatchRsp
(
&
batchMetaRsp
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
}
...
...
source/client/src/tmq.c
浏览文件 @
a82fc113
...
@@ -27,9 +27,7 @@
...
@@ -27,9 +27,7 @@
#include "tref.h"
#include "tref.h"
struct
tmq_list_t
{
struct
tmq_list_t
{
int32_t
cnt
;
SArray
container
;
int32_t
tot
;
char
*
elems
[];
};
};
struct
tmq_topic_vgroup_t
{
struct
tmq_topic_vgroup_t
{
...
@@ -45,11 +43,14 @@ struct tmq_topic_vgroup_list_t {
...
@@ -45,11 +43,14 @@ struct tmq_topic_vgroup_list_t {
struct
tmq_conf_t
{
struct
tmq_conf_t
{
char
clientId
[
256
];
char
clientId
[
256
];
char
groupId
[
TSDB_CGROUP_LEN
];
char
groupId
[
TSDB_CGROUP_LEN
];
int8_t
auto
_c
ommit
;
int8_t
auto
C
ommit
;
int8_t
resetOffset
;
int8_t
resetOffset
;
uint16_t
port
;
char
*
ip
;
char
*
user
;
char
*
pass
;
char
*
db
;
tmq_commit_cb
*
commit_cb
;
tmq_commit_cb
*
commit_cb
;
/*char* ip;*/
/*uint16_t port;*/
};
};
struct
tmq_t
{
struct
tmq_t
{
...
@@ -98,12 +99,13 @@ typedef struct {
...
@@ -98,12 +99,13 @@ typedef struct {
typedef
struct
{
typedef
struct
{
// subscribe info
// subscribe info
int32_t
sqlLen
;
int32_t
sqlLen
;
char
*
sql
;
char
*
sql
;
char
*
topicName
;
char
*
topicName
;
int64_t
topicId
;
int64_t
topicId
;
int32_t
nextVgIdx
;
int32_t
nextVgIdx
;
SArray
*
vgs
;
// SArray<SMqClientVg>
SArray
*
vgs
;
// SArray<SMqClientVg>
SSchemaWrapper
schema
;
}
SMqClientTopic
;
}
SMqClientTopic
;
typedef
struct
{
typedef
struct
{
...
@@ -137,7 +139,7 @@ typedef struct {
...
@@ -137,7 +139,7 @@ typedef struct {
tmq_conf_t
*
tmq_conf_new
()
{
tmq_conf_t
*
tmq_conf_new
()
{
tmq_conf_t
*
conf
=
taosMemoryCalloc
(
1
,
sizeof
(
tmq_conf_t
));
tmq_conf_t
*
conf
=
taosMemoryCalloc
(
1
,
sizeof
(
tmq_conf_t
));
conf
->
auto
_c
ommit
=
false
;
conf
->
auto
C
ommit
=
false
;
conf
->
resetOffset
=
TMQ_CONF__RESET_OFFSET__EARLIEAST
;
conf
->
resetOffset
=
TMQ_CONF__RESET_OFFSET__EARLIEAST
;
return
conf
;
return
conf
;
}
}
...
@@ -151,21 +153,24 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
...
@@ -151,21 +153,24 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
strcpy
(
conf
->
groupId
,
value
);
strcpy
(
conf
->
groupId
,
value
);
return
TMQ_CONF_OK
;
return
TMQ_CONF_OK
;
}
}
if
(
strcmp
(
key
,
"client.id"
)
==
0
)
{
if
(
strcmp
(
key
,
"client.id"
)
==
0
)
{
strcpy
(
conf
->
clientId
,
value
);
strcpy
(
conf
->
clientId
,
value
);
return
TMQ_CONF_OK
;
return
TMQ_CONF_OK
;
}
}
if
(
strcmp
(
key
,
"enable.auto.commit"
)
==
0
)
{
if
(
strcmp
(
key
,
"enable.auto.commit"
)
==
0
)
{
if
(
strcmp
(
value
,
"true"
)
==
0
)
{
if
(
strcmp
(
value
,
"true"
)
==
0
)
{
conf
->
auto
_c
ommit
=
true
;
conf
->
auto
C
ommit
=
true
;
return
TMQ_CONF_OK
;
return
TMQ_CONF_OK
;
}
else
if
(
strcmp
(
value
,
"false"
)
==
0
)
{
}
else
if
(
strcmp
(
value
,
"false"
)
==
0
)
{
conf
->
auto
_c
ommit
=
false
;
conf
->
auto
C
ommit
=
false
;
return
TMQ_CONF_OK
;
return
TMQ_CONF_OK
;
}
else
{
}
else
{
return
TMQ_CONF_INVALID
;
return
TMQ_CONF_INVALID
;
}
}
}
}
if
(
strcmp
(
key
,
"auto.offset.reset"
)
==
0
)
{
if
(
strcmp
(
key
,
"auto.offset.reset"
)
==
0
)
{
if
(
strcmp
(
value
,
"none"
)
==
0
)
{
if
(
strcmp
(
value
,
"none"
)
==
0
)
{
conf
->
resetOffset
=
TMQ_CONF__RESET_OFFSET__NONE
;
conf
->
resetOffset
=
TMQ_CONF__RESET_OFFSET__NONE
;
...
@@ -180,28 +185,51 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
...
@@ -180,28 +185,51 @@ tmq_conf_res_t tmq_conf_set(tmq_conf_t* conf, const char* key, const char* value
return
TMQ_CONF_INVALID
;
return
TMQ_CONF_INVALID
;
}
}
}
}
if
(
strcmp
(
key
,
"td.connect.ip"
)
==
0
)
{
conf
->
ip
=
strdup
(
value
);
return
TMQ_CONF_OK
;
}
if
(
strcmp
(
key
,
"td.connect.user"
)
==
0
)
{
conf
->
user
=
strdup
(
value
);
return
TMQ_CONF_OK
;
}
if
(
strcmp
(
key
,
"td.connect.pass"
)
==
0
)
{
conf
->
pass
=
strdup
(
value
);
return
TMQ_CONF_OK
;
}
if
(
strcmp
(
key
,
"td.connect.port"
)
==
0
)
{
conf
->
port
=
atoi
(
value
);
return
TMQ_CONF_OK
;
}
if
(
strcmp
(
key
,
"td.connect.db"
)
==
0
)
{
conf
->
db
=
strdup
(
value
);
return
TMQ_CONF_OK
;
}
return
TMQ_CONF_UNKNOWN
;
return
TMQ_CONF_UNKNOWN
;
}
}
tmq_list_t
*
tmq_list_new
()
{
tmq_list_t
*
tmq_list_new
()
{
tmq_list_t
*
ptr
=
taosMemoryMalloc
(
sizeof
(
tmq_list_t
)
+
8
*
sizeof
(
char
*
));
//
if
(
ptr
==
NULL
)
{
return
(
tmq_list_t
*
)
taosArrayInit
(
0
,
sizeof
(
void
*
));
return
ptr
;
}
ptr
->
cnt
=
0
;
ptr
->
tot
=
8
;
return
ptr
;
}
}
int32_t
tmq_list_append
(
tmq_list_t
*
ptr
,
const
char
*
src
)
{
int32_t
tmq_list_append
(
tmq_list_t
*
list
,
const
char
*
src
)
{
if
(
ptr
->
cnt
>=
ptr
->
tot
-
1
)
return
-
1
;
SArray
*
container
=
&
list
->
container
;
ptr
->
elems
[
ptr
->
cnt
]
=
strdup
(
src
);
char
*
topic
=
strdup
(
src
);
ptr
->
cnt
++
;
if
(
taosArrayPush
(
container
,
&
topic
)
==
NULL
)
return
-
1
;
return
0
;
return
0
;
}
}
void
tmq_list_destroy
(
tmq_list_t
*
list
)
{
SArray
*
container
=
&
list
->
container
;
/*taosArrayDestroy(container);*/
taosArrayDestroyEx
(
container
,
(
void
(
*
)(
void
*
))
taosMemoryFree
);
}
void
tmqClearUnhandleMsg
(
tmq_t
*
tmq
)
{
void
tmqClearUnhandleMsg
(
tmq_t
*
tmq
)
{
tmq_message_t
*
msg
;
tmq_message_t
*
msg
=
NULL
;
while
(
1
)
{
while
(
1
)
{
taosGetQitem
(
tmq
->
qall
,
(
void
**
)
&
msg
);
taosGetQitem
(
tmq
->
qall
,
(
void
**
)
&
msg
);
if
(
msg
)
if
(
msg
)
...
@@ -268,17 +296,57 @@ tmq_t* tmq_consumer_new(void* conn, tmq_conf_t* conf, char* errstr, int32_t errs
...
@@ -268,17 +296,57 @@ tmq_t* tmq_consumer_new(void* conn, tmq_conf_t* conf, char* errstr, int32_t errs
// set conf
// set conf
strcpy
(
pTmq
->
clientId
,
conf
->
clientId
);
strcpy
(
pTmq
->
clientId
,
conf
->
clientId
);
strcpy
(
pTmq
->
groupId
,
conf
->
groupId
);
strcpy
(
pTmq
->
groupId
,
conf
->
groupId
);
pTmq
->
autoCommit
=
conf
->
auto
_c
ommit
;
pTmq
->
autoCommit
=
conf
->
auto
C
ommit
;
pTmq
->
commit_cb
=
conf
->
commit_cb
;
pTmq
->
commit_cb
=
conf
->
commit_cb
;
pTmq
->
resetOffsetCfg
=
conf
->
resetOffset
;
pTmq
->
resetOffsetCfg
=
conf
->
resetOffset
;
pTmq
->
consumerId
=
generateRequestId
()
&
(((
uint64_t
)
-
1
)
>>
1
);
pTmq
->
clientTopics
=
taosArrayInit
(
0
,
sizeof
(
SMqClientTopic
));
if
(
pTmq
->
clientTopics
==
NULL
)
{
taosMemoryFree
(
pTmq
);
return
NULL
;
}
pTmq
->
mqueue
=
taosOpenQueue
();
pTmq
->
qall
=
taosAllocateQall
();
tsem_init
(
&
pTmq
->
rspSem
,
0
,
0
);
tsem_init
(
&
pTmq
->
rspSem
,
0
,
0
);
return
pTmq
;
}
tmq_t
*
tmq_consumer_new1
(
tmq_conf_t
*
conf
,
char
*
errstr
,
int32_t
errstrLen
)
{
tmq_t
*
pTmq
=
taosMemoryCalloc
(
1
,
sizeof
(
tmq_t
));
if
(
pTmq
==
NULL
)
{
return
NULL
;
}
pTmq
->
pTscObj
=
taos_connect
(
conf
->
ip
,
conf
->
user
,
conf
->
pass
,
conf
->
db
,
conf
->
port
);
pTmq
->
inWaiting
=
0
;
pTmq
->
status
=
0
;
pTmq
->
pollCnt
=
0
;
pTmq
->
epoch
=
0
;
pTmq
->
waitingRequest
=
0
;
pTmq
->
readyRequest
=
0
;
// set conf
strcpy
(
pTmq
->
clientId
,
conf
->
clientId
);
strcpy
(
pTmq
->
groupId
,
conf
->
groupId
);
pTmq
->
autoCommit
=
conf
->
autoCommit
;
pTmq
->
commit_cb
=
conf
->
commit_cb
;
pTmq
->
resetOffsetCfg
=
conf
->
resetOffset
;
pTmq
->
consumerId
=
generateRequestId
()
&
(((
uint64_t
)
-
1
)
>>
1
);
pTmq
->
consumerId
=
generateRequestId
()
&
(((
uint64_t
)
-
1
)
>>
1
);
pTmq
->
clientTopics
=
taosArrayInit
(
0
,
sizeof
(
SMqClientTopic
));
pTmq
->
clientTopics
=
taosArrayInit
(
0
,
sizeof
(
SMqClientTopic
));
if
(
pTmq
->
clientTopics
==
NULL
)
{
taosMemoryFree
(
pTmq
);
return
NULL
;
}
pTmq
->
mqueue
=
taosOpenQueue
();
pTmq
->
mqueue
=
taosOpenQueue
();
pTmq
->
qall
=
taosAllocateQall
();
pTmq
->
qall
=
taosAllocateQall
();
tsem_init
(
&
pTmq
->
rspSem
,
0
,
0
);
return
pTmq
;
return
pTmq
;
}
}
...
@@ -372,7 +440,8 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
...
@@ -372,7 +440,8 @@ tmq_resp_err_t tmq_commit(tmq_t* tmq, const tmq_topic_vgroup_list_t* offsets, in
tmq_resp_err_t
tmq_subscribe
(
tmq_t
*
tmq
,
tmq_list_t
*
topic_list
)
{
tmq_resp_err_t
tmq_subscribe
(
tmq_t
*
tmq
,
tmq_list_t
*
topic_list
)
{
SRequestObj
*
pRequest
=
NULL
;
SRequestObj
*
pRequest
=
NULL
;
int32_t
sz
=
topic_list
->
cnt
;
SArray
*
container
=
&
topic_list
->
container
;
int32_t
sz
=
taosArrayGetSize
(
container
);
// destroy ex
// destroy ex
taosArrayDestroy
(
tmq
->
clientTopics
);
taosArrayDestroy
(
tmq
->
clientTopics
);
tmq
->
clientTopics
=
taosArrayInit
(
sz
,
sizeof
(
SMqClientTopic
));
tmq
->
clientTopics
=
taosArrayInit
(
sz
,
sizeof
(
SMqClientTopic
));
...
@@ -384,7 +453,8 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, tmq_list_t* topic_list) {
...
@@ -384,7 +453,8 @@ tmq_resp_err_t tmq_subscribe(tmq_t* tmq, tmq_list_t* topic_list) {
req
.
topicNames
=
taosArrayInit
(
sz
,
sizeof
(
void
*
));
req
.
topicNames
=
taosArrayInit
(
sz
,
sizeof
(
void
*
));
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
char
*
topicName
=
topic_list
->
elems
[
i
];
/*char* topicName = topic_list->elems[i];*/
char
*
topicName
=
taosArrayGetP
(
container
,
i
);
SName
name
=
{
0
};
SName
name
=
{
0
};
char
*
dbName
=
getDbOfConnection
(
tmq
->
pTscObj
);
char
*
dbName
=
getDbOfConnection
(
tmq
->
pTscObj
);
...
@@ -737,7 +807,7 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
...
@@ -737,7 +807,7 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
SMqClientVg
*
pVg
=
pParam
->
pVg
;
SMqClientVg
*
pVg
=
pParam
->
pVg
;
tmq_t
*
tmq
=
pParam
->
tmq
;
tmq_t
*
tmq
=
pParam
->
tmq
;
if
(
code
!=
0
)
{
if
(
code
!=
0
)
{
printf
(
"msg discard
%x
\n
"
,
code
);
printf
(
"msg discard
, code:
%x
\n
"
,
code
);
goto
WRITE_QUEUE_FAIL
;
goto
WRITE_QUEUE_FAIL
;
}
}
...
@@ -807,10 +877,10 @@ WRITE_QUEUE_FAIL:
...
@@ -807,10 +877,10 @@ WRITE_QUEUE_FAIL:
}
}
bool
tmqUpdateEp
(
tmq_t
*
tmq
,
int32_t
epoch
,
SMqCMGetSubEpRsp
*
pRsp
)
{
bool
tmqUpdateEp
(
tmq_t
*
tmq
,
int32_t
epoch
,
SMqCMGetSubEpRsp
*
pRsp
)
{
printf
(
"call update ep %d
\n
"
,
epoch
);
bool
set
=
false
;
bool
set
=
false
;
int32_t
sz
=
taosArrayGetSize
(
pRsp
->
topics
);
int32_t
sz
=
taosArrayGetSize
(
pRsp
->
topics
);
if
(
tmq
->
clientTopics
)
taosArrayDestroy
(
tmq
->
clientTopics
);
SArray
*
newTopics
=
taosArrayInit
(
sz
,
sizeof
(
SMqClientTopic
));
tmq
->
clientTopics
=
taosArrayInit
(
sz
,
sizeof
(
SMqClientTopic
));
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
sz
;
i
++
)
{
SMqClientTopic
topic
=
{
0
};
SMqClientTopic
topic
=
{
0
};
SMqSubTopicEp
*
pTopicEp
=
taosArrayGet
(
pRsp
->
topics
,
i
);
SMqSubTopicEp
*
pTopicEp
=
taosArrayGet
(
pRsp
->
topics
,
i
);
...
@@ -829,8 +899,10 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqCMGetSubEpRsp* pRsp) {
...
@@ -829,8 +899,10 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqCMGetSubEpRsp* pRsp) {
taosArrayPush
(
topic
.
vgs
,
&
clientVg
);
taosArrayPush
(
topic
.
vgs
,
&
clientVg
);
set
=
true
;
set
=
true
;
}
}
taosArrayPush
(
tmq
->
client
Topics
,
&
topic
);
taosArrayPush
(
new
Topics
,
&
topic
);
}
}
if
(
tmq
->
clientTopics
)
taosArrayDestroy
(
tmq
->
clientTopics
);
tmq
->
clientTopics
=
newTopics
;
atomic_store_32
(
&
tmq
->
epoch
,
epoch
);
atomic_store_32
(
&
tmq
->
epoch
,
epoch
);
return
set
;
return
set
;
}
}
...
@@ -1149,6 +1221,7 @@ tmq_message_t* tmqHandleAllRsp(tmq_t* tmq, int64_t blockingTime, bool pollIfRese
...
@@ -1149,6 +1221,7 @@ tmq_message_t* tmqHandleAllRsp(tmq_t* tmq, int64_t blockingTime, bool pollIfRese
if
(
rspMsg
->
msg
.
head
.
epoch
==
atomic_load_32
(
&
tmq
->
epoch
))
{
if
(
rspMsg
->
msg
.
head
.
epoch
==
atomic_load_32
(
&
tmq
->
epoch
))
{
/*printf("epoch match\n");*/
/*printf("epoch match\n");*/
SMqClientVg
*
pVg
=
rspMsg
->
vg
;
SMqClientVg
*
pVg
=
rspMsg
->
vg
;
/*printf("vg %d offset %ld up to %ld\n", pVg->vgId, pVg->currentOffset, rspMsg->msg.rspOffset);*/
pVg
->
currentOffset
=
rspMsg
->
msg
.
rspOffset
;
pVg
->
currentOffset
=
rspMsg
->
msg
.
rspOffset
;
atomic_store_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
);
atomic_store_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
);
return
rspMsg
;
return
rspMsg
;
...
...
source/common/src/tdataformat.c
浏览文件 @
a82fc113
...
@@ -106,12 +106,12 @@ void *tdDecodeSchema(void *buf, STSchema **pRSchema) {
...
@@ -106,12 +106,12 @@ void *tdDecodeSchema(void *buf, STSchema **pRSchema) {
if
(
tdInitTSchemaBuilder
(
&
schemaBuilder
,
version
)
<
0
)
return
NULL
;
if
(
tdInitTSchemaBuilder
(
&
schemaBuilder
,
version
)
<
0
)
return
NULL
;
for
(
int
i
=
0
;
i
<
numOfCols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
numOfCols
;
i
++
)
{
int8
_t
type
=
0
;
col_type
_t
type
=
0
;
int16_t
colId
=
0
;
col_id_t
colId
=
0
;
int16
_t
bytes
=
0
;
col_bytes
_t
bytes
=
0
;
buf
=
taosDecodeFixedI8
(
buf
,
&
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
type
);
buf
=
taosDecodeFixedI16
(
buf
,
&
colId
);
buf
=
taosDecodeFixedI16
(
buf
,
&
colId
);
buf
=
taosDecodeFixedI
16
(
buf
,
&
bytes
);
buf
=
taosDecodeFixedI
32
(
buf
,
&
bytes
);
if
(
tdAddColToSchema
(
&
schemaBuilder
,
type
,
colId
,
bytes
)
<
0
)
{
if
(
tdAddColToSchema
(
&
schemaBuilder
,
type
,
colId
,
bytes
)
<
0
)
{
tdDestroyTSchemaBuilder
(
&
schemaBuilder
);
tdDestroyTSchemaBuilder
(
&
schemaBuilder
);
return
NULL
;
return
NULL
;
...
@@ -148,7 +148,7 @@ void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) {
...
@@ -148,7 +148,7 @@ void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, int32_t version) {
pBuilder
->
version
=
version
;
pBuilder
->
version
=
version
;
}
}
int
tdAddColToSchema
(
STSchemaBuilder
*
pBuilder
,
int8_t
type
,
int16_t
colId
,
int16
_t
bytes
)
{
int
tdAddColToSchema
(
STSchemaBuilder
*
pBuilder
,
int8_t
type
,
col_id_t
colId
,
col_bytes
_t
bytes
)
{
if
(
!
isValidDataType
(
type
))
return
-
1
;
if
(
!
isValidDataType
(
type
))
return
-
1
;
if
(
pBuilder
->
nCols
>=
pBuilder
->
tCols
)
{
if
(
pBuilder
->
nCols
>=
pBuilder
->
tCols
)
{
...
...
source/common/src/tglobal.c
浏览文件 @
a82fc113
...
@@ -303,7 +303,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
...
@@ -303,7 +303,7 @@ static int32_t taosAddClientCfg(SConfig *pCfg) {
static
int32_t
taosAddSystemCfg
(
SConfig
*
pCfg
)
{
static
int32_t
taosAddSystemCfg
(
SConfig
*
pCfg
)
{
SysNameInfo
info
=
taosGetSysNameInfo
();
SysNameInfo
info
=
taosGetSysNameInfo
();
if
(
cfgAddTimezone
(
pCfg
,
"timezone"
,
tsTimezone
)
!=
0
)
return
-
1
;
if
(
cfgAddTimezone
(
pCfg
,
"timezone"
,
tsTimezone
Str
)
!=
0
)
return
-
1
;
if
(
cfgAddLocale
(
pCfg
,
"locale"
,
tsLocale
)
!=
0
)
return
-
1
;
if
(
cfgAddLocale
(
pCfg
,
"locale"
,
tsLocale
)
!=
0
)
return
-
1
;
if
(
cfgAddCharset
(
pCfg
,
"charset"
,
tsCharset
)
!=
0
)
return
-
1
;
if
(
cfgAddCharset
(
pCfg
,
"charset"
,
tsCharset
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"enableCoreFile"
,
1
,
1
)
!=
0
)
return
-
1
;
if
(
cfgAddBool
(
pCfg
,
"enableCoreFile"
,
1
,
1
)
!=
0
)
return
-
1
;
...
@@ -431,12 +431,13 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
...
@@ -431,12 +431,13 @@ static int32_t taosSetClientCfg(SConfig *pCfg) {
static
void
taosSetSystemCfg
(
SConfig
*
pCfg
)
{
static
void
taosSetSystemCfg
(
SConfig
*
pCfg
)
{
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
"timezone"
);
SConfigItem
*
pItem
=
cfgGetItem
(
pCfg
,
"timezone"
);
osSetTimezone
(
pItem
->
str
);
osSetTimezone
(
pItem
->
str
);
uDebug
(
"timezone format changed from %s to %s"
,
pItem
->
str
,
tsTimezone
);
uDebug
(
"timezone format changed from %s to %s"
,
pItem
->
str
,
tsTimezone
Str
);
cfgSetItem
(
pCfg
,
"timezone"
,
tsTimezone
,
pItem
->
stype
);
cfgSetItem
(
pCfg
,
"timezone"
,
tsTimezone
Str
,
pItem
->
stype
);
const
char
*
locale
=
cfgGetItem
(
pCfg
,
"locale"
)
->
str
;
const
char
*
locale
=
cfgGetItem
(
pCfg
,
"locale"
)
->
str
;
const
char
*
charset
=
cfgGetItem
(
pCfg
,
"charset"
)
->
str
;
const
char
*
charset
=
cfgGetItem
(
pCfg
,
"charset"
)
->
str
;
taosSetSystemLocale
(
locale
,
charset
);
taosSetSystemLocale
(
locale
,
charset
);
osSetSystemLocale
(
locale
,
charset
);
bool
enableCore
=
cfgGetItem
(
pCfg
,
"enableCoreFile"
)
->
bval
;
bool
enableCore
=
cfgGetItem
(
pCfg
,
"enableCoreFile"
)
->
bval
;
taosSetConsoleEcho
(
enableCore
);
taosSetConsoleEcho
(
enableCore
);
...
@@ -483,7 +484,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
...
@@ -483,7 +484,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
*
envFile
,
int32_t
taosCreateLog
(
const
char
*
logname
,
int32_t
logFileNum
,
const
char
*
cfgDir
,
const
char
*
envFile
,
const
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
const
char
*
apolloUrl
,
SArray
*
pArgs
,
bool
tsc
)
{
osInit
();
os
Default
Init
();
SConfig
*
pCfg
=
cfgInit
();
SConfig
*
pCfg
=
cfgInit
();
if
(
pCfg
==
NULL
)
return
-
1
;
if
(
pCfg
==
NULL
)
return
-
1
;
...
...
source/common/src/tmsg.c
浏览文件 @
a82fc113
...
@@ -299,14 +299,14 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -299,14 +299,14 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
stbCfg
.
nCols
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
stbCfg
.
nCols
);
for
(
uint32_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nCols
;
i
++
)
{
for
(
uint32_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nCols
;
i
++
)
{
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
type
);
tlen
+=
taosEncodeFixedI
32
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
colId
);
tlen
+=
taosEncodeFixedI
16
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
colId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
bytes
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
bytes
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
name
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
name
);
}
}
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
stbCfg
.
nTagCols
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
stbCfg
.
nTagCols
);
for
(
uint32_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nTagCols
;
i
++
)
{
for
(
uint32_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nTagCols
;
i
++
)
{
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
type
);
tlen
+=
taosEncodeFixedI
32
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
colId
);
tlen
+=
taosEncodeFixedI
16
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
colId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
bytes
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
bytes
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
name
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
name
);
}
}
...
@@ -333,7 +333,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
...
@@ -333,7 +333,7 @@ int32_t tSerializeSVCreateTbReq(void **buf, SVCreateTbReq *pReq) {
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
ntbCfg
.
nCols
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pReq
->
ntbCfg
.
nCols
);
for
(
uint32_t
i
=
0
;
i
<
pReq
->
ntbCfg
.
nCols
;
i
++
)
{
for
(
uint32_t
i
=
0
;
i
<
pReq
->
ntbCfg
.
nCols
;
i
++
)
{
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
type
);
tlen
+=
taosEncodeFixedI
32
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
colId
);
tlen
+=
taosEncodeFixedI
16
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
colId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
bytes
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
bytes
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
name
);
tlen
+=
taosEncodeString
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
name
);
}
}
...
@@ -374,7 +374,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -374,7 +374,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
pReq
->
stbCfg
.
pSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
pReq
->
stbCfg
.
nCols
*
sizeof
(
SSchema
));
pReq
->
stbCfg
.
pSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
pReq
->
stbCfg
.
nCols
*
sizeof
(
SSchema
));
for
(
uint32_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nCols
;
i
++
)
{
for
(
uint32_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nCols
;
i
++
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
type
));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
type
));
buf
=
taosDecodeFixedI
32
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
colId
));
buf
=
taosDecodeFixedI
16
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
colId
));
buf
=
taosDecodeFixedI32
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
bytes
));
buf
=
taosDecodeFixedI32
(
buf
,
&
(
pReq
->
stbCfg
.
pSchema
[
i
].
bytes
));
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
name
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
stbCfg
.
pSchema
[
i
].
name
);
}
}
...
@@ -382,7 +382,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -382,7 +382,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
pReq
->
stbCfg
.
pTagSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
pReq
->
stbCfg
.
nTagCols
*
sizeof
(
SSchema
));
pReq
->
stbCfg
.
pTagSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
pReq
->
stbCfg
.
nTagCols
*
sizeof
(
SSchema
));
for
(
uint32_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nTagCols
;
i
++
)
{
for
(
uint32_t
i
=
0
;
i
<
pReq
->
stbCfg
.
nTagCols
;
i
++
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pTagSchema
[
i
].
type
));
buf
=
taosDecodeFixedI8
(
buf
,
&
(
pReq
->
stbCfg
.
pTagSchema
[
i
].
type
));
buf
=
taosDecodeFixedI
32
(
buf
,
&
pReq
->
stbCfg
.
pTagSchema
[
i
].
colId
);
buf
=
taosDecodeFixedI
16
(
buf
,
&
pReq
->
stbCfg
.
pTagSchema
[
i
].
colId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
stbCfg
.
pTagSchema
[
i
].
bytes
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
stbCfg
.
pTagSchema
[
i
].
bytes
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
name
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
stbCfg
.
pTagSchema
[
i
].
name
);
}
}
...
@@ -422,7 +422,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
...
@@ -422,7 +422,7 @@ void *tDeserializeSVCreateTbReq(void *buf, SVCreateTbReq *pReq) {
pReq
->
ntbCfg
.
pSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
pReq
->
ntbCfg
.
nCols
*
sizeof
(
SSchema
));
pReq
->
ntbCfg
.
pSchema
=
(
SSchema
*
)
taosMemoryMalloc
(
pReq
->
ntbCfg
.
nCols
*
sizeof
(
SSchema
));
for
(
uint32_t
i
=
0
;
i
<
pReq
->
ntbCfg
.
nCols
;
i
++
)
{
for
(
uint32_t
i
=
0
;
i
<
pReq
->
ntbCfg
.
nCols
;
i
++
)
{
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
ntbCfg
.
pSchema
[
i
].
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pReq
->
ntbCfg
.
pSchema
[
i
].
type
);
buf
=
taosDecodeFixedI
32
(
buf
,
&
pReq
->
ntbCfg
.
pSchema
[
i
].
colId
);
buf
=
taosDecodeFixedI
16
(
buf
,
&
pReq
->
ntbCfg
.
pSchema
[
i
].
colId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
ntbCfg
.
pSchema
[
i
].
bytes
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pReq
->
ntbCfg
.
pSchema
[
i
].
bytes
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
name
);
buf
=
taosDecodeStringTo
(
buf
,
pReq
->
ntbCfg
.
pSchema
[
i
].
name
);
}
}
...
...
source/dnode/mgmt/container/inc/dndInt.h
浏览文件 @
a82fc113
...
@@ -56,7 +56,6 @@ void dndCleanupServer(SDnode *pDnode);
...
@@ -56,7 +56,6 @@ void dndCleanupServer(SDnode *pDnode);
int32_t
dndInitClient
(
SDnode
*
pDnode
);
int32_t
dndInitClient
(
SDnode
*
pDnode
);
void
dndCleanupClient
(
SDnode
*
pDnode
);
void
dndCleanupClient
(
SDnode
*
pDnode
);
int32_t
dndInitMsgHandle
(
SDnode
*
pDnode
);
int32_t
dndInitMsgHandle
(
SDnode
*
pDnode
);
void
dndSendRpcRsp
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRsp
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/dnode/mgmt/container/src/dndExec.c
浏览文件 @
a82fc113
...
@@ -20,7 +20,7 @@ static void dndResetLog(SMgmtWrapper *pMgmt) {
...
@@ -20,7 +20,7 @@ static void dndResetLog(SMgmtWrapper *pMgmt) {
char
logname
[
24
]
=
{
0
};
char
logname
[
24
]
=
{
0
};
snprintf
(
logname
,
sizeof
(
logname
),
"%slog"
,
pMgmt
->
name
);
snprintf
(
logname
,
sizeof
(
logname
),
"%slog"
,
pMgmt
->
name
);
dInfo
(
"node:%s, reset log to %s"
,
pMgmt
->
name
,
logname
);
dInfo
(
"node:%s, reset log to %s
in child process
"
,
pMgmt
->
name
,
logname
);
taosCloseLog
();
taosCloseLog
();
taosInitLog
(
logname
,
1
);
taosInitLog
(
logname
,
1
);
}
}
...
@@ -51,6 +51,7 @@ int32_t dndOpenNode(SMgmtWrapper *pWrapper) {
...
@@ -51,6 +51,7 @@ int32_t dndOpenNode(SMgmtWrapper *pWrapper) {
void
dndCloseNode
(
SMgmtWrapper
*
pWrapper
)
{
void
dndCloseNode
(
SMgmtWrapper
*
pWrapper
)
{
dDebug
(
"node:%s, start to close"
,
pWrapper
->
name
);
dDebug
(
"node:%s, start to close"
,
pWrapper
->
name
);
pWrapper
->
required
=
false
;
taosWLockLatch
(
&
pWrapper
->
latch
);
taosWLockLatch
(
&
pWrapper
->
latch
);
if
(
pWrapper
->
deployed
)
{
if
(
pWrapper
->
deployed
)
{
(
*
pWrapper
->
fp
.
closeFp
)(
pWrapper
);
(
*
pWrapper
->
fp
.
closeFp
)(
pWrapper
);
...
@@ -138,7 +139,7 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int32_t
...
@@ -138,7 +139,7 @@ static void dndConsumeChildQueue(SMgmtWrapper *pWrapper, SNodeMsg *pMsg, int32_t
static
void
dndConsumeParentQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRsp
,
int32_t
msgLen
,
void
*
pCont
,
int32_t
contLen
)
{
static
void
dndConsumeParentQueue
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRsp
,
int32_t
msgLen
,
void
*
pCont
,
int32_t
contLen
)
{
dTrace
(
"msg:%p, get from parent queue"
,
pRsp
);
dTrace
(
"msg:%p, get from parent queue"
,
pRsp
);
pRsp
->
pCont
=
pCont
;
pRsp
->
pCont
=
pCont
;
dndSendR
pcR
sp
(
pWrapper
,
pRsp
);
dndSendRsp
(
pWrapper
,
pRsp
);
taosMemoryFree
(
pRsp
);
taosMemoryFree
(
pRsp
);
}
}
...
@@ -178,7 +179,6 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) {
...
@@ -178,7 +179,6 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) {
.
parentFreeHeadFp
=
(
ProcFreeFp
)
taosMemoryFree
,
.
parentFreeHeadFp
=
(
ProcFreeFp
)
taosMemoryFree
,
.
parentMallocBodyFp
=
(
ProcMallocFp
)
rpcMallocCont
,
.
parentMallocBodyFp
=
(
ProcMallocFp
)
rpcMallocCont
,
.
parentFreeBodyFp
=
(
ProcFreeFp
)
rpcFreeCont
,
.
parentFreeBodyFp
=
(
ProcFreeFp
)
rpcFreeCont
,
.
testFlag
=
0
,
.
pParent
=
pWrapper
,
.
pParent
=
pWrapper
,
.
name
=
pWrapper
->
name
};
.
name
=
pWrapper
->
name
};
SProcObj
*
pProc
=
taosProcInit
(
&
cfg
);
SProcObj
*
pProc
=
taosProcInit
(
&
cfg
);
...
@@ -200,7 +200,7 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) {
...
@@ -200,7 +200,7 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) {
dInfo
(
"node:%s, will be initialized in child process"
,
pWrapper
->
name
);
dInfo
(
"node:%s, will be initialized in child process"
,
pWrapper
->
name
);
dndOpenNode
(
pWrapper
);
dndOpenNode
(
pWrapper
);
}
else
{
}
else
{
dInfo
(
"node:%s, will not start in parent process
"
,
pWrapper
->
name
);
dInfo
(
"node:%s, will not start in parent process
, child pid:%d"
,
pWrapper
->
name
,
taosProcChildId
(
pProc
)
);
pWrapper
->
procType
=
PROC_PARENT
;
pWrapper
->
procType
=
PROC_PARENT
;
}
}
...
@@ -210,16 +210,20 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) {
...
@@ -210,16 +210,20 @@ static int32_t dndRunInMultiProcess(SDnode *pDnode) {
}
}
}
}
#if 0
dndSetStatus
(
pDnode
,
DND_STAT_RUNNING
);
SMgmtWrapper *pWrapper = dndAcquireWrapper(pDnode, DNODE);
if (pWrapper->procType == PROC_PARENT && dmStart(pWrapper->pMgmt) != 0) {
for
(
ENodeType
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
dndReleaseWrapper(pWrapper);
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
dError("failed to start dnode worker since %s", terrstr());
if
(
!
pWrapper
->
required
)
continue
;
return -1;
if
(
pWrapper
->
fp
.
startFp
==
NULL
)
continue
;
if
(
pWrapper
->
procType
==
PROC_PARENT
&&
n
!=
DNODE
)
continue
;
if
(
pWrapper
->
procType
==
PROC_CHILD
&&
n
==
DNODE
)
continue
;
if
((
*
pWrapper
->
fp
.
startFp
)(
pWrapper
)
!=
0
)
{
dError
(
"node:%s, failed to start since %s"
,
pWrapper
->
name
,
terrstr
());
return
-
1
;
}
}
}
dndReleaseWrapper(pWrapper);
#endif
return
0
;
return
0
;
}
}
...
...
source/dnode/mgmt/container/src/dndFile.c
浏览文件 @
a82fc113
...
@@ -16,14 +16,16 @@
...
@@ -16,14 +16,16 @@
#define _DEFAULT_SOURCE
#define _DEFAULT_SOURCE
#include "dndInt.h"
#include "dndInt.h"
#define MAXLEN 1024
int32_t
dndReadFile
(
SMgmtWrapper
*
pWrapper
,
bool
*
pDeployed
)
{
int32_t
dndReadFile
(
SMgmtWrapper
*
pWrapper
,
bool
*
pDeployed
)
{
int32_t
code
=
TSDB_CODE_NODE_PARSE_FILE_ERROR
;
int32_t
code
=
TSDB_CODE_NODE_PARSE_FILE_ERROR
;
int32_t
len
=
0
;
int32_t
len
=
0
;
int32_t
maxLen
=
1024
;
const
int32_t
maxLen
=
MAXLEN
;
char
*
content
=
taosMemoryCalloc
(
1
,
maxLen
+
1
)
;
char
content
[
MAXLEN
+
1
]
=
{
0
}
;
cJSON
*
root
=
NULL
;
cJSON
*
root
=
NULL
;
char
file
[
PATH_MAX
];
char
file
[
PATH_MAX
];
TdFilePtr
pFile
=
NULL
;
TdFilePtr
pFile
=
NULL
;
snprintf
(
file
,
sizeof
(
file
),
"%s%s%s.json"
,
pWrapper
->
path
,
TD_DIRSEP
,
pWrapper
->
name
);
snprintf
(
file
,
sizeof
(
file
),
"%s%s%s.json"
,
pWrapper
->
path
,
TD_DIRSEP
,
pWrapper
->
name
);
pFile
=
taosOpenFile
(
file
,
TD_FILE_READ
);
pFile
=
taosOpenFile
(
file
,
TD_FILE_READ
);
...
@@ -57,7 +59,6 @@ int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) {
...
@@ -57,7 +59,6 @@ int32_t dndReadFile(SMgmtWrapper *pWrapper, bool *pDeployed) {
dDebug
(
"succcessed to read file %s, deployed:%d"
,
file
,
*
pDeployed
);
dDebug
(
"succcessed to read file %s, deployed:%d"
,
file
,
*
pDeployed
);
_OVER:
_OVER:
if
(
content
!=
NULL
)
taosMemoryFree
(
content
);
if
(
root
!=
NULL
)
cJSON_Delete
(
root
);
if
(
root
!=
NULL
)
cJSON_Delete
(
root
);
if
(
pFile
!=
NULL
)
taosCloseFile
(
&
pFile
);
if
(
pFile
!=
NULL
)
taosCloseFile
(
&
pFile
);
...
@@ -66,7 +67,7 @@ _OVER:
...
@@ -66,7 +67,7 @@ _OVER:
}
}
int32_t
dndWriteFile
(
SMgmtWrapper
*
pWrapper
,
bool
deployed
)
{
int32_t
dndWriteFile
(
SMgmtWrapper
*
pWrapper
,
bool
deployed
)
{
char
file
[
PATH_MAX
];
char
file
[
PATH_MAX
]
=
{
0
}
;
snprintf
(
file
,
sizeof
(
file
),
"%s%s%s.json"
,
pWrapper
->
path
,
TD_DIRSEP
,
pWrapper
->
name
);
snprintf
(
file
,
sizeof
(
file
),
"%s%s%s.json"
,
pWrapper
->
path
,
TD_DIRSEP
,
pWrapper
->
name
);
TdFilePtr
pFile
=
taosOpenFile
(
file
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
TdFilePtr
pFile
=
taosOpenFile
(
file
,
TD_FILE_CTEATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
);
...
@@ -76,9 +77,9 @@ int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) {
...
@@ -76,9 +77,9 @@ int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) {
return
-
1
;
return
-
1
;
}
}
int32_t
len
=
0
;
int32_t
len
=
0
;
int32_t
maxLen
=
1024
;
const
int32_t
maxLen
=
MAXLEN
;
char
*
content
=
taosMemoryCalloc
(
1
,
maxLen
+
1
)
;
char
content
[
MAXLEN
+
1
]
=
{
0
}
;
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"{
\n
"
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
deployed
\"
: %d
\n
"
,
deployed
);
len
+=
snprintf
(
content
+
len
,
maxLen
-
len
,
"
\"
deployed
\"
: %d
\n
"
,
deployed
);
...
@@ -87,9 +88,8 @@ int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) {
...
@@ -87,9 +88,8 @@ int32_t dndWriteFile(SMgmtWrapper *pWrapper, bool deployed) {
taosWriteFile
(
pFile
,
content
,
len
);
taosWriteFile
(
pFile
,
content
,
len
);
taosFsyncFile
(
pFile
);
taosFsyncFile
(
pFile
);
taosCloseFile
(
&
pFile
);
taosCloseFile
(
&
pFile
);
taosMemoryFree
(
content
);
char
realfile
[
PATH_MAX
];
char
realfile
[
PATH_MAX
]
=
{
0
}
;
snprintf
(
realfile
,
sizeof
(
realfile
),
"%s%s%s.json"
,
pWrapper
->
path
,
TD_DIRSEP
,
pWrapper
->
name
);
snprintf
(
realfile
,
sizeof
(
realfile
),
"%s%s%s.json"
,
pWrapper
->
path
,
TD_DIRSEP
,
pWrapper
->
name
);
if
(
taosRenameFile
(
file
,
realfile
)
!=
0
)
{
if
(
taosRenameFile
(
file
,
realfile
)
!=
0
)
{
...
...
source/dnode/mgmt/container/src/dndMsg.c
浏览文件 @
a82fc113
...
@@ -43,36 +43,40 @@ static inline int32_t dndBuildMsg(SNodeMsg *pMsg, SRpcMsg *pRpc) {
...
@@ -43,36 +43,40 @@ static inline int32_t dndBuildMsg(SNodeMsg *pMsg, SRpcMsg *pRpc) {
memcpy
(
pMsg
->
user
,
connInfo
.
user
,
TSDB_USER_LEN
);
memcpy
(
pMsg
->
user
,
connInfo
.
user
,
TSDB_USER_LEN
);
memcpy
(
&
pMsg
->
rpcMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
memcpy
(
&
pMsg
->
rpcMsg
,
pRpc
,
sizeof
(
SRpcMsg
));
return
0
;
return
0
;
}
}
void
dndProcessRpcMsg
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
,
SEpSet
*
pEpSet
)
{
void
dndProcessRpcMsg
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRpc
,
SEpSet
*
pEpSet
)
{
if
(
pEpSet
&&
pEpSet
->
numOfEps
>
0
&&
pRpc
->
msgType
==
TDMT_MND_STATUS_RSP
)
{
dndUpdateMnodeEpSet
(
pWrapper
->
pDnode
,
pEpSet
);
}
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
SNodeMsg
*
pMsg
=
NULL
;
SNodeMsg
*
pMsg
=
NULL
;
NodeMsgFp
msgFp
=
NULL
;
NodeMsgFp
msgFp
=
NULL
;
if
(
pEpSet
&&
pEpSet
->
numOfEps
>
0
&&
pRpc
->
msgType
==
TDMT_MND_STATUS_RSP
)
{
dndUpdateMnodeEpSet
(
pWrapper
->
pDnode
,
pEpSet
);
}
if
(
dndMarkWrapper
(
pWrapper
)
!=
0
)
goto
_OVER
;
if
(
dndMarkWrapper
(
pWrapper
)
!=
0
)
goto
_OVER
;
if
((
msgFp
=
dndGetMsgFp
(
pWrapper
,
pRpc
))
==
NULL
)
goto
_OVER
;
if
((
msgFp
=
dndGetMsgFp
(
pWrapper
,
pRpc
))
==
NULL
)
goto
_OVER
;
if
((
pMsg
=
taosAllocateQitem
(
sizeof
(
SNodeMsg
)))
==
NULL
)
goto
_OVER
;
if
((
pMsg
=
taosAllocateQitem
(
sizeof
(
SNodeMsg
)))
==
NULL
)
goto
_OVER
;
if
(
dndBuildMsg
(
pMsg
,
pRpc
)
!=
0
)
goto
_OVER
;
if
(
dndBuildMsg
(
pMsg
,
pRpc
)
!=
0
)
goto
_OVER
;
dTrace
(
"msg:%p, is created, handle:%p app:%p user:%s"
,
pMsg
,
pRpc
->
handle
,
pRpc
->
ahandle
,
pMsg
->
user
);
if
(
pWrapper
->
procType
==
PROC_SINGLE
)
{
if
(
pWrapper
->
procType
==
PROC_SINGLE
)
{
dTrace
(
"msg:%p, is created, handle:%p app:%p user:%s"
,
pMsg
,
pRpc
->
handle
,
pRpc
->
ahandle
,
pMsg
->
user
);
code
=
(
*
msgFp
)(
pWrapper
->
pMgmt
,
pMsg
);
code
=
(
*
msgFp
)(
pWrapper
->
pMgmt
,
pMsg
);
}
else
if
(
pWrapper
->
procType
==
PROC_PARENT
)
{
}
else
if
(
pWrapper
->
procType
==
PROC_PARENT
)
{
dTrace
(
"msg:%p, is created and will put into child queue, handle:%p app:%p user:%s"
,
pMsg
,
pRpc
->
handle
,
pRpc
->
ahandle
,
pMsg
->
user
);
code
=
taosProcPutToChildQueue
(
pWrapper
->
pProc
,
pMsg
,
sizeof
(
SNodeMsg
),
pRpc
->
pCont
,
pRpc
->
contLen
);
code
=
taosProcPutToChildQueue
(
pWrapper
->
pProc
,
pMsg
,
sizeof
(
SNodeMsg
),
pRpc
->
pCont
,
pRpc
->
contLen
);
}
else
{
}
else
{
dTrace
(
"msg:%p, should not processed in child process, handle:%p app:%p user:%s"
,
pMsg
,
pRpc
->
handle
,
pRpc
->
ahandle
,
pMsg
->
user
);
ASSERT
(
1
);
}
}
_OVER:
_OVER:
if
(
code
==
0
)
{
if
(
code
==
0
)
{
if
(
pWrapper
->
procType
==
PROC_PARENT
)
{
if
(
pWrapper
->
procType
==
PROC_PARENT
)
{
dTrace
(
"msg:%p, is freed"
,
pMsg
);
dTrace
(
"msg:%p, is freed
in parent process
"
,
pMsg
);
taosFreeQitem
(
pMsg
);
taosFreeQitem
(
pMsg
);
rpcFreeCont
(
pRpc
->
pCont
);
rpcFreeCont
(
pRpc
->
pCont
);
}
}
...
...
source/dnode/mgmt/container/src/dndObj.c
浏览文件 @
a82fc113
...
@@ -175,7 +175,7 @@ int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) {
...
@@ -175,7 +175,7 @@ int32_t dndMarkWrapper(SMgmtWrapper *pWrapper) {
int32_t
code
=
0
;
int32_t
code
=
0
;
taosRLockLatch
(
&
pWrapper
->
latch
);
taosRLockLatch
(
&
pWrapper
->
latch
);
if
(
pWrapper
->
deployed
)
{
if
(
pWrapper
->
deployed
||
(
pWrapper
->
procType
==
PROC_PARENT
&&
pWrapper
->
required
)
)
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is marked, refCount:%d"
,
pWrapper
->
name
,
refCount
);
dTrace
(
"node:%s, is marked, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
else
{
}
else
{
...
...
source/dnode/mgmt/container/src/dndTransport.c
浏览文件 @
a82fc113
...
@@ -348,7 +348,7 @@ int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
...
@@ -348,7 +348,7 @@ int32_t dndSendReqToMnode(SMgmtWrapper *pWrapper, SRpcMsg *pReq) {
}
}
}
}
void
dndSendRpcRsp
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRsp
)
{
static
void
dndSendRpcRsp
(
SMgmtWrapper
*
pWrapper
,
SRpcMsg
*
pRsp
)
{
if
(
pRsp
->
code
==
TSDB_CODE_APP_NOT_READY
)
{
if
(
pRsp
->
code
==
TSDB_CODE_APP_NOT_READY
)
{
SMgmtWrapper
*
pDnodeWrapper
=
dndAcquireWrapper
(
pWrapper
->
pDnode
,
DNODE
);
SMgmtWrapper
*
pDnodeWrapper
=
dndAcquireWrapper
(
pWrapper
->
pDnode
,
DNODE
);
if
(
pDnodeWrapper
!=
NULL
)
{
if
(
pDnodeWrapper
!=
NULL
)
{
...
...
source/dnode/mgmt/dnode/src/dmMsg.c
浏览文件 @
a82fc113
...
@@ -36,7 +36,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
...
@@ -36,7 +36,7 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
req
.
clusterCfg
.
checkTime
=
0
;
req
.
clusterCfg
.
checkTime
=
0
;
char
timestr
[
32
]
=
"1970-01-01 00:00:00.00"
;
char
timestr
[
32
]
=
"1970-01-01 00:00:00.00"
;
(
void
)
taosParseTime
(
timestr
,
&
req
.
clusterCfg
.
checkTime
,
(
int32_t
)
strlen
(
timestr
),
TSDB_TIME_PRECISION_MILLI
,
0
);
(
void
)
taosParseTime
(
timestr
,
&
req
.
clusterCfg
.
checkTime
,
(
int32_t
)
strlen
(
timestr
),
TSDB_TIME_PRECISION_MILLI
,
0
);
memcpy
(
req
.
clusterCfg
.
timezone
,
tsTimezone
,
TD_TIMEZONE_LEN
);
memcpy
(
req
.
clusterCfg
.
timezone
,
tsTimezone
Str
,
TD_TIMEZONE_LEN
);
memcpy
(
req
.
clusterCfg
.
locale
,
tsLocale
,
TD_LOCALE_LEN
);
memcpy
(
req
.
clusterCfg
.
locale
,
tsLocale
,
TD_LOCALE_LEN
);
memcpy
(
req
.
clusterCfg
.
charset
,
tsCharset
,
TD_LOCALE_LEN
);
memcpy
(
req
.
clusterCfg
.
charset
,
tsCharset
,
TD_LOCALE_LEN
);
taosRUnLockLatch
(
&
pMgmt
->
latch
);
taosRUnLockLatch
(
&
pMgmt
->
latch
);
...
...
source/dnode/mgmt/vnode/src/vmWorker.c
浏览文件 @
a82fc113
...
@@ -160,6 +160,24 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
...
@@ -160,6 +160,24 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
}
}
}
}
static
void
vmProcessMergeQueue
(
SQueueInfo
*
pInfo
,
STaosQall
*
qall
,
int32_t
numOfMsgs
)
{
SVnodeObj
*
pVnode
=
pInfo
->
ahandle
;
SNodeMsg
*
pMsg
=
NULL
;
for
(
int32_t
i
=
0
;
i
<
numOfMsgs
;
++
i
)
{
taosGetQitem
(
qall
,
(
void
**
)
&
pMsg
);
dTrace
(
"msg:%p, will be processed in vnode-merge queue"
,
pMsg
);
int32_t
code
=
vnodeProcessFetchMsg
(
pVnode
->
pImpl
,
&
pMsg
->
rpcMsg
);
if
(
code
!=
0
)
{
vmSendRsp
(
pVnode
->
pWrapper
,
pMsg
,
code
);
dTrace
(
"msg:%p, is freed, result:0x%04x:%s"
,
pMsg
,
code
&
0XFFFF
,
tstrerror
(
code
));
rpcFreeCont
(
pMsg
->
rpcMsg
.
pCont
);
taosFreeQitem
(
pMsg
);
}
}
}
static
int32_t
vmPutNodeMsgToQueue
(
SVnodesMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
,
EQueueType
qtype
)
{
static
int32_t
vmPutNodeMsgToQueue
(
SVnodesMgmt
*
pMgmt
,
SNodeMsg
*
pMsg
,
EQueueType
qtype
)
{
SRpcMsg
*
pRpc
=
&
pMsg
->
rpcMsg
;
SRpcMsg
*
pRpc
=
&
pMsg
->
rpcMsg
;
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
...
@@ -308,7 +326,7 @@ int32_t vmGetQueueSize(SMgmtWrapper *pWrapper, int32_t vgId, EQueueType qtype) {
...
@@ -308,7 +326,7 @@ int32_t vmGetQueueSize(SMgmtWrapper *pWrapper, int32_t vgId, EQueueType qtype) {
int32_t
vmAllocQueue
(
SVnodesMgmt
*
pMgmt
,
SVnodeObj
*
pVnode
)
{
int32_t
vmAllocQueue
(
SVnodesMgmt
*
pMgmt
,
SVnodeObj
*
pVnode
)
{
pVnode
->
pWriteQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
writePool
,
pVnode
,
(
FItems
)
vmProcessWriteQueue
);
pVnode
->
pWriteQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
writePool
,
pVnode
,
(
FItems
)
vmProcessWriteQueue
);
pVnode
->
pApplyQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
writePool
,
pVnode
,
(
FItems
)
vmProcessApplyQueue
);
pVnode
->
pApplyQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
writePool
,
pVnode
,
(
FItems
)
vmProcessApplyQueue
);
pVnode
->
pMergeQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
mergePool
,
pVnode
,
(
FItems
)
vmProcessMerge
Msg
);
pVnode
->
pMergeQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
mergePool
,
pVnode
,
(
FItems
)
vmProcessMerge
Queue
);
pVnode
->
pSyncQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
syncPool
,
pVnode
,
(
FItems
)
vmProcessSyncQueue
);
pVnode
->
pSyncQ
=
tWWorkerAllocQueue
(
&
pMgmt
->
syncPool
,
pVnode
,
(
FItems
)
vmProcessSyncQueue
);
pVnode
->
pFetchQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
fetchPool
,
pVnode
,
(
FItem
)
vmProcessFetchQueue
);
pVnode
->
pFetchQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
fetchPool
,
pVnode
,
(
FItem
)
vmProcessFetchQueue
);
pVnode
->
pQueryQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
queryPool
,
pVnode
,
(
FItem
)
vmProcessQueryQueue
);
pVnode
->
pQueryQ
=
tQWorkerAllocQueue
(
&
pMgmt
->
queryPool
,
pVnode
,
(
FItem
)
vmProcessQueryQueue
);
...
...
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
a82fc113
...
@@ -633,18 +633,19 @@ static FORCE_INLINE void tDeleteSMqSubscribeObj(SMqSubscribeObj* pSub) {
...
@@ -633,18 +633,19 @@ static FORCE_INLINE void tDeleteSMqSubscribeObj(SMqSubscribeObj* pSub) {
}
}
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
];
int64_t
createTime
;
int64_t
createTime
;
int64_t
updateTime
;
int64_t
updateTime
;
int64_t
uid
;
int64_t
uid
;
int64_t
dbUid
;
int64_t
dbUid
;
int32_t
version
;
int32_t
version
;
SRWLatch
lock
;
SRWLatch
lock
;
int32_t
sqlLen
;
int32_t
sqlLen
;
char
*
sql
;
char
*
sql
;
char
*
logicalPlan
;
char
*
logicalPlan
;
char
*
physicalPlan
;
char
*
physicalPlan
;
SSchemaWrapper
schema
;
}
SMqTopicObj
;
}
SMqTopicObj
;
typedef
struct
{
typedef
struct
{
...
@@ -733,12 +734,12 @@ typedef struct {
...
@@ -733,12 +734,12 @@ typedef struct {
int8_t
sourceType
;
int8_t
sourceType
;
int8_t
sinkType
;
int8_t
sinkType
;
// int32_t sqlLen;
// int32_t sqlLen;
int32_t
sinkVgId
;
// 0 for automatic
int32_t
sinkVgId
;
// 0 for automatic
char
*
sql
;
char
*
sql
;
char
*
logicalPlan
;
char
*
logicalPlan
;
char
*
physicalPlan
;
char
*
physicalPlan
;
SArray
*
tasks
;
// SArray<SArray<SStreamTask>>
SArray
*
tasks
;
// SArray<SArray<SStreamTask>>
S
Array
*
ColAlias
;
// SArray<char*>
S
SchemaWrapper
outputSchema
;
}
SStreamObj
;
}
SStreamObj
;
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
);
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
);
...
...
source/dnode/mnode/impl/src/mndDef.c
浏览文件 @
a82fc113
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
)
{
int32_t
tEncodeSStreamObj
(
SCoder
*
pEncoder
,
const
SStreamObj
*
pObj
)
{
int32_t
sz
=
0
;
int32_t
sz
=
0
;
int32_t
outputNameSz
=
0
;
/*int32_t outputNameSz = 0;*/
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
name
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeCStr
(
pEncoder
,
pObj
->
db
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
createTime
)
<
0
)
return
-
1
;
if
(
tEncodeI64
(
pEncoder
,
pObj
->
createTime
)
<
0
)
return
-
1
;
...
@@ -45,6 +45,9 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
...
@@ -45,6 +45,9 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
}
}
}
}
if
(
tEncodeSSchemaWrapper
(
pEncoder
,
&
pObj
->
outputSchema
)
<
0
)
return
-
1
;
#if 0
if (pObj->ColAlias != NULL) {
if (pObj->ColAlias != NULL) {
outputNameSz = taosArrayGetSize(pObj->ColAlias);
outputNameSz = taosArrayGetSize(pObj->ColAlias);
}
}
...
@@ -53,6 +56,7 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
...
@@ -53,6 +56,7 @@ int32_t tEncodeSStreamObj(SCoder *pEncoder, const SStreamObj *pObj) {
char *name = taosArrayGetP(pObj->ColAlias, i);
char *name = taosArrayGetP(pObj->ColAlias, i);
if (tEncodeCStr(pEncoder, name) < 0) return -1;
if (tEncodeCStr(pEncoder, name) < 0) return -1;
}
}
#endif
return
pEncoder
->
pos
;
return
pEncoder
->
pos
;
}
}
...
@@ -85,6 +89,9 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
...
@@ -85,6 +89,9 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
taosArrayPush
(
pObj
->
tasks
,
pArray
);
taosArrayPush
(
pObj
->
tasks
,
pArray
);
}
}
}
}
if
(
tDecodeSSchemaWrapper
(
pDecoder
,
&
pObj
->
outputSchema
)
<
0
)
return
-
1
;
#if 0
int32_t outputNameSz;
int32_t outputNameSz;
if (tDecodeI32(pDecoder, &outputNameSz) < 0) return -1;
if (tDecodeI32(pDecoder, &outputNameSz) < 0) return -1;
if (outputNameSz != 0) {
if (outputNameSz != 0) {
...
@@ -98,5 +105,6 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
...
@@ -98,5 +105,6 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) {
if (tDecodeCStrAlloc(pDecoder, &name) < 0) return -1;
if (tDecodeCStrAlloc(pDecoder, &name) < 0) return -1;
taosArrayPush(pObj->ColAlias, &name);
taosArrayPush(pObj->ColAlias, &name);
}
}
#endif
return
0
;
return
0
;
}
}
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
a82fc113
...
@@ -277,8 +277,8 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, const SClusterCfg *pCfg) {
...
@@ -277,8 +277,8 @@ static int32_t mndCheckClusterCfgPara(SMnode *pMnode, const SClusterCfg *pCfg) {
return
DND_REASON_STATUS_INTERVAL_NOT_MATCH
;
return
DND_REASON_STATUS_INTERVAL_NOT_MATCH
;
}
}
if
((
0
!=
strcasecmp
(
pCfg
->
timezone
,
tsTimezone
))
&&
(
pMnode
->
checkTime
!=
pCfg
->
checkTime
))
{
if
((
0
!=
strcasecmp
(
pCfg
->
timezone
,
tsTimezone
Str
))
&&
(
pMnode
->
checkTime
!=
pCfg
->
checkTime
))
{
mError
(
"timezone [%s - %s] [%"
PRId64
" - %"
PRId64
"] cfg inconsistent"
,
pCfg
->
timezone
,
tsTimezone
,
mError
(
"timezone [%s - %s] [%"
PRId64
" - %"
PRId64
"] cfg inconsistent"
,
pCfg
->
timezone
,
tsTimezone
Str
,
pCfg
->
checkTime
,
pMnode
->
checkTime
);
pCfg
->
checkTime
,
pMnode
->
checkTime
);
return
DND_REASON_TIME_ZONE_NOT_MATCH
;
return
DND_REASON_TIME_ZONE_NOT_MATCH
;
}
}
...
@@ -677,7 +677,7 @@ static int32_t mndRetrieveConfigs(SNodeMsg *pReq, SShowObj *pShow, char *data, i
...
@@ -677,7 +677,7 @@ static int32_t mndRetrieveConfigs(SNodeMsg *pReq, SShowObj *pShow, char *data, i
totalRows
++
;
totalRows
++
;
cfgOpts
[
totalRows
]
=
"timezone"
;
cfgOpts
[
totalRows
]
=
"timezone"
;
snprintf
(
cfgVals
[
totalRows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
tsTimezone
);
snprintf
(
cfgVals
[
totalRows
],
TSDB_CONIIG_VALUE_LEN
,
"%s"
,
tsTimezone
Str
);
totalRows
++
;
totalRows
++
;
cfgOpts
[
totalRows
]
=
"locale"
;
cfgOpts
[
totalRows
]
=
"locale"
;
...
...
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
a82fc113
...
@@ -185,6 +185,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
...
@@ -185,6 +185,7 @@ int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) {
pTask
->
dispatchMsgType
=
TDMT_VND_TASK_MERGE_EXEC
;
pTask
->
dispatchMsgType
=
TDMT_VND_TASK_MERGE_EXEC
;
pTask
->
dispatchType
=
TASK_DISPATCH__FIXED
;
pTask
->
dispatchType
=
TASK_DISPATCH__FIXED
;
pTask
->
fixedEpDispatcher
.
taskId
=
lastLevelTask
->
taskId
;
pTask
->
fixedEpDispatcher
.
nodeId
=
lastLevelTask
->
nodeId
;
pTask
->
fixedEpDispatcher
.
nodeId
=
lastLevelTask
->
nodeId
;
pTask
->
fixedEpDispatcher
.
epSet
=
lastLevelTask
->
epSet
;
pTask
->
fixedEpDispatcher
.
epSet
=
lastLevelTask
->
epSet
;
}
}
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
a82fc113
...
@@ -98,7 +98,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
...
@@ -98,7 +98,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
pColumns
[
i
];
SSchema
*
pSchema
=
&
pStb
->
pColumns
[
i
];
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
,
STB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
,
STB_ENCODE_OVER
)
SDB_SET_INT
32
(
pRaw
,
dataPos
,
pSchema
->
colId
,
STB_ENCODE_OVER
)
SDB_SET_INT
16
(
pRaw
,
dataPos
,
pSchema
->
colId
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
bytes
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
bytes
,
STB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_ENCODE_OVER
)
}
}
...
@@ -106,7 +106,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
...
@@ -106,7 +106,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
pTags
[
i
];
SSchema
*
pSchema
=
&
pStb
->
pTags
[
i
];
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
,
STB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
,
STB_ENCODE_OVER
)
SDB_SET_INT
32
(
pRaw
,
dataPos
,
pSchema
->
colId
,
STB_ENCODE_OVER
)
SDB_SET_INT
16
(
pRaw
,
dataPos
,
pSchema
->
colId
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
bytes
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
bytes
,
STB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_ENCODE_OVER
)
}
}
...
@@ -114,7 +114,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
...
@@ -114,7 +114,7 @@ SSdbRaw *mndStbActionEncode(SStbObj *pStb) {
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfSmas
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfSmas
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
pSmas
[
i
];
SSchema
*
pSchema
=
&
pStb
->
pSmas
[
i
];
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
,
STB_ENCODE_OVER
)
SDB_SET_INT8
(
pRaw
,
dataPos
,
pSchema
->
type
,
STB_ENCODE_OVER
)
SDB_SET_INT
32
(
pRaw
,
dataPos
,
pSchema
->
colId
,
STB_ENCODE_OVER
)
SDB_SET_INT
16
(
pRaw
,
dataPos
,
pSchema
->
colId
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
bytes
,
STB_ENCODE_OVER
)
SDB_SET_INT32
(
pRaw
,
dataPos
,
pSchema
->
bytes
,
STB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_ENCODE_OVER
)
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_ENCODE_OVER
)
}
}
...
@@ -185,7 +185,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
...
@@ -185,7 +185,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfColumns
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
pColumns
[
i
];
SSchema
*
pSchema
=
&
pStb
->
pColumns
[
i
];
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pSchema
->
type
,
STB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pSchema
->
type
,
STB_DECODE_OVER
)
SDB_GET_INT
32
(
pRaw
,
dataPos
,
&
pSchema
->
colId
,
STB_DECODE_OVER
)
SDB_GET_INT
16
(
pRaw
,
dataPos
,
&
pSchema
->
colId
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pSchema
->
bytes
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pSchema
->
bytes
,
STB_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_DECODE_OVER
)
}
}
...
@@ -193,7 +193,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
...
@@ -193,7 +193,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfTags
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfTags
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
pTags
[
i
];
SSchema
*
pSchema
=
&
pStb
->
pTags
[
i
];
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pSchema
->
type
,
STB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pSchema
->
type
,
STB_DECODE_OVER
)
SDB_GET_INT
32
(
pRaw
,
dataPos
,
&
pSchema
->
colId
,
STB_DECODE_OVER
)
SDB_GET_INT
16
(
pRaw
,
dataPos
,
&
pSchema
->
colId
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pSchema
->
bytes
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pSchema
->
bytes
,
STB_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_DECODE_OVER
)
}
}
...
@@ -201,7 +201,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
...
@@ -201,7 +201,7 @@ static SSdbRow *mndStbActionDecode(SSdbRaw *pRaw) {
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfSmas
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
pStb
->
numOfSmas
;
++
i
)
{
SSchema
*
pSchema
=
&
pStb
->
pSmas
[
i
];
SSchema
*
pSchema
=
&
pStb
->
pSmas
[
i
];
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pSchema
->
type
,
STB_DECODE_OVER
)
SDB_GET_INT8
(
pRaw
,
dataPos
,
&
pSchema
->
type
,
STB_DECODE_OVER
)
SDB_GET_INT
32
(
pRaw
,
dataPos
,
&
pSchema
->
colId
,
STB_DECODE_OVER
)
SDB_GET_INT
16
(
pRaw
,
dataPos
,
&
pSchema
->
colId
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pSchema
->
bytes
,
STB_DECODE_OVER
)
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pSchema
->
bytes
,
STB_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_DECODE_OVER
)
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pSchema
->
name
,
TSDB_COL_NAME_LEN
,
STB_DECODE_OVER
)
}
}
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
a82fc113
...
@@ -14,7 +14,6 @@
...
@@ -14,7 +14,6 @@
*/
*/
#include "mndStream.h"
#include "mndStream.h"
#include "parser.h"
#include "mndAuth.h"
#include "mndAuth.h"
#include "mndDb.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndDnode.h"
...
@@ -26,6 +25,7 @@
...
@@ -26,6 +25,7 @@
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndUser.h"
#include "mndVgroup.h"
#include "mndVgroup.h"
#include "parser.h"
#include "tname.h"
#include "tname.h"
#define MND_STREAM_VER_NUMBER 1
#define MND_STREAM_VER_NUMBER 1
...
@@ -248,23 +248,22 @@ static int32_t mndStreamGetPlanString(const char *ast, char **pStr) {
...
@@ -248,23 +248,22 @@ static int32_t mndStreamGetPlanString(const char *ast, char **pStr) {
int32_t
mndAddStreamToTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
const
char
*
ast
,
STrans
*
pTrans
)
{
int32_t
mndAddStreamToTrans
(
SMnode
*
pMnode
,
SStreamObj
*
pStream
,
const
char
*
ast
,
STrans
*
pTrans
)
{
SNode
*
pAst
=
NULL
;
SNode
*
pAst
=
NULL
;
#if 1 // TODO: remove debug info later
printf
(
"ast = %s
\n
"
,
ast
);
#endif
if
(
nodesStringToNode
(
ast
,
&
pAst
)
<
0
)
{
if
(
nodesStringToNode
(
ast
,
&
pAst
)
<
0
)
{
return
-
1
;
return
-
1
;
}
}
#if 1
SSchemaWrapper
sw
=
{
0
};
qExtractResultSchema
(
pAst
,
(
int32_t
*
)
&
sw
.
nCols
,
&
sw
.
pSchema
);
if
(
qExtractResultSchema
(
pAst
,
(
int32_t
*
)
&
pStream
->
outputSchema
.
nCols
,
&
pStream
->
outputSchema
.
pSchema
)
!=
0
)
{
return
-
1
;
}
#if 1
printf
(
"|"
);
printf
(
"|"
);
for
(
int
i
=
0
;
i
<
sw
.
nCols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pStream
->
outputSchema
.
nCols
;
i
++
)
{
printf
(
" %15s |"
,
(
char
*
)
sw
.
pSchema
[
i
].
name
);
printf
(
" %15s |"
,
(
char
*
)
pStream
->
outputSchema
.
pSchema
[
i
].
name
);
}
}
printf
(
"
\n
=======================================================
\n
"
);
printf
(
"
\n
=======================================================
\n
"
);
pStream
->
ColAlias
=
NULL
;
#endif
#endif
if
(
TSDB_CODE_SUCCESS
!=
mndStreamGetPlanString
(
ast
,
&
pStream
->
physicalPlan
))
{
if
(
TSDB_CODE_SUCCESS
!=
mndStreamGetPlanString
(
ast
,
&
pStream
->
physicalPlan
))
{
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
a82fc113
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
#include "mndTrans.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "mndUser.h"
#include "mndVgroup.h"
#include "mndVgroup.h"
#include "parser.h"
#include "tname.h"
#include "tname.h"
#define MND_TOPIC_VER_NUMBER 1
#define MND_TOPIC_VER_NUMBER 1
...
@@ -85,6 +86,16 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
...
@@ -85,6 +86,16 @@ SSdbRaw *mndTopicActionEncode(SMqTopicObj *pTopic) {
SDB_SET_INT32
(
pRaw
,
dataPos
,
physicalPlanLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
physicalPlanLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
physicalPlan
,
physicalPlanLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
physicalPlan
,
physicalPlanLen
,
TOPIC_ENCODE_OVER
);
int32_t
swLen
=
taosEncodeSSchemaWrapper
(
NULL
,
&
pTopic
->
schema
);
void
*
swBuf
=
taosMemoryMalloc
(
swLen
);
if
(
swBuf
==
NULL
)
{
goto
TOPIC_ENCODE_OVER
;
}
void
*
aswBuf
=
swBuf
;
taosEncodeSSchemaWrapper
(
&
aswBuf
,
&
pTopic
->
schema
);
SDB_SET_INT32
(
pRaw
,
dataPos
,
swLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_BINARY
(
pRaw
,
dataPos
,
swBuf
,
swLen
,
TOPIC_ENCODE_OVER
);
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_ENCODE_OVER
);
SDB_SET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_ENCODE_OVER
);
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
TOPIC_ENCODE_OVER
);
SDB_SET_DATALEN
(
pRaw
,
dataPos
,
TOPIC_ENCODE_OVER
);
...
@@ -149,6 +160,17 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
...
@@ -149,6 +160,17 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
}
}
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
physicalPlan
,
len
,
TOPIC_DECODE_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
physicalPlan
,
len
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
len
,
TOPIC_DECODE_OVER
);
void
*
buf
=
taosMemoryMalloc
(
len
);
if
(
buf
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
TOPIC_DECODE_OVER
;
}
SDB_GET_BINARY
(
pRaw
,
dataPos
,
buf
,
len
,
TOPIC_DECODE_OVER
);
if
(
taosDecodeSSchemaWrapper
(
buf
,
&
pTopic
->
schema
)
==
NULL
)
{
goto
TOPIC_DECODE_OVER
;
}
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_DECODE_OVER
);
SDB_GET_RESERVE
(
pRaw
,
dataPos
,
MND_TOPIC_RESERVE_SIZE
,
TOPIC_DECODE_OVER
);
terrno
=
TSDB_CODE_SUCCESS
;
terrno
=
TSDB_CODE_SUCCESS
;
...
@@ -283,6 +305,14 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
...
@@ -283,6 +305,14 @@ static int32_t mndCreateTopic(SMnode *pMnode, SNodeMsg *pReq, SCMCreateTopicReq
topicObj
.
physicalPlan
=
pPlanStr
;
topicObj
.
physicalPlan
=
pPlanStr
;
}
}
SNode
*
pAst
=
NULL
;
if
(
nodesStringToNode
(
pCreate
->
ast
,
&
pAst
)
<
0
)
{
return
-
1
;
}
if
(
qExtractResultSchema
(
pAst
,
&
topicObj
.
schema
.
nCols
,
&
topicObj
.
schema
.
pSchema
)
!=
0
)
{
return
-
1
;
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_TOPIC
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_TOPIC
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
if
(
pTrans
==
NULL
)
{
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
mError
(
"topic:%s, failed to create since %s"
,
pCreate
->
name
,
terrstr
());
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
a82fc113
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
#include "mndTrans.h"
#include "mndTrans.h"
#include "tbase64.h"
#include "tbase64.h"
#define TSDB_USER_VER_NUMBER 1
#define TSDB_USER_VER_NUMBER
1
#define TSDB_USER_RESERVE_SIZE 64
#define TSDB_USER_RESERVE_SIZE 64
static
int32_t
mndCreateDefaultUsers
(
SMnode
*
pMnode
);
static
int32_t
mndCreateDefaultUsers
(
SMnode
*
pMnode
);
...
@@ -270,7 +270,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
...
@@ -270,7 +270,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
userObj
.
updateTime
=
userObj
.
createdTime
;
userObj
.
updateTime
=
userObj
.
createdTime
;
userObj
.
superUser
=
pCreate
->
superUser
;
userObj
.
superUser
=
pCreate
->
superUser
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_USER
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_CREATE_USER
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
if
(
pTrans
==
NULL
)
{
mError
(
"user:%s, failed to create since %s"
,
pCreate
->
user
,
terrstr
());
mError
(
"user:%s, failed to create since %s"
,
pCreate
->
user
,
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -350,7 +350,7 @@ CREATE_USER_OVER:
...
@@ -350,7 +350,7 @@ CREATE_USER_OVER:
}
}
static
int32_t
mndUpdateUser
(
SMnode
*
pMnode
,
SUserObj
*
pOld
,
SUserObj
*
pNew
,
SNodeMsg
*
pReq
)
{
static
int32_t
mndUpdateUser
(
SMnode
*
pMnode
,
SUserObj
*
pOld
,
SUserObj
*
pNew
,
SNodeMsg
*
pReq
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_ALTER_USER
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_ALTER_USER
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
if
(
pTrans
==
NULL
)
{
mError
(
"user:%s, failed to update since %s"
,
pOld
->
user
,
terrstr
());
mError
(
"user:%s, failed to update since %s"
,
pOld
->
user
,
terrstr
());
return
-
1
;
return
-
1
;
...
@@ -511,7 +511,7 @@ ALTER_USER_OVER:
...
@@ -511,7 +511,7 @@ ALTER_USER_OVER:
}
}
static
int32_t
mndDropUser
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SUserObj
*
pUser
)
{
static
int32_t
mndDropUser
(
SMnode
*
pMnode
,
SNodeMsg
*
pReq
,
SUserObj
*
pUser
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_DROP_USER
,
&
pReq
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_TYPE_DROP_USER
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
if
(
pTrans
==
NULL
)
{
mError
(
"user:%s, failed to drop since %s"
,
pUser
->
user
,
terrstr
());
mError
(
"user:%s, failed to drop since %s"
,
pUser
->
user
,
terrstr
());
return
-
1
;
return
-
1
;
...
...
source/dnode/vnode/src/meta/metaBDBImpl.c
浏览文件 @
a82fc113
...
@@ -233,7 +233,7 @@ int metaSaveSmaToDB(SMeta *pMeta, STSma *pSmaCfg) {
...
@@ -233,7 +233,7 @@ int metaSaveSmaToDB(SMeta *pMeta, STSma *pSmaCfg) {
// save sma info
// save sma info
int32_t
len
=
tEncodeTSma
(
NULL
,
pSmaCfg
);
int32_t
len
=
tEncodeTSma
(
NULL
,
pSmaCfg
);
pBuf
=
taosMemoryCalloc
(
len
,
1
);
pBuf
=
taosMemoryCalloc
(
1
,
len
);
if
(
pBuf
==
NULL
)
{
if
(
pBuf
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
return
-
1
;
...
@@ -285,7 +285,7 @@ static int metaEncodeSchema(void **buf, SSchemaWrapper *pSW) {
...
@@ -285,7 +285,7 @@ static int metaEncodeSchema(void **buf, SSchemaWrapper *pSW) {
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
pSchema
=
pSW
->
pSchema
+
i
;
pSchema
=
pSW
->
pSchema
+
i
;
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
type
);
tlen
+=
taosEncodeFixedI8
(
buf
,
pSchema
->
type
);
tlen
+=
taosEncodeFixedI
32
(
buf
,
pSchema
->
colId
);
tlen
+=
taosEncodeFixedI
16
(
buf
,
pSchema
->
colId
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSchema
->
bytes
);
tlen
+=
taosEncodeFixedI32
(
buf
,
pSchema
->
bytes
);
tlen
+=
taosEncodeString
(
buf
,
pSchema
->
name
);
tlen
+=
taosEncodeString
(
buf
,
pSchema
->
name
);
}
}
...
@@ -301,7 +301,7 @@ static void *metaDecodeSchema(void *buf, SSchemaWrapper *pSW) {
...
@@ -301,7 +301,7 @@ static void *metaDecodeSchema(void *buf, SSchemaWrapper *pSW) {
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pSW
->
nCols
;
i
++
)
{
pSchema
=
pSW
->
pSchema
+
i
;
pSchema
=
pSW
->
pSchema
+
i
;
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
type
);
buf
=
taosDecodeFixedI8
(
buf
,
&
pSchema
->
type
);
buf
=
taosDecodeFixedI
32
(
buf
,
&
pSchema
->
colId
);
buf
=
taosDecodeFixedI
16
(
buf
,
&
pSchema
->
colId
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSchema
->
bytes
);
buf
=
taosDecodeFixedI32
(
buf
,
&
pSchema
->
bytes
);
buf
=
taosDecodeStringTo
(
buf
,
pSchema
->
name
);
buf
=
taosDecodeStringTo
(
buf
,
pSchema
->
name
);
}
}
...
@@ -516,6 +516,7 @@ static int metaEncodeTbInfo(void **buf, STbCfg *pTbCfg) {
...
@@ -516,6 +516,7 @@ static int metaEncodeTbInfo(void **buf, STbCfg *pTbCfg) {
tsize
+=
taosEncodeFixedU64
(
buf
,
pTbCfg
->
ctbCfg
.
suid
);
tsize
+=
taosEncodeFixedU64
(
buf
,
pTbCfg
->
ctbCfg
.
suid
);
tsize
+=
tdEncodeKVRow
(
buf
,
pTbCfg
->
ctbCfg
.
pTag
);
tsize
+=
tdEncodeKVRow
(
buf
,
pTbCfg
->
ctbCfg
.
pTag
);
}
else
if
(
pTbCfg
->
type
==
META_NORMAL_TABLE
)
{
}
else
if
(
pTbCfg
->
type
==
META_NORMAL_TABLE
)
{
// TODO
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
@@ -538,6 +539,7 @@ static void *metaDecodeTbInfo(void *buf, STbCfg *pTbCfg) {
...
@@ -538,6 +539,7 @@ static void *metaDecodeTbInfo(void *buf, STbCfg *pTbCfg) {
buf
=
taosDecodeFixedU64
(
buf
,
&
(
pTbCfg
->
ctbCfg
.
suid
));
buf
=
taosDecodeFixedU64
(
buf
,
&
(
pTbCfg
->
ctbCfg
.
suid
));
buf
=
tdDecodeKVRow
(
buf
,
&
(
pTbCfg
->
ctbCfg
.
pTag
));
buf
=
tdDecodeKVRow
(
buf
,
&
(
pTbCfg
->
ctbCfg
.
pTag
));
}
else
if
(
pTbCfg
->
type
==
META_NORMAL_TABLE
)
{
}
else
if
(
pTbCfg
->
type
==
META_NORMAL_TABLE
)
{
// TODO
}
else
{
}
else
{
ASSERT
(
0
);
ASSERT
(
0
);
}
}
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
a82fc113
...
@@ -42,8 +42,8 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, STq
...
@@ -42,8 +42,8 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal, SMeta* pVnodeMeta, STq
// TODO: error code of buffer pool
// TODO: error code of buffer pool
}
}
#endif
#endif
pTq
->
tqMeta
=
pTq
->
tqMeta
=
tqStoreOpen
(
pTq
,
path
,
(
FTqSerialize
)
tqSerializeConsumer
,
(
FTqDeserialize
)
tqDeserializeConsumer
,
tqStoreOpen
(
pTq
,
path
,
(
FTqSerialize
)
tqSerializeConsumer
,
(
FTqDeserialize
)
tqDeserializeConsumer
,
(
FTqDelete
)
taosMemoryFree
,
0
);
(
FTqDelete
)
taosMemoryFree
,
0
);
if
(
pTq
->
tqMeta
==
NULL
)
{
if
(
pTq
->
tqMeta
==
NULL
)
{
taosMemoryFree
(
pTq
);
taosMemoryFree
(
pTq
);
#if 0
#if 0
...
@@ -498,12 +498,16 @@ int32_t tqProcessStreamTrigger(STQ* pTq, void* data, int32_t dataLen) {
...
@@ -498,12 +498,16 @@ int32_t tqProcessStreamTrigger(STQ* pTq, void* data, int32_t dataLen) {
}
}
int32_t
tqProcessTaskExec
(
STQ
*
pTq
,
SRpcMsg
*
msg
)
{
int32_t
tqProcessTaskExec
(
STQ
*
pTq
,
SRpcMsg
*
msg
)
{
SStreamTaskExecReq
*
pReq
=
msg
->
pCont
;
char
*
msgstr
=
POINTER_SHIFT
(
msg
->
pCont
,
sizeof
(
SMsgHead
));
int32_t
taskId
=
pReq
->
taskId
;
SStreamTask
*
pTask
=
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
SStreamTaskExecReq
req
;
tDecodeSStreamTaskExecReq
(
msgstr
,
&
req
);
int32_t
taskId
=
req
.
taskId
;
SStreamTask
*
pTask
=
taosHashGet
(
pTq
->
pStreamTasks
,
&
taskId
,
sizeof
(
int32_t
));
ASSERT
(
pTask
);
ASSERT
(
pTask
);
if
(
streamExecTask
(
pTask
,
&
pTq
->
pVnode
->
msgCb
,
pReq
->
data
,
STREAM_DATA_TYPE_SSDATA_BLOCK
,
0
)
<
0
)
{
if
(
streamExecTask
(
pTask
,
&
pTq
->
pVnode
->
msgCb
,
req
.
data
,
STREAM_DATA_TYPE_SSDATA_BLOCK
,
0
)
<
0
)
{
// TODO
// TODO
}
}
return
0
;
return
0
;
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
a82fc113
...
@@ -130,8 +130,8 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
...
@@ -130,8 +130,8 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
int32_t
colNeed
=
0
;
int32_t
colNeed
=
0
;
while
(
colMeta
<
pSchemaWrapper
->
nCols
&&
colNeed
<
colNumNeed
)
{
while
(
colMeta
<
pSchemaWrapper
->
nCols
&&
colNeed
<
colNumNeed
)
{
SSchema
*
pColSchema
=
&
pSchemaWrapper
->
pSchema
[
colMeta
];
SSchema
*
pColSchema
=
&
pSchemaWrapper
->
pSchema
[
colMeta
];
int16_t
colIdSchema
=
pColSchema
->
colId
;
col_id_t
colIdSchema
=
pColSchema
->
colId
;
int16_t
colIdNeed
=
*
(
int16
_t
*
)
taosArrayGet
(
pHandle
->
pColIdList
,
colNeed
);
col_id_t
colIdNeed
=
*
(
col_id
_t
*
)
taosArrayGet
(
pHandle
->
pColIdList
,
colNeed
);
if
(
colIdSchema
<
colIdNeed
)
{
if
(
colIdSchema
<
colIdNeed
)
{
colMeta
++
;
colMeta
++
;
}
else
if
(
colIdSchema
>
colIdNeed
)
{
}
else
if
(
colIdSchema
>
colIdNeed
)
{
...
@@ -159,7 +159,7 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
...
@@ -159,7 +159,7 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
int
j
=
0
;
int
j
=
0
;
for
(
int32_t
i
=
0
;
i
<
colNumNeed
;
i
++
)
{
for
(
int32_t
i
=
0
;
i
<
colNumNeed
;
i
++
)
{
int16_t
colId
=
*
(
int16
_t
*
)
taosArrayGet
(
pHandle
->
pColIdList
,
i
);
col_id_t
colId
=
*
(
col_id
_t
*
)
taosArrayGet
(
pHandle
->
pColIdList
,
i
);
while
(
j
<
pSchemaWrapper
->
nCols
&&
pSchemaWrapper
->
pSchema
[
j
].
colId
<
colId
)
{
while
(
j
<
pSchemaWrapper
->
nCols
&&
pSchemaWrapper
->
pSchema
[
j
].
colId
<
colId
)
{
j
++
;
j
++
;
}
}
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
a82fc113
...
@@ -1369,7 +1369,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
...
@@ -1369,7 +1369,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
}
}
}
}
// Update pBlock membership va
ir
ables
// Update pBlock membership va
ri
ables
pBlock
->
last
=
isLast
;
pBlock
->
last
=
isLast
;
pBlock
->
offset
=
offset
;
pBlock
->
offset
=
offset
;
pBlock
->
algorithm
=
pCfg
->
compression
;
pBlock
->
algorithm
=
pCfg
->
compression
;
...
...
source/dnode/vnode/src/tsdb/tsdbMemTable.c
浏览文件 @
a82fc113
...
@@ -255,7 +255,7 @@ int32_t tdScanAndConvertSubmitMsg(SSubmitReq *pMsg) {
...
@@ -255,7 +255,7 @@ int32_t tdScanAndConvertSubmitMsg(SSubmitReq *pMsg) {
return
0
;
return
0
;
}
}
int
tsdbScanAndConvertSubmitMsg
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
)
{
static
int
tsdbScanAndConvertSubmitMsg
(
STsdb
*
pTsdb
,
SSubmitReq
*
pMsg
)
{
ASSERT
(
pMsg
!=
NULL
);
ASSERT
(
pMsg
!=
NULL
);
// STsdbMeta * pMeta = pTsdb->tsdbMeta;
// STsdbMeta * pMeta = pTsdb->tsdbMeta;
SSubmitMsgIter
msgIter
=
{
0
};
SSubmitMsgIter
msgIter
=
{
0
};
...
...
source/dnode/vnode/src/tsdb/tsdbSma.c
浏览文件 @
a82fc113
...
@@ -38,9 +38,10 @@ typedef enum {
...
@@ -38,9 +38,10 @@ typedef enum {
}
ESmaStorageLevel
;
}
ESmaStorageLevel
;
typedef
struct
{
typedef
struct
{
STsdb
*
pTsdb
;
STsdb
*
pTsdb
;
SDBFile
dFile
;
SDBFile
dFile
;
int32_t
interval
;
// interval with the precision of DB
SSDataBlock
*
pData
;
// sma data
int32_t
interval
;
// interval with the precision of DB
}
STSmaWriteH
;
}
STSmaWriteH
;
typedef
struct
{
typedef
struct
{
...
@@ -98,7 +99,8 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_
...
@@ -98,7 +99,8 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_
int32_t
nMaxResult
);
int32_t
nMaxResult
);
// insert data
// insert data
static
int32_t
tsdbInitTSmaWriteH
(
STSmaWriteH
*
pSmaH
,
STsdb
*
pTsdb
,
STSmaDataWrapper
*
pData
);
static
int32_t
tsdbInitTSmaWriteH
(
STSmaWriteH
*
pSmaH
,
STsdb
*
pTsdb
,
SSDataBlock
*
pData
,
int64_t
interval
,
int8_t
intervalUnit
);
static
void
tsdbDestroyTSmaWriteH
(
STSmaWriteH
*
pSmaH
);
static
void
tsdbDestroyTSmaWriteH
(
STSmaWriteH
*
pSmaH
);
static
int32_t
tsdbInitTSmaReadH
(
STSmaReadH
*
pSmaH
,
STsdb
*
pTsdb
,
int64_t
interval
,
int8_t
intervalUnit
);
static
int32_t
tsdbInitTSmaReadH
(
STSmaReadH
*
pSmaH
,
STsdb
*
pTsdb
,
int64_t
interval
,
int8_t
intervalUnit
);
static
int32_t
tsdbGetSmaStorageLevel
(
int64_t
interval
,
int8_t
intervalUnit
);
static
int32_t
tsdbGetSmaStorageLevel
(
int64_t
interval
,
int8_t
intervalUnit
);
...
@@ -800,9 +802,10 @@ static int32_t tsdbInsertTSmaDataSection(STSmaWriteH *pSmaH, STSmaDataWrapper *p
...
@@ -800,9 +802,10 @@ static int32_t tsdbInsertTSmaDataSection(STSmaWriteH *pSmaH, STSmaDataWrapper *p
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
int32_t
tsdbInitTSmaWriteH
(
STSmaWriteH
*
pSmaH
,
STsdb
*
pTsdb
,
S
TSmaDataWrapper
*
pData
)
{
static
int32_t
tsdbInitTSmaWriteH
(
STSmaWriteH
*
pSmaH
,
STsdb
*
pTsdb
,
S
SDataBlock
*
pData
,
int64_t
interval
,
int8_t
intervalUnit
)
{
pSmaH
->
pTsdb
=
pTsdb
;
pSmaH
->
pTsdb
=
pTsdb
;
pSmaH
->
interval
=
tsdbGetIntervalByPrecision
(
pData
->
interval
,
pData
->
intervalUnit
,
REPO_CFG
(
pTsdb
)
->
precision
);
pSmaH
->
interval
=
tsdbGetIntervalByPrecision
(
interval
,
intervalUnit
,
REPO_CFG
(
pTsdb
)
->
precision
);
pSmaH
->
pData
=
pData
;
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -857,10 +860,10 @@ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLe
...
@@ -857,10 +860,10 @@ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLe
* @return int32_t
* @return int32_t
*/
*/
static
int32_t
tsdbInsertTSmaDataImpl
(
STsdb
*
pTsdb
,
char
*
msg
)
{
static
int32_t
tsdbInsertTSmaDataImpl
(
STsdb
*
pTsdb
,
char
*
msg
)
{
STsdbCfg
*
pCfg
=
REPO_CFG
(
pTsdb
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pTsdb
);
S
TSmaDataWrapper
*
pData
=
(
STSmaDataWrapper
*
)
msg
;
S
SDataBlock
*
pData
=
(
SSDataBlock
*
)
msg
;
SSmaEnv
*
pEnv
=
atomic_load_ptr
(
&
pTsdb
->
pTSmaEnv
);
SSmaEnv
*
pEnv
=
atomic_load_ptr
(
&
pTsdb
->
pTSmaEnv
);
int64_t
indexUid
=
SMA_TEST_INDEX_UID
;
int64_t
indexUid
=
SMA_TEST_INDEX_UID
;
if
(
pEnv
==
NULL
)
{
if
(
pEnv
==
NULL
)
{
terrno
=
TSDB_CODE_INVALID_PTR
;
terrno
=
TSDB_CODE_INVALID_PTR
;
...
@@ -868,15 +871,15 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
...
@@ -868,15 +871,15 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
return
terrno
;
return
terrno
;
}
}
if
(
pData
->
dataLen
<=
0
)
{
if
(
pData
==
NULL
)
{
TASSERT
(
0
)
;
terrno
=
TSDB_CODE_INVALID_PTR
;
t
errno
=
TSDB_CODE_INVALID_PARA
;
t
sdbWarn
(
"vgId:%d insert tSma data failed since pData is NULL"
,
REPO_ID
(
pTsdb
))
;
return
TSDB_CODE_FAILED
;
return
terrno
;
}
}
STSmaWriteH
tSmaH
=
{
0
};
if
(
taosArrayGetSize
(
pData
->
pDataBlock
)
<=
0
)
{
terrno
=
TSDB_CODE_INVALID_PARA
;
if
(
tsdbInitTSmaWriteH
(
&
tSmaH
,
pTsdb
,
pData
)
!=
0
)
{
tsdbWarn
(
"vgId:%d insert tSma data failed since pDataBlock is empty"
,
REPO_ID
(
pTsdb
));
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
...
@@ -895,6 +898,14 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
...
@@ -895,6 +898,14 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
STSma
*
pSma
=
pItem
->
pSma
;
STSmaWriteH
tSmaH
=
{
0
};
if
(
tsdbInitTSmaWriteH
(
&
tSmaH
,
pTsdb
,
pData
,
pSma
->
interval
,
pSma
->
intervalUnit
)
!=
0
)
{
return
TSDB_CODE_FAILED
;
}
char
rPath
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
rPath
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
aPath
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
aPath
[
TSDB_FILENAME_LEN
]
=
{
0
};
snprintf
(
rPath
,
TSDB_FILENAME_LEN
,
"%s%s%"
PRIi64
,
SMA_ENV_PATH
(
pEnv
),
TD_DIRSEP
,
indexUid
);
snprintf
(
rPath
,
TSDB_FILENAME_LEN
,
"%s%s%"
PRIi64
,
SMA_ENV_PATH
(
pEnv
),
TD_DIRSEP
,
indexUid
);
...
@@ -907,8 +918,11 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
...
@@ -907,8 +918,11 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
}
}
// Step 1: Judge the storage level and days
// Step 1: Judge the storage level and days
int32_t
storageLevel
=
tsdbGetSmaStorageLevel
(
p
Data
->
interval
,
pDat
a
->
intervalUnit
);
int32_t
storageLevel
=
tsdbGetSmaStorageLevel
(
p
Sma
->
interval
,
pSm
a
->
intervalUnit
);
int32_t
daysPerFile
=
tsdbGetTSmaDays
(
pTsdb
,
tSmaH
.
interval
,
storageLevel
);
int32_t
daysPerFile
=
tsdbGetTSmaDays
(
pTsdb
,
tSmaH
.
interval
,
storageLevel
);
#if 0
int32_t fid = (int32_t)(TSDB_KEY_FID(pData->skey, daysPerFile, pCfg->precision));
int32_t fid = (int32_t)(TSDB_KEY_FID(pData->skey, daysPerFile, pCfg->precision));
// Step 2: Set the DFile for storage of SMA index, and iterate/split the TSma data and store to B+Tree index file
// Step 2: Set the DFile for storage of SMA index, and iterate/split the TSma data and store to B+Tree index file
...
@@ -933,7 +947,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
...
@@ -933,7 +947,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) {
// Step 3: reset the SSmaStat
// Step 3: reset the SSmaStat
tsdbResetExpiredWindow(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv), pData->indexUid, pData->skey);
tsdbResetExpiredWindow(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv), pData->indexUid, pData->skey);
#endif
tsdbDestroyTSmaWriteH
(
&
tSmaH
);
tsdbDestroyTSmaWriteH
(
&
tSmaH
);
tsdbUnRefSmaStat
(
pTsdb
,
pStat
);
tsdbUnRefSmaStat
(
pTsdb
,
pStat
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -999,29 +1013,58 @@ static int32_t tsdbSetRSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData,
...
@@ -999,29 +1013,58 @@ static int32_t tsdbSetRSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData,
}
}
static
int32_t
tsdbInsertRSmaDataImpl
(
STsdb
*
pTsdb
,
char
*
msg
)
{
static
int32_t
tsdbInsertRSmaDataImpl
(
STsdb
*
pTsdb
,
char
*
msg
)
{
STsdbCfg
*
pCfg
=
REPO_CFG
(
pTsdb
);
STsdbCfg
*
pCfg
=
REPO_CFG
(
pTsdb
);
STSmaDataWrapper
*
pData
=
(
STSmaDataWrapper
*
)
msg
;
SSDataBlock
*
pData
=
(
SSDataBlock
*
)
msg
;
SSmaEnv
*
pEnv
=
atomic_load_ptr
(
&
pTsdb
->
pRSmaEnv
);
SSmaEnv
*
pEnv
=
atomic_load_ptr
(
&
pTsdb
->
pRSmaEnv
);
int64_t
indexUid
=
SMA_TEST_INDEX_UID
;
if
(
pEnv
==
NULL
)
{
if
(
pEnv
==
NULL
)
{
terrno
=
TSDB_CODE_INVALID_PTR
;
terrno
=
TSDB_CODE_INVALID_PTR
;
tsdbWarn
(
"vgId:%d insert tSma data failed since pTSmaEnv is NULL"
,
REPO_ID
(
pTsdb
));
tsdbWarn
(
"vgId:%d insert rSma data failed since pTSmaEnv is NULL"
,
REPO_ID
(
pTsdb
));
return
terrno
;
}
if
(
pEnv
==
NULL
)
{
terrno
=
TSDB_CODE_INVALID_PTR
;
tsdbWarn
(
"vgId:%d insert rSma data failed since pTSmaEnv is NULL"
,
REPO_ID
(
pTsdb
));
return
terrno
;
}
if
(
pData
==
NULL
)
{
terrno
=
TSDB_CODE_INVALID_PTR
;
tsdbWarn
(
"vgId:%d insert rSma data failed since pData is NULL"
,
REPO_ID
(
pTsdb
));
return
terrno
;
return
terrno
;
}
}
if
(
pData
->
dataLen
<=
0
)
{
if
(
taosArrayGetSize
(
pData
->
pDataBlock
)
<=
0
)
{
TASSERT
(
0
);
terrno
=
TSDB_CODE_INVALID_PARA
;
terrno
=
TSDB_CODE_INVALID_PARA
;
tsdbWarn
(
"vgId:%d insert rSma data failed since pDataBlock is empty"
,
REPO_ID
(
pTsdb
));
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
SSmaStat
*
pStat
=
SMA_ENV_STAT
(
pTsdb
->
pTSmaEnv
);
SSmaStatItem
*
pItem
=
NULL
;
tsdbRefSmaStat
(
pTsdb
,
pStat
);
if
(
pStat
&&
pStat
->
smaStatItems
)
{
pItem
=
taosHashGet
(
pStat
->
smaStatItems
,
&
indexUid
,
sizeof
(
indexUid
));
}
if
((
pItem
==
NULL
)
||
((
pItem
=
*
(
SSmaStatItem
**
)
pItem
)
==
NULL
)
||
tsdbSmaStatIsDropped
(
pItem
))
{
terrno
=
TSDB_CODE_TDB_INVALID_SMA_STAT
;
tsdbUnRefSmaStat
(
pTsdb
,
pStat
);
return
TSDB_CODE_FAILED
;
}
STSma
*
pSma
=
pItem
->
pSma
;
STSmaWriteH
tSmaH
=
{
0
};
STSmaWriteH
tSmaH
=
{
0
};
if
(
tsdbInitTSmaWriteH
(
&
tSmaH
,
pTsdb
,
pData
)
!=
0
)
{
if
(
tsdbInitTSmaWriteH
(
&
tSmaH
,
pTsdb
,
pData
,
pSma
->
interval
,
pSma
->
intervalUnit
)
!=
0
)
{
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
int64_t
indexUid
=
SMA_TEST_INDEX_UID
;
char
rPath
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
rPath
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
aPath
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
aPath
[
TSDB_FILENAME_LEN
]
=
{
0
};
snprintf
(
rPath
,
TSDB_FILENAME_LEN
,
"%s%s%"
PRIi64
,
SMA_ENV_PATH
(
pEnv
),
TD_DIRSEP
,
indexUid
);
snprintf
(
rPath
,
TSDB_FILENAME_LEN
,
"%s%s%"
PRIi64
,
SMA_ENV_PATH
(
pEnv
),
TD_DIRSEP
,
indexUid
);
...
@@ -1033,8 +1076,9 @@ static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg) {
...
@@ -1033,8 +1076,9 @@ static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg) {
}
}
// Step 1: Judge the storage level and days
// Step 1: Judge the storage level and days
int32_t
storageLevel
=
tsdbGetSmaStorageLevel
(
p
Data
->
interval
,
pDat
a
->
intervalUnit
);
int32_t
storageLevel
=
tsdbGetSmaStorageLevel
(
p
Sma
->
interval
,
pSm
a
->
intervalUnit
);
int32_t
daysPerFile
=
tsdbGetTSmaDays
(
pTsdb
,
tSmaH
.
interval
,
storageLevel
);
int32_t
daysPerFile
=
tsdbGetTSmaDays
(
pTsdb
,
tSmaH
.
interval
,
storageLevel
);
#if 0
int32_t fid = (int32_t)(TSDB_KEY_FID(pData->skey, daysPerFile, pCfg->precision));
int32_t fid = (int32_t)(TSDB_KEY_FID(pData->skey, daysPerFile, pCfg->precision));
// Step 2: Set the DFile for storage of SMA index, and iterate/split the TSma data and store to B+Tree index file
// Step 2: Set the DFile for storage of SMA index, and iterate/split the TSma data and store to B+Tree index file
...
@@ -1057,8 +1101,10 @@ static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg) {
...
@@ -1057,8 +1101,10 @@ static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg) {
// Step 3: reset the SSmaStat
// Step 3: reset the SSmaStat
tsdbResetExpiredWindow(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv), pData->indexUid, pData->skey);
tsdbResetExpiredWindow(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv), pData->indexUid, pData->skey);
#endif
tsdbDestroyTSmaWriteH
(
&
tSmaH
);
tsdbDestroyTSmaWriteH
(
&
tSmaH
);
tsdbUnRefSmaStat
(
pTsdb
,
pStat
);
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
a82fc113
...
@@ -66,6 +66,8 @@ int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg) {
...
@@ -66,6 +66,8 @@ int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg) {
case
TDMT_VND_CONSUME
:
case
TDMT_VND_CONSUME
:
return
tqProcessPollReq
(
pVnode
->
pTq
,
pMsg
);
return
tqProcessPollReq
(
pVnode
->
pTq
,
pMsg
);
case
TDMT_VND_TASK_EXEC
:
case
TDMT_VND_TASK_EXEC
:
case
TDMT_VND_TASK_PIPE_EXEC
:
case
TDMT_VND_TASK_MERGE_EXEC
:
return
tqProcessTaskExec
(
pVnode
->
pTq
,
pMsg
);
return
tqProcessTaskExec
(
pVnode
->
pTq
,
pMsg
);
case
TDMT_VND_STREAM_TRIGGER
:
case
TDMT_VND_STREAM_TRIGGER
:
return
tqProcessStreamTrigger
(
pVnode
->
pTq
,
pMsg
->
pCont
,
pMsg
->
contLen
);
return
tqProcessStreamTrigger
(
pVnode
->
pTq
,
pMsg
->
pCont
,
pMsg
->
contLen
);
...
...
source/dnode/vnode/src/vnd/vnodeWrite.c
浏览文件 @
a82fc113
...
@@ -74,6 +74,9 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -74,6 +74,9 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
// TODO: maybe need to clear the request struct
// TODO: maybe need to clear the request struct
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pSchema
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pSchema
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pTagSchema
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pTagSchema
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pBSmaCols
);
taosMemoryFree
(
vCreateTbReq
.
stbCfg
.
pRSmaParam
);
taosMemoryFree
(
vCreateTbReq
.
dbFName
);
taosMemoryFree
(
vCreateTbReq
.
name
);
taosMemoryFree
(
vCreateTbReq
.
name
);
break
;
break
;
}
}
...
@@ -102,13 +105,18 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -102,13 +105,18 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
vError
(
"vgId:%d, failed to create table: %s"
,
pVnode
->
vgId
,
pCreateTbReq
->
name
);
vError
(
"vgId:%d, failed to create table: %s"
,
pVnode
->
vgId
,
pCreateTbReq
->
name
);
}
}
taosMemoryFree
(
pCreateTbReq
->
name
);
taosMemoryFree
(
pCreateTbReq
->
name
);
taosMemoryFree
(
pCreateTbReq
->
dbFName
);
if
(
pCreateTbReq
->
type
==
TD_SUPER_TABLE
)
{
if
(
pCreateTbReq
->
type
==
TD_SUPER_TABLE
)
{
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pSchema
);
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pSchema
);
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pTagSchema
);
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pTagSchema
);
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pBSmaCols
);
taosMemoryFree
(
pCreateTbReq
->
stbCfg
.
pRSmaParam
);
}
else
if
(
pCreateTbReq
->
type
==
TD_CHILD_TABLE
)
{
}
else
if
(
pCreateTbReq
->
type
==
TD_CHILD_TABLE
)
{
taosMemoryFree
(
pCreateTbReq
->
ctbCfg
.
pTag
);
taosMemoryFree
(
pCreateTbReq
->
ctbCfg
.
pTag
);
}
else
{
}
else
{
taosMemoryFree
(
pCreateTbReq
->
ntbCfg
.
pSchema
);
taosMemoryFree
(
pCreateTbReq
->
ntbCfg
.
pSchema
);
taosMemoryFree
(
pCreateTbReq
->
ntbCfg
.
pBSmaCols
);
taosMemoryFree
(
pCreateTbReq
->
ntbCfg
.
pRSmaParam
);
}
}
}
}
...
@@ -135,6 +143,9 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -135,6 +143,9 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
tDeserializeSVCreateTbReq
(
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
&
vAlterTbReq
);
tDeserializeSVCreateTbReq
(
POINTER_SHIFT
(
pMsg
->
pCont
,
sizeof
(
SMsgHead
)),
&
vAlterTbReq
);
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pSchema
);
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pSchema
);
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pTagSchema
);
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pTagSchema
);
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pBSmaCols
);
taosMemoryFree
(
vAlterTbReq
.
stbCfg
.
pRSmaParam
);
taosMemoryFree
(
vAlterTbReq
.
dbFName
);
taosMemoryFree
(
vAlterTbReq
.
name
);
taosMemoryFree
(
vAlterTbReq
.
name
);
break
;
break
;
}
}
...
@@ -176,7 +187,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
...
@@ -176,7 +187,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
}
}
// record current timezone of server side
// record current timezone of server side
tstrncpy(vCreateSmaReq.tSma.timezone, tsTimezone, TD_TIMEZONE_LEN);
tstrncpy(vCreateSmaReq.tSma.timezone, tsTimezone
Str
, TD_TIMEZONE_LEN);
if (metaCreateTSma(pVnode->pMeta, &vCreateSmaReq) < 0) {
if (metaCreateTSma(pVnode->pMeta, &vCreateSmaReq) < 0) {
// TODO: handle error
// TODO: handle error
...
...
source/dnode/vnode/test/tsdbSmaTest.cpp
浏览文件 @
a82fc113
...
@@ -280,7 +280,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
...
@@ -280,7 +280,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) {
}
}
#endif
#endif
#if
1
#if
0
TEST(testCase, tSma_Data_Insert_Query_Test) {
TEST(testCase, tSma_Data_Insert_Query_Test) {
// step 1: prepare meta
// step 1: prepare meta
const char *smaIndexName1 = "sma_index_test_1";
const char *smaIndexName1 = "sma_index_test_1";
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
a82fc113
...
@@ -53,7 +53,6 @@ SCtgAction gCtgAction[CTG_ACT_MAX] = {{
...
@@ -53,7 +53,6 @@ SCtgAction gCtgAction[CTG_ACT_MAX] = {{
}
}
};
};
void
ctgFreeMetaRent
(
SCtgRentMgmt
*
mgmt
)
{
void
ctgFreeMetaRent
(
SCtgRentMgmt
*
mgmt
)
{
if
(
NULL
==
mgmt
->
slots
)
{
if
(
NULL
==
mgmt
->
slots
)
{
return
;
return
;
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
a82fc113
...
@@ -415,6 +415,7 @@ typedef struct STableScanInfo {
...
@@ -415,6 +415,7 @@ typedef struct STableScanInfo {
int32_t
*
rowCellInfoOffset
;
int32_t
*
rowCellInfoOffset
;
SExprInfo
*
pExpr
;
SExprInfo
*
pExpr
;
SSDataBlock
block
;
SSDataBlock
block
;
SArray
*
pColMatchInfo
;
int32_t
numOfOutput
;
int32_t
numOfOutput
;
int64_t
elapsedTime
;
int64_t
elapsedTime
;
int32_t
prevGroupId
;
// previous table group id
int32_t
prevGroupId
;
// previous table group id
...
@@ -648,8 +649,8 @@ typedef struct SDistinctOperatorInfo {
...
@@ -648,8 +649,8 @@ typedef struct SDistinctOperatorInfo {
}
SDistinctOperatorInfo
;
}
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
numOf
Output
,
SOperatorInfo
*
createTableScanOperatorInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOf
Cols
,
int32_t
repeatTime
,
int32_t
re
peatTime
,
int32_t
reverseTime
,
SExecTaskInfo
*
pTaskInfo
);
int32_t
re
verseTime
,
SArray
*
pColMatchInfo
,
SExecTaskInfo
*
pTaskInfo
);
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SOperatorInfo
*
createAggregateOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResultBlock
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createMultiTableAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
SOperatorInfo
*
createMultiTableAggOperatorInfo
(
SOperatorInfo
*
downstream
,
SExprInfo
*
pExprInfo
,
int32_t
numOfCols
,
SSDataBlock
*
pResBlock
,
SExecTaskInfo
*
pTaskInfo
,
const
STableGroupInfo
*
pTableGroupInfo
);
...
...
source/libs/executor/src/executor.c
浏览文件 @
a82fc113
...
@@ -97,6 +97,8 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, void* streamReadHandle) {
...
@@ -97,6 +97,8 @@ qTaskInfo_t qCreateStreamExecTaskInfo(void* msg, void* streamReadHandle) {
pMsg->contentLen = pMsg->contentLen;
pMsg->contentLen = pMsg->contentLen;
#endif
#endif
qDebugL
(
"stream task string %s"
,
(
const
char
*
)
msg
);
struct
SSubplan
*
plan
=
NULL
;
struct
SSubplan
*
plan
=
NULL
;
int32_t
code
=
qStringToSubplan
(
msg
,
&
plan
);
int32_t
code
=
qStringToSubplan
(
msg
,
&
plan
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
a82fc113
...
@@ -66,6 +66,11 @@ typedef enum SResultTsInterpType {
...
@@ -66,6 +66,11 @@ typedef enum SResultTsInterpType {
RESULT_ROW_END_INTERP
=
2
,
RESULT_ROW_END_INTERP
=
2
,
}
SResultTsInterpType
;
}
SResultTsInterpType
;
typedef
struct
SColMatchInfo
{
int32_t
colId
;
int32_t
targetSlotId
;
}
SColMatchInfo
;
#if 0
#if 0
static UNUSED_FUNC void *u_malloc (size_t __size) {
static UNUSED_FUNC void *u_malloc (size_t __size) {
uint32_t v = taosRand();
uint32_t v = taosRand();
...
@@ -2944,12 +2949,21 @@ int32_t loadDataBlock(SExecTaskInfo *pTaskInfo, STableScanInfo* pTableScanInfo,
...
@@ -2944,12 +2949,21 @@ int32_t loadDataBlock(SExecTaskInfo *pTaskInfo, STableScanInfo* pTableScanInfo,
*
status
=
BLK_DATA_ALL_NEEDED
;
*
status
=
BLK_DATA_ALL_NEEDED
;
pBlock
->
pDataBlock
=
tsdbRetrieveDataBlock
(
pTableScanInfo
->
pTsdbReadHandle
,
NULL
);
SArray
*
pCols
=
tsdbRetrieveDataBlock
(
pTableScanInfo
->
pTsdbReadHandle
,
NULL
);
if
(
p
Block
->
pDataBlock
==
NULL
)
{
if
(
p
Cols
==
NULL
)
{
return
terrno
;
return
terrno
;
}
else
{
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
numOfCols
=
pBlock
->
info
.
numOfCols
;
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
SColumnInfoData
*
p
=
taosArrayGet
(
pCols
,
i
);
SColMatchInfo
*
pColMatchInfo
=
taosArrayGet
(
pTableScanInfo
->
pColMatchInfo
,
i
);
ASSERT
(
pColMatchInfo
->
colId
==
p
->
info
.
colId
);
taosArraySet
(
pBlock
->
pDataBlock
,
pColMatchInfo
->
targetSlotId
,
p
);
}
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
loadDataBlockOnDemand
(
SExecTaskInfo
*
pTaskInfo
,
STableScanInfo
*
pTableScanInfo
,
SSDataBlock
*
pBlock
,
uint32_t
*
status
)
{
int32_t
loadDataBlockOnDemand
(
SExecTaskInfo
*
pTaskInfo
,
STableScanInfo
*
pTableScanInfo
,
SSDataBlock
*
pBlock
,
uint32_t
*
status
)
{
...
@@ -5374,7 +5388,8 @@ SSDataBlock* createResultDataBlock(const SArray* pExprInfo) {
...
@@ -5374,7 +5388,8 @@ SSDataBlock* createResultDataBlock(const SArray* pExprInfo) {
return
pResBlock
;
return
pResBlock
;
}
}
SOperatorInfo
*
createTableScanOperatorInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
int32_t
reverseTime
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createTableScanOperatorInfo
(
void
*
pTsdbReadHandle
,
int32_t
order
,
int32_t
numOfOutput
,
int32_t
repeatTime
,
int32_t
reverseTime
,
SArray
*
pColMatchInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
assert
(
repeatTime
>
0
);
assert
(
repeatTime
>
0
);
STableScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STableScanInfo
));
STableScanInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
STableScanInfo
));
...
@@ -5387,12 +5402,19 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order,
...
@@ -5387,12 +5402,19 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order,
return
NULL
;
return
NULL
;
}
}
pInfo
->
block
.
pDataBlock
=
taosArrayInit
(
numOfOutput
,
sizeof
(
SColumnInfoData
));
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
SColumnInfoData
idata
=
{
0
};
taosArrayPush
(
pInfo
->
block
.
pDataBlock
,
&
idata
);
}
pInfo
->
pTsdbReadHandle
=
pTsdbReadHandle
;
pInfo
->
pTsdbReadHandle
=
pTsdbReadHandle
;
pInfo
->
times
=
repeatTime
;
pInfo
->
times
=
repeatTime
;
pInfo
->
reverseTimes
=
reverseTime
;
pInfo
->
reverseTimes
=
reverseTime
;
pInfo
->
order
=
order
;
pInfo
->
order
=
order
;
pInfo
->
current
=
0
;
pInfo
->
current
=
0
;
pInfo
->
scanFlag
=
MAIN_SCAN
;
pInfo
->
scanFlag
=
MAIN_SCAN
;
pInfo
->
pColMatchInfo
=
pColMatchInfo
;
pOperator
->
name
=
"TableScanOperator"
;
pOperator
->
name
=
"TableScanOperator"
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
;
pOperator
->
operatorType
=
QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN
;
pOperator
->
blockingOptr
=
false
;
pOperator
->
blockingOptr
=
false
;
...
@@ -8569,6 +8591,7 @@ static int32_t doCreateTableGroup(void* metaHandle, int32_t tableType, uint64_t
...
@@ -8569,6 +8591,7 @@ static int32_t doCreateTableGroup(void* metaHandle, int32_t tableType, uint64_t
static
SArray
*
extractTableIdList
(
const
STableGroupInfo
*
pTableGroupInfo
);
static
SArray
*
extractTableIdList
(
const
STableGroupInfo
*
pTableGroupInfo
);
static
SArray
*
extractScanColumnId
(
SNodeList
*
pNodeList
);
static
SArray
*
extractScanColumnId
(
SNodeList
*
pNodeList
);
static
SArray
*
extractColumnInfo
(
SNodeList
*
pNodeList
);
static
SArray
*
extractColumnInfo
(
SNodeList
*
pNodeList
);
static
SArray
*
extractColMatchInfo
(
SNodeList
*
pNodeList
);
SOperatorInfo
*
doCreateOperatorTreeNode
(
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
,
STableGroupInfo
*
pTableGroupInfo
)
{
SOperatorInfo
*
doCreateOperatorTreeNode
(
SPhysiNode
*
pPhyNode
,
SExecTaskInfo
*
pTaskInfo
,
SReadHandle
*
pHandle
,
uint64_t
queryId
,
uint64_t
taskId
,
STableGroupInfo
*
pTableGroupInfo
)
{
if
(
pPhyNode
->
pChildren
==
NULL
||
LIST_LENGTH
(
pPhyNode
->
pChildren
)
==
0
)
{
if
(
pPhyNode
->
pChildren
==
NULL
||
LIST_LENGTH
(
pPhyNode
->
pChildren
)
==
0
)
{
...
@@ -8577,7 +8600,9 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
...
@@ -8577,7 +8600,9 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa
size_t
numOfCols
=
LIST_LENGTH
(
pScanPhyNode
->
pScanCols
);
size_t
numOfCols
=
LIST_LENGTH
(
pScanPhyNode
->
pScanCols
);
tsdbReaderT
pDataReader
=
doCreateDataReader
((
STableScanPhysiNode
*
)
pPhyNode
,
pHandle
,
pTableGroupInfo
,
(
uint64_t
)
queryId
,
taskId
);
tsdbReaderT
pDataReader
=
doCreateDataReader
((
STableScanPhysiNode
*
)
pPhyNode
,
pHandle
,
pTableGroupInfo
,
(
uint64_t
)
queryId
,
taskId
);
return
createTableScanOperatorInfo
(
pDataReader
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
pScanPhyNode
->
reverse
,
pTaskInfo
);
SArray
*
pColList
=
extractColMatchInfo
(
pScanPhyNode
->
pScanCols
);
return
createTableScanOperatorInfo
(
pDataReader
,
pScanPhyNode
->
order
,
numOfCols
,
pScanPhyNode
->
count
,
pScanPhyNode
->
reverse
,
pColList
,
pTaskInfo
);
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
==
nodeType
(
pPhyNode
))
{
}
else
if
(
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
==
nodeType
(
pPhyNode
))
{
SExchangePhysiNode
*
pExchange
=
(
SExchangePhysiNode
*
)
pPhyNode
;
SExchangePhysiNode
*
pExchange
=
(
SExchangePhysiNode
*
)
pPhyNode
;
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pExchange
->
node
.
pOutputDataBlockDesc
);
SSDataBlock
*
pResBlock
=
createOutputBuf_rv1
(
pExchange
->
node
.
pOutputDataBlockDesc
);
...
@@ -8717,9 +8742,14 @@ SArray* extractScanColumnId(SNodeList* pNodeList) {
...
@@ -8717,9 +8742,14 @@ SArray* extractScanColumnId(SNodeList* pNodeList) {
}
}
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
STargetNode
*
pNode
=
(
STargetNode
*
)
nodesListGetNode
(
pNodeList
,
i
);
for
(
int32_t
j
=
0
;
j
<
numOfCols
;
++
j
)
{
SColumnNode
*
pColNode
=
(
SColumnNode
*
)
pNode
->
pExpr
;
STargetNode
*
pNode
=
(
STargetNode
*
)
nodesListGetNode
(
pNodeList
,
j
);
taosArrayPush
(
pList
,
&
pColNode
->
colId
);
if
(
pNode
->
slotId
==
i
)
{
SColumnNode
*
pColNode
=
(
SColumnNode
*
)
pNode
->
pExpr
;
taosArrayPush
(
pList
,
&
pColNode
->
colId
);
break
;
}
}
}
}
return
pList
;
return
pList
;
...
@@ -8751,6 +8781,28 @@ SArray* extractColumnInfo(SNodeList* pNodeList) {
...
@@ -8751,6 +8781,28 @@ SArray* extractColumnInfo(SNodeList* pNodeList) {
return
pList
;
return
pList
;
}
}
SArray
*
extractColMatchInfo
(
SNodeList
*
pNodeList
)
{
size_t
numOfCols
=
LIST_LENGTH
(
pNodeList
);
SArray
*
pList
=
taosArrayInit
(
numOfCols
,
sizeof
(
SColMatchInfo
));
if
(
pList
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
NULL
;
}
for
(
int32_t
i
=
0
;
i
<
numOfCols
;
++
i
)
{
STargetNode
*
pNode
=
(
STargetNode
*
)
nodesListGetNode
(
pNodeList
,
i
);
SColumnNode
*
pColNode
=
(
SColumnNode
*
)
pNode
->
pExpr
;
SColMatchInfo
c
=
{
0
};
c
.
colId
=
pColNode
->
colId
;
c
.
targetSlotId
=
pNode
->
slotId
;
taosArrayPush
(
pList
,
&
c
);
}
return
pList
;
}
int32_t
doCreateTableGroup
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableGroupInfo
*
pGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
)
{
int32_t
doCreateTableGroup
(
void
*
metaHandle
,
int32_t
tableType
,
uint64_t
tableUid
,
STableGroupInfo
*
pGroupInfo
,
uint64_t
queryId
,
uint64_t
taskId
)
{
int32_t
code
=
0
;
int32_t
code
=
0
;
if
(
tableType
==
TSDB_SUPER_TABLE
)
{
if
(
tableType
==
TSDB_SUPER_TABLE
)
{
...
...
source/libs/nodes/src/nodesCloneFuncs.c
浏览文件 @
a82fc113
...
@@ -19,6 +19,11 @@
...
@@ -19,6 +19,11 @@
#include "taos.h"
#include "taos.h"
#include "taoserror.h"
#include "taoserror.h"
#define COPY_ALL_SCALAR_FIELDS \
do { \
memcpy((pDst), (pSrc), sizeof(*pSrc)); \
} while (0)
#define COPY_SCALAR_FIELD(fldname) \
#define COPY_SCALAR_FIELD(fldname) \
do { \
do { \
(pDst)->fldname = (pSrc)->fldname; \
(pDst)->fldname = (pSrc)->fldname; \
...
@@ -195,6 +200,12 @@ static SNode* groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode
...
@@ -195,6 +200,12 @@ static SNode* groupingSetNodeCopy(const SGroupingSetNode* pSrc, SGroupingSetNode
return
(
SNode
*
)
pDst
;
return
(
SNode
*
)
pDst
;
}
}
static
SNode
*
orderByExprNodeCopy
(
const
SOrderByExprNode
*
pSrc
,
SOrderByExprNode
*
pDst
)
{
COPY_ALL_SCALAR_FIELDS
;
CLONE_NODE_FIELD
(
pExpr
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
fillNodeCopy
(
const
SFillNode
*
pSrc
,
SFillNode
*
pDst
)
{
static
SNode
*
fillNodeCopy
(
const
SFillNode
*
pSrc
,
SFillNode
*
pDst
)
{
COPY_SCALAR_FIELD
(
mode
);
COPY_SCALAR_FIELD
(
mode
);
CLONE_NODE_FIELD
(
pValues
);
CLONE_NODE_FIELD
(
pValues
);
...
@@ -251,6 +262,7 @@ static SNode* logicAggCopy(const SAggLogicNode* pSrc, SAggLogicNode* pDst) {
...
@@ -251,6 +262,7 @@ static SNode* logicAggCopy(const SAggLogicNode* pSrc, SAggLogicNode* pDst) {
static
SNode
*
logicProjectCopy
(
const
SProjectLogicNode
*
pSrc
,
SProjectLogicNode
*
pDst
)
{
static
SNode
*
logicProjectCopy
(
const
SProjectLogicNode
*
pSrc
,
SProjectLogicNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
CLONE_NODE_LIST_FIELD
(
pProjections
);
CLONE_NODE_LIST_FIELD
(
pProjections
);
COPY_CHAR_ARRAY_FIELD
(
stmtName
);
return
(
SNode
*
)
pDst
;
return
(
SNode
*
)
pDst
;
}
}
...
@@ -267,16 +279,24 @@ static SNode* logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNo
...
@@ -267,16 +279,24 @@ static SNode* logicExchangeCopy(const SExchangeLogicNode* pSrc, SExchangeLogicNo
}
}
static
SNode
*
logicWindowCopy
(
const
SWindowLogicNode
*
pSrc
,
SWindowLogicNode
*
pDst
)
{
static
SNode
*
logicWindowCopy
(
const
SWindowLogicNode
*
pSrc
,
SWindowLogicNode
*
pDst
)
{
COPY_ALL_SCALAR_FIELDS
;
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
COPY_SCALAR_FIELD
(
winType
);
//
COPY_SCALAR_FIELD(winType);
CLONE_NODE_LIST_FIELD
(
pFuncs
);
CLONE_NODE_LIST_FIELD
(
pFuncs
);
COPY_SCALAR_FIELD
(
interval
);
//
COPY_SCALAR_FIELD(interval);
COPY_SCALAR_FIELD
(
offset
);
//
COPY_SCALAR_FIELD(offset);
COPY_SCALAR_FIELD
(
sliding
);
//
COPY_SCALAR_FIELD(sliding);
COPY_SCALAR_FIELD
(
intervalUnit
);
//
COPY_SCALAR_FIELD(intervalUnit);
COPY_SCALAR_FIELD
(
slidingUnit
);
//
COPY_SCALAR_FIELD(slidingUnit);
CLONE_NODE_FIELD
(
pFill
);
CLONE_NODE_FIELD
(
pFill
);
COPY_SCALAR_FIELD
(
sessionGap
);
// COPY_SCALAR_FIELD(sessionGap);
CLONE_NODE_FIELD
(
pTspk
);
return
(
SNode
*
)
pDst
;
}
static
SNode
*
logicSortCopy
(
const
SSortLogicNode
*
pSrc
,
SSortLogicNode
*
pDst
)
{
COPY_BASE_OBJECT_FIELD
(
node
,
logicNodeCopy
);
CLONE_NODE_LIST_FIELD
(
pSortKeys
);
return
(
SNode
*
)
pDst
;
return
(
SNode
*
)
pDst
;
}
}
...
@@ -339,6 +359,7 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
...
@@ -339,6 +359,7 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
case
QUERY_NODE_GROUPING_SET
:
case
QUERY_NODE_GROUPING_SET
:
return
groupingSetNodeCopy
((
const
SGroupingSetNode
*
)
pNode
,
(
SGroupingSetNode
*
)
pDst
);
return
groupingSetNodeCopy
((
const
SGroupingSetNode
*
)
pNode
,
(
SGroupingSetNode
*
)
pDst
);
case
QUERY_NODE_ORDER_BY_EXPR
:
case
QUERY_NODE_ORDER_BY_EXPR
:
return
orderByExprNodeCopy
((
const
SOrderByExprNode
*
)
pNode
,
(
SOrderByExprNode
*
)
pDst
);
case
QUERY_NODE_LIMIT
:
case
QUERY_NODE_LIMIT
:
break
;
break
;
case
QUERY_NODE_FILL
:
case
QUERY_NODE_FILL
:
...
@@ -361,6 +382,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
...
@@ -361,6 +382,8 @@ SNodeptr nodesCloneNode(const SNodeptr pNode) {
return
logicExchangeCopy
((
const
SExchangeLogicNode
*
)
pNode
,
(
SExchangeLogicNode
*
)
pDst
);
return
logicExchangeCopy
((
const
SExchangeLogicNode
*
)
pNode
,
(
SExchangeLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
return
logicWindowCopy
((
const
SWindowLogicNode
*
)
pNode
,
(
SWindowLogicNode
*
)
pDst
);
return
logicWindowCopy
((
const
SWindowLogicNode
*
)
pNode
,
(
SWindowLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_PLAN_SORT
:
return
logicSortCopy
((
const
SSortLogicNode
*
)
pNode
,
(
SSortLogicNode
*
)
pDst
);
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
logicSubplanCopy
((
const
SLogicSubplan
*
)
pNode
,
(
SLogicSubplan
*
)
pDst
);
return
logicSubplanCopy
((
const
SLogicSubplan
*
)
pNode
,
(
SLogicSubplan
*
)
pDst
);
default:
default:
...
...
source/libs/nodes/src/nodesCodeFuncs.c
浏览文件 @
a82fc113
...
@@ -851,9 +851,7 @@ static int32_t jsonToPhysiJoinNode(const SJson* pJson, void* pObj) {
...
@@ -851,9 +851,7 @@ static int32_t jsonToPhysiJoinNode(const SJson* pJson, void* pObj) {
int32_t
code
=
jsonToPhysicPlanNode
(
pJson
,
pObj
);
int32_t
code
=
jsonToPhysicPlanNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
int32_t
val
;
code
=
tjsonGetNumberValue
(
pJson
,
jkJoinPhysiPlanJoinType
,
pNode
->
joinType
);
code
=
tjsonGetIntValue
(
pJson
,
jkJoinPhysiPlanJoinType
,
&
val
);
pNode
->
joinType
=
val
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkJoinPhysiPlanOnConditions
,
&
pNode
->
pOnConditions
);
code
=
jsonToNodeObject
(
pJson
,
jkJoinPhysiPlanOnConditions
,
&
pNode
->
pOnConditions
);
...
@@ -934,6 +932,37 @@ static int32_t jsonToPhysiExchangeNode(const SJson* pJson, void* pObj) {
...
@@ -934,6 +932,37 @@ static int32_t jsonToPhysiExchangeNode(const SJson* pJson, void* pObj) {
return
code
;
return
code
;
}
}
static
const
char
*
jkSortPhysiPlanExprs
=
"Exprs"
;
static
const
char
*
jkSortPhysiPlanSortKeys
=
"SortKeys"
;
static
int32_t
physiSortNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SSortPhysiNode
*
pNode
=
(
const
SSortPhysiNode
*
)
pObj
;
int32_t
code
=
physicPlanNodeToJson
(
pObj
,
pJson
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkSortPhysiPlanExprs
,
pNode
->
pExprs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
nodeListToJson
(
pJson
,
jkSortPhysiPlanSortKeys
,
pNode
->
pSortKeys
);
}
return
code
;
}
static
int32_t
jsonToPhysiSortNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SSortPhysiNode
*
pNode
=
(
SSortPhysiNode
*
)
pObj
;
int32_t
code
=
jsonToPhysicPlanNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkSortPhysiPlanExprs
,
&
pNode
->
pExprs
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkSortPhysiPlanSortKeys
,
&
pNode
->
pSortKeys
);
}
return
code
;
}
static
const
char
*
jkWindowPhysiPlanExprs
=
"Exprs"
;
static
const
char
*
jkWindowPhysiPlanExprs
=
"Exprs"
;
static
const
char
*
jkWindowPhysiPlanFuncs
=
"Funcs"
;
static
const
char
*
jkWindowPhysiPlanFuncs
=
"Funcs"
;
...
@@ -971,6 +1000,7 @@ static const char* jkIntervalPhysiPlanSliding = "Sliding";
...
@@ -971,6 +1000,7 @@ static const char* jkIntervalPhysiPlanSliding = "Sliding";
static
const
char
*
jkIntervalPhysiPlanIntervalUnit
=
"intervalUnit"
;
static
const
char
*
jkIntervalPhysiPlanIntervalUnit
=
"intervalUnit"
;
static
const
char
*
jkIntervalPhysiPlanSlidingUnit
=
"slidingUnit"
;
static
const
char
*
jkIntervalPhysiPlanSlidingUnit
=
"slidingUnit"
;
static
const
char
*
jkIntervalPhysiPlanFill
=
"Fill"
;
static
const
char
*
jkIntervalPhysiPlanFill
=
"Fill"
;
static
const
char
*
jkIntervalPhysiPlanTsPk
=
"TsPk"
;
static
int32_t
physiIntervalNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
physiIntervalNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SIntervalPhysiNode
*
pNode
=
(
const
SIntervalPhysiNode
*
)
pObj
;
const
SIntervalPhysiNode
*
pNode
=
(
const
SIntervalPhysiNode
*
)
pObj
;
...
@@ -994,6 +1024,9 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -994,6 +1024,9 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkIntervalPhysiPlanFill
,
nodeToJson
,
pNode
->
pFill
);
code
=
tjsonAddObject
(
pJson
,
jkIntervalPhysiPlanFill
,
nodeToJson
,
pNode
->
pFill
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkIntervalPhysiPlanTsPk
,
nodeToJson
,
pNode
->
pTspk
);
}
return
code
;
return
code
;
}
}
...
@@ -1020,6 +1053,9 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) {
...
@@ -1020,6 +1053,9 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkIntervalPhysiPlanFill
,
(
SNode
**
)
&
pNode
->
pFill
);
code
=
jsonToNodeObject
(
pJson
,
jkIntervalPhysiPlanFill
,
(
SNode
**
)
&
pNode
->
pFill
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkIntervalPhysiPlanTsPk
,
(
SNode
**
)
&
pNode
->
pTspk
);
}
return
code
;
return
code
;
}
}
...
@@ -1178,9 +1214,7 @@ static int32_t jsonToSubplan(const SJson* pJson, void* pObj) {
...
@@ -1178,9 +1214,7 @@ static int32_t jsonToSubplan(const SJson* pJson, void* pObj) {
int32_t
code
=
tjsonToObject
(
pJson
,
jkSubplanId
,
jsonToSubplanId
,
&
pNode
->
id
);
int32_t
code
=
tjsonToObject
(
pJson
,
jkSubplanId
,
jsonToSubplanId
,
&
pNode
->
id
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
int32_t
val
;
code
=
tjsonGetNumberValue
(
pJson
,
jkSubplanType
,
pNode
->
subplanType
);
code
=
tjsonGetIntValue
(
pJson
,
jkSubplanType
,
&
val
);
pNode
->
subplanType
=
val
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetIntValue
(
pJson
,
jkSubplanMsgType
,
&
pNode
->
msgType
);
code
=
tjsonGetIntValue
(
pJson
,
jkSubplanMsgType
,
&
pNode
->
msgType
);
...
@@ -1370,9 +1404,7 @@ static int32_t jsonToColumnNode(const SJson* pJson, void* pObj) {
...
@@ -1370,9 +1404,7 @@ static int32_t jsonToColumnNode(const SJson* pJson, void* pObj) {
code
=
tjsonGetSmallIntValue
(
pJson
,
jkColumnColId
,
&
pNode
->
colId
);
code
=
tjsonGetSmallIntValue
(
pJson
,
jkColumnColId
,
&
pNode
->
colId
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
int32_t
tmp
;
code
=
tjsonGetNumberValue
(
pJson
,
jkColumnColType
,
pNode
->
colType
);
code
=
tjsonGetIntValue
(
pJson
,
jkColumnColType
,
&
tmp
);
pNode
->
colType
=
tmp
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetStringValue
(
pJson
,
jkColumnDbName
,
pNode
->
dbName
);
code
=
tjsonGetStringValue
(
pJson
,
jkColumnDbName
,
pNode
->
dbName
);
...
@@ -1560,9 +1592,7 @@ static int32_t jsonToOperatorNode(const SJson* pJson, void* pObj) {
...
@@ -1560,9 +1592,7 @@ static int32_t jsonToOperatorNode(const SJson* pJson, void* pObj) {
int32_t
code
=
jsonToExprNode
(
pJson
,
pObj
);
int32_t
code
=
jsonToExprNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
int32_t
val
;
code
=
tjsonGetNumberValue
(
pJson
,
jkOperatorType
,
pNode
->
opType
);
code
=
tjsonGetIntValue
(
pJson
,
jkOperatorType
,
&
val
);
pNode
->
opType
=
val
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkOperatorLeft
,
&
pNode
->
pLeft
);
code
=
jsonToNodeObject
(
pJson
,
jkOperatorLeft
,
&
pNode
->
pLeft
);
...
@@ -1596,9 +1626,7 @@ static int32_t jsonToLogicConditionNode(const SJson* pJson, void* pObj) {
...
@@ -1596,9 +1626,7 @@ static int32_t jsonToLogicConditionNode(const SJson* pJson, void* pObj) {
int32_t
code
=
jsonToExprNode
(
pJson
,
pObj
);
int32_t
code
=
jsonToExprNode
(
pJson
,
pObj
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
int32_t
val
;
code
=
tjsonGetNumberValue
(
pJson
,
jkLogicCondType
,
pNode
->
condType
);
code
=
tjsonGetIntValue
(
pJson
,
jkLogicCondType
,
&
val
);
pNode
->
condType
=
val
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeList
(
pJson
,
jkLogicCondParameters
,
&
pNode
->
pParameterList
);
code
=
jsonToNodeList
(
pJson
,
jkLogicCondParameters
,
&
pNode
->
pParameterList
);
...
@@ -1821,10 +1849,43 @@ static int32_t groupingSetNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -1821,10 +1849,43 @@ static int32_t groupingSetNodeToJson(const void* pObj, SJson* pJson) {
return
code
;
return
code
;
}
}
static
const
char
*
jkOrderByExprExpr
=
"Expr"
;
static
const
char
*
jkOrderByExprOrder
=
"Order"
;
static
const
char
*
jkOrderByExprNullOrder
=
"NullOrder"
;
static
int32_t
orderByExprNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SOrderByExprNode
*
pNode
=
(
const
SOrderByExprNode
*
)
pObj
;
int32_t
code
=
tjsonAddObject
(
pJson
,
jkOrderByExprExpr
,
nodeToJson
,
pNode
->
pExpr
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkOrderByExprOrder
,
pNode
->
order
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddIntegerToObject
(
pJson
,
jkOrderByExprNullOrder
,
pNode
->
nullOrder
);
}
return
code
;
}
static
int32_t
jsonToOrderByExprNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SOrderByExprNode
*
pNode
=
(
SOrderByExprNode
*
)
pObj
;
int32_t
code
=
jsonToNodeObject
(
pJson
,
jkOrderByExprExpr
,
&
pNode
->
pExpr
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetNumberValue
(
pJson
,
jkOrderByExprOrder
,
pNode
->
order
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetNumberValue
(
pJson
,
jkOrderByExprNullOrder
,
pNode
->
nullOrder
);
}
return
code
;
}
static
const
char
*
jkIntervalWindowInterval
=
"Interval"
;
static
const
char
*
jkIntervalWindowInterval
=
"Interval"
;
static
const
char
*
jkIntervalWindowOffset
=
"Offset"
;
static
const
char
*
jkIntervalWindowOffset
=
"Offset"
;
static
const
char
*
jkIntervalWindowSliding
=
"Sliding"
;
static
const
char
*
jkIntervalWindowSliding
=
"Sliding"
;
static
const
char
*
jkIntervalWindowFill
=
"Fill"
;
static
const
char
*
jkIntervalWindowFill
=
"Fill"
;
static
const
char
*
jkIntervalWindowTsPk
=
"TsPk"
;
static
int32_t
intervalWindowNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
intervalWindowNodeToJson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SIntervalWindowNode
*
pNode
=
(
const
SIntervalWindowNode
*
)
pObj
;
const
SIntervalWindowNode
*
pNode
=
(
const
SIntervalWindowNode
*
)
pObj
;
...
@@ -1839,6 +1900,9 @@ static int32_t intervalWindowNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -1839,6 +1900,9 @@ static int32_t intervalWindowNodeToJson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkIntervalWindowFill
,
nodeToJson
,
pNode
->
pFill
);
code
=
tjsonAddObject
(
pJson
,
jkIntervalWindowFill
,
nodeToJson
,
pNode
->
pFill
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkIntervalWindowTsPk
,
nodeToJson
,
pNode
->
pCol
);
}
return
code
;
return
code
;
}
}
...
@@ -1856,6 +1920,9 @@ static int32_t jsonToIntervalWindowNode(const SJson* pJson, void* pObj) {
...
@@ -1856,6 +1920,9 @@ static int32_t jsonToIntervalWindowNode(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkIntervalWindowFill
,
&
pNode
->
pFill
);
code
=
jsonToNodeObject
(
pJson
,
jkIntervalWindowFill
,
&
pNode
->
pFill
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkIntervalWindowTsPk
,
&
pNode
->
pCol
);
}
return
code
;
return
code
;
}
}
...
@@ -2033,6 +2100,7 @@ static const char* jkSelectStmtHaving = "Having";
...
@@ -2033,6 +2100,7 @@ static const char* jkSelectStmtHaving = "Having";
static
const
char
*
jkSelectStmtOrderBy
=
"OrderBy"
;
static
const
char
*
jkSelectStmtOrderBy
=
"OrderBy"
;
static
const
char
*
jkSelectStmtLimit
=
"Limit"
;
static
const
char
*
jkSelectStmtLimit
=
"Limit"
;
static
const
char
*
jkSelectStmtSlimit
=
"Slimit"
;
static
const
char
*
jkSelectStmtSlimit
=
"Slimit"
;
static
const
char
*
jkSelectStmtStmtName
=
"StmtName"
;
static
int32_t
selectStmtTojson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
static
int32_t
selectStmtTojson
(
const
void
*
pObj
,
SJson
*
pJson
)
{
const
SSelectStmt
*
pNode
=
(
const
SSelectStmt
*
)
pObj
;
const
SSelectStmt
*
pNode
=
(
const
SSelectStmt
*
)
pObj
;
...
@@ -2068,6 +2136,9 @@ static int32_t selectStmtTojson(const void* pObj, SJson* pJson) {
...
@@ -2068,6 +2136,9 @@ static int32_t selectStmtTojson(const void* pObj, SJson* pJson) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddObject
(
pJson
,
jkSelectStmtSlimit
,
nodeToJson
,
pNode
->
pSlimit
);
code
=
tjsonAddObject
(
pJson
,
jkSelectStmtSlimit
,
nodeToJson
,
pNode
->
pSlimit
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonAddStringToObject
(
pJson
,
jkSelectStmtStmtName
,
pNode
->
stmtName
);
}
return
code
;
return
code
;
}
}
...
@@ -2106,6 +2177,9 @@ static int32_t jsonToSelectStmt(const SJson* pJson, void* pObj) {
...
@@ -2106,6 +2177,9 @@ static int32_t jsonToSelectStmt(const SJson* pJson, void* pObj) {
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
jsonToNodeObject
(
pJson
,
jkSelectStmtSlimit
,
&
pNode
->
pSlimit
);
code
=
jsonToNodeObject
(
pJson
,
jkSelectStmtSlimit
,
&
pNode
->
pSlimit
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonGetStringValue
(
pJson
,
jkSelectStmtStmtName
,
pNode
->
stmtName
);
}
return
code
;
return
code
;
}
}
...
@@ -2169,6 +2243,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -2169,6 +2243,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
case
QUERY_NODE_GROUPING_SET
:
case
QUERY_NODE_GROUPING_SET
:
return
groupingSetNodeToJson
(
pObj
,
pJson
);
return
groupingSetNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_ORDER_BY_EXPR
:
case
QUERY_NODE_ORDER_BY_EXPR
:
return
orderByExprNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_LIMIT
:
case
QUERY_NODE_LIMIT
:
case
QUERY_NODE_STATE_WINDOW
:
case
QUERY_NODE_STATE_WINDOW
:
case
QUERY_NODE_SESSION_WINDOW
:
case
QUERY_NODE_SESSION_WINDOW
:
...
@@ -2232,7 +2307,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
...
@@ -2232,7 +2307,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) {
case
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
:
case
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
:
return
physiExchangeNodeToJson
(
pObj
,
pJson
);
return
physiExchangeNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_SORT
:
case
QUERY_NODE_PHYSICAL_PLAN_SORT
:
break
;
return
physiSortNodeToJson
(
pObj
,
pJson
)
;
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
physiIntervalNodeToJson
(
pObj
,
pJson
);
return
physiIntervalNodeToJson
(
pObj
,
pJson
);
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
...
@@ -2272,7 +2347,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
...
@@ -2272,7 +2347,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
// break;
// break;
// case QUERY_NODE_GROUPING_SET:
// case QUERY_NODE_GROUPING_SET:
// return jsonToGroupingSetNode(pJson, pObj);
// return jsonToGroupingSetNode(pJson, pObj);
// case QUERY_NODE_ORDER_BY_EXPR:
case
QUERY_NODE_ORDER_BY_EXPR
:
return
jsonToOrderByExprNode
(
pJson
,
pObj
);
// case QUERY_NODE_LIMIT:
// case QUERY_NODE_LIMIT:
// case QUERY_NODE_STATE_WINDOW:
// case QUERY_NODE_STATE_WINDOW:
// case QUERY_NODE_SESSION_WINDOW:
// case QUERY_NODE_SESSION_WINDOW:
...
@@ -2321,6 +2397,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
...
@@ -2321,6 +2397,8 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) {
return
jsonToPhysiAggNode
(
pJson
,
pObj
);
return
jsonToPhysiAggNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
:
case
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
:
return
jsonToPhysiExchangeNode
(
pJson
,
pObj
);
return
jsonToPhysiExchangeNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_SORT
:
return
jsonToPhysiSortNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
jsonToPhysiIntervalNode
(
pJson
,
pObj
);
return
jsonToPhysiIntervalNode
(
pJson
,
pObj
);
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
...
@@ -2362,9 +2440,7 @@ static int32_t nodeToJson(const void* pObj, SJson* pJson) {
...
@@ -2362,9 +2440,7 @@ static int32_t nodeToJson(const void* pObj, SJson* pJson) {
static
int32_t
jsonToNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
static
int32_t
jsonToNode
(
const
SJson
*
pJson
,
void
*
pObj
)
{
SNode
*
pNode
=
(
SNode
*
)
pObj
;
SNode
*
pNode
=
(
SNode
*
)
pObj
;
int32_t
val
=
0
;
int32_t
code
=
tjsonGetNumberValue
(
pJson
,
jkNodeType
,
pNode
->
type
);
int32_t
code
=
tjsonGetIntValue
(
pJson
,
jkNodeType
,
&
val
);
pNode
->
type
=
val
;
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
tjsonToObject
(
pJson
,
nodesNodeName
(
pNode
->
type
),
jsonToSpecificNode
,
pNode
);
code
=
tjsonToObject
(
pJson
,
nodesNodeName
(
pNode
->
type
),
jsonToSpecificNode
,
pNode
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
...
...
source/libs/nodes/src/nodesTraverseFuncs.c
浏览文件 @
a82fc113
...
@@ -99,6 +99,9 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker
...
@@ -99,6 +99,9 @@ static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FNodeWalker walker
if
(
DEAL_RES_ERROR
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
)
{
res
=
walkNode
(
pInterval
->
pFill
,
order
,
walker
,
pContext
);
res
=
walkNode
(
pInterval
->
pFill
,
order
,
walker
,
pContext
);
}
}
if
(
DEAL_RES_ERROR
!=
res
)
{
res
=
walkNode
(
pInterval
->
pCol
,
order
,
walker
,
pContext
);
}
break
;
break
;
}
}
case
QUERY_NODE_NODE_LIST
:
case
QUERY_NODE_NODE_LIST
:
...
@@ -225,6 +228,9 @@ static EDealRes rewriteNode(SNode** pRawNode, ETraversalOrder order, FNodeRewrit
...
@@ -225,6 +228,9 @@ static EDealRes rewriteNode(SNode** pRawNode, ETraversalOrder order, FNodeRewrit
if
(
DEAL_RES_ERROR
!=
res
)
{
if
(
DEAL_RES_ERROR
!=
res
)
{
res
=
rewriteNode
(
&
(
pInterval
->
pFill
),
order
,
rewriter
,
pContext
);
res
=
rewriteNode
(
&
(
pInterval
->
pFill
),
order
,
rewriter
,
pContext
);
}
}
if
(
DEAL_RES_ERROR
!=
res
)
{
res
=
rewriteNode
(
&
(
pInterval
->
pCol
),
order
,
rewriter
,
pContext
);
}
break
;
break
;
}
}
case
QUERY_NODE_NODE_LIST
:
case
QUERY_NODE_NODE_LIST
:
...
@@ -294,10 +300,10 @@ void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker wa
...
@@ -294,10 +300,10 @@ void nodesWalkSelectStmt(SSelectStmt* pSelect, ESqlClause clause, FNodeWalker wa
case
SQL_CLAUSE_GROUP_BY
:
case
SQL_CLAUSE_GROUP_BY
:
nodesWalkNode
(
pSelect
->
pHaving
,
walker
,
pContext
);
nodesWalkNode
(
pSelect
->
pHaving
,
walker
,
pContext
);
case
SQL_CLAUSE_HAVING
:
case
SQL_CLAUSE_HAVING
:
nodesWalkList
(
pSelect
->
pProjectionList
,
walker
,
pContext
);
case
SQL_CLAUSE_SELECT
:
nodesWalkList
(
pSelect
->
pOrderByList
,
walker
,
pContext
);
nodesWalkList
(
pSelect
->
pOrderByList
,
walker
,
pContext
);
case
SQL_CLAUSE_ORDER_BY
:
case
SQL_CLAUSE_ORDER_BY
:
nodesWalkList
(
pSelect
->
pProjectionList
,
walker
,
pContext
);
case
SQL_CLAUSE_SELECT
:
default:
default:
break
;
break
;
}
}
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
a82fc113
...
@@ -159,6 +159,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -159,6 +159,8 @@ SNodeptr nodesMakeNode(ENodeType type) {
return
makeNode
(
type
,
sizeof
(
SExchangeLogicNode
));
return
makeNode
(
type
,
sizeof
(
SExchangeLogicNode
));
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
case
QUERY_NODE_LOGIC_PLAN_WINDOW
:
return
makeNode
(
type
,
sizeof
(
SWindowLogicNode
));
return
makeNode
(
type
,
sizeof
(
SWindowLogicNode
));
case
QUERY_NODE_LOGIC_PLAN_SORT
:
return
makeNode
(
type
,
sizeof
(
SSortLogicNode
));
case
QUERY_NODE_LOGIC_SUBPLAN
:
case
QUERY_NODE_LOGIC_SUBPLAN
:
return
makeNode
(
type
,
sizeof
(
SLogicSubplan
));
return
makeNode
(
type
,
sizeof
(
SLogicSubplan
));
case
QUERY_NODE_LOGIC_PLAN
:
case
QUERY_NODE_LOGIC_PLAN
:
...
@@ -182,7 +184,7 @@ SNodeptr nodesMakeNode(ENodeType type) {
...
@@ -182,7 +184,7 @@ SNodeptr nodesMakeNode(ENodeType type) {
case
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
:
case
QUERY_NODE_PHYSICAL_PLAN_EXCHANGE
:
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
(
S
SortPhysi
Node
));
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
case
QUERY_NODE_PHYSICAL_PLAN_INTERVAL
:
return
makeNode
(
type
,
sizeof
(
SIntervalPhysiNode
));
return
makeNode
(
type
,
sizeof
(
SIntervalPhysiNode
));
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
case
QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW
:
...
@@ -555,7 +557,7 @@ static EDealRes collectColumns(SNode* pNode, void* pContext) {
...
@@ -555,7 +557,7 @@ static EDealRes collectColumns(SNode* pNode, void* pContext) {
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
if
(
QUERY_NODE_COLUMN
==
nodeType
(
pNode
))
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
pNode
;
int32_t
colId
=
pCol
->
colId
;
int32_t
colId
=
pCol
->
colId
;
if
(
0
==
strcmp
(
pCxt
->
pTableAlias
,
pCol
->
tableAlias
))
{
if
(
NULL
==
pCxt
->
pTableAlias
||
0
==
strcmp
(
pCxt
->
pTableAlias
,
pCol
->
tableAlias
))
{
return
doCollect
(
pCxt
,
colId
,
pNode
);
return
doCollect
(
pCxt
,
colId
,
pNode
);
}
}
}
}
...
...
source/libs/parser/inc/parInsertData.h
浏览文件 @
a82fc113
...
@@ -41,26 +41,26 @@ typedef struct SBoundColumn {
...
@@ -41,26 +41,26 @@ typedef struct SBoundColumn {
}
SBoundColumn
;
}
SBoundColumn
;
typedef
struct
{
typedef
struct
{
uint16
_t
schemaColIdx
;
col_id
_t
schemaColIdx
;
uint16
_t
boundIdx
;
col_id
_t
boundIdx
;
uint16
_t
finalIdx
;
col_id
_t
finalIdx
;
}
SBoundIdxInfo
;
}
SBoundIdxInfo
;
typedef
struct
SParsedDataColInfo
{
typedef
struct
SParsedDataColInfo
{
int16_t
numOfCols
;
col_id_t
numOfCols
;
int16_t
numOfBound
;
col_id_t
numOfBound
;
uint16_t
flen
;
// TODO: get from STSchema
uint16_t
flen
;
// TODO: get from STSchema
uint16_t
allNullLen
;
// TODO: get from STSchema(base on SDataRow)
uint16_t
allNullLen
;
// TODO: get from STSchema(base on SDataRow)
uint16_t
extendedVarLen
;
uint16_t
extendedVarLen
;
uint16_t
boundNullLen
;
// bound column len with all NULL value(without VarDataOffsetT/SColIdx part)
uint16_t
boundNullLen
;
// bound column len with all NULL value(without VarDataOffsetT/SColIdx part)
int32_t
*
boundedColumns
;
// bound column idx according to schema
col_id_t
*
boundColumns
;
// bound column idx according to schema
SBoundColumn
*
cols
;
SBoundColumn
*
cols
;
SBoundIdxInfo
*
colIdxInfo
;
SBoundIdxInfo
*
colIdxInfo
;
int8_t
orderStatus
;
// bound columns
int8_t
orderStatus
;
// bound columns
}
SParsedDataColInfo
;
}
SParsedDataColInfo
;
typedef
struct
{
typedef
struct
{
uint8_t
memR
owType
;
// default is 0, that is SDataRow
uint8_t
r
owType
;
// default is 0, that is SDataRow
int32_t
rowSize
;
int32_t
rowSize
;
}
SMemRowBuilder
;
}
SMemRowBuilder
;
...
@@ -92,11 +92,11 @@ static FORCE_INLINE int32_t getExtendedRowSize(STableDataBlocks *pBlock) {
...
@@ -92,11 +92,11 @@ static FORCE_INLINE int32_t getExtendedRowSize(STableDataBlocks *pBlock) {
(
int32_t
)
TD_BITMAP_BYTES
(
pTableInfo
->
numOfColumns
-
1
);
(
int32_t
)
TD_BITMAP_BYTES
(
pTableInfo
->
numOfColumns
-
1
);
}
}
static
FORCE_INLINE
void
get
MemRowAppendInfo
(
SSchema
*
pSchema
,
uint8_t
rowType
,
SParsedDataColInfo
*
spd
,
static
FORCE_INLINE
void
get
STSRowAppendInfo
(
SSchema
*
pSchema
,
uint8_t
rowType
,
SParsedDataColInfo
*
spd
,
col_id_t
idx
,
int32_t
idx
,
int32_t
*
toffset
,
int32
_t
*
colIdx
)
{
int32_t
*
toffset
,
col_id
_t
*
colIdx
)
{
int32
_t
schemaIdx
=
0
;
col_id
_t
schemaIdx
=
0
;
if
(
IS_DATA_COL_ORDERED
(
spd
))
{
if
(
IS_DATA_COL_ORDERED
(
spd
))
{
schemaIdx
=
spd
->
bound
ed
Columns
[
idx
]
-
PRIMARYKEY_TIMESTAMP_COL_ID
;
schemaIdx
=
spd
->
boundColumns
[
idx
]
-
PRIMARYKEY_TIMESTAMP_COL_ID
;
if
(
TD_IS_TP_ROW_T
(
rowType
))
{
if
(
TD_IS_TP_ROW_T
(
rowType
))
{
*
toffset
=
(
spd
->
cols
+
schemaIdx
)
->
toffset
;
// the offset of firstPart
*
toffset
=
(
spd
->
cols
+
schemaIdx
)
->
toffset
;
// the offset of firstPart
*
colIdx
=
schemaIdx
;
*
colIdx
=
schemaIdx
;
...
@@ -132,7 +132,7 @@ static FORCE_INLINE int32_t setBlockInfo(SSubmitBlk *pBlocks, STableDataBlocks*
...
@@ -132,7 +132,7 @@ static FORCE_INLINE int32_t setBlockInfo(SSubmitBlk *pBlocks, STableDataBlocks*
int32_t
schemaIdxCompar
(
const
void
*
lhs
,
const
void
*
rhs
);
int32_t
schemaIdxCompar
(
const
void
*
lhs
,
const
void
*
rhs
);
int32_t
boundIdxCompar
(
const
void
*
lhs
,
const
void
*
rhs
);
int32_t
boundIdxCompar
(
const
void
*
lhs
,
const
void
*
rhs
);
void
setBoundColumnInfo
(
SParsedDataColInfo
*
pColList
,
SSchema
*
pSchema
,
int32
_t
numOfCols
);
void
setBoundColumnInfo
(
SParsedDataColInfo
*
pColList
,
SSchema
*
pSchema
,
col_id
_t
numOfCols
);
void
destroyBoundColumnInfo
(
SParsedDataColInfo
*
pColList
);
void
destroyBoundColumnInfo
(
SParsedDataColInfo
*
pColList
);
void
destroyBlockArrayList
(
SArray
*
pDataBlockList
);
void
destroyBlockArrayList
(
SArray
*
pDataBlockList
);
void
destroyBlockHashmap
(
SHashObj
*
pDataBlockHash
);
void
destroyBlockHashmap
(
SHashObj
*
pDataBlockHash
);
...
...
source/libs/parser/inc/parUtil.h
浏览文件 @
a82fc113
...
@@ -30,6 +30,8 @@ extern "C" {
...
@@ -30,6 +30,8 @@ extern "C" {
#define parserDebug(param, ...) qDebug("PARSER: " param, __VA_ARGS__)
#define parserDebug(param, ...) qDebug("PARSER: " param, __VA_ARGS__)
#define parserTrace(param, ...) qTrace("PARSER: " param, __VA_ARGS__)
#define parserTrace(param, ...) qTrace("PARSER: " param, __VA_ARGS__)
#define PK_TS_COL_INTERNAL_NAME "_rowts"
typedef
struct
SMsgBuf
{
typedef
struct
SMsgBuf
{
int32_t
len
;
int32_t
len
;
char
*
buf
;
char
*
buf
;
...
...
source/libs/parser/src/parAstCreater.c
浏览文件 @
a82fc113
...
@@ -645,6 +645,11 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const STok
...
@@ -645,6 +645,11 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const STok
tempTable
->
pSubquery
=
pSubquery
;
tempTable
->
pSubquery
=
pSubquery
;
if
(
NULL
!=
pTableAlias
&&
TK_NK_NIL
!=
pTableAlias
->
type
)
{
if
(
NULL
!=
pTableAlias
&&
TK_NK_NIL
!=
pTableAlias
->
type
)
{
strncpy
(
tempTable
->
table
.
tableAlias
,
pTableAlias
->
z
,
pTableAlias
->
n
);
strncpy
(
tempTable
->
table
.
tableAlias
,
pTableAlias
->
z
,
pTableAlias
->
n
);
}
else
{
sprintf
(
tempTable
->
table
.
tableAlias
,
"%p"
,
tempTable
);
}
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pSubquery
))
{
strcpy
(((
SSelectStmt
*
)
pSubquery
)
->
stmtName
,
tempTable
->
table
.
tableAlias
);
}
}
return
(
SNode
*
)
tempTable
;
return
(
SNode
*
)
tempTable
;
}
}
...
@@ -697,6 +702,13 @@ SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pCol) {
...
@@ -697,6 +702,13 @@ SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pCol) {
SNode
*
createIntervalWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
,
SNode
*
pFill
)
{
SNode
*
createIntervalWindowNode
(
SAstCreateContext
*
pCxt
,
SNode
*
pInterval
,
SNode
*
pOffset
,
SNode
*
pSliding
,
SNode
*
pFill
)
{
SIntervalWindowNode
*
interval
=
(
SIntervalWindowNode
*
)
nodesMakeNode
(
QUERY_NODE_INTERVAL_WINDOW
);
SIntervalWindowNode
*
interval
=
(
SIntervalWindowNode
*
)
nodesMakeNode
(
QUERY_NODE_INTERVAL_WINDOW
);
CHECK_OUT_OF_MEM
(
interval
);
CHECK_OUT_OF_MEM
(
interval
);
interval
->
pCol
=
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
interval
->
pCol
)
{
nodesDestroyNode
(
interval
);
CHECK_OUT_OF_MEM
(
interval
->
pCol
);
}
((
SColumnNode
*
)
interval
->
pCol
)
->
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
strcpy
(((
SColumnNode
*
)
interval
->
pCol
)
->
colName
,
PK_TS_COL_INTERNAL_NAME
);
interval
->
pInterval
=
pInterval
;
interval
->
pInterval
=
pInterval
;
interval
->
pOffset
=
pOffset
;
interval
->
pOffset
=
pOffset
;
interval
->
pSliding
=
pSliding
;
interval
->
pSliding
=
pSliding
;
...
@@ -792,6 +804,7 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr
...
@@ -792,6 +804,7 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr
select
->
isDistinct
=
isDistinct
;
select
->
isDistinct
=
isDistinct
;
select
->
pProjectionList
=
pProjectionList
;
select
->
pProjectionList
=
pProjectionList
;
select
->
pFromTable
=
pTable
;
select
->
pFromTable
=
pTable
;
sprintf
(
select
->
stmtName
,
"%p"
,
select
);
return
(
SNode
*
)
select
;
return
(
SNode
*
)
select
;
}
}
...
...
source/libs/parser/src/parInsert.c
浏览文件 @
a82fc113
...
@@ -600,9 +600,9 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
...
@@ -600,9 +600,9 @@ static int32_t parseValueToken(char** end, SToken* pToken, SSchema* pSchema, int
typedef
struct
SMemParam
{
typedef
struct
SMemParam
{
SRowBuilder
*
rb
;
SRowBuilder
*
rb
;
SSchema
*
schema
;
SSchema
*
schema
;
int32_t
toffset
;
int32_t
toffset
;
int32_t
colIdx
;
col_id_t
colIdx
;
}
SMemParam
;
}
SMemParam
;
static
FORCE_INLINE
int32_t
MemRowAppend
(
const
void
*
value
,
int32_t
len
,
void
*
param
)
{
static
FORCE_INLINE
int32_t
MemRowAppend
(
const
void
*
value
,
int32_t
len
,
void
*
param
)
{
...
@@ -623,9 +623,11 @@ static FORCE_INLINE int32_t MemRowAppend(const void* value, int32_t len, void* p
...
@@ -623,9 +623,11 @@ static FORCE_INLINE int32_t MemRowAppend(const void* value, int32_t len, void* p
tdAppendColValToRow
(
rb
,
pa
->
schema
->
colId
,
pa
->
schema
->
type
,
TD_VTYPE_NORM
,
rowEnd
,
false
,
pa
->
toffset
,
pa
->
colIdx
);
tdAppendColValToRow
(
rb
,
pa
->
schema
->
colId
,
pa
->
schema
->
type
,
TD_VTYPE_NORM
,
rowEnd
,
false
,
pa
->
toffset
,
pa
->
colIdx
);
}
else
{
}
else
{
if
(
value
==
NULL
)
{
// it is a null data
if
(
value
==
NULL
)
{
// it is a null data
tdAppendColValToRow
(
rb
,
pa
->
schema
->
colId
,
pa
->
schema
->
type
,
TD_VTYPE_NULL
,
value
,
false
,
pa
->
toffset
,
pa
->
colIdx
);
tdAppendColValToRow
(
rb
,
pa
->
schema
->
colId
,
pa
->
schema
->
type
,
TD_VTYPE_NULL
,
value
,
false
,
pa
->
toffset
,
pa
->
colIdx
);
}
else
{
}
else
{
tdAppendColValToRow
(
rb
,
pa
->
schema
->
colId
,
pa
->
schema
->
type
,
TD_VTYPE_NORM
,
value
,
false
,
pa
->
toffset
,
pa
->
colIdx
);
tdAppendColValToRow
(
rb
,
pa
->
schema
->
colId
,
pa
->
schema
->
type
,
TD_VTYPE_NORM
,
value
,
false
,
pa
->
toffset
,
pa
->
colIdx
);
}
}
}
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
...
@@ -633,18 +635,18 @@ static FORCE_INLINE int32_t MemRowAppend(const void* value, int32_t len, void* p
...
@@ -633,18 +635,18 @@ static FORCE_INLINE int32_t MemRowAppend(const void* value, int32_t len, void* p
// pSql -> tag1_name, ...)
// pSql -> tag1_name, ...)
static
int32_t
parseBoundColumns
(
SInsertParseContext
*
pCxt
,
SParsedDataColInfo
*
pColList
,
SSchema
*
pSchema
)
{
static
int32_t
parseBoundColumns
(
SInsertParseContext
*
pCxt
,
SParsedDataColInfo
*
pColList
,
SSchema
*
pSchema
)
{
int32
_t
nCols
=
pColList
->
numOfCols
;
col_id
_t
nCols
=
pColList
->
numOfCols
;
pColList
->
numOfBound
=
0
;
pColList
->
numOfBound
=
0
;
pColList
->
boundNullLen
=
0
;
pColList
->
boundNullLen
=
0
;
memset
(
pColList
->
bound
edColumns
,
0
,
sizeof
(
int32
_t
)
*
nCols
);
memset
(
pColList
->
bound
Columns
,
0
,
sizeof
(
col_id
_t
)
*
nCols
);
for
(
int32
_t
i
=
0
;
i
<
nCols
;
++
i
)
{
for
(
col_id
_t
i
=
0
;
i
<
nCols
;
++
i
)
{
pColList
->
cols
[
i
].
valStat
=
VAL_STAT_NONE
;
pColList
->
cols
[
i
].
valStat
=
VAL_STAT_NONE
;
}
}
SToken
sToken
;
SToken
sToken
;
bool
isOrdered
=
true
;
bool
isOrdered
=
true
;
int32
_t
lastColIdx
=
-
1
;
// last column found
col_id
_t
lastColIdx
=
-
1
;
// last column found
while
(
1
)
{
while
(
1
)
{
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
NEXT_TOKEN
(
pCxt
->
pSql
,
sToken
);
...
@@ -652,8 +654,8 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
...
@@ -652,8 +654,8 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
break
;
break
;
}
}
int32
_t
t
=
lastColIdx
+
1
;
col_id
_t
t
=
lastColIdx
+
1
;
int32
_t
index
=
findCol
(
&
sToken
,
t
,
nCols
,
pSchema
);
col_id
_t
index
=
findCol
(
&
sToken
,
t
,
nCols
,
pSchema
);
if
(
index
<
0
&&
t
>
0
)
{
if
(
index
<
0
&&
t
>
0
)
{
index
=
findCol
(
&
sToken
,
0
,
t
,
pSchema
);
index
=
findCol
(
&
sToken
,
0
,
t
,
pSchema
);
isOrdered
=
false
;
isOrdered
=
false
;
...
@@ -666,7 +668,7 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
...
@@ -666,7 +668,7 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
}
}
lastColIdx
=
index
;
lastColIdx
=
index
;
pColList
->
cols
[
index
].
valStat
=
VAL_STAT_HAS
;
pColList
->
cols
[
index
].
valStat
=
VAL_STAT_HAS
;
pColList
->
bound
ed
Columns
[
pColList
->
numOfBound
]
=
index
+
PRIMARYKEY_TIMESTAMP_COL_ID
;
pColList
->
boundColumns
[
pColList
->
numOfBound
]
=
index
+
PRIMARYKEY_TIMESTAMP_COL_ID
;
++
pColList
->
numOfBound
;
++
pColList
->
numOfBound
;
switch
(
pSchema
[
t
].
type
)
{
switch
(
pSchema
[
t
].
type
)
{
case
TSDB_DATA_TYPE_BINARY
:
case
TSDB_DATA_TYPE_BINARY
:
...
@@ -689,18 +691,19 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
...
@@ -689,18 +691,19 @@ static int32_t parseBoundColumns(SInsertParseContext* pCxt, SParsedDataColInfo*
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
return
TSDB_CODE_TSC_OUT_OF_MEMORY
;
}
}
SBoundIdxInfo
*
pColIdx
=
pColList
->
colIdxInfo
;
SBoundIdxInfo
*
pColIdx
=
pColList
->
colIdxInfo
;
for
(
uint16
_t
i
=
0
;
i
<
pColList
->
numOfBound
;
++
i
)
{
for
(
col_id
_t
i
=
0
;
i
<
pColList
->
numOfBound
;
++
i
)
{
pColIdx
[
i
].
schemaColIdx
=
(
uint16_t
)
pColList
->
bounde
dColumns
[
i
];
pColIdx
[
i
].
schemaColIdx
=
pColList
->
boun
dColumns
[
i
];
pColIdx
[
i
].
boundIdx
=
i
;
pColIdx
[
i
].
boundIdx
=
i
;
}
}
qsort
(
pColIdx
,
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
schemaIdxCompar
);
qsort
(
pColIdx
,
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
schemaIdxCompar
);
for
(
uint16
_t
i
=
0
;
i
<
pColList
->
numOfBound
;
++
i
)
{
for
(
col_id
_t
i
=
0
;
i
<
pColList
->
numOfBound
;
++
i
)
{
pColIdx
[
i
].
finalIdx
=
i
;
pColIdx
[
i
].
finalIdx
=
i
;
}
}
qsort
(
pColIdx
,
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
boundIdxCompar
);
qsort
(
pColIdx
,
pColList
->
numOfBound
,
sizeof
(
SBoundIdxInfo
),
boundIdxCompar
);
}
}
memset
(
&
pColList
->
boundedColumns
[
pColList
->
numOfBound
],
0
,
sizeof
(
int32_t
)
*
(
pColList
->
numOfCols
-
pColList
->
numOfBound
));
memset
(
&
pColList
->
boundColumns
[
pColList
->
numOfBound
],
0
,
sizeof
(
col_id_t
)
*
(
pColList
->
numOfCols
-
pColList
->
numOfBound
));
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
@@ -714,8 +717,8 @@ typedef struct SKvParam {
...
@@ -714,8 +717,8 @@ typedef struct SKvParam {
static
int32_t
KvRowAppend
(
const
void
*
value
,
int32_t
len
,
void
*
param
)
{
static
int32_t
KvRowAppend
(
const
void
*
value
,
int32_t
len
,
void
*
param
)
{
SKvParam
*
pa
=
(
SKvParam
*
)
param
;
SKvParam
*
pa
=
(
SKvParam
*
)
param
;
int
32_t
type
=
pa
->
schema
->
type
;
int
8_t
type
=
pa
->
schema
->
type
;
int
32
_t
colId
=
pa
->
schema
->
colId
;
int
16
_t
colId
=
pa
->
schema
->
colId
;
if
(
TSDB_DATA_TYPE_BINARY
==
type
)
{
if
(
TSDB_DATA_TYPE_BINARY
==
type
)
{
STR_WITH_SIZE_TO_VARSTR
(
pa
->
buf
,
value
,
len
);
STR_WITH_SIZE_TO_VARSTR
(
pa
->
buf
,
value
,
len
);
...
@@ -747,7 +750,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pTagsSchema,
...
@@ -747,7 +750,7 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pTagsSchema,
char
tmpTokenBuf
[
TSDB_MAX_BYTES_PER_ROW
]
=
{
0
};
// used for deleting Escape character: \\, \', \"
char
tmpTokenBuf
[
TSDB_MAX_BYTES_PER_ROW
]
=
{
0
};
// used for deleting Escape character: \\, \', \"
for
(
int
i
=
0
;
i
<
pCxt
->
tags
.
numOfBound
;
++
i
)
{
for
(
int
i
=
0
;
i
<
pCxt
->
tags
.
numOfBound
;
++
i
)
{
NEXT_TOKEN_WITH_PREV
(
pCxt
->
pSql
,
sToken
);
NEXT_TOKEN_WITH_PREV
(
pCxt
->
pSql
,
sToken
);
SSchema
*
pSchema
=
&
pTagsSchema
[
pCxt
->
tags
.
bound
ed
Columns
[
i
]];
SSchema
*
pSchema
=
&
pTagsSchema
[
pCxt
->
tags
.
boundColumns
[
i
]];
param
.
schema
=
pSchema
;
param
.
schema
=
pSchema
;
CHECK_CODE
(
parseValueToken
(
&
pCxt
->
pSql
,
&
sToken
,
pSchema
,
precision
,
tmpTokenBuf
,
KvRowAppend
,
&
param
,
&
pCxt
->
msg
));
CHECK_CODE
(
parseValueToken
(
&
pCxt
->
pSql
,
&
sToken
,
pSchema
,
precision
,
tmpTokenBuf
,
KvRowAppend
,
&
param
,
&
pCxt
->
msg
));
}
}
...
@@ -813,9 +816,9 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks,
...
@@ -813,9 +816,9 @@ static int parseOneRow(SInsertParseContext* pCxt, STableDataBlocks* pDataBlocks,
// 1. set the parsed value from sql string
// 1. set the parsed value from sql string
for
(
int
i
=
0
;
i
<
spd
->
numOfBound
;
++
i
)
{
for
(
int
i
=
0
;
i
<
spd
->
numOfBound
;
++
i
)
{
NEXT_TOKEN_WITH_PREV
(
pCxt
->
pSql
,
sToken
);
NEXT_TOKEN_WITH_PREV
(
pCxt
->
pSql
,
sToken
);
SSchema
*
pSchema
=
&
schema
[
spd
->
bounde
dColumns
[
i
]
-
1
];
SSchema
*
pSchema
=
&
schema
[
spd
->
boun
dColumns
[
i
]
-
1
];
param
.
schema
=
pSchema
;
param
.
schema
=
pSchema
;
get
Mem
RowAppendInfo
(
schema
,
pBuilder
->
rowType
,
spd
,
i
,
&
param
.
toffset
,
&
param
.
colIdx
);
get
STS
RowAppendInfo
(
schema
,
pBuilder
->
rowType
,
spd
,
i
,
&
param
.
toffset
,
&
param
.
colIdx
);
CHECK_CODE
(
parseValueToken
(
&
pCxt
->
pSql
,
&
sToken
,
pSchema
,
timePrec
,
tmpTokenBuf
,
MemRowAppend
,
&
param
,
&
pCxt
->
msg
));
CHECK_CODE
(
parseValueToken
(
&
pCxt
->
pSql
,
&
sToken
,
pSchema
,
timePrec
,
tmpTokenBuf
,
MemRowAppend
,
&
param
,
&
pCxt
->
msg
));
if
(
PRIMARYKEY_TIMESTAMP_COL_ID
==
pSchema
->
colId
)
{
if
(
PRIMARYKEY_TIMESTAMP_COL_ID
==
pSchema
->
colId
)
{
...
...
source/libs/parser/src/parInsertData.c
浏览文件 @
a82fc113
...
@@ -43,11 +43,11 @@ static int32_t rowDataCompar(const void *lhs, const void *rhs) {
...
@@ -43,11 +43,11 @@ static int32_t rowDataCompar(const void *lhs, const void *rhs) {
}
}
}
}
void
setBoundColumnInfo
(
SParsedDataColInfo
*
pColList
,
SSchema
*
pSchema
,
int32
_t
numOfCols
)
{
void
setBoundColumnInfo
(
SParsedDataColInfo
*
pColList
,
SSchema
*
pSchema
,
col_id
_t
numOfCols
)
{
pColList
->
numOfCols
=
numOfCols
;
pColList
->
numOfCols
=
numOfCols
;
pColList
->
numOfBound
=
numOfCols
;
pColList
->
numOfBound
=
numOfCols
;
pColList
->
orderStatus
=
ORDER_STATUS_ORDERED
;
// default is ORDERED for non-bound mode
pColList
->
orderStatus
=
ORDER_STATUS_ORDERED
;
// default is ORDERED for non-bound mode
pColList
->
bound
edColumns
=
taosMemoryCalloc
(
pColList
->
numOfCols
,
sizeof
(
int32
_t
));
pColList
->
bound
Columns
=
taosMemoryCalloc
(
pColList
->
numOfCols
,
sizeof
(
col_id
_t
));
pColList
->
cols
=
taosMemoryCalloc
(
pColList
->
numOfCols
,
sizeof
(
SBoundColumn
));
pColList
->
cols
=
taosMemoryCalloc
(
pColList
->
numOfCols
,
sizeof
(
SBoundColumn
));
pColList
->
colIdxInfo
=
NULL
;
pColList
->
colIdxInfo
=
NULL
;
pColList
->
flen
=
0
;
pColList
->
flen
=
0
;
...
@@ -73,7 +73,7 @@ void setBoundColumnInfo(SParsedDataColInfo* pColList, SSchema* pSchema, int32_t
...
@@ -73,7 +73,7 @@ void setBoundColumnInfo(SParsedDataColInfo* pColList, SSchema* pSchema, int32_t
default:
default:
break
;
break
;
}
}
pColList
->
bound
ed
Columns
[
i
]
=
pSchema
[
i
].
colId
;
pColList
->
boundColumns
[
i
]
=
pSchema
[
i
].
colId
;
}
}
pColList
->
allNullLen
+=
pColList
->
flen
;
pColList
->
allNullLen
+=
pColList
->
flen
;
pColList
->
boundNullLen
=
pColList
->
allNullLen
;
// default set allNullLen
pColList
->
boundNullLen
=
pColList
->
allNullLen
;
// default set allNullLen
...
@@ -103,7 +103,7 @@ int32_t boundIdxCompar(const void *lhs, const void *rhs) {
...
@@ -103,7 +103,7 @@ int32_t boundIdxCompar(const void *lhs, const void *rhs) {
}
}
void
destroyBoundColumnInfo
(
SParsedDataColInfo
*
pColList
)
{
void
destroyBoundColumnInfo
(
SParsedDataColInfo
*
pColList
)
{
taosMemoryFreeClear
(
pColList
->
bound
ed
Columns
);
taosMemoryFreeClear
(
pColList
->
boundColumns
);
taosMemoryFreeClear
(
pColList
->
cols
);
taosMemoryFreeClear
(
pColList
->
cols
);
taosMemoryFreeClear
(
pColList
->
colIdxInfo
);
taosMemoryFreeClear
(
pColList
->
colIdxInfo
);
}
}
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
a82fc113
...
@@ -271,6 +271,10 @@ static bool findAndSetColumn(SColumnNode* pCol, const STableNode* pTable) {
...
@@ -271,6 +271,10 @@ static bool findAndSetColumn(SColumnNode* pCol, const STableNode* pTable) {
bool
found
=
false
;
bool
found
=
false
;
if
(
QUERY_NODE_REAL_TABLE
==
nodeType
(
pTable
))
{
if
(
QUERY_NODE_REAL_TABLE
==
nodeType
(
pTable
))
{
const
STableMeta
*
pMeta
=
((
SRealTableNode
*
)
pTable
)
->
pMeta
;
const
STableMeta
*
pMeta
=
((
SRealTableNode
*
)
pTable
)
->
pMeta
;
if
(
PRIMARYKEY_TIMESTAMP_COL_ID
==
pCol
->
colId
&&
0
==
strcmp
(
pCol
->
colName
,
PK_TS_COL_INTERNAL_NAME
))
{
setColumnInfoBySchema
((
SRealTableNode
*
)
pTable
,
pMeta
->
schema
,
false
,
pCol
);
return
true
;
}
int32_t
nums
=
pMeta
->
tableInfo
.
numOfTags
+
pMeta
->
tableInfo
.
numOfColumns
;
int32_t
nums
=
pMeta
->
tableInfo
.
numOfTags
+
pMeta
->
tableInfo
.
numOfColumns
;
for
(
int32_t
i
=
0
;
i
<
nums
;
++
i
)
{
for
(
int32_t
i
=
0
;
i
<
nums
;
++
i
)
{
if
(
0
==
strcmp
(
pCol
->
colName
,
pMeta
->
schema
[
i
].
name
))
{
if
(
0
==
strcmp
(
pCol
->
colName
,
pMeta
->
schema
[
i
].
name
))
{
...
@@ -1448,6 +1452,7 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS
...
@@ -1448,6 +1452,7 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS
if
(
NULL
==
pSelect
)
{
if
(
NULL
==
pSelect
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
sprintf
(
pSelect
->
stmtName
,
"%p"
,
pSelect
);
SRealTableNode
*
pTable
=
nodesMakeNode
(
QUERY_NODE_REAL_TABLE
);
SRealTableNode
*
pTable
=
nodesMakeNode
(
QUERY_NODE_REAL_TABLE
);
if
(
NULL
==
pTable
)
{
if
(
NULL
==
pTable
)
{
...
@@ -1463,6 +1468,10 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS
...
@@ -1463,6 +1468,10 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS
nodesDestroyNode
(
pSelect
);
nodesDestroyNode
(
pSelect
);
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
SNode
*
pProject
=
NULL
;
FOREACH
(
pProject
,
pSelect
->
pProjectionList
)
{
sprintf
(((
SExprNode
*
)
pProject
)
->
aliasName
,
"#sma_%p"
,
pProject
);
}
SIntervalWindowNode
*
pInterval
=
nodesMakeNode
(
QUERY_NODE_INTERVAL_WINDOW
);
SIntervalWindowNode
*
pInterval
=
nodesMakeNode
(
QUERY_NODE_INTERVAL_WINDOW
);
if
(
NULL
==
pInterval
)
{
if
(
NULL
==
pInterval
)
{
...
@@ -1470,14 +1479,18 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS
...
@@ -1470,14 +1479,18 @@ static int32_t getSmaIndexBuildAst(STranslateContext* pCxt, SCreateIndexStmt* pS
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
pSelect
->
pWindow
=
(
SNode
*
)
pInterval
;
pSelect
->
pWindow
=
(
SNode
*
)
pInterval
;
pInterval
->
pCol
=
nodesMakeNode
(
QUERY_NODE_COLUMN
);
pInterval
->
pInterval
=
nodesCloneNode
(
pStmt
->
pOptions
->
pInterval
);
pInterval
->
pInterval
=
nodesCloneNode
(
pStmt
->
pOptions
->
pInterval
);
pInterval
->
pOffset
=
nodesCloneNode
(
pStmt
->
pOptions
->
pOffset
);
pInterval
->
pOffset
=
nodesCloneNode
(
pStmt
->
pOptions
->
pOffset
);
pInterval
->
pSliding
=
nodesCloneNode
(
pStmt
->
pOptions
->
pSliding
);
pInterval
->
pSliding
=
nodesCloneNode
(
pStmt
->
pOptions
->
pSliding
);
if
(
NULL
==
pInterval
->
pInterval
||
(
NULL
!=
pStmt
->
pOptions
->
pOffset
&&
NULL
==
pInterval
->
pOffset
)
||
if
(
NULL
==
pInterval
->
pCol
||
NULL
==
pInterval
->
pInterval
||
(
NULL
!=
pStmt
->
pOptions
->
pOffset
&&
NULL
==
pInterval
->
pOffset
)
||
(
NULL
!=
pStmt
->
pOptions
->
pSliding
&&
NULL
==
pInterval
->
pSliding
))
{
(
NULL
!=
pStmt
->
pOptions
->
pSliding
&&
NULL
==
pInterval
->
pSliding
))
{
nodesDestroyNode
(
pSelect
);
nodesDestroyNode
(
pSelect
);
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
((
SColumnNode
*
)
pInterval
->
pCol
)
->
colId
=
PRIMARYKEY_TIMESTAMP_COL_ID
;
strcpy
(((
SColumnNode
*
)
pInterval
->
pCol
)
->
colName
,
PK_TS_COL_INTERNAL_NAME
);
int32_t
code
=
translateQuery
(
pCxt
,
(
SNode
*
)
pSelect
);
int32_t
code
=
translateQuery
(
pCxt
,
(
SNode
*
)
pSelect
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -1787,7 +1800,7 @@ static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) {
...
@@ -1787,7 +1800,7 @@ static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) {
}
}
int32_t
qExtractResultSchema
(
const
SNode
*
pRoot
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
)
{
int32_t
qExtractResultSchema
(
const
SNode
*
pRoot
,
int32_t
*
numOfCols
,
SSchema
**
pSchema
)
{
if
(
QUERY_NODE_SELECT_STMT
==
nodeType
(
pRoot
))
{
if
(
NULL
!=
pRoot
&&
QUERY_NODE_SELECT_STMT
==
nodeType
(
pRoot
))
{
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pRoot
;
SSelectStmt
*
pSelect
=
(
SSelectStmt
*
)
pRoot
;
*
numOfCols
=
LIST_LENGTH
(
pSelect
->
pProjectionList
);
*
numOfCols
=
LIST_LENGTH
(
pSelect
->
pProjectionList
);
*
pSchema
=
taosMemoryCalloc
((
*
numOfCols
),
sizeof
(
SSchema
));
*
pSchema
=
taosMemoryCalloc
((
*
numOfCols
),
sizeof
(
SSchema
));
...
@@ -1865,6 +1878,7 @@ static int32_t createSelectStmtForShow(ENodeType showType, SSelectStmt** pStmt)
...
@@ -1865,6 +1878,7 @@ static int32_t createSelectStmtForShow(ENodeType showType, SSelectStmt** pStmt)
if
(
NULL
==
pSelect
)
{
if
(
NULL
==
pSelect
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
sprintf
(
pSelect
->
stmtName
,
"%p"
,
pSelect
);
SRealTableNode
*
pTable
=
nodesMakeNode
(
QUERY_NODE_REAL_TABLE
);
SRealTableNode
*
pTable
=
nodesMakeNode
(
QUERY_NODE_REAL_TABLE
);
if
(
NULL
==
pTable
)
{
if
(
NULL
==
pTable
)
{
...
@@ -1873,6 +1887,7 @@ static int32_t createSelectStmtForShow(ENodeType showType, SSelectStmt** pStmt)
...
@@ -1873,6 +1887,7 @@ static int32_t createSelectStmtForShow(ENodeType showType, SSelectStmt** pStmt)
}
}
strcpy
(
pTable
->
table
.
dbName
,
TSDB_INFORMATION_SCHEMA_DB
);
strcpy
(
pTable
->
table
.
dbName
,
TSDB_INFORMATION_SCHEMA_DB
);
strcpy
(
pTable
->
table
.
tableName
,
getSysTableName
(
showType
));
strcpy
(
pTable
->
table
.
tableName
,
getSysTableName
(
showType
));
strcpy
(
pTable
->
table
.
tableAlias
,
pTable
->
table
.
tableName
);
pSelect
->
pFromTable
=
(
SNode
*
)
pTable
;
pSelect
->
pFromTable
=
(
SNode
*
)
pTable
;
*
pStmt
=
pSelect
;
*
pStmt
=
pSelect
;
...
@@ -1975,7 +1990,7 @@ typedef struct SVgroupTablesBatch {
...
@@ -1975,7 +1990,7 @@ typedef struct SVgroupTablesBatch {
char
dbName
[
TSDB_DB_NAME_LEN
];
char
dbName
[
TSDB_DB_NAME_LEN
];
}
SVgroupTablesBatch
;
}
SVgroupTablesBatch
;
static
void
toSchema
(
const
SColumnDefNode
*
pCol
,
int32
_t
colId
,
SSchema
*
pSchema
)
{
static
void
toSchema
(
const
SColumnDefNode
*
pCol
,
col_id
_t
colId
,
SSchema
*
pSchema
)
{
pSchema
->
colId
=
colId
;
pSchema
->
colId
=
colId
;
pSchema
->
type
=
pCol
->
dataType
.
type
;
pSchema
->
type
=
pCol
->
dataType
.
type
;
pSchema
->
bytes
=
pCol
->
dataType
.
bytes
;
pSchema
->
bytes
=
pCol
->
dataType
.
bytes
;
...
@@ -2385,13 +2400,14 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
...
@@ -2385,13 +2400,14 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) {
}
}
static
int32_t
setQuery
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
static
int32_t
setQuery
(
STranslateContext
*
pCxt
,
SQuery
*
pQuery
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
switch
(
nodeType
(
pQuery
->
pRoot
))
{
switch
(
nodeType
(
pQuery
->
pRoot
))
{
case
QUERY_NODE_SELECT_STMT
:
case
QUERY_NODE_SELECT_STMT
:
pQuery
->
haveResultSet
=
true
;
pQuery
->
haveResultSet
=
true
;
pQuery
->
directRpc
=
false
;
pQuery
->
directRpc
=
false
;
pQuery
->
msgType
=
TDMT_VND_QUERY
;
pQuery
->
msgType
=
TDMT_VND_QUERY
;
code
=
qExtractResultSchema
(
pQuery
->
pRoot
,
&
pQuery
->
numOfResCols
,
&
pQuery
->
pResSchema
);
if
(
TSDB_CODE_SUCCESS
!=
qExtractResultSchema
(
pQuery
->
pRoot
,
&
pQuery
->
numOfResCols
,
&
pQuery
->
pResSchema
))
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
break
;
break
;
case
QUERY_NODE_VNODE_MODIF_STMT
:
case
QUERY_NODE_VNODE_MODIF_STMT
:
pQuery
->
haveResultSet
=
false
;
pQuery
->
haveResultSet
=
false
;
...
@@ -2431,7 +2447,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
...
@@ -2431,7 +2447,7 @@ static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery) {
}
}
}
}
return
code
;
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
doTranslate
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
)
{
int32_t
doTranslate
(
SParseContext
*
pParseCxt
,
SQuery
*
pQuery
)
{
...
...
source/libs/parser/test/mockCatalogService.cpp
浏览文件 @
a82fc113
...
@@ -87,7 +87,7 @@ private:
...
@@ -87,7 +87,7 @@ private:
return
meta_
;
return
meta_
;
}
}
int32_t
colId_
;
col_id_t
colId_
;
int32_t
rowsize_
;
int32_t
rowsize_
;
std
::
shared_ptr
<
MockTableMeta
>
meta_
;
std
::
shared_ptr
<
MockTableMeta
>
meta_
;
};
};
...
...
source/libs/planner/inc/planInt.h
浏览文件 @
a82fc113
...
@@ -22,32 +22,6 @@ extern "C" {
...
@@ -22,32 +22,6 @@ extern "C" {
#include "planner.h"
#include "planner.h"
#define CHECK_ALLOC(p, res) \
do { \
if (NULL == (p)) { \
pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; \
return (res); \
} \
} while (0)
#define CHECK_CODE(exec, res) \
do { \
int32_t code = (exec); \
if (TSDB_CODE_SUCCESS != code) { \
pCxt->errCode = code; \
return (res); \
} \
} while (0)
#define CHECK_CODE_EXT(exec) \
do { \
int32_t code = (exec); \
if (TSDB_CODE_SUCCESS != code) { \
pCxt->errCode = code; \
return code; \
} \
} while (0)
#define planFatal(param, ...) qFatal("PLAN: " param, __VA_ARGS__)
#define planFatal(param, ...) qFatal("PLAN: " param, __VA_ARGS__)
#define planError(param, ...) qError("PLAN: " param, __VA_ARGS__)
#define planError(param, ...) qError("PLAN: " param, __VA_ARGS__)
#define planWarn(param, ...) qWarn("PLAN: " param, __VA_ARGS__)
#define planWarn(param, ...) qWarn("PLAN: " param, __VA_ARGS__)
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
a82fc113
...
@@ -45,7 +45,9 @@ static EDealRes doRewriteExpr(SNode** pNode, void* pContext) {
...
@@ -45,7 +45,9 @@ static EDealRes doRewriteExpr(SNode** pNode, void* pContext) {
}
}
if
(
nodesEqualNode
(
pExpr
,
*
pNode
))
{
if
(
nodesEqualNode
(
pExpr
,
*
pNode
))
{
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
CHECK_ALLOC
(
pCol
,
DEAL_RES_ERROR
);
if
(
NULL
==
pCol
)
{
return
DEAL_RES_ERROR
;
}
SExprNode
*
pToBeRewrittenExpr
=
(
SExprNode
*
)(
*
pNode
);
SExprNode
*
pToBeRewrittenExpr
=
(
SExprNode
*
)(
*
pNode
);
pCol
->
node
.
resType
=
pToBeRewrittenExpr
->
resType
;
pCol
->
node
.
resType
=
pToBeRewrittenExpr
->
resType
;
strcpy
(
pCol
->
node
.
aliasName
,
pToBeRewrittenExpr
->
aliasName
);
strcpy
(
pCol
->
node
.
aliasName
,
pToBeRewrittenExpr
->
aliasName
);
...
@@ -65,17 +67,12 @@ static EDealRes doRewriteExpr(SNode** pNode, void* pContext) {
...
@@ -65,17 +67,12 @@ static EDealRes doRewriteExpr(SNode** pNode, void* pContext) {
return
DEAL_RES_CONTINUE
;
return
DEAL_RES_CONTINUE
;
}
}
typedef
struct
SNameExprCxt
{
int32_t
rewriteId
;
}
SNameExprCxt
;
static
EDealRes
doNameExpr
(
SNode
*
pNode
,
void
*
pContext
)
{
static
EDealRes
doNameExpr
(
SNode
*
pNode
,
void
*
pContext
)
{
switch
(
nodeType
(
pNode
))
{
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_OPERATOR
:
case
QUERY_NODE_OPERATOR
:
case
QUERY_NODE_LOGIC_CONDITION
:
case
QUERY_NODE_LOGIC_CONDITION
:
case
QUERY_NODE_FUNCTION
:
{
case
QUERY_NODE_FUNCTION
:
{
SNameExprCxt
*
pCxt
=
(
SNameExprCxt
*
)
pContext
;
sprintf
(((
SExprNode
*
)
pNode
)
->
aliasName
,
"#expr_%p"
,
pNode
);
sprintf
(((
SExprNode
*
)
pNode
)
->
aliasName
,
"#expr_%d"
,
pCxt
->
rewriteId
++
);
return
DEAL_RES_IGNORE_CHILD
;
return
DEAL_RES_IGNORE_CHILD
;
}
}
default:
default:
...
@@ -86,9 +83,7 @@ static EDealRes doNameExpr(SNode* pNode, void* pContext) {
...
@@ -86,9 +83,7 @@ static EDealRes doNameExpr(SNode* pNode, void* pContext) {
}
}
static
int32_t
rewriteExpr
(
SNodeList
*
pExprs
,
SSelectStmt
*
pSelect
,
ESqlClause
clause
)
{
static
int32_t
rewriteExpr
(
SNodeList
*
pExprs
,
SSelectStmt
*
pSelect
,
ESqlClause
clause
)
{
static
int32_t
rewriteId
=
1
;
nodesWalkList
(
pExprs
,
doNameExpr
,
NULL
);
SNameExprCxt
nameCxt
=
{
.
rewriteId
=
rewriteId
};
nodesWalkList
(
pExprs
,
doNameExpr
,
&
nameCxt
);
SRewriteExprCxt
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
pExprs
=
pExprs
};
SRewriteExprCxt
cxt
=
{
.
errCode
=
TSDB_CODE_SUCCESS
,
.
pExprs
=
pExprs
};
nodesRewriteSelectStmt
(
pSelect
,
clause
,
doRewriteExpr
,
&
cxt
);
nodesRewriteSelectStmt
(
pSelect
,
clause
,
doRewriteExpr
,
&
cxt
);
return
cxt
.
errCode
;
return
cxt
.
errCode
;
...
@@ -291,13 +286,14 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel
...
@@ -291,13 +286,14 @@ static int32_t createLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pSel
return
code
;
return
code
;
}
}
static
SColumnNode
*
createColumnByExpr
(
SExprNode
*
pExpr
)
{
static
SColumnNode
*
createColumnByExpr
(
const
char
*
pStmtName
,
SExprNode
*
pExpr
)
{
SColumnNode
*
pCol
=
nodesMakeNode
(
QUERY_NODE_COLUMN
);
SColumnNode
*
pCol
=
nodesMakeNode
(
QUERY_NODE_COLUMN
);
if
(
NULL
==
pCol
)
{
if
(
NULL
==
pCol
)
{
return
NULL
;
return
NULL
;
}
}
pCol
->
node
.
resType
=
pExpr
->
resType
;
pCol
->
node
.
resType
=
pExpr
->
resType
;
strcpy
(
pCol
->
colName
,
pExpr
->
aliasName
);
strcpy
(
pCol
->
colName
,
pExpr
->
aliasName
);
strcpy
(
pCol
->
tableAlias
,
pStmtName
);
return
pCol
;
return
pCol
;
}
}
...
@@ -311,20 +307,22 @@ static EDealRes doCreateColumn(SNode* pNode, void* pContext) {
...
@@ -311,20 +307,22 @@ static EDealRes doCreateColumn(SNode* pNode, void* pContext) {
switch
(
nodeType
(
pNode
))
{
switch
(
nodeType
(
pNode
))
{
case
QUERY_NODE_COLUMN
:
{
case
QUERY_NODE_COLUMN
:
{
SNode
*
pCol
=
nodesCloneNode
(
pNode
);
SNode
*
pCol
=
nodesCloneNode
(
pNode
);
CHECK_ALLOC
(
pCol
,
DEAL_RES_ERROR
);
if
(
NULL
==
pCol
)
{
CHECK_CODE
(
nodesListAppend
(
pCxt
->
pList
,
pCol
),
DEAL_RES_ERROR
);
return
DEAL_RES_ERROR
;
return
DEAL_RES_IGNORE_CHILD
;
}
return
(
TSDB_CODE_SUCCESS
==
nodesListAppend
(
pCxt
->
pList
,
pCol
)
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
);
}
}
case
QUERY_NODE_OPERATOR
:
case
QUERY_NODE_OPERATOR
:
case
QUERY_NODE_LOGIC_CONDITION
:
case
QUERY_NODE_LOGIC_CONDITION
:
case
QUERY_NODE_FUNCTION
:
{
case
QUERY_NODE_FUNCTION
:
{
SExprNode
*
pExpr
=
(
SExprNode
*
)
pNode
;
SExprNode
*
pExpr
=
(
SExprNode
*
)
pNode
;
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
SColumnNode
*
pCol
=
(
SColumnNode
*
)
nodesMakeNode
(
QUERY_NODE_COLUMN
);
CHECK_ALLOC
(
pCol
,
DEAL_RES_ERROR
);
if
(
NULL
==
pCol
)
{
return
DEAL_RES_ERROR
;
}
pCol
->
node
.
resType
=
pExpr
->
resType
;
pCol
->
node
.
resType
=
pExpr
->
resType
;
strcpy
(
pCol
->
colName
,
pExpr
->
aliasName
);
strcpy
(
pCol
->
colName
,
pExpr
->
aliasName
);
CHECK_CODE
(
nodesListAppend
(
pCxt
->
pList
,
(
SNode
*
)
pCol
),
DEAL_RES_ERROR
);
return
(
TSDB_CODE_SUCCESS
==
nodesListAppend
(
pCxt
->
pList
,
pCol
)
?
DEAL_RES_IGNORE_CHILD
:
DEAL_RES_ERROR
);
return
DEAL_RES_IGNORE_CHILD
;
}
}
default:
default:
break
;
break
;
...
@@ -457,6 +455,12 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva
...
@@ -457,6 +455,12 @@ static int32_t createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInterva
pWindow
->
sliding
=
(
NULL
!=
pInterval
->
pSliding
?
((
SValueNode
*
)
pInterval
->
pSliding
)
->
datum
.
i
:
pWindow
->
interval
);
pWindow
->
sliding
=
(
NULL
!=
pInterval
->
pSliding
?
((
SValueNode
*
)
pInterval
->
pSliding
)
->
datum
.
i
:
pWindow
->
interval
);
pWindow
->
slidingUnit
=
(
NULL
!=
pInterval
->
pSliding
?
((
SValueNode
*
)
pInterval
->
pSliding
)
->
unit
:
pWindow
->
intervalUnit
);
pWindow
->
slidingUnit
=
(
NULL
!=
pInterval
->
pSliding
?
((
SValueNode
*
)
pInterval
->
pSliding
)
->
unit
:
pWindow
->
intervalUnit
);
pWindow
->
pTspk
=
nodesCloneNode
(
pInterval
->
pCol
);
if
(
NULL
==
pWindow
->
pTspk
)
{
nodesDestroyNode
(
pWindow
);
return
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
NULL
!=
pInterval
->
pFill
)
{
if
(
NULL
!=
pInterval
->
pFill
)
{
pWindow
->
pFill
=
nodesCloneNode
(
pInterval
->
pFill
);
pWindow
->
pFill
=
nodesCloneNode
(
pInterval
->
pFill
);
if
(
NULL
==
pWindow
->
pFill
)
{
if
(
NULL
==
pWindow
->
pFill
)
{
...
@@ -485,7 +489,42 @@ static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
...
@@ -485,7 +489,42 @@ static int32_t createWindowLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
return
TSDB_CODE_FAILED
;
return
TSDB_CODE_FAILED
;
}
}
static
int32_t
createColumnByProjections
(
SLogicPlanContext
*
pCxt
,
SNodeList
*
pExprs
,
SNodeList
**
pCols
)
{
static
int32_t
createSortLogicNode
(
SLogicPlanContext
*
pCxt
,
SSelectStmt
*
pSelect
,
SLogicNode
**
pLogicNode
)
{
if
(
NULL
==
pSelect
->
pOrderByList
)
{
return
TSDB_CODE_SUCCESS
;
}
SSortLogicNode
*
pSort
=
nodesMakeNode
(
QUERY_NODE_LOGIC_PLAN_SORT
);
if
(
NULL
==
pSort
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
SNodeList
*
pCols
=
NULL
;
int32_t
code
=
nodesCollectColumns
(
pSelect
,
SQL_CLAUSE_ORDER_BY
,
NULL
,
&
pCols
);
if
(
TSDB_CODE_SUCCESS
==
code
&&
NULL
!=
pCols
)
{
pSort
->
node
.
pTargets
=
nodesCloneList
(
pCols
);
if
(
NULL
==
pSort
->
node
.
pTargets
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pSort
->
pSortKeys
=
nodesCloneList
(
pSelect
->
pOrderByList
);
if
(
NULL
==
pSort
->
pSortKeys
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
*
pLogicNode
=
(
SLogicNode
*
)
pSort
;
}
else
{
nodesDestroyNode
(
pSort
);
}
return
code
;
}
static
int32_t
createColumnByProjections
(
SLogicPlanContext
*
pCxt
,
const
char
*
pStmtName
,
SNodeList
*
pExprs
,
SNodeList
**
pCols
)
{
SNodeList
*
pList
=
nodesMakeList
();
SNodeList
*
pList
=
nodesMakeList
();
if
(
NULL
==
pList
)
{
if
(
NULL
==
pList
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
...
@@ -493,7 +532,7 @@ static int32_t createColumnByProjections(SLogicPlanContext* pCxt, SNodeList* pEx
...
@@ -493,7 +532,7 @@ static int32_t createColumnByProjections(SLogicPlanContext* pCxt, SNodeList* pEx
SNode
*
pNode
;
SNode
*
pNode
;
FOREACH
(
pNode
,
pExprs
)
{
FOREACH
(
pNode
,
pExprs
)
{
if
(
TSDB_CODE_SUCCESS
!=
nodesListAppend
(
pList
,
createColumnByExpr
((
SExprNode
*
)
pNode
)))
{
if
(
TSDB_CODE_SUCCESS
!=
nodesListAppend
(
pList
,
createColumnByExpr
(
pStmtName
,
(
SExprNode
*
)
pNode
)))
{
nodesDestroyList
(
pList
);
nodesDestroyList
(
pList
);
return
TSDB_CODE_OUT_OF_MEMORY
;
return
TSDB_CODE_OUT_OF_MEMORY
;
}
}
...
@@ -515,9 +554,10 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
...
@@ -515,9 +554,10 @@ static int32_t createProjectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSel
if
(
NULL
==
pProject
->
pProjections
)
{
if
(
NULL
==
pProject
->
pProjections
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
}
strcpy
(
pProject
->
stmtName
,
pSelect
->
stmtName
);
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createColumnByProjections
(
pCxt
,
pSelect
->
pProjectionList
,
&
pProject
->
node
.
pTargets
);
code
=
createColumnByProjections
(
pCxt
,
pSelect
->
stmtName
,
pSelect
->
pProjectionList
,
&
pProject
->
node
.
pTargets
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
@@ -538,6 +578,9 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
...
@@ -538,6 +578,9 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createChildLogicNode
(
pCxt
,
pSelect
,
createAggLogicNode
,
&
pRoot
);
code
=
createChildLogicNode
(
pCxt
,
pSelect
,
createAggLogicNode
,
&
pRoot
);
}
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createChildLogicNode
(
pCxt
,
pSelect
,
createSortLogicNode
,
&
pRoot
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
createChildLogicNode
(
pCxt
,
pSelect
,
createProjectLogicNode
,
&
pRoot
);
code
=
createChildLogicNode
(
pCxt
,
pSelect
,
createProjectLogicNode
,
&
pRoot
);
}
}
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
a82fc113
此差异已折叠。
点击以展开。
source/libs/planner/src/planSpliter.c
浏览文件 @
a82fc113
...
@@ -65,7 +65,9 @@ static int32_t stsMatch(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
...
@@ -65,7 +65,9 @@ static int32_t stsMatch(SSplitContext* pCxt, SLogicSubplan* pSubplan) {
SLogicNode
*
pSplitNode
=
stsMatchByNode
(
pSubplan
->
pNode
);
SLogicNode
*
pSplitNode
=
stsMatchByNode
(
pSubplan
->
pNode
);
if
(
NULL
!=
pSplitNode
)
{
if
(
NULL
!=
pSplitNode
)
{
SStsInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SStsInfo
));
SStsInfo
*
pInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SStsInfo
));
CHECK_ALLOC
(
pInfo
,
TSDB_CODE_OUT_OF_MEMORY
);
if
(
NULL
==
pInfo
)
{
return
TSDB_CODE_OUT_OF_MEMORY
;
}
pInfo
->
pScan
=
(
SScanLogicNode
*
)
pSplitNode
;
pInfo
->
pScan
=
(
SScanLogicNode
*
)
pSplitNode
;
pInfo
->
pSubplan
=
pSubplan
;
pInfo
->
pSubplan
=
pSubplan
;
pCxt
->
pInfo
=
pInfo
;
pCxt
->
pInfo
=
pInfo
;
...
...
source/libs/planner/test/plannerTest.cpp
浏览文件 @
a82fc113
...
@@ -170,7 +170,7 @@ TEST_F(PlannerTest, groupBy) {
...
@@ -170,7 +170,7 @@ TEST_F(PlannerTest, groupBy) {
bind
(
"SELECT count(*) FROM t1"
);
bind
(
"SELECT count(*) FROM t1"
);
ASSERT_TRUE
(
run
());
ASSERT_TRUE
(
run
());
bind
(
"SELECT c1, count(*) FROM t1 GROUP BY c1"
);
bind
(
"SELECT c1,
max(c3), min(c2),
count(*) FROM t1 GROUP BY c1"
);
ASSERT_TRUE
(
run
());
ASSERT_TRUE
(
run
());
bind
(
"SELECT c1 + c3, c1 + count(*) FROM t1 where c2 = 'abc' GROUP BY c1, c3"
);
bind
(
"SELECT c1 + c3, c1 + count(*) FROM t1 where c2 = 'abc' GROUP BY c1, c3"
);
...
@@ -201,10 +201,31 @@ TEST_F(PlannerTest, sessionWindow) {
...
@@ -201,10 +201,31 @@ TEST_F(PlannerTest, sessionWindow) {
ASSERT_TRUE
(
run
());
ASSERT_TRUE
(
run
());
}
}
TEST_F
(
PlannerTest
,
orderBy
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"SELECT * FROM t1 order by c1"
);
ASSERT_TRUE
(
run
());
bind
(
"SELECT c1 FROM t1 order by c2"
);
ASSERT_TRUE
(
run
());
bind
(
"SELECT * FROM t1 order by c1 + 10, c2"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
PlannerTest
,
showTables
)
{
TEST_F
(
PlannerTest
,
showTables
)
{
setDatabase
(
"root"
,
"test"
);
setDatabase
(
"root"
,
"test"
);
bind
(
"show tables"
);
bind
(
"show tables"
);
ASSERT_TRUE
(
run
());
}
TEST_F
(
PlannerTest
,
showStables
)
{
setDatabase
(
"root"
,
"test"
);
bind
(
"show stables"
);
ASSERT_TRUE
(
run
());
}
}
TEST_F
(
PlannerTest
,
createTopic
)
{
TEST_F
(
PlannerTest
,
createTopic
)
{
...
...
source/libs/qcom/src/queryUtil.c
浏览文件 @
a82fc113
...
@@ -198,7 +198,7 @@ char *jobTaskStatusStr(int32_t status) {
...
@@ -198,7 +198,7 @@ char *jobTaskStatusStr(int32_t status) {
return
"UNKNOWN"
;
return
"UNKNOWN"
;
}
}
SSchema
createSchema
(
uint8_t
type
,
int32_t
bytes
,
int32
_t
colId
,
const
char
*
name
)
{
SSchema
createSchema
(
int8_t
type
,
int32_t
bytes
,
col_id
_t
colId
,
const
char
*
name
)
{
SSchema
s
=
{
0
};
SSchema
s
=
{
0
};
s
.
type
=
type
;
s
.
type
=
type
;
s
.
bytes
=
bytes
;
s
.
bytes
=
bytes
;
...
...
source/libs/qcom/src/querymsg.c
浏览文件 @
a82fc113
...
@@ -188,7 +188,7 @@ static int32_t queryConvertTableMetaMsg(STableMetaRsp *pMetaMsg) {
...
@@ -188,7 +188,7 @@ static int32_t queryConvertTableMetaMsg(STableMetaRsp *pMetaMsg) {
}
}
if
(
pMetaMsg
->
pSchemas
[
0
].
colId
!=
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
if
(
pMetaMsg
->
pSchemas
[
0
].
colId
!=
PRIMARYKEY_TIMESTAMP_COL_ID
)
{
qError
(
"invalid colId[%
d
] for the first column in table meta rsp msg"
,
pMetaMsg
->
pSchemas
[
0
].
colId
);
qError
(
"invalid colId[%
"
PRIi16
"
] for the first column in table meta rsp msg"
,
pMetaMsg
->
pSchemas
[
0
].
colId
);
return
TSDB_CODE_TSC_INVALID_VALUE
;
return
TSDB_CODE_TSC_INVALID_VALUE
;
}
}
...
...
source/libs/qworker/src/qworker.c
浏览文件 @
a82fc113
...
@@ -947,10 +947,12 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType) {
...
@@ -947,10 +947,12 @@ int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, int8_t taskType) {
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
&
ctx
));
QW_ERR_JRET
(
qwGetTaskCtx
(
QW_FPARAMS
(),
&
ctx
));
atomic_store_8
(
&
ctx
->
taskType
,
taskType
);
atomic_store_8
(
&
ctx
->
taskType
,
taskType
);
atomic_store_ptr
(
&
ctx
->
connInfo
.
handle
,
qwMsg
->
connInfo
.
handle
);
atomic_store_ptr
(
&
ctx
->
connInfo
.
handle
,
qwMsg
->
connInfo
.
handle
);
atomic_store_ptr
(
&
ctx
->
connInfo
.
ahandle
,
qwMsg
->
connInfo
.
ahandle
);
atomic_store_ptr
(
&
ctx
->
connInfo
.
ahandle
,
qwMsg
->
connInfo
.
ahandle
);
QW_TASK_DLOGL
(
"subplan json string, len:%d, %s"
,
qwMsg
->
msgLen
,
qwMsg
->
msg
);
QW_TASK_DLOGL
(
"subplan json string, len:%d, %s"
,
qwMsg
->
msgLen
,
qwMsg
->
msg
);
code
=
qStringToSubplan
(
qwMsg
->
msg
,
&
plan
);
code
=
qStringToSubplan
(
qwMsg
->
msg
,
&
plan
);
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
if
(
TSDB_CODE_SUCCESS
!=
code
)
{
QW_TASK_ELOG
(
"task string to subplan failed, code:%x - %s"
,
code
,
tstrerror
(
code
));
QW_TASK_ELOG
(
"task string to subplan failed, code:%x - %s"
,
code
,
tstrerror
(
code
));
...
...
source/libs/qworker/src/qworkerMsg.c
浏览文件 @
a82fc113
...
@@ -170,7 +170,7 @@ int32_t qwBuildAndSendShowRsp(SRpcMsg *pMsg, int32_t code) {
...
@@ -170,7 +170,7 @@ int32_t qwBuildAndSendShowRsp(SRpcMsg *pMsg, int32_t code) {
return
-
1
;
return
-
1
;
}
}
int32
_t
cols
=
0
;
col_id
_t
cols
=
0
;
SSchema
*
pSchema
=
showRsp
.
tableMeta
.
pSchemas
;
SSchema
*
pSchema
=
showRsp
.
tableMeta
.
pSchemas
;
const
SSchema
*
s
=
tGetTbnameColumnSchema
();
const
SSchema
*
s
=
tGetTbnameColumnSchema
();
...
...
source/libs/stream/src/tstream.c
浏览文件 @
a82fc113
...
@@ -121,7 +121,7 @@ int32_t streamExecTask(SStreamTask* pTask, SMsgCb* pMsgCb, const void* input, in
...
@@ -121,7 +121,7 @@ int32_t streamExecTask(SStreamTask* pTask, SMsgCb* pMsgCb, const void* input, in
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__FIXED
)
{
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__FIXED
)
{
SStreamTaskExecReq
req
=
{
SStreamTaskExecReq
req
=
{
.
streamId
=
pTask
->
streamId
,
.
streamId
=
pTask
->
streamId
,
.
taskId
=
pTask
->
taskId
,
.
taskId
=
pTask
->
fixedEpDispatcher
.
taskId
,
.
data
=
pRes
,
.
data
=
pRes
,
};
};
...
@@ -211,8 +211,9 @@ int32_t tEncodeSStreamTask(SCoder* pEncoder, const SStreamTask* pTask) {
...
@@ -211,8 +211,9 @@ int32_t tEncodeSStreamTask(SCoder* pEncoder, const SStreamTask* pTask) {
}
}
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__INPLACE
)
{
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__INPLACE
)
{
if
(
tEncodeI
8
(
pEncoder
,
pTask
->
inplaceDispatcher
.
reserve
d
)
<
0
)
return
-
1
;
if
(
tEncodeI
32
(
pEncoder
,
pTask
->
inplaceDispatcher
.
taskI
d
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__FIXED
)
{
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__FIXED
)
{
if
(
tEncodeI32
(
pEncoder
,
pTask
->
fixedEpDispatcher
.
taskId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pTask
->
fixedEpDispatcher
.
nodeId
)
<
0
)
return
-
1
;
if
(
tEncodeI32
(
pEncoder
,
pTask
->
fixedEpDispatcher
.
nodeId
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
pEncoder
,
&
pTask
->
fixedEpDispatcher
.
epSet
)
<
0
)
return
-
1
;
if
(
tEncodeSEpSet
(
pEncoder
,
&
pTask
->
fixedEpDispatcher
.
epSet
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__SHUFFLE
)
{
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__SHUFFLE
)
{
...
@@ -248,8 +249,9 @@ int32_t tDecodeSStreamTask(SCoder* pDecoder, SStreamTask* pTask) {
...
@@ -248,8 +249,9 @@ int32_t tDecodeSStreamTask(SCoder* pDecoder, SStreamTask* pTask) {
}
}
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__INPLACE
)
{
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__INPLACE
)
{
if
(
tDecodeI
8
(
pDecoder
,
&
pTask
->
inplaceDispatcher
.
reserve
d
)
<
0
)
return
-
1
;
if
(
tDecodeI
32
(
pDecoder
,
&
pTask
->
inplaceDispatcher
.
taskI
d
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__FIXED
)
{
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__FIXED
)
{
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
fixedEpDispatcher
.
taskId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
fixedEpDispatcher
.
nodeId
)
<
0
)
return
-
1
;
if
(
tDecodeI32
(
pDecoder
,
&
pTask
->
fixedEpDispatcher
.
nodeId
)
<
0
)
return
-
1
;
if
(
tDecodeSEpSet
(
pDecoder
,
&
pTask
->
fixedEpDispatcher
.
epSet
)
<
0
)
return
-
1
;
if
(
tDecodeSEpSet
(
pDecoder
,
&
pTask
->
fixedEpDispatcher
.
epSet
)
<
0
)
return
-
1
;
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__SHUFFLE
)
{
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__SHUFFLE
)
{
...
...
source/libs/tdb/CMakeLists.txt
浏览文件 @
a82fc113
...
@@ -8,7 +8,6 @@ target_sources(tdb
...
@@ -8,7 +8,6 @@ target_sources(tdb
"src/db/tdbBtree.c"
"src/db/tdbBtree.c"
"src/db/tdbDb.c"
"src/db/tdbDb.c"
"src/db/tdbEnv.c"
"src/db/tdbEnv.c"
# "src/db/tdbPage.c"
"src/page/tdbPage.c"
"src/page/tdbPage.c"
"src/page/tdbPageL.c"
"src/page/tdbPageL.c"
)
)
...
...
source/libs/tdb/src/btree/tdbBtreeBalance.c
0 → 100644
浏览文件 @
a82fc113
/*
* 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/>.
*/
\ No newline at end of file
source/libs/tdb/src/btree/tdbBtreeCommon.c
0 → 100644
浏览文件 @
a82fc113
/*
* 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/>.
*/
\ No newline at end of file
source/libs/tdb/src/btree/tdbBtreeDelete.c
0 → 100644
浏览文件 @
a82fc113
/*
* 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/>.
*/
\ No newline at end of file
source/libs/tdb/src/btree/tdbBtreeInsert.c
0 → 100644
浏览文件 @
a82fc113
/*
* 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/>.
*/
\ No newline at end of file
source/libs/tdb/src/btree/tdbBtreeInt.h
0 → 100644
浏览文件 @
a82fc113
/*
* 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 _TDB_BTREE_INT_H_
#define _TDB_BTREE_INT_H_
#ifdef __cplusplus
extern
"C"
{
#endif
#ifdef __cplusplus
}
#endif
#endif
/*_TDB_BTREE_INT_H_*/
\ No newline at end of file
source/libs/tdb/src/btree/tdbBtreeOpen.c
0 → 100644
浏览文件 @
a82fc113
/*
* 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/>.
*/
\ No newline at end of file
source/libs/tdb/src/db/tdbBtree.c
浏览文件 @
a82fc113
此差异已折叠。
点击以展开。
source/libs/tdb/src/db/tdbDb.c
浏览文件 @
a82fc113
...
@@ -15,13 +15,17 @@
...
@@ -15,13 +15,17 @@
#include "tdbInt.h"
#include "tdbInt.h"
struct
STD
b
{
struct
STD
B
{
STEnv
*
pEnv
;
STEnv
*
pEnv
;
SBTree
*
pBt
;
SBTree
*
pBt
;
};
};
int
tdbDbOpen
(
const
char
*
fname
,
int
keyLen
,
int
valLen
,
FKeyComparator
keyCmprFn
,
STEnv
*
pEnv
,
STDb
**
ppDb
)
{
struct
STDBC
{
STDb
*
pDb
;
SBTC
btc
;
};
int
tdbDbOpen
(
const
char
*
fname
,
int
keyLen
,
int
valLen
,
FKeyComparator
keyCmprFn
,
STEnv
*
pEnv
,
STDB
**
ppDb
)
{
STDB
*
pDb
;
SPager
*
pPager
;
SPager
*
pPager
;
int
ret
;
int
ret
;
char
fFullName
[
TDB_FILENAME_LEN
];
char
fFullName
[
TDB_FILENAME_LEN
];
...
@@ -30,7 +34,7 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF
...
@@ -30,7 +34,7 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF
*
ppDb
=
NULL
;
*
ppDb
=
NULL
;
pDb
=
(
STD
b
*
)
taosMemoryC
alloc
(
1
,
sizeof
(
*
pDb
));
pDb
=
(
STD
B
*
)
c
alloc
(
1
,
sizeof
(
*
pDb
));
if
(
pDb
==
NULL
)
{
if
(
pDb
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -59,23 +63,23 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF
...
@@ -59,23 +63,23 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF
return
0
;
return
0
;
}
}
int
tdbDbClose
(
STD
b
*
pDb
)
{
int
tdbDbClose
(
STD
B
*
pDb
)
{
// TODO
// TODO
return
0
;
return
0
;
}
}
int
tdbDbDrop
(
STD
b
*
pDb
)
{
int
tdbDbDrop
(
STD
B
*
pDb
)
{
// TODO
// TODO
return
0
;
return
0
;
}
}
int
tdbDbInsert
(
STD
b
*
pDb
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
)
{
int
tdbDbInsert
(
STD
B
*
pDb
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
)
{
SB
tCursor
btc
;
SB
TC
btc
;
SB
tCursor
*
pCur
;
SB
TC
*
pCur
;
int
ret
;
int
ret
;
pCur
=
&
btc
;
pCur
=
&
btc
;
ret
=
tdbBt
reeCursor
(
pCur
,
pDb
->
pBt
);
ret
=
tdbBt
cOpen
(
pCur
,
pDb
->
pBt
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -85,5 +89,45 @@ int tdbDbInsert(STDb *pDb, const void *pKey, int keyLen, const void *pVal, int v
...
@@ -85,5 +89,45 @@ int tdbDbInsert(STDb *pDb, const void *pKey, int keyLen, const void *pVal, int v
return
-
1
;
return
-
1
;
}
}
return
0
;
}
int
tdbDbGet
(
STDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppVal
,
int
*
vLen
)
{
return
tdbBtreeGet
(
pDb
->
pBt
,
pKey
,
kLen
,
ppVal
,
vLen
);
}
int
tdbDbcOpen
(
STDB
*
pDb
,
STDBC
**
ppDbc
)
{
int
ret
;
STDBC
*
pDbc
=
NULL
;
*
ppDbc
=
NULL
;
pDbc
=
malloc
(
sizeof
(
*
pDbc
));
if
(
pDbc
==
NULL
)
{
return
-
1
;
}
tdbBtcOpen
(
&
pDbc
->
btc
,
pDb
->
pBt
);
// TODO: move to first now, we can move to any key-value
// and in any direction, design new APIs.
ret
=
tdbBtcMoveToFirst
(
&
pDbc
->
btc
);
if
(
ret
<
0
)
{
ASSERT
(
0
);
return
-
1
;
}
*
ppDbc
=
pDbc
;
return
0
;
}
int
tdbDbNext
(
STDBC
*
pDbc
,
void
**
ppKey
,
int
*
kLen
,
void
**
ppVal
,
int
*
vLen
)
{
return
tdbBtreeNext
(
&
pDbc
->
btc
,
ppKey
,
kLen
,
ppVal
,
vLen
);
}
int
tdbDbcClose
(
STDBC
*
pDbc
)
{
if
(
pDbc
)
{
free
(
pDbc
);
}
return
0
;
return
0
;
}
}
\ No newline at end of file
source/libs/tdb/src/db/tdbEnv.c
浏览文件 @
a82fc113
...
@@ -27,7 +27,7 @@ int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv)
...
@@ -27,7 +27,7 @@ int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, STEnv **ppEnv)
dsize
=
strlen
(
rootDir
);
dsize
=
strlen
(
rootDir
);
zsize
=
sizeof
(
*
pEnv
)
+
dsize
*
2
+
strlen
(
TDB_JOURNAL_NAME
)
+
3
;
zsize
=
sizeof
(
*
pEnv
)
+
dsize
*
2
+
strlen
(
TDB_JOURNAL_NAME
)
+
3
;
pPtr
=
(
uint8_t
*
)
taosMemoryC
alloc
(
1
,
zsize
);
pPtr
=
(
uint8_t
*
)
c
alloc
(
1
,
zsize
);
if
(
pPtr
==
NULL
)
{
if
(
pPtr
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
...
...
source/libs/tdb/src/db/tdbPCache.c
浏览文件 @
a82fc113
...
@@ -17,7 +17,7 @@
...
@@ -17,7 +17,7 @@
struct
SPCache
{
struct
SPCache
{
int
pageSize
;
int
pageSize
;
int
cacheSize
;
int
cacheSize
;
TdThreadMutex
mutex
;
pthread_mutex_t
mutex
;
int
nFree
;
int
nFree
;
SPage
*
pFree
;
SPage
*
pFree
;
int
nPage
;
int
nPage
;
...
@@ -53,19 +53,17 @@ static void tdbPCacheLock(SPCache *pCache);
...
@@ -53,19 +53,17 @@ static void tdbPCacheLock(SPCache *pCache);
static
void
tdbPCacheUnlock
(
SPCache
*
pCache
);
static
void
tdbPCacheUnlock
(
SPCache
*
pCache
);
static
bool
tdbPCacheLocked
(
SPCache
*
pCache
);
static
bool
tdbPCacheLocked
(
SPCache
*
pCache
);
static
SPage
*
tdbPCacheFetchImpl
(
SPCache
*
pCache
,
const
SPgid
*
pPgid
,
bool
alcNewPage
);
static
SPage
*
tdbPCacheFetchImpl
(
SPCache
*
pCache
,
const
SPgid
*
pPgid
,
bool
alcNewPage
);
static
void
tdbPCachePinPage
(
SPage
*
pPage
);
static
void
tdbPCachePinPage
(
SPCache
*
pCache
,
SPage
*
pPage
);
static
void
tdbPCacheRemovePageFromHash
(
SPage
*
pPage
);
static
void
tdbPCacheRemovePageFromHash
(
SPCache
*
pCache
,
SPage
*
pPage
);
static
void
tdbPCacheAddPageToHash
(
SPage
*
pPage
);
static
void
tdbPCacheAddPageToHash
(
SPCache
*
pCache
,
SPage
*
pPage
);
static
void
tdbPCacheUnpinPage
(
SPage
*
pPage
);
static
void
tdbPCacheUnpinPage
(
SPCache
*
pCache
,
SPage
*
pPage
);
static
void
*
tdbOsMalloc
(
void
*
arg
,
size_t
size
);
static
void
tdbOsFree
(
void
*
arg
,
void
*
ptr
);
int
tdbPCacheOpen
(
int
pageSize
,
int
cacheSize
,
SPCache
**
ppCache
)
{
int
tdbPCacheOpen
(
int
pageSize
,
int
cacheSize
,
SPCache
**
ppCache
)
{
SPCache
*
pCache
;
SPCache
*
pCache
;
void
*
pPtr
;
void
*
pPtr
;
SPage
*
pPgHdr
;
SPage
*
pPgHdr
;
pCache
=
(
SPCache
*
)
taosMemoryC
alloc
(
1
,
sizeof
(
*
pCache
));
pCache
=
(
SPCache
*
)
c
alloc
(
1
,
sizeof
(
*
pCache
));
if
(
pCache
==
NULL
)
{
if
(
pCache
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -74,7 +72,7 @@ int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) {
...
@@ -74,7 +72,7 @@ int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache) {
pCache
->
cacheSize
=
cacheSize
;
pCache
->
cacheSize
=
cacheSize
;
if
(
tdbPCacheOpenImpl
(
pCache
)
<
0
)
{
if
(
tdbPCacheOpenImpl
(
pCache
)
<
0
)
{
taosMemoryF
ree
(
pCache
);
f
ree
(
pCache
);
return
-
1
;
return
-
1
;
}
}
...
@@ -102,7 +100,7 @@ SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage) {
...
@@ -102,7 +100,7 @@ SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage) {
return
pPage
;
return
pPage
;
}
}
void
tdbPCacheRelease
(
SPage
*
pPage
)
{
void
tdbPCacheRelease
(
SP
Cache
*
pCache
,
SP
age
*
pPage
)
{
i32
nRef
;
i32
nRef
;
nRef
=
TDB_UNREF_PAGE
(
pPage
);
nRef
=
TDB_UNREF_PAGE
(
pPage
);
...
@@ -110,7 +108,7 @@ void tdbPCacheRelease(SPage *pPage) {
...
@@ -110,7 +108,7 @@ void tdbPCacheRelease(SPage *pPage) {
if
(
nRef
==
0
)
{
if
(
nRef
==
0
)
{
if
(
1
/*TODO: page still clean*/
)
{
if
(
1
/*TODO: page still clean*/
)
{
tdbPCacheUnpinPage
(
pPage
);
tdbPCacheUnpinPage
(
p
Cache
,
p
Page
);
}
else
{
}
else
{
// TODO
// TODO
ASSERT
(
0
);
ASSERT
(
0
);
...
@@ -118,13 +116,13 @@ void tdbPCacheRelease(SPage *pPage) {
...
@@ -118,13 +116,13 @@ void tdbPCacheRelease(SPage *pPage) {
}
}
}
}
static
void
tdbPCacheInitLock
(
SPCache
*
pCache
)
{
taosThreadMutexI
nit
(
&
(
pCache
->
mutex
),
NULL
);
}
static
void
tdbPCacheInitLock
(
SPCache
*
pCache
)
{
pthread_mutex_i
nit
(
&
(
pCache
->
mutex
),
NULL
);
}
static
void
tdbPCacheClearLock
(
SPCache
*
pCache
)
{
taosThreadMutexD
estroy
(
&
(
pCache
->
mutex
));
}
static
void
tdbPCacheClearLock
(
SPCache
*
pCache
)
{
pthread_mutex_d
estroy
(
&
(
pCache
->
mutex
));
}
static
void
tdbPCacheLock
(
SPCache
*
pCache
)
{
taosThreadMutexL
ock
(
&
(
pCache
->
mutex
));
}
static
void
tdbPCacheLock
(
SPCache
*
pCache
)
{
pthread_mutex_l
ock
(
&
(
pCache
->
mutex
));
}
static
void
tdbPCacheUnlock
(
SPCache
*
pCache
)
{
taosThreadMutexU
nlock
(
&
(
pCache
->
mutex
));
}
static
void
tdbPCacheUnlock
(
SPCache
*
pCache
)
{
pthread_mutex_u
nlock
(
&
(
pCache
->
mutex
));
}
static
bool
tdbPCacheLocked
(
SPCache
*
pCache
)
{
static
bool
tdbPCacheLocked
(
SPCache
*
pCache
)
{
assert
(
0
);
assert
(
0
);
...
@@ -144,7 +142,7 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNe
...
@@ -144,7 +142,7 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNe
if
(
pPage
||
!
alcNewPage
)
{
if
(
pPage
||
!
alcNewPage
)
{
if
(
pPage
)
{
if
(
pPage
)
{
tdbPCachePinPage
(
pPage
);
tdbPCachePinPage
(
p
Cache
,
p
Page
);
}
}
return
pPage
;
return
pPage
;
}
}
...
@@ -160,8 +158,8 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNe
...
@@ -160,8 +158,8 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNe
// 3. Try to Recycle a page
// 3. Try to Recycle a page
if
(
!
pPage
&&
!
pCache
->
lru
.
pLruPrev
->
isAnchor
)
{
if
(
!
pPage
&&
!
pCache
->
lru
.
pLruPrev
->
isAnchor
)
{
pPage
=
pCache
->
lru
.
pLruPrev
;
pPage
=
pCache
->
lru
.
pLruPrev
;
tdbPCacheRemovePageFromHash
(
pPage
);
tdbPCacheRemovePageFromHash
(
p
Cache
,
p
Page
);
tdbPCachePinPage
(
pPage
);
tdbPCachePinPage
(
p
Cache
,
p
Page
);
}
}
// 4. Try a stress allocation (TODO)
// 4. Try a stress allocation (TODO)
...
@@ -173,16 +171,13 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNe
...
@@ -173,16 +171,13 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNe
memcpy
(
&
(
pPage
->
pgid
),
pPgid
,
sizeof
(
*
pPgid
));
memcpy
(
&
(
pPage
->
pgid
),
pPgid
,
sizeof
(
*
pPgid
));
pPage
->
pLruNext
=
NULL
;
pPage
->
pLruNext
=
NULL
;
pPage
->
pPager
=
NULL
;
pPage
->
pPager
=
NULL
;
tdbPCacheAddPageToHash
(
pPage
);
tdbPCacheAddPageToHash
(
p
Cache
,
p
Page
);
}
}
return
pPage
;
return
pPage
;
}
}
static
void
tdbPCachePinPage
(
SPage
*
pPage
)
{
static
void
tdbPCachePinPage
(
SPCache
*
pCache
,
SPage
*
pPage
)
{
SPCache
*
pCache
;
pCache
=
pPage
->
pCache
;
if
(
!
PAGE_IS_PINNED
(
pPage
))
{
if
(
!
PAGE_IS_PINNED
(
pPage
))
{
pPage
->
pLruPrev
->
pLruNext
=
pPage
->
pLruNext
;
pPage
->
pLruPrev
->
pLruNext
=
pPage
->
pLruNext
;
pPage
->
pLruNext
->
pLruPrev
=
pPage
->
pLruPrev
;
pPage
->
pLruNext
->
pLruPrev
=
pPage
->
pLruPrev
;
...
@@ -192,11 +187,8 @@ static void tdbPCachePinPage(SPage *pPage) {
...
@@ -192,11 +187,8 @@ static void tdbPCachePinPage(SPage *pPage) {
}
}
}
}
static
void
tdbPCacheUnpinPage
(
SPage
*
pPage
)
{
static
void
tdbPCacheUnpinPage
(
SPCache
*
pCache
,
SPage
*
pPage
)
{
SPCache
*
pCache
;
i32
nRef
;
i32
nRef
;
pCache
=
pPage
->
pCache
;
tdbPCacheLock
(
pCache
);
tdbPCacheLock
(
pCache
);
...
@@ -217,12 +209,10 @@ static void tdbPCacheUnpinPage(SPage *pPage) {
...
@@ -217,12 +209,10 @@ static void tdbPCacheUnpinPage(SPage *pPage) {
tdbPCacheUnlock
(
pCache
);
tdbPCacheUnlock
(
pCache
);
}
}
static
void
tdbPCacheRemovePageFromHash
(
SPage
*
pPage
)
{
static
void
tdbPCacheRemovePageFromHash
(
SPCache
*
pCache
,
SPage
*
pPage
)
{
SPCache
*
pCache
;
SPage
**
ppPage
;
SPage
**
ppPage
;
int
h
;
int
h
;
pCache
=
pPage
->
pCache
;
h
=
PCACHE_PAGE_HASH
(
&
(
pPage
->
pgid
));
h
=
PCACHE_PAGE_HASH
(
&
(
pPage
->
pgid
));
for
(
ppPage
=
&
(
pCache
->
pgHash
[
h
%
pCache
->
nHash
]);
*
ppPage
!=
pPage
;
ppPage
=
&
((
*
ppPage
)
->
pHashNext
))
for
(
ppPage
=
&
(
pCache
->
pgHash
[
h
%
pCache
->
nHash
]);
*
ppPage
!=
pPage
;
ppPage
=
&
((
*
ppPage
)
->
pHashNext
))
;
;
...
@@ -232,11 +222,9 @@ static void tdbPCacheRemovePageFromHash(SPage *pPage) {
...
@@ -232,11 +222,9 @@ static void tdbPCacheRemovePageFromHash(SPage *pPage) {
pCache
->
nPage
--
;
pCache
->
nPage
--
;
}
}
static
void
tdbPCacheAddPageToHash
(
SPage
*
pPage
)
{
static
void
tdbPCacheAddPageToHash
(
SPCache
*
pCache
,
SPage
*
pPage
)
{
SPCache
*
pCache
;
int
h
;
int
h
;
pCache
=
pPage
->
pCache
;
h
=
PCACHE_PAGE_HASH
(
&
(
pPage
->
pgid
))
%
pCache
->
nHash
;
h
=
PCACHE_PAGE_HASH
(
&
(
pPage
->
pgid
))
%
pCache
->
nHash
;
pPage
->
pHashNext
=
pCache
->
pgHash
[
h
];
pPage
->
pHashNext
=
pCache
->
pgHash
[
h
];
...
@@ -257,7 +245,7 @@ static int tdbPCacheOpenImpl(SPCache *pCache) {
...
@@ -257,7 +245,7 @@ static int tdbPCacheOpenImpl(SPCache *pCache) {
pCache
->
nFree
=
0
;
pCache
->
nFree
=
0
;
pCache
->
pFree
=
NULL
;
pCache
->
pFree
=
NULL
;
for
(
int
i
=
0
;
i
<
pCache
->
cacheSize
;
i
++
)
{
for
(
int
i
=
0
;
i
<
pCache
->
cacheSize
;
i
++
)
{
ret
=
tdbPageCreate
(
pCache
->
pageSize
,
&
pPage
,
tdbOsMalloc
,
NULL
);
ret
=
tdbPageCreate
(
pCache
->
pageSize
,
&
pPage
,
NULL
,
NULL
);
if
(
ret
<
0
)
{
if
(
ret
<
0
)
{
// TODO: handle error
// TODO: handle error
return
-
1
;
return
-
1
;
...
@@ -266,7 +254,6 @@ static int tdbPCacheOpenImpl(SPCache *pCache) {
...
@@ -266,7 +254,6 @@ static int tdbPCacheOpenImpl(SPCache *pCache) {
// pPage->pgid = 0;
// pPage->pgid = 0;
pPage
->
isAnchor
=
0
;
pPage
->
isAnchor
=
0
;
pPage
->
isLocalPage
=
1
;
pPage
->
isLocalPage
=
1
;
pPage
->
pCache
=
pCache
;
TDB_INIT_PAGE_REF
(
pPage
);
TDB_INIT_PAGE_REF
(
pPage
);
pPage
->
pHashNext
=
NULL
;
pPage
->
pHashNext
=
NULL
;
pPage
->
pLruNext
=
NULL
;
pPage
->
pLruNext
=
NULL
;
...
@@ -281,7 +268,7 @@ static int tdbPCacheOpenImpl(SPCache *pCache) {
...
@@ -281,7 +268,7 @@ static int tdbPCacheOpenImpl(SPCache *pCache) {
// Open the hash table
// Open the hash table
pCache
->
nPage
=
0
;
pCache
->
nPage
=
0
;
pCache
->
nHash
=
pCache
->
cacheSize
;
pCache
->
nHash
=
pCache
->
cacheSize
;
pCache
->
pgHash
=
(
SPage
**
)
taosMemoryC
alloc
(
pCache
->
nHash
,
sizeof
(
SPage
*
));
pCache
->
pgHash
=
(
SPage
**
)
c
alloc
(
pCache
->
nHash
,
sizeof
(
SPage
*
));
if
(
pCache
->
pgHash
==
NULL
)
{
if
(
pCache
->
pgHash
==
NULL
)
{
// TODO
// TODO
return
-
1
;
return
-
1
;
...
@@ -297,13 +284,3 @@ static int tdbPCacheOpenImpl(SPCache *pCache) {
...
@@ -297,13 +284,3 @@ static int tdbPCacheOpenImpl(SPCache *pCache) {
}
}
int
tdbPCacheGetPageSize
(
SPCache
*
pCache
)
{
return
pCache
->
pageSize
;
}
int
tdbPCacheGetPageSize
(
SPCache
*
pCache
)
{
return
pCache
->
pageSize
;
}
static
void
*
tdbOsMalloc
(
void
*
arg
,
size_t
size
)
{
void
*
ptr
;
ptr
=
taosMemoryMalloc
(
size
);
return
ptr
;
}
static
void
tdbOsFree
(
void
*
arg
,
void
*
ptr
)
{
taosMemoryFree
(
ptr
);
}
\ No newline at end of file
source/libs/tdb/src/db/tdbPage.c
已删除
100644 → 0
浏览文件 @
9e3f03ad
/*
* 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 "tdbInt.h"
typedef
struct
__attribute__
((
__packed__
))
{
u8
szCell
[
2
];
u8
nxOffset
[
2
];
}
SFreeCell
;
typedef
struct
__attribute__
((
__packed__
))
{
u8
szCell
[
3
];
u8
nxOffset
[
3
];
}
SFreeCellL
;
/* For small page */
#define TDB_SPAGE_FREE_CELL_SIZE_PTR(PCELL) (((SFreeCell *)(PCELL))->szCell)
#define TDB_SPAGE_FREE_CELL_NXOFFSET_PTR(PCELL) (((SFreeCell *)(PCELL))->nxOffset)
#define TDB_SPAGE_FREE_CELL_SIZE(PCELL) ((u16 *)TDB_SPAGE_FREE_CELL_SIZE_PTR(PCELL))[0]
#define TDB_SPAGE_FREE_CELL_NXOFFSET(PCELL) ((u16 *)TDB_SPAGE_FREE_CELL_NXOFFSET_PTR(PCELL))[0]
#define TDB_SPAGE_FREE_CELL_SIZE_SET(PCELL, SIZE) (TDB_SPAGE_FREE_CELL_SIZE(PCELL) = (SIZE))
#define TDB_SPAGE_FREE_CELL_NXOFFSET_SET(PCELL, OFFSET) (TDB_SPAGE_FREE_CELL_NXOFFSET(PCELL) = (OFFSET))
/* For large page */
#define TDB_LPAGE_FREE_CELL_SIZE_PTR(PCELL) (((SFreeCellL *)(PCELL))->szCell)
#define TDB_LPAGE_FREE_CELL_NXOFFSET_PTR(PCELL) (((SFreeCellL *)(PCELL))->nxOffset)
#define TDB_LPAGE_FREE_CELL_SIZE(PCELL) TDB_GET_U24(TDB_LPAGE_FREE_CELL_SIZE_PTR(PCELL))
#define TDB_LPAGE_FREE_CELL_NXOFFSET(PCELL) TDB_GET_U24(TDB_LPAGE_FREE_CELL_NXOFFSET_PTR(PCELL))
#define TDB_LPAGE_FREE_CELL_SIZE_SET(PCELL, SIZE) TDB_PUT_U24(TDB_LPAGE_FREE_CELL_SIZE_PTR(PCELL), SIZE)
#define TDB_LPAGE_FREE_CELL_NXOFFSET_SET(PCELL, OFFSET) TDB_PUT_U24(TDB_LPAGE_FREE_CELL_NXOFFSET_PTR(PCELL), OFFSET)
/* For page */
#define TDB_PAGE_FREE_CELL_SIZE_PTR(PPAGE, PCELL) \
(TDB_IS_LARGE_PAGE(pPage) ? TDB_LPAGE_FREE_CELL_SIZE_PTR(PCELL) : TDB_SPAGE_FREE_CELL_SIZE_PTR(PCELL))
#define TDB_PAGE_FREE_CELL_NXOFFSET_PTR(PPAGE, PCELL) \
(TDB_IS_LARGE_PAGE(pPage) ? TDB_LPAGE_FREE_CELL_NXOFFSET_PTR(PCELL) : TDB_SPAGE_FREE_CELL_NXOFFSET_PTR(PCELL))
#define TDB_PAGE_FREE_CELL_SIZE(PPAGE, PCELL) \
(TDB_IS_LARGE_PAGE(pPage) ? TDB_LPAGE_FREE_CELL_SIZE(PCELL) : TDB_SPAGE_FREE_CELL_SIZE(PCELL))
#define TDB_PAGE_FREE_CELL_NXOFFSET(PPAGE, PCELL) \
(TDB_IS_LARGE_PAGE(pPage) ? TDB_LPAGE_FREE_CELL_NXOFFSET(PCELL) : TDB_SPAGE_FREE_CELL_NXOFFSET(PCELL))
#define TDB_PAGE_FREE_CELL_SIZE_SET(PPAGE, PCELL, SIZE) \
do { \
if (TDB_IS_LARGE_PAGE(PPAGE)) { \
TDB_LPAGE_FREE_CELL_SIZE_SET(PCELL, SIZE); \
} else { \
TDB_SPAGE_FREE_CELL_SIZE_SET(PCELL, SIZE); \
} \
} while (0)
#define TDB_PAGE_FREE_CELL_NXOFFSET_SET(PPAGE, PCELL, OFFSET) \
do { \
if (TDB_IS_LARGE_PAGE(PPAGE)) { \
TDB_LPAGE_FREE_CELL_NXOFFSET_SET(PCELL, OFFSET); \
} else { \
TDB_SPAGE_FREE_CELL_NXOFFSET_SET(PCELL, OFFSET); \
} \
} while (0)
static
int
tdbPageAllocate
(
SPage
*
pPage
,
int
size
,
SCell
**
ppCell
);
static
int
tdbPageDefragment
(
SPage
*
pPage
);
int
tdbPageCreate
(
int
pageSize
,
SPage
**
ppPage
,
void
*
(
*
xMalloc
)(
void
*
,
size_t
),
void
*
arg
)
{
SPage
*
pPage
;
u8
*
ptr
;
int
size
;
ASSERT
(
TDB_IS_PGSIZE_VLD
(
pageSize
));
*
ppPage
=
NULL
;
size
=
pageSize
+
sizeof
(
*
pPage
);
ptr
=
(
u8
*
)((
*
xMalloc
)(
arg
,
size
));
if
(
pPage
==
NULL
)
{
return
-
1
;
}
memset
(
ptr
,
0
,
size
);
pPage
=
(
SPage
*
)(
ptr
+
pageSize
);
pPage
->
pData
=
ptr
;
pPage
->
pageSize
=
pageSize
;
if
(
pageSize
<
65536
)
{
pPage
->
szOffset
=
2
;
pPage
->
szPageHdr
=
sizeof
(
SPageHdr
);
pPage
->
szFreeCell
=
sizeof
(
SFreeCell
);
}
else
{
pPage
->
szOffset
=
3
;
pPage
->
szPageHdr
=
sizeof
(
SPageHdrL
);
pPage
->
szFreeCell
=
sizeof
(
SFreeCellL
);
}
TDB_INIT_PAGE_LOCK
(
pPage
);
/* TODO */
*
ppPage
=
pPage
;
return
0
;
}
int
tdbPageDestroy
(
SPage
*
pPage
,
void
(
*
xFree
)(
void
*
arg
,
void
*
ptr
),
void
*
arg
)
{
u8
*
ptr
;
ptr
=
pPage
->
pData
;
(
*
xFree
)(
arg
,
ptr
);
return
0
;
}
int
tdbPageInsertCell
(
SPage
*
pPage
,
int
idx
,
SCell
*
pCell
,
int
szCell
)
{
int
ret
;
SCell
*
pTarget
;
u8
*
pTmp
;
int
j
;
if
(
pPage
->
nOverflow
||
szCell
+
pPage
->
szOffset
>
pPage
->
nFree
)
{
// TODO: need to figure out if pCell may be used by outside of this function
j
=
pPage
->
nOverflow
++
;
pPage
->
apOvfl
[
j
]
=
pCell
;
pPage
->
aiOvfl
[
j
]
=
idx
;
}
else
{
ret
=
tdbPageAllocate
(
pPage
,
szCell
,
&
pTarget
);
if
(
ret
<
0
)
{
return
-
1
;
}
memcpy
(
pTarget
,
pCell
,
szCell
);
pTmp
=
pPage
->
pCellIdx
+
idx
*
pPage
->
szOffset
;
memmove
(
pTmp
+
pPage
->
szOffset
,
pTmp
,
pPage
->
pFreeStart
-
pTmp
-
pPage
->
szOffset
);
TDB_PAGE_CELL_OFFSET_AT_SET
(
pPage
,
idx
,
pTarget
-
pPage
->
pData
);
TDB_PAGE_NCELLS_SET
(
pPage
,
TDB_PAGE_NCELLS
(
pPage
)
+
1
);
}
return
0
;
}
int
tdbPageDropCell
(
SPage
*
pPage
,
int
idx
)
{
// TODO
return
0
;
}
static
int
tdbPageAllocate
(
SPage
*
pPage
,
int
size
,
SCell
**
ppCell
)
{
SCell
*
pCell
;
SFreeCell
*
pFreeCell
;
u8
*
pOffset
;
int
ret
;
ASSERT
(
pPage
->
nFree
>
size
+
pPage
->
szOffset
);
pCell
=
NULL
;
*
ppCell
=
NULL
;
// 1. Try to allocate from the free space area
if
(
pPage
->
pFreeEnd
-
pPage
->
pFreeStart
>
size
+
pPage
->
szOffset
)
{
pPage
->
pFreeEnd
-=
size
;
pPage
->
pFreeStart
+=
pPage
->
szOffset
;
pCell
=
pPage
->
pFreeEnd
;
}
// 2. Try to allocate from the page free list
if
((
pCell
==
NULL
)
&&
(
pPage
->
pFreeEnd
-
pPage
->
pFreeStart
>=
pPage
->
szOffset
)
&&
TDB_PAGE_FCELL
(
pPage
))
{
int
szCell
;
int
nxOffset
;
pCell
=
pPage
->
pData
+
TDB_PAGE_FCELL
(
pPage
);
pOffset
=
TDB_IS_LARGE_PAGE
(
pPage
)
?
((
SPageHdrL
*
)(
pPage
->
pPageHdr
))[
0
].
fCell
:
(
u8
*
)
&
(((
SPageHdr
*
)(
pPage
->
pPageHdr
))[
0
].
fCell
);
szCell
=
TDB_PAGE_FREE_CELL_SIZE
(
pPage
,
pCell
);
nxOffset
=
TDB_PAGE_FREE_CELL_NXOFFSET
(
pPage
,
pCell
);
for
(;;)
{
// Find a cell
if
(
szCell
>=
size
)
{
if
(
szCell
-
size
>=
pPage
->
szFreeCell
)
{
SCell
*
pTmpCell
=
pCell
+
size
;
TDB_PAGE_FREE_CELL_SIZE_SET
(
pPage
,
pTmpCell
,
szCell
-
size
);
TDB_PAGE_FREE_CELL_NXOFFSET_SET
(
pPage
,
pTmpCell
,
nxOffset
);
// TODO: *pOffset = pTmpCell - pPage->pData;
}
else
{
TDB_PAGE_NFREE_SET
(
pPage
,
TDB_PAGE_NFREE
(
pPage
)
+
szCell
-
size
);
// TODO: *pOffset = nxOffset;
}
break
;
}
// Not find a cell yet
if
(
nxOffset
>
0
)
{
pCell
=
pPage
->
pData
+
nxOffset
;
pOffset
=
TDB_PAGE_FREE_CELL_NXOFFSET_PTR
(
pPage
,
pCell
);
szCell
=
TDB_PAGE_FREE_CELL_SIZE
(
pPage
,
pCell
);
nxOffset
=
TDB_PAGE_FREE_CELL_NXOFFSET
(
pPage
,
pCell
);
continue
;
}
else
{
pCell
=
NULL
;
break
;
}
}
if
(
pCell
)
{
pPage
->
pFreeStart
=
pPage
->
pFreeStart
+
pPage
->
szOffset
;
}
}
// 3. Try to dfragment and allocate again
if
(
pCell
==
NULL
)
{
ret
=
tdbPageDefragment
(
pPage
);
if
(
ret
<
0
)
{
return
-
1
;
}
ASSERT
(
pPage
->
pFreeEnd
-
pPage
->
pFreeStart
>
size
+
pPage
->
szOffset
);
ASSERT
(
pPage
->
nFree
==
pPage
->
pFreeEnd
-
pPage
->
pFreeStart
);
// Allocate from the free space area again
pPage
->
pFreeEnd
-=
size
;
pPage
->
pFreeStart
+=
pPage
->
szOffset
;
pCell
=
pPage
->
pFreeEnd
;
}
ASSERT
(
pCell
!=
NULL
);
pPage
->
nFree
=
pPage
->
nFree
-
size
-
pPage
->
szOffset
;
*
ppCell
=
pCell
;
return
0
;
}
static
int
tdbPageFree
(
SPage
*
pPage
,
int
idx
,
SCell
*
pCell
,
int
size
)
{
// TODO
return
0
;
}
static
int
tdbPageDefragment
(
SPage
*
pPage
)
{
// TODO
ASSERT
(
0
);
return
0
;
}
\ No newline at end of file
source/libs/tdb/src/db/tdbPager.c
浏览文件 @
a82fc113
...
@@ -60,7 +60,7 @@ int tdbPagerOpen(SPCache *pCache, const char *fileName, SPager **ppPager) {
...
@@ -60,7 +60,7 @@ int tdbPagerOpen(SPCache *pCache, const char *fileName, SPager **ppPager) {
zsize
=
sizeof
(
*
pPager
)
/* SPager */
zsize
=
sizeof
(
*
pPager
)
/* SPager */
+
fsize
+
1
/* dbFileName */
+
fsize
+
1
/* dbFileName */
+
fsize
+
8
+
1
;
/* jFileName */
+
fsize
+
8
+
1
;
/* jFileName */
pPtr
=
(
uint8_t
*
)
taosMemoryC
alloc
(
1
,
zsize
);
pPtr
=
(
uint8_t
*
)
c
alloc
(
1
,
zsize
);
if
(
pPtr
==
NULL
)
{
if
(
pPtr
==
NULL
)
{
return
-
1
;
return
-
1
;
}
}
...
@@ -255,6 +255,10 @@ int tdbPagerNewPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initPage
...
@@ -255,6 +255,10 @@ int tdbPagerNewPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initPage
return
0
;
return
0
;
}
}
void
tdbPagerReturnPage
(
SPager
*
pPager
,
SPage
*
pPage
)
{
tdbPCacheRelease
(
pPager
->
pCache
,
pPage
);
}
static
int
tdbPagerAllocFreePage
(
SPager
*
pPager
,
SPgno
*
ppgno
)
{
static
int
tdbPagerAllocFreePage
(
SPager
*
pPager
,
SPgno
*
ppgno
)
{
// TODO: Allocate a page from the free list
// TODO: Allocate a page from the free list
return
0
;
return
0
;
...
...
source/libs/tdb/src/inc/tdbBtree.h
浏览文件 @
a82fc113
...
@@ -20,10 +20,15 @@
...
@@ -20,10 +20,15 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
typedef
struct
SBTree
SBTree
;
typedef
struct
SBTree
SBTree
;
typedef
struct
SBtCursor
SBtCursor
;
typedef
struct
SBTC
SBTC
;
typedef
struct
SBtInfo
{
SPgno
root
;
int
nLevel
;
int
nData
;
}
SBtInfo
;
struct
SB
tCursor
{
struct
SB
TC
{
SBTree
*
pBt
;
SBTree
*
pBt
;
i8
iPage
;
i8
iPage
;
SPage
*
pPage
;
SPage
*
pPage
;
...
@@ -33,10 +38,19 @@ struct SBtCursor {
...
@@ -33,10 +38,19 @@ struct SBtCursor {
void
*
pBuf
;
void
*
pBuf
;
};
};
// SBTree
int
tdbBtreeOpen
(
int
keyLen
,
int
valLen
,
SPager
*
pFile
,
FKeyComparator
kcmpr
,
SBTree
**
ppBt
);
int
tdbBtreeOpen
(
int
keyLen
,
int
valLen
,
SPager
*
pFile
,
FKeyComparator
kcmpr
,
SBTree
**
ppBt
);
int
tdbBtreeClose
(
SBTree
*
pBt
);
int
tdbBtreeClose
(
SBTree
*
pBt
);
int
tdbBtreeCursor
(
SBtCursor
*
pCur
,
SBTree
*
pBt
);
int
tdbBtCursorInsert
(
SBTC
*
pCur
,
const
void
*
pKey
,
int
kLen
,
const
void
*
pVal
,
int
vLen
);
int
tdbBtCursorInsert
(
SBtCursor
*
pCur
,
const
void
*
pKey
,
int
kLen
,
const
void
*
pVal
,
int
vLen
);
int
tdbBtreeGet
(
SBTree
*
pBt
,
const
void
*
pKey
,
int
kLen
,
void
**
ppVal
,
int
*
vLen
);
// SBTC
int
tdbBtcOpen
(
SBTC
*
pCur
,
SBTree
*
pBt
);
int
tdbBtcMoveToFirst
(
SBTC
*
pBtc
);
int
tdbBtcMoveToLast
(
SBTC
*
pBtc
);
int
tdbBtcMoveTo
(
SBTC
*
pBtc
,
const
void
*
pKey
,
int
kLen
);
int
tdbBtreeNext
(
SBTC
*
pBtc
,
void
**
ppKey
,
int
*
kLen
,
void
**
ppVal
,
int
*
vLen
);
int
tdbBtcClose
(
SBTC
*
pBtc
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/tdb/src/inc/tdbDb.h
浏览文件 @
a82fc113
...
@@ -20,12 +20,20 @@
...
@@ -20,12 +20,20 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
typedef
struct
STDb
STDb
;
typedef
struct
STDB
STDB
;
typedef
struct
STDBC
STDBC
;
int
tdbDbOpen
(
const
char
*
fname
,
int
keyLen
,
int
valLen
,
FKeyComparator
keyCmprFn
,
STEnv
*
pEnv
,
STDb
**
ppDb
);
// STDB
int
tdbDbClose
(
STDb
*
pDb
);
int
tdbDbOpen
(
const
char
*
fname
,
int
keyLen
,
int
valLen
,
FKeyComparator
keyCmprFn
,
STEnv
*
pEnv
,
STDB
**
ppDb
);
int
tdbDbDrop
(
STDb
*
pDb
);
int
tdbDbClose
(
STDB
*
pDb
);
int
tdbDbInsert
(
STDb
*
pDb
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
);
int
tdbDbDrop
(
STDB
*
pDb
);
int
tdbDbInsert
(
STDB
*
pDb
,
const
void
*
pKey
,
int
keyLen
,
const
void
*
pVal
,
int
valLen
);
int
tdbDbGet
(
STDB
*
pDb
,
const
void
*
pKey
,
int
kLen
,
void
**
ppVal
,
int
*
vLen
);
// STDBC
int
tdbDbcOpen
(
STDB
*
pDb
,
STDBC
**
ppDbc
);
int
tdbDbNext
(
STDBC
*
pDbc
,
void
**
ppKey
,
int
*
kLen
,
void
**
ppVal
,
int
*
vLen
);
int
tdbDbcClose
(
STDBC
*
pDbc
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/tdb/src/inc/tdbInt.h
浏览文件 @
a82fc113
...
@@ -95,7 +95,7 @@ static FORCE_INLINE int tdbCmprPgId(const void *p1, const void *p2) {
...
@@ -95,7 +95,7 @@ static FORCE_INLINE int tdbCmprPgId(const void *p1, const void *p2) {
// tdb_log
// tdb_log
#define tdbError(var)
#define tdbError(var)
typedef
TD_DLIST
(
STD
b
)
STDbList
;
typedef
TD_DLIST
(
STD
B
)
STDbList
;
typedef
TD_DLIST
(
SPgFile
)
SPgFileList
;
typedef
TD_DLIST
(
SPgFile
)
SPgFileList
;
typedef
TD_DLIST_NODE
(
SPgFile
)
SPgFileListNode
;
typedef
TD_DLIST_NODE
(
SPgFile
)
SPgFileListNode
;
...
@@ -141,8 +141,8 @@ typedef int (*FKeyComparator)(const void *pKey1, int kLen1, const void *pKey2, i
...
@@ -141,8 +141,8 @@ typedef int (*FKeyComparator)(const void *pKey1, int kLen1, const void *pKey2, i
#define TDB_FLAG_IS(flags, flag) ((flags) == (flag))
#define TDB_FLAG_IS(flags, flag) ((flags) == (flag))
#define TDB_FLAG_HAS(flags, flag) (((flags) & (flag)) != 0)
#define TDB_FLAG_HAS(flags, flag) (((flags) & (flag)) != 0)
#define TDB_FLAG_NO(flags, flag) ((flags) & (flag) == 0)
#define TDB_FLAG_NO(flags, flag) ((flags) & (flag) == 0)
#define TDB_FLAG_ADD(flags, flag) ((flags) |
=
(flag))
#define TDB_FLAG_ADD(flags, flag) ((flags) | (flag))
#define TDB_FLAG_REMOVE(flags, flag) ((flags) &
=
(~(flag)))
#define TDB_FLAG_REMOVE(flags, flag) ((flags) & (~(flag)))
typedef
struct
SPager
SPager
;
typedef
struct
SPager
SPager
;
typedef
struct
SPCache
SPCache
;
typedef
struct
SPCache
SPCache
;
...
...
source/libs/tdb/src/inc/tdbPCache.h
浏览文件 @
a82fc113
...
@@ -21,23 +21,22 @@ extern "C" {
...
@@ -21,23 +21,22 @@ extern "C" {
#endif
#endif
#define TDB_PCACHE_PAGE \
#define TDB_PCACHE_PAGE \
u8 isAnchor; \
u8 isAnchor; \
u8 isLocalPage; \
u8 isLocalPage; \
u8 isDirty; \
u8 isDirty; \
i32 nRef; \
i32 nRef; \
SPCache *pCache; \
SPage *pFreeNext; \
SPage *pFreeNext; \
SPage *pHashNext; \
SPage *pHashNext; \
SPage *pLruNext; \
SPage *pLruNext; \
SPage *pLruPrev; \
SPage *pLruPrev; \
SPage *pDirtyNext; \
SPage *pDirtyNext; \
SPager *pPager; \
SPager *pPager; \
SPgid pgid;
SPgid pgid;
int
tdbPCacheOpen
(
int
pageSize
,
int
cacheSize
,
SPCache
**
ppCache
);
int
tdbPCacheOpen
(
int
pageSize
,
int
cacheSize
,
SPCache
**
ppCache
);
int
tdbPCacheClose
(
SPCache
*
pCache
);
int
tdbPCacheClose
(
SPCache
*
pCache
);
SPage
*
tdbPCacheFetch
(
SPCache
*
pCache
,
const
SPgid
*
pPgid
,
bool
alcNewPage
);
SPage
*
tdbPCacheFetch
(
SPCache
*
pCache
,
const
SPgid
*
pPgid
,
bool
alcNewPage
);
void
tdbPCacheRelease
(
SPage
*
pPage
);
void
tdbPCacheRelease
(
SP
Cache
*
pCache
,
SP
age
*
pPage
);
int
tdbPCacheGetPageSize
(
SPCache
*
pCache
);
int
tdbPCacheGetPageSize
(
SPCache
*
pCache
);
#ifdef __cplusplus
#ifdef __cplusplus
...
...
source/libs/tdb/src/inc/tdbPage.h
浏览文件 @
a82fc113
...
@@ -27,9 +27,6 @@ typedef struct {
...
@@ -27,9 +27,6 @@ typedef struct {
int
szOffset
;
int
szOffset
;
int
szPageHdr
;
int
szPageHdr
;
int
szFreeCell
;
int
szFreeCell
;
// flags
u16
(
*
getFlags
)(
SPage
*
);
void
(
*
setFlags
)(
SPage
*
,
u16
);
// cell number
// cell number
int
(
*
getCellNum
)(
SPage
*
);
int
(
*
getCellNum
)(
SPage
*
);
void
(
*
setCellNum
)(
SPage
*
,
int
);
void
(
*
setCellNum
)(
SPage
*
,
int
);
...
@@ -45,6 +42,9 @@ typedef struct {
...
@@ -45,6 +42,9 @@ typedef struct {
// cell offset at idx
// cell offset at idx
int
(
*
getCellOffset
)(
SPage
*
,
int
);
int
(
*
getCellOffset
)(
SPage
*
,
int
);
void
(
*
setCellOffset
)(
SPage
*
,
int
,
int
);
void
(
*
setCellOffset
)(
SPage
*
,
int
,
int
);
// free cell info
void
(
*
getFreeCellInfo
)(
SCell
*
pCell
,
int
*
szCell
,
int
*
nxOffset
);
void
(
*
setFreeCellInfo
)(
SCell
*
pCell
,
int
szCell
,
int
nxOffset
);
}
SPageMethods
;
}
SPageMethods
;
// Page footer
// Page footer
...
@@ -53,58 +53,37 @@ typedef struct __attribute__((__packed__)) {
...
@@ -53,58 +53,37 @@ typedef struct __attribute__((__packed__)) {
}
SPageFtr
;
}
SPageFtr
;
struct
SPage
{
struct
SPage
{
TdThreadSpinlock
lock
;
pthread_spinlock_t
lock
;
u8
*
pData
;
int
pageSize
;
int
pageSize
;
u8
*
pData
;
SPageMethods
*
pPageMethods
;
SPageMethods
*
pPageMethods
;
// Fields below used by pager and am
// Fields below used by pager and am
u8
szAmHdr
;
u8
*
pPageHdr
;
u8
*
pPageHdr
;
u8
*
pAmHdr
;
u8
*
pCellIdx
;
u8
*
pCellIdx
;
u8
*
pFreeStart
;
u8
*
pFreeStart
;
u8
*
pFreeEnd
;
u8
*
pFreeEnd
;
SPageFtr
*
pPageFtr
;
SPageFtr
*
pPageFtr
;
int
nOverflow
;
SCell
*
apOvfl
[
4
];
int
aiOvfl
[
4
];
int
kLen
;
// key length of the page, -1 for unknown
int
kLen
;
// key length of the page, -1 for unknown
int
vLen
;
// value length of the page, -1 for unknown
int
vLen
;
// value length of the page, -1 for unknown
int
nFree
;
int
maxLocal
;
int
maxLocal
;
int
minLocal
;
int
minLocal
;
int
nOverflow
;
int
(
*
xCellSize
)(
const
SPage
*
,
SCell
*
);
SCell
*
apOvfl
[
4
];
int
aiOvfl
[
4
];
// Fields used by SPCache
// Fields used by SPCache
TDB_PCACHE_PAGE
TDB_PCACHE_PAGE
};
};
/* For page */
#define TDB_PAGE_FLAGS(pPage) (*(pPage)->pPageMethods->getFlags)(pPage)
#define TDB_PAGE_NCELLS(pPage) (*(pPage)->pPageMethods->getCellNum)(pPage)
#define TDB_PAGE_CCELLS(pPage) (*(pPage)->pPageMethods->getCellBody)(pPage)
#define TDB_PAGE_FCELL(pPage) (*(pPage)->pPageMethods->getCellFree)(pPage)
#define TDB_PAGE_NFREE(pPage) (*(pPage)->pPageMethods->getFreeBytes)(pPage)
#define TDB_PAGE_CELL_OFFSET_AT(pPage, idx) (*(pPage)->pPageMethods->getCellOffset)(pPage, idx)
#define TDB_PAGE_FLAGS_SET(pPage, FLAGS) (*(pPage)->pPageMethods->setFlags)(pPage, FLAGS)
#define TDB_PAGE_NCELLS_SET(pPage, NCELLS) (*(pPage)->pPageMethods->setCellNum)(pPage, NCELLS)
#define TDB_PAGE_CCELLS_SET(pPage, CCELLS) (*(pPage)->pPageMethods->setCellBody)(pPage, CCELLS)
#define TDB_PAGE_FCELL_SET(pPage, FCELL) (*(pPage)->pPageMethods->setCellFree)(pPage, FCELL)
#define TDB_PAGE_NFREE_SET(pPage, NFREE) (*(pPage)->pPageMethods->setFreeBytes)(pPage, NFREE)
#define TDB_PAGE_CELL_OFFSET_AT_SET(pPage, idx, OFFSET) (*(pPage)->pPageMethods->setCellOffset)(pPage, idx, OFFSET)
#define TDB_PAGE_OFFSET_SIZE(pPage) ((pPage)->pPageMethods->szOffset)
#define TDB_PAGE_CELL_AT(pPage, idx) ((pPage)->pData + TDB_PAGE_CELL_OFFSET_AT(pPage, idx))
// For page lock
// For page lock
#define P_LOCK_SUCC 0
#define P_LOCK_SUCC 0
#define P_LOCK_BUSY 1
#define P_LOCK_BUSY 1
#define P_LOCK_FAIL -1
#define P_LOCK_FAIL -1
#define TDB_INIT_PAGE_LOCK(pPage)
taosThreadSpinI
nit(&((pPage)->lock), 0)
#define TDB_INIT_PAGE_LOCK(pPage)
pthread_spin_i
nit(&((pPage)->lock), 0)
#define TDB_DESTROY_PAGE_LOCK(pPage)
taosThreadSpinD
estroy(&((pPage)->lock))
#define TDB_DESTROY_PAGE_LOCK(pPage)
pthread_spin_d
estroy(&((pPage)->lock))
#define TDB_LOCK_PAGE(pPage)
taosThreadSpinL
ock(&((pPage)->lock))
#define TDB_LOCK_PAGE(pPage)
pthread_spin_l
ock(&((pPage)->lock))
#define TDB_UNLOCK_PAGE(pPage)
taosThreadSpinU
nlock(&((pPage)->lock))
#define TDB_UNLOCK_PAGE(pPage)
pthread_spin_u
nlock(&((pPage)->lock))
#define TDB_TRY_LOCK_PAGE(pPage) \
#define TDB_TRY_LOCK_PAGE(pPage) \
({ \
({ \
int ret; \
int ret; \
...
@@ -119,10 +98,43 @@ struct SPage {
...
@@ -119,10 +98,43 @@ struct SPage {
})
})
// APIs
// APIs
int
tdbPageCreate
(
int
pageSize
,
SPage
**
ppPage
,
void
*
(
*
xMalloc
)(
void
*
,
size_t
),
void
*
arg
);
#define TDB_PAGE_TOTAL_CELLS(pPage) ((pPage)->nOverflow + (pPage)->pPageMethods->getCellNum(pPage))
int
tdbPageDestroy
(
SPage
*
pPage
,
void
(
*
xFree
)(
void
*
arg
,
void
*
ptr
),
void
*
arg
);
#define TDB_PAGE_USABLE_SIZE(pPage) ((u8 *)(pPage)->pPageFtr - (pPage)->pCellIdx)
int
tdbPageInsertCell
(
SPage
*
pPage
,
int
idx
,
SCell
*
pCell
,
int
szCell
);
#define TDB_PAGE_PGNO(pPage) ((pPage)->pgid.pgno)
int
tdbPageDropCell
(
SPage
*
pPage
,
int
idx
);
#define TDB_BYTES_CELL_TAKEN(pPage, pCell) ((*(pPage)->xCellSize)(pPage, pCell) + (pPage)->pPageMethods->szOffset)
#define TDB_PAGE_OFFSET_SIZE(pPage) ((pPage)->pPageMethods->szOffset)
int
tdbPageCreate
(
int
pageSize
,
SPage
**
ppPage
,
void
*
(
*
xMalloc
)(
void
*
,
size_t
),
void
*
arg
);
int
tdbPageDestroy
(
SPage
*
pPage
,
void
(
*
xFree
)(
void
*
arg
,
void
*
ptr
),
void
*
arg
);
void
tdbPageZero
(
SPage
*
pPage
,
u8
szAmHdr
,
int
(
*
xCellSize
)(
const
SPage
*
,
SCell
*
));
void
tdbPageInit
(
SPage
*
pPage
,
u8
szAmHdr
,
int
(
*
xCellSize
)(
const
SPage
*
,
SCell
*
));
int
tdbPageInsertCell
(
SPage
*
pPage
,
int
idx
,
SCell
*
pCell
,
int
szCell
,
u8
asOvfl
);
int
tdbPageDropCell
(
SPage
*
pPage
,
int
idx
);
void
tdbPageCopy
(
SPage
*
pFromPage
,
SPage
*
pToPage
);
static
inline
SCell
*
tdbPageGetCell
(
SPage
*
pPage
,
int
idx
)
{
SCell
*
pCell
;
int
iOvfl
;
int
lidx
;
ASSERT
(
idx
>=
0
&&
idx
<
TDB_PAGE_TOTAL_CELLS
(
pPage
));
iOvfl
=
0
;
for
(;
iOvfl
<
pPage
->
nOverflow
;
iOvfl
++
)
{
if
(
pPage
->
aiOvfl
[
iOvfl
]
==
idx
)
{
pCell
=
pPage
->
apOvfl
[
iOvfl
];
return
pCell
;
}
else
if
(
pPage
->
aiOvfl
[
iOvfl
]
>
idx
)
{
break
;
}
}
lidx
=
idx
-
iOvfl
;
ASSERT
(
lidx
>=
0
&&
lidx
<
pPage
->
pPageMethods
->
getCellNum
(
pPage
));
pCell
=
pPage
->
pData
+
pPage
->
pPageMethods
->
getCellOffset
(
pPage
,
lidx
);
return
pCell
;
}
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/tdb/src/inc/tdbPager.h
浏览文件 @
a82fc113
...
@@ -20,15 +20,16 @@
...
@@ -20,15 +20,16 @@
extern
"C"
{
extern
"C"
{
#endif
#endif
int
tdbPagerOpen
(
SPCache
*
pCache
,
const
char
*
fileName
,
SPager
**
ppPager
);
int
tdbPagerOpen
(
SPCache
*
pCache
,
const
char
*
fileName
,
SPager
**
ppPager
);
int
tdbPagerClose
(
SPager
*
pPager
);
int
tdbPagerClose
(
SPager
*
pPager
);
int
tdbPagerOpenDB
(
SPager
*
pPager
,
SPgno
*
ppgno
,
bool
toCreate
);
int
tdbPagerOpenDB
(
SPager
*
pPager
,
SPgno
*
ppgno
,
bool
toCreate
);
int
tdbPagerWrite
(
SPager
*
pPager
,
SPage
*
pPage
);
int
tdbPagerWrite
(
SPager
*
pPager
,
SPage
*
pPage
);
int
tdbPagerBegin
(
SPager
*
pPager
);
int
tdbPagerBegin
(
SPager
*
pPager
);
int
tdbPagerCommit
(
SPager
*
pPager
);
int
tdbPagerCommit
(
SPager
*
pPager
);
int
tdbPagerGetPageSize
(
SPager
*
pPager
);
int
tdbPagerGetPageSize
(
SPager
*
pPager
);
int
tdbPagerFetchPage
(
SPager
*
pPager
,
SPgno
pgno
,
SPage
**
ppPage
,
int
(
*
initPage
)(
SPage
*
,
void
*
),
void
*
arg
);
int
tdbPagerFetchPage
(
SPager
*
pPager
,
SPgno
pgno
,
SPage
**
ppPage
,
int
(
*
initPage
)(
SPage
*
,
void
*
),
void
*
arg
);
int
tdbPagerNewPage
(
SPager
*
pPager
,
SPgno
*
ppgno
,
SPage
**
ppPage
,
int
(
*
initPage
)(
SPage
*
,
void
*
),
void
*
arg
);
int
tdbPagerNewPage
(
SPager
*
pPager
,
SPgno
*
ppgno
,
SPage
**
ppPage
,
int
(
*
initPage
)(
SPage
*
,
void
*
),
void
*
arg
);
void
tdbPagerReturnPage
(
SPager
*
pPager
,
SPage
*
pPage
);
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
source/libs/tdb/src/inc/tdbUtil.h
浏览文件 @
a82fc113
...
@@ -39,6 +39,38 @@ int tdbGetFileSize(const char *fname, int pgSize, SPgno *pSize);
...
@@ -39,6 +39,38 @@ int tdbGetFileSize(const char *fname, int pgSize, SPgno *pSize);
int
tdbPRead
(
int
fd
,
void
*
pData
,
int
count
,
i64
offset
);
int
tdbPRead
(
int
fd
,
void
*
pData
,
int
count
,
i64
offset
);
#define TDB_REALLOC(PTR, SIZE) \
({ \
void *nPtr; \
if ((PTR) == NULL || ((int *)(PTR))[-1] < (SIZE)) { \
nPtr = realloc((PTR) ? (char *)(PTR) - sizeof(int) : NULL, (SIZE) + sizeof(int)); \
if (nPtr) { \
((int *)nPtr)[0] = (SIZE); \
nPtr = (char *)nPtr + sizeof(int); \
} \
} else { \
nPtr = (PTR); \
} \
nPtr; \
})
#define TDB_FREE(PTR) \
do { \
if (PTR) { \
free((char *)(PTR) - sizeof(int)); \
} \
} while (0)
static
inline
void
*
tdbOsMalloc
(
void
*
arg
,
size_t
size
)
{
void
*
ptr
;
ptr
=
malloc
(
size
);
return
ptr
;
}
static
inline
void
tdbOsFree
(
void
*
arg
,
void
*
ptr
)
{
free
(
ptr
);
}
static
inline
int
tdbPutVarInt
(
u8
*
p
,
int
v
)
{
static
inline
int
tdbPutVarInt
(
u8
*
p
,
int
v
)
{
int
n
=
0
;
int
n
=
0
;
...
...
source/libs/tdb/src/page/tdbPage.c
浏览文件 @
a82fc113
此差异已折叠。
点击以展开。
source/libs/tdb/src/page/tdbPageL.c
浏览文件 @
a82fc113
...
@@ -16,11 +16,10 @@
...
@@ -16,11 +16,10 @@
#include "tdbInt.h"
#include "tdbInt.h"
typedef
struct
__attribute__
((
__packed__
))
{
typedef
struct
__attribute__
((
__packed__
))
{
u16
flags
;
u8
cellNum
[
3
];
u8
cellNum
[
3
];
u8
cellBody
[
3
];
u8
cellBody
[
3
];
u8
cellFree
[
3
];
u8
cellFree
[
3
];
u8
nFree
[
3
];
u8
nFree
[
3
];
}
SPageHdrL
;
}
SPageHdrL
;
typedef
struct
__attribute__
((
__packed__
))
{
typedef
struct
__attribute__
((
__packed__
))
{
...
@@ -28,10 +27,6 @@ typedef struct __attribute__((__packed__)) {
...
@@ -28,10 +27,6 @@ typedef struct __attribute__((__packed__)) {
u8
nxOffset
[
3
];
u8
nxOffset
[
3
];
}
SFreeCellL
;
}
SFreeCellL
;
// flags
static
inline
u16
getPageFlags
(
SPage
*
pPage
)
{
return
((
SPageHdrL
*
)(
pPage
->
pPageHdr
))[
0
].
flags
;
}
static
inline
void
setPageFlags
(
SPage
*
pPage
,
u16
flags
)
{
((
SPageHdrL
*
)(
pPage
->
pPageHdr
))[
0
].
flags
=
flags
;
}
// cellNum
// cellNum
static
inline
int
getPageCellNum
(
SPage
*
pPage
)
{
return
TDB_GET_U24
(((
SPageHdrL
*
)(
pPage
->
pPageHdr
))[
0
].
cellNum
);
}
static
inline
int
getPageCellNum
(
SPage
*
pPage
)
{
return
TDB_GET_U24
(((
SPageHdrL
*
)(
pPage
->
pPageHdr
))[
0
].
cellNum
);
}
static
inline
void
setPageCellNum
(
SPage
*
pPage
,
int
cellNum
)
{
static
inline
void
setPageCellNum
(
SPage
*
pPage
,
int
cellNum
)
{
...
@@ -66,20 +61,33 @@ static inline void setPageCellOffset(SPage *pPage, int idx, int offset) {
...
@@ -66,20 +61,33 @@ static inline void setPageCellOffset(SPage *pPage, int idx, int offset) {
TDB_PUT_U24
(
pPage
->
pCellIdx
+
3
*
idx
,
offset
);
TDB_PUT_U24
(
pPage
->
pCellIdx
+
3
*
idx
,
offset
);
}
}
// free cell info
static
inline
void
getPageFreeCellInfo
(
SCell
*
pCell
,
int
*
szCell
,
int
*
nxOffset
)
{
SFreeCellL
*
pFreeCell
=
(
SFreeCellL
*
)
pCell
;
*
szCell
=
TDB_GET_U24
(
pFreeCell
->
szCell
);
*
nxOffset
=
TDB_GET_U24
(
pFreeCell
->
nxOffset
);
}
static
inline
void
setPageFreeCellInfo
(
SCell
*
pCell
,
int
szCell
,
int
nxOffset
)
{
SFreeCellL
*
pFreeCell
=
(
SFreeCellL
*
)
pCell
;
TDB_PUT_U24
(
pFreeCell
->
szCell
,
szCell
);
TDB_PUT_U24
(
pFreeCell
->
nxOffset
,
nxOffset
);
}
SPageMethods
pageLargeMethods
=
{
SPageMethods
pageLargeMethods
=
{
3
,
// szOffset
3
,
// szOffset
sizeof
(
SPageHdrL
),
// szPageHdr
sizeof
(
SPageHdrL
),
// szPageHdr
sizeof
(
SFreeCellL
),
// szFreeCell
sizeof
(
SFreeCellL
),
// szFreeCell
getPage
Flags
,
// getPageFlags
getPage
CellNum
,
// getCellNum
setPage
Flags
,
// setFlagsp
setPage
CellNum
,
// setCellNum
getPageCell
Num
,
// getCellNum
getPageCell
Body
,
// getCellBody
setPageCell
Num
,
// setCellNum
setPageCell
Body
,
// setCellBody
getPageCell
Body
,
// getCellBody
getPageCell
Free
,
// getCellFree
setPageCell
Body
,
// setCellBody
setPageCell
Free
,
// setCellFree
getPage
CellFree
,
// getCellFree
getPage
NFree
,
// getFreeBytes
setPage
CellFree
,
// setCellFree
setPage
NFree
,
// setFreeBytes
getPage
NFree
,
// getFreeBytes
getPage
CellOffset
,
// getCellOffset
setPage
NFree
,
// setFreeBytes
setPage
CellOffset
,
// setCellOffset
getPage
CellOffset
,
// getCellOffset
getPage
FreeCellInfo
,
// getFreeCellInfo
setPage
CellOffset
// setCellOffset
setPage
FreeCellInfo
// setFreeCellInfo
};
};
\ No newline at end of file
source/libs/tdb/test/tdbTest.cpp
浏览文件 @
a82fc113
此差异已折叠。
点击以展开。
source/libs/wal/src/walMeta.c
浏览文件 @
a82fc113
此差异已折叠。
点击以展开。
source/libs/wal/src/walRead.c
浏览文件 @
a82fc113
此差异已折叠。
点击以展开。
source/libs/wal/src/walSeek.c
浏览文件 @
a82fc113
此差异已折叠。
点击以展开。
source/os/src/osEnv.c
浏览文件 @
a82fc113
此差异已折叠。
点击以展开。
source/os/src/osMemory.c
浏览文件 @
a82fc113
此差异已折叠。
点击以展开。
source/os/src/osTimezone.c
浏览文件 @
a82fc113
此差异已折叠。
点击以展开。
source/util/src/tprocess.c
浏览文件 @
a82fc113
此差异已折叠。
点击以展开。
tests/pytest/util/dnodes.py
浏览文件 @
a82fc113
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/basic.sim
浏览文件 @
a82fc113
此差异已折叠。
点击以展开。
tests/test/c/tmqDemo.c
浏览文件 @
a82fc113
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录