TD-12194 Improve the planner interface.
This commit is contained in:
parent
2e507dc8b7
commit
1afa3de4c1
|
@ -138,8 +138,11 @@ typedef struct SQueryDag {
|
||||||
*/
|
*/
|
||||||
int32_t qCreateQueryDag(const struct SQueryStmtInfo* pQueryInfo, struct SEpSet* pQnode, struct SQueryDag** pDag);
|
int32_t qCreateQueryDag(const struct SQueryStmtInfo* pQueryInfo, struct SEpSet* pQnode, struct SQueryDag** pDag);
|
||||||
|
|
||||||
// @eps is an array of SEpAddr structures
|
// Set datasource of this subplan, multiple calls may be made to a subplan.
|
||||||
int32_t qSetSubplanExecutionNode(SSubplan* subplan, SArray* eps);
|
// @subplan subplan to be schedule
|
||||||
|
// @templateId templateId of a group of datasource subplans of this @subplan
|
||||||
|
// @eps Execution location of this group of datasource subplans, is an array of SEpAddr structures
|
||||||
|
int32_t qSetSubplanExecutionNode(SSubplan* subplan, uint64_t templateId, SArray* eps);
|
||||||
|
|
||||||
int32_t qExplainQuery(const struct SQueryStmtInfo* pQueryInfo, struct SEpSet* pQnode, char** str);
|
int32_t qExplainQuery(const struct SQueryStmtInfo* pQueryInfo, struct SEpSet* pQnode, char** str);
|
||||||
|
|
||||||
|
|
|
@ -100,8 +100,9 @@ int32_t queryPlanToString(struct SQueryPlanNode* pQueryNode, char** str);
|
||||||
int32_t queryPlanToSql(struct SQueryPlanNode* pQueryNode, char** sql);
|
int32_t queryPlanToSql(struct SQueryPlanNode* pQueryNode, char** sql);
|
||||||
|
|
||||||
int32_t createDag(SQueryPlanNode* pQueryNode, struct SCatalog* pCatalog, SQueryDag** pDag);
|
int32_t createDag(SQueryPlanNode* pQueryNode, struct SCatalog* pCatalog, SQueryDag** pDag);
|
||||||
|
int32_t setSubplanExecutionNode(SSubplan* subplan, uint64_t templateId, SArray* eps);
|
||||||
int32_t subPlanToString(const SSubplan *pPhyNode, char** str);
|
int32_t subPlanToString(const SSubplan *pPhyNode, char** str);
|
||||||
|
int32_t stringToSubplan(const char* str, SSubplan** subplan);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Destroy the query plan object.
|
* Destroy the query plan object.
|
||||||
|
|
|
@ -19,6 +19,13 @@
|
||||||
#define STORE_CURRENT_SUBPLAN(cxt) SSubplan* _ = cxt->pCurrentSubplan
|
#define STORE_CURRENT_SUBPLAN(cxt) SSubplan* _ = cxt->pCurrentSubplan
|
||||||
#define RECOVERY_CURRENT_SUBPLAN(cxt) cxt->pCurrentSubplan = _
|
#define RECOVERY_CURRENT_SUBPLAN(cxt) cxt->pCurrentSubplan = _
|
||||||
|
|
||||||
|
typedef struct SPlanContext {
|
||||||
|
struct SCatalog* pCatalog;
|
||||||
|
struct SQueryDag* pDag;
|
||||||
|
SSubplan* pCurrentSubplan;
|
||||||
|
SSubplanId nextId;
|
||||||
|
} SPlanContext;
|
||||||
|
|
||||||
static const char* gOpName[] = {
|
static const char* gOpName[] = {
|
||||||
"Unknown",
|
"Unknown",
|
||||||
#define INCLUDE_AS_NAME
|
#define INCLUDE_AS_NAME
|
||||||
|
@ -26,12 +33,14 @@ static const char* gOpName[] = {
|
||||||
#undef INCLUDE_AS_NAME
|
#undef INCLUDE_AS_NAME
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct SPlanContext {
|
int32_t opNameToOpType(const char* name) {
|
||||||
struct SCatalog* pCatalog;
|
for (int32_t i = 1; i < sizeof(gOpName) / sizeof(gOpName[0]); ++i) {
|
||||||
struct SQueryDag* pDag;
|
if (strcmp(name, gOpName[i])) {
|
||||||
SSubplan* pCurrentSubplan;
|
return i;
|
||||||
SSubplanId nextId;
|
}
|
||||||
} SPlanContext;
|
}
|
||||||
|
return OP_Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
static void toDataBlockSchema(SQueryPlanNode* pPlanNode, SDataBlockSchema* dataBlockSchema) {
|
static void toDataBlockSchema(SQueryPlanNode* pPlanNode, SDataBlockSchema* dataBlockSchema) {
|
||||||
SWAP(dataBlockSchema->pSchema, pPlanNode->pSchema, SSchema*);
|
SWAP(dataBlockSchema->pSchema, pPlanNode->pSchema, SSchema*);
|
||||||
|
@ -216,11 +225,6 @@ int32_t createDag(SQueryPlanNode* pQueryNode, struct SCatalog* pCatalog, SQueryD
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t opNameToOpType(const char* name) {
|
int32_t setSubplanExecutionNode(SSubplan* subplan, uint64_t templateId, SArray* eps) {
|
||||||
for (int32_t i = 1; i < sizeof(gOpName) / sizeof(gOpName[0]); ++i) {
|
//todo
|
||||||
if (strcmp(name, gOpName[i])) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return OP_Unknown;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,10 @@ int32_t qCreateQueryDag(const struct SQueryStmtInfo* pQueryInfo, struct SEpSet*
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t qSetSubplanExecutionNode(SSubplan* subplan, uint64_t templateId, SArray* eps) {
|
||||||
|
return setSubplanExecutionNode(subplan, templateId, eps);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t qSubPlanToString(const SSubplan *subplan, char** str) {
|
int32_t qSubPlanToString(const SSubplan *subplan, char** str) {
|
||||||
return subPlanToString(subplan, str);
|
return subPlanToString(subplan, str);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue