Merge pull request #9717 from taosdata/feature/3.0_wxy
TD-12678 datasink to json
This commit is contained in:
commit
dcda885a36
|
@ -198,6 +198,29 @@ static bool schemaFromJson(const cJSON* json, void* obj) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const char* jkDataBlockSchemaSlotSchema = "SlotSchema";
|
||||||
|
static const char* jkDataBlockSchemaResultRowSize = "resultRowSize";
|
||||||
|
static const char* jkDataBlockSchemaPrecision = "Precision";
|
||||||
|
|
||||||
|
static bool dataBlockSchemaToJson(const void* obj, cJSON* json) {
|
||||||
|
const SDataBlockSchema* schema = (const SDataBlockSchema*)obj;
|
||||||
|
bool res = addRawArray(json, jkDataBlockSchemaSlotSchema, schemaToJson, schema->pSchema, sizeof(SSlotSchema), schema->numOfCols);
|
||||||
|
if (res) {
|
||||||
|
res = cJSON_AddNumberToObject(json, jkDataBlockSchemaResultRowSize, schema->resultRowSize);
|
||||||
|
}
|
||||||
|
if (res) {
|
||||||
|
res = cJSON_AddNumberToObject(json, jkDataBlockSchemaPrecision, schema->precision);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool dataBlockSchemaFromJson(const cJSON* json, void* obj) {
|
||||||
|
SDataBlockSchema* schema = (SDataBlockSchema*)obj;
|
||||||
|
schema->resultRowSize = getNumber(json, jkDataBlockSchemaResultRowSize);
|
||||||
|
schema->precision = getNumber(json, jkDataBlockSchemaPrecision);
|
||||||
|
return fromRawArray(json, jkDataBlockSchemaSlotSchema, schemaFromJson, schema->pSchema, sizeof(SSlotSchema), &schema->numOfCols);
|
||||||
|
}
|
||||||
|
|
||||||
static const char* jkColumnFilterInfoLowerRelOptr = "LowerRelOptr";
|
static const char* jkColumnFilterInfoLowerRelOptr = "LowerRelOptr";
|
||||||
static const char* jkColumnFilterInfoUpperRelOptr = "UpperRelOptr";
|
static const char* jkColumnFilterInfoUpperRelOptr = "UpperRelOptr";
|
||||||
static const char* jkColumnFilterInfoFilterstr = "Filterstr";
|
static const char* jkColumnFilterInfoFilterstr = "Filterstr";
|
||||||
|
@ -708,7 +731,7 @@ static bool phyNodeToJson(const void* obj, cJSON* jNode) {
|
||||||
res = addArray(jNode, jkPnodeConditions, exprInfoToJson, phyNode->pConditions);
|
res = addArray(jNode, jkPnodeConditions, exprInfoToJson, phyNode->pConditions);
|
||||||
}
|
}
|
||||||
if (res) {
|
if (res) {
|
||||||
res = addRawArray(jNode, jkPnodeSchema, schemaToJson, phyNode->targetSchema.pSchema, sizeof(SSlotSchema), phyNode->targetSchema.numOfCols);
|
res = addObject(jNode, jkPnodeSchema, dataBlockSchemaToJson, &phyNode->targetSchema);
|
||||||
}
|
}
|
||||||
if (res) {
|
if (res) {
|
||||||
res = addArray(jNode, jkPnodeChildren, phyNodeToJson, phyNode->pChildren);
|
res = addArray(jNode, jkPnodeChildren, phyNodeToJson, phyNode->pChildren);
|
||||||
|
@ -728,7 +751,7 @@ static bool phyNodeFromJson(const cJSON* json, void* obj) {
|
||||||
res = fromArray(json, jkPnodeConditions, exprInfoFromJson, &node->pConditions, sizeof(SExprInfo));
|
res = fromArray(json, jkPnodeConditions, exprInfoFromJson, &node->pConditions, sizeof(SExprInfo));
|
||||||
}
|
}
|
||||||
if (res) {
|
if (res) {
|
||||||
res = fromRawArray(json, jkPnodeSchema, schemaFromJson, node->targetSchema.pSchema, sizeof(SSlotSchema), &node->targetSchema.numOfCols);
|
res = fromObject(json, jkPnodeSchema, dataBlockSchemaFromJson, &node->targetSchema, true);
|
||||||
}
|
}
|
||||||
if (res) {
|
if (res) {
|
||||||
res = fromArray(json, jkPnodeChildren, phyNodeFromJson, &node->pChildren, sizeof(SSlotSchema));
|
res = fromArray(json, jkPnodeChildren, phyNodeFromJson, &node->pChildren, sizeof(SSlotSchema));
|
||||||
|
@ -786,6 +809,7 @@ static bool specificDataSinkFromJson(const cJSON* json, void* obj) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* jkDataSinkName = "Name";
|
static const char* jkDataSinkName = "Name";
|
||||||
|
static const char* jkDataSinkSchema = "Schema";
|
||||||
|
|
||||||
static bool dataSinkToJson(const void* obj, cJSON* json) {
|
static bool dataSinkToJson(const void* obj, cJSON* json) {
|
||||||
const SDataSink* dsink = (const SDataSink*)obj;
|
const SDataSink* dsink = (const SDataSink*)obj;
|
||||||
|
@ -793,6 +817,9 @@ static bool dataSinkToJson(const void* obj, cJSON* json) {
|
||||||
if (res) {
|
if (res) {
|
||||||
res = addObject(json, dsink->info.name, specificDataSinkToJson, dsink);
|
res = addObject(json, dsink->info.name, specificDataSinkToJson, dsink);
|
||||||
}
|
}
|
||||||
|
if (res) {
|
||||||
|
res = addObject(json, jkDataSinkSchema, dataBlockSchemaToJson, &dsink->schema);
|
||||||
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -800,7 +827,11 @@ static bool dataSinkFromJson(const cJSON* json, void* obj) {
|
||||||
SDataSink* dsink = (SDataSink*)obj;
|
SDataSink* dsink = (SDataSink*)obj;
|
||||||
dsink->info.name = getString(json, jkDataSinkName);
|
dsink->info.name = getString(json, jkDataSinkName);
|
||||||
dsink->info.type = dsinkNameToDsinkType(dsink->info.name);
|
dsink->info.type = dsinkNameToDsinkType(dsink->info.name);
|
||||||
return fromObject(json, dsink->info.name, specificDataSinkFromJson, dsink, true);
|
bool res = fromObject(json, jkDataSinkSchema, dataBlockSchemaFromJson, &dsink->schema, true);
|
||||||
|
if (res) {
|
||||||
|
res = fromObject(json, dsink->info.name, specificDataSinkFromJson, dsink, true);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* jkIdQueryId = "QueryId";
|
static const char* jkIdQueryId = "QueryId";
|
||||||
|
|
Loading…
Reference in New Issue