planner.h 2.1 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
#include "plannodes.h"
24
#include "taos.h"
X
Xiaoyu Wang 已提交
25 26 27

typedef struct SPlanContext {
  uint64_t queryId;
X
Xiaoyu Wang 已提交
28
  int32_t acctId;
X
Xiaoyu Wang 已提交
29
  SEpSet mgmtEpSet;
X
Xiaoyu Wang 已提交
30
  SNode* pAstRoot;
X
Xiaoyu Wang 已提交
31
  bool topicQuery;
32
  bool streamQuery;
L
Liu Jicong 已提交
33
  bool rSmaQuery;
D
dapan1121 已提交
34
  bool showRewrite;
X
Xiaoyu Wang 已提交
35 36
  int8_t triggerType;
  int64_t watermark;
37
  bool isStmtQuery;
X
Xiaoyu Wang 已提交
38 39
  void* pTransporter;
  struct SCatalog* pCatalog;
X
Xiaoyu Wang 已提交
40 41
  char* pMsg;
  int32_t msgLen;
X
Xiaoyu Wang 已提交
42 43 44
} SPlanContext;

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

// Set datasource of this subplan, multiple calls may be made to a subplan.
X
Xiaoyu Wang 已提交
48 49 50 51
// @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 已提交
52

D
dapan1121 已提交
53
int32_t qStmtBindParam(SQueryPlan* pPlan, TAOS_MULTI_BIND* pParams, int32_t colIdx);
54

X
Xiaoyu Wang 已提交
55
// Convert to subplan to string for the scheduler to send to the executor
X
Xiaoyu Wang 已提交
56 57
int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen);
int32_t qStringToSubplan(const char* pStr, SSubplan** pSubplan);
X
Xiaoyu Wang 已提交
58 59 60 61 62 63

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

void qDestroyQueryPlan(SQueryPlan* pPlan);

H
Hongze Cheng 已提交
64 65 66 67
#ifdef __cplusplus
}
#endif

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