Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9833a6c5
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看板
提交
9833a6c5
编写于
4月 01, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/3.0_wxy
上级
6d4c848d
613963a1
变更
75
展开全部
显示空白变更内容
内联
并排
Showing
75 changed file
with
2930 addition
and
1079 deletion
+2930
-1079
.clang-format
.clang-format
+1
-0
example/src/tmq.c
example/src/tmq.c
+44
-8
example/src/tstream.c
example/src/tstream.c
+2
-2
include/common/tcommon.h
include/common/tcommon.h
+22
-11
include/common/trow.h
include/common/trow.h
+37
-37
include/common/ttime.h
include/common/ttime.h
+2
-0
include/libs/command/command.h
include/libs/command/command.h
+5
-0
include/libs/nodes/nodes.h
include/libs/nodes/nodes.h
+2
-0
include/libs/nodes/plannodes.h
include/libs/nodes/plannodes.h
+1
-1
include/libs/nodes/querynodes.h
include/libs/nodes/querynodes.h
+1
-0
include/libs/qcom/query.h
include/libs/qcom/query.h
+6
-0
include/libs/wal/wal.h
include/libs/wal/wal.h
+18
-16
include/os/osTime.h
include/os/osTime.h
+8
-0
include/util/tdef.h
include/util/tdef.h
+5
-0
source/client/src/tmq.c
source/client/src/tmq.c
+14
-1
source/common/src/ttime.c
source/common/src/ttime.c
+40
-1
source/dnode/mgmt/main/exe/dndMain.c
source/dnode/mgmt/main/exe/dndMain.c
+1
-8
source/dnode/mgmt/main/src/dndEnv.c
source/dnode/mgmt/main/src/dndEnv.c
+96
-0
source/dnode/mgmt/main/src/dndExec.c
source/dnode/mgmt/main/src/dndExec.c
+6
-6
source/dnode/mgmt/main/src/dndInt.c
source/dnode/mgmt/main/src/dndInt.c
+158
-54
source/dnode/mgmt/main/src/dndObj.c
source/dnode/mgmt/main/src/dndObj.c
+0
-200
source/dnode/mnode/impl/inc/mndDef.h
source/dnode/mnode/impl/inc/mndDef.h
+3
-0
source/dnode/mnode/impl/src/mndInfoSchema.c
source/dnode/mnode/impl/src/mndInfoSchema.c
+0
-1
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+0
-4
source/dnode/vnode/src/inc/tsdbCommit.h
source/dnode/vnode/src/inc/tsdbCommit.h
+1
-1
source/dnode/vnode/src/inc/tsdbDef.h
source/dnode/vnode/src/inc/tsdbDef.h
+1
-1
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+1
-1
source/dnode/vnode/src/meta/metaTbUid.c
source/dnode/vnode/src/meta/metaTbUid.c
+1
-1
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+54
-34
source/dnode/vnode/src/tq/tqRead.c
source/dnode/vnode/src/tq/tqRead.c
+1
-0
source/dnode/vnode/src/tsdb/tsdbCommit.c
source/dnode/vnode/src/tsdb/tsdbCommit.c
+1
-1
source/dnode/vnode/src/tsdb/tsdbRead.c
source/dnode/vnode/src/tsdb/tsdbRead.c
+1
-1
source/dnode/vnode/src/vnd/vnodeQuery.c
source/dnode/vnode/src/vnd/vnodeQuery.c
+1
-1
source/dnode/vnode/src/vnd/vnodeWrite.c
source/dnode/vnode/src/vnd/vnodeWrite.c
+1
-0
source/libs/catalog/inc/catalogInt.h
source/libs/catalog/inc/catalogInt.h
+19
-4
source/libs/catalog/src/catalog.c
source/libs/catalog/src/catalog.c
+119
-238
source/libs/catalog/src/catalogDbg.c
source/libs/catalog/src/catalogDbg.c
+222
-0
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+45
-45
source/libs/command/inc/commandInt.h
source/libs/command/inc/commandInt.h
+99
-0
source/libs/command/src/explain.c
source/libs/command/src/explain.c
+687
-0
source/libs/executor/inc/executil.h
source/libs/executor/inc/executil.h
+17
-35
source/libs/executor/inc/executorimpl.h
source/libs/executor/inc/executorimpl.h
+1
-3
source/libs/executor/src/executil.c
source/libs/executor/src/executil.c
+55
-75
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+77
-65
source/libs/index/inc/indexFstRegex.h
source/libs/index/inc/indexFstRegex.h
+4
-3
source/libs/index/inc/indexFstSparse.h
source/libs/index/inc/indexFstSparse.h
+3
-3
source/libs/index/src/index.c
source/libs/index/src/index.c
+1
-1
source/libs/index/src/indexCache.c
source/libs/index/src/indexCache.c
+2
-2
source/libs/index/src/indexFstCommon.c
source/libs/index/src/indexFstCommon.c
+1
-1
source/libs/index/src/indexFstRegex.c
source/libs/index/src/indexFstRegex.c
+30
-3
source/libs/index/src/indexFstSparse.c
source/libs/index/src/indexFstSparse.c
+17
-20
source/libs/nodes/inc/nodesUtil.h
source/libs/nodes/inc/nodesUtil.h
+10
-6
source/libs/nodes/src/nodesToSQLFuncs.c
source/libs/nodes/src/nodesToSQLFuncs.c
+145
-0
source/libs/nodes/src/nodesTraverseFuncs.c
source/libs/nodes/src/nodesTraverseFuncs.c
+2
-1
source/libs/nodes/src/nodesUtilFuncs.c
source/libs/nodes/src/nodesUtilFuncs.c
+65
-0
source/libs/parser/src/parTranslater.c
source/libs/parser/src/parTranslater.c
+1
-0
source/libs/planner/src/planLogicCreater.c
source/libs/planner/src/planLogicCreater.c
+1
-1
source/libs/planner/src/planPhysiCreater.c
source/libs/planner/src/planPhysiCreater.c
+5
-0
source/libs/qcom/CMakeLists.txt
source/libs/qcom/CMakeLists.txt
+1
-1
source/libs/qcom/inc/queryInt.h
source/libs/qcom/inc/queryInt.h
+0
-1
source/libs/scalar/inc/filterInt.h
source/libs/scalar/inc/filterInt.h
+0
-2
source/libs/scalar/src/sclvector.c
source/libs/scalar/src/sclvector.c
+7
-7
source/libs/scheduler/CMakeLists.txt
source/libs/scheduler/CMakeLists.txt
+1
-1
source/libs/scheduler/inc/schedulerInt.h
source/libs/scheduler/inc/schedulerInt.h
+4
-4
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+220
-147
source/libs/stream/src/tstream.c
source/libs/stream/src/tstream.c
+1
-1
source/libs/wal/src/walRead.c
source/libs/wal/src/walRead.c
+22
-1
source/os/src/osProc.c
source/os/src/osProc.c
+3
-0
source/util/src/tcompare.c
source/util/src/tcompare.c
+1
-0
source/util/src/tconfig.c
source/util/src/tconfig.c
+4
-4
source/util/src/tjson.c
source/util/src/tjson.c
+5
-4
source/util/src/tprocess.c
source/util/src/tprocess.c
+9
-8
tests/script/tsim/tmq/multiTopic.sim
tests/script/tsim/tmq/multiTopic.sim
+224
-0
tests/script/tsim/tmq/oneTopic.sim
tests/script/tsim/tmq/oneTopic.sim
+264
-0
tests/test/c/tmqSim.c
tests/test/c/tmqSim.c
+1
-1
未找到文件。
.clang-format
浏览文件 @
9833a6c5
...
...
@@ -5,6 +5,7 @@ AccessModifierOffset: -1
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: true
AlignConsecutiveMacros: true
AlignEscapedNewlinesLeft: true
AlignOperands: true
AlignTrailingComments: true
...
...
example/src/tmq.c
浏览文件 @
9833a6c5
...
...
@@ -28,7 +28,7 @@ int32_t init_env() {
return
-
1
;
}
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create database if not exists abc1 vgroups
1
"
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"create database if not exists abc1 vgroups
2
"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in create db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
...
...
@@ -42,25 +42,33 @@ int32_t init_env() {
}
taos_free_result
(
pRes
);
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, c1 int, c2 float, c3 binary(10)) tags(t1 int)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create super table st1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table if not exists
tu1 using st1 tags(1
)"
);
pRes
=
taos_query
(
pConn
,
"create table if not exists
ct0 using st1 tags(1000
)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table tu1, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"create table if not exists
tu2 using st1 tags(2
)"
);
pRes
=
taos_query
(
pConn
,
"create table if not exists
ct1 using st1 tags(2000
)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table tu2, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
pRes
=
taos_query
(
pConn
,
"create table if not exists ct3 using st1 tags(3000)"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create child table tu3, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
return
0
;
}
...
...
@@ -82,12 +90,40 @@ int32_t create_topic() {
/*const char* sql = "select * from tu1";*/
/*pRes = tmq_create_topic(pConn, "test_stb_topic_1", sql, strlen(sql));*/
pRes
=
taos_query
(
pConn
,
"create topic t
est_stb_topic_1 as select * from tu
1"
);
pRes
=
taos_query
(
pConn
,
"create topic t
opic_ctb_column as select ts, c1 from ct
1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to create topic t
est_stb_topic_1
, reason:%s
\n
"
,
taos_errstr
(
pRes
));
printf
(
"failed to create topic t
opic_ctb_column
, reason:%s
\n
"
,
taos_errstr
(
pRes
));
return
-
1
;
}
taos_free_result
(
pRes
);
#if 0
pRes = taos_query(pConn, "insert into tu1 values(now, 1, 1.0, 'bi1')");
if (taos_errno(pRes) != 0) {
printf("failed to insert, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "insert into tu1 values(now+1d, 1, 1.0, 'bi1')");
if (taos_errno(pRes) != 0) {
printf("failed to insert, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "insert into tu2 values(now, 2, 2.0, 'bi2')");
if (taos_errno(pRes) != 0) {
printf("failed to insert, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
pRes = taos_query(pConn, "insert into tu2 values(now+1d, 2, 2.0, 'bi2')");
if (taos_errno(pRes) != 0) {
printf("failed to insert, reason:%s\n", taos_errstr(pRes));
return -1;
}
taos_free_result(pRes);
#endif
taos_close
(
pConn
);
return
0
;
}
...
...
@@ -115,7 +151,7 @@ tmq_t* build_consumer() {
tmq_list_t
*
build_topic_list
()
{
tmq_list_t
*
topic_list
=
tmq_list_new
();
tmq_list_append
(
topic_list
,
"t
est_stb_topic_1
"
);
tmq_list_append
(
topic_list
,
"t
opic_ctb_column
"
);
return
topic_list
;
}
...
...
@@ -215,8 +251,8 @@ int main(int argc, char* argv[]) {
if
(
argc
>
1
)
{
printf
(
"env init
\n
"
);
code
=
init_env
();
}
create_topic
();
}
tmq_t
*
tmq
=
build_consumer
();
tmq_list_t
*
topic_list
=
build_topic_list
();
/*perf_loop(tmq, topic_list);*/
...
...
example/src/tstream.c
浏览文件 @
9833a6c5
...
...
@@ -20,7 +20,7 @@
#include "taos.h"
int32_t
init_env
()
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
701
0
);
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
pConn
==
NULL
)
{
return
-
1
;
}
...
...
@@ -65,7 +65,7 @@ int32_t init_env() {
int32_t
create_stream
()
{
printf
(
"create stream
\n
"
);
TAOS_RES
*
pRes
;
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
701
0
);
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
if
(
pConn
==
NULL
)
{
return
-
1
;
}
...
...
include/common/tcommon.h
浏览文件 @
9833a6c5
...
...
@@ -37,6 +37,14 @@ enum {
TMQ_MSG_TYPE__EP_RSP
,
};
enum
{
STREAM_TRIGGER__AT_ONCE
=
1
,
STREAM_TRIGGER__WINDOW_CLOSE
,
STREAM_TRIGGER__BY_COUNT
,
STREAM_TRIGGER__BY_BATCH_COUNT
,
STREAM_TRIGGER__BY_EVENT_TIME
,
};
typedef
struct
{
uint32_t
numOfTables
;
SArray
*
pGroupList
;
...
...
@@ -59,7 +67,10 @@ typedef struct SDataBlockInfo {
int32_t
rowSize
;
int16_t
numOfCols
;
int16_t
hasVarCol
;
union
{
int64_t
uid
;
int64_t
blockId
;};
union
{
int64_t
uid
;
int64_t
blockId
;
};
int64_t
groupId
;
// no need to serialize
}
SDataBlockInfo
;
...
...
@@ -93,7 +104,7 @@ void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock);
int32_t
tEncodeDataBlocks
(
void
**
buf
,
const
SArray
*
blocks
);
void
*
tDecodeDataBlocks
(
const
void
*
buf
,
SArray
**
blocks
);
void
colDataDestroy
(
SColumnInfoData
*
pColData
)
;
void
colDataDestroy
(
SColumnInfoData
*
pColData
);
static
FORCE_INLINE
void
blockDestroyInner
(
SSDataBlock
*
pBlock
)
{
// WARNING: do not use info.numOfCols,
...
...
@@ -198,8 +209,8 @@ typedef struct SGroupbyExpr {
}
SGroupbyExpr
;
enum
{
FUNC_PARAM_TYPE_VALUE
=
0
,
FUNC_PARAM_TYPE_COLUMN
,
FUNC_PARAM_TYPE_VALUE
=
0
x1
,
FUNC_PARAM_TYPE_COLUMN
=
0x2
,
};
typedef
struct
SFunctParam
{
...
...
include/common/trow.h
浏览文件 @
9833a6c5
...
...
@@ -98,7 +98,7 @@ typedef void *SRow;
typedef
struct
{
TDRowValT
valType
;
void
*
val
;
void
*
val
;
}
SCellVal
;
typedef
struct
{
...
...
@@ -158,8 +158,8 @@ typedef struct {
int16_t
nBitmaps
;
int16_t
nBoundBitmaps
;
int32_t
offset
;
void
*
pBitmap
;
void
*
pOffset
;
void
*
pBitmap
;
void
*
pOffset
;
int32_t
extendedRowSize
;
}
SRowBuilder
;
...
...
@@ -275,7 +275,7 @@ static FORCE_INLINE int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TD
}
int16_t
nBytes
=
colIdx
/
TD_VTYPE_PARTS
;
int16_t
nOffset
=
colIdx
&
TD_VTYPE_OPTR
;
char
*
pDestByte
=
(
char
*
)
POINTER_SHIFT
(
pBitmap
,
nBytes
);
char
*
pDestByte
=
(
char
*
)
POINTER_SHIFT
(
pBitmap
,
nBytes
);
switch
(
nOffset
)
{
case
0
:
*
pDestByte
=
((
*
pDestByte
)
&
0x3F
)
|
(
valType
<<
6
);
...
...
@@ -313,7 +313,7 @@ static FORCE_INLINE int32_t tdGetBitmapValType(void *pBitmap, int16_t colIdx, TD
}
int16_t
nBytes
=
colIdx
/
TD_VTYPE_PARTS
;
int16_t
nOffset
=
colIdx
&
TD_VTYPE_OPTR
;
char
*
pDestByte
=
(
char
*
)
POINTER_SHIFT
(
pBitmap
,
nBytes
);
char
*
pDestByte
=
(
char
*
)
POINTER_SHIFT
(
pBitmap
,
nBytes
);
switch
(
nOffset
)
{
case
0
:
*
pValType
=
(((
*
pDestByte
)
&
0xC0
)
>>
6
);
...
...
@@ -620,7 +620,7 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowVa
if
(
tdValIsNorm
(
valType
,
val
,
colType
))
{
// ts key stored in STSRow.ts
SKvRowIdx
*
pColIdx
=
(
SKvRowIdx
*
)
POINTER_SHIFT
(
TD_ROW_COL_IDX
(
row
),
offset
);
char
*
ptr
=
(
char
*
)
POINTER_SHIFT
(
row
,
TD_ROW_LEN
(
row
));
char
*
ptr
=
(
char
*
)
POINTER_SHIFT
(
row
,
TD_ROW_LEN
(
row
));
pColIdx
->
colId
=
colId
;
pColIdx
->
offset
=
TD_ROW_LEN
(
row
);
// the offset include the TD_ROW_HEAD_LEN
...
...
@@ -638,7 +638,7 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowVa
// NULL/None value
else
{
SKvRowIdx
*
pColIdx
=
(
SKvRowIdx
*
)
POINTER_SHIFT
(
TD_ROW_COL_IDX
(
row
),
offset
);
char
*
ptr
=
(
char
*
)
POINTER_SHIFT
(
row
,
TD_ROW_LEN
(
row
));
char
*
ptr
=
(
char
*
)
POINTER_SHIFT
(
row
,
TD_ROW_LEN
(
row
));
pColIdx
->
colId
=
colId
;
pColIdx
->
offset
=
TD_ROW_LEN
(
row
);
// the offset include the TD_ROW_HEAD_LEN
const
void
*
nullVal
=
getNullValue
(
colType
);
...
...
@@ -775,8 +775,8 @@ static FORCE_INLINE int32_t tdGetKvRowValOfCol(SCellVal *output, STSRow *pRow, v
typedef
struct
{
STSchema
*
pSchema
;
STSRow
*
pRow
;
void
*
pBitmap
;
STSRow
*
pRow
;
void
*
pBitmap
;
uint32_t
offset
;
col_id_t
maxColId
;
col_id_t
colIdx
;
// [PRIMARYKEY_TIMESTAMP_COL_ID, nSchemaCols], PRIMARYKEY_TIMESTAMP_COL_ID equals 1
...
...
@@ -881,7 +881,7 @@ static FORCE_INLINE bool tdGetTpRowDataOfCol(STSRowIter *pIter, col_type_t colTy
// internal
static
FORCE_INLINE
bool
tdGetKvRowValOfColEx
(
STSRowIter
*
pIter
,
col_id_t
colId
,
col_type_t
colType
,
col_id_t
*
nIdx
,
SCellVal
*
pVal
)
{
STSRow
*
pRow
=
pIter
->
pRow
;
STSRow
*
pRow
=
pIter
->
pRow
;
SKvRowIdx
*
pKvIdx
=
NULL
;
bool
colFound
=
false
;
col_id_t
kvNCols
=
tdRowGetNCols
(
pRow
);
...
...
@@ -1076,7 +1076,7 @@ typedef struct {
typedef
struct
{
STSchema
*
pSchema
;
STSRow
*
pRow
;
STSRow
*
pRow
;
}
STSRowReader
;
typedef
struct
{
...
...
include/common/ttime.h
浏览文件 @
9833a6c5
...
...
@@ -60,8 +60,10 @@ int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* durati
int32_t
taosParseTime
(
const
char
*
timestr
,
int64_t
*
time
,
int32_t
len
,
int32_t
timePrec
,
int8_t
dayligth
);
void
deltaToUtcInitOnce
();
char
getPrecisionUnit
(
int32_t
precision
);
int64_t
convertTimePrecision
(
int64_t
time
,
int32_t
fromPrecision
,
int32_t
toPrecision
);
int64_t
convertTimeFromPrecisionToUnit
(
int64_t
time
,
int32_t
fromPrecision
,
char
toUnit
);
void
taosFormatUtcTime
(
char
*
buf
,
int32_t
bufLen
,
int64_t
time
,
int32_t
precision
);
...
...
include/libs/command/command.h
浏览文件 @
9833a6c5
...
...
@@ -15,5 +15,10 @@
#include "cmdnodes.h"
#include "tmsg.h"
#include "plannodes.h"
int32_t
qExecCommand
(
SNode
*
pStmt
,
SRetrieveTableRsp
**
pRsp
);
int32_t
qExecStaticExplain
(
SQueryPlan
*
pDag
,
SRetrieveTableRsp
**
pRsp
);
include/libs/nodes/nodes.h
浏览文件 @
9833a6c5
...
...
@@ -215,6 +215,8 @@ int32_t nodesStringToNode(const char* pStr, SNode** pNode);
int32_t
nodesListToString
(
const
SNodeList
*
pList
,
bool
format
,
char
**
pStr
,
int32_t
*
pLen
);
int32_t
nodesStringToList
(
const
char
*
pStr
,
SNodeList
**
pList
);
int32_t
nodesNodeToSQL
(
SNode
*
pNode
,
char
*
buf
,
int32_t
bufSize
,
int32_t
*
len
);
#ifdef __cplusplus
}
#endif
...
...
include/libs/nodes/plannodes.h
浏览文件 @
9833a6c5
include/libs/nodes/querynodes.h
浏览文件 @
9833a6c5
...
...
@@ -314,6 +314,7 @@ bool nodesIsTimeorderQuery(const SNode* pQuery);
bool
nodesIsTimelineQuery
(
const
SNode
*
pQuery
);
void
*
nodesGetValueFromNode
(
SValueNode
*
pNode
);
char
*
nodesGetStrValueFromNode
(
SValueNode
*
pNode
);
#ifdef __cplusplus
}
...
...
include/libs/qcom/query.h
浏览文件 @
9833a6c5
...
...
@@ -53,6 +53,7 @@ typedef struct SIndexMeta {
}
SIndexMeta
;
/*
* ASSERT(sizeof(SCTableMeta) == 24)
* ASSERT(tableType == TSDB_CHILD_TABLE)
...
...
@@ -235,6 +236,11 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t
} \
} while (0)
#define QRY_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
#define QRY_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
#define QRY_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
#ifdef __cplusplus
}
#endif
...
...
include/libs/wal/wal.h
浏览文件 @
9833a6c5
...
...
@@ -157,6 +157,7 @@ typedef struct SWalReadHandle {
int64_t
curVersion
;
int64_t
capacity
;
int64_t
status
;
// if cursor valid
TdThreadMutex
mutex
;
SWalHead
*
pHead
;
}
SWalReadHandle
;
#pragma pack(pop)
...
...
@@ -191,6 +192,7 @@ int32_t walEndSnapshot(SWal *);
SWalReadHandle
*
walOpenReadHandle
(
SWal
*
);
void
walCloseReadHandle
(
SWalReadHandle
*
);
int32_t
walReadWithHandle
(
SWalReadHandle
*
pRead
,
int64_t
ver
);
int32_t
walReadWithHandle_s
(
SWalReadHandle
*
pRead
,
int64_t
ver
,
SWalReadHead
**
ppHead
);
// deprecated
#if 0
...
...
include/os/osTime.h
浏览文件 @
9833a6c5
...
...
@@ -46,6 +46,14 @@ extern "C" {
#define MILLISECOND_PER_DAY (MILLISECOND_PER_HOUR * 24)
#define MILLISECOND_PER_WEEK (MILLISECOND_PER_DAY * 7)
#define NANOSECOND_PER_USEC (1000L)
#define NANOSECOND_PER_MSEC (1000000L)
#define NANOSECOND_PER_SEC (1000000000L)
#define NANOSECOND_PER_MINUTE (NANOSECOND_PER_SEC * 60)
#define NANOSECOND_PER_HOUR (NANOSECOND_PER_MINUTE * 60)
#define NANOSECOND_PER_DAY (NANOSECOND_PER_HOUR * 24)
#define NANOSECOND_PER_WEEK (NANOSECOND_PER_DAY * 7)
int32_t
taosGetTimeOfDay
(
struct
timeval
*
tv
);
//@return timestamp in second
...
...
include/util/tdef.h
浏览文件 @
9833a6c5
...
...
@@ -224,6 +224,7 @@ typedef enum ELogicConditionType {
#define TSDB_APP_NAME_LEN TSDB_UNI_LEN
#define TSDB_STB_COMMENT_LEN 1024
/**
* In some scenarios uint16_t (0~65535) is used to store the row len.
* - Firstly, we use 65531(65535 - 4), as the SDataRow/SKVRow contains 4 bits header.
...
...
@@ -388,6 +389,7 @@ typedef enum ELogicConditionType {
#define TSDB_DEFAULT_EXPLAIN_RATIO 0.001
#define TSDB_EXPLAIN_RESULT_ROW_SIZE 1024
#define TSDB_EXPLAIN_RESULT_COLUMN_NAME "QUERY PLAN"
#define TSDB_MAX_JOIN_TABLE_NUM 10
#define TSDB_MAX_UNION_CLAUSE 5
...
...
@@ -479,6 +481,9 @@ enum {
#define QND_VGID 1
#define VND_VGID 0
#define MAX_NUM_STR_SIZE 40
#ifdef __cplusplus
}
#endif
...
...
source/client/src/tmq.c
浏览文件 @
9833a6c5
...
...
@@ -255,6 +255,7 @@ void tmqClearUnhandleMsg(tmq_t* tmq) {
break
;
}
msg
=
NULL
;
taosReadAllQitems
(
tmq
->
mqueue
,
tmq
->
qall
);
while
(
1
)
{
taosGetQitem
(
tmq
->
qall
,
(
void
**
)
&
msg
);
...
...
@@ -787,7 +788,7 @@ void tmqShowMsg(tmq_message_t* tmq_message) {
static
bool
noPrintSchema
;
char
pBuf
[
128
];
SMqPollRsp
*
pRsp
=
&
tmq_message
->
msg
;
int32_t
colNum
=
pRsp
->
schema
->
nCols
;
int32_t
colNum
=
2
;
if
(
!
noPrintSchema
)
{
printf
(
"|"
);
for
(
int32_t
i
=
0
;
i
<
colNum
;
i
++
)
{
...
...
@@ -838,6 +839,7 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
int32_t
msgEpoch
=
((
SMqRspHead
*
)
pMsg
->
pData
)
->
epoch
;
int32_t
tmqEpoch
=
atomic_load_32
(
&
tmq
->
epoch
);
if
(
msgEpoch
<
tmqEpoch
)
{
/*printf("discard rsp epoch %d, current epoch %d\n", msgEpoch, tmqEpoch);*/
tsem_post
(
&
tmq
->
rspSem
);
tscWarn
(
"discard rsp epoch %d, current epoch %d"
,
msgEpoch
,
tmqEpoch
);
return
0
;
...
...
@@ -886,6 +888,9 @@ int32_t tmqPollCb(void* param, const SDataBuf* pMsg, int32_t code) {
goto
WRITE_QUEUE_FAIL
;
}
tscError
(
"tmq recv poll: vg %d, req offset %ld, rsp offset %ld"
,
pParam
->
pVg
->
vgId
,
pRsp
->
msg
.
reqOffset
,
pRsp
->
msg
.
rspOffset
);
pRsp
->
vg
=
pParam
->
pVg
;
taosWriteQitem
(
tmq
->
mqueue
,
pRsp
);
atomic_add_fetch_32
(
&
tmq
->
readyRequest
,
1
);
...
...
@@ -902,6 +907,7 @@ WRITE_QUEUE_FAIL:
bool
tmqUpdateEp
(
tmq_t
*
tmq
,
int32_t
epoch
,
SMqCMGetSubEpRsp
*
pRsp
)
{
/*printf("call update ep %d\n", epoch);*/
/*printf("tmq update ep epoch %d to epoch %d\n", tmq->epoch, epoch);*/
bool
set
=
false
;
int32_t
topicNumGet
=
taosArrayGetSize
(
pRsp
->
topics
);
char
vgKey
[
TSDB_TOPIC_FNAME_LEN
+
22
];
...
...
@@ -932,6 +938,7 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqCMGetSubEpRsp* pRsp) {
for
(
int32_t
k
=
0
;
k
<
vgNumCur
;
k
++
)
{
SMqClientVg
*
pVgCur
=
taosArrayGet
(
pTopicCur
->
vgs
,
k
);
sprintf
(
vgKey
,
"%s:%d"
,
topic
.
topicName
,
pVgCur
->
vgId
);
/*printf("epoch %d vg %d build %s\n", epoch, pVgCur->vgId, vgKey);*/
taosHashPut
(
pHash
,
vgKey
,
strlen
(
vgKey
),
&
pVgCur
->
currentOffset
,
sizeof
(
int64_t
));
}
break
;
...
...
@@ -945,9 +952,12 @@ bool tmqUpdateEp(tmq_t* tmq, int32_t epoch, SMqCMGetSubEpRsp* pRsp) {
sprintf
(
vgKey
,
"%s:%d"
,
topic
.
topicName
,
pVgEp
->
vgId
);
int64_t
*
pOffset
=
taosHashGet
(
pHash
,
vgKey
,
strlen
(
vgKey
));
int64_t
offset
=
pVgEp
->
offset
;
/*printf("epoch %d vg %d offset og to %ld\n", epoch, pVgEp->vgId, offset);*/
if
(
pOffset
!=
NULL
)
{
offset
=
*
pOffset
;
/*printf("epoch %d vg %d found %s\n", epoch, pVgEp->vgId, vgKey);*/
}
/*printf("epoch %d vg %d offset set to %ld\n", epoch, pVgEp->vgId, offset);*/
SMqClientVg
clientVg
=
{
.
pollCnt
=
0
,
.
currentOffset
=
offset
,
...
...
@@ -1195,6 +1205,7 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) {
SMqClientVg
*
pVg
=
taosArrayGet
(
pTopic
->
vgs
,
j
);
int32_t
vgStatus
=
atomic_val_compare_exchange_32
(
&
pVg
->
vgStatus
,
TMQ_VG_STATUS__IDLE
,
TMQ_VG_STATUS__WAIT
);
if
(
vgStatus
!=
TMQ_VG_STATUS__IDLE
)
{
/*printf("skip vg %d\n", pVg->vgId);*/
continue
;
}
SMqPollReq
*
pReq
=
tmqBuildConsumeReqImpl
(
tmq
,
blockingTime
,
pTopic
,
pVg
);
...
...
@@ -1238,6 +1249,8 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t blockingTime) {
int64_t
transporterId
=
0
;
/*printf("send poll\n");*/
atomic_add_fetch_32
(
&
tmq
->
waitingRequest
,
1
);
/*tscDebug("tmq send poll: vg %d, req offset %ld", pVg->vgId, pVg->currentOffset);*/
/*printf("send vg %d %ld\n", pVg->vgId, pVg->currentOffset);*/
asyncSendMsgToServer
(
tmq
->
pTscObj
->
pAppInfo
->
pTransporter
,
&
pVg
->
epSet
,
&
transporterId
,
sendInfo
);
pVg
->
pollCnt
++
;
tmq
->
pollCnt
++
;
...
...
source/common/src/ttime.c
浏览文件 @
9833a6c5
...
...
@@ -361,6 +361,18 @@ int32_t parseLocaltimeDst(char* timestr, int64_t* time, int32_t timePrec) {
return
0
;
}
char
getPrecisionUnit
(
int32_t
precision
)
{
static
char
units
[
3
]
=
{
TIME_UNIT_MILLISECOND
,
TIME_UNIT_MICROSECOND
,
TIME_UNIT_NANOSECOND
};
switch
(
precision
)
{
case
TSDB_TIME_PRECISION_MILLI
:
case
TSDB_TIME_PRECISION_MICRO
:
case
TSDB_TIME_PRECISION_NANO
:
return
units
[
precision
];
default:
return
0
;
}
}
int64_t
convertTimePrecision
(
int64_t
time
,
int32_t
fromPrecision
,
int32_t
toPrecision
)
{
assert
(
fromPrecision
==
TSDB_TIME_PRECISION_MILLI
||
fromPrecision
==
TSDB_TIME_PRECISION_MICRO
||
fromPrecision
==
TSDB_TIME_PRECISION_NANO
);
...
...
@@ -370,6 +382,33 @@ int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrec
return
(
int64_t
)((
double
)
time
*
factors
[
fromPrecision
][
toPrecision
]);
}
int64_t
convertTimeFromPrecisionToUnit
(
int64_t
time
,
int32_t
fromPrecision
,
char
toUnit
)
{
assert
(
fromPrecision
==
TSDB_TIME_PRECISION_MILLI
||
fromPrecision
==
TSDB_TIME_PRECISION_MICRO
||
fromPrecision
==
TSDB_TIME_PRECISION_NANO
);
static
double
factors
[
3
]
=
{
1000000
.,
1000
.,
1
.};
switch
(
toUnit
)
{
case
's'
:
return
time
*
factors
[
fromPrecision
]
/
NANOSECOND_PER_SEC
;
case
'm'
:
return
time
*
factors
[
fromPrecision
]
/
NANOSECOND_PER_MINUTE
;
case
'h'
:
return
time
*
factors
[
fromPrecision
]
/
NANOSECOND_PER_HOUR
;
case
'd'
:
return
time
*
factors
[
fromPrecision
]
/
NANOSECOND_PER_DAY
;
case
'w'
:
return
time
*
factors
[
fromPrecision
]
/
NANOSECOND_PER_WEEK
;
case
'a'
:
return
time
*
factors
[
fromPrecision
]
/
NANOSECOND_PER_MSEC
;
case
'u'
:
return
time
*
factors
[
fromPrecision
]
/
NANOSECOND_PER_USEC
;
case
'b'
:
return
time
*
factors
[
fromPrecision
];
default:
{
return
-
1
;
}
}
}
static
int32_t
getDuration
(
int64_t
val
,
char
unit
,
int64_t
*
result
,
int32_t
timePrecision
)
{
switch
(
unit
)
{
case
's'
:
...
...
source/dnode/mgmt/main/exe/dndMain.c
浏览文件 @
9833a6c5
...
...
@@ -37,13 +37,6 @@ static void dndStopDnode(int signum, void *info, void *ctx) {
}
}
static
void
dndHandleChild
(
int
signum
,
void
*
info
,
void
*
ctx
)
{
dInfo
(
"sigchild received"
);
if
(
global
.
pDnode
!=
NULL
)
{
dndHandleEvent
(
global
.
pDnode
,
DND_EVENT_CHILD
);
}
}
static
void
dndSetSignalHandle
()
{
taosSetSignal
(
SIGTERM
,
dndStopDnode
);
taosSetSignal
(
SIGHUP
,
dndStopDnode
);
...
...
@@ -53,7 +46,7 @@ static void dndSetSignalHandle() {
if
(
!
tsMultiProcess
)
{
}
else
if
(
global
.
ntype
==
DNODE
||
global
.
ntype
==
NODE_MAX
)
{
taos
SetSignal
(
SIGCHLD
,
dndHandleChild
);
taos
IgnSignal
(
SIGCHLD
);
}
else
{
taosKillChildOnParentStopped
();
}
...
...
source/dnode/mgmt/main/src/dndEnv.c
0 → 100644
浏览文件 @
9833a6c5
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "dndInt.h"
#include "wal.h"
static
int8_t
once
=
DND_ENV_INIT
;
int32_t
dndInit
()
{
dDebug
(
"start to init dnode env"
);
if
(
atomic_val_compare_exchange_8
(
&
once
,
DND_ENV_INIT
,
DND_ENV_READY
)
!=
DND_ENV_INIT
)
{
terrno
=
TSDB_CODE_REPEAT_INIT
;
dError
(
"failed to init dnode env since %s"
,
terrstr
());
return
-
1
;
}
taosIgnSIGPIPE
();
taosBlockSIGPIPE
();
taosResolveCRC
();
SMonCfg
monCfg
=
{
0
};
monCfg
.
maxLogs
=
tsMonitorMaxLogs
;
monCfg
.
port
=
tsMonitorPort
;
monCfg
.
server
=
tsMonitorFqdn
;
monCfg
.
comp
=
tsMonitorComp
;
if
(
monInit
(
&
monCfg
)
!=
0
)
{
dError
(
"failed to init monitor since %s"
,
terrstr
());
return
-
1
;
}
dInfo
(
"dnode env is initialized"
);
return
0
;
}
void
dndCleanup
()
{
dDebug
(
"start to cleanup dnode env"
);
if
(
atomic_val_compare_exchange_8
(
&
once
,
DND_ENV_READY
,
DND_ENV_CLEANUP
)
!=
DND_ENV_READY
)
{
dError
(
"dnode env is already cleaned up"
);
return
;
}
monCleanup
();
walCleanUp
();
taosStopCacheRefreshWorker
();
dInfo
(
"dnode env is cleaned up"
);
}
void
dndSetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
tmsg_t
msgType
,
NodeMsgFp
nodeMsgFp
,
int8_t
vgId
)
{
pWrapper
->
msgFps
[
TMSG_INDEX
(
msgType
)]
=
nodeMsgFp
;
pWrapper
->
msgVgIds
[
TMSG_INDEX
(
msgType
)]
=
vgId
;
}
EDndStatus
dndGetStatus
(
SDnode
*
pDnode
)
{
return
pDnode
->
status
;
}
void
dndSetStatus
(
SDnode
*
pDnode
,
EDndStatus
status
)
{
if
(
pDnode
->
status
!=
status
)
{
dDebug
(
"dnode status set from %s to %s"
,
dndStatStr
(
pDnode
->
status
),
dndStatStr
(
status
));
pDnode
->
status
=
status
;
}
}
void
dndReportStartup
(
SDnode
*
pDnode
,
const
char
*
pName
,
const
char
*
pDesc
)
{
SStartupReq
*
pStartup
=
&
pDnode
->
startup
;
tstrncpy
(
pStartup
->
name
,
pName
,
TSDB_STEP_NAME_LEN
);
tstrncpy
(
pStartup
->
desc
,
pDesc
,
TSDB_STEP_DESC_LEN
);
pStartup
->
finished
=
0
;
}
void
dndGetStartup
(
SDnode
*
pDnode
,
SStartupReq
*
pStartup
)
{
memcpy
(
pStartup
,
&
pDnode
->
startup
,
sizeof
(
SStartupReq
));
pStartup
->
finished
=
(
dndGetStatus
(
pDnode
)
==
DND_STAT_RUNNING
);
}
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
dDebug
(
"startup req is received"
);
SStartupReq
*
pStartup
=
rpcMallocCont
(
sizeof
(
SStartupReq
));
dndGetStartup
(
pDnode
,
pStartup
);
dDebug
(
"startup req is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
SRpcMsg
rpcRsp
=
{
.
handle
=
pReq
->
handle
,
.
pCont
=
pStartup
,
.
contLen
=
sizeof
(
SStartupReq
),
.
ahandle
=
pReq
->
ahandle
};
rpcSendResponse
(
&
rpcRsp
);
}
source/dnode/mgmt/main/src/dndExec.c
浏览文件 @
9833a6c5
...
...
@@ -128,7 +128,7 @@ static int32_t dndNewProc(SMgmtWrapper *pWrapper, ENodeType n) {
}
pWrapper
->
procId
=
pid
;
dInfo
(
"node:%s,
run in new process, pid
:%d"
,
pWrapper
->
name
,
pid
);
dInfo
(
"node:%s,
continue running in new process
:%d"
,
pWrapper
->
name
,
pid
);
return
0
;
}
...
...
@@ -263,21 +263,21 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) {
if
(
!
pWrapper
->
required
)
continue
;
if
(
pDnode
->
ntype
==
NODE_MAX
)
continue
;
if
(
pWrapper
->
procId
!=
0
&&
!
taosProcExists
(
pWrapper
->
procId
))
{
dInfo
(
"node:%s, process
not exist, pid:%
d"
,
pWrapper
->
name
,
pWrapper
->
procId
);
if
(
pWrapper
->
procId
<=
0
||
!
taosProcExists
(
pWrapper
->
procId
))
{
dInfo
(
"node:%s, process
:%d is killed and needs to be restarte
d"
,
pWrapper
->
name
,
pWrapper
->
procId
);
dndNewProc
(
pWrapper
,
n
);
}
}
taosMsleep
(
100
);
}
}
return
0
;
}
static
int32_t
dndRunInChildProcess
(
SDnode
*
pDnode
)
{
dInfo
(
"dnode run in child process"
);
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
pDnode
->
ntype
];
dInfo
(
"%s run in child process"
,
pWrapper
->
name
);
SMsgCb
msgCb
=
dndCreateMsgcb
(
pWrapper
);
tmsgSetDefaultMsgCb
(
&
msgCb
);
...
...
source/dnode/mgmt/main/src/dndInt.c
浏览文件 @
9833a6c5
...
...
@@ -15,82 +15,186 @@
#define _DEFAULT_SOURCE
#include "dndInt.h"
#include "wal.h"
static
int8_t
once
=
DND_ENV_INIT
;
static
int32_t
dndInitVars
(
SDnode
*
pDnode
,
const
SDnodeOpt
*
pOption
)
{
pDnode
->
numOfSupportVnodes
=
pOption
->
numOfSupportVnodes
;
pDnode
->
serverPort
=
pOption
->
serverPort
;
pDnode
->
dataDir
=
strdup
(
pOption
->
dataDir
);
pDnode
->
localEp
=
strdup
(
pOption
->
localEp
);
pDnode
->
localFqdn
=
strdup
(
pOption
->
localFqdn
);
pDnode
->
firstEp
=
strdup
(
pOption
->
firstEp
);
pDnode
->
secondEp
=
strdup
(
pOption
->
secondEp
);
pDnode
->
disks
=
pOption
->
disks
;
pDnode
->
numOfDisks
=
pOption
->
numOfDisks
;
pDnode
->
ntype
=
pOption
->
ntype
;
pDnode
->
rebootTime
=
taosGetTimestampMs
();
int32_t
dndInit
()
{
dDebug
(
"start to init dnode env"
);
if
(
atomic_val_compare_exchange_8
(
&
once
,
DND_ENV_INIT
,
DND_ENV_READY
)
!=
DND_ENV_INIT
)
{
terrno
=
TSDB_CODE_REPEAT_INIT
;
dError
(
"failed to init dnode env since %s"
,
terrstr
());
if
(
pDnode
->
dataDir
==
NULL
||
pDnode
->
localEp
==
NULL
||
pDnode
->
localFqdn
==
NULL
||
pDnode
->
firstEp
==
NULL
||
pDnode
->
secondEp
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
taosIgnSIGPIPE
();
taosBlockSIGPIPE
();
taosResolveCRC
();
SMonCfg
monCfg
=
{
0
};
monCfg
.
maxLogs
=
tsMonitorMaxLogs
;
monCfg
.
port
=
tsMonitorPort
;
monCfg
.
server
=
tsMonitorFqdn
;
monCfg
.
comp
=
tsMonitorComp
;
if
(
monInit
(
&
monCfg
)
!=
0
)
{
dError
(
"failed to init monitor since %s"
,
terrstr
());
if
(
!
tsMultiProcess
||
pDnode
->
ntype
==
DNODE
||
pDnode
->
ntype
==
NODE_MAX
)
{
pDnode
->
lockfile
=
dndCheckRunning
(
pDnode
->
dataDir
);
if
(
pDnode
->
lockfile
==
NULL
)
{
return
-
1
;
}
}
dInfo
(
"dnode env is initialized"
);
return
0
;
}
void
dndCleanup
()
{
dDebug
(
"start to cleanup dnode env"
);
if
(
atomic_val_compare_exchange_8
(
&
once
,
DND_ENV_READY
,
DND_ENV_CLEANUP
)
!=
DND_ENV_READY
)
{
dError
(
"dnode env is already cleaned up"
);
static
void
dndClearVars
(
SDnode
*
pDnode
)
{
for
(
ENodeType
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pMgmt
=
&
pDnode
->
wrappers
[
n
];
taosMemoryFreeClear
(
pMgmt
->
path
);
}
if
(
pDnode
->
lockfile
!=
NULL
)
{
taosUnLockFile
(
pDnode
->
lockfile
);
taosCloseFile
(
&
pDnode
->
lockfile
);
pDnode
->
lockfile
=
NULL
;
}
taosMemoryFreeClear
(
pDnode
->
localEp
);
taosMemoryFreeClear
(
pDnode
->
localFqdn
);
taosMemoryFreeClear
(
pDnode
->
firstEp
);
taosMemoryFreeClear
(
pDnode
->
secondEp
);
taosMemoryFreeClear
(
pDnode
->
dataDir
);
taosMemoryFree
(
pDnode
);
dDebug
(
"dnode memory is cleared, data:%p"
,
pDnode
);
}
SDnode
*
dndCreate
(
const
SDnodeOpt
*
pOption
)
{
dDebug
(
"start to create dnode object"
);
int32_t
code
=
-
1
;
char
path
[
PATH_MAX
]
=
{
0
};
SDnode
*
pDnode
=
NULL
;
pDnode
=
taosMemoryCalloc
(
1
,
sizeof
(
SDnode
));
if
(
pDnode
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_OVER
;
}
if
(
dndInitVars
(
pDnode
,
pOption
)
!=
0
)
{
dError
(
"failed to init variables since %s"
,
terrstr
());
goto
_OVER
;
}
dndSetStatus
(
pDnode
,
DND_STAT_INIT
);
dmGetMgmtFp
(
&
pDnode
->
wrappers
[
DNODE
]);
mmGetMgmtFp
(
&
pDnode
->
wrappers
[
MNODE
]);
vmGetMgmtFp
(
&
pDnode
->
wrappers
[
VNODES
]);
qmGetMgmtFp
(
&
pDnode
->
wrappers
[
QNODE
]);
smGetMgmtFp
(
&
pDnode
->
wrappers
[
SNODE
]);
bmGetMgmtFp
(
&
pDnode
->
wrappers
[
BNODE
]);
for
(
ENodeType
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
snprintf
(
path
,
sizeof
(
path
),
"%s%s%s"
,
pDnode
->
dataDir
,
TD_DIRSEP
,
pWrapper
->
name
);
pWrapper
->
path
=
strdup
(
path
);
pWrapper
->
shm
.
id
=
-
1
;
pWrapper
->
pDnode
=
pDnode
;
if
(
pWrapper
->
path
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_OVER
;
}
pWrapper
->
procType
=
PROC_SINGLE
;
taosInitRWLatch
(
&
pWrapper
->
latch
);
}
if
(
dndInitMsgHandle
(
pDnode
)
!=
0
)
{
dError
(
"failed to msg handles since %s"
,
terrstr
());
goto
_OVER
;
}
if
(
dndReadShmFile
(
pDnode
)
!=
0
)
{
dError
(
"failed to read shm file since %s"
,
terrstr
());
goto
_OVER
;
}
SMsgCb
msgCb
=
dndCreateMsgcb
(
&
pDnode
->
wrappers
[
0
]);
tmsgSetDefaultMsgCb
(
&
msgCb
);
dInfo
(
"dnode is created, data:%p"
,
pDnode
);
code
=
0
;
_OVER:
if
(
code
!=
0
&&
pDnode
)
{
dndClearVars
(
pDnode
);
pDnode
=
NULL
;
dError
(
"failed to create dnode since %s"
,
terrstr
());
}
return
pDnode
;
}
void
dndClose
(
SDnode
*
pDnode
)
{
if
(
pDnode
==
NULL
)
return
;
if
(
dndGetStatus
(
pDnode
)
==
DND_STAT_STOPPED
)
{
dError
(
"dnode is shutting down, data:%p"
,
pDnode
);
return
;
}
monCleanup
();
walCleanUp
();
taosStopCacheRefreshWorker
();
dInfo
(
"dnode env is cleaned up"
);
dInfo
(
"start to close dnode, data:%p"
,
pDnode
);
dndSetStatus
(
pDnode
,
DND_STAT_STOPPED
);
for
(
ENodeType
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
dndCloseNode
(
pWrapper
);
}
dndClearVars
(
pDnode
);
dInfo
(
"dnode is closed, data:%p"
,
pDnode
);
}
void
dndSetMsgHandle
(
SMgmtWrapper
*
pWrapper
,
tmsg_t
msgType
,
NodeMsgFp
nodeMsgFp
,
int8_t
vgId
)
{
pWrapper
->
msgFps
[
TMSG_INDEX
(
msgType
)]
=
nodeMsgFp
;
pWrapper
->
msgVgIds
[
TMSG_INDEX
(
msgType
)]
=
vgId
;
void
dndHandleEvent
(
SDnode
*
pDnode
,
EDndEvent
event
)
{
dInfo
(
"dnode receive %s event, data:%p"
,
dndEventStr
(
event
),
pDnode
);
if
(
event
==
DND_EVENT_STOP
)
{
pDnode
->
event
=
event
;
}
}
EDndStatus
dndGetStatus
(
SDnode
*
pDnode
)
{
return
pDnode
->
status
;
}
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
ENodeType
ntype
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
SMgmtWrapper
*
pRetWrapper
=
pWrapper
;
void
dndSetStatus
(
SDnode
*
pDnode
,
EDndStatus
status
)
{
if
(
pDnode
->
status
!=
status
)
{
dDebug
(
"dnode status set from %s to %s"
,
dndStatStr
(
pDnode
->
status
),
dndStatStr
(
status
));
pDnode
->
status
=
status
;
taosRLockLatch
(
&
pWrapper
->
latch
);
if
(
pWrapper
->
deployed
)
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is acquired, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
else
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
pRetWrapper
=
NULL
;
}
}
taosRUnLockLatch
(
&
pWrapper
->
latch
);
void
dndReportStartup
(
SDnode
*
pDnode
,
const
char
*
pName
,
const
char
*
pDesc
)
{
SStartupReq
*
pStartup
=
&
pDnode
->
startup
;
tstrncpy
(
pStartup
->
name
,
pName
,
TSDB_STEP_NAME_LEN
);
tstrncpy
(
pStartup
->
desc
,
pDesc
,
TSDB_STEP_DESC_LEN
);
pStartup
->
finished
=
0
;
return
pRetWrapper
;
}
void
dndGetStartup
(
SDnode
*
pDnode
,
SStartupReq
*
pStartup
)
{
memcpy
(
pStartup
,
&
pDnode
->
startup
,
sizeof
(
SStartupReq
));
pStartup
->
finished
=
(
dndGetStatus
(
pDnode
)
==
DND_STAT_RUNNING
);
int32_t
dndMarkWrapper
(
SMgmtWrapper
*
pWrapper
)
{
int32_t
code
=
0
;
taosRLockLatch
(
&
pWrapper
->
latch
);
if
(
pWrapper
->
deployed
||
(
pWrapper
->
procType
==
PROC_PARENT
&&
pWrapper
->
required
))
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is marked, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
else
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
code
=
-
1
;
}
taosRUnLockLatch
(
&
pWrapper
->
latch
);
return
code
;
}
void
dndProcessStartupReq
(
SDnode
*
pDnode
,
SRpcMsg
*
pReq
)
{
dDebug
(
"startup req is received"
);
SStartupReq
*
pStartup
=
rpcMallocCont
(
sizeof
(
SStartupReq
));
dndGetStartup
(
pDnode
,
pStartup
);
void
dndReleaseWrapper
(
SMgmtWrapper
*
pWrapper
)
{
if
(
pWrapper
==
NULL
)
return
;
dDebug
(
"startup req is sent, step:%s desc:%s finished:%d"
,
pStartup
->
name
,
pStartup
->
desc
,
pStartup
->
finished
);
SRpcMsg
rpcRsp
=
{
.
handle
=
pReq
->
handle
,
.
pCont
=
pStartup
,
.
contLen
=
sizeof
(
SStartupReq
),
.
ahandle
=
pReq
->
ahandle
}
;
rpcSendResponse
(
&
rpcRsp
);
taosRLockLatch
(
&
pWrapper
->
latch
);
int32_t
refCount
=
atomic_sub_fetch_32
(
&
pWrapper
->
refCount
,
1
);
taosRUnLockLatch
(
&
pWrapper
->
latch
)
;
dTrace
(
"node:%s, is released, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
\ No newline at end of file
source/dnode/mgmt/main/src/dndObj.c
已删除
100644 → 0
浏览文件 @
6d4c848d
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "dndInt.h"
static
int32_t
dndInitVars
(
SDnode
*
pDnode
,
const
SDnodeOpt
*
pOption
)
{
pDnode
->
numOfSupportVnodes
=
pOption
->
numOfSupportVnodes
;
pDnode
->
serverPort
=
pOption
->
serverPort
;
pDnode
->
dataDir
=
strdup
(
pOption
->
dataDir
);
pDnode
->
localEp
=
strdup
(
pOption
->
localEp
);
pDnode
->
localFqdn
=
strdup
(
pOption
->
localFqdn
);
pDnode
->
firstEp
=
strdup
(
pOption
->
firstEp
);
pDnode
->
secondEp
=
strdup
(
pOption
->
secondEp
);
pDnode
->
disks
=
pOption
->
disks
;
pDnode
->
numOfDisks
=
pOption
->
numOfDisks
;
pDnode
->
ntype
=
pOption
->
ntype
;
pDnode
->
rebootTime
=
taosGetTimestampMs
();
if
(
pDnode
->
dataDir
==
NULL
||
pDnode
->
localEp
==
NULL
||
pDnode
->
localFqdn
==
NULL
||
pDnode
->
firstEp
==
NULL
||
pDnode
->
secondEp
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
if
(
!
tsMultiProcess
||
pDnode
->
ntype
==
DNODE
||
pDnode
->
ntype
==
NODE_MAX
)
{
pDnode
->
lockfile
=
dndCheckRunning
(
pDnode
->
dataDir
);
if
(
pDnode
->
lockfile
==
NULL
)
{
return
-
1
;
}
}
return
0
;
}
static
void
dndClearVars
(
SDnode
*
pDnode
)
{
for
(
ENodeType
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pMgmt
=
&
pDnode
->
wrappers
[
n
];
taosMemoryFreeClear
(
pMgmt
->
path
);
}
if
(
pDnode
->
lockfile
!=
NULL
)
{
taosUnLockFile
(
pDnode
->
lockfile
);
taosCloseFile
(
&
pDnode
->
lockfile
);
pDnode
->
lockfile
=
NULL
;
}
taosMemoryFreeClear
(
pDnode
->
localEp
);
taosMemoryFreeClear
(
pDnode
->
localFqdn
);
taosMemoryFreeClear
(
pDnode
->
firstEp
);
taosMemoryFreeClear
(
pDnode
->
secondEp
);
taosMemoryFreeClear
(
pDnode
->
dataDir
);
taosMemoryFree
(
pDnode
);
dDebug
(
"dnode memory is cleared, data:%p"
,
pDnode
);
}
SDnode
*
dndCreate
(
const
SDnodeOpt
*
pOption
)
{
dDebug
(
"start to create dnode object"
);
int32_t
code
=
-
1
;
char
path
[
PATH_MAX
]
=
{
0
};
SDnode
*
pDnode
=
NULL
;
pDnode
=
taosMemoryCalloc
(
1
,
sizeof
(
SDnode
));
if
(
pDnode
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_OVER
;
}
if
(
dndInitVars
(
pDnode
,
pOption
)
!=
0
)
{
dError
(
"failed to init variables since %s"
,
terrstr
());
goto
_OVER
;
}
dndSetStatus
(
pDnode
,
DND_STAT_INIT
);
dmGetMgmtFp
(
&
pDnode
->
wrappers
[
DNODE
]);
mmGetMgmtFp
(
&
pDnode
->
wrappers
[
MNODE
]);
vmGetMgmtFp
(
&
pDnode
->
wrappers
[
VNODES
]);
qmGetMgmtFp
(
&
pDnode
->
wrappers
[
QNODE
]);
smGetMgmtFp
(
&
pDnode
->
wrappers
[
SNODE
]);
bmGetMgmtFp
(
&
pDnode
->
wrappers
[
BNODE
]);
for
(
ENodeType
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
snprintf
(
path
,
sizeof
(
path
),
"%s%s%s"
,
pDnode
->
dataDir
,
TD_DIRSEP
,
pWrapper
->
name
);
pWrapper
->
path
=
strdup
(
path
);
pWrapper
->
shm
.
id
=
-
1
;
pWrapper
->
pDnode
=
pDnode
;
if
(
pWrapper
->
path
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
goto
_OVER
;
}
pWrapper
->
procType
=
PROC_SINGLE
;
taosInitRWLatch
(
&
pWrapper
->
latch
);
}
if
(
dndInitMsgHandle
(
pDnode
)
!=
0
)
{
dError
(
"failed to msg handles since %s"
,
terrstr
());
goto
_OVER
;
}
if
(
dndReadShmFile
(
pDnode
)
!=
0
)
{
dError
(
"failed to read shm file since %s"
,
terrstr
());
goto
_OVER
;
}
SMsgCb
msgCb
=
dndCreateMsgcb
(
&
pDnode
->
wrappers
[
0
]);
tmsgSetDefaultMsgCb
(
&
msgCb
);
dInfo
(
"dnode is created, data:%p"
,
pDnode
);
code
=
0
;
_OVER:
if
(
code
!=
0
&&
pDnode
)
{
dndClearVars
(
pDnode
);
pDnode
=
NULL
;
dError
(
"failed to create dnode since %s"
,
terrstr
());
}
return
pDnode
;
}
void
dndClose
(
SDnode
*
pDnode
)
{
if
(
pDnode
==
NULL
)
return
;
if
(
dndGetStatus
(
pDnode
)
==
DND_STAT_STOPPED
)
{
dError
(
"dnode is shutting down, data:%p"
,
pDnode
);
return
;
}
dInfo
(
"start to close dnode, data:%p"
,
pDnode
);
dndSetStatus
(
pDnode
,
DND_STAT_STOPPED
);
for
(
ENodeType
n
=
0
;
n
<
NODE_MAX
;
++
n
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
n
];
dndCloseNode
(
pWrapper
);
}
dndClearVars
(
pDnode
);
dInfo
(
"dnode is closed, data:%p"
,
pDnode
);
}
void
dndHandleEvent
(
SDnode
*
pDnode
,
EDndEvent
event
)
{
dInfo
(
"dnode receive %s event, data:%p"
,
dndEventStr
(
event
),
pDnode
);
if
(
event
==
DND_EVENT_STOP
)
{
pDnode
->
event
=
event
;
}
}
SMgmtWrapper
*
dndAcquireWrapper
(
SDnode
*
pDnode
,
ENodeType
ntype
)
{
SMgmtWrapper
*
pWrapper
=
&
pDnode
->
wrappers
[
ntype
];
SMgmtWrapper
*
pRetWrapper
=
pWrapper
;
taosRLockLatch
(
&
pWrapper
->
latch
);
if
(
pWrapper
->
deployed
)
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is acquired, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
else
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
pRetWrapper
=
NULL
;
}
taosRUnLockLatch
(
&
pWrapper
->
latch
);
return
pRetWrapper
;
}
int32_t
dndMarkWrapper
(
SMgmtWrapper
*
pWrapper
)
{
int32_t
code
=
0
;
taosRLockLatch
(
&
pWrapper
->
latch
);
if
(
pWrapper
->
deployed
||
(
pWrapper
->
procType
==
PROC_PARENT
&&
pWrapper
->
required
))
{
int32_t
refCount
=
atomic_add_fetch_32
(
&
pWrapper
->
refCount
,
1
);
dTrace
(
"node:%s, is marked, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
else
{
terrno
=
TSDB_CODE_NODE_NOT_DEPLOYED
;
code
=
-
1
;
}
taosRUnLockLatch
(
&
pWrapper
->
latch
);
return
code
;
}
void
dndReleaseWrapper
(
SMgmtWrapper
*
pWrapper
)
{
if
(
pWrapper
==
NULL
)
return
;
taosRLockLatch
(
&
pWrapper
->
latch
);
int32_t
refCount
=
atomic_sub_fetch_32
(
&
pWrapper
->
refCount
,
1
);
taosRUnLockLatch
(
&
pWrapper
->
latch
);
dTrace
(
"node:%s, is released, refCount:%d"
,
pWrapper
->
name
,
refCount
);
}
\ No newline at end of file
source/dnode/mnode/impl/inc/mndDef.h
浏览文件 @
9833a6c5
...
...
@@ -735,6 +735,9 @@ typedef struct {
int8_t
createdBy
;
// STREAM_CREATED_BY__USER or SMA
int32_t
fixedSinkVgId
;
// 0 for shuffle
int64_t
smaId
;
// 0 for unused
int8_t
trigger
;
int32_t
triggerParam
;
int64_t
waterMark
;
char
*
sql
;
char
*
logicalPlan
;
char
*
physicalPlan
;
...
...
source/dnode/mnode/impl/src/mndInfoSchema.c
浏览文件 @
9833a6c5
...
...
@@ -89,7 +89,6 @@ static const SInfosTableSchema userStbsSchema[] = {
{.
name
=
"create_time"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"columns"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"tags"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"tables"
,
.
bytes
=
4
,
.
type
=
TSDB_DATA_TYPE_INT
},
{.
name
=
"last_update"
,
.
bytes
=
8
,
.
type
=
TSDB_DATA_TYPE_TIMESTAMP
},
{.
name
=
"table_comment"
,
.
bytes
=
1024
+
VARSTR_HEADER_SIZE
,
.
type
=
TSDB_DATA_TYPE_INT
},
};
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
9833a6c5
...
...
@@ -1652,10 +1652,6 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, char *data, int32
*
(
int32_t
*
)
pWrite
=
pStb
->
numOfTags
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int32_t
*
)
pWrite
=
0
;
// number of tables
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int64_t
*
)
pWrite
=
pStb
->
updateTime
;
// number of tables
cols
++
;
...
...
source/dnode/vnode/src/inc/tsdbCommit.h
浏览文件 @
9833a6c5
source/dnode/vnode/src/inc/tsdbDef.h
浏览文件 @
9833a6c5
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
9833a6c5
...
...
@@ -194,7 +194,7 @@ void tqClose(STQ*);
int
tqPushMsg
(
STQ
*
,
void
*
msg
,
int32_t
msgLen
,
tmsg_t
msgType
,
int64_t
version
);
int
tqCommit
(
STQ
*
);
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
);
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
,
int32_t
workerId
);
int32_t
tqProcessSetConnReq
(
STQ
*
pTq
,
char
*
msg
);
int32_t
tqProcessRebReq
(
STQ
*
pTq
,
char
*
msg
);
int32_t
tqProcessTaskExec
(
STQ
*
pTq
,
char
*
msg
,
int32_t
msgLen
,
int32_t
workerId
);
...
...
source/dnode/vnode/src/meta/metaTbUid.c
浏览文件 @
9833a6c5
...
...
@@ -27,5 +27,5 @@ void metaCloseUidGnrt(SMeta *pMeta) { /* TODO */
tb_uid_t
metaGenerateUid
(
SMeta
*
pMeta
)
{
// Generate a new table UID
return
++
(
pMeta
->
uidGnrt
.
nextUid
);
return
tGenIdPI32
(
);
}
source/dnode/vnode/src/tq/tq.c
浏览文件 @
9833a6c5
...
...
@@ -250,7 +250,7 @@ int32_t tqDeserializeConsumer(STQ* pTq, const STqSerializedHead* pHead, STqConsu
return
0
;
}
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
)
{
int32_t
tqProcessPollReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
,
int32_t
workerId
)
{
SMqPollReq
*
pReq
=
pMsg
->
pCont
;
int64_t
consumerId
=
pReq
->
consumerId
;
int64_t
fetchOffset
;
...
...
@@ -264,6 +264,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
fetchOffset
=
pReq
->
currentOffset
+
1
;
}
/*printf("tmq poll vg %d req %ld %ld\n", pTq->pVnode->vgId, pReq->currentOffset, fetchOffset);*/
SMqPollRsp
rsp
=
{
/*.consumerId = consumerId,*/
.
numOfTopics
=
0
,
...
...
@@ -288,37 +290,47 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
rsp
.
reqOffset
=
pReq
->
currentOffset
;
rsp
.
skipLogNum
=
0
;
SWalHead
*
pHead
;
while
(
1
)
{
/*if (fetchOffset > walGetLastVer(pTq->pWal) || walReadWithHandle(pTopic->pReadhandle, fetchOffset) < 0) {*/
if
(
walReadWithHandle
(
pTopic
->
pReadhandle
,
fetchOffset
)
<
0
)
{
SWalReadHead
*
pHead
;
if
(
walReadWithHandle_s
(
pTopic
->
pReadhandle
,
fetchOffset
,
&
pHead
)
<
0
)
{
// TODO: no more log, set timer to wait blocking time
// if data inserted during waiting, launch query and
// response to user
break
;
}
int8_t
pos
=
fetchOffset
%
TQ_BUFFER_SIZE
;
pHead
=
pTopic
->
pReadhandle
->
pHead
;
if
(
pHead
->
head
.
msgType
==
TDMT_VND_SUBMIT
)
{
SSubmitReq
*
pCont
=
(
SSubmitReq
*
)
&
pHead
->
head
.
body
;
qTaskInfo_t
task
=
pTopic
->
buffer
.
output
[
pos
].
task
;
/*printf("vg %d offset %ld msgType %d from epoch %d\n", pTq->pVnode->vgId, fetchOffset, pHead->msgType,
* pReq->epoch);*/
/*int8_t pos = fetchOffset % TQ_BUFFER_SIZE;*/
/*pHead = pTopic->pReadhandle->pHead;*/
if
(
pHead
->
msgType
==
TDMT_VND_SUBMIT
)
{
SSubmitReq
*
pCont
=
(
SSubmitReq
*
)
&
pHead
->
body
;
/*printf("from topic %s from consumer\n", pTopic->topicName, consumerId);*/
qTaskInfo_t
task
=
pTopic
->
buffer
.
output
[
workerId
].
task
;
ASSERT
(
task
);
qSetStreamInput
(
task
,
pCont
,
STREAM_DATA_TYPE_SUBMIT_BLOCK
);
SArray
*
pRes
=
taosArrayInit
(
0
,
sizeof
(
SSDataBlock
));
while
(
1
)
{
SSDataBlock
*
pDataBlock
;
SSDataBlock
*
pDataBlock
=
NULL
;
uint64_t
ts
;
if
(
qExecTask
(
task
,
&
pDataBlock
,
&
ts
)
<
0
)
{
ASSERT
(
false
);
}
if
(
pDataBlock
==
NULL
)
{
fetchOffset
++
;
pos
=
fetchOffset
%
TQ_BUFFER_SIZE
;
rsp
.
skipLogNum
++
;
/*pos = fetchOffset % TQ_BUFFER_SIZE;*/
break
;
}
taosArrayPush
(
pRes
,
pDataBlock
);
rsp
.
schema
=
pTopic
->
buffer
.
output
[
pos
].
pReadHandle
->
pSchemaWrapper
;
}
if
(
taosArrayGetSize
(
pRes
)
==
0
)
{
fetchOffset
++
;
rsp
.
skipLogNum
++
;
taosArrayDestroy
(
pRes
);
continue
;
}
rsp
.
schema
=
pTopic
->
buffer
.
output
[
workerId
].
pReadHandle
->
pSchemaWrapper
;
rsp
.
rspOffset
=
fetchOffset
;
rsp
.
numOfTopics
=
1
;
...
...
@@ -328,6 +340,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
void
*
buf
=
rpcMallocCont
(
tlen
);
if
(
buf
==
NULL
)
{
pMsg
->
code
=
-
1
;
taosMemoryFree
(
pHead
);
return
-
1
;
}
((
SMqRspHead
*
)
buf
)
->
mqMsgType
=
TMQ_MSG_TYPE__POLL_RSP
;
...
...
@@ -340,10 +353,14 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
pMsg
->
pCont
=
buf
;
pMsg
->
contLen
=
tlen
;
pMsg
->
code
=
0
;
/*printf("vg %d offset %ld msgType %d from epoch %d actual rsp\n", pTq->pVnode->vgId, fetchOffset,
* pHead->msgType,*/
/*pReq->epoch);*/
tmsgSendRsp
(
pMsg
);
taosMemoryFree
(
pHead
);
return
0
;
}
}
else
{
taosMemoryFree
(
pHead
);
fetchOffset
++
;
rsp
.
skipLogNum
++
;
}
...
...
@@ -368,6 +385,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
pMsg
->
contLen
=
tlen
;
pMsg
->
code
=
0
;
tmsgSendRsp
(
pMsg
);
/*printf("vg %d offset %ld from epoch %d not rsp\n", pTq->pVnode->vgId, fetchOffset, pReq->epoch);*/
/*}*/
return
0
;
...
...
@@ -432,7 +450,9 @@ int32_t tqProcessSetConnReq(STQ* pTq, char* msg) {
};
pTopic
->
buffer
.
output
[
i
].
pReadHandle
=
pReadHandle
;
pTopic
->
buffer
.
output
[
i
].
task
=
qCreateStreamExecTaskInfo
(
req
.
qmsg
,
&
handle
);
ASSERT
(
pTopic
->
buffer
.
output
[
i
].
task
);
}
printf
(
"set topic %s to consumer %ld
\n
"
,
pTopic
->
topicName
,
req
.
consumerId
);
taosArrayPush
(
pConsumer
->
topics
,
pTopic
);
tqHandleMovePut
(
pTq
->
tqMeta
,
req
.
consumerId
,
pConsumer
);
tqHandleCommit
(
pTq
->
tqMeta
,
req
.
consumerId
);
...
...
source/dnode/vnode/src/tq/tqRead.c
浏览文件 @
9833a6c5
...
...
@@ -168,6 +168,7 @@ SArray* tqRetrieveDataBlock(STqReadHandle* pHandle) {
break
;
}
if
(
colDataAppend
(
pColData
,
curRow
,
sVal
.
val
,
false
)
<
0
)
{
/*if (colDataAppend(pColData, curRow, sVal.val, sVal.valType == TD_VTYPE_NULL) < 0) {*/
taosArrayDestroyEx
(
pArray
,
(
void
(
*
)(
void
*
))
tDeleteSSDataBlock
);
return
NULL
;
}
...
...
source/dnode/vnode/src/tsdb/tsdbCommit.c
浏览文件 @
9833a6c5
...
...
@@ -1394,7 +1394,7 @@ int tsdbWriteBlockImpl(STsdb *pRepo, STable *pTable, SDFile *pDFile, SDFile *pDF
tsdbDebug
(
"vgId:%d uid:%"
PRId64
" a block of data is written to file %s, offset %"
PRId64
" numOfRows %d len %d numOfCols %"
PRId16
" keyFirst %"
PRId64
" keyLast %"
PRId64
,
REPO_ID
(
pRepo
),
TABLE_
T
ID
(
pTable
),
TSDB_FILE_FULL_NAME
(
pDFile
),
offset
,
rowsToWrite
,
pBlock
->
len
,
REPO_ID
(
pRepo
),
TABLE_
U
ID
(
pTable
),
TSDB_FILE_FULL_NAME
(
pDFile
),
offset
,
rowsToWrite
,
pBlock
->
len
,
pBlock
->
numOfCols
,
pBlock
->
keyFirst
,
pBlock
->
keyLast
);
return
0
;
...
...
source/dnode/vnode/src/tsdb/tsdbRead.c
浏览文件 @
9833a6c5
source/dnode/vnode/src/vnd/vnodeQuery.c
浏览文件 @
9833a6c5
...
...
@@ -66,7 +66,7 @@ int vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
case
TDMT_VND_TABLE_META
:
return
vnodeGetTableMeta
(
pVnode
,
pMsg
);
case
TDMT_VND_CONSUME
:
return
tqProcessPollReq
(
pVnode
->
pTq
,
pMsg
);
return
tqProcessPollReq
(
pVnode
->
pTq
,
pMsg
,
pInfo
->
workerId
);
case
TDMT_VND_TASK_PIPE_EXEC
:
case
TDMT_VND_TASK_MERGE_EXEC
:
return
tqProcessTaskExec
(
pVnode
->
pTq
,
msgstr
,
msgLen
,
0
);
...
...
source/dnode/vnode/src/vnd/vnodeWrite.c
浏览文件 @
9833a6c5
...
...
@@ -165,6 +165,7 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
// }
break
;
case
TDMT_VND_SUBMIT
:
/*printf("vnode %d write data %ld\n", pVnode->vgId, ver);*/
if
(
pVnode
->
config
.
streamMode
==
0
)
{
if
(
tsdbInsertData
(
pVnode
->
pTsdb
,
(
SSubmitReq
*
)
ptr
,
NULL
)
<
0
)
{
// TODO: handle error
...
...
source/libs/catalog/inc/catalogInt.h
浏览文件 @
9833a6c5
...
...
@@ -112,7 +112,14 @@ typedef struct SCtgRuntimeStat {
}
SCtgRuntimeStat
;
typedef
struct
SCtgCacheStat
{
uint64_t
clusterNum
;
uint64_t
dbNum
;
uint64_t
tblNum
;
uint64_t
stblNum
;
uint64_t
vgHitNum
;
uint64_t
vgMissNum
;
uint64_t
tblHitNum
;
uint64_t
tblMissNum
;
}
SCtgCacheStat
;
typedef
struct
SCatalogStat
{
...
...
@@ -204,8 +211,13 @@ typedef struct SCtgAction {
#define CTG_QUEUE_ADD() atomic_add_fetch_64(&gCtgMgmt.queue.qRemainNum, 1)
#define CTG_QUEUE_SUB() atomic_sub_fetch_64(&gCtgMgmt.queue.qRemainNum, 1)
#define CTG_STAT_ADD(n) atomic_add_fetch_64(&(n), 1)
#define CTG_STAT_SUB(n) atomic_sub_fetch_64(&(n), 1)
#define CTG_STAT_ADD(_item, _n) atomic_add_fetch_64(&(_item), _n)
#define CTG_STAT_SUB(_item, _n) atomic_sub_fetch_64(&(_item), _n)
#define CTG_STAT_GET(_item) atomic_load_64(&(_item))
#define CTG_RUNTIME_STAT_ADD(item, n) (CTG_STAT_ADD(gCtgMgmt.stat.runtime.item, n))
#define CTG_CACHE_STAT_ADD(item, n) (CTG_STAT_ADD(gCtgMgmt.stat.cache.item, n))
#define CTG_CACHE_STAT_SUB(item, n) (CTG_STAT_SUB(gCtgMgmt.stat.cache.item, n))
#define CTG_IS_META_NULL(type) ((type) == META_TYPE_NULL_TABLE)
#define CTG_IS_META_CTABLE(type) ((type) == META_TYPE_CTABLE)
...
...
@@ -291,6 +303,9 @@ typedef struct SCtgAction {
#define CTG_API_ENTER() do { CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); CTG_LOCK(CTG_READ, &gCtgMgmt.lock); if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { CTG_API_LEAVE(TSDB_CODE_CTG_OUT_OF_SERVICE); } } while (0)
extern
void
ctgdShowTableMeta
(
SCatalog
*
pCtg
,
const
char
*
tbName
,
STableMeta
*
p
);
extern
void
ctgdShowClusterCache
(
SCatalog
*
pCtg
);
extern
int32_t
ctgdShowCacheInfo
(
void
);
#ifdef __cplusplus
}
...
...
source/libs/catalog/src/catalog.c
浏览文件 @
9833a6c5
此差异已折叠。
点击以展开。
source/libs/catalog/src/catalogDbg.c
0 → 100644
浏览文件 @
9833a6c5
/*
* 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 "trpc.h"
#include "query.h"
#include "tname.h"
#include "catalogInt.h"
extern
SCatalogMgmt
gCtgMgmt
;
SCtgDebug
gCTGDebug
=
{
0
};
int32_t
ctgdEnableDebug
(
char
*
option
)
{
if
(
0
==
strcasecmp
(
option
,
"lock"
))
{
gCTGDebug
.
lockEnable
=
true
;
qDebug
(
"lock debug enabled"
);
return
TSDB_CODE_SUCCESS
;
}
if
(
0
==
strcasecmp
(
option
,
"cache"
))
{
gCTGDebug
.
cacheEnable
=
true
;
qDebug
(
"cache debug enabled"
);
return
TSDB_CODE_SUCCESS
;
}
if
(
0
==
strcasecmp
(
option
,
"api"
))
{
gCTGDebug
.
apiEnable
=
true
;
qDebug
(
"api debug enabled"
);
return
TSDB_CODE_SUCCESS
;
}
if
(
0
==
strcasecmp
(
option
,
"meta"
))
{
gCTGDebug
.
metaEnable
=
true
;
qDebug
(
"api debug enabled"
);
return
TSDB_CODE_SUCCESS
;
}
qError
(
"invalid debug option:%s"
,
option
);
return
TSDB_CODE_CTG_INTERNAL_ERROR
;
}
int32_t
ctgdGetStatNum
(
char
*
option
,
void
*
res
)
{
if
(
0
==
strcasecmp
(
option
,
"runtime.qDoneNum"
))
{
*
(
uint64_t
*
)
res
=
atomic_load_64
(
&
gCtgMgmt
.
stat
.
runtime
.
qDoneNum
);
return
TSDB_CODE_SUCCESS
;
}
qError
(
"invalid stat option:%s"
,
option
);
return
TSDB_CODE_CTG_INTERNAL_ERROR
;
}
int32_t
ctgdGetTbMetaNum
(
SCtgDBCache
*
dbCache
)
{
return
dbCache
->
tbCache
.
metaCache
?
(
int32_t
)
taosHashGetSize
(
dbCache
->
tbCache
.
metaCache
)
:
0
;
}
int32_t
ctgdGetStbNum
(
SCtgDBCache
*
dbCache
)
{
return
dbCache
->
tbCache
.
stbCache
?
(
int32_t
)
taosHashGetSize
(
dbCache
->
tbCache
.
stbCache
)
:
0
;
}
int32_t
ctgdGetRentNum
(
SCtgRentMgmt
*
rent
)
{
int32_t
num
=
0
;
for
(
uint16_t
i
=
0
;
i
<
rent
->
slotNum
;
++
i
)
{
SCtgRentSlot
*
slot
=
&
rent
->
slots
[
i
];
if
(
NULL
==
slot
->
meta
)
{
continue
;
}
num
+=
taosArrayGetSize
(
slot
->
meta
);
}
return
num
;
}
int32_t
ctgdGetClusterCacheNum
(
SCatalog
*
pCtg
,
int32_t
type
)
{
if
(
NULL
==
pCtg
||
NULL
==
pCtg
->
dbCache
)
{
return
0
;
}
switch
(
type
)
{
case
CTG_DBG_DB_NUM
:
return
(
int32_t
)
taosHashGetSize
(
pCtg
->
dbCache
);
case
CTG_DBG_DB_RENT_NUM
:
return
ctgdGetRentNum
(
&
pCtg
->
dbRent
);
case
CTG_DBG_STB_RENT_NUM
:
return
ctgdGetRentNum
(
&
pCtg
->
stbRent
);
default:
break
;
}
SCtgDBCache
*
dbCache
=
NULL
;
int32_t
num
=
0
;
void
*
pIter
=
taosHashIterate
(
pCtg
->
dbCache
,
NULL
);
while
(
pIter
)
{
dbCache
=
(
SCtgDBCache
*
)
pIter
;
switch
(
type
)
{
case
CTG_DBG_META_NUM
:
num
+=
ctgdGetTbMetaNum
(
dbCache
);
break
;
case
CTG_DBG_STB_NUM
:
num
+=
ctgdGetStbNum
(
dbCache
);
break
;
default:
ctgError
(
"invalid type:%d"
,
type
);
break
;
}
pIter
=
taosHashIterate
(
pCtg
->
dbCache
,
pIter
);
}
return
num
;
}
void
ctgdShowTableMeta
(
SCatalog
*
pCtg
,
const
char
*
tbName
,
STableMeta
*
p
)
{
if
(
!
gCTGDebug
.
metaEnable
)
{
return
;
}
STableComInfo
*
c
=
&
p
->
tableInfo
;
if
(
TSDB_CHILD_TABLE
==
p
->
tableType
)
{
ctgDebug
(
"table [%s] meta: type:%d, vgId:%d, uid:%"
PRIx64
",suid:%"
PRIx64
,
tbName
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
);
return
;
}
else
{
ctgDebug
(
"table [%s] meta: type:%d, vgId:%d, uid:%"
PRIx64
",suid:%"
PRIx64
",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d"
,
tbName
,
p
->
tableType
,
p
->
vgId
,
p
->
uid
,
p
->
suid
,
p
->
sversion
,
p
->
tversion
,
c
->
numOfTags
,
c
->
precision
,
c
->
numOfColumns
,
c
->
rowSize
);
}
int32_t
colNum
=
c
->
numOfColumns
+
c
->
numOfTags
;
for
(
int32_t
i
=
0
;
i
<
colNum
;
++
i
)
{
SSchema
*
s
=
&
p
->
schema
[
i
];
ctgDebug
(
"[%d] name:%s, type:%d, colId:%d, bytes:%d"
,
i
,
s
->
name
,
s
->
type
,
s
->
colId
,
s
->
bytes
);
}
}
void
ctgdShowDBCache
(
SCatalog
*
pCtg
,
SHashObj
*
dbHash
)
{
if
(
NULL
==
dbHash
||
!
gCTGDebug
.
cacheEnable
)
{
return
;
}
int32_t
i
=
0
;
SCtgDBCache
*
dbCache
=
NULL
;
void
*
pIter
=
taosHashIterate
(
dbHash
,
NULL
);
while
(
pIter
)
{
char
*
dbFName
=
NULL
;
size_t
len
=
0
;
dbCache
=
(
SCtgDBCache
*
)
pIter
;
dbFName
=
taosHashGetKey
(
pIter
,
&
len
);
int32_t
metaNum
=
dbCache
->
tbCache
.
metaCache
?
taosHashGetSize
(
dbCache
->
tbCache
.
metaCache
)
:
0
;
int32_t
stbNum
=
dbCache
->
tbCache
.
stbCache
?
taosHashGetSize
(
dbCache
->
tbCache
.
stbCache
)
:
0
;
int32_t
vgVersion
=
CTG_DEFAULT_INVALID_VERSION
;
int32_t
hashMethod
=
-
1
;
int32_t
vgNum
=
0
;
if
(
dbCache
->
vgInfo
)
{
vgVersion
=
dbCache
->
vgInfo
->
vgVersion
;
hashMethod
=
dbCache
->
vgInfo
->
hashMethod
;
if
(
dbCache
->
vgInfo
->
vgHash
)
{
vgNum
=
taosHashGetSize
(
dbCache
->
vgInfo
->
vgHash
);
}
}
ctgDebug
(
"[%d] db [%.*s][%"
PRIx64
"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, vgNum:%d"
,
i
,
(
int32_t
)
len
,
dbFName
,
dbCache
->
dbId
,
dbCache
->
deleted
?
"deleted"
:
""
,
metaNum
,
stbNum
,
vgVersion
,
hashMethod
,
vgNum
);
pIter
=
taosHashIterate
(
dbHash
,
pIter
);
}
}
void
ctgdShowClusterCache
(
SCatalog
*
pCtg
)
{
if
(
!
gCTGDebug
.
cacheEnable
||
NULL
==
pCtg
)
{
return
;
}
ctgDebug
(
"## cluster %"
PRIx64
" %p cache Info BEGIN ##"
,
pCtg
->
clusterId
,
pCtg
);
ctgDebug
(
"db:%d meta:%d stb:%d dbRent:%d stbRent:%d"
,
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_RENT_NUM
),
ctgdGetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
));
ctgdShowDBCache
(
pCtg
,
pCtg
->
dbCache
);
ctgDebug
(
"## cluster %"
PRIx64
" %p cache Info END ##"
,
pCtg
->
clusterId
,
pCtg
);
}
int32_t
ctgdShowCacheInfo
(
void
)
{
if
(
!
gCTGDebug
.
cacheEnable
)
{
return
TSDB_CODE_CTG_OUT_OF_SERVICE
;
}
CTG_API_ENTER
();
SCatalog
*
pCtg
=
NULL
;
void
*
pIter
=
taosHashIterate
(
gCtgMgmt
.
pCluster
,
NULL
);
while
(
pIter
)
{
pCtg
=
*
(
SCatalog
**
)
pIter
;
if
(
pCtg
)
{
ctgdShowClusterCache
(
pCtg
);
}
pIter
=
taosHashIterate
(
gCtgMgmt
.
pCluster
,
pIter
);
}
CTG_API_LEAVE
(
TSDB_CODE_SUCCESS
);
}
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
9833a6c5
...
...
@@ -38,11 +38,11 @@
namespace
{
extern
"C"
int32_t
ctgGetTableMetaFromCache
(
struct
SCatalog
*
pCatalog
,
const
SName
*
pTableName
,
STableMeta
**
pTableMeta
,
int32_t
*
exist
,
int32_t
flag
,
uint64_t
*
dbId
);
extern
"C"
int32_t
ctg
Dbg
GetClusterCacheNum
(
struct
SCatalog
*
pCatalog
,
int32_t
type
);
bool
*
inCache
,
int32_t
flag
,
uint64_t
*
dbId
);
extern
"C"
int32_t
ctg
d
GetClusterCacheNum
(
struct
SCatalog
*
pCatalog
,
int32_t
type
);
extern
"C"
int32_t
ctgActUpdateTbl
(
SCtgMetaAction
*
action
);
extern
"C"
int32_t
ctg
Dbg
EnableDebug
(
char
*
option
);
extern
"C"
int32_t
ctg
Dbg
GetStatNum
(
char
*
option
,
void
*
res
);
extern
"C"
int32_t
ctg
d
EnableDebug
(
char
*
option
);
extern
"C"
int32_t
ctg
d
GetStatNum
(
char
*
option
,
void
*
res
);
void
ctgTestSetRspTableMeta
();
void
ctgTestSetRspCTableMeta
();
...
...
@@ -140,9 +140,9 @@ void ctgTestInitLogFile() {
qDebugFlag
=
159
;
strcpy
(
tsLogDir
,
"/var/log/taos"
);
ctg
Dbg
EnableDebug
(
"api"
);
ctg
Dbg
EnableDebug
(
"meta"
);
ctg
Dbg
EnableDebug
(
"cache"
);
ctg
d
EnableDebug
(
"api"
);
ctg
d
EnableDebug
(
"meta"
);
ctg
d
EnableDebug
(
"cache"
);
if
(
taosInitLog
(
defaultLogFileNamePrefix
,
maxLogFileNum
)
<
0
)
{
printf
(
"failed to open log file in directory:%s
\n
"
,
tsLogDir
);
...
...
@@ -786,15 +786,15 @@ void *ctgTestGetCtableMetaThread(void *param) {
int32_t
code
=
0
;
int32_t
n
=
0
;
STableMeta
*
tbMeta
=
NULL
;
int32_t
exist
=
0
;
bool
inCache
=
false
;
SName
cn
=
{.
type
=
TSDB_TABLE_NAME_T
,
.
acctId
=
1
};
strcpy
(
cn
.
dbname
,
"db1"
);
strcpy
(
cn
.
tname
,
ctgTestCTablename
);
while
(
!
ctgTestStop
)
{
code
=
ctgGetTableMetaFromCache
(
pCtg
,
&
cn
,
&
tbMeta
,
&
exist
,
0
,
NULL
);
if
(
code
||
0
==
exist
)
{
code
=
ctgGetTableMetaFromCache
(
pCtg
,
&
cn
,
&
tbMeta
,
&
inCache
,
0
,
NULL
);
if
(
code
||
!
inCache
)
{
assert
(
0
);
}
...
...
@@ -879,7 +879,7 @@ TEST(tableMeta, normalTable) {
ASSERT_EQ
(
vgInfo
.
vgId
,
8
);
ASSERT_EQ
(
vgInfo
.
epSet
.
numOfEps
,
3
);
while
(
0
==
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
))
{
while
(
0
==
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
))
{
taosMsleep
(
50
);
}
...
...
@@ -899,7 +899,7 @@ TEST(tableMeta, normalTable) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
while
(
true
)
{
uint32_t
n
=
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
);
uint32_t
n
=
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
);
if
(
0
==
n
)
{
taosMsleep
(
50
);
}
else
{
...
...
@@ -994,7 +994,7 @@ TEST(tableMeta, childTableCase) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
while
(
true
)
{
uint32_t
n
=
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
);
uint32_t
n
=
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
);
if
(
0
==
n
)
{
taosMsleep
(
50
);
}
else
{
...
...
@@ -1103,7 +1103,7 @@ TEST(tableMeta, superTableCase) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
while
(
true
)
{
uint32_t
n
=
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
);
uint32_t
n
=
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
);
if
(
0
==
n
)
{
taosMsleep
(
50
);
}
else
{
...
...
@@ -1130,7 +1130,7 @@ TEST(tableMeta, superTableCase) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
while
(
true
)
{
uint32_t
n
=
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
);
uint32_t
n
=
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
);
if
(
2
!=
n
)
{
taosMsleep
(
50
);
}
else
{
...
...
@@ -1228,7 +1228,7 @@ TEST(tableMeta, rmStbMeta) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
while
(
true
)
{
uint32_t
n
=
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
);
uint32_t
n
=
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
);
if
(
0
==
n
)
{
taosMsleep
(
50
);
}
else
{
...
...
@@ -1241,8 +1241,8 @@ TEST(tableMeta, rmStbMeta) {
ASSERT_EQ
(
code
,
0
);
while
(
true
)
{
int32_t
n
=
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
);
int32_t
m
=
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
);
int32_t
n
=
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
);
int32_t
m
=
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
);
if
(
n
||
m
)
{
taosMsleep
(
50
);
}
else
{
...
...
@@ -1251,11 +1251,11 @@ TEST(tableMeta, rmStbMeta) {
}
ASSERT_EQ
(
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
1
);
ASSERT_EQ
(
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
0
);
ASSERT_EQ
(
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
0
);
ASSERT_EQ
(
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_RENT_NUM
),
1
);
ASSERT_EQ
(
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
),
0
);
ASSERT_EQ
(
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
1
);
ASSERT_EQ
(
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
0
);
ASSERT_EQ
(
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
0
);
ASSERT_EQ
(
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_RENT_NUM
),
1
);
ASSERT_EQ
(
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
),
0
);
catalogDestroy
();
memset
(
&
gCtgMgmt
,
0
,
sizeof
(
gCtgMgmt
));
...
...
@@ -1298,7 +1298,7 @@ TEST(tableMeta, updateStbMeta) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
while
(
true
)
{
uint32_t
n
=
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
);
uint32_t
n
=
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
);
if
(
0
==
n
)
{
taosMsleep
(
50
);
}
else
{
...
...
@@ -1318,7 +1318,7 @@ TEST(tableMeta, updateStbMeta) {
while
(
true
)
{
uint64_t
n
=
0
;
ctg
Dbg
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
ctg
d
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
if
(
n
!=
3
)
{
taosMsleep
(
50
);
}
else
{
...
...
@@ -1326,11 +1326,11 @@ TEST(tableMeta, updateStbMeta) {
}
}
ASSERT_EQ
(
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
1
);
ASSERT_EQ
(
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
1
);
ASSERT_EQ
(
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
1
);
ASSERT_EQ
(
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_RENT_NUM
),
1
);
ASSERT_EQ
(
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
),
1
);
ASSERT_EQ
(
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_NUM
),
1
);
ASSERT_EQ
(
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
),
1
);
ASSERT_EQ
(
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_NUM
),
1
);
ASSERT_EQ
(
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_DB_RENT_NUM
),
1
);
ASSERT_EQ
(
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_STB_RENT_NUM
),
1
);
code
=
catalogGetTableMeta
(
pCtg
,
mockPointer
,
(
const
SEpSet
*
)
mockPointer
,
&
n
,
&
tableMeta
);
ASSERT_EQ
(
code
,
0
);
...
...
@@ -1388,7 +1388,7 @@ TEST(refreshGetMeta, normal2normal) {
while
(
true
)
{
uint64_t
n
=
0
;
ctg
Dbg
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
ctg
d
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
if
(
n
>
0
)
{
break
;
}
...
...
@@ -1409,7 +1409,7 @@ TEST(refreshGetMeta, normal2normal) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
taosMemoryFreeClear
(
tableMeta
);
while
(
0
==
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
))
{
while
(
0
==
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
))
{
taosMsleep
(
50
);
}
...
...
@@ -1467,7 +1467,7 @@ TEST(refreshGetMeta, normal2notexist) {
while
(
true
)
{
uint64_t
n
=
0
;
ctg
Dbg
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
ctg
d
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
if
(
n
>
0
)
{
break
;
}
...
...
@@ -1488,7 +1488,7 @@ TEST(refreshGetMeta, normal2notexist) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
taosMemoryFreeClear
(
tableMeta
);
while
(
0
==
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
))
{
while
(
0
==
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
))
{
taosMsleep
(
50
);
}
...
...
@@ -1541,7 +1541,7 @@ TEST(refreshGetMeta, normal2child) {
while
(
true
)
{
uint64_t
n
=
0
;
ctg
Dbg
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
ctg
d
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
if
(
n
>
0
)
{
break
;
}
...
...
@@ -1562,7 +1562,7 @@ TEST(refreshGetMeta, normal2child) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
taosMemoryFreeClear
(
tableMeta
);
while
(
0
==
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
))
{
while
(
0
==
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
))
{
taosMsleep
(
50
);
}
...
...
@@ -1625,7 +1625,7 @@ TEST(refreshGetMeta, stable2child) {
while
(
true
)
{
uint64_t
n
=
0
;
ctg
Dbg
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
ctg
d
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
if
(
n
>
0
)
{
break
;
}
...
...
@@ -1647,7 +1647,7 @@ TEST(refreshGetMeta, stable2child) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
taosMemoryFreeClear
(
tableMeta
);
while
(
0
==
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
))
{
while
(
0
==
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
))
{
taosMsleep
(
50
);
}
...
...
@@ -1710,7 +1710,7 @@ TEST(refreshGetMeta, stable2stable) {
while
(
true
)
{
uint64_t
n
=
0
;
ctg
Dbg
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
ctg
d
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
if
(
n
>
0
)
{
break
;
}
...
...
@@ -1732,7 +1732,7 @@ TEST(refreshGetMeta, stable2stable) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
taosMemoryFreeClear
(
tableMeta
);
while
(
0
==
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
))
{
while
(
0
==
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
))
{
taosMsleep
(
50
);
}
...
...
@@ -1798,7 +1798,7 @@ TEST(refreshGetMeta, child2stable) {
while
(
true
)
{
uint64_t
n
=
0
;
ctg
Dbg
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
ctg
d
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
if
(
n
>
0
)
{
break
;
}
...
...
@@ -1818,7 +1818,7 @@ TEST(refreshGetMeta, child2stable) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
taosMemoryFreeClear
(
tableMeta
);
while
(
2
!=
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
))
{
while
(
2
!=
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
))
{
taosMsleep
(
50
);
}
...
...
@@ -2015,7 +2015,7 @@ TEST(dbVgroup, getSetDbVgroupCase) {
while
(
true
)
{
uint64_t
n
=
0
;
ctg
Dbg
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
ctg
d
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
if
(
n
>
0
)
{
break
;
}
...
...
@@ -2041,7 +2041,7 @@ TEST(dbVgroup, getSetDbVgroupCase) {
while
(
true
)
{
uint64_t
n
=
0
;
ctg
Dbg
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
ctg
d
GetStatNum
(
"runtime.qDoneNum"
,
(
void
*
)
&
n
);
if
(
n
!=
3
)
{
taosMsleep
(
50
);
}
else
{
...
...
@@ -2266,7 +2266,7 @@ TEST(rentTest, allRent) {
ASSERT_EQ
(
tableMeta
->
tableInfo
.
precision
,
1
);
ASSERT_EQ
(
tableMeta
->
tableInfo
.
rowSize
,
12
);
while
(
ctg
Dbg
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
)
<
i
)
{
while
(
ctg
d
GetClusterCacheNum
(
pCtg
,
CTG_DBG_META_NUM
)
<
i
)
{
taosMsleep
(
50
);
}
...
...
source/libs/command/inc/commandInt.h
0 → 100644
浏览文件 @
9833a6c5
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_QUERY_INT_H_
#define _TD_QUERY_INT_H_
#ifdef __cplusplus
extern
"C"
{
#endif
#include "nodes.h"
#include "plannodes.h"
#include "ttime.h"
#define EXPLAIN_MAX_GROUP_NUM 100
//newline area
#define EXPLAIN_TAG_SCAN_FORMAT "Tag Scan on %s columns=%d width=%d"
#define EXPLAIN_TBL_SCAN_FORMAT "Table Scan on %s columns=%d width=%d"
#define EXPLAIN_SYSTBL_SCAN_FORMAT "System Table Scan on %s columns=%d width=%d"
#define EXPLAIN_PROJECTION_FORMAT "Projection columns=%d width=%d"
#define EXPLAIN_JOIN_FORMAT "%s between %d tables width=%d"
#define EXPLAIN_AGG_FORMAT "Aggragate functions=%d"
#define EXPLAIN_EXCHANGE_FORMAT "Data Exchange %d:1 width=%d"
#define EXPLAIN_SORT_FORMAT "Sort on %d Column(s) width=%d"
#define EXPLAIN_INTERVAL_FORMAT "Interval on Column %s functions=%d interval=%" PRId64 "%c offset=%" PRId64 "%c sliding=%" PRId64 "%c width=%d"
#define EXPLAIN_SESSION_FORMAT "Session gap=%" PRId64 " functions=%d width=%d"
#define EXPLAIN_ORDER_FORMAT "Order: %s"
#define EXPLAIN_FILTER_FORMAT "Filter: "
#define EXPLAIN_FILL_FORMAT "Fill: %s"
#define EXPLAIN_ON_CONDITIONS_FORMAT "Join Cond: "
#define EXPLAIN_TIMERANGE_FORMAT "Time Range: [%" PRId64 ", %" PRId64 "]"
//append area
#define EXPLAIN_GROUPS_FORMAT " groups=%d"
#define EXPLAIN_WIDTH_FORMAT " width=%d"
#define EXPLAIN_LOOPS_FORMAT " loops=%d"
#define EXPLAIN_REVERSE_FORMAT " reverse=%d"
typedef
struct
SExplainGroup
{
int32_t
nodeNum
;
SSubplan
*
plan
;
void
*
execInfo
;
//TODO
}
SExplainGroup
;
typedef
struct
SExplainResNode
{
SNodeList
*
pChildren
;
SPhysiNode
*
pNode
;
void
*
pExecInfo
;
}
SExplainResNode
;
typedef
struct
SQueryExplainRowInfo
{
int32_t
level
;
int32_t
len
;
char
*
buf
;
}
SQueryExplainRowInfo
;
typedef
struct
SExplainCtx
{
int32_t
totalSize
;
bool
verbose
;
char
*
tbuf
;
SArray
*
rows
;
SHashObj
*
groupHash
;
}
SExplainCtx
;
#define EXPLAIN_ORDER_STRING(_order) ((TSDB_ORDER_ASC == _order) ? "Ascending" : "Descending")
#define EXPLAIN_JOIN_STRING(_type) ((JOIN_TYPE_INNER == _type) ? "Inner join" : "Join")
#define INVERAL_TIME_FROM_PRECISION_TO_UNIT(_t, _u, _p) (((_u) == 'n' || (_u) == 'y') ? (_t) : (convertTimeFromPrecisionToUnit(_t, _p, _u)))
#define EXPLAIN_ROW_NEW(level, ...) \
do { \
if (isVerboseLine) { \
tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, "%*s", (level) * 2 + 3, ""); \
} else { \
tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, "%*s%s", (level) * 2, "", "-> "); \
} \
tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - tlen, __VA_ARGS__); \
} while (0)
#define EXPLAIN_ROW_APPEND(...) tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - tlen, __VA_ARGS__)
#define EXPLAIN_ROW_END() do { varDataSetLen(tbuf, tlen); tlen += VARSTR_HEADER_SIZE; isVerboseLine = true; } while (0)
#ifdef __cplusplus
}
#endif
#endif
/*_TD_QUERY_INT_H_*/
source/libs/command/src/explain.c
0 → 100644
浏览文件 @
9833a6c5
此差异已折叠。
点击以展开。
source/libs/executor/inc/executil.h
浏览文件 @
9833a6c5
...
...
@@ -73,27 +73,12 @@ typedef struct SResultRowPosition {
}
SResultRowPosition
;
typedef
struct
SResultRowInfo
{
SList
*
pRows
;
SResultRowPosition
*
pPosition
;
SResultRow
**
pResult
;
// result list
int32_t
size
;
// number of result set
int32_t
capacity
;
// max capacity
int32_t
curPos
;
// current active result row index of pResult list
}
SResultRowInfo
;
typedef
struct
SResultRowPool
{
int32_t
elemSize
;
int32_t
blockSize
;
int32_t
numOfElemPerBlock
;
struct
{
int32_t
blockIndex
;
int32_t
pos
;
}
position
;
SArray
*
pData
;
// SArray<void*>
}
SResultRowPool
;
struct
STaskAttr
;
struct
STaskRuntimeEnv
;
struct
SUdfInfo
;
...
...
@@ -109,25 +94,33 @@ void resetResultRowInfo(struct STaskRuntimeEnv* pRuntimeEnv, SResultRowInfo*
int32_t
numOfClosedResultRows
(
SResultRowInfo
*
pResultRowInfo
);
void
closeAllResultRows
(
SResultRowInfo
*
pResultRowInfo
);
int32_t
initResultRow
(
SResultRow
*
pResultRow
);
void
closeResultRow
(
SResultRowInfo
*
pResultRowInfo
,
int32_t
slot
);
bool
isResultRowClosed
(
SResultRowInfo
*
pResultRowInfo
,
int32_t
slot
);
void
clearResultRow
(
struct
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResultRow
);
void
initResultRow
(
SResultRow
*
pResultRow
);
void
closeResultRow
(
SResultRow
*
pResultRow
);
bool
isResultRowClosed
(
SResultRow
*
pResultRow
);
struct
SResultRowEntryInfo
*
getResultCell
(
const
SResultRow
*
pRow
,
int32_t
index
,
int32_t
*
offset
);
void
*
destroyQueryFuncExpr
(
SExprInfo
*
pExprInfo
,
int32_t
numOfExpr
);
int32_t
getRowNumForMultioutput
(
struct
STaskAttr
*
pQueryAttr
,
bool
topBottomQuery
,
bool
stable
);
static
FORCE_INLINE
SResultRow
*
getResultRow
(
SResultRowInfo
*
pResultRowInfo
,
int32_t
slot
)
{
assert
(
pResultRowInfo
!=
NULL
&&
slot
>=
0
&&
slot
<
pResultRowInfo
->
size
);
return
pResultRowInfo
->
pResult
[
slot
];
static
FORCE_INLINE
SResultRow
*
getResultRow
(
SDiskbasedBuf
*
pBuf
,
SResultRowInfo
*
pResultRowInfo
,
int32_t
slot
)
{
ASSERT
(
pResultRowInfo
!=
NULL
&&
slot
>=
0
&&
slot
<
pResultRowInfo
->
size
);
SResultRowPosition
*
pos
=
&
pResultRowInfo
->
pPosition
[
slot
];
SFilePage
*
bufPage
=
(
SFilePage
*
)
getBufPage
(
pBuf
,
pos
->
pageId
);
SResultRow
*
pRow
=
(
SResultRow
*
)((
char
*
)
bufPage
+
pos
->
offset
);
return
pRow
;
}
static
FORCE_INLINE
SResultRow
*
getResultRowByPos
(
SDiskbasedBuf
*
pBuf
,
SResultRowPosition
*
pos
)
{
SFilePage
*
bufPage
=
(
SFilePage
*
)
getBufPage
(
pBuf
,
pos
->
pageId
);
SResultRow
*
pRow
=
(
SResultRow
*
)((
char
*
)
bufPage
+
pos
->
offset
);
return
pRow
;
}
static
FORCE_INLINE
char
*
getPosInResultPage
(
struct
STaskAttr
*
pQueryAttr
,
SFilePage
*
page
,
int32_t
rowOffset
,
int32_t
offset
)
{
assert
(
rowOffset
>=
0
&&
pQueryAttr
!=
NULL
);
ASSERT
(
0
);
// int32_t numOfRows = (int32_t)getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery);
// return ((char *)page->data) + rowOffset + offset * numOfRows;
}
...
...
@@ -139,22 +132,11 @@ static FORCE_INLINE char* getPosInResultPage_rv(SFilePage* page, int32_t rowOffs
return
(
char
*
)
page
+
rowOffset
+
offset
*
numOfRows
;
}
//bool isNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type);
//bool notNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type);
__filter_func_t
getFilterOperator
(
int32_t
lowerOptr
,
int32_t
upperOptr
);
SResultRow
*
getNewResultRow
(
SResultRowPool
*
p
);
typedef
struct
{
SArray
*
pResult
;
// SArray<SResPair>
int32_t
colId
;
}
SStddevInterResult
;
void
interResToBinary
(
SBufferWriter
*
bw
,
SArray
*
pRes
,
int32_t
tagLen
);
SArray
*
interResFromBinary
(
const
char
*
data
,
int32_t
len
);
void
freeInterResult
(
void
*
param
);
void
initGroupResInfo
(
SGroupResInfo
*
pGroupResInfo
,
SResultRowInfo
*
pResultInfo
);
void
initMultiResInfoFromArrayList
(
SGroupResInfo
*
pGroupResInfo
,
SArray
*
pArrayList
);
...
...
source/libs/executor/inc/executorimpl.h
浏览文件 @
9833a6c5
...
...
@@ -69,7 +69,7 @@ enum {
typedef
struct
SResultRowCell
{
uint64_t
groupId
;
SResultRow
*
pRow
;
SResultRow
Position
pos
;
}
SResultRowCell
;
/**
...
...
@@ -277,8 +277,6 @@ typedef struct STaskRuntimeEnv {
char
*
keyBuf
;
// window key buffer
// The window result objects pool, all the resultRow Objects are allocated and managed by this object.
char
**
prevRow
;
SResultRowPool
*
pool
;
SArray
*
prevResult
;
// intermediate result, SArray<SInterResult>
STSBuf
*
pTsBuf
;
// timestamp filter list
STSCursor
cur
;
...
...
source/libs/executor/src/executil.c
浏览文件 @
9833a6c5
...
...
@@ -55,13 +55,11 @@ int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size) {
pResultRowInfo
->
size
=
0
;
pResultRowInfo
->
curPos
=
-
1
;
pResultRowInfo
->
capacity
=
size
;
pResultRowInfo
->
pResult
=
taosMemoryCalloc
(
pResultRowInfo
->
capacity
,
POINTER_BYTES
);
pResultRowInfo
->
pPosition
=
taosMemoryCalloc
(
pResultRowInfo
->
capacity
,
sizeof
(
SResultRowPosition
));
if
(
pResultRowInfo
->
pResult
==
NULL
||
pResultRowInfo
->
pPosition
==
NULL
)
{
if
(
pResultRowInfo
->
pPosition
==
NULL
)
{
return
TSDB_CODE_QRY_OUT_OF_MEMORY
;
}
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -71,17 +69,17 @@ void cleanupResultRowInfo(SResultRowInfo *pResultRowInfo) {
}
if
(
pResultRowInfo
->
capacity
==
0
)
{
assert
(
pResultRowInfo
->
pResult
==
NULL
);
//
assert(pResultRowInfo->pResult == NULL);
return
;
}
for
(
int32_t
i
=
0
;
i
<
pResultRowInfo
->
size
;
++
i
)
{
if
(
pResultRowInfo
->
pResult
[
i
])
{
taosMemoryFreeClear
(
pResultRowInfo
->
pResult
[
i
]
->
key
);
}
//
if (pResultRowInfo->pResult[i]) {
//
taosMemoryFreeClear(pResultRowInfo->pResult[i]->key);
//
}
}
taosMemoryFreeClear
(
pResultRowInfo
->
p
Result
);
taosMemoryFreeClear
(
pResultRowInfo
->
p
Position
);
}
void
resetResultRowInfo
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRowInfo
*
pResultRowInfo
)
{
...
...
@@ -90,8 +88,8 @@ void resetResultRowInfo(STaskRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRow
}
for
(
int32_t
i
=
0
;
i
<
pResultRowInfo
->
size
;
++
i
)
{
SResultRow
*
pWindowRes
=
pResultRowInfo
->
pResult
[
i
];
clearResultRow
(
pRuntimeEnv
,
pWindowRes
);
//
SResultRow *pWindowRes = pResultRowInfo->pResult[i];
//
clearResultRow(pRuntimeEnv, pWindowRes);
int32_t
groupIndex
=
0
;
int64_t
uid
=
0
;
...
...
@@ -101,14 +99,13 @@ void resetResultRowInfo(STaskRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRow
}
pResultRowInfo
->
size
=
0
;
pResultRowInfo
->
curPos
=
-
1
;
}
int32_t
numOfClosedResultRows
(
SResultRowInfo
*
pResultRowInfo
)
{
int32_t
i
=
0
;
while
(
i
<
pResultRowInfo
->
size
&&
pResultRowInfo
->
pResult
[
i
]
->
closed
)
{
++
i
;
}
//
while (i < pResultRowInfo->size && pResultRowInfo->pResult[i]->closed) {
//
++i;
//
}
return
i
;
}
...
...
@@ -117,21 +114,22 @@ void closeAllResultRows(SResultRowInfo *pResultRowInfo) {
assert
(
pResultRowInfo
->
size
>=
0
&&
pResultRowInfo
->
capacity
>=
pResultRowInfo
->
size
);
for
(
int32_t
i
=
0
;
i
<
pResultRowInfo
->
size
;
++
i
)
{
SResultRow
*
pRow
=
pResultRowInfo
->
pResult
[
i
];
if
(
pRow
->
closed
)
{
continue
;
}
// ASSERT(0);
// SResultRow* pRow = pResultRowInfo->pResult[i];
// if (pRow->closed) {
// continue;
// }
pRow
->
closed
=
true
;
//
pRow->closed = true;
}
}
bool
isResultRowClosed
(
SResultRow
Info
*
pResultRowInfo
,
int32_t
slot
)
{
return
(
getResultRow
(
pResultRowInfo
,
slot
)
->
closed
==
true
);
bool
isResultRowClosed
(
SResultRow
*
pRow
)
{
return
(
pRow
->
closed
==
true
);
}
void
closeResultRow
(
SResultRow
Info
*
pResultRowInfo
,
int32_t
slot
)
{
getResultRow
(
pResultRowInfo
,
slot
)
->
closed
=
true
;
void
closeResultRow
(
SResultRow
*
pResultRow
)
{
pResultRow
->
closed
=
true
;
}
void
clearResultRow
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResultRow
)
{
...
...
@@ -181,29 +179,6 @@ size_t getResultRowSize(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
return
rowSize
;
}
SResultRow
*
getNewResultRow
(
SResultRowPool
*
p
)
{
if
(
p
==
NULL
)
{
return
NULL
;
}
void
*
ptr
=
NULL
;
if
(
p
->
position
.
pos
==
0
)
{
ptr
=
taosMemoryCalloc
(
1
,
p
->
blockSize
);
taosArrayPush
(
p
->
pData
,
&
ptr
);
}
else
{
size_t
last
=
taosArrayGetSize
(
p
->
pData
);
void
**
pBlock
=
taosArrayGet
(
p
->
pData
,
last
-
1
);
ptr
=
((
char
*
)
(
*
pBlock
))
+
p
->
elemSize
*
p
->
position
.
pos
;
}
p
->
position
.
pos
=
(
p
->
position
.
pos
+
1
)
%
p
->
numOfElemPerBlock
;
initResultRow
(
ptr
);
return
ptr
;
}
void
cleanupGroupResInfo
(
SGroupResInfo
*
pGroupResInfo
)
{
assert
(
pGroupResInfo
!=
NULL
);
...
...
@@ -261,8 +236,9 @@ int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo) {
return
(
int32_t
)
taosArrayGetSize
(
pGroupResInfo
->
pRows
);
}
static
int64_t
getNumOfResultWindowRes
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRow
*
pResultRow
,
int32_t
*
rowCellInfoOffset
)
{
static
int64_t
getNumOfResultWindowRes
(
STaskRuntimeEnv
*
pRuntimeEnv
,
SResultRow
Position
*
pos
,
int32_t
*
rowCellInfoOffset
)
{
STaskAttr
*
pQueryAttr
=
pRuntimeEnv
->
pQueryAttr
;
ASSERT
(
0
);
for
(
int32_t
j
=
0
;
j
<
pQueryAttr
->
numOfOutput
;
++
j
)
{
int32_t
functionId
=
0
;
//pQueryAttr->pExpr1[j].base.functionId;
...
...
@@ -305,25 +281,26 @@ static int32_t tableResultComparFn(const void *pLeft, const void *pRight, void *
return
-
1
;
}
ASSERT
(
0
);
STableQueryInfo
**
pList
=
supporter
->
pTableQueryInfo
;
SResultRow
*
pWindowRes1
=
pList
[
left
]
->
resInfo
.
pResult
[
leftPos
];
//
SResultRow* pWindowRes1 = pList[left]->resInfo.pResult[leftPos];
// SResultRow * pWindowRes1 = getResultRow(&(pList[left]->resInfo), leftPos);
TSKEY
leftTimestamp
=
pWindowRes1
->
win
.
skey
;
//
TSKEY leftTimestamp = pWindowRes1->win.skey;
// SResultRowInfo *pWindowResInfo2 = &(pList[right]->resInfo);
// SResultRow * pWindowRes2 = getResultRow(pWindowResInfo2, rightPos);
SResultRow
*
pWindowRes2
=
pList
[
right
]
->
resInfo
.
pResult
[
rightPos
];
TSKEY
rightTimestamp
=
pWindowRes2
->
win
.
skey
;
//
SResultRow* pWindowRes2 = pList[right]->resInfo.pResult[rightPos];
//
TSKEY rightTimestamp = pWindowRes2->win.skey;
if
(
leftTimestamp
==
rightTimestamp
)
{
//
if (leftTimestamp == rightTimestamp) {
return
0
;
}
//
}
if
(
supporter
->
order
==
TSDB_ORDER_ASC
)
{
return
(
leftTimestamp
>
rightTimestamp
)
?
1
:-
1
;
}
else
{
return
(
leftTimestamp
<
rightTimestamp
)
?
1
:-
1
;
}
//
if (supporter->order == TSDB_ORDER_ASC) {
//
return (leftTimestamp > rightTimestamp)? 1:-1;
//
} else {
//
return (leftTimestamp < rightTimestamp)? 1:-1;
//
}
}
int32_t
tsAscOrder
(
const
void
*
p1
,
const
void
*
p2
)
{
...
...
@@ -331,11 +308,12 @@ int32_t tsAscOrder(const void* p1, const void* p2) {
SResultRowCell
*
pc2
=
(
SResultRowCell
*
)
p2
;
if
(
pc1
->
groupId
==
pc2
->
groupId
)
{
if
(
pc1
->
pRow
->
win
.
skey
==
pc2
->
pRow
->
win
.
skey
)
{
return
0
;
}
else
{
return
(
pc1
->
pRow
->
win
.
skey
<
pc2
->
pRow
->
win
.
skey
)
?
-
1
:
1
;
}
ASSERT
(
0
);
// if (pc1->pRow->win.skey == pc2->pRow->win.skey) {
// return 0;
// } else {
// return (pc1->pRow->win.skey < pc2->pRow->win.skey)? -1:1;
// }
}
else
{
return
(
pc1
->
groupId
<
pc2
->
groupId
)
?
-
1
:
1
;
}
...
...
@@ -346,11 +324,12 @@ int32_t tsDescOrder(const void* p1, const void* p2) {
SResultRowCell
*
pc2
=
(
SResultRowCell
*
)
p2
;
if
(
pc1
->
groupId
==
pc2
->
groupId
)
{
if
(
pc1
->
pRow
->
win
.
skey
==
pc2
->
pRow
->
win
.
skey
)
{
return
0
;
}
else
{
return
(
pc1
->
pRow
->
win
.
skey
<
pc2
->
pRow
->
win
.
skey
)
?
1
:-
1
;
}
ASSERT
(
0
);
// if (pc1->pRow->win.skey == pc2->pRow->win.skey) {
// return 0;
// } else {
// return (pc1->pRow->win.skey < pc2->pRow->win.skey)? 1:-1;
// }
}
else
{
return
(
pc1
->
groupId
<
pc2
->
groupId
)
?
-
1
:
1
;
}
...
...
@@ -384,13 +363,13 @@ static int32_t mergeIntoGroupResultImplRv(STaskRuntimeEnv *pRuntimeEnv, SGroupRe
break
;
}
int64_t
num
=
getNumOfResultWindowRes
(
pRuntimeEnv
,
pResultRowCell
->
pRow
,
rowCellInfoOffset
);
int64_t
num
=
getNumOfResultWindowRes
(
pRuntimeEnv
,
&
pResultRowCell
->
pos
,
rowCellInfoOffset
);
if
(
num
<=
0
)
{
continue
;
}
taosArrayPush
(
pGroupResInfo
->
pRows
,
&
pResultRowCell
->
p
Row
);
pResultRowCell
->
pRow
->
numOfRows
=
(
uint32_t
)
num
;
taosArrayPush
(
pGroupResInfo
->
pRows
,
&
pResultRowCell
->
p
os
);
//
pResultRowCell->pRow->numOfRows = (uint32_t) num;
}
return
TSDB_CODE_SUCCESS
;
...
...
@@ -449,9 +428,10 @@ static UNUSED_FUNC int32_t mergeIntoGroupResultImpl(STaskRuntimeEnv *pRuntimeEnv
int32_t
tableIndex
=
tMergeTreeGetChosenIndex
(
pTree
);
SResultRowInfo
*
pWindowResInfo
=
&
pTableQueryInfoList
[
tableIndex
]
->
resInfo
;
SResultRow
*
pWindowRes
=
getResultRow
(
pWindowResInfo
,
cs
.
rowIndex
[
tableIndex
]);
ASSERT
(
0
);
SResultRow
*
pWindowRes
=
NULL
;
//getResultRow(pBuf, pWindowResInfo, cs.rowIndex[tableIndex]);
int64_t
num
=
getNumOfResultWindowRes
(
pRuntimeEnv
,
pWindowRes
,
rowCellInfoOffset
);
int64_t
num
=
0
;
//
getNumOfResultWindowRes(pRuntimeEnv, pWindowRes, rowCellInfoOffset);
if
(
num
<=
0
)
{
cs
.
rowIndex
[
tableIndex
]
+=
1
;
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
9833a6c5
...
...
@@ -426,18 +426,10 @@ static void prepareResultListBuffer(SResultRowInfo* pResultRowInfo, jmp_buf env)
newCapacity
+=
4
;
}
char
*
t
=
taosMemoryRealloc
(
pResultRowInfo
->
pResult
,
(
size_t
)(
newCapacity
*
POINTER_BYTES
));
if
(
t
==
NULL
)
{
longjmp
(
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
pResultRowInfo
->
pPosition
=
taosMemoryRealloc
(
pResultRowInfo
->
pPosition
,
newCapacity
*
sizeof
(
SResultRowPosition
));
pResultRowInfo
->
pResult
=
(
SResultRow
**
)
t
;
int32_t
inc
=
(
int32_t
)
newCapacity
-
pResultRowInfo
->
capacity
;
memset
(
&
pResultRowInfo
->
pResult
[
pResultRowInfo
->
capacity
],
0
,
POINTER_BYTES
*
inc
);
memset
(
&
pResultRowInfo
->
pPosition
[
pResultRowInfo
->
capacity
],
0
,
sizeof
(
SResultRowPosition
));
pResultRowInfo
->
capacity
=
(
int32_t
)
newCapacity
;
}
...
...
@@ -458,9 +450,8 @@ static bool chkResultRowFromKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowInfo* pR
if
(
p1
!=
NULL
)
{
if
(
pResultRowInfo
->
size
==
0
)
{
existed
=
false
;
assert
(
pResultRowInfo
->
curPos
==
-
1
);
}
else
if
(
pResultRowInfo
->
size
==
1
)
{
existed
=
(
pResultRowInfo
->
pResult
[
0
]
==
(
*
p1
));
//
existed = (pResultRowInfo->pResult[0] == (*p1));
}
else
{
// check if current pResultRowInfo contains the existed pResultRow
SET_RES_EXT_WINDOW_KEY
(
pRuntimeEnv
->
keyBuf
,
pData
,
bytes
,
uid
,
pResultRowInfo
);
int64_t
*
index
=
...
...
@@ -479,6 +470,7 @@ static bool chkResultRowFromKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowInfo* pR
return
p1
!=
NULL
;
}
#if 0
static SResultRow* doSetResultOutBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowInfo* pResultRowInfo, int64_t tid,
char* pData, int16_t bytes, bool masterscan, uint64_t tableGroupId) {
bool existed = false;
...
...
@@ -496,16 +488,16 @@ static SResultRow* doSetResultOutBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultR
if (p1 != NULL) {
if (pResultRowInfo->size == 0) {
existed = false;
assert
(
pResultRowInfo
->
curPos
==
-
1
);
//
assert(pResultRowInfo->curPos == -1);
} else if (pResultRowInfo->size == 1) {
existed
=
(
pResultRowInfo
->
pResult
[
0
]
==
(
*
p1
));
pResultRowInfo
->
curPos
=
0
;
//
existed = (pResultRowInfo->pResult[0] == (*p1));
//
pResultRowInfo->curPos = 0;
} else { // check if current pResultRowInfo contains the existed pResultRow
SET_RES_EXT_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tid, pResultRowInfo);
int64_t* index =
taosHashGet(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes));
if (index != NULL) {
pResultRowInfo
->
curPos
=
(
int32_t
)
*
index
;
//
pResultRowInfo->curPos = (int32_t)*index;
existed = true;
} else {
existed = false;
...
...
@@ -555,6 +547,7 @@ static SResultRow* doSetResultOutBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultR
return pResultRowInfo->pResult[pResultRowInfo->curPos];
}
#endif
SResultRow
*
getNewResultRow_rv
(
SDiskbasedBuf
*
pResultBuf
,
int64_t
tableGroupId
,
int32_t
interBufSize
)
{
SFilePage
*
pData
=
NULL
;
...
...
@@ -599,65 +592,75 @@ SResultRow* getNewResultRow_rv(SDiskbasedBuf* pResultBuf, int64_t tableGroupId,
static
SResultRow
*
doSetResultOutBufByKey_rv
(
SDiskbasedBuf
*
pResultBuf
,
SResultRowInfo
*
pResultRowInfo
,
int64_t
tid
,
char
*
pData
,
int16_t
bytes
,
bool
masterscan
,
uint64_t
tableGroupId
,
SExecTaskInfo
*
pTaskInfo
,
bool
isIntervalQuery
,
SAggSupporter
*
pSup
)
{
bool
exist
ed
=
false
;
bool
exist
InCurrentResusltRowInfo
=
false
;
SET_RES_WINDOW_KEY
(
pSup
->
keyBuf
,
pData
,
bytes
,
tableGroupId
);
SResultRow
**
p1
=
(
SResultRow
*
*
)
taosHashGet
(
pSup
->
pResultRowHashTable
,
pSup
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
SResultRow
Position
*
p1
=
(
SResultRowPosition
*
)
taosHashGet
(
pSup
->
pResultRowHashTable
,
pSup
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
));
// in case of repeat scan/reverse scan, no new time window added.
if
(
isIntervalQuery
)
{
if
(
!
masterscan
)
{
// the *p1 may be NULL in case of sliding+offset exists.
return
(
p1
!=
NULL
)
?
*
p1
:
NULL
;
if
(
p1
!=
NULL
)
{
return
getResultRowByPos
(
pResultBuf
,
p1
);
}
else
{
return
NULL
;
}
}
if
(
p1
!=
NULL
)
{
if
(
pResultRowInfo
->
size
==
0
)
{
exist
ed
=
false
;
exist
InCurrentResusltRowInfo
=
false
;
// this time window created by other timestamp that does not belongs to current table.
assert
(
pResultRowInfo
->
curPos
==
-
1
);
}
else
if
(
pResultRowInfo
->
size
==
1
)
{
existed
=
(
pResultRowInfo
->
pResult
[
0
]
==
(
*
p1
)
);
pResultRowInfo
->
curPos
=
0
;
}
else
{
// check if current pResultRowInfo contains the exist
ed
pResultRow
ASSERT
(
0
);
// existInCurrentResusltRowInfo = (pResultRowInfo->pResult[0] == (*p1))
;
}
else
{
// check if current pResultRowInfo contains the exist
InCurrentResusltRowInfo
pResultRow
SET_RES_EXT_WINDOW_KEY
(
pSup
->
keyBuf
,
pData
,
bytes
,
tid
,
pResultRowInfo
);
int64_t
*
index
=
taosHashGet
(
pSup
->
pResultRowListSet
,
pSup
->
keyBuf
,
GET_RES_EXT_WINDOW_KEY_LEN
(
bytes
));
if
(
index
!=
NULL
)
{
pResultRowInfo
->
curPos
=
(
int32_t
)
*
index
;
existed
=
true
;
// TODO check the scan order for current opened time window
// pResultRowInfo->curPos = (int32_t)*index;
existInCurrentResusltRowInfo
=
true
;
}
else
{
exist
ed
=
false
;
exist
InCurrentResusltRowInfo
=
false
;
}
}
}
}
else
{
// In case of group by column query, the required SResultRow object must be exist
ed
in the pResultRowInfo object.
// In case of group by column query, the required SResultRow object must be exist
InCurrentResusltRowInfo
in the pResultRowInfo object.
if
(
p1
!=
NULL
)
{
return
*
p1
;
return
getResultRowByPos
(
pResultBuf
,
p1
)
;
}
}
if
(
!
existed
)
{
prepareResultListBuffer
(
pResultRowInfo
,
pTaskInfo
->
env
);
SResultRow
*
pResult
=
NULL
;
if
(
!
existInCurrentResusltRowInfo
)
{
// 1. close current opened time window
if
(
pResultRowInfo
->
curPos
!=
-
1
)
{
// todo extract function
SResultRowPosition
*
pos
=
&
pResultRowInfo
->
pPosition
[
pResultRowInfo
->
curPos
];
SFilePage
*
pPage
=
getBufPage
(
pResultBuf
,
pos
->
pageId
);
SResultRow
*
pRow
=
(
SResultRow
*
)((
char
*
)
pPage
+
pos
->
offset
);
closeResultRow
(
pRow
);
releaseBufPage
(
pResultBuf
,
pPage
);
}
prepareResultListBuffer
(
pResultRowInfo
,
pTaskInfo
->
env
);
if
(
p1
==
NULL
)
{
pResult
=
getNewResultRow_rv
(
pResultBuf
,
tableGroupId
,
pSup
->
resultRowSize
);
int32_t
ret
=
initResultRow
(
pResult
);
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
initResultRow
(
pResult
);
// add a new result set for a new group
taosHashPut
(
pSup
->
pResultRowHashTable
,
pSup
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
),
&
pResult
,
POINTER_BYTES
);
SResultRowCell
cell
=
{.
groupId
=
tableGroupId
,
.
pRow
=
pResult
};
SResultRowPosition
pos
=
{.
pageId
=
pResult
->
pageId
,
.
offset
=
pResult
->
offset
};
taosHashPut
(
pSup
->
pResultRowHashTable
,
pSup
->
keyBuf
,
GET_RES_WINDOW_KEY_LEN
(
bytes
),
&
pos
,
POINTER_BYTES
);
SResultRowCell
cell
=
{.
groupId
=
tableGroupId
,
.
pos
=
pos
};
taosArrayPush
(
pSup
->
pResultRowArrayList
,
&
cell
);
}
else
{
pResult
=
*
p1
;
pResult
=
getResultRowByPos
(
pResultBuf
,
p1
)
;
}
// 2. set the new time window to be the new active time window
pResultRowInfo
->
curPos
=
pResultRowInfo
->
size
;
pResultRowInfo
->
pPosition
[
pResultRowInfo
->
size
]
=
(
SResultRowPosition
){.
pageId
=
pResult
->
pageId
,
.
offset
=
pResult
->
offset
};
pResultRowInfo
->
pResult
[
pResultRowInfo
->
size
++
]
=
pResult
;
pResultRowInfo
->
pPosition
[
pResultRowInfo
->
size
++
]
=
(
SResultRowPosition
){.
pageId
=
pResult
->
pageId
,
.
offset
=
pResult
->
offset
};
int64_t
index
=
pResultRowInfo
->
curPos
;
SET_RES_EXT_WINDOW_KEY
(
pSup
->
keyBuf
,
pData
,
bytes
,
tid
,
pResultRowInfo
);
...
...
@@ -669,7 +672,7 @@ static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultR
longjmp
(
pTaskInfo
->
env
,
TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW
);
}
return
pResult
RowInfo
->
pResult
[
pResultRowInfo
->
curPos
]
;
return
pResult
;
}
static
void
getInitialStartTimeWindow
(
SInterval
*
pInterval
,
int32_t
precision
,
TSKEY
ts
,
STimeWindow
*
w
,
TSKEY
ekey
,
...
...
@@ -693,7 +696,7 @@ static void getInitialStartTimeWindow(SInterval* pInterval, int32_t precision, T
}
// get the correct time window according to the handled timestamp
static
STimeWindow
getActiveTimeWindow
(
SResultRowInfo
*
pResultRowInfo
,
int64_t
ts
,
SInterval
*
pInterval
,
static
STimeWindow
getActiveTimeWindow
(
S
DiskbasedBuf
*
pBuf
,
S
ResultRowInfo
*
pResultRowInfo
,
int64_t
ts
,
SInterval
*
pInterval
,
int32_t
precision
,
STimeWindow
*
win
)
{
STimeWindow
w
=
{
0
};
...
...
@@ -701,7 +704,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo* pResultRowInfo, int64_t t
getInitialStartTimeWindow
(
pInterval
,
precision
,
ts
,
&
w
,
win
->
ekey
,
true
);
w
.
ekey
=
taosTimeAdd
(
w
.
skey
,
pInterval
->
interval
,
pInterval
->
intervalUnit
,
precision
)
-
1
;
}
else
{
w
=
getResultRow
(
pResultRowInfo
,
pResultRowInfo
->
curPos
)
->
win
;
w
=
getResultRow
(
p
Buf
,
p
ResultRowInfo
,
pResultRowInfo
->
curPos
)
->
win
;
}
if
(
w
.
skey
>
ts
||
w
.
ekey
<
ts
)
{
...
...
@@ -730,7 +733,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo* pResultRowInfo, int64_t t
// get the correct time window according to the handled timestamp
static
STimeWindow
getCurrentActiveTimeWindow
(
SResultRowInfo
*
pResultRowInfo
,
int64_t
ts
,
STaskAttr
*
pQueryAttr
)
{
STimeWindow
w
=
{
0
};
#if 0
if (pResultRowInfo->curPos == -1) { // the first window, from the previous stored value
// getInitialStartTimeWindow(pQueryAttr, ts, &w);
...
...
@@ -742,7 +745,7 @@ static STimeWindow getCurrentActiveTimeWindow(SResultRowInfo* pResultRowInfo, in
w.ekey = w.skey + pQueryAttr->interval.interval - 1;
}
} else {
w
=
getResultRow
(
pResultRowInfo
,
pResultRowInfo
->
curPos
)
->
win
;
w =
pRow
->win;
}
/*
...
...
@@ -752,6 +755,7 @@ static STimeWindow getCurrentActiveTimeWindow(SResultRowInfo* pResultRowInfo, in
if (w.ekey > pQueryAttr->window.ekey && QUERY_IS_ASC_QUERY(pQueryAttr)) {
w.ekey = pQueryAttr->window.ekey;
}
#endif
return
w
;
}
...
...
@@ -816,8 +820,8 @@ static int32_t setResultOutputBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowI
assert
(
win
->
skey
<=
win
->
ekey
);
SDiskbasedBuf
*
pResultBuf
=
pRuntimeEnv
->
pResultBuf
;
SResultRow
*
pResultRow
=
doSetResultOutBufByKey
(
pRuntimeEnv
,
pResultRowInfo
,
tid
,
(
char
*
)
&
win
->
skey
,
TSDB_KEYSIZE
,
masterscan
,
tableGroupId
);
SResultRow
*
pResultRow
=
NULL
;
//
doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, (char*)&win->skey, TSDB_KEYSIZE,
//
masterscan, tableGroupId);
if
(
pResultRow
==
NULL
)
{
*
pResult
=
NULL
;
return
TSDB_CODE_SUCCESS
;
...
...
@@ -909,9 +913,9 @@ static FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_se
return
forwardStep
;
}
static
void
doUpdateResultRowIndex
(
SResultRowInfo
*
pResultRowInfo
,
TSKEY
lastKey
,
bool
ascQuery
,
bool
timeWindowInterpo
)
{
static
void
doUpdateResultRowIndex
(
SResultRowInfo
*
pResultRowInfo
,
TSKEY
lastKey
,
bool
ascQuery
,
bool
timeWindowInterpo
)
{
int64_t
skey
=
TSKEY_INITIAL_VAL
;
#if 0
int32_t i = 0;
for (i = pResultRowInfo->size - 1; i >= 0; --i) {
SResultRow* pResult = pResultRowInfo->pResult[i];
...
...
@@ -963,6 +967,7 @@ static void doUpdateResultRowIndex(SResultRowInfo* pResultRowInfo, TSKEY lastKey
pResultRowInfo->curPos = i + 1; // current not closed result object
}
}
#endif
}
static
void
updateResultRowInfoActiveIndex
(
SResultRowInfo
*
pResultRowInfo
,
const
STimeWindow
*
pWin
,
TSKEY
lastKey
,
...
...
@@ -1253,8 +1258,8 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx,
ASSERT
(
pCtx
[
i
].
input
.
pData
[
j
]
!=
NULL
);
}
}
// setBlockStatisInfo(&pCtx[i], pBlock, pOperator->pExpr[i].base.pColumns);
// setBlockStatisInfo(&pCtx[i], pBlock, pOperator->pExpr[i].base.pColumns);
// uint32_t flag = pOperator->pExpr[i].base.pParam[0].pCol->flag;
// if (TSDB_COL_IS_NORMAL_COL(flag) /*|| (pCtx[i].functionId == FUNCTION_BLKINFO) ||
// (TSDB_COL_IS_TAG(flag) && pOperator->pRuntimeEnv->scanFlag == MERGE_STAGE)*/) {
...
...
@@ -1551,14 +1556,14 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
if
(
pSDataBlock
->
pDataBlock
!=
NULL
)
{
SColumnInfoData
*
pColDataInfo
=
taosArrayGet
(
pSDataBlock
->
pDataBlock
,
0
);
tsCols
=
(
int64_t
*
)
pColDataInfo
->
pData
;
// assert(tsCols[0] == pSDataBlock->info.window.skey &&
//
tsCols[pSDataBlock->info.rows - 1] ==
pSDataBlock->info.window.ekey);
// assert(tsCols[0] == pSDataBlock->info.window.skey &&
tsCols[pSDataBlock->info.rows - 1] ==
// pSDataBlock->info.window.ekey);
}
int32_t
startPos
=
ascScan
?
0
:
(
pSDataBlock
->
info
.
rows
-
1
);
TSKEY
ts
=
getStartTsKey
(
&
pSDataBlock
->
info
.
window
,
tsCols
,
pSDataBlock
->
info
.
rows
,
ascScan
);
STimeWindow
win
=
getActiveTimeWindow
(
pResultRowInfo
,
ts
,
&
pInfo
->
interval
,
pInfo
->
interval
.
precision
,
&
pInfo
->
win
);
STimeWindow
win
=
getActiveTimeWindow
(
p
Info
->
aggSup
.
pResultBuf
,
p
ResultRowInfo
,
ts
,
&
pInfo
->
interval
,
pInfo
->
interval
.
precision
,
&
pInfo
->
win
);
bool
masterScan
=
true
;
SResultRow
*
pResult
=
NULL
;
...
...
@@ -1581,6 +1586,8 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
// prev time window not interpolation yet.
int32_t
curIndex
=
pResultRowInfo
->
curPos
;
#if 0
if (prevIndex != -1 && prevIndex < curIndex && pInfo->timeWindowInterpo) {
for (int32_t j = prevIndex; j < curIndex; ++j) { // previous time window may be all closed already.
SResultRow* pRes = getResultRow(pResultRowInfo, j);
...
...
@@ -1615,6 +1622,7 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe
longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
}
}
#endif
// window start key interpolation
doWindowBorderInterpolation
(
pOperatorInfo
,
pSDataBlock
,
pInfo
->
binfo
.
pCtx
,
pResult
,
&
win
,
startPos
,
forwardStep
,
...
...
@@ -3430,10 +3438,8 @@ void switchCtxOrder(SqlFunctionCtx* pCtx, int32_t numOfOutput) {
}
}
// TODO fix this bug.
int32_t
initResultRow
(
SResultRow
*
pResultRow
)
{
void
initResultRow
(
SResultRow
*
pResultRow
)
{
pResultRow
->
pEntryInfo
=
(
struct
SResultRowEntryInfo
*
)((
char
*
)
pResultRow
+
sizeof
(
SResultRow
));
return
TSDB_CODE_SUCCESS
;
}
/*
...
...
@@ -3449,7 +3455,9 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t
SqlFunctionCtx
*
pCtx
=
pInfo
->
pCtx
;
SSDataBlock
*
pDataBlock
=
pInfo
->
pRes
;
int32_t
*
rowCellInfoOffset
=
pInfo
->
rowCellInfoOffset
;
SResultRowInfo
*
pResultRowInfo
=
&
pInfo
->
resultRowInfo
;
initResultRowInfo
(
pResultRowInfo
,
16
);
int64_t
tid
=
0
;
int64_t
groupId
=
0
;
...
...
@@ -3610,9 +3618,11 @@ void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SD
SFilePage
*
bufPage
=
getBufPage
(
pBuf
,
pPos
->
pageId
);
SResultRow
*
pRow
=
(
SResultRow
*
)((
char
*
)
bufPage
+
pPos
->
offset
);
if
(
!
isResultRowClosed
(
pResultRowInfo
,
i
))
{
continue
;
}
// TODO ignore the close status anyway.
// if (!isResultRowClosed(pRow)) {
// continue;
// }
for
(
int32_t
j
=
0
;
j
<
numOfOutput
;
++
j
)
{
pCtx
[
j
].
resultInfo
=
getResultCell
(
pRow
,
j
,
rowCellInfoOffset
);
...
...
@@ -3622,7 +3632,7 @@ void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SD
continue
;
}
if
(
pCtx
[
j
].
fpSet
.
process
)
{
// TODO set the dummy function.
if
(
pCtx
[
j
].
fpSet
.
process
)
{
// TODO set the dummy function
, to avoid the check for null ptr
.
pCtx
[
j
].
fpSet
.
finalize
(
&
pCtx
[
j
]);
}
...
...
@@ -4132,7 +4142,7 @@ static void updateNumOfRowsInResultRows(SqlFunctionCtx* pCtx, int32_t numOfOutpu
// if (QUERY_IS_INTERVAL_QUERY(pQueryAttr)) {
// return;
// }
#if 0
for (int32_t i = 0; i < pResultRowInfo->size; ++i) {
SResultRow* pResult = pResultRowInfo->pResult[i];
...
...
@@ -4146,6 +4156,8 @@ static void updateNumOfRowsInResultRows(SqlFunctionCtx* pCtx, int32_t numOfOutpu
pResult->numOfRows = (uint16_t)(TMAX(pResult->numOfRows, pCell->numOfRes));
}
}
#endif
}
static
int32_t
compressQueryColData
(
SColumnInfoData
*
pColRes
,
int32_t
numOfRows
,
char
*
data
,
int8_t
compressed
)
{
...
...
@@ -8761,8 +8773,8 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
pExp
->
pExpr
->
_optrRoot
.
pRootNode
=
pTargetNode
->
pExpr
;
pExp
->
base
.
pParam
[
0
].
type
=
FUNC_PARAM_TYPE_COLUMN
;
pExp
->
base
.
pParam
[
0
].
pCol
=
createColumn
(
pTargetNode
->
dataBlockId
,
pTargetNode
->
slotId
,
pType
);
//
pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN;
//
pExp->base.pParam[0].pCol = createColumn(pTargetNode->dataBlockId, pTargetNode->slotId, pType);
}
else
{
ASSERT
(
0
);
}
...
...
source/libs/index/inc/indexFstRegex.h
浏览文件 @
9833a6c5
...
...
@@ -63,9 +63,10 @@ typedef struct {
FstRegex
*
regexCreate
(
const
char
*
str
);
void
regexSetup
(
FstRegex
*
regex
,
uint32_t
size
,
const
char
*
str
);
// uint32_t regexStart()
uint32_t
regexAutomStart
(
FstRegex
*
regex
);
bool
regexAutomIsMatch
(
FstRegex
*
regex
,
uint32_t
state
);
bool
regexAutomCanMatch
(
FstRegex
*
regex
,
uint32_t
state
,
bool
null
);
bool
regexAutomAccept
(
FstRegex
*
regex
,
uint32_t
state
,
uint8_t
byte
,
uint32_t
*
result
);
#ifdef __cplusplus
}
...
...
source/libs/index/inc/indexFstSparse.h
浏览文件 @
9833a6c5
...
...
@@ -23,8 +23,8 @@ extern "C" {
#endif
typedef
struct
FstSparseSet
{
SArray
*
dense
;
SArray
*
sparse
;
uint32_t
*
dense
;
uint32_t
*
sparse
;
int32_t
size
;
}
FstSparseSet
;
...
...
source/libs/index/src/index.c
浏览文件 @
9833a6c5
source/libs/index/src/indexCache.c
浏览文件 @
9833a6c5
source/libs/index/src/indexFstCommon.c
浏览文件 @
9833a6c5
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
YAML:9:25: error: unknown key 'AlignConsecutiveMacros'
* 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
...
...
source/libs/index/src/indexFstRegex.c
浏览文件 @
9833a6c5
...
...
@@ -14,6 +14,7 @@
*/
#include "indexFstRegex.h"
#include "indexFstDfa.h"
#include "indexFstSparse.h"
FstRegex
*
regexCreate
(
const
char
*
str
)
{
...
...
@@ -26,9 +27,35 @@ FstRegex *regexCreate(const char *str) {
memcpy
(
orig
,
str
,
sz
);
regex
->
orig
=
orig
;
// construct insts based on str
SArray
*
insts
=
NULL
;
FstDfaBuilder
*
builder
=
dfaBuilderCreate
(
insts
);
regex
->
dfa
=
dfaBuilderBuild
(
builder
);
return
regex
;
}
void
regexSetup
(
FstRegex
*
regex
,
uint32_t
size
,
const
char
*
str
)
{
// return
// return;
uint32_t
regexAutomStart
(
FstRegex
*
regex
)
{
///// no nothing
return
0
;
}
bool
regexAutomIsMatch
(
FstRegex
*
regex
,
uint32_t
state
)
{
if
(
regex
->
dfa
!=
NULL
&&
dfaIsMatch
(
regex
->
dfa
,
state
))
{
return
true
;
}
else
{
return
false
;
}
}
bool
regexAutomCanMatch
(
FstRegex
*
regex
,
uint32_t
state
,
bool
null
)
{
// make frame happy
return
null
;
}
bool
regexAutomAccept
(
FstRegex
*
regex
,
uint32_t
state
,
uint8_t
byte
,
uint32_t
*
result
)
{
if
(
regex
->
dfa
==
NULL
)
{
return
false
;
}
return
dfaAccept
(
regex
->
dfa
,
state
,
byte
,
result
);
}
source/libs/index/src/indexSparse.c
→
source/libs/index/src/index
Fst
Sparse.c
浏览文件 @
9833a6c5
...
...
@@ -21,47 +21,44 @@ FstSparseSet *sparSetCreate(int32_t sz) {
return
NULL
;
}
ss
->
dense
=
taosArrayInit
(
sz
,
sizeof
(
uint32_t
));
ss
->
sparse
=
taosArrayInit
(
sz
,
sizeof
(
uint32_t
));
ss
->
size
=
sz
;
ss
->
dense
=
(
uint32_t
*
)
taosMemoryCalloc
(
sz
,
sizeof
(
uint32_t
));
ss
->
sparse
=
(
uint32_t
*
)
taosMemoryCalloc
(
sz
,
sizeof
(
uint32_t
));
ss
->
size
=
0
;
return
ss
;
}
void
sparSetDestroy
(
FstSparseSet
*
ss
)
{
if
(
ss
==
NULL
)
{
return
;
}
taos
ArrayDestroy
(
ss
->
dense
);
taos
ArrayDestroy
(
ss
->
sparse
);
taos
MemoryFree
(
ss
->
dense
);
taos
MemoryFree
(
ss
->
sparse
);
taosMemoryFree
(
ss
);
}
uint32_t
sparSetLen
(
FstSparseSet
*
ss
)
{
return
ss
==
NULL
?
0
:
ss
->
size
;
}
uint32_t
sparSetLen
(
FstSparseSet
*
ss
)
{
// Get occupied size
return
ss
==
NULL
?
0
:
ss
->
size
;
}
uint32_t
sparSetAdd
(
FstSparseSet
*
ss
,
uint32_t
ip
)
{
if
(
ss
==
NULL
)
{
return
0
;
}
uint32_t
i
=
ss
->
size
;
taosArraySet
(
ss
->
dense
,
i
,
&
ip
)
;
taosArraySet
(
ss
->
sparse
,
ip
,
&
i
)
;
ss
->
dense
[
i
]
=
ip
;
ss
->
sparse
[
ip
]
=
i
;
ss
->
size
+=
1
;
return
i
;
}
uint32_t
sparSetGet
(
FstSparseSet
*
ss
,
uint32_t
i
)
{
if
(
i
>=
taosArrayGetSize
(
ss
->
dense
))
{
return
0
;
}
uint32_t
*
v
=
taosArrayGet
(
ss
->
dense
,
i
);
return
*
v
;
// check later
return
ss
->
dense
[
i
];
}
bool
sparSetContains
(
FstSparseSet
*
ss
,
uint32_t
ip
)
{
if
(
ip
>=
taosArrayGetSize
(
ss
->
sparse
))
{
return
false
;
}
uint32_t
i
=
*
(
uint32_t
*
)
taosArrayGet
(
ss
->
sparse
,
ip
);
if
(
i
>=
taosArrayGetSize
(
ss
->
dense
))
{
uint32_t
i
=
ss
->
sparse
[
ip
];
if
(
i
<
ss
->
size
&&
ss
->
dense
[
i
]
==
ip
)
{
return
true
;
}
else
{
return
false
;
}
uint32_t
v
=
*
(
uint32_t
*
)
taosArrayGet
(
ss
->
dense
,
i
);
return
v
==
ip
;
}
void
sparSetClear
(
FstSparseSet
*
ss
)
{
if
(
ss
==
NULL
)
{
...
...
source/libs/nodes/inc/nodesUtil.h
浏览文件 @
9833a6c5
...
...
@@ -20,12 +20,16 @@
extern
"C"
{
#endif
#define nodesFatal(param, ...) qFatal("NODES: " param, __VA_ARGS__)
#define nodesError(param, ...) qError("NODES: " param, __VA_ARGS__)
#define nodesWarn(param, ...) qWarn("NODES: " param, __VA_ARGS__)
#define nodesInfo(param, ...) qInfo("NODES: " param, __VA_ARGS__)
#define nodesDebug(param, ...) qDebug("NODES: " param, __VA_ARGS__)
#define nodesTrace(param, ...) qTrace("NODES: " param, __VA_ARGS__)
#define nodesFatal(...) qFatal("NODES: " __VA_ARGS__)
#define nodesError(...) qError("NODES: " __VA_ARGS__)
#define nodesWarn(...) qWarn("NODES: " __VA_ARGS__)
#define nodesInfo(...) qInfo("NODES: " __VA_ARGS__)
#define nodesDebug(...) qDebug("NODES: " __VA_ARGS__)
#define nodesTrace(...) qTrace("NODES: " __VA_ARGS__)
#define NODES_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0)
#define NODES_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0)
#define NODES_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0)
#ifdef __cplusplus
}
...
...
source/libs/nodes/src/nodesToSQLFuncs.c
0 → 100644
浏览文件 @
9833a6c5
/*
* 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 "cmdnodes.h"
#include "nodesUtil.h"
#include "plannodes.h"
#include "querynodes.h"
#include "taos.h"
#include "taoserror.h"
#include "thash.h"
char
*
gOperatorStr
[]
=
{
NULL
,
"+"
,
"-"
,
"*"
,
"/"
,
"%"
,
"&"
,
"|"
,
">"
,
">="
,
"<"
,
"<="
,
"="
,
"<>"
,
"IN"
,
"NOT IN"
,
"LIKE"
,
"NOT LIKE"
,
"MATCH"
,
"NMATCH"
,
"IS NULL"
,
"IS NOT NULL"
,
"IS TRUE"
,
"IS FALSE"
,
"IS UNKNOWN"
,
"IS NOT TRUE"
,
"IS NOT FALSE"
,
"IS NOT UNKNOWN"
};
char
*
gLogicConditionStr
[]
=
{
"AND"
,
"OR"
,
"NOT"
};
int32_t
nodesNodeToSQL
(
SNode
*
pNode
,
char
*
buf
,
int32_t
bufSize
,
int32_t
*
len
)
{
switch
(
pNode
->
type
)
{
case
QUERY_NODE_COLUMN
:
{
SColumnNode
*
colNode
=
(
SColumnNode
*
)
pNode
;
if
(
colNode
->
dbName
[
0
])
{
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
"`%s`."
,
colNode
->
dbName
);
}
if
(
colNode
->
tableAlias
[
0
])
{
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
"`%s`."
,
colNode
->
tableAlias
);
}
else
if
(
colNode
->
tableName
[
0
])
{
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
"`%s`."
,
colNode
->
tableName
);
}
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
"`%s`"
,
colNode
->
colName
);
return
TSDB_CODE_SUCCESS
;
}
case
QUERY_NODE_VALUE
:{
SValueNode
*
colNode
=
(
SValueNode
*
)
pNode
;
char
*
t
=
nodesGetStrValueFromNode
(
colNode
);
if
(
NULL
==
t
)
{
nodesError
(
"fail to get str value from valueNode"
);
NODES_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
"%s"
,
t
);
taosMemoryFree
(
t
);
return
TSDB_CODE_SUCCESS
;
}
case
QUERY_NODE_OPERATOR
:
{
SOperatorNode
*
pOpNode
=
(
SOperatorNode
*
)
pNode
;
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
"("
);
if
(
pOpNode
->
pLeft
)
{
NODES_ERR_RET
(
nodesNodeToSQL
(
pOpNode
->
pLeft
,
buf
,
bufSize
,
len
));
}
if
(
pOpNode
->
opType
>=
(
sizeof
(
gOperatorStr
)
/
sizeof
(
gOperatorStr
[
0
])))
{
nodesError
(
"unknown operation type:%d"
,
pOpNode
->
opType
);
NODES_ERR_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
" %s "
,
gOperatorStr
[
pOpNode
->
opType
]);
if
(
pOpNode
->
pRight
)
{
NODES_ERR_RET
(
nodesNodeToSQL
(
pOpNode
->
pRight
,
buf
,
bufSize
,
len
));
}
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
")"
);
return
TSDB_CODE_SUCCESS
;
}
case
QUERY_NODE_LOGIC_CONDITION
:{
SLogicConditionNode
*
pLogicNode
=
(
SLogicConditionNode
*
)
pNode
;
SNode
*
node
=
NULL
;
bool
first
=
true
;
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
"("
);
FOREACH
(
node
,
pLogicNode
->
pParameterList
)
{
if
(
!
first
)
{
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
" %s "
,
gLogicConditionStr
[
pLogicNode
->
condType
]);
}
NODES_ERR_RET
(
nodesNodeToSQL
(
node
,
buf
,
bufSize
,
len
));
first
=
false
;
}
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
")"
);
return
TSDB_CODE_SUCCESS
;
}
case
QUERY_NODE_FUNCTION
:{
SFunctionNode
*
pFuncNode
=
(
SFunctionNode
*
)
pNode
;
SNode
*
node
=
NULL
;
bool
first
=
true
;
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
"%s("
,
pFuncNode
->
functionName
);
FOREACH
(
node
,
pFuncNode
->
pParameterList
)
{
if
(
!
first
)
{
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
", "
);
}
NODES_ERR_RET
(
nodesNodeToSQL
(
node
,
buf
,
bufSize
,
len
));
first
=
false
;
}
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
")"
);
return
TSDB_CODE_SUCCESS
;
}
case
QUERY_NODE_NODE_LIST
:{
SNodeListNode
*
pListNode
=
(
SNodeListNode
*
)
pNode
;
SNode
*
node
=
NULL
;
bool
first
=
true
;
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
"("
);
FOREACH
(
node
,
pListNode
->
pNodeList
)
{
if
(
!
first
)
{
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
", "
);
}
NODES_ERR_RET
(
nodesNodeToSQL
(
node
,
buf
,
bufSize
,
len
));
first
=
false
;
}
*
len
+=
snprintf
(
buf
+
*
len
,
bufSize
-
*
len
,
")"
);
return
TSDB_CODE_SUCCESS
;
}
default:
break
;
}
nodesError
(
"nodesNodeToSQL unknown node = %s"
,
nodesNodeName
(
pNode
->
type
));
NODES_RET
(
TSDB_CODE_QRY_APP_ERROR
);
}
source/libs/nodes/src/nodesTraverseFuncs.c
浏览文件 @
9833a6c5
...
...
@@ -17,7 +17,8 @@
typedef
enum
ETraversalOrder
{
TRAVERSAL_PREORDER
=
1
,
TRAVERSAL_POSTORDER
TRAVERSAL_INORDER
,
TRAVERSAL_POSTORDER
,
}
ETraversalOrder
;
static
EDealRes
walkList
(
SNodeList
*
pNodeList
,
ETraversalOrder
order
,
FNodeWalker
walker
,
void
*
pContext
);
...
...
source/libs/nodes/src/nodesUtilFuncs.c
浏览文件 @
9833a6c5
...
...
@@ -790,6 +790,71 @@ void* nodesGetValueFromNode(SValueNode *pNode) {
return
NULL
;
}
char
*
nodesGetStrValueFromNode
(
SValueNode
*
pNode
)
{
switch
(
pNode
->
node
.
resType
.
type
)
{
case
TSDB_DATA_TYPE_BOOL
:
{
void
*
buf
=
taosMemoryMalloc
(
MAX_NUM_STR_SIZE
);
if
(
NULL
==
buf
)
{
return
NULL
;
}
sprintf
(
buf
,
"%s"
,
pNode
->
datum
.
b
?
"true"
:
"false"
);
return
buf
;
}
case
TSDB_DATA_TYPE_TINYINT
:
case
TSDB_DATA_TYPE_SMALLINT
:
case
TSDB_DATA_TYPE_INT
:
case
TSDB_DATA_TYPE_BIGINT
:
case
TSDB_DATA_TYPE_TIMESTAMP
:
{
void
*
buf
=
taosMemoryMalloc
(
MAX_NUM_STR_SIZE
);
if
(
NULL
==
buf
)
{
return
NULL
;
}
sprintf
(
buf
,
"%"
PRId64
,
pNode
->
datum
.
i
);
return
buf
;
}
case
TSDB_DATA_TYPE_UTINYINT
:
case
TSDB_DATA_TYPE_USMALLINT
:
case
TSDB_DATA_TYPE_UINT
:
case
TSDB_DATA_TYPE_UBIGINT
:
{
void
*
buf
=
taosMemoryMalloc
(
MAX_NUM_STR_SIZE
);
if
(
NULL
==
buf
)
{
return
NULL
;
}
sprintf
(
buf
,
"%"
PRIu64
,
pNode
->
datum
.
u
);
return
buf
;
}
case
TSDB_DATA_TYPE_FLOAT
:
case
TSDB_DATA_TYPE_DOUBLE
:
{
void
*
buf
=
taosMemoryMalloc
(
MAX_NUM_STR_SIZE
);
if
(
NULL
==
buf
)
{
return
NULL
;
}
sprintf
(
buf
,
"%e"
,
pNode
->
datum
.
d
);
return
buf
;
}
case
TSDB_DATA_TYPE_NCHAR
:
case
TSDB_DATA_TYPE_VARCHAR
:
case
TSDB_DATA_TYPE_VARBINARY
:
{
int32_t
bufSize
=
varDataLen
(
pNode
->
datum
.
p
)
+
2
+
1
;
void
*
buf
=
taosMemoryMalloc
(
bufSize
);
if
(
NULL
==
buf
)
{
return
NULL
;
}
snprintf
(
buf
,
bufSize
,
"'%s'"
,
varDataVal
(
pNode
->
datum
.
p
));
return
buf
;
}
default:
break
;
}
return
NULL
;
}
bool
nodesIsExprNode
(
const
SNode
*
pNode
)
{
ENodeType
type
=
nodeType
(
pNode
);
return
(
QUERY_NODE_COLUMN
==
type
||
QUERY_NODE_VALUE
==
type
||
QUERY_NODE_OPERATOR
==
type
||
QUERY_NODE_FUNCTION
==
type
);
...
...
source/libs/parser/src/parTranslater.c
浏览文件 @
9833a6c5
...
...
@@ -1953,6 +1953,7 @@ static int32_t extractExplainResultSchema(int32_t* numOfCols, SSchema** pSchema)
}
(
*
pSchema
)[
0
].
type
=
TSDB_DATA_TYPE_BINARY
;
(
*
pSchema
)[
0
].
bytes
=
TSDB_EXPLAIN_RESULT_ROW_SIZE
;
strcpy
((
*
pSchema
)[
0
].
name
,
TSDB_EXPLAIN_RESULT_COLUMN_NAME
);
return
TSDB_CODE_SUCCESS
;
}
...
...
source/libs/planner/src/planLogicCreater.c
浏览文件 @
9833a6c5
...
...
@@ -288,7 +288,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect
// set the output
if
(
TSDB_CODE_SUCCESS
==
code
)
{
pJoin
->
node
.
pTargets
=
nodesCloneList
(
pLeft
->
pTargets
);
if
(
NULL
==
pJoin
->
pOnCondition
s
)
{
if
(
NULL
==
pJoin
->
node
.
pTarget
s
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
...
...
source/libs/planner/src/planPhysiCreater.c
浏览文件 @
9833a6c5
...
...
@@ -719,6 +719,11 @@ static int32_t createStreamScanPhysiNodeByExchange(SPhysiPlanContext* pCxt, SExc
if
(
NULL
==
pScan
->
pScanCols
)
{
code
=
TSDB_CODE_OUT_OF_MEMORY
;
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
sortScanCols
(
pScan
->
pScanCols
);
}
if
(
TSDB_CODE_SUCCESS
==
code
)
{
code
=
sortScanCols
(
pScan
->
pScanCols
);
}
...
...
source/libs/qcom/CMakeLists.txt
浏览文件 @
9833a6c5
...
...
@@ -8,7 +8,7 @@ target_include_directories(
target_link_libraries
(
qcom
PRIVATE os util transport
PRIVATE os util transport
nodes
)
if
(
${
BUILD_TEST
}
)
...
...
source/libs/qcom/inc/queryInt.h
浏览文件 @
9833a6c5
...
...
@@ -21,7 +21,6 @@ extern "C" {
#endif
#ifdef __cplusplus
}
#endif
...
...
source/libs/scalar/inc/filterInt.h
浏览文件 @
9833a6c5
...
...
@@ -36,8 +36,6 @@ extern "C" {
#define FILTER_DUMMY_EMPTY_OPTR 127
#define MAX_NUM_STR_SIZE 40
#define FILTER_RM_UNIT_MIN_ROWS 100
enum
{
...
...
source/libs/scalar/src/sclvector.c
浏览文件 @
9833a6c5
...
...
@@ -720,7 +720,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
double
lx
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
i
);
double
rx
=
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
i
);
if
(
compareDoubleVal
(
&
zero
,
&
rx
))
{
if
(
isnan
(
lx
)
||
isinf
(
lx
)
||
isnan
(
rx
)
||
isinf
(
rx
))
{
colDataAppend
(
pOutputCol
,
i
,
NULL
,
true
);
continue
;
}
...
...
@@ -729,7 +729,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
}
}
else
if
(
pLeft
->
numOfRows
==
1
)
{
double
lx
=
getVectorDoubleValueFnLeft
(
pLeftCol
->
pData
,
0
);
if
(
colDataIsNull_f
(
pLeftCol
->
nullbitmap
,
0
))
{
// Set pLeft->numOfRows NULL value
if
(
colDataIsNull_f
(
pLeftCol
->
nullbitmap
,
0
)
||
isnan
(
lx
)
||
isinf
(
lx
)
)
{
// Set pLeft->numOfRows NULL value
// TODO set numOfRows NULL value
}
else
{
for
(;
i
>=
0
&&
i
<
pRight
->
numOfRows
;
i
+=
step
,
output
+=
1
)
{
...
...
@@ -739,7 +739,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
}
double
rx
=
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
i
);
if
(
compareDoubleVal
(
&
zero
,
&
rx
))
{
if
(
isnan
(
rx
)
||
isinf
(
rx
)
||
FLT_EQUAL
(
rx
,
0
))
{
colDataAppend
(
pOutputCol
,
i
,
NULL
,
true
);
continue
;
}
...
...
@@ -749,17 +749,17 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam
}
}
else
if
(
pRight
->
numOfRows
==
1
)
{
double
rx
=
getVectorDoubleValueFnRight
(
pRightCol
->
pData
,
0
);
if
(
colDataIsNull_f
(
pRightCol
->
nullbitmap
,
0
))
{
// Set pLeft->numOfRows NULL value
if
(
colDataIsNull_f
(
pRightCol
->
nullbitmap
,
0
)
||
FLT_EQUAL
(
rx
,
0
)
)
{
// Set pLeft->numOfRows NULL value
// TODO set numOfRows NULL value
}
else
{
for
(;
i
>=
0
&&
i
<
pLeft
->
numOfRows
;
i
+=
step
,
output
+=
1
)
{
if
(
colDataIsNull_f
(
p
Righ
tCol
->
nullbitmap
,
i
))
{
if
(
colDataIsNull_f
(
p
Lef
tCol
->
nullbitmap
,
i
))
{
colDataAppend
(
pOutputCol
,
i
,
NULL
,
true
);
continue
;
}
double
lx
=
getVectorDoubleValueFnLeft
(
p
Righ
tCol
->
pData
,
i
);
if
(
compareDoubleVal
(
&
zero
,
&
lx
))
{
double
lx
=
getVectorDoubleValueFnLeft
(
p
Lef
tCol
->
pData
,
i
);
if
(
isnan
(
lx
)
||
isinf
(
lx
))
{
colDataAppend
(
pOutputCol
,
i
,
NULL
,
true
);
continue
;
}
...
...
source/libs/scheduler/CMakeLists.txt
浏览文件 @
9833a6c5
...
...
@@ -9,7 +9,7 @@ target_include_directories(
target_link_libraries
(
scheduler
PUBLIC os util nodes planner qcom common catalog transport
PUBLIC os util nodes planner qcom common catalog transport
command
)
if
(
${
BUILD_TEST
}
)
...
...
source/libs/scheduler/inc/schedulerInt.h
浏览文件 @
9833a6c5
...
...
@@ -142,7 +142,7 @@ typedef struct SSchTask {
}
SSchTask
;
typedef
struct
SSchJobAttr
{
bool
needFetch
;
EExplainMode
explainMode
;
bool
syncSchedule
;
bool
queryJob
;
bool
needFlowCtrl
;
...
...
source/libs/scheduler/src/scheduler.c
浏览文件 @
9833a6c5
...
...
@@ -19,6 +19,7 @@
#include "tmsg.h"
#include "tref.h"
#include "trpc.h"
#include "command.h"
SSchedulerMgmt
schMgmt
=
{
0
};
...
...
@@ -86,7 +87,7 @@ void schFreeRpcCtx(SRpcCtx *pCtx) {
}
}
void
schFreeTask
(
SSchTask
*
pTask
)
{
void
schFreeTask
(
SSchTask
*
pTask
)
{
if
(
pTask
->
candidateAddrs
)
{
taosArrayDestroy
(
pTask
->
candidateAddrs
);
}
...
...
@@ -126,11 +127,13 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m
return
TSDB_CODE_SUCCESS
;
case
TDMT_VND_QUERY_RSP
:
// query_rsp may be processed later than ready_rsp
if
(
lastMsgType
!=
reqMsgType
&&
-
1
!=
lastMsgType
&&
TDMT_VND_FETCH
!=
lastMsgType
)
{
SCH_TASK_DLOG
(
"rsp msg type mis-match, last sent msgType:%s, rspType:%s"
,
TMSG_INFO
(
lastMsgType
),
TMSG_INFO
(
msgType
));
SCH_TASK_DLOG
(
"rsp msg type mis-match, last sent msgType:%s, rspType:%s"
,
TMSG_INFO
(
lastMsgType
),
TMSG_INFO
(
msgType
));
}
if
(
taskStatus
!=
JOB_TASK_STATUS_EXECUTING
&&
taskStatus
!=
JOB_TASK_STATUS_PARTIAL_SUCCEED
)
{
SCH_TASK_DLOG
(
"rsp msg conflicted with task status, status:%s, rspType:%s"
,
jobTaskStatusStr
(
taskStatus
),
TMSG_INFO
(
msgType
));
SCH_TASK_DLOG
(
"rsp msg conflicted with task status, status:%s, rspType:%s"
,
jobTaskStatusStr
(
taskStatus
),
TMSG_INFO
(
msgType
));
}
SCH_SET_TASK_LASTMSG_TYPE
(
pTask
,
-
1
);
...
...
@@ -138,12 +141,14 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m
case
TDMT_VND_RES_READY_RSP
:
reqMsgType
=
TDMT_VND_QUERY
;
if
(
lastMsgType
!=
reqMsgType
&&
-
1
!=
lastMsgType
)
{
SCH_TASK_ELOG
(
"rsp msg type mis-match, last sent msgType:%s, rspType:%s"
,
(
lastMsgType
>
0
?
TMSG_INFO
(
lastMsgType
)
:
"null"
),
TMSG_INFO
(
msgType
));
SCH_TASK_ELOG
(
"rsp msg type mis-match, last sent msgType:%s, rspType:%s"
,
(
lastMsgType
>
0
?
TMSG_INFO
(
lastMsgType
)
:
"null"
),
TMSG_INFO
(
msgType
));
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
if
(
taskStatus
!=
JOB_TASK_STATUS_EXECUTING
&&
taskStatus
!=
JOB_TASK_STATUS_PARTIAL_SUCCEED
)
{
SCH_TASK_ELOG
(
"rsp msg conflicted with task status, status:%s, rspType:%s"
,
jobTaskStatusStr
(
taskStatus
),
TMSG_INFO
(
msgType
));
SCH_TASK_ELOG
(
"rsp msg conflicted with task status, status:%s, rspType:%s"
,
jobTaskStatusStr
(
taskStatus
),
TMSG_INFO
(
msgType
));
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
...
...
@@ -151,12 +156,14 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m
return
TSDB_CODE_SUCCESS
;
case
TDMT_VND_FETCH_RSP
:
if
(
lastMsgType
!=
reqMsgType
&&
-
1
!=
lastMsgType
)
{
SCH_TASK_ELOG
(
"rsp msg type mis-match, last sent msgType:%s, rspType:%s"
,
TMSG_INFO
(
lastMsgType
),
TMSG_INFO
(
msgType
));
SCH_TASK_ELOG
(
"rsp msg type mis-match, last sent msgType:%s, rspType:%s"
,
TMSG_INFO
(
lastMsgType
),
TMSG_INFO
(
msgType
));
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
if
(
taskStatus
!=
JOB_TASK_STATUS_EXECUTING
&&
taskStatus
!=
JOB_TASK_STATUS_PARTIAL_SUCCEED
)
{
SCH_TASK_ELOG
(
"rsp msg conflicted with task status, status:%s, rspType:%s"
,
jobTaskStatusStr
(
taskStatus
),
TMSG_INFO
(
msgType
));
SCH_TASK_ELOG
(
"rsp msg conflicted with task status, status:%s, rspType:%s"
,
jobTaskStatusStr
(
taskStatus
),
TMSG_INFO
(
msgType
));
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
...
...
@@ -171,12 +178,14 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m
}
if
(
lastMsgType
!=
reqMsgType
)
{
SCH_TASK_ELOG
(
"rsp msg type mis-match, last sent msgType:%s, rspType:%s"
,
TMSG_INFO
(
lastMsgType
),
TMSG_INFO
(
msgType
));
SCH_TASK_ELOG
(
"rsp msg type mis-match, last sent msgType:%s, rspType:%s"
,
TMSG_INFO
(
lastMsgType
),
TMSG_INFO
(
msgType
));
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
if
(
taskStatus
!=
JOB_TASK_STATUS_EXECUTING
&&
taskStatus
!=
JOB_TASK_STATUS_PARTIAL_SUCCEED
)
{
SCH_TASK_ELOG
(
"rsp msg conflicted with task status, status:%s, rspType:%s"
,
jobTaskStatusStr
(
taskStatus
),
TMSG_INFO
(
msgType
));
SCH_TASK_ELOG
(
"rsp msg conflicted with task status, status:%s, rspType:%s"
,
jobTaskStatusStr
(
taskStatus
),
TMSG_INFO
(
msgType
));
SCH_ERR_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
...
...
@@ -654,7 +663,8 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
if
(
SCH_IS_DATA_SRC_TASK
(
pTask
))
{
if
(
pTask
->
tryTimes
>=
SCH_TASK_NUM_OF_EPS
(
&
pTask
->
plan
->
execNode
))
{
*
needRetry
=
false
;
SCH_TASK_DLOG
(
"task no more retry since all ep tried, tryTimes:%d, epNum:%d"
,
pTask
->
tryTimes
,
SCH_TASK_NUM_OF_EPS
(
&
pTask
->
plan
->
execNode
));
SCH_TASK_DLOG
(
"task no more retry since all ep tried, tryTimes:%d, epNum:%d"
,
pTask
->
tryTimes
,
SCH_TASK_NUM_OF_EPS
(
&
pTask
->
plan
->
execNode
));
return
TSDB_CODE_SUCCESS
;
}
}
else
{
...
...
@@ -662,7 +672,8 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
if
((
pTask
->
candidateIdx
+
1
)
>=
candidateNum
)
{
*
needRetry
=
false
;
SCH_TASK_DLOG
(
"task no more retry since all candiates tried, candidateIdx:%d, candidateNum:%d"
,
pTask
->
candidateIdx
,
candidateNum
);
SCH_TASK_DLOG
(
"task no more retry since all candiates tried, candidateIdx:%d, candidateNum:%d"
,
pTask
->
candidateIdx
,
candidateNum
);
return
TSDB_CODE_SUCCESS
;
}
}
...
...
@@ -706,9 +717,8 @@ int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchTrans *trans) {
memcpy
(
&
hb
->
trans
,
trans
,
sizeof
(
*
trans
));
SCH_UNLOCK
(
SCH_WRITE
,
&
hb
->
lock
);
qDebug
(
"hb connection updated, sId:%"
PRIx64
", nodeId:%d, fqdn:%s, port:%d, instance:%p, handle:%p"
,
schMgmt
.
sId
,
epId
->
nodeId
,
epId
->
ep
.
fqdn
,
epId
->
ep
.
port
,
trans
->
transInst
,
trans
->
transHandle
);
qDebug
(
"hb connection updated, sId:%"
PRIx64
", nodeId:%d, fqdn:%s, port:%d, instance:%p, handle:%p"
,
schMgmt
.
sId
,
epId
->
nodeId
,
epId
->
ep
.
fqdn
,
epId
->
ep
.
port
,
trans
->
transInst
,
trans
->
transHandle
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -965,7 +975,8 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
int8_t
status
=
0
;
if
(
schJobNeedToStop
(
pJob
,
&
status
))
{
SCH_TASK_ELOG
(
"rsp not processed cause of job status, job status:%s, rspCode:0x%x"
,
jobTaskStatusStr
(
status
),
rspCode
);
SCH_TASK_ELOG
(
"rsp not processed cause of job status, job status:%s, rspCode:0x%x"
,
jobTaskStatusStr
(
status
),
rspCode
);
SCH_RET
(
atomic_load_32
(
&
pJob
->
errCode
));
}
...
...
@@ -1023,7 +1034,7 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch
SCH_ERR_JRET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
//
SCH_ERR_JRET(schBuildAndSendMsg(pJob, pTask, NULL, TDMT_VND_RES_READY));
//
SCH_ERR_JRET(schBuildAndSendMsg(pJob, pTask, NULL, TDMT_VND_RES_READY));
break
;
}
...
...
@@ -1173,7 +1184,8 @@ int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code) {
SCH_ERR_RET
(
schUpdateHbConnection
(
&
rsp
.
epId
,
&
trans
));
int32_t
taskNum
=
(
int32_t
)
taosArrayGetSize
(
rsp
.
taskStatus
);
qDebug
(
"%d task status in hb rsp, nodeId:%d, fqdn:%s, port:%d"
,
taskNum
,
rsp
.
epId
.
nodeId
,
rsp
.
epId
.
ep
.
fqdn
,
rsp
.
epId
.
ep
.
port
);
qDebug
(
"%d task status in hb rsp, nodeId:%d, fqdn:%s, port:%d"
,
taskNum
,
rsp
.
epId
.
nodeId
,
rsp
.
epId
.
ep
.
fqdn
,
rsp
.
epId
.
ep
.
port
);
for
(
int32_t
i
=
0
;
i
<
taskNum
;
++
i
)
{
STaskStatus
*
taskStatus
=
taosArrayGet
(
rsp
.
taskStatus
,
i
);
...
...
@@ -1188,7 +1200,8 @@ int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code) {
// TODO
SCH_JOB_DLOG
(
"TID:0x%"
PRIx64
" task status in server: %s"
,
taskStatus
->
taskId
,
jobTaskStatusStr
(
taskStatus
->
status
));
SCH_JOB_DLOG
(
"TID:0x%"
PRIx64
" task status in server: %s"
,
taskStatus
->
taskId
,
jobTaskStatusStr
(
taskStatus
->
status
));
schReleaseJob
(
taskStatus
->
refId
);
}
...
...
@@ -1219,7 +1232,6 @@ int32_t schHandleLinkBrokenCallback(void *param, const SDataBuf *pMsg, int32_t c
return
TSDB_CODE_SUCCESS
;
}
int32_t
schGetCallbackFp
(
int32_t
msgType
,
__async_send_cb_fn_t
*
fp
)
{
switch
(
msgType
)
{
case
TDMT_VND_CREATE_TABLE
:
...
...
@@ -1259,7 +1271,7 @@ void schFreeRpcCtxVal(const void *arg) {
return
;
}
SMsgSendInfo
*
pMsgSendInfo
=
(
SMsgSendInfo
*
)
arg
;
SMsgSendInfo
*
pMsgSendInfo
=
(
SMsgSendInfo
*
)
arg
;
taosMemoryFreeClear
(
pMsgSendInfo
->
param
);
taosMemoryFreeClear
(
pMsgSendInfo
);
}
...
...
@@ -1301,10 +1313,9 @@ int32_t schMakeHbCallbackParam(SSchJob *pJob, SSchTask *pTask, void **pParam) {
return
TSDB_CODE_SUCCESS
;
}
int32_t
schMakeBrokenLinkVal
(
SSchJob
*
pJob
,
SSchTask
*
pTask
,
SRpcBrokenlinkVal
*
brokenVal
,
bool
isHb
)
{
int32_t
code
=
0
;
SMsgSendInfo
*
pMsgSendInfo
=
NULL
;
SMsgSendInfo
*
pMsgSendInfo
=
NULL
;
pMsgSendInfo
=
taosMemoryCalloc
(
1
,
sizeof
(
SMsgSendInfo
));
if
(
NULL
==
pMsgSendInfo
)
{
...
...
@@ -1342,7 +1353,7 @@ _return:
int32_t
schMakeQueryRpcCtx
(
SSchJob
*
pJob
,
SSchTask
*
pTask
,
SRpcCtx
*
pCtx
)
{
int32_t
code
=
0
;
SSchTaskCallbackParam
*
param
=
NULL
;
SMsgSendInfo
*
pMsgSendInfo
=
NULL
;
SMsgSendInfo
*
pMsgSendInfo
=
NULL
;
pCtx
->
args
=
taosHashInit
(
1
,
taosGetDefaultHashFunction
(
TSDB_DATA_TYPE_INT
),
false
,
HASH_ENTRY_LOCK
);
if
(
NULL
==
pCtx
->
args
)
{
...
...
@@ -1396,7 +1407,7 @@ _return:
int32_t
schMakeHbRpcCtx
(
SSchJob
*
pJob
,
SSchTask
*
pTask
,
SRpcCtx
*
pCtx
)
{
int32_t
code
=
0
;
SSchHbCallbackParam
*
param
=
NULL
;
SMsgSendInfo
*
pMsgSendInfo
=
NULL
;
SMsgSendInfo
*
pMsgSendInfo
=
NULL
;
SQueryNodeAddr
*
addr
=
taosArrayGet
(
pTask
->
candidateAddrs
,
pTask
->
candidateIdx
);
SQueryNodeEpId
epId
=
{
0
};
...
...
@@ -1450,7 +1461,6 @@ _return:
SCH_RET
(
code
);
}
int32_t
schRegisterHbConnection
(
SSchJob
*
pJob
,
SSchTask
*
pTask
,
SQueryNodeEpId
*
epId
,
bool
*
exist
)
{
int32_t
code
=
0
;
SSchHbTrans
hb
=
{
0
};
...
...
@@ -1475,8 +1485,6 @@ int32_t schRegisterHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *
return
TSDB_CODE_SUCCESS
;
}
int32_t
schCloneCallbackParam
(
SSchCallbackParamHeader
*
pSrc
,
SSchCallbackParamHeader
**
pDst
)
{
if
(
pSrc
->
isHbParam
)
{
SSchHbCallbackParam
*
dst
=
taosMemoryMalloc
(
sizeof
(
SSchHbCallbackParam
));
...
...
@@ -1568,8 +1576,8 @@ _return:
SCH_RET
(
code
);
}
int32_t
schAsyncSendMsg
(
SSchJob
*
pJob
,
SSchTask
*
pTask
,
void
*
transport
,
SEpSet
*
epSet
,
int32_t
msgType
,
void
*
msg
,
uint32_t
msgSize
,
bool
persistHandle
,
SRpcCtx
*
ctx
)
{
int32_t
schAsyncSendMsg
(
SSchJob
*
pJob
,
SSchTask
*
pTask
,
void
*
transport
,
SEpSet
*
epSet
,
int32_t
msgType
,
void
*
msg
,
uint32_t
msgSize
,
bool
persistHandle
,
SRpcCtx
*
ctx
)
{
int32_t
code
=
0
;
SSchTrans
*
trans
=
(
SSchTrans
*
)
transport
;
...
...
@@ -1601,9 +1609,9 @@ int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, void *transport, SEpSet*
pMsgSendInfo
->
msgType
=
msgType
;
pMsgSendInfo
->
fp
=
fp
;
qDebug
(
"start to send %s msg to node[%d,%s,%d], refId:%"
PRIx64
"instance:%p, handle:%p"
,
TMSG_INFO
(
msgType
),
ntohl
(((
SMsgHead
*
)
msg
)
->
vgId
),
epSet
->
eps
[
epSet
->
inUse
].
fqdn
,
epSet
->
eps
[
epSet
->
inUse
].
port
,
pJob
->
refId
,
trans
->
transInst
,
trans
->
transHandle
);
qDebug
(
"start to send %s msg to node[%d,%s,%d], refId:%"
PRIx64
"instance:%p, handle:%p"
,
TMSG_INFO
(
msgType
),
ntohl
(((
SMsgHead
*
)
msg
)
->
vgId
),
epSet
->
eps
[
epSet
->
inUse
].
fqdn
,
epSet
->
eps
[
epSet
->
inUse
].
port
,
pJob
->
refId
,
trans
->
transInst
,
trans
->
transHandle
);
int64_t
transporterId
=
0
;
code
=
asyncSendMsgToServerExt
(
trans
->
transInst
,
epSet
,
&
transporterId
,
pMsgSendInfo
,
persistHandle
,
ctx
);
...
...
@@ -1628,13 +1636,14 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId) {
SSchTrans
trans
=
{
0
};
int32_t
msgType
=
TDMT_VND_QUERY_HEARTBEAT
;
req
.
header
.
vgId
=
htonl
(
nodeEpId
->
nodeId
)
;
req
.
header
.
vgId
=
nodeEpId
->
nodeId
;
req
.
sId
=
schMgmt
.
sId
;
memcpy
(
&
req
.
epId
,
nodeEpId
,
sizeof
(
SQueryNodeEpId
));
SSchHbTrans
*
hb
=
taosHashGet
(
schMgmt
.
hbConnections
,
nodeEpId
,
sizeof
(
SQueryNodeEpId
));
if
(
NULL
==
hb
)
{
qError
(
"taosHashGet hb connection failed, nodeId:%d, fqdn:%s, port:%d"
,
nodeEpId
->
nodeId
,
nodeEpId
->
ep
.
fqdn
,
nodeEpId
->
ep
.
port
);
qError
(
"taosHashGet hb connection failed, nodeId:%d, fqdn:%s, port:%d"
,
nodeEpId
->
nodeId
,
nodeEpId
->
ep
.
fqdn
,
nodeEpId
->
ep
.
port
);
SCH_ERR_RET
(
code
);
}
...
...
@@ -1689,12 +1698,13 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId) {
SEpSet
epSet
=
{.
inUse
=
0
,
.
numOfEps
=
1
};
memcpy
(
&
epSet
.
eps
[
0
],
&
nodeEpId
->
ep
,
sizeof
(
nodeEpId
->
ep
));
qDebug
(
"start to send hb msg, instance:%p, handle:%p, fqdn:%s, port:%d"
,
trans
.
transInst
,
trans
.
transHandle
,
nodeEpId
->
ep
.
fqdn
,
nodeEpId
->
ep
.
port
);
qDebug
(
"start to send hb msg, instance:%p, handle:%p, fqdn:%s, port:%d"
,
trans
.
transInst
,
trans
.
transHandle
,
nodeEpId
->
ep
.
fqdn
,
nodeEpId
->
ep
.
port
);
code
=
asyncSendMsgToServerExt
(
trans
.
transInst
,
&
epSet
,
&
transporterId
,
pMsgSendInfo
,
true
,
&
rpcCtx
);
if
(
code
)
{
qError
(
"fail to send hb msg, instance:%p, handle:%p, fqdn:%s, port:%d, error:%x - %s"
,
trans
.
transInst
,
trans
.
transHandle
,
nodeEpId
->
ep
.
fqdn
,
nodeEpId
->
ep
.
port
,
code
,
tstrerror
(
code
));
qError
(
"fail to send hb msg, instance:%p, handle:%p, fqdn:%s, port:%d, error:%x - %s"
,
trans
.
transInst
,
trans
.
transHandle
,
nodeEpId
->
ep
.
fqdn
,
nodeEpId
->
ep
.
port
,
code
,
tstrerror
(
code
));
SCH_ERR_JRET
(
code
);
}
...
...
@@ -1856,7 +1866,8 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
SCH_SET_TASK_LASTMSG_TYPE
(
pTask
,
msgType
);
SSchTrans
trans
=
{.
transInst
=
pJob
->
transport
,
.
transHandle
=
SCH_GET_TASK_HANDLE
(
pTask
)};
SCH_ERR_JRET
(
schAsyncSendMsg
(
pJob
,
pTask
,
&
trans
,
&
epSet
,
msgType
,
msg
,
msgSize
,
persistHandle
,
(
rpcCtx
.
args
?
&
rpcCtx
:
NULL
)));
SCH_ERR_JRET
(
schAsyncSendMsg
(
pJob
,
pTask
,
&
trans
,
&
epSet
,
msgType
,
msg
,
msgSize
,
persistHandle
,
(
rpcCtx
.
args
?
&
rpcCtx
:
NULL
)));
if
(
msgType
==
TDMT_VND_QUERY
)
{
SCH_ERR_RET
(
schRecordTaskExecNode
(
pJob
,
pTask
,
addr
,
trans
.
transHandle
));
...
...
@@ -2093,6 +2104,7 @@ static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan *pD
SCH_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
pJob
->
attr
.
explainMode
=
pDag
->
explainInfo
.
mode
;
pJob
->
attr
.
syncSchedule
=
syncSchedule
;
pJob
->
transport
=
transport
;
pJob
->
sql
=
sql
;
...
...
@@ -2126,19 +2138,24 @@ static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan *pD
tsem_init
(
&
pJob
->
rspSem
,
0
,
0
);
pJob
->
refId
=
taosAddRef
(
schMgmt
.
jobRef
,
pJob
);
if
(
pJob
->
refId
<
0
)
{
SCH_JOB_ELOG
(
"taos
HashPut
job failed, error:%s"
,
tstrerror
(
terrno
));
int64_t
refId
=
taosAddRef
(
schMgmt
.
jobRef
,
pJob
);
if
(
refId
<
0
)
{
SCH_JOB_ELOG
(
"taos
AddRef
job failed, error:%s"
,
tstrerror
(
terrno
));
SCH_ERR_JRET
(
terrno
);
}
if
(
NULL
==
schAcquireJob
(
refId
))
{
SCH_JOB_ELOG
(
"schAcquireJob job failed, refId:%"
PRIx64
,
refId
);
SCH_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
pJob
->
refId
=
refId
;
SCH_JOB_DLOG
(
"job refId:%"
PRIx64
,
pJob
->
refId
);
pJob
->
status
=
JOB_TASK_STATUS_NOT_START
;
SCH_ERR_JRET
(
schLaunchJob
(
pJob
));
schAcquireJob
(
pJob
->
refId
);
*
job
=
pJob
->
refId
;
if
(
syncSchedule
)
{
...
...
@@ -2158,6 +2175,54 @@ _return:
SCH_RET
(
code
);
}
int32_t
schExecStaticExplain
(
void
*
transport
,
SArray
*
pNodeList
,
SQueryPlan
*
pDag
,
int64_t
*
job
,
const
char
*
sql
,
bool
syncSchedule
)
{
qDebug
(
"QID:0x%"
PRIx64
" job started"
,
pDag
->
queryId
);
int32_t
code
=
0
;
SSchJob
*
pJob
=
taosMemoryCalloc
(
1
,
sizeof
(
SSchJob
));
if
(
NULL
==
pJob
)
{
qError
(
"QID:%"
PRIx64
" calloc %d failed"
,
pDag
->
queryId
,
(
int32_t
)
sizeof
(
SSchJob
));
SCH_ERR_RET
(
TSDB_CODE_QRY_OUT_OF_MEMORY
);
}
pJob
->
sql
=
sql
;
pJob
->
attr
.
queryJob
=
true
;
pJob
->
attr
.
explainMode
=
pDag
->
explainInfo
.
mode
;
pJob
->
queryId
=
pDag
->
queryId
;
pJob
->
subPlans
=
pDag
->
pSubplans
;
SCH_ERR_JRET
(
qExecStaticExplain
(
pDag
,
(
SRetrieveTableRsp
**
)
&
pJob
->
resData
));
int64_t
refId
=
taosAddRef
(
schMgmt
.
jobRef
,
pJob
);
if
(
refId
<
0
)
{
SCH_JOB_ELOG
(
"taosAddRef job failed, error:%s"
,
tstrerror
(
terrno
));
SCH_ERR_JRET
(
terrno
);
}
if
(
NULL
==
schAcquireJob
(
refId
))
{
SCH_JOB_ELOG
(
"schAcquireJob job failed, refId:%"
PRIx64
,
refId
);
SCH_RET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
pJob
->
refId
=
refId
;
SCH_JOB_DLOG
(
"job refId:%"
PRIx64
,
pJob
->
refId
);
pJob
->
status
=
JOB_TASK_STATUS_PARTIAL_SUCCEED
;
*
job
=
pJob
->
refId
;
SCH_JOB_DLOG
(
"job exec done, job status:%s"
,
SCH_GET_JOB_STATUS_STR
(
pJob
));
schReleaseJob
(
pJob
->
refId
);
return
TSDB_CODE_SUCCESS
;
_return:
schFreeJobImpl
(
pJob
);
SCH_RET
(
code
);
}
int32_t
schedulerInit
(
SSchedulerCfg
*
cfg
)
{
if
(
schMgmt
.
jobRef
)
{
qError
(
"scheduler already initialized"
);
...
...
@@ -2206,7 +2271,11 @@ int32_t schedulerExecJob(void *transport, SArray *nodeList, SQueryPlan *pDag, in
SCH_ERR_RET
(
TSDB_CODE_QRY_INVALID_INPUT
);
}
if
(
EXPLAIN_MODE_STATIC
==
pDag
->
explainInfo
.
mode
)
{
SCH_ERR_RET
(
schExecStaticExplain
(
transport
,
nodeList
,
pDag
,
pJob
,
sql
,
true
));
}
else
{
SCH_ERR_RET
(
schExecJobImpl
(
transport
,
nodeList
,
pDag
,
pJob
,
sql
,
true
));
}
SSchJob
*
job
=
schAcquireJob
(
*
pJob
);
...
...
@@ -2389,10 +2458,14 @@ int32_t schedulerFetchRows(int64_t job, void **pData) {
SCH_JOB_DLOG
(
"job already succeed, status:%s"
,
jobTaskStatusStr
(
status
));
goto
_return
;
}
else
if
(
status
==
JOB_TASK_STATUS_PARTIAL_SUCCEED
)
{
if
(
!
(
pJob
->
attr
.
explainMode
==
EXPLAIN_MODE_STATIC
))
{
SCH_ERR_JRET
(
schFetchFromRemote
(
pJob
));
}
tsem_wait
(
&
pJob
->
rspSem
);
}
}
else
{
SCH_JOB_ELOG
(
"job status error for fetch, status:%s"
,
jobTaskStatusStr
(
status
));
SCH_ERR_JRET
(
TSDB_CODE_SCH_STATUS_ERROR
);
}
status
=
SCH_GET_JOB_STATUS
(
pJob
);
...
...
source/libs/stream/src/tstream.c
浏览文件 @
9833a6c5
...
...
@@ -38,7 +38,7 @@ static int32_t streamBuildDispatchMsg(SStreamTask* pTask, SArray* data, SRpcMsg*
req
.
taskId
=
pTask
->
fixedEpDispatcher
.
taskId
;
}
else
if
(
pTask
->
dispatchType
==
TASK_DISPATCH__SHUFFLE
)
{
// TODO
fix tbname issue
// TODO
use general name rule of schemaless
char
ctbName
[
TSDB_TABLE_FNAME_LEN
+
22
];
// all groupId must be the same in an array
SSDataBlock
*
pBlock
=
taosArrayGet
(
data
,
0
);
...
...
source/libs/wal/src/walRead.c
浏览文件 @
9833a6c5
...
...
@@ -30,6 +30,9 @@ SWalReadHandle *walOpenReadHandle(SWal *pWal) {
pRead
->
curFileFirstVer
=
-
1
;
pRead
->
capacity
=
0
;
pRead
->
status
=
0
;
taosThreadMutexInit
(
&
pRead
->
mutex
,
NULL
);
pRead
->
pHead
=
taosMemoryMalloc
(
sizeof
(
SWalHead
));
if
(
pRead
->
pHead
==
NULL
)
{
terrno
=
TSDB_CODE_WAL_OUT_OF_MEMORY
;
...
...
@@ -135,6 +138,22 @@ static int32_t walReadSeekVer(SWalReadHandle *pRead, int64_t ver) {
return
0
;
}
int32_t
walReadWithHandle_s
(
SWalReadHandle
*
pRead
,
int64_t
ver
,
SWalReadHead
**
ppHead
)
{
taosThreadMutexLock
(
&
pRead
->
mutex
);
if
(
walReadWithHandle
(
pRead
,
ver
)
<
0
)
{
taosThreadMutexUnlock
(
&
pRead
->
mutex
);
return
-
1
;
}
*
ppHead
=
taosMemoryMalloc
(
sizeof
(
SWalReadHead
)
+
pRead
->
pHead
->
head
.
len
);
if
(
*
ppHead
==
NULL
)
{
taosThreadMutexUnlock
(
&
pRead
->
mutex
);
return
-
1
;
}
memcpy
(
*
ppHead
,
&
pRead
->
pHead
->
head
,
sizeof
(
SWalReadHead
)
+
pRead
->
pHead
->
head
.
len
);
taosThreadMutexUnlock
(
&
pRead
->
mutex
);
return
0
;
}
int32_t
walReadWithHandle
(
SWalReadHandle
*
pRead
,
int64_t
ver
)
{
int
code
;
// TODO: check wal life
...
...
@@ -145,7 +164,9 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) {
}
}
if
(
!
taosValidFile
(
pRead
->
pReadLogTFile
))
return
-
1
;
if
(
!
taosValidFile
(
pRead
->
pReadLogTFile
))
{
return
-
1
;
}
code
=
taosReadFile
(
pRead
->
pReadLogTFile
,
pRead
->
pHead
,
sizeof
(
SWalHead
));
if
(
code
!=
sizeof
(
SWalHead
))
{
...
...
source/os/src/osProc.c
浏览文件 @
9833a6c5
...
...
@@ -23,6 +23,9 @@ int32_t taosNewProc(char **args) {
int32_t
pid
=
fork
();
if
(
pid
==
0
)
{
args
[
0
]
=
tsProcPath
;
close
(
STDIN_FILENO
);
close
(
STDOUT_FILENO
);
close
(
STDERR_FILENO
);
return
execvp
(
tsProcPath
,
args
);
}
else
{
return
pid
;
...
...
source/util/src/tcompare.c
浏览文件 @
9833a6c5
...
...
@@ -173,6 +173,7 @@ int32_t compareDoubleVal(const void *pLeft, const void *pRight) {
if
(
isnan
(
p2
))
{
return
1
;
}
if
(
FLT_EQUAL
(
p1
,
p2
))
{
return
0
;
}
...
...
source/util/src/tconfig.c
浏览文件 @
9833a6c5
...
...
@@ -590,12 +590,12 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) {
}
int32_t
cfgLoadFromEnvVar
(
SConfig
*
pConfig
)
{
uInfo
(
"load from global env variables
success
"
);
uInfo
(
"load from global env variables
not implemented yet
"
);
return
0
;
}
int32_t
cfgLoadFromEnvFile
(
SConfig
*
pConfig
,
const
char
*
filepath
)
{
uInfo
(
"load from env file
[%s] success"
,
filepath
);
uInfo
(
"load from env file
not implemented yet"
);
return
0
;
}
...
...
@@ -649,11 +649,11 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) {
taosCloseFile
(
&
pFile
);
if
(
line
!=
NULL
)
taosMemoryFreeClear
(
line
);
uInfo
(
"load from cfg file
[%s]
success"
,
filepath
);
uInfo
(
"load from cfg file
%s
success"
,
filepath
);
return
0
;
}
int32_t
cfgLoadFromApollUrl
(
SConfig
*
pConfig
,
const
char
*
url
)
{
uInfo
(
"load from apoll url
[%s] success"
,
url
);
uInfo
(
"load from apoll url
not implemented yet"
);
return
0
;
}
source/util/src/tjson.c
浏览文件 @
9833a6c5
...
...
@@ -121,7 +121,8 @@ int32_t tjsonAddItem(SJson* pJson, FToJson func, const void* pObj) {
return
tjsonAddItemToArray
(
pJson
,
pJobj
);
}
int32_t
tjsonAddArray
(
SJson
*
pJson
,
const
char
*
pName
,
FToJson
func
,
const
void
*
pArray
,
int32_t
itemSize
,
int32_t
num
)
{
int32_t
tjsonAddArray
(
SJson
*
pJson
,
const
char
*
pName
,
FToJson
func
,
const
void
*
pArray
,
int32_t
itemSize
,
int32_t
num
)
{
if
(
num
>
0
)
{
SJson
*
pJsonArray
=
tjsonAddArrayToObject
(
pJson
,
pName
);
if
(
NULL
==
pJsonArray
)
{
...
...
source/util/src/tprocess.c
浏览文件 @
9833a6c5
...
...
@@ -140,14 +140,16 @@ static void taosProcDestroySem(SProcQueue *pQueue) {
pQueue->sem = NULL;
}
}
#endif
static
void
taosProcCleanupQueue
(
SProcQueue
*
pQueue
)
{
#if 0
if (pQueue != NULL) {
taosProcDestroyMutex(pQueue);
taosProcDestroySem(pQueue);
}
}
#endif
}
static
int32_t
taosProcQueuePush
(
SProcQueue
*
pQueue
,
const
char
*
pHead
,
int16_t
rawHeadLen
,
const
char
*
pBody
,
int32_t
rawBodyLen
,
ProcFuncType
ftype
)
{
...
...
@@ -222,7 +224,6 @@ static int32_t taosProcQueuePop(SProcQueue *pQueue, void **ppHead, int16_t *pHea
taosThreadMutexLock
(
&
pQueue
->
mutex
);
if
(
pQueue
->
total
-
pQueue
->
avail
<=
0
)
{
taosThreadMutexUnlock
(
&
pQueue
->
mutex
);
tsem_post
(
&
pQueue
->
sem
);
terrno
=
TSDB_CODE_OUT_OF_SHM_MEM
;
return
0
;
}
...
...
@@ -317,7 +318,7 @@ SProcObj *taosProcInit(const SProcCfg *pCfg) {
pProc
->
pChildQueue
=
taosProcInitQueue
(
pCfg
->
name
,
pCfg
->
isChild
,
(
char
*
)
pCfg
->
shm
.
ptr
+
cstart
,
csize
);
pProc
->
pParentQueue
=
taosProcInitQueue
(
pCfg
->
name
,
pCfg
->
isChild
,
(
char
*
)
pCfg
->
shm
.
ptr
+
pstart
,
psize
);
if
(
pProc
->
pChildQueue
==
NULL
||
pProc
->
pParentQueue
==
NULL
)
{
//
taosProcCleanupQueue(pProc->pChildQueue);
taosProcCleanupQueue
(
pProc
->
pChildQueue
);
taosMemoryFree
(
pProc
);
return
NULL
;
}
...
...
@@ -370,13 +371,13 @@ static void taosProcThreadLoop(SProcObj *pProc) {
freeBodyFp
=
pProc
->
parentFreeBodyFp
;
}
uDebug
(
"proc:%s, start to get msg from queue:%p
, isChild:%d"
,
pProc
->
name
,
pQueue
,
pProc
->
isChild
);
uDebug
(
"proc:%s, start to get msg from queue:%p
"
,
pProc
->
name
,
pQueue
);
while
(
1
)
{
int32_t
numOfMsgs
=
taosProcQueuePop
(
pQueue
,
&
pHead
,
&
headLen
,
&
pBody
,
&
bodyLen
,
&
ftype
,
mallocHeadFp
,
freeHeadFp
,
mallocBodyFp
,
freeBodyFp
);
if
(
numOfMsgs
==
0
)
{
u
Info
(
"proc:%s, get no msg from queue:%p and exit the proc thread"
,
pProc
->
name
,
pQueue
);
u
Debug
(
"proc:%s, get no msg from queue:%p and exit the proc thread"
,
pProc
->
name
,
pQueue
);
break
;
}
else
if
(
numOfMsgs
<
0
)
{
uTrace
(
"proc:%s, get no msg from queue:%p since %s"
,
pProc
->
name
,
pQueue
,
terrstr
());
...
...
@@ -406,7 +407,7 @@ int32_t taosProcRun(SProcObj *pProc) {
static
void
taosProcStop
(
SProcObj
*
pProc
)
{
if
(
!
taosCheckPthreadValid
(
pProc
->
thread
))
return
;
uDebug
(
"proc:%s, start to join thread:%"
PRId64
", isChild:%d"
,
pProc
->
name
,
pProc
->
thread
,
pProc
->
isChil
d
);
uDebug
(
"proc:%s, start to join thread:%"
PRId64
,
pProc
->
name
,
pProc
->
threa
d
);
SProcQueue
*
pQueue
;
if
(
pProc
->
isChild
)
{
pQueue
=
pProc
->
pChildQueue
;
...
...
@@ -421,9 +422,9 @@ void taosProcCleanup(SProcObj *pProc) {
if
(
pProc
!=
NULL
)
{
uDebug
(
"proc:%s, start to clean up"
,
pProc
->
name
);
taosProcStop
(
pProc
);
taosProcCleanupQueue
(
pProc
->
pChildQueue
);
taosProcCleanupQueue
(
pProc
->
pParentQueue
);
uDebug
(
"proc:%s, is cleaned up"
,
pProc
->
name
);
// taosProcCleanupQueue(pProc->pChildQueue);
// taosProcCleanupQueue(pProc->pParentQueue);
taosMemoryFree
(
pProc
);
}
}
...
...
tests/script/tsim/tmq/multiTopic.sim
0 → 100644
浏览文件 @
9833a6c5
此差异已折叠。
点击以展开。
tests/script/tsim/tmq/oneTopic.sim
0 → 100644
浏览文件 @
9833a6c5
此差异已折叠。
点击以展开。
tests/test/c/tmqSim.c
浏览文件 @
9833a6c5
...
...
@@ -226,7 +226,7 @@ void loop_consume(tmq_t* tmq) {
int32_t
totalRows
=
0
;
int32_t
skipLogNum
=
0
;
while
(
running
)
{
tmq_message_t
*
tmqMsg
=
tmq_consumer_poll
(
tmq
,
6
000
);
tmq_message_t
*
tmqMsg
=
tmq_consumer_poll
(
tmq
,
3
000
);
if
(
tmqMsg
)
{
totalMsgs
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录