planner.h 2.3 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
  uint64_t    queryId;
  int32_t     acctId;
  SEpSet      mgmtEpSet;
  SNode*      pAstRoot;
  bool        topicQuery;
  bool        streamQuery;
  bool        rSmaQuery;
  bool        showRewrite;
  int8_t      triggerType;
  int64_t     watermark;
37
  int64_t     deleteMark;
38
  int8_t      igExpired;
X
Xiaoyu Wang 已提交
39 40 41
  char*       pMsg;
  int32_t     msgLen;
  const char* pUser;
42
  bool        sysInfo;
43
  int64_t     allocatorId;
X
Xiaoyu Wang 已提交
44 45 46
} SPlanContext;

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

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

55
void qClearSubplanExecutionNode(SSubplan* pSubplan);
56

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

61 62 63 64
// Convert to subplan to msg for the scheduler to send to the executor
int32_t qSubPlanToMsg(const SSubplan* pSubplan, char** pStr, int32_t* pLen);
int32_t qMsgToSubplan(const char* pStr, int32_t len, SSubplan** pSubplan);

X
Xiaoyu Wang 已提交
65 66 67 68
SQueryPlan* qStringToQueryPlan(const char* pStr);

void qDestroyQueryPlan(SQueryPlan* pPlan);

H
Hongze Cheng 已提交
69 70 71 72
#ifdef __cplusplus
}
#endif

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