Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0399125b
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看板
提交
0399125b
编写于
1月 19, 2022
作者:
H
Haojun Liao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[td-11818] Refactor.
上级
8dc69569
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
70 addition
and
79 deletion
+70
-79
source/client/test/clientTests.cpp
source/client/test/clientTests.cpp
+50
-50
source/libs/planner/src/physicalPlanJson.c
source/libs/planner/src/physicalPlanJson.c
+17
-26
source/libs/planner/src/planner.c
source/libs/planner/src/planner.c
+3
-3
未找到文件。
source/client/test/clientTests.cpp
浏览文件 @
0399125b
...
...
@@ -521,29 +521,29 @@ TEST(testCase, connect_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);
...
...
@@ -614,30 +614,30 @@ TEST(testCase, connect_Test) {
// taos_close(pConn);
//}
TEST
(
testCase
,
projection_query_stables
)
{
TAOS
*
pConn
=
taos_connect
(
"localhost"
,
"root"
,
"taosdata"
,
NULL
,
0
);
ASSERT_NE
(
pConn
,
nullptr
);
TAOS_RES
*
pRes
=
taos_query
(
pConn
,
"use abc1"
);
taos_free_result
(
pRes
);
pRes
=
taos_query
(
pConn
,
"select ts from m1"
);
if
(
taos_errno
(
pRes
)
!=
0
)
{
printf
(
"failed to select from table, reason:%s
\n
"
,
taos_errstr
(
pRes
));
taos_free_result
(
pRes
);
ASSERT_TRUE
(
false
);
}
TAOS_ROW
pRow
=
NULL
;
TAOS_FIELD
*
pFields
=
taos_fetch_fields
(
pRes
);
int32_t
numOfFields
=
taos_num_fields
(
pRes
);
char
str
[
512
]
=
{
0
};
while
((
pRow
=
taos_fetch_row
(
pRes
))
!=
NULL
)
{
int32_t
code
=
taos_print_row
(
str
,
pRow
,
pFields
,
numOfFields
);
printf
(
"%s
\n
"
,
str
);
}
taos_free_result
(
pRes
);
taos_close
(
pConn
);
}
//
TEST(testCase, projection_query_stables) {
//
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
//
ASSERT_NE(pConn, nullptr);
//
//
TAOS_RES* pRes = taos_query(pConn, "use abc1");
//
taos_free_result(pRes);
//
//
pRes = taos_query(pConn, "select ts from m1");
//
if (taos_errno(pRes) != 0) {
//
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
//
taos_free_result(pRes);
//
ASSERT_TRUE(false);
//
}
//
//
TAOS_ROW pRow = NULL;
//
TAOS_FIELD* pFields = taos_fetch_fields(pRes);
//
int32_t numOfFields = taos_num_fields(pRes);
//
//
char str[512] = {0};
//
while ((pRow = taos_fetch_row(pRes)) != NULL) {
//
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
//
printf("%s\n", str);
//
}
//
//
taos_free_result(pRes);
//
taos_close(pConn);
//
}
source/libs/planner/src/physicalPlanJson.c
浏览文件 @
0399125b
...
...
@@ -29,6 +29,14 @@ static void copyString(const cJSON* json, const char* name, char* dst) {
strcpy
(
dst
,
cJSON_GetStringValue
(
cJSON_GetObjectItem
(
json
,
name
)));
}
static
uint64_t
getBigintFromString
(
const
cJSON
*
json
,
const
char
*
name
)
{
char
*
val
=
getString
(
json
,
name
);
uint64_t
intVal
=
strtoul
(
val
,
NULL
,
10
);
tfree
(
val
);
return
intVal
;
}
static
int64_t
getNumber
(
const
cJSON
*
json
,
const
char
*
name
)
{
double
d
=
cJSON_GetNumberValue
(
cJSON_GetObjectItem
(
json
,
name
));
return
(
int64_t
)
d
;
...
...
@@ -543,13 +551,13 @@ static const char* jkTimeWindowEndKey = "EndKey";
static
bool
timeWindowToJson
(
const
void
*
obj
,
cJSON
*
json
)
{
const
STimeWindow
*
win
=
(
const
STimeWindow
*
)
obj
;
char
tmp
[
32
]
=
{
0
};
s
printf
(
tmp
,
"%"
PRId64
,
win
->
skey
);
char
tmp
[
40
]
=
{
0
};
s
nprintf
(
tmp
,
tListLen
(
tmp
),
"%"
PRId64
,
win
->
skey
);
bool
res
=
cJSON_AddStringToObject
(
json
,
jkTimeWindowStartKey
,
tmp
);
if
(
res
)
{
memset
(
tmp
,
0
,
tListLen
(
tmp
));
s
printf
(
tmp
,
"%"
PRId64
,
win
->
ekey
);
s
nprintf
(
tmp
,
tListLen
(
tmp
),
"%"
PRId64
,
win
->
ekey
);
res
=
cJSON_AddStringToObject
(
json
,
jkTimeWindowEndKey
,
tmp
);
}
return
res
;
...
...
@@ -557,16 +565,8 @@ static bool timeWindowToJson(const void* obj, cJSON* json) {
static
bool
timeWindowFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
STimeWindow
*
win
=
(
STimeWindow
*
)
obj
;
char
*
pStartKey
=
getString
(
json
,
jkTimeWindowStartKey
);
win
->
skey
=
strtoul
(
pStartKey
,
NULL
,
10
);
char
*
pEndKey
=
getString
(
json
,
jkTimeWindowEndKey
);
win
->
ekey
=
strtoul
(
pEndKey
,
NULL
,
10
);
tfree
(
pStartKey
);
tfree
(
pEndKey
);
win
->
skey
=
getBigintFromString
(
json
,
jkTimeWindowStartKey
);
win
->
ekey
=
getBigintFromString
(
json
,
jkTimeWindowEndKey
);
return
true
;
}
...
...
@@ -605,10 +605,7 @@ static bool scanNodeToJson(const void* obj, cJSON* json) {
static
bool
scanNodeFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
SScanPhyNode
*
pNode
=
(
SScanPhyNode
*
)
obj
;
char
*
val
=
getString
(
json
,
jkScanNodeTableId
);
pNode
->
uid
=
strtoull
(
val
,
NULL
,
10
);
tfree
(
val
);
pNode
->
uid
=
getBigintFromString
(
json
,
jkScanNodeTableId
);
pNode
->
tableType
=
getNumber
(
json
,
jkScanNodeTableType
);
pNode
->
count
=
getNumber
(
json
,
jkScanNodeTableCount
);
pNode
->
order
=
getNumber
(
json
,
jkScanNodeTableOrder
);
...
...
@@ -782,10 +779,7 @@ static bool nodeAddrFromJson(const cJSON* json, void* obj) {
SDownstreamSource
*
pSource
=
(
SDownstreamSource
*
)
obj
;
pSource
->
taskId
=
getNumber
(
json
,
jkNodeTaskId
);
char
*
pSchedId
=
getString
(
json
,
jkNodeTaskSchedId
);
pSource
->
schedId
=
strtoul
(
pSchedId
,
NULL
,
10
);
tfree
(
pSchedId
);
pSource
->
schedId
=
getBigintFromString
(
json
,
jkNodeTaskSchedId
);
bool
res
=
fromObject
(
json
,
jkNodeAddr
,
queryNodeAddrFromJson
,
&
pSource
->
addr
,
true
);
return
res
;
}
...
...
@@ -1031,12 +1025,9 @@ static bool subplanIdToJson(const void* obj, cJSON* jId) {
static
bool
subplanIdFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
SSubplanId
*
id
=
(
SSubplanId
*
)
obj
;
char
*
queryId
=
getString
(
json
,
jkIdQueryId
);
id
->
queryId
=
strtoul
(
queryId
,
NULL
,
0
);
tfree
(
queryId
);
id
->
queryId
=
getBigintFromString
(
json
,
jkIdQueryId
);
id
->
templateId
=
getNumber
(
json
,
jkIdTemplateId
);
id
->
subplanId
=
getNumber
(
json
,
jkIdSubplanId
);
id
->
subplanId
=
getNumber
(
json
,
jkIdSubplanId
);
return
true
;
}
...
...
source/libs/planner/src/planner.c
浏览文件 @
0399125b
...
...
@@ -65,9 +65,9 @@ int32_t qCreateQueryDag(const struct SQueryNode* pNode, struct SQueryDag** pDag,
}
if
(
pLogicPlan
->
info
.
type
!=
QNODE_MODIFY
)
{
char
*
str
=
NULL
;
queryPlanToString
(
pLogicPlan
,
&
str
);
printf
(
"%s
\n
"
,
str
);
//
char* str = NULL;
//
queryPlanToString(pLogicPlan, &str);
//
printf("%s\n", str);
}
code
=
optimizeQueryPlan
(
pLogicPlan
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录