Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
cc24ae76
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看板
提交
cc24ae76
编写于
3月 08, 2022
作者:
L
Liu Jicong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix crash
上级
8447cea6
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
115 addition
and
98 deletion
+115
-98
source/dnode/mnode/impl/src/mndScheduler.c
source/dnode/mnode/impl/src/mndScheduler.c
+2
-2
source/libs/planner/src/physicalPlanJson.c
source/libs/planner/src/physicalPlanJson.c
+113
-96
未找到文件。
source/dnode/mnode/impl/src/mndScheduler.c
浏览文件 @
cc24ae76
...
@@ -47,7 +47,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
...
@@ -47,7 +47,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
return
-
1
;
return
-
1
;
}
}
SArray
*
plans
=
taosArrayGet
(
pDag
->
pSubplans
,
0
);
SArray
*
plans
=
taosArrayGet
P
(
pDag
->
pSubplans
,
0
);
int32_t
opNum
=
taosArrayGetSize
(
plans
);
int32_t
opNum
=
taosArrayGetSize
(
plans
);
if
(
opNum
!=
1
)
{
if
(
opNum
!=
1
)
{
...
@@ -85,7 +85,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
...
@@ -85,7 +85,7 @@ int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscrib
taosArrayPush
(
pSub
->
unassignedVg
,
&
consumerEp
);
taosArrayPush
(
pSub
->
unassignedVg
,
&
consumerEp
);
}
}
/*qDestroyQueryDag(pDag);*/
qDestroyQueryDag
(
pDag
);
return
0
;
return
0
;
}
}
source/libs/planner/src/physicalPlanJson.c
浏览文件 @
cc24ae76
...
@@ -13,9 +13,9 @@
...
@@ -13,9 +13,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
*/
#include "plannerInt.h"
#include "parser.h"
#include "cJSON.h"
#include "cJSON.h"
#include "parser.h"
#include "plannerInt.h"
typedef
bool
(
*
FToJson
)(
const
void
*
obj
,
cJSON
*
json
);
typedef
bool
(
*
FToJson
)(
const
void
*
obj
,
cJSON
*
json
);
typedef
bool
(
*
FFromJson
)(
const
cJSON
*
json
,
void
*
obj
);
typedef
bool
(
*
FFromJson
)(
const
cJSON
*
json
,
void
*
obj
);
...
@@ -39,7 +39,7 @@ static uint64_t getBigintFromString(const cJSON* json, const char* name) {
...
@@ -39,7 +39,7 @@ static uint64_t getBigintFromString(const cJSON* json, const char* name) {
static
int64_t
getNumber
(
const
cJSON
*
json
,
const
char
*
name
)
{
static
int64_t
getNumber
(
const
cJSON
*
json
,
const
char
*
name
)
{
double
d
=
cJSON_GetNumberValue
(
cJSON_GetObjectItem
(
json
,
name
));
double
d
=
cJSON_GetNumberValue
(
cJSON_GetObjectItem
(
json
,
name
));
return
(
int64_t
)
d
;
return
(
int64_t
)
d
;
}
}
static
bool
addObject
(
cJSON
*
json
,
const
char
*
name
,
FToJson
func
,
const
void
*
obj
)
{
static
bool
addObject
(
cJSON
*
json
,
const
char
*
name
,
FToJson
func
,
const
void
*
obj
)
{
...
@@ -72,7 +72,8 @@ static bool fromObject(const cJSON* json, const char* name, FFromJson func, void
...
@@ -72,7 +72,8 @@ static bool fromObject(const cJSON* json, const char* name, FFromJson func, void
return
func
(
jObj
,
obj
);
return
func
(
jObj
,
obj
);
}
}
static
bool
fromObjectWithAlloc
(
const
cJSON
*
json
,
const
char
*
name
,
FFromJson
func
,
void
**
obj
,
int32_t
size
,
bool
required
)
{
static
bool
fromObjectWithAlloc
(
const
cJSON
*
json
,
const
char
*
name
,
FFromJson
func
,
void
**
obj
,
int32_t
size
,
bool
required
)
{
cJSON
*
jObj
=
cJSON_GetObjectItem
(
json
,
name
);
cJSON
*
jObj
=
cJSON_GetObjectItem
(
json
,
name
);
if
(
NULL
==
jObj
)
{
if
(
NULL
==
jObj
)
{
return
!
required
;
return
!
required
;
...
@@ -161,7 +162,8 @@ static bool addArray(cJSON* json, const char* name, FToJson func, const SArray*
...
@@ -161,7 +162,8 @@ static bool addArray(cJSON* json, const char* name, FToJson func, const SArray*
return
addTarray
(
json
,
name
,
func
,
array
,
true
);
return
addTarray
(
json
,
name
,
func
,
array
,
true
);
}
}
static
bool
fromTarray
(
const
cJSON
*
json
,
const
char
*
name
,
FFromJson
func
,
SArray
**
array
,
int32_t
itemSize
,
bool
isPoint
)
{
static
bool
fromTarray
(
const
cJSON
*
json
,
const
char
*
name
,
FFromJson
func
,
SArray
**
array
,
int32_t
itemSize
,
bool
isPoint
)
{
const
cJSON
*
jArray
=
cJSON_GetObjectItem
(
json
,
name
);
const
cJSON
*
jArray
=
cJSON_GetObjectItem
(
json
,
name
);
int32_t
size
=
(
NULL
==
jArray
?
0
:
cJSON_GetArraySize
(
jArray
));
int32_t
size
=
(
NULL
==
jArray
?
0
:
cJSON_GetArraySize
(
jArray
));
if
(
size
>
0
)
{
if
(
size
>
0
)
{
...
@@ -188,7 +190,8 @@ static bool fromArray(const cJSON* json, const char* name, FFromJson func, SArra
...
@@ -188,7 +190,8 @@ static bool fromArray(const cJSON* json, const char* name, FFromJson func, SArra
return
fromTarray
(
json
,
name
,
func
,
array
,
itemSize
,
true
);
return
fromTarray
(
json
,
name
,
func
,
array
,
itemSize
,
true
);
}
}
static
bool
addRawArray
(
cJSON
*
json
,
const
char
*
name
,
FToJson
func
,
const
void
*
array
,
int32_t
itemSize
,
int32_t
size
)
{
static
bool
addRawArray
(
cJSON
*
json
,
const
char
*
name
,
FToJson
func
,
const
void
*
array
,
int32_t
itemSize
,
int32_t
size
)
{
if
(
size
>
0
)
{
if
(
size
>
0
)
{
cJSON
*
jArray
=
cJSON_AddArrayToObject
(
json
,
name
);
cJSON
*
jArray
=
cJSON_AddArrayToObject
(
json
,
name
);
if
(
NULL
==
jArray
)
{
if
(
NULL
==
jArray
)
{
...
@@ -218,7 +221,8 @@ static bool fromItem(const cJSON* jArray, FFromJson func, void* array, int32_t i
...
@@ -218,7 +221,8 @@ static bool fromItem(const cJSON* jArray, FFromJson func, void* array, int32_t i
return
true
;
return
true
;
}
}
static
bool
fromRawArrayWithAlloc
(
const
cJSON
*
json
,
const
char
*
name
,
FFromJson
func
,
void
**
array
,
int32_t
itemSize
,
int32_t
*
size
)
{
static
bool
fromRawArrayWithAlloc
(
const
cJSON
*
json
,
const
char
*
name
,
FFromJson
func
,
void
**
array
,
int32_t
itemSize
,
int32_t
*
size
)
{
const
cJSON
*
jArray
=
getArray
(
json
,
name
,
size
);
const
cJSON
*
jArray
=
getArray
(
json
,
name
,
size
);
if
(
*
size
>
0
)
{
if
(
*
size
>
0
)
{
*
array
=
calloc
(
1
,
itemSize
*
(
*
size
));
*
array
=
calloc
(
1
,
itemSize
*
(
*
size
));
...
@@ -229,7 +233,8 @@ static bool fromRawArrayWithAlloc(const cJSON* json, const char* name, FFromJson
...
@@ -229,7 +233,8 @@ static bool fromRawArrayWithAlloc(const cJSON* json, const char* name, FFromJson
return
fromItem
(
jArray
,
func
,
*
array
,
itemSize
,
*
size
);
return
fromItem
(
jArray
,
func
,
*
array
,
itemSize
,
*
size
);
}
}
static
bool
fromRawArray
(
const
cJSON
*
json
,
const
char
*
name
,
FFromJson
func
,
void
*
array
,
int32_t
itemSize
,
int32_t
*
size
)
{
static
bool
fromRawArray
(
const
cJSON
*
json
,
const
char
*
name
,
FFromJson
func
,
void
*
array
,
int32_t
itemSize
,
int32_t
*
size
)
{
const
cJSON
*
jArray
=
getArray
(
json
,
name
,
size
);
const
cJSON
*
jArray
=
getArray
(
json
,
name
,
size
);
return
fromItem
(
jArray
,
func
,
array
,
itemSize
,
*
size
);
return
fromItem
(
jArray
,
func
,
array
,
itemSize
,
*
size
);
}
}
...
@@ -264,7 +269,8 @@ static const char* jkDataBlockSchemaPrecision = "Precision";
...
@@ -264,7 +269,8 @@ static const char* jkDataBlockSchemaPrecision = "Precision";
static
bool
dataBlockSchemaToJson
(
const
void
*
obj
,
cJSON
*
json
)
{
static
bool
dataBlockSchemaToJson
(
const
void
*
obj
,
cJSON
*
json
)
{
const
SDataBlockSchema
*
schema
=
(
const
SDataBlockSchema
*
)
obj
;
const
SDataBlockSchema
*
schema
=
(
const
SDataBlockSchema
*
)
obj
;
bool
res
=
addRawArray
(
json
,
jkDataBlockSchemaSlotSchema
,
schemaToJson
,
schema
->
pSchema
,
sizeof
(
SSlotSchema
),
schema
->
numOfCols
);
bool
res
=
addRawArray
(
json
,
jkDataBlockSchemaSlotSchema
,
schemaToJson
,
schema
->
pSchema
,
sizeof
(
SSlotSchema
),
schema
->
numOfCols
);
if
(
res
)
{
if
(
res
)
{
res
=
cJSON_AddNumberToObject
(
json
,
jkDataBlockSchemaResultRowSize
,
schema
->
resultRowSize
);
res
=
cJSON_AddNumberToObject
(
json
,
jkDataBlockSchemaResultRowSize
,
schema
->
resultRowSize
);
}
}
...
@@ -279,7 +285,8 @@ static bool dataBlockSchemaFromJson(const cJSON* json, void* obj) {
...
@@ -279,7 +285,8 @@ static bool dataBlockSchemaFromJson(const cJSON* json, void* obj) {
schema
->
resultRowSize
=
getNumber
(
json
,
jkDataBlockSchemaResultRowSize
);
schema
->
resultRowSize
=
getNumber
(
json
,
jkDataBlockSchemaResultRowSize
);
schema
->
precision
=
getNumber
(
json
,
jkDataBlockSchemaPrecision
);
schema
->
precision
=
getNumber
(
json
,
jkDataBlockSchemaPrecision
);
return
fromRawArrayWithAlloc
(
json
,
jkDataBlockSchemaSlotSchema
,
schemaFromJson
,
(
void
**
)
&
(
schema
->
pSchema
),
sizeof
(
SSlotSchema
),
&
schema
->
numOfCols
);
return
fromRawArrayWithAlloc
(
json
,
jkDataBlockSchemaSlotSchema
,
schemaFromJson
,
(
void
**
)
&
(
schema
->
pSchema
),
sizeof
(
SSlotSchema
),
&
schema
->
numOfCols
);
}
}
static
const
char
*
jkColumnFilterInfoLowerRelOptr
=
"LowerRelOptr"
;
static
const
char
*
jkColumnFilterInfoLowerRelOptr
=
"LowerRelOptr"
;
...
@@ -332,7 +339,8 @@ static bool columnInfoToJson(const void* obj, cJSON* jCol) {
...
@@ -332,7 +339,8 @@ static bool columnInfoToJson(const void* obj, cJSON* jCol) {
}
}
if
(
res
)
{
// TODO: temporarily disable it
if
(
res
)
{
// TODO: temporarily disable it
// res = addRawArray(jCol, jkColumnInfoFilterList, columnFilterInfoToJson, col->flist.filterInfo, sizeof(SColumnFilterInfo), col->flist.numOfFilters);
// res = addRawArray(jCol, jkColumnInfoFilterList, columnFilterInfoToJson, col->flist.filterInfo,
// sizeof(SColumnFilterInfo), col->flist.numOfFilters);
}
}
return
res
;
return
res
;
...
@@ -344,7 +352,8 @@ static bool columnInfoFromJson(const cJSON* json, void* obj) {
...
@@ -344,7 +352,8 @@ static bool columnInfoFromJson(const cJSON* json, void* obj) {
col
->
type
=
getNumber
(
json
,
jkColumnInfoType
);
col
->
type
=
getNumber
(
json
,
jkColumnInfoType
);
col
->
bytes
=
getNumber
(
json
,
jkColumnInfoBytes
);
col
->
bytes
=
getNumber
(
json
,
jkColumnInfoBytes
);
int32_t
size
=
0
;
int32_t
size
=
0
;
bool
res
=
fromRawArrayWithAlloc
(
json
,
jkColumnInfoFilterList
,
columnFilterInfoFromJson
,
(
void
**
)
&
col
->
flist
.
filterInfo
,
sizeof
(
SColumnFilterInfo
),
&
size
);
bool
res
=
fromRawArrayWithAlloc
(
json
,
jkColumnInfoFilterList
,
columnFilterInfoFromJson
,
(
void
**
)
&
col
->
flist
.
filterInfo
,
sizeof
(
SColumnFilterInfo
),
&
size
);
col
->
flist
.
numOfFilters
=
size
;
col
->
flist
.
numOfFilters
=
size
;
return
res
;
return
res
;
}
}
...
@@ -408,7 +417,8 @@ static bool functionToJson(const void* obj, cJSON* jFunc) {
...
@@ -408,7 +417,8 @@ static bool functionToJson(const void* obj, cJSON* jFunc) {
const
tExprNode
*
exprInfo
=
(
const
tExprNode
*
)
obj
;
const
tExprNode
*
exprInfo
=
(
const
tExprNode
*
)
obj
;
bool
res
=
cJSON_AddStringToObject
(
jFunc
,
jkFunctionName
,
exprInfo
->
_function
.
functionName
);
bool
res
=
cJSON_AddStringToObject
(
jFunc
,
jkFunctionName
,
exprInfo
->
_function
.
functionName
);
if
(
res
&&
NULL
!=
exprInfo
->
_function
.
pChild
)
{
if
(
res
&&
NULL
!=
exprInfo
->
_function
.
pChild
)
{
res
=
addRawArray
(
jFunc
,
jkFunctionChild
,
exprNodeToJson
,
exprInfo
->
_function
.
pChild
,
sizeof
(
tExprNode
*
),
exprInfo
->
_function
.
num
);
res
=
addRawArray
(
jFunc
,
jkFunctionChild
,
exprNodeToJson
,
exprInfo
->
_function
.
pChild
,
sizeof
(
tExprNode
*
),
exprInfo
->
_function
.
num
);
}
}
return
res
;
return
res
;
}
}
...
@@ -420,7 +430,8 @@ static bool functionFromJson(const cJSON* json, void* obj) {
...
@@ -420,7 +430,8 @@ static bool functionFromJson(const cJSON* json, void* obj) {
if
(
NULL
==
exprInfo
->
_function
.
pChild
)
{
if
(
NULL
==
exprInfo
->
_function
.
pChild
)
{
return
false
;
return
false
;
}
}
return
fromRawArrayWithAlloc
(
json
,
jkFunctionChild
,
exprNodeFromJson
,
(
void
**
)
exprInfo
->
_function
.
pChild
,
sizeof
(
tExprNode
*
),
&
exprInfo
->
_function
.
num
);
return
fromRawArrayWithAlloc
(
json
,
jkFunctionChild
,
exprNodeFromJson
,
(
void
**
)
exprInfo
->
_function
.
pChild
,
sizeof
(
tExprNode
*
),
&
exprInfo
->
_function
.
num
);
}
}
static
const
char
*
jkVariantType
=
"Type"
;
static
const
char
*
jkVariantType
=
"Type"
;
...
@@ -435,7 +446,7 @@ static bool variantToJson(const void* obj, cJSON* jVar) {
...
@@ -435,7 +446,7 @@ static bool variantToJson(const void* obj, cJSON* jVar) {
res
=
cJSON_AddNumberToObject
(
jVar
,
jkVariantLen
,
var
->
nLen
);
res
=
cJSON_AddNumberToObject
(
jVar
,
jkVariantLen
,
var
->
nLen
);
}
}
if
(
res
)
{
if
(
res
)
{
if
(
0
/* in */
)
{
if
(
0
/* in */
)
{
res
=
addArray
(
jVar
,
jkVariantvalues
,
variantToJson
,
var
->
arr
);
res
=
addArray
(
jVar
,
jkVariantvalues
,
variantToJson
,
var
->
arr
);
}
else
if
(
IS_NUMERIC_TYPE
(
var
->
nType
))
{
}
else
if
(
IS_NUMERIC_TYPE
(
var
->
nType
))
{
res
=
cJSON_AddNumberToObject
(
jVar
,
jkVariantValue
,
var
->
d
);
res
=
cJSON_AddNumberToObject
(
jVar
,
jkVariantValue
,
var
->
d
);
...
@@ -450,7 +461,7 @@ static bool variantFromJson(const cJSON* json, void* obj) {
...
@@ -450,7 +461,7 @@ static bool variantFromJson(const cJSON* json, void* obj) {
SVariant
*
var
=
(
SVariant
*
)
obj
;
SVariant
*
var
=
(
SVariant
*
)
obj
;
var
->
nType
=
getNumber
(
json
,
jkVariantType
);
var
->
nType
=
getNumber
(
json
,
jkVariantType
);
var
->
nLen
=
getNumber
(
json
,
jkVariantLen
);
var
->
nLen
=
getNumber
(
json
,
jkVariantLen
);
if
(
0
/* in */
)
{
if
(
0
/* in */
)
{
return
fromArray
(
json
,
jkVariantvalues
,
variantFromJson
,
&
var
->
arr
,
sizeof
(
SVariant
));
return
fromArray
(
json
,
jkVariantvalues
,
variantFromJson
,
&
var
->
arr
,
sizeof
(
SVariant
));
}
else
if
(
IS_NUMERIC_TYPE
(
var
->
nType
))
{
}
else
if
(
IS_NUMERIC_TYPE
(
var
->
nType
))
{
var
->
d
=
getNumber
(
json
,
jkVariantValue
);
var
->
d
=
getNumber
(
json
,
jkVariantValue
);
...
@@ -502,7 +513,8 @@ static bool exprNodeFromJson(const cJSON* json, void* obj) {
...
@@ -502,7 +513,8 @@ static bool exprNodeFromJson(const cJSON* json, void* obj) {
case
TEXPR_FUNCTION_NODE
:
case
TEXPR_FUNCTION_NODE
:
return
fromObject
(
json
,
jkExprNodeFunction
,
functionFromJson
,
exprInfo
,
false
);
return
fromObject
(
json
,
jkExprNodeFunction
,
functionFromJson
,
exprInfo
,
false
);
case
TEXPR_COL_NODE
:
case
TEXPR_COL_NODE
:
return
fromObjectWithAlloc
(
json
,
jkExprNodeColumn
,
schemaFromJson
,
(
void
**
)
&
exprInfo
->
pSchema
,
sizeof
(
SSchema
),
false
);
return
fromObjectWithAlloc
(
json
,
jkExprNodeColumn
,
schemaFromJson
,
(
void
**
)
&
exprInfo
->
pSchema
,
sizeof
(
SSchema
),
false
);
case
TEXPR_VALUE_NODE
:
case
TEXPR_VALUE_NODE
:
return
fromObject
(
json
,
jkExprNodeValue
,
variantFromJson
,
exprInfo
->
pVal
,
false
);
return
fromObject
(
json
,
jkExprNodeValue
,
variantFromJson
,
exprInfo
->
pVal
,
false
);
default:
default:
...
@@ -535,7 +547,8 @@ static bool sqlExprFromJson(const cJSON* json, void* obj) {
...
@@ -535,7 +547,8 @@ static bool sqlExprFromJson(const cJSON* json, void* obj) {
SSqlExpr
*
expr
=
(
SSqlExpr
*
)
obj
;
SSqlExpr
*
expr
=
(
SSqlExpr
*
)
obj
;
bool
res
=
fromObject
(
json
,
jkSqlExprSchema
,
schemaFromJson
,
&
expr
->
resSchema
,
false
);
bool
res
=
fromObject
(
json
,
jkSqlExprSchema
,
schemaFromJson
,
&
expr
->
resSchema
,
false
);
if
(
res
)
{
if
(
res
)
{
res
=
fromRawArrayWithAlloc
(
json
,
jkSqlExprColumns
,
columnFromJson
,
(
void
**
)
&
expr
->
pColumns
,
sizeof
(
SColumn
),
&
expr
->
numOfCols
);
res
=
fromRawArrayWithAlloc
(
json
,
jkSqlExprColumns
,
columnFromJson
,
(
void
**
)
&
expr
->
pColumns
,
sizeof
(
SColumn
),
&
expr
->
numOfCols
);
}
}
if
(
res
)
{
if
(
res
)
{
expr
->
interBytes
=
getNumber
(
json
,
jkSqlExprInterBytes
);
expr
->
interBytes
=
getNumber
(
json
,
jkSqlExprInterBytes
);
...
@@ -564,7 +577,8 @@ static bool exprInfoFromJson(const cJSON* json, void* obj) {
...
@@ -564,7 +577,8 @@ static bool exprInfoFromJson(const cJSON* json, void* obj) {
SExprInfo
*
exprInfo
=
(
SExprInfo
*
)
obj
;
SExprInfo
*
exprInfo
=
(
SExprInfo
*
)
obj
;
bool
res
=
fromObject
(
json
,
jkExprInfoBase
,
sqlExprFromJson
,
&
exprInfo
->
base
,
true
);
bool
res
=
fromObject
(
json
,
jkExprInfoBase
,
sqlExprFromJson
,
&
exprInfo
->
base
,
true
);
if
(
res
)
{
if
(
res
)
{
res
=
fromObjectWithAlloc
(
json
,
jkExprInfoExpr
,
exprNodeFromJson
,
(
void
**
)
&
exprInfo
->
pExpr
,
sizeof
(
tExprNode
),
true
);
res
=
fromObjectWithAlloc
(
json
,
jkExprInfoExpr
,
exprNodeFromJson
,
(
void
**
)
&
exprInfo
->
pExpr
,
sizeof
(
tExprNode
),
true
);
}
}
return
res
;
return
res
;
}
}
...
@@ -576,12 +590,12 @@ static bool timeWindowToJson(const void* obj, cJSON* json) {
...
@@ -576,12 +590,12 @@ static bool timeWindowToJson(const void* obj, cJSON* json) {
const
STimeWindow
*
win
=
(
const
STimeWindow
*
)
obj
;
const
STimeWindow
*
win
=
(
const
STimeWindow
*
)
obj
;
char
tmp
[
40
]
=
{
0
};
char
tmp
[
40
]
=
{
0
};
snprintf
(
tmp
,
tListLen
(
tmp
),
"%"
PRId64
,
win
->
skey
);
snprintf
(
tmp
,
tListLen
(
tmp
),
"%"
PRId64
,
win
->
skey
);
bool
res
=
cJSON_AddStringToObject
(
json
,
jkTimeWindowStartKey
,
tmp
);
bool
res
=
cJSON_AddStringToObject
(
json
,
jkTimeWindowStartKey
,
tmp
);
if
(
res
)
{
if
(
res
)
{
memset
(
tmp
,
0
,
tListLen
(
tmp
));
memset
(
tmp
,
0
,
tListLen
(
tmp
));
snprintf
(
tmp
,
tListLen
(
tmp
),
"%"
PRId64
,
win
->
ekey
);
snprintf
(
tmp
,
tListLen
(
tmp
),
"%"
PRId64
,
win
->
ekey
);
res
=
cJSON_AddStringToObject
(
json
,
jkTimeWindowEndKey
,
tmp
);
res
=
cJSON_AddStringToObject
(
json
,
jkTimeWindowEndKey
,
tmp
);
}
}
return
res
;
return
res
;
...
@@ -604,7 +618,7 @@ static bool scanNodeToJson(const void* obj, cJSON* json) {
...
@@ -604,7 +618,7 @@ static bool scanNodeToJson(const void* obj, cJSON* json) {
const
SScanPhyNode
*
pNode
=
(
const
SScanPhyNode
*
)
obj
;
const
SScanPhyNode
*
pNode
=
(
const
SScanPhyNode
*
)
obj
;
char
uid
[
40
]
=
{
0
};
char
uid
[
40
]
=
{
0
};
snprintf
(
uid
,
tListLen
(
uid
),
"%"
PRIu64
,
pNode
->
uid
);
snprintf
(
uid
,
tListLen
(
uid
),
"%"
PRIu64
,
pNode
->
uid
);
bool
res
=
cJSON_AddStringToObject
(
json
,
jkScanNodeTableId
,
uid
);
bool
res
=
cJSON_AddStringToObject
(
json
,
jkScanNodeTableId
,
uid
);
if
(
res
)
{
if
(
res
)
{
...
@@ -758,7 +772,7 @@ static const char* jkNodeTaskId = "TaskId";
...
@@ -758,7 +772,7 @@ static const char* jkNodeTaskId = "TaskId";
static
const
char
*
jkNodeTaskSchedId
=
"SchedId"
;
static
const
char
*
jkNodeTaskSchedId
=
"SchedId"
;
static
bool
queryNodeAddrToJson
(
const
void
*
obj
,
cJSON
*
json
)
{
static
bool
queryNodeAddrToJson
(
const
void
*
obj
,
cJSON
*
json
)
{
const
SQueryNodeAddr
*
pAddr
=
(
const
SQueryNodeAddr
*
)
obj
;
const
SQueryNodeAddr
*
pAddr
=
(
const
SQueryNodeAddr
*
)
obj
;
bool
res
=
cJSON_AddNumberToObject
(
json
,
jkNodeAddrId
,
pAddr
->
nodeId
);
bool
res
=
cJSON_AddNumberToObject
(
json
,
jkNodeAddrId
,
pAddr
->
nodeId
);
if
(
res
)
{
if
(
res
)
{
...
@@ -772,7 +786,7 @@ static bool queryNodeAddrToJson(const void* obj, cJSON* json) {
...
@@ -772,7 +786,7 @@ static bool queryNodeAddrToJson(const void* obj, cJSON* json) {
}
}
static
bool
queryNodeAddrFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
static
bool
queryNodeAddrFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
SQueryNodeAddr
*
pAddr
=
(
SQueryNodeAddr
*
)
obj
;
SQueryNodeAddr
*
pAddr
=
(
SQueryNodeAddr
*
)
obj
;
pAddr
->
nodeId
=
getNumber
(
json
,
jkNodeAddrId
);
pAddr
->
nodeId
=
getNumber
(
json
,
jkNodeAddrId
);
pAddr
->
epSet
.
inUse
=
getNumber
(
json
,
jkNodeAddrInUse
);
pAddr
->
epSet
.
inUse
=
getNumber
(
json
,
jkNodeAddrInUse
);
...
@@ -784,12 +798,12 @@ static bool queryNodeAddrFromJson(const cJSON* json, void* obj) {
...
@@ -784,12 +798,12 @@ static bool queryNodeAddrFromJson(const cJSON* json, void* obj) {
}
}
static
bool
nodeAddrToJson
(
const
void
*
obj
,
cJSON
*
json
)
{
static
bool
nodeAddrToJson
(
const
void
*
obj
,
cJSON
*
json
)
{
const
SDownstreamSource
*
pSource
=
(
const
SDownstreamSource
*
)
obj
;
const
SDownstreamSource
*
pSource
=
(
const
SDownstreamSource
*
)
obj
;
bool
res
=
cJSON_AddNumberToObject
(
json
,
jkNodeTaskId
,
pSource
->
taskId
);
bool
res
=
cJSON_AddNumberToObject
(
json
,
jkNodeTaskId
,
pSource
->
taskId
);
if
(
res
)
{
if
(
res
)
{
char
t
[
30
]
=
{
0
};
char
t
[
30
]
=
{
0
};
snprintf
(
t
,
tListLen
(
t
),
"%"
PRIu64
,
pSource
->
schedId
);
snprintf
(
t
,
tListLen
(
t
),
"%"
PRIu64
,
pSource
->
schedId
);
res
=
cJSON_AddStringToObject
(
json
,
jkNodeTaskSchedId
,
t
);
res
=
cJSON_AddStringToObject
(
json
,
jkNodeTaskSchedId
,
t
);
}
}
...
@@ -815,7 +829,8 @@ static bool exchangeNodeToJson(const void* obj, cJSON* json) {
...
@@ -815,7 +829,8 @@ static bool exchangeNodeToJson(const void* obj, cJSON* json) {
const
SExchangePhyNode
*
exchange
=
(
const
SExchangePhyNode
*
)
obj
;
const
SExchangePhyNode
*
exchange
=
(
const
SExchangePhyNode
*
)
obj
;
bool
res
=
cJSON_AddNumberToObject
(
json
,
jkExchangeNodeSrcTemplateId
,
exchange
->
srcTemplateId
);
bool
res
=
cJSON_AddNumberToObject
(
json
,
jkExchangeNodeSrcTemplateId
,
exchange
->
srcTemplateId
);
if
(
res
)
{
if
(
res
)
{
res
=
addRawArray
(
json
,
jkExchangeNodeSrcEndPoints
,
nodeAddrToJson
,
exchange
->
pSrcEndPoints
->
pData
,
sizeof
(
SDownstreamSource
),
taosArrayGetSize
(
exchange
->
pSrcEndPoints
));
res
=
addRawArray
(
json
,
jkExchangeNodeSrcEndPoints
,
nodeAddrToJson
,
exchange
->
pSrcEndPoints
->
pData
,
sizeof
(
SDownstreamSource
),
taosArrayGetSize
(
exchange
->
pSrcEndPoints
));
}
}
return
res
;
return
res
;
}
}
...
@@ -823,7 +838,8 @@ static bool exchangeNodeToJson(const void* obj, cJSON* json) {
...
@@ -823,7 +838,8 @@ static bool exchangeNodeToJson(const void* obj, cJSON* json) {
static
bool
exchangeNodeFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
static
bool
exchangeNodeFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
SExchangePhyNode
*
exchange
=
(
SExchangePhyNode
*
)
obj
;
SExchangePhyNode
*
exchange
=
(
SExchangePhyNode
*
)
obj
;
exchange
->
srcTemplateId
=
getNumber
(
json
,
jkExchangeNodeSrcTemplateId
);
exchange
->
srcTemplateId
=
getNumber
(
json
,
jkExchangeNodeSrcTemplateId
);
return
fromInlineArray
(
json
,
jkExchangeNodeSrcEndPoints
,
nodeAddrFromJson
,
&
exchange
->
pSrcEndPoints
,
sizeof
(
SDownstreamSource
));
return
fromInlineArray
(
json
,
jkExchangeNodeSrcEndPoints
,
nodeAddrFromJson
,
&
exchange
->
pSrcEndPoints
,
sizeof
(
SDownstreamSource
));
}
}
static
bool
specificPhyNodeToJson
(
const
void
*
obj
,
cJSON
*
json
)
{
static
bool
specificPhyNodeToJson
(
const
void
*
obj
,
cJSON
*
json
)
{
...
@@ -933,7 +949,7 @@ static bool phyNodeToJson(const void* obj, cJSON* jNode) {
...
@@ -933,7 +949,7 @@ static bool phyNodeToJson(const void* obj, cJSON* jNode) {
}
}
static
bool
phyNodeFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
static
bool
phyNodeFromJson
(
const
cJSON
*
json
,
void
*
obj
)
{
SPhyNode
*
node
=
(
SPhyNode
*
)
obj
;
SPhyNode
*
node
=
(
SPhyNode
*
)
obj
;
node
->
info
.
type
=
getNumber
(
json
,
jkPnodeType
);
node
->
info
.
type
=
getNumber
(
json
,
jkPnodeType
);
node
->
info
.
name
=
opTypeToOpName
(
node
->
info
.
type
);
node
->
info
.
name
=
opTypeToOpName
(
node
->
info
.
type
);
...
@@ -1034,7 +1050,7 @@ static bool subplanIdToJson(const void* obj, cJSON* jId) {
...
@@ -1034,7 +1050,7 @@ static bool subplanIdToJson(const void* obj, cJSON* jId) {
const
SSubplanId
*
id
=
(
const
SSubplanId
*
)
obj
;
const
SSubplanId
*
id
=
(
const
SSubplanId
*
)
obj
;
char
ids
[
40
]
=
{
0
};
char
ids
[
40
]
=
{
0
};
snprintf
(
ids
,
tListLen
(
ids
),
"%"
PRIu64
,
id
->
queryId
);
snprintf
(
ids
,
tListLen
(
ids
),
"%"
PRIu64
,
id
->
queryId
);
bool
res
=
cJSON_AddStringToObject
(
jId
,
jkIdQueryId
,
ids
);
bool
res
=
cJSON_AddStringToObject
(
jId
,
jkIdQueryId
,
ids
);
if
(
res
)
{
if
(
res
)
{
...
@@ -1094,7 +1110,8 @@ static SSubplan* subplanFromJson(const cJSON* json) {
...
@@ -1094,7 +1110,8 @@ static SSubplan* subplanFromJson(const cJSON* json) {
}
}
if
(
res
)
{
if
(
res
)
{
res
=
fromObjectWithAlloc
(
json
,
jkSubplanDataSink
,
dataSinkFromJson
,
(
void
**
)
&
subplan
->
pDataSink
,
sizeof
(
SDataSink
),
false
);
res
=
fromObjectWithAlloc
(
json
,
jkSubplanDataSink
,
dataSinkFromJson
,
(
void
**
)
&
subplan
->
pDataSink
,
sizeof
(
SDataSink
),
false
);
}
}
if
(
!
res
)
{
if
(
!
res
)
{
...
@@ -1137,15 +1154,15 @@ int32_t stringToSubplan(const char* str, SSubplan** subplan) {
...
@@ -1137,15 +1154,15 @@ int32_t stringToSubplan(const char* str, SSubplan** subplan) {
cJSON
*
qDagToJson
(
const
SQueryDag
*
pDag
)
{
cJSON
*
qDagToJson
(
const
SQueryDag
*
pDag
)
{
cJSON
*
pRoot
=
cJSON_CreateObject
();
cJSON
*
pRoot
=
cJSON_CreateObject
();
if
(
pRoot
==
NULL
)
{
if
(
pRoot
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
cJSON_AddNumberToObject
(
pRoot
,
"Number"
,
pDag
->
numOfSubplans
);
cJSON_AddNumberToObject
(
pRoot
,
"Number"
,
pDag
->
numOfSubplans
);
cJSON_AddNumberToObject
(
pRoot
,
"QueryId"
,
pDag
->
queryId
);
cJSON_AddNumberToObject
(
pRoot
,
"QueryId"
,
pDag
->
queryId
);
cJSON
*
pLevels
=
cJSON_CreateArray
();
cJSON
*
pLevels
=
cJSON_CreateArray
();
if
(
pLevels
==
NULL
)
{
if
(
pLevels
==
NULL
)
{
cJSON_Delete
(
pRoot
);
cJSON_Delete
(
pRoot
);
return
NULL
;
return
NULL
;
}
}
...
@@ -1153,19 +1170,19 @@ cJSON* qDagToJson(const SQueryDag* pDag) {
...
@@ -1153,19 +1170,19 @@ cJSON* qDagToJson(const SQueryDag* pDag) {
cJSON_AddItemToObject
(
pRoot
,
"Subplans"
,
pLevels
);
cJSON_AddItemToObject
(
pRoot
,
"Subplans"
,
pLevels
);
size_t
level
=
taosArrayGetSize
(
pDag
->
pSubplans
);
size_t
level
=
taosArrayGetSize
(
pDag
->
pSubplans
);
for
(
size_t
i
=
0
;
i
<
level
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
level
;
i
++
)
{
const
SArray
*
pSubplans
=
(
const
SArray
*
)
taosArrayGetP
(
pDag
->
pSubplans
,
i
);
const
SArray
*
pSubplans
=
(
const
SArray
*
)
taosArrayGetP
(
pDag
->
pSubplans
,
i
);
size_t
num
=
taosArrayGetSize
(
pSubplans
);
size_t
num
=
taosArrayGetSize
(
pSubplans
);
cJSON
*
plansOneLevel
=
cJSON_CreateArray
();
cJSON
*
plansOneLevel
=
cJSON_CreateArray
();
if
(
plansOneLevel
==
NULL
)
{
if
(
plansOneLevel
==
NULL
)
{
cJSON_Delete
(
pRoot
);
cJSON_Delete
(
pRoot
);
return
NULL
;
return
NULL
;
}
}
cJSON_AddItemToArray
(
pLevels
,
plansOneLevel
);
cJSON_AddItemToArray
(
pLevels
,
plansOneLevel
);
for
(
size_t
j
=
0
;
j
<
num
;
j
++
)
{
for
(
size_t
j
=
0
;
j
<
num
;
j
++
)
{
cJSON
*
pSubplan
=
subplanToJson
((
const
SSubplan
*
)
taosArrayGetP
(
pSubplans
,
j
));
cJSON
*
pSubplan
=
subplanToJson
((
const
SSubplan
*
)
taosArrayGetP
(
pSubplans
,
j
));
if
(
pSubplan
==
NULL
)
{
if
(
pSubplan
==
NULL
)
{
cJSON_Delete
(
pRoot
);
cJSON_Delete
(
pRoot
);
return
NULL
;
return
NULL
;
}
}
...
@@ -1183,22 +1200,22 @@ char* qDagToString(const SQueryDag* pDag) {
...
@@ -1183,22 +1200,22 @@ char* qDagToString(const SQueryDag* pDag) {
SQueryDag
*
qJsonToDag
(
const
cJSON
*
pRoot
)
{
SQueryDag
*
qJsonToDag
(
const
cJSON
*
pRoot
)
{
SQueryDag
*
pDag
=
malloc
(
sizeof
(
SQueryDag
));
SQueryDag
*
pDag
=
malloc
(
sizeof
(
SQueryDag
));
if
(
pDag
==
NULL
)
{
if
(
pDag
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
pDag
->
numOfSubplans
=
cJSON_GetNumberValue
(
cJSON_GetObjectItem
(
pRoot
,
"Number"
));
pDag
->
numOfSubplans
=
cJSON_GetNumberValue
(
cJSON_GetObjectItem
(
pRoot
,
"Number"
));
pDag
->
queryId
=
cJSON_GetNumberValue
(
cJSON_GetObjectItem
(
pRoot
,
"QueryId"
));
pDag
->
queryId
=
cJSON_GetNumberValue
(
cJSON_GetObjectItem
(
pRoot
,
"QueryId"
));
pDag
->
pSubplans
=
taosArrayInit
(
0
,
sizeof
(
SArray
));
pDag
->
pSubplans
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
if
(
pDag
->
pSubplans
==
NULL
)
{
if
(
pDag
->
pSubplans
==
NULL
)
{
free
(
pDag
);
free
(
pDag
);
return
NULL
;
return
NULL
;
}
}
cJSON
*
pLevels
=
cJSON_GetObjectItem
(
pRoot
,
"Subplans"
);
cJSON
*
pLevels
=
cJSON_GetObjectItem
(
pRoot
,
"Subplans"
);
int
level
=
cJSON_GetArraySize
(
pLevels
);
int
level
=
cJSON_GetArraySize
(
pLevels
);
for
(
int
i
=
0
;
i
<
level
;
i
++
)
{
for
(
int
i
=
0
;
i
<
level
;
i
++
)
{
SArray
*
plansOneLevel
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
SArray
*
plansOneLevel
=
taosArrayInit
(
0
,
sizeof
(
void
*
));
if
(
plansOneLevel
==
NULL
)
{
if
(
plansOneLevel
==
NULL
)
{
for
(
int
j
=
0
;
j
<
i
;
j
++
)
{
for
(
int
j
=
0
;
j
<
i
;
j
++
)
{
taosArrayDestroy
(
taosArrayGetP
(
pDag
->
pSubplans
,
j
));
taosArrayDestroy
(
taosArrayGetP
(
pDag
->
pSubplans
,
j
));
}
}
taosArrayDestroy
(
pDag
->
pSubplans
);
taosArrayDestroy
(
pDag
->
pSubplans
);
...
@@ -1207,12 +1224,12 @@ SQueryDag* qJsonToDag(const cJSON* pRoot) {
...
@@ -1207,12 +1224,12 @@ SQueryDag* qJsonToDag(const cJSON* pRoot) {
}
}
cJSON
*
pItem
=
cJSON_GetArrayItem
(
pLevels
,
i
);
cJSON
*
pItem
=
cJSON_GetArrayItem
(
pLevels
,
i
);
int
sz
=
cJSON_GetArraySize
(
pItem
);
int
sz
=
cJSON_GetArraySize
(
pItem
);
for
(
int
j
=
0
;
j
<
sz
;
j
++
)
{
for
(
int
j
=
0
;
j
<
sz
;
j
++
)
{
cJSON
*
pSubplanJson
=
cJSON_GetArrayItem
(
pItem
,
j
);
cJSON
*
pSubplanJson
=
cJSON_GetArrayItem
(
pItem
,
j
);
SSubplan
*
pSubplan
=
subplanFromJson
(
pSubplanJson
);
SSubplan
*
pSubplan
=
subplanFromJson
(
pSubplanJson
);
taosArrayPush
(
plansOneLevel
,
&
pSubplan
);
taosArrayPush
(
plansOneLevel
,
&
pSubplan
);
}
}
taosArrayPush
(
pDag
->
pSubplans
,
plansOneLevel
);
taosArrayPush
(
pDag
->
pSubplans
,
&
plansOneLevel
);
}
}
return
pDag
;
return
pDag
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录