planner.h 1.9 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
  SEpSet mgmtEpSet;
X
Xiaoyu Wang 已提交
29
  SNode* pAstRoot;
X
Xiaoyu Wang 已提交
30
  bool topicQuery;
31
  bool streamQuery;
D
dapan1121 已提交
32
  bool showRewrite;
X
Xiaoyu Wang 已提交
33 34
  int8_t triggerType;
  int64_t watermark;
X
Xiaoyu Wang 已提交
35 36 37
} SPlanContext;

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

// Set datasource of this subplan, multiple calls may be made to a subplan.
X
Xiaoyu Wang 已提交
41 42 43 44
// @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 已提交
45 46

// Convert to subplan to string for the scheduler to send to the executor
X
Xiaoyu Wang 已提交
47 48
int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen);
int32_t qStringToSubplan(const char* pStr, SSubplan** pSubplan);
X
Xiaoyu Wang 已提交
49 50 51 52 53 54

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

void qDestroyQueryPlan(SQueryPlan* pPlan);

H
Hongze Cheng 已提交
55 56 57 58
#ifdef __cplusplus
}
#endif

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