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

typedef struct SPlanContext {
X
Xiaoyu Wang 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39
  uint64_t    queryId;
  int32_t     acctId;
  SEpSet      mgmtEpSet;
  SNode*      pAstRoot;
  bool        topicQuery;
  bool        streamQuery;
  bool        rSmaQuery;
  bool        showRewrite;
  int8_t      triggerType;
  int64_t     watermark;
  char*       pMsg;
  int32_t     msgLen;
  const char* pUser;
X
Xiaoyu Wang 已提交
40 41 42
} SPlanContext;

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

// Set datasource of this subplan, multiple calls may be made to a subplan.
X
Xiaoyu Wang 已提交
46 47
// @pSubplan subplan to be schedule
// @groupId id of a group of datasource subplans of this @pSubplan
48
// @pSource one execution location of this group of datasource subplans
X
Xiaoyu Wang 已提交
49
int32_t qSetSubplanExecutionNode(SSubplan* pSubplan, int32_t groupId, SDownstreamSourceNode* pSource);
X
Xiaoyu Wang 已提交
50

51
void qClearSubplanExecutionNode(SSubplan* pSubplan);
52

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

57
char*       qQueryPlanToString(const SQueryPlan* pPlan);
X
Xiaoyu Wang 已提交
58 59 60 61
SQueryPlan* qStringToQueryPlan(const char* pStr);

void qDestroyQueryPlan(SQueryPlan* pPlan);

H
Hongze Cheng 已提交
62 63 64 65
#ifdef __cplusplus
}
#endif

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