planner.h 1.7 KB
Newer Older
H
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef _TD_PLANNER_H_
#define _TD_PLANNER_H_

#ifdef __cplusplus
extern "C" {
#endif

X
Xiaoyu Wang 已提交
23 24 25 26
#include "plannodes.h"

typedef struct SPlanContext {
  uint64_t queryId;
X
Xiaoyu Wang 已提交
27
  int32_t acctId;
X
Xiaoyu Wang 已提交
28 29 30 31
  SNode* pAstRoot;
} SPlanContext;

// Create the physical plan for the query, according to the AST.
32
int32_t qCreateQueryPlan(SPlanContext* pCxt, SQueryPlan** pPlan, SArray* pExecNodeList);
X
Xiaoyu Wang 已提交
33 34

// Set datasource of this subplan, multiple calls may be made to a subplan.
X
Xiaoyu Wang 已提交
35 36 37 38
// @pSubplan subplan to be schedule
// @groupId id of a group of datasource subplans of this @pSubplan
// @pSource one execution location of this group of datasource subplans 
int32_t qSetSubplanExecutionNode(SSubplan* pSubplan, int32_t groupId, SDownstreamSourceNode* pSource);
X
Xiaoyu Wang 已提交
39 40

// Convert to subplan to string for the scheduler to send to the executor
X
Xiaoyu Wang 已提交
41 42
int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen);
int32_t qStringToSubplan(const char* pStr, SSubplan** pSubplan);
X
Xiaoyu Wang 已提交
43 44 45 46 47 48

char* qQueryPlanToString(const SQueryPlan* pPlan);
SQueryPlan* qStringToQueryPlan(const char* pStr);

void qDestroyQueryPlan(SQueryPlan* pPlan);

H
Hongze Cheng 已提交
49 50 51 52
#ifdef __cplusplus
}
#endif

L
Liu Jicong 已提交
53
#endif /*_TD_PLANNER_H_*/