Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
fab31722
T
TDengine
项目概览
taosdata
/
TDengine
大约 2 年 前同步成功
通知
1192
Star
22018
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fab31722
编写于
1月 21, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'origin/3.0' into feature/warning
上级
2e14f634
36e99c22
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
722 addition
and
214 deletion
+722
-214
include/common/tmsg.h
include/common/tmsg.h
+12
-7
include/libs/executor/executor.h
include/libs/executor/executor.h
+21
-19
include/util/tcoding.h
include/util/tcoding.h
+10
-5
source/client/src/clientEnv.c
source/client/src/clientEnv.c
+4
-0
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+12
-8
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+56
-56
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+1
-1
source/dnode/vnode/inc/tq.h
source/dnode/vnode/inc/tq.h
+8
-42
source/dnode/vnode/inc/vnode.h
source/dnode/vnode/inc/vnode.h
+31
-1
source/dnode/vnode/src/inc/tqInt.h
source/dnode/vnode/src/inc/tqInt.h
+1
-0
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+1
-0
source/dnode/vnode/src/tq/tq.c
source/dnode/vnode/src/tq/tq.c
+38
-34
source/dnode/vnode/src/vnd/vnodeMain.c
source/dnode/vnode/src/vnd/vnodeMain.c
+1
-1
source/dnode/vnode/src/vnd/vnodeWrite.c
source/dnode/vnode/src/vnd/vnodeWrite.c
+3
-1
source/libs/executor/src/executor.c
source/libs/executor/src/executor.c
+56
-10
source/libs/executor/src/executorimpl.c
source/libs/executor/src/executorimpl.c
+19
-3
source/libs/parser/src/dCDAstProcess.c
source/libs/parser/src/dCDAstProcess.c
+2
-3
source/libs/parser/src/parser.c
source/libs/parser/src/parser.c
+16
-10
source/libs/scheduler/src/scheduler.c
source/libs/scheduler/src/scheduler.c
+4
-4
source/libs/tfs/src/tfs.c
source/libs/tfs/src/tfs.c
+6
-2
source/libs/tfs/src/tfsTier.c
source/libs/tfs/src/tfsTier.c
+1
-1
source/libs/tfs/test/tfsTest.cpp
source/libs/tfs/test/tfsTest.cpp
+418
-5
tests/script/sh/massiveTable/setupDnodes.sh
tests/script/sh/massiveTable/setupDnodes.sh
+1
-1
未找到文件。
include/common/tmsg.h
浏览文件 @
fab31722
...
...
@@ -1529,17 +1529,22 @@ typedef struct SMqSetCVgReq {
}
SMqSetCVgReq
;
static
FORCE_INLINE
int32_t
tEncodeSSubQueryMsg
(
void
**
buf
,
const
SSubQueryMsg
*
pMsg
)
{
int32_t
tlen
=
sizeof
(
SSubQueryMsg
)
+
pMsg
->
contentLen
;
if
(
buf
==
NULL
)
return
tlen
;
memcpy
(
*
buf
,
pMsg
,
tlen
);
*
buf
=
POINTER_SHIFT
(
*
buf
,
tlen
);
int32_t
tlen
=
0
;
tlen
+=
taosEncodeFixedU64
(
buf
,
pMsg
->
sId
);
tlen
+=
taosEncodeFixedU64
(
buf
,
pMsg
->
queryId
);
tlen
+=
taosEncodeFixedU64
(
buf
,
pMsg
->
taskId
);
tlen
+=
taosEncodeFixedU32
(
buf
,
pMsg
->
contentLen
);
tlen
+=
taosEncodeBinary
(
buf
,
pMsg
->
msg
,
pMsg
->
contentLen
);
return
tlen
;
}
static
FORCE_INLINE
void
*
tDecodeSSubQueryMsg
(
void
*
buf
,
SSubQueryMsg
*
pMsg
)
{
int32_t
tlen
=
sizeof
(
SSubQueryMsg
)
+
((
SSubQueryMsg
*
)
buf
)
->
contentLen
;
memcpy
(
pMsg
,
buf
,
tlen
);
return
POINTER_SHIFT
(
buf
,
tlen
);
buf
=
taosDecodeFixedU64
(
buf
,
&
pMsg
->
sId
);
buf
=
taosDecodeFixedU64
(
buf
,
&
pMsg
->
queryId
);
buf
=
taosDecodeFixedU64
(
buf
,
&
pMsg
->
taskId
);
buf
=
taosDecodeFixedU32
(
buf
,
&
pMsg
->
contentLen
);
buf
=
taosDecodeBinaryTo
(
buf
,
pMsg
->
msg
,
pMsg
->
contentLen
);
return
buf
;
}
static
FORCE_INLINE
int32_t
tEncodeSMqSetCVgReq
(
void
**
buf
,
const
SMqSetCVgReq
*
pReq
)
{
...
...
include/libs/executor/executor.h
浏览文件 @
fab31722
...
...
@@ -29,21 +29,23 @@ struct SSubplan;
/**
* Create the exec task for streaming mode
* @param pMsg
* @param
pStreamBlock
ReadHandle
* @param
stream
ReadHandle
* @return
*/
qTaskInfo_t
createStreamExecTaskInfo
(
SSubQueryMsg
*
pMsg
,
void
*
pStreamBlockReadHandle
);
qTaskInfo_t
qCreateStreamExecTaskInfo
(
SSubQueryMsg
*
pMsg
,
void
*
streamReadHandle
);
int32_t
qSetStreamInput
(
qTaskInfo_t
tinfo
,
void
*
input
);
/**
* Create the exec task object according to task json
* @param
tsdb
* @param
readHandle
* @param vgId
* @param pTaskInfoMsg
* @param pTaskInfo
* @param qId
* @return
*/
int32_t
qCreateExecTask
(
void
*
tsdb
,
int32_t
vgId
,
struct
SSubplan
*
pPlan
,
qTaskInfo_t
*
pTaskInfo
,
DataSinkHandle
*
handle
);
int32_t
qCreateExecTask
(
void
*
readHandle
,
int32_t
vgId
,
struct
SSubplan
*
pPlan
,
qTaskInfo_t
*
pTaskInfo
,
DataSinkHandle
*
handle
);
/**
* The main task execution function, including query on both table and multiple tables,
...
...
@@ -60,63 +62,63 @@ int32_t qExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds);
* this function will be blocked to wait for the query execution completed or paused,
* in which case enough results have been produced already.
*
* @param
q
info
* @param
t
info
* @return
*/
int32_t
qRetrieveQueryResultInfo
(
qTaskInfo_t
q
info
,
bool
*
buildRes
,
void
*
pRspContext
);
int32_t
qRetrieveQueryResultInfo
(
qTaskInfo_t
t
info
,
bool
*
buildRes
,
void
*
pRspContext
);
/**
*
* Retrieve the actual results to fill the response message payload.
* Note that this function must be executed after qRetrieveQueryResultInfo is invoked.
*
* @param
qinfo q
info object
* @param
tinfo t
info object
* @param pRsp response message
* @param contLen payload length
* @return
*/
//int32_t qDumpRetrieveResult(qTaskInfo_t
q
info, SRetrieveTableRsp** pRsp, int32_t* contLen, bool* continueExec);
//int32_t qDumpRetrieveResult(qTaskInfo_t
t
info, SRetrieveTableRsp** pRsp, int32_t* contLen, bool* continueExec);
/**
* return the transporter context (RPC)
* @param
q
info
* @param
t
info
* @return
*/
void
*
qGetResultRetrieveMsg
(
qTaskInfo_t
q
info
);
void
*
qGetResultRetrieveMsg
(
qTaskInfo_t
t
info
);
/**
* kill the ongoing query and free the query handle and corresponding resources automatically
* @param
q
info qhandle
* @param
t
info qhandle
* @return
*/
int32_t
qKillTask
(
qTaskInfo_t
q
info
);
int32_t
qKillTask
(
qTaskInfo_t
t
info
);
/**
* kill the ongoing query asynchronously
* @param
q
info qhandle
* @param
t
info qhandle
* @return
*/
int32_t
qAsyncKillTask
(
qTaskInfo_t
q
info
);
int32_t
qAsyncKillTask
(
qTaskInfo_t
t
info
);
/**
* return whether query is completed or not
* @param
q
info
* @param
t
info
* @return
*/
int32_t
qIsTaskCompleted
(
qTaskInfo_t
q
info
);
int32_t
qIsTaskCompleted
(
qTaskInfo_t
t
info
);
/**
* destroy query info structure
* @param qHandle
*/
void
qDestroyTask
(
qTaskInfo_t
qHandle
);
void
qDestroyTask
(
qTaskInfo_t
tinfo
);
/**
* Get the queried table uid
* @param qHandle
* @return
*/
int64_t
qGetQueriedTableUid
(
qTaskInfo_t
qHandle
);
int64_t
qGetQueriedTableUid
(
qTaskInfo_t
tinfo
);
/**
* Extract the qualified table id list, and than pass them to the TSDB driver to load the required table data blocks.
...
...
@@ -143,7 +145,7 @@ int32_t qGetQualifiedTableIdList(void* pTableList, const char* tagCond, int32_t
* @param type operation type: ADD|DROP
* @return
*/
int32_t
qUpdateQueriedTableIdList
(
qTaskInfo_t
q
info
,
int64_t
uid
,
int32_t
type
);
int32_t
qUpdateQueriedTableIdList
(
qTaskInfo_t
t
info
,
int64_t
uid
,
int32_t
type
);
//================================================================================================
// query handle management
...
...
include/util/tcoding.h
浏览文件 @
fab31722
...
...
@@ -372,7 +372,7 @@ static FORCE_INLINE void *taosDecodeStringTo(void *buf, char *value) {
}
// ---- binary
static
FORCE_INLINE
int
taosEncodeBinary
(
void
**
buf
,
const
void
*
value
,
int
valueLen
)
{
static
FORCE_INLINE
int
taosEncodeBinary
(
void
**
buf
,
const
void
*
value
,
int
32_t
valueLen
)
{
int
tlen
=
0
;
if
(
buf
!=
NULL
)
{
...
...
@@ -384,14 +384,19 @@ static FORCE_INLINE int taosEncodeBinary(void **buf, const void *value, int valu
return
tlen
;
}
static
FORCE_INLINE
void
*
taosDecodeBinary
(
void
*
buf
,
void
**
value
,
int
valueLen
)
{
uint64_t
size
=
0
;
static
FORCE_INLINE
void
*
taosDecodeBinary
(
void
*
buf
,
void
**
value
,
int32_t
valueLen
)
{
*
value
=
malloc
((
size_t
)
valueLen
);
if
(
*
value
==
NULL
)
return
NULL
;
memcpy
(
*
value
,
buf
,
(
size_t
)
size
);
memcpy
(
*
value
,
buf
,
(
size_t
)
valueLen
);
return
POINTER_SHIFT
(
buf
,
size
);
return
POINTER_SHIFT
(
buf
,
valueLen
);
}
static
FORCE_INLINE
void
*
taosDecodeBinaryTo
(
void
*
buf
,
void
*
value
,
int32_t
valueLen
)
{
memcpy
(
value
,
buf
,
(
size_t
)
valueLen
);
return
POINTER_SHIFT
(
buf
,
valueLen
);
}
#endif
...
...
source/client/src/clientEnv.c
浏览文件 @
fab31722
...
...
@@ -196,6 +196,10 @@ static void doDestroyRequest(void* p) {
doFreeReqResultInfo
(
&
pRequest
->
body
.
resInfo
);
qDestroyQueryDag
(
pRequest
->
body
.
pDag
);
if
(
pRequest
->
body
.
showInfo
.
pArray
!=
NULL
)
{
taosArrayDestroy
(
pRequest
->
body
.
showInfo
.
pArray
);
}
deregisterRequest
(
pRequest
);
tfree
(
pRequest
);
}
...
...
source/client/src/clientMsgHandler.c
浏览文件 @
fab31722
...
...
@@ -145,19 +145,23 @@ int32_t processShowRsp(void* param, const SDataBuf* pMsg, int32_t code) {
}
pSchema
=
pMetaMsg
->
pSchema
;
TAOS_FIELD
*
pFields
=
calloc
(
pMetaMsg
->
numOfColumns
,
sizeof
(
TAOS_FIELD
));
for
(
int32_t
i
=
0
;
i
<
pMetaMsg
->
numOfColumns
;
++
i
)
{
tstrncpy
(
pFields
[
i
].
name
,
pSchema
[
i
].
name
,
tListLen
(
pFields
[
i
].
name
));
pFields
[
i
].
type
=
pSchema
[
i
].
type
;
pFields
[
i
].
bytes
=
pSchema
[
i
].
bytes
;
}
tfree
(
pRequest
->
body
.
resInfo
.
pRspMsg
);
pRequest
->
body
.
resInfo
.
pRspMsg
=
pMsg
->
pData
;
SReqResultInfo
*
pResInfo
=
&
pRequest
->
body
.
resInfo
;
pResInfo
->
fields
=
pFields
;
pResInfo
->
numOfCols
=
pMetaMsg
->
numOfColumns
;
if
(
pResInfo
->
fields
==
NULL
)
{
TAOS_FIELD
*
pFields
=
calloc
(
pMetaMsg
->
numOfColumns
,
sizeof
(
TAOS_FIELD
));
for
(
int32_t
i
=
0
;
i
<
pMetaMsg
->
numOfColumns
;
++
i
)
{
tstrncpy
(
pFields
[
i
].
name
,
pSchema
[
i
].
name
,
tListLen
(
pFields
[
i
].
name
));
pFields
[
i
].
type
=
pSchema
[
i
].
type
;
pFields
[
i
].
bytes
=
pSchema
[
i
].
bytes
;
}
pResInfo
->
fields
=
pFields
;
}
pResInfo
->
numOfCols
=
pMetaMsg
->
numOfColumns
;
pRequest
->
body
.
showInfo
.
execId
=
pShow
->
showId
;
// todo
...
...
source/client/test/clientTests.cpp
浏览文件 @
fab31722
...
...
@@ -452,39 +452,39 @@ TEST(testCase, driverInit_Test) {
//
// taos_close(pConn);
//}
//
//
TEST(testCase, show_table_Test) {
//
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
//
assert(pConn != NULL);
//
//
TAOS_RES* pRes = taos_query(pConn, "show tables");
//
if (taos_errno(pRes) != 0) {
//
printf("failed to show tables, reason:%s\n", taos_errstr(pRes));
//
taos_free_result(pRes);
//
}
//
//
pRes = taos_query(pConn, "show abc1.tables");
//
if (taos_errno(pRes) != 0) {
//
printf("failed to show tables, reason:%s\n", taos_errstr(pRes));
//
taos_free_result(pRes);
//
}
//
//
TAOS_ROW pRow = NULL;
//
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
//
int32_t numOfFields = taos_num_fields(pRes);
//
//
int32_t count = 0;
//
char str[512] = {0};
//
//
while ((pRow = taos_fetch_row(pRes)) != NULL) {
//
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
//
printf("%d: %s\n", ++count, str);
//
}
//
//
taos_free_result(pRes);
//
taos_close(pConn);
//
}
//
TEST
(
testCase
,
show_table_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"show tables"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to show tables, reason:%s
\n
"
,
taos_errstr
(
pRes
));
taos_free_result
(
pRes
);
}
pRes
=
taos_query
(
pConn
,
"show abc1.tables"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to show tables, reason:%s
\n
"
,
taos_errstr
(
pRes
));
taos_free_result
(
pRes
);
}
TAOS_ROW
pRow
=
NULL
;
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
int32_t
count
=
0
;
char
str
[
512
]
=
{
0
};
while
((
pRow
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
int32_t
code
=
taos_print_row
(
str
,
pRow
,
pFields
,
numOfFields
);
printf
(
"%d: %s
\n
"
,
++
count
,
str
);
}
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
//TEST(testCase, drop_stable_Test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
// assert(pConn != NULL);
...
...
@@ -526,29 +526,29 @@ TEST(testCase, driverInit_Test) {
// taosHashCleanup(phash);
//}
//
TEST
(
testCase
,
create_topic_Test
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
assert
(
pConn
!=
NULL
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"error in use db, reason:%s
\n
"
,
taos_errstr
(
pRes
));
}
taos_free_result
(
pRes
);
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
ASSERT_TRUE
(
pFields
==
nullptr
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
ASSERT_EQ
(
numOfFields
,
0
);
taos_free_result
(
pRes
);
char
*
sql
=
"select * from tu"
;
pRes
=
taos_create_topic
(
pConn
,
"test_topic_1"
,
sql
,
strlen
(
sql
));
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
//
TEST(testCase, create_topic_Test) {
//
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
//
assert(pConn != NULL);
//
//
TAOS_RES* pRes = taos_query(pConn, "use abc1");
//
if (taos_errno(pRes) != 0) {
//
printf("error in use db, reason:%s\n", taos_errstr(pRes));
//
}
//
taos_free_result(pRes);
//
//
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
//
ASSERT_TRUE(pFields == nullptr);
//
//
int32_t numOfFields = taos_num_fields(pRes);
//
ASSERT_EQ(numOfFields, 0);
//
//
taos_free_result(pRes);
//
//
char* sql = "select * from tu";
//
pRes = taos_create_topic(pConn, "test_topic_1", sql, strlen(sql));
//
taos_free_result(pRes);
//
taos_close(pConn);
//
}
//TEST(testCase, insert_test) {
// TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
fab31722
...
...
@@ -127,7 +127,7 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
pTopic
->
sql
=
calloc
(
pTopic
->
sqlLen
+
1
,
sizeof
(
char
));
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
SDB_GET_BINARY
(
pRaw
,
dataPos
,
pTopic
->
sql
,
pTopic
->
sqlLen
,
TOPIC_DECODE_OVER
);
SDB_GET_INT32
(
pRaw
,
dataPos
,
&
len
,
TOPIC_DECODE_OVER
);
pTopic
->
logicalPlan
=
calloc
(
len
+
1
,
sizeof
(
char
));
...
...
source/dnode/vnode/inc/tq.h
浏览文件 @
fab31722
...
...
@@ -17,11 +17,12 @@
#define _TD_TQ_H_
#include "common.h"
#include "executor.h"
#include "vnode.h"
#include "mallocator.h"
#include "meta.h"
#include "os.h"
#include "scheduler.h"
#include "executor.h"
#include "taoserror.h"
#include "tlist.h"
#include "tmsg.h"
...
...
@@ -82,27 +83,12 @@ typedef struct STqSubscribeReq {
int64_t
topic
[];
}
STqSubscribeReq
;
typedef
struct
STqSubscribeRsp
{
STqMsgHead
head
;
int64_t
vgId
;
char
ep
[
TSDB_EP_LEN
];
// TSDB_EP_LEN
}
STqSubscribeRsp
;
typedef
struct
STqHeartbeatReq
{
}
STqHeartbeatReq
;
typedef
struct
STqHeartbeatRsp
{
}
STqHeartbeatRsp
;
typedef
struct
STqTopicVhandle
{
int64_t
topicId
;
// executor for filter
void
*
filterExec
;
// callback for mnode
// trigger when vnode list associated topic change
void
*
(
*
mCallback
)(
void
*
,
void
*
);
}
STqTopicVhandle
;
#define TQ_BUFFER_SIZE 8
typedef
struct
STqExec
{
...
...
@@ -163,10 +149,10 @@ typedef struct STqGroup {
}
STqGroup
;
typedef
struct
STqTaskItem
{
int8_t
status
;
int64_t
offset
;
void
*
dst
;
qTaskInfo_t
task
;
int8_t
status
;
int64_t
offset
;
void
*
dst
;
qTaskInfo_t
task
;
}
STqTaskItem
;
// new version
...
...
@@ -199,10 +185,6 @@ typedef struct STqQueryMsg {
struct
STqQueryMsg
*
next
;
}
STqQueryMsg
;
typedef
struct
STqCfg
{
// TODO
}
STqCfg
;
typedef
struct
STqMemRef
{
SMemAllocatorFactory
*
pAllocatorFactory
;
SMemAllocator
*
pAllocator
;
...
...
@@ -299,6 +281,7 @@ typedef struct STQ {
STqMemRef
tqMemRef
;
STqMetaStore
*
tqMeta
;
SWal
*
pWal
;
SMeta
*
pMeta
;
}
STQ
;
typedef
struct
STqMgmt
{
...
...
@@ -313,7 +296,7 @@ int tqInit();
void
tqCleanUp
();
// open in each vnode
STQ
*
tqOpen
(
const
char
*
path
,
SWal
*
pWal
,
STqCfg
*
tqConfig
,
SMemAllocatorFactory
*
allocFac
);
STQ
*
tqOpen
(
const
char
*
path
,
SWal
*
pWal
,
S
Meta
*
pMeta
,
S
TqCfg
*
tqConfig
,
SMemAllocatorFactory
*
allocFac
);
void
tqClose
(
STQ
*
);
// void* will be replace by a msg type
...
...
@@ -337,23 +320,6 @@ int tqSendLaunchQuery(STqMsgItem*, int64_t offset);
int32_t
tqProcessConsumeReq
(
STQ
*
pTq
,
SRpcMsg
*
pMsg
,
SRpcMsg
**
ppRsp
);
int32_t
tqProcessSetConnReq
(
STQ
*
pTq
,
SMqSetCVgReq
*
pReq
);
typedef
struct
STqReadHandle
{
int64_t
ver
;
SSubmitMsg
*
pMsg
;
SSubmitBlk
*
pBlock
;
SSubmitMsgIter
msgIter
;
SSubmitBlkIter
blkIter
;
SMeta
*
pMeta
;
SArray
*
pColumnIdList
;
}
STqReadHandle
;
STqReadHandle
*
tqInitSubmitMsgScanner
(
SMeta
*
pMeta
,
SArray
*
pColumnIdList
);
void
tqReadHandleSetMsg
(
STqReadHandle
*
pHandle
,
SSubmitMsg
*
pMsg
,
int64_t
ver
);
bool
tqNextDataBlock
(
STqReadHandle
*
pHandle
);
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
);
// return SArray<SColumnInfoData>
SArray
*
tqRetrieveDataBlock
(
STqReadHandle
*
pHandle
);
#ifdef __cplusplus
}
#endif
...
...
source/dnode/vnode/inc/vnode.h
浏览文件 @
fab31722
...
...
@@ -22,7 +22,6 @@
#include "meta.h"
#include "tarray.h"
#include "tfs.h"
#include "tq.h"
#include "tsdb.h"
#include "wal.h"
...
...
@@ -35,6 +34,12 @@ typedef struct SVnode SVnode;
typedef
struct
SDnode
SDnode
;
typedef
int32_t
(
*
PutReqToVQueryQFp
)(
SDnode
*
pDnode
,
struct
SRpcMsg
*
pReq
);
typedef
struct
STqCfg
{
// TODO
int32_t
reserved
;
}
STqCfg
;
typedef
struct
SVnodeCfg
{
int32_t
vgId
;
SDnode
*
pDnode
;
...
...
@@ -61,6 +66,16 @@ typedef struct {
PutReqToVQueryQFp
putReqToVQueryQFp
;
}
SVnodeOpt
;
typedef
struct
STqReadHandle
{
int64_t
ver
;
SSubmitMsg
*
pMsg
;
SSubmitBlk
*
pBlock
;
SSubmitMsgIter
msgIter
;
SSubmitBlkIter
blkIter
;
SMeta
*
pMeta
;
SArray
*
pColumnIdList
;
}
STqReadHandle
;
/* ------------------------ SVnode ------------------------ */
/**
* @brief Initialize the vnode module
...
...
@@ -180,6 +195,21 @@ int32_t vnodeCompact(SVnode *pVnode);
int32_t
vnodeSync
(
SVnode
*
pVnode
);
int32_t
vnodeGetLoad
(
SVnode
*
pVnode
,
SVnodeLoad
*
pLoad
);
/* ------------------------- TQ QUERY -------------------------- */
STqReadHandle
*
tqInitSubmitMsgScanner
(
SMeta
*
pMeta
);
static
FORCE_INLINE
void
tqReadHandleSetColIdList
(
STqReadHandle
*
pReadHandle
,
SArray
*
pColumnIdList
)
{
pReadHandle
->
pColumnIdList
=
pColumnIdList
;
}
void
tqReadHandleSetMsg
(
STqReadHandle
*
pHandle
,
SSubmitMsg
*
pMsg
,
int64_t
ver
);
bool
tqNextDataBlock
(
STqReadHandle
*
pHandle
);
int
tqRetrieveDataBlockInfo
(
STqReadHandle
*
pHandle
,
SDataBlockInfo
*
pBlockInfo
);
// return SArray<SColumnInfoData>
SArray
*
tqRetrieveDataBlock
(
STqReadHandle
*
pHandle
);
#ifdef __cplusplus
}
#endif
...
...
source/dnode/vnode/src/inc/tqInt.h
浏览文件 @
fab31722
...
...
@@ -17,6 +17,7 @@
#define _TD_TQ_INT_H_
#include "tq.h"
#include "meta.h"
#include "tlog.h"
#include "trpc.h"
#ifdef __cplusplus
...
...
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
fab31722
...
...
@@ -24,6 +24,7 @@
#include "tlockfree.h"
#include "tmacro.h"
#include "wal.h"
#include "tq.h"
#include "vnode.h"
...
...
source/dnode/vnode/src/tq/tq.c
浏览文件 @
fab31722
...
...
@@ -50,7 +50,7 @@ void tqCleanUp() {
taosTmrCleanUp
(
tqMgmt
.
timer
);
}
STQ
*
tqOpen
(
const
char
*
path
,
SWal
*
pWal
,
STqCfg
*
tqConfig
,
SMemAllocatorFactory
*
allocFac
)
{
STQ
*
tqOpen
(
const
char
*
path
,
SWal
*
pWal
,
S
Meta
*
pMeta
,
S
TqCfg
*
tqConfig
,
SMemAllocatorFactory
*
allocFac
)
{
STQ
*
pTq
=
malloc
(
sizeof
(
STQ
));
if
(
pTq
==
NULL
)
{
terrno
=
TSDB_CODE_TQ_OUT_OF_MEMORY
;
...
...
@@ -58,6 +58,8 @@ STQ* tqOpen(const char* path, SWal* pWal, STqCfg* tqConfig, SMemAllocatorFactory
}
pTq
->
path
=
strdup
(
path
);
pTq
->
tqConfig
=
tqConfig
;
pTq
->
pWal
=
pWal
;
pTq
->
pMeta
=
pMeta
;
#if 0
pTq->tqMemRef.pAllocatorFactory = allocFac;
pTq->tqMemRef.pAllocator = allocFac->create(allocFac);
...
...
@@ -610,44 +612,52 @@ int32_t tqProcessConsumeReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg** ppRsp) {
SMqCVConsumeReq
*
pReq
=
pMsg
->
pCont
;
int64_t
reqId
=
pReq
->
reqId
;
int64_t
consumerId
=
pReq
->
consumerId
;
int64_t
offset
=
pReq
->
offset
;
int64_t
reqOffset
=
pReq
->
offset
;
int64_t
fetchOffset
=
reqOffset
;
int64_t
blockingTime
=
pReq
->
blockingTime
;
STqConsumerHandle
*
pConsumer
=
tqHandleGet
(
pTq
->
tqMeta
,
consumerId
);
int
sz
=
taosArrayGetSize
(
pConsumer
->
topics
);
for
(
int
i
=
0
;
i
<
sz
;
i
++
)
{
STqTopicHandle
*
p
Handle
=
taosArrayGet
(
pConsumer
->
topics
,
i
);
STqTopicHandle
*
p
Topic
=
taosArrayGet
(
pConsumer
->
topics
,
i
);
int8_t
pos
=
o
ffset
%
TQ_BUFFER_SIZE
;
int8_t
old
=
atomic_val_compare_exchange_8
(
&
p
Handle
->
buffer
.
output
[
pos
].
status
,
0
,
1
);
int8_t
pos
=
fetchO
ffset
%
TQ_BUFFER_SIZE
;
int8_t
old
=
atomic_val_compare_exchange_8
(
&
p
Topic
->
buffer
.
output
[
pos
].
status
,
0
,
1
);
if
(
old
==
1
)
{
// do nothing
continue
;
}
if
(
walReadWithHandle
(
p
Handle
->
pReadhandle
,
o
ffset
)
<
0
)
{
// TODO
if
(
walReadWithHandle
(
p
Topic
->
pReadhandle
,
fetchO
ffset
)
<
0
)
{
return
-
1
;
}
SWalHead
*
pHead
=
p
Handle
->
pReadhandle
->
pHead
;
while
(
pHead
->
head
.
msgType
!=
TDMT_VND_SUBMIT
)
{
SWalHead
*
pHead
=
p
Topic
->
pReadhandle
->
pHead
;
while
(
1
)
{
// read until find TDMT_VND_SUBMIT
if
(
walReadWithHandle
(
pTopic
->
pReadhandle
,
fetchOffset
)
<
0
)
{
return
-
1
;
}
}
SSubmitMsg
*
pCont
=
(
SSubmitMsg
*
)
&
pHead
->
head
.
body
;
void
*
task
=
pTopic
->
buffer
.
output
[
pos
].
task
;
/*SSubQueryMsg* pQueryMsg = pHandle->buffer.output[pos].pMsg;*/
qSetStreamInput
(
task
,
pCont
);
SSDataBlock
*
pDataBlock
;
uint64_t
ts
;
if
(
qExecTask
(
task
,
&
pDataBlock
,
&
ts
)
<
0
)
{
}
// TODO: launch query and get output data
void
*
outputData
;
pHandle
->
buffer
.
output
[
pos
].
dst
=
outputData
;
if
(
pHandle
->
buffer
.
firstOffset
==
-
1
||
pReq
->
offset
<
pHandle
->
buffer
.
firstOffset
)
{
pHandle
->
buffer
.
firstOffset
=
pReq
->
offset
;
pTopic
->
buffer
.
output
[
pos
].
dst
=
pDataBlock
;
if
(
pTopic
->
buffer
.
firstOffset
==
-
1
||
pReq
->
offset
<
pTopic
->
buffer
.
firstOffset
)
{
pTopic
->
buffer
.
firstOffset
=
pReq
->
offset
;
}
if
(
p
Handle
->
buffer
.
lastOffset
==
-
1
||
pReq
->
offset
>
p
Handle
->
buffer
.
lastOffset
)
{
p
Handle
->
buffer
.
lastOffset
=
pReq
->
offset
;
if
(
p
Topic
->
buffer
.
lastOffset
==
-
1
||
pReq
->
offset
>
p
Topic
->
buffer
.
lastOffset
)
{
p
Topic
->
buffer
.
lastOffset
=
pReq
->
offset
;
}
atomic_store_8
(
&
p
Handle
->
buffer
.
output
[
pos
].
status
,
1
);
atomic_store_8
(
&
p
Topic
->
buffer
.
output
[
pos
].
status
,
1
);
// put output into rsp
}
...
...
@@ -674,29 +684,23 @@ int32_t tqProcessSetConnReq(STQ* pTq, SMqSetCVgReq* pReq) {
strcpy
(
pTopic
->
sql
,
pReq
->
sql
);
strcpy
(
pTopic
->
logicalPlan
,
pReq
->
logicalPlan
);
strcpy
(
pTopic
->
physicalPlan
,
pReq
->
physicalPlan
);
SArray
*
pArray
;
//TODO: deserialize to SQueryDag
SQueryDag
*
pDag
;
// convert to task
if
(
schedulerConvertDagToTaskList
(
pDag
,
&
pArray
)
<
0
)
{
// TODO: handle error
}
STaskInfo
*
pInfo
=
taosArrayGet
(
pArray
,
0
);
SArray
*
pTasks
;
schedulerCopyTask
(
pInfo
,
&
pTasks
,
TQ_BUFFER_SIZE
);
pTopic
->
buffer
.
firstOffset
=
-
1
;
pTopic
->
buffer
.
lastOffset
=
-
1
;
pTopic
->
pReadhandle
=
walOpenReadHandle
(
pTq
->
pWal
);
if
(
pTopic
->
pReadhandle
==
NULL
)
{
}
for
(
int
i
=
0
;
i
<
TQ_BUFFER_SIZE
;
i
++
)
{
SSubQueryMsg
*
pMsg
=
taosArrayGet
(
pTasks
,
i
);
pTopic
->
buffer
.
output
[
i
].
status
=
0
;
pTopic
->
buffer
.
output
[
i
].
task
=
createStreamExecTaskInfo
(
pMsg
,
NULL
);
STqReadHandle
*
pReadHandle
=
tqInitSubmitMsgScanner
(
pTq
->
pMeta
);
pTopic
->
buffer
.
output
[
i
].
task
=
qCreateStreamExecTaskInfo
(
&
pReq
->
msg
,
pReadHandle
);
}
pTopic
->
pReadhandle
=
walOpenReadHandle
(
pTq
->
pWal
);
// write mq meta
return
0
;
}
STqReadHandle
*
tqInitSubmitMsgScanner
(
SMeta
*
pMeta
,
SArray
*
pColumnIdList
)
{
STqReadHandle
*
tqInitSubmitMsgScanner
(
SMeta
*
pMeta
)
{
STqReadHandle
*
pReadHandle
=
malloc
(
sizeof
(
STqReadHandle
));
if
(
pReadHandle
==
NULL
)
{
return
NULL
;
...
...
@@ -704,7 +708,7 @@ STqReadHandle* tqInitSubmitMsgScanner(SMeta* pMeta, SArray* pColumnIdList) {
pReadHandle
->
pMeta
=
pMeta
;
pReadHandle
->
pMsg
=
NULL
;
pReadHandle
->
ver
=
-
1
;
pReadHandle
->
pColumnIdList
=
pColumnIdList
;
pReadHandle
->
pColumnIdList
=
NULL
;
return
NULL
;
}
...
...
source/dnode/vnode/src/vnd/vnodeMain.c
浏览文件 @
fab31722
...
...
@@ -127,7 +127,7 @@ static int vnodeOpenImpl(SVnode *pVnode) {
// Open TQ
sprintf
(
dir
,
"%s/tq"
,
pVnode
->
path
);
pVnode
->
pTq
=
tqOpen
(
dir
,
pVnode
->
pWal
,
&
(
pVnode
->
config
.
tqCfg
),
vBufPoolGetMAF
(
pVnode
));
pVnode
->
pTq
=
tqOpen
(
dir
,
pVnode
->
pWal
,
pVnode
->
pMeta
,
&
(
pVnode
->
config
.
tqCfg
),
vBufPoolGetMAF
(
pVnode
));
if
(
pVnode
->
pTq
==
NULL
)
{
// TODO: handle error
return
-
1
;
...
...
source/dnode/vnode/src/vnd/vnodeWrite.c
浏览文件 @
fab31722
...
...
@@ -83,8 +83,8 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
SVCreateTbReq
*
pCreateTbReq
=
taosArrayGet
(
vCreateTbBatchReq
.
pArray
,
i
);
if
(
metaCreateTable
(
pVnode
->
pMeta
,
pCreateTbReq
)
<
0
)
{
// TODO: handle error
vError
(
"vgId:%d, failed to create table: %s"
,
pVnode
->
vgId
,
pCreateTbReq
->
name
);
}
vTrace
(
"vgId:%d process create table %s"
,
pVnode
->
vgId
,
pCreateTbReq
->
name
);
free
(
pCreateTbReq
->
name
);
if
(
pCreateTbReq
->
type
==
TD_SUPER_TABLE
)
{
free
(
pCreateTbReq
->
stbCfg
.
pSchema
);
...
...
@@ -95,6 +95,8 @@ int vnodeApplyWMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
free
(
pCreateTbReq
->
ntbCfg
.
pSchema
);
}
}
vInfo
(
"vgId:%d process create %"
PRIzu
" tables"
,
pVnode
->
vgId
,
taosArrayGetSize
(
vCreateTbBatchReq
.
pArray
));
taosArrayDestroy
(
vCreateTbBatchReq
.
pArray
);
break
;
...
...
source/libs/executor/src/executor.c
浏览文件 @
fab31722
...
...
@@ -13,29 +13,75 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "planner.h"
#include "executor.h"
#include "tq.h"
#include "executorimpl.h"
#include "planner.h"
static
int32_t
doSetStreamBlock
(
SOperatorInfo
*
pOperator
,
void
*
input
,
uint64_t
reqId
)
{
ASSERT
(
pOperator
!=
NULL
);
if
(
pOperator
->
operatorType
!=
OP_StreamScan
)
{
if
(
pOperator
->
numOfDownstream
==
0
)
{
qError
(
"failed to find stream scan operator to set the input data block, reqId:0x%"
PRIx64
,
reqId
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
if
(
pOperator
->
numOfDownstream
>
1
)
{
// not handle this in join query
qError
(
"join not supported for stream block scan, reqId:0x%"
PRIx64
,
reqId
);
return
TSDB_CODE_QRY_APP_ERROR
;
}
return
doSetStreamBlock
(
pOperator
->
pDownstream
[
0
],
input
,
reqId
);
}
else
{
SStreamBlockScanInfo
*
pInfo
=
pOperator
->
info
;
tqReadHandleSetMsg
(
pInfo
->
readerHandle
,
input
,
0
);
return
TSDB_CODE_SUCCESS
;
}
}
int32_t
qSetStreamInput
(
qTaskInfo_t
tinfo
,
void
*
input
)
{
if
(
tinfo
==
NULL
)
{
return
TSDB_CODE_QRY_APP_ERROR
;
}
if
(
input
==
NULL
)
{
return
TSDB_CODE_SUCCESS
;
}
SExecTaskInfo
*
pTaskInfo
=
(
SExecTaskInfo
*
)
tinfo
;
int32_t
code
=
doSetStreamBlock
(
pTaskInfo
->
pRoot
,
input
,
GET_TASKID
(
pTaskInfo
));
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
qError
(
"failed to set the stream block data, reqId:0x%"
PRIx64
,
GET_TASKID
(
pTaskInfo
));
}
else
{
qDebug
(
"set the stream block successfully, reqId:0x%"
PRIx64
,
GET_TASKID
(
pTaskInfo
));
}
return
code
;
}
qTaskInfo_t
createStreamExecTaskInfo
(
SSubQueryMsg
*
pMsg
,
void
*
pStreamBlock
ReadHandle
)
{
if
(
pMsg
==
NULL
||
pStreamBlock
ReadHandle
==
NULL
)
{
qTaskInfo_t
qCreateStreamExecTaskInfo
(
SSubQueryMsg
*
pMsg
,
void
*
stream
ReadHandle
)
{
if
(
pMsg
==
NULL
||
stream
ReadHandle
==
NULL
)
{
return
NULL
;
}
// print those info into log
pMsg
->
sId
=
be64toh
(
pMsg
->
sId
);
pMsg
->
queryId
=
be64toh
(
pMsg
->
queryId
);
pMsg
->
taskId
=
be64toh
(
pMsg
->
taskId
);
pMsg
->
contentLen
=
ntohl
(
pMsg
->
contentLen
);
#if 0
pMsg->sId = pMsg->sId;
pMsg->queryId = pMsg->queryId;
pMsg->taskId = pMsg->taskId;
pMsg->contentLen = pMsg->contentLen;
#endif
struct
SSubplan
*
plan
=
NULL
;
int32_t
code
=
qStringToSubplan
(
pMsg
->
msg
,
&
plan
);
struct
SSubplan
*
plan
=
NULL
;
int32_t
code
=
qStringToSubplan
(
pMsg
->
msg
,
&
plan
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
code
;
return
NULL
;
}
qTaskInfo_t
pTaskInfo
=
NULL
;
code
=
qCreateExecTask
(
pStreamBlock
ReadHandle
,
0
,
plan
,
&
pTaskInfo
,
NULL
);
code
=
qCreateExecTask
(
stream
ReadHandle
,
0
,
plan
,
&
pTaskInfo
,
NULL
);
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
// TODO: destroy SSubplan & pTaskInfo
terrno
=
code
;
...
...
source/libs/executor/src/executorimpl.c
浏览文件 @
fab31722
...
...
@@ -27,6 +27,7 @@
#include "thash.h"
#include "ttypes.h"
#include "query.h"
#include "vnode.h"
#include "tsdb.h"
#define IS_MAIN_SCAN(runtime) ((runtime)->scanFlag == MAIN_SCAN)
...
...
@@ -5407,7 +5408,7 @@ SOperatorInfo* createTableBlockInfoScanOperator(void* pTsdbReadHandle, STaskRunt
return
pOperator
;
}
SOperatorInfo
*
createStream
BlockScanOperatorInfo
(
void
*
pStreamBlockHandle
,
int32_t
numOfOutput
,
SExecTaskInfo
*
pTaskInfo
)
{
SOperatorInfo
*
createStream
ScanOperatorInfo
(
void
*
streamReadHandle
,
SArray
*
pExprInfo
,
SExecTaskInfo
*
pTaskInfo
)
{
SStreamBlockScanInfo
*
pInfo
=
calloc
(
1
,
sizeof
(
SStreamBlockScanInfo
));
SOperatorInfo
*
pOperator
=
calloc
(
1
,
sizeof
(
SOperatorInfo
));
if
(
pInfo
==
NULL
||
pOperator
==
NULL
)
{
...
...
@@ -5417,16 +5418,28 @@ SOperatorInfo* createStreamBlockScanOperatorInfo(void *pStreamBlockHandle, int32
return
NULL
;
}
pInfo
->
readerHandle
=
pStreamBlockHandle
;
int32_t
numOfOutput
=
(
int32_t
)
taosArrayGetSize
(
pExprInfo
);
SArray
*
pColList
=
taosArrayInit
(
numOfOutput
,
sizeof
(
int32_t
));
for
(
int32_t
i
=
0
;
i
<
numOfOutput
;
++
i
)
{
SExprInfo
*
pExpr
=
taosArrayGetP
(
pExprInfo
,
i
);
taosArrayPush
(
pColList
,
&
pExpr
->
pExpr
->
pSchema
[
0
].
colId
);
}
// set the extract column id to streamHandle
tqReadHandleSetColIdList
((
STqReadHandle
*
)
streamReadHandle
,
pColList
);
pInfo
->
readerHandle
=
streamReadHandle
;
pOperator
->
name
=
"StreamBlockScanOperator"
;
pOperator
->
operatorType
=
OP_Stream
Block
Scan
;
pOperator
->
operatorType
=
OP_StreamScan
;
pOperator
->
blockingOptr
=
false
;
pOperator
->
status
=
OP_IN_EXECUTING
;
pOperator
->
info
=
pInfo
;
pOperator
->
numOfOutput
=
numOfOutput
;
pOperator
->
exec
=
doStreamBlockScan
;
pOperator
->
pTaskInfo
=
pTaskInfo
;
return
pOperator
;
}
...
...
@@ -7704,6 +7717,9 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhyNode* pPhyNode, SExecTaskInfo* pTask
}
else
if
(
pPhyNode
->
info
.
type
==
OP_Exchange
)
{
SExchangePhyNode
*
pEx
=
(
SExchangePhyNode
*
)
pPhyNode
;
return
createExchangeOperatorInfo
(
pEx
->
pSrcEndPoints
,
pEx
->
node
.
pTargets
,
pTaskInfo
);
}
else
if
(
pPhyNode
->
info
.
type
==
OP_StreamScan
)
{
size_t
numOfCols
=
taosArrayGetSize
(
pPhyNode
->
pTargets
);
return
createStreamScanOperatorInfo
(
readerHandle
,
pPhyNode
->
pTargets
,
pTaskInfo
);
}
}
...
...
source/libs/parser/src/dCDAstProcess.c
浏览文件 @
fab31722
...
...
@@ -62,9 +62,8 @@ static int32_t setShowInfo(SShowInfo* pShowInfo, SParseContext* pCtx, void** out
pEpSet
->
port
[
i
]
=
info
->
epAddr
[
i
].
port
;
}
*
outputLen
=
sizeof
(
SVShowTablesReq
);
*
output
=
pShowReq
;
*
outputLen
=
sizeof
(
SVShowTablesReq
);
*
output
=
pShowReq
;
*
pExtension
=
array
;
}
else
{
if
(
showType
==
TSDB_MGMT_TABLE_STB
||
showType
==
TSDB_MGMT_TABLE_VGROUP
)
{
...
...
source/libs/parser/src/parser.c
浏览文件 @
fab31722
...
...
@@ -36,25 +36,29 @@ bool qIsDdlQuery(const SQueryNode* pQueryNode) {
}
int32_t
parseQuerySql
(
SParseContext
*
pCxt
,
SQueryNode
**
pQuery
)
{
int32_t
code
=
TSDB_CODE_SUCCESS
;
SSqlInfo
info
=
doGenerateAST
(
pCxt
->
pSql
);
if
(
!
info
.
valid
)
{
strncpy
(
pCxt
->
pMsg
,
info
.
msg
,
pCxt
->
msgLen
);
terrno
=
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
return
terrno
;
code
=
TSDB_CODE_TSC_SQL_SYNTAX_ERROR
;
goto
_end
;
}
if
(
!
isDqlSqlStatement
(
&
info
))
{
if
(
info
.
type
==
TSDB_SQL_CREATE_TABLE
)
{
SVnodeModifOpStmtInfo
*
pModifStmtInfo
=
qParserValidateCreateTbSqlNode
(
&
info
,
pCxt
,
pCxt
->
pMsg
,
pCxt
->
msgLen
);
if
(
pModifStmtInfo
==
NULL
)
{
return
terrno
;
code
=
terrno
;
goto
_end
;
}
*
pQuery
=
(
SQueryNode
*
)
pModifStmtInfo
;
}
else
{
SDclStmtInfo
*
pDcl
=
qParserValidateDclSqlNode
(
&
info
,
pCxt
,
pCxt
->
pMsg
,
pCxt
->
msgLen
);
if
(
pDcl
==
NULL
)
{
return
terrno
;
code
=
terrno
;
goto
_end
;
}
*
pQuery
=
(
SQueryNode
*
)
pDcl
;
...
...
@@ -63,21 +67,22 @@ int32_t parseQuerySql(SParseContext* pCxt, SQueryNode** pQuery) {
}
else
{
SQueryStmtInfo
*
pQueryInfo
=
createQueryInfo
();
if
(
pQueryInfo
==
NULL
)
{
terrno
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
// set correct error code.
return
terrno
;
code
=
TSDB_CODE_QRY_OUT_OF_MEMORY
;
// set correct error code.
goto
_end
;
}
int32_t
code
=
qParserValidateSqlNode
(
pCxt
,
&
info
,
pQueryInfo
,
pCxt
->
pMsg
,
pCxt
->
msgLen
);
code
=
qParserValidateSqlNode
(
pCxt
,
&
info
,
pQueryInfo
,
pCxt
->
pMsg
,
pCxt
->
msgLen
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
*
pQuery
=
(
SQueryNode
*
)
pQueryInfo
;
}
else
{
terrno
=
code
;
return
code
;
goto
_end
;
}
}
_end:
destroySqlInfo
(
&
info
);
return
TSDB_CODE_SUCCESS
;
terrno
=
code
;
return
code
;
}
int32_t
qParseQuerySql
(
SParseContext
*
pCxt
,
SQueryNode
**
pQueryNode
)
{
...
...
@@ -247,5 +252,6 @@ void qDestroyQuery(SQueryNode* pQueryNode) {
SVnodeModifOpStmtInfo
*
pModifInfo
=
(
SVnodeModifOpStmtInfo
*
)
pQueryNode
;
taosArrayDestroy
(
pModifInfo
->
pDataBlocks
);
}
tfree
(
pQueryNode
);
}
source/libs/scheduler/src/scheduler.c
浏览文件 @
fab31722
...
...
@@ -1485,11 +1485,11 @@ int32_t schedulerConvertDagToTaskList(SQueryDag* pDag, SArray **pTasks) {
pMsg
->
header
.
vgId
=
htonl
(
tInfo
.
addr
.
nodeId
);
pMsg
->
sId
=
htobe64
(
schMgmt
.
sId
)
;
pMsg
->
queryId
=
htobe64
(
plan
->
id
.
queryId
)
;
pMsg
->
taskId
=
htobe64
(
schGenUUID
()
);
pMsg
->
sId
=
schMgmt
.
sId
;
pMsg
->
queryId
=
plan
->
id
.
queryId
;
pMsg
->
taskId
=
schGenUUID
(
);
pMsg
->
taskType
=
TASK_TYPE_PERSISTENT
;
pMsg
->
contentLen
=
htonl
(
msgLen
)
;
pMsg
->
contentLen
=
msgLen
;
memcpy
(
pMsg
->
msg
,
msg
,
msgLen
);
tInfo
.
msg
=
pMsg
;
...
...
source/libs/tfs/src/tfs.c
浏览文件 @
fab31722
...
...
@@ -118,7 +118,11 @@ int32_t tfsAllocDisk(STfs *pTfs, int32_t expLevel, SDiskID *pDiskId) {
pDiskId
->
id
=
-
1
;
if
(
pDiskId
->
level
>=
pTfs
->
nlevel
)
{
pDiskId
->
level
--
;
pDiskId
->
level
=
pTfs
->
nlevel
-
1
;
}
if
(
pDiskId
->
level
<
0
)
{
pDiskId
->
level
=
0
;
}
while
(
pDiskId
->
level
>=
0
)
{
...
...
@@ -289,7 +293,7 @@ int32_t tfsRename(STfs *pTfs, char *orname, char *nrname) {
STfsDisk
*
pDisk
=
pTier
->
disks
[
id
];
snprintf
(
oaname
,
TMPNAME_LEN
,
"%s%s%s"
,
pDisk
->
path
,
TD_DIRSEP
,
orname
);
snprintf
(
naname
,
TMPNAME_LEN
,
"%s%s%s"
,
pDisk
->
path
,
TD_DIRSEP
,
nrname
);
if
(
taosRenameFile
(
oaname
,
naname
)
!=
0
)
{
if
(
taosRenameFile
(
oaname
,
naname
)
!=
0
&&
errno
!=
ENOENT
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
fError
(
"failed to rename %s to %s since %s"
,
oaname
,
naname
,
terrstr
());
return
-
1
;
...
...
source/libs/tfs/src/tfsTier.c
浏览文件 @
fab31722
...
...
@@ -69,7 +69,7 @@ STfsDisk *tfsMountDiskToTier(STfsTier *pTier, SDiskCfg *pCfg) {
pTier
->
disks
[
id
]
=
pDisk
;
pTier
->
ndisk
++
;
f
Info
(
"disk %s is mounted to tier level %d id %d"
,
pCfg
->
dir
,
pCfg
->
level
,
id
);
f
Debug
(
"disk %s is mounted to tier level %d id %d"
,
pCfg
->
dir
,
pCfg
->
level
,
id
);
return
pTier
->
disks
[
id
];
}
...
...
source/libs/tfs/test/tfsTest.cpp
浏览文件 @
fab31722
...
...
@@ -246,20 +246,19 @@ TEST_F(TfsTest, 04_File) {
snprintf
(
fulldir
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
"t3"
);
EXPECT_STREQ
(
dir
,
fulldir
);
EXPECT_
NE
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
EXPECT_
GT
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
char
af2
[
128
]
=
{
0
};
snprintf
(
af2
,
128
,
"%s%s%s"
,
root
,
TD_DIRSEP
,
n2
);
EXPECT_EQ
(
taosDirExist
(
af2
),
0
);
tfsRemoveFile
(
&
f2
);
EXPECT_NE
(
taosDirExist
(
af2
),
0
);
EXPECT_NE
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
{
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
""
);
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
"
t3
"
);
const
STfsFile
*
pf1
=
tfsReaddir
(
pDir
);
EXPECT_
STREQ
(
pf1
->
rname
,
"t3"
);
EXPECT_
NE
(
pf1
,
nullptr
);
EXPECT_EQ
(
pf1
->
did
.
id
,
0
);
EXPECT_EQ
(
pf1
->
did
.
level
,
0
);
EXPECT_EQ
(
pf1
->
pTfs
,
pTfs
);
...
...
@@ -270,6 +269,8 @@ TEST_F(TfsTest, 04_File) {
tfsClosedir
(
pDir
);
}
EXPECT_GT
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
{
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
"t3"
);
...
...
@@ -280,7 +281,9 @@ TEST_F(TfsTest, 04_File) {
EXPECT_EQ
(
pf1
->
pTfs
,
pTfs
);
const
STfsFile
*
pf2
=
tfsReaddir
(
pDir
);
EXPECT_NE
(
pf2
,
nullptr
);
EXPECT_EQ
(
pf2
->
did
.
id
,
0
);
EXPECT_EQ
(
pf2
->
did
.
level
,
0
);
EXPECT_EQ
(
pf2
->
pTfs
,
pTfs
);
const
STfsFile
*
pf3
=
tfsReaddir
(
pDir
);
EXPECT_EQ
(
pf3
,
nullptr
);
...
...
@@ -289,5 +292,415 @@ TEST_F(TfsTest, 04_File) {
}
}
tfsClose
(
pTfs
);
}
TEST_F
(
TfsTest
,
05
_MultiDisk
)
{
int32_t
code
=
0
;
const
char
*
root00
=
"/tmp/tfsTest00"
;
const
char
*
root01
=
"/tmp/tfsTest01"
;
const
char
*
root10
=
"/tmp/tfsTest10"
;
const
char
*
root11
=
"/tmp/tfsTest11"
;
const
char
*
root12
=
"/tmp/tfsTest12"
;
const
char
*
root20
=
"/tmp/tfsTest20"
;
const
char
*
root21
=
"/tmp/tfsTest21"
;
const
char
*
root22
=
"/tmp/tfsTest22"
;
const
char
*
root23
=
"/tmp/tfsTest23"
;
SDiskCfg
dCfg
[
9
]
=
{
0
};
tstrncpy
(
dCfg
[
0
].
dir
,
root01
,
TSDB_FILENAME_LEN
);
dCfg
[
0
].
level
=
0
;
dCfg
[
0
].
primary
=
0
;
tstrncpy
(
dCfg
[
1
].
dir
,
root00
,
TSDB_FILENAME_LEN
);
dCfg
[
1
].
level
=
0
;
dCfg
[
1
].
primary
=
0
;
tstrncpy
(
dCfg
[
2
].
dir
,
root20
,
TSDB_FILENAME_LEN
);
dCfg
[
2
].
level
=
2
;
dCfg
[
2
].
primary
=
0
;
tstrncpy
(
dCfg
[
3
].
dir
,
root21
,
TSDB_FILENAME_LEN
);
dCfg
[
3
].
level
=
2
;
dCfg
[
3
].
primary
=
0
;
tstrncpy
(
dCfg
[
4
].
dir
,
root22
,
TSDB_FILENAME_LEN
);
dCfg
[
4
].
level
=
2
;
dCfg
[
4
].
primary
=
0
;
tstrncpy
(
dCfg
[
5
].
dir
,
root23
,
TSDB_FILENAME_LEN
);
dCfg
[
5
].
level
=
2
;
dCfg
[
5
].
primary
=
0
;
tstrncpy
(
dCfg
[
6
].
dir
,
root10
,
TSDB_FILENAME_LEN
);
dCfg
[
6
].
level
=
1
;
dCfg
[
6
].
primary
=
0
;
tstrncpy
(
dCfg
[
7
].
dir
,
root11
,
TSDB_FILENAME_LEN
);
dCfg
[
7
].
level
=
1
;
dCfg
[
7
].
primary
=
0
;
tstrncpy
(
dCfg
[
8
].
dir
,
root12
,
TSDB_FILENAME_LEN
);
dCfg
[
8
].
level
=
1
;
dCfg
[
8
].
primary
=
0
;
taosRemoveDir
(
root00
);
taosRemoveDir
(
root01
);
taosRemoveDir
(
root10
);
taosRemoveDir
(
root11
);
taosRemoveDir
(
root12
);
taosRemoveDir
(
root20
);
taosRemoveDir
(
root21
);
taosRemoveDir
(
root22
);
taosRemoveDir
(
root23
);
taosMkDir
(
root00
);
taosMkDir
(
root01
);
taosMkDir
(
root10
);
taosMkDir
(
root11
);
taosMkDir
(
root12
);
taosMkDir
(
root20
);
taosMkDir
(
root21
);
taosMkDir
(
root22
);
taosMkDir
(
root23
);
STfs
*
pTfs
=
tfsOpen
(
dCfg
,
9
);
ASSERT_EQ
(
pTfs
,
nullptr
);
dCfg
[
0
].
primary
=
1
;
dCfg
[
1
].
primary
=
1
;
pTfs
=
tfsOpen
(
dCfg
,
9
);
ASSERT_EQ
(
pTfs
,
nullptr
);
dCfg
[
0
].
primary
=
0
;
dCfg
[
1
].
primary
=
1
;
pTfs
=
tfsOpen
(
dCfg
,
9
);
ASSERT_NE
(
pTfs
,
nullptr
);
tfsUpdateSize
(
pTfs
);
SDiskSize
size
=
tfsGetSize
(
pTfs
);
EXPECT_GT
(
size
.
avail
,
0
);
EXPECT_GT
(
size
.
used
,
0
);
EXPECT_GT
(
size
.
total
,
size
.
avail
);
EXPECT_GT
(
size
.
total
,
size
.
used
);
//------------- AllocDisk -----------------//
{
const
char
*
path
=
NULL
;
SDiskID
did
;
did
.
id
=
0
;
did
.
level
=
0
;
code
=
tfsAllocDisk
(
pTfs
,
0
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
0
);
EXPECT_EQ
(
did
.
level
,
0
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root00
);
code
=
tfsAllocDisk
(
pTfs
,
0
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
1
);
EXPECT_EQ
(
did
.
level
,
0
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root01
);
code
=
tfsAllocDisk
(
pTfs
,
0
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
0
);
EXPECT_EQ
(
did
.
level
,
0
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root00
);
code
=
tfsAllocDisk
(
pTfs
,
0
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
1
);
EXPECT_EQ
(
did
.
level
,
0
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root01
);
code
=
tfsAllocDisk
(
pTfs
,
0
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
0
);
EXPECT_EQ
(
did
.
level
,
0
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root00
);
code
=
tfsAllocDisk
(
pTfs
,
0
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
1
);
EXPECT_EQ
(
did
.
level
,
0
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root01
);
code
=
tfsAllocDisk
(
pTfs
,
1
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
0
);
EXPECT_EQ
(
did
.
level
,
1
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root10
);
code
=
tfsAllocDisk
(
pTfs
,
1
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
1
);
EXPECT_EQ
(
did
.
level
,
1
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root11
);
code
=
tfsAllocDisk
(
pTfs
,
1
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
2
);
EXPECT_EQ
(
did
.
level
,
1
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root12
);
code
=
tfsAllocDisk
(
pTfs
,
1
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
0
);
EXPECT_EQ
(
did
.
level
,
1
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root10
);
code
=
tfsAllocDisk
(
pTfs
,
2
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
0
);
EXPECT_EQ
(
did
.
level
,
2
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root20
);
code
=
tfsAllocDisk
(
pTfs
,
2
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
1
);
EXPECT_EQ
(
did
.
level
,
2
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root21
);
code
=
tfsAllocDisk
(
pTfs
,
2
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
2
);
EXPECT_EQ
(
did
.
level
,
2
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root22
);
code
=
tfsAllocDisk
(
pTfs
,
2
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
3
);
EXPECT_EQ
(
did
.
level
,
2
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root23
);
code
=
tfsAllocDisk
(
pTfs
,
2
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
0
);
EXPECT_EQ
(
did
.
level
,
2
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root20
);
code
=
tfsAllocDisk
(
pTfs
,
3
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
1
);
EXPECT_EQ
(
did
.
level
,
2
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root21
);
code
=
tfsAllocDisk
(
pTfs
,
4
,
&
did
);
EXPECT_EQ
(
code
,
0
);
EXPECT_EQ
(
did
.
id
,
2
);
EXPECT_EQ
(
did
.
level
,
2
);
path
=
tfsGetDiskPath
(
pTfs
,
did
);
EXPECT_STREQ
(
path
,
root22
);
const
char
*
primary
=
tfsGetPrimaryPath
(
pTfs
);
EXPECT_STREQ
(
primary
,
root00
);
}
//------------- Dir -----------------//
{
char
p1
[]
=
"p1"
;
char
ap00
[
128
]
=
{
0
};
snprintf
(
ap00
,
128
,
"%s%s%s"
,
root00
,
TD_DIRSEP
,
p1
);
char
ap01
[
128
]
=
{
0
};
snprintf
(
ap01
,
128
,
"%s%s%s"
,
root01
,
TD_DIRSEP
,
p1
);
char
ap10
[
128
]
=
{
0
};
snprintf
(
ap10
,
128
,
"%s%s%s"
,
root10
,
TD_DIRSEP
,
p1
);
char
ap11
[
128
]
=
{
0
};
snprintf
(
ap11
,
128
,
"%s%s%s"
,
root11
,
TD_DIRSEP
,
p1
);
char
ap12
[
128
]
=
{
0
};
snprintf
(
ap12
,
128
,
"%s%s%s"
,
root12
,
TD_DIRSEP
,
p1
);
char
ap20
[
128
]
=
{
0
};
snprintf
(
ap20
,
128
,
"%s%s%s"
,
root20
,
TD_DIRSEP
,
p1
);
char
ap21
[
128
]
=
{
0
};
snprintf
(
ap21
,
128
,
"%s%s%s"
,
root21
,
TD_DIRSEP
,
p1
);
char
ap22
[
128
]
=
{
0
};
snprintf
(
ap22
,
128
,
"%s%s%s"
,
root22
,
TD_DIRSEP
,
p1
);
char
ap23
[
128
]
=
{
0
};
snprintf
(
ap23
,
128
,
"%s%s%s"
,
root23
,
TD_DIRSEP
,
p1
);
EXPECT_NE
(
taosDirExist
(
ap00
),
0
);
EXPECT_NE
(
taosDirExist
(
ap01
),
0
);
EXPECT_NE
(
taosDirExist
(
ap10
),
0
);
EXPECT_NE
(
taosDirExist
(
ap11
),
0
);
EXPECT_NE
(
taosDirExist
(
ap12
),
0
);
EXPECT_NE
(
taosDirExist
(
ap20
),
0
);
EXPECT_NE
(
taosDirExist
(
ap21
),
0
);
EXPECT_NE
(
taosDirExist
(
ap22
),
0
);
EXPECT_NE
(
taosDirExist
(
ap23
),
0
);
EXPECT_EQ
(
tfsMkdir
(
pTfs
,
p1
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap00
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap01
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap10
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap11
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap12
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap20
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap21
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap22
),
0
);
EXPECT_EQ
(
taosDirExist
(
ap23
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p1
),
0
);
EXPECT_NE
(
taosDirExist
(
ap00
),
0
);
EXPECT_NE
(
taosDirExist
(
ap01
),
0
);
EXPECT_NE
(
taosDirExist
(
ap10
),
0
);
EXPECT_NE
(
taosDirExist
(
ap11
),
0
);
EXPECT_NE
(
taosDirExist
(
ap12
),
0
);
EXPECT_NE
(
taosDirExist
(
ap20
),
0
);
EXPECT_NE
(
taosDirExist
(
ap21
),
0
);
EXPECT_NE
(
taosDirExist
(
ap22
),
0
);
EXPECT_NE
(
taosDirExist
(
ap23
),
0
);
char
p2
[]
=
"p2"
;
char
_ap21
[
128
]
=
{
0
};
snprintf
(
_ap21
,
128
,
"%s%s%s"
,
root21
,
TD_DIRSEP
,
p2
);
SDiskID
did
=
{
0
};
did
.
level
=
2
;
did
.
id
=
1
;
EXPECT_NE
(
taosDirExist
(
_ap21
),
0
);
EXPECT_EQ
(
tfsMkdirAt
(
pTfs
,
p2
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap21
),
0
);
char
p3
[]
=
"p3/p2/p1/p0"
;
char
_ap12
[
128
]
=
{
0
};
snprintf
(
_ap12
,
128
,
"%s%s%s"
,
root12
,
TD_DIRSEP
,
p3
);
did
.
level
=
1
;
did
.
id
=
2
;
EXPECT_NE
(
taosDirExist
(
_ap12
),
0
);
EXPECT_NE
(
tfsMkdir
(
pTfs
,
p3
),
0
);
EXPECT_NE
(
tfsMkdirAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p3
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap12
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p3
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap12
),
0
);
char
p45
[]
=
"p5"
;
char
p44
[]
=
"p4"
;
char
p4
[]
=
"p4/p2/p1/p0"
;
char
_ap22
[
128
]
=
{
0
};
snprintf
(
_ap22
,
128
,
"%s%s%s"
,
root22
,
TD_DIRSEP
,
p4
);
did
.
level
=
2
;
did
.
id
=
2
;
EXPECT_NE
(
taosDirExist
(
_ap22
),
0
);
EXPECT_EQ
(
tfsMkdirRecurAt
(
pTfs
,
p4
,
did
),
0
);
EXPECT_EQ
(
taosDirExist
(
_ap22
),
0
);
EXPECT_EQ
(
tfsRename
(
pTfs
,
p44
,
p45
),
0
);
EXPECT_EQ
(
tfsRmdir
(
pTfs
,
p4
),
0
);
EXPECT_NE
(
taosDirExist
(
_ap22
),
0
);
}
//------------- File -----------------//
{
STfsFile
file0
;
STfsFile
file1
;
STfsFile
file2
;
STfsFile
file3
;
STfsFile
file4
;
SDiskID
did0
=
{
0
};
SDiskID
did1
=
{
0
};
SDiskID
did2
=
{
0
};
SDiskID
did3
=
{
0
};
SDiskID
did4
=
{
0
};
did3
.
id
=
1
;
did4
.
level
=
1
;
tfsInitFile
(
pTfs
,
&
file0
,
did0
,
"fname"
);
tfsInitFile
(
pTfs
,
&
file1
,
did1
,
"fname"
);
tfsInitFile
(
pTfs
,
&
file2
,
did2
,
"fnamex"
);
tfsInitFile
(
pTfs
,
&
file3
,
did3
,
"fname"
);
tfsInitFile
(
pTfs
,
&
file4
,
did4
,
"fname"
);
EXPECT_TRUE
(
tfsIsSameFile
(
&
file0
,
&
file1
));
EXPECT_FALSE
(
tfsIsSameFile
(
&
file0
,
&
file2
));
EXPECT_FALSE
(
tfsIsSameFile
(
&
file0
,
&
file3
));
EXPECT_FALSE
(
tfsIsSameFile
(
&
file0
,
&
file4
));
{
char
n1
[]
=
"t3/t1.json"
;
char
n2
[]
=
"t3/t2.json"
;
STfsFile
f1
=
{
0
};
STfsFile
f2
=
{
0
};
SDiskID
did
;
did1
.
level
=
1
;
did1
.
id
=
2
;
did2
.
level
=
2
;
did2
.
id
=
3
;
tfsInitFile
(
pTfs
,
&
f1
,
did1
,
n1
);
tfsInitFile
(
pTfs
,
&
f2
,
did2
,
n2
);
EXPECT_EQ
(
tfsMkdir
(
pTfs
,
"t3"
),
0
);
FILE
*
fp
=
fopen
(
f1
.
aname
,
"w"
);
ASSERT_NE
(
fp
,
nullptr
);
fwrite
(
"12345678"
,
1
,
5
,
fp
);
fclose
(
fp
);
char
base
[
128
]
=
{
0
};
tfsBasename
(
&
f1
,
base
);
char
dir
[
128
]
=
{
0
};
tfsDirname
(
&
f1
,
dir
);
EXPECT_STREQ
(
base
,
"t1.json"
);
char
fulldir
[
128
];
snprintf
(
fulldir
,
128
,
"%s%s%s"
,
root12
,
TD_DIRSEP
,
"t3"
);
EXPECT_STREQ
(
dir
,
fulldir
);
EXPECT_GT
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
char
af2
[
128
]
=
{
0
};
snprintf
(
af2
,
128
,
"%s%s%s"
,
root23
,
TD_DIRSEP
,
n2
);
EXPECT_EQ
(
taosDirExist
(
af2
),
0
);
tfsRemoveFile
(
&
f2
);
{
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
"t3"
);
const
STfsFile
*
pf1
=
tfsReaddir
(
pDir
);
EXPECT_NE
(
pf1
,
nullptr
);
EXPECT_EQ
(
pf1
->
did
.
level
,
1
);
EXPECT_EQ
(
pf1
->
did
.
id
,
2
);
EXPECT_EQ
(
pf1
->
pTfs
,
pTfs
);
const
STfsFile
*
pf2
=
tfsReaddir
(
pDir
);
EXPECT_EQ
(
pf2
,
nullptr
);
tfsClosedir
(
pDir
);
}
EXPECT_NE
(
taosDirExist
(
af2
),
0
);
EXPECT_GT
(
tfsCopyFile
(
&
f1
,
&
f2
),
0
);
{
STfsDir
*
pDir
=
tfsOpendir
(
pTfs
,
"t3"
);
const
STfsFile
*
pf1
=
tfsReaddir
(
pDir
);
EXPECT_NE
(
pf1
,
nullptr
);
EXPECT_GT
(
pf1
->
did
.
level
,
0
);
EXPECT_GT
(
pf1
->
did
.
id
,
0
);
EXPECT_EQ
(
pf1
->
pTfs
,
pTfs
);
const
STfsFile
*
pf2
=
tfsReaddir
(
pDir
);
EXPECT_NE
(
pf1
,
nullptr
);
EXPECT_GT
(
pf1
->
did
.
level
,
0
);
EXPECT_GT
(
pf1
->
did
.
id
,
0
);
EXPECT_EQ
(
pf1
->
pTfs
,
pTfs
);
const
STfsFile
*
pf3
=
tfsReaddir
(
pDir
);
EXPECT_EQ
(
pf3
,
nullptr
);
tfsClosedir
(
pDir
);
}
}
}
tfsClose
(
pTfs
);
}
\ No newline at end of file
tests/script/sh/massiveTable/setupDnodes.sh
浏览文件 @
fab31722
...
...
@@ -70,7 +70,7 @@ createNewCfgFile() {
echo
"dataDir
${
dataDir
}
"
>>
${
cfgFile
}
echo
"logDir
${
logDir
}
"
>>
${
cfgFile
}
echo
"serverPort
${
serverPort
}
"
>>
${
cfgFile
}
echo
"numOfLogLines 100000000"
>>
${
cfgFile
}
echo
"supportVnodes 1024"
>>
${
cfgFile
}
#echo "asyncLog 0" >> ${cfgFile}
echo
"telemetryReporting 0"
>>
${
cfgFile
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录