plannodes.h 5.9 KB
Newer Older
X
Xiaoyu Wang 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/*
 * 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_PLANN_NODES_H_
#define _TD_PLANN_NODES_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "querynodes.h"
X
Xiaoyu Wang 已提交
24
#include "query.h"
X
Xiaoyu Wang 已提交
25
#include "tname.h"
X
Xiaoyu Wang 已提交
26 27 28 29 30 31 32 33 34 35

typedef struct SLogicNode {
  ENodeType type;
  int32_t id;
  SNodeList* pTargets; // SColumnNode
  SNode* pConditions;
  SNodeList* pChildren;
  struct SLogicNode* pParent;
} SLogicNode;

X
Xiaoyu Wang 已提交
36 37 38 39 40 41 42
typedef enum EScanType {
  SCAN_TYPE_TAG,
  SCAN_TYPE_TABLE,
  SCAN_TYPE_STABLE,
  SCAN_TYPE_STREAM
} EScanType;

X
Xiaoyu Wang 已提交
43 44 45 46
typedef struct SScanLogicNode {
  SLogicNode node;
  SNodeList* pScanCols;
  struct STableMeta* pMeta;
47
  SVgroupsInfo* pVgroupList;
X
Xiaoyu Wang 已提交
48 49 50
  EScanType scanType;
  uint8_t scanFlag;         // denotes reversed scan of data or not
  STimeWindow scanRange;
X
Xiaoyu Wang 已提交
51
  SName tableName;
X
Xiaoyu Wang 已提交
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
} SScanLogicNode;

typedef struct SJoinLogicNode {
  SLogicNode node;
  EJoinType joinType;
  SNode* pOnConditions;
} SJoinLogicNode;

typedef struct SAggLogicNode {
  SLogicNode node;
  SNodeList* pGroupKeys;
  SNodeList* pAggFuncs;
} SAggLogicNode;

typedef struct SProjectLogicNode {
  SLogicNode node;
  SNodeList* pProjections;
} SProjectLogicNode;

71
typedef struct SVnodeModifLogicNode {
X
Xiaoyu Wang 已提交
72
  SLogicNode node;;
73 74 75 76 77
  int32_t msgType;
  SArray* pDataBlocks;
  SVgDataBlocks* pVgDataBlocks;
} SVnodeModifLogicNode;

X
Xiaoyu Wang 已提交
78 79 80 81 82
typedef struct SExchangeLogicNode {
  SLogicNode node;
  int32_t srcGroupId;
} SExchangeLogicNode;

83 84 85 86 87 88 89
typedef enum ESubplanType {
  SUBPLAN_TYPE_MERGE = 1,
  SUBPLAN_TYPE_PARTIAL,
  SUBPLAN_TYPE_SCAN,
  SUBPLAN_TYPE_MODIFY
} ESubplanType;

X
Xiaoyu Wang 已提交
90 91 92 93 94 95
typedef struct SSubplanId {
  uint64_t queryId;
  int32_t groupId;
  int32_t subplanId;
} SSubplanId;

X
Xiaoyu Wang 已提交
96 97
typedef struct SSubLogicPlan {
  ENodeType type;
X
Xiaoyu Wang 已提交
98
  SSubplanId id;
X
Xiaoyu Wang 已提交
99 100 101
  SNodeList* pChildren;
  SNodeList* pParents;
  SLogicNode* pNode;
102
  ESubplanType subplanType;
X
Xiaoyu Wang 已提交
103
  SVgroupsInfo* pVgroupList;
104
  int32_t level;
X
Xiaoyu Wang 已提交
105
  int32_t splitFlag;
X
Xiaoyu Wang 已提交
106 107 108
} SSubLogicPlan;

typedef struct SQueryLogicPlan {
D
dapan1121 已提交
109
  ENodeType type;
X
Xiaoyu Wang 已提交
110 111
  int32_t totalLevel;
  SNodeList* pTopSubplans;
X
Xiaoyu Wang 已提交
112 113
} SQueryLogicPlan;

X
Xiaoyu Wang 已提交
114 115 116 117 118 119
typedef struct SSlotDescNode {
  ENodeType type;
  int16_t slotId;
  SDataType dataType;
  bool reserve;
  bool output;
X
Xiaoyu Wang 已提交
120
  bool tag;
X
Xiaoyu Wang 已提交
121 122
} SSlotDescNode;

X
Xiaoyu Wang 已提交
123
typedef struct SDataBlockDescNode {
X
Xiaoyu Wang 已提交
124
  ENodeType type;
X
Xiaoyu Wang 已提交
125
  int16_t dataBlockId;
X
Xiaoyu Wang 已提交
126
  SNodeList* pSlots;
X
Xiaoyu Wang 已提交
127 128
  int32_t resultRowSize;
  int16_t precision;
X
Xiaoyu Wang 已提交
129
} SDataBlockDescNode;
X
Xiaoyu Wang 已提交
130 131 132

typedef struct SPhysiNode {
  ENodeType type;
X
Xiaoyu Wang 已提交
133
  SDataBlockDescNode* pOutputDataBlockDesc;
X
Xiaoyu Wang 已提交
134 135 136 137 138 139 140 141 142 143 144 145 146
  SNode* pConditions;
  SNodeList* pChildren;
  struct SPhysiNode* pParent;
} SPhysiNode;

typedef struct SScanPhysiNode {
  SPhysiNode  node;
  SNodeList* pScanCols;
  uint64_t uid;           // unique id of the table
  int8_t tableType;
  int32_t order;         // scan order: TSDB_ORDER_ASC|TSDB_ORDER_DESC
  int32_t count;         // repeat count
  int32_t reverse;       // reverse scan count
X
Xiaoyu Wang 已提交
147
  SName tableName;
X
Xiaoyu Wang 已提交
148 149 150 151 152 153 154 155 156
} SScanPhysiNode;

typedef SScanPhysiNode SSystemTableScanPhysiNode;
typedef SScanPhysiNode STagScanPhysiNode;

typedef struct STableScanPhysiNode {
  SScanPhysiNode scan;
  uint8_t scanFlag;         // denotes reversed scan of data or not
  STimeWindow scanRange;
X
Xiaoyu Wang 已提交
157
  SNode* pScanConditions;
X
Xiaoyu Wang 已提交
158 159 160 161 162 163 164 165 166
} STableScanPhysiNode;

typedef STableScanPhysiNode STableSeqScanPhysiNode;

typedef struct SProjectPhysiNode {
  SPhysiNode node;
  SNodeList* pProjections;
} SProjectPhysiNode;

X
Xiaoyu Wang 已提交
167 168 169 170 171 172 173 174 175 176 177 178 179 180
typedef struct SJoinPhysiNode {
  SPhysiNode node;
  EJoinType joinType;
  SNode* pOnConditions; // in or out tuple ?
  SNodeList* pTargets;
} SJoinPhysiNode;

typedef struct SAggPhysiNode {
  SPhysiNode node;
  SNodeList* pExprs;   // these are expression list of group_by_clause and parameter expression of aggregate function
  SNodeList* pGroupKeys; // SColumnRefNode list
  SNodeList* pAggFuncs;
} SAggPhysiNode;

X
Xiaoyu Wang 已提交
181 182
typedef struct SDownstreamSourceNode {
  ENodeType type;
X
Xiaoyu Wang 已提交
183
  SQueryNodeAddr addr;
X
Xiaoyu Wang 已提交
184 185 186
  uint64_t taskId;
  uint64_t schedId;
} SDownstreamSourceNode;
X
Xiaoyu Wang 已提交
187 188

typedef struct SExchangePhysiNode {
X
Xiaoyu Wang 已提交
189 190 191
  SPhysiNode node;
  int32_t srcGroupId;  // group id of datasource suplans
  SNodeList* pSrcEndPoints;  // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
X
Xiaoyu Wang 已提交
192 193 194
} SExchangePhysiNode;

typedef struct SDataSinkNode {
X
Xiaoyu Wang 已提交
195
  ENodeType type;
X
Xiaoyu Wang 已提交
196
  SDataBlockDescNode* pInputDataBlockDesc;
X
Xiaoyu Wang 已提交
197 198 199 200 201 202 203 204 205 206 207 208 209
} SDataSinkNode;

typedef struct SDataDispatcherNode {
  SDataSinkNode sink;
} SDataDispatcherNode;

typedef struct SDataInserterNode {
  SDataSinkNode sink;
  int32_t   numOfTables;
  uint32_t  size;
  char     *pData;
} SDataInserterNode;

X
Xiaoyu Wang 已提交
210 211 212 213 214 215 216
typedef struct SSubplan {
  ENodeType type;
  SSubplanId id;           // unique id of the subplan
  ESubplanType subplanType;
  int32_t msgType;      // message type for subplan, used to denote the send message type to vnode.
  int32_t level;        // the execution level of current subplan, starting from 0 in a top-down manner.
  SQueryNodeAddr execNode;    // for the scan/modify subplan, the optional execution node
D
dapan1121 已提交
217
  SQueryNodeStat execNodeStat; // only for scan subplan
X
Xiaoyu Wang 已提交
218 219 220 221 222 223 224 225 226
  SNodeList* pChildren;    // the datasource subplan,from which to fetch the result
  SNodeList* pParents;     // the data destination subplan, get data from current subplan
  SPhysiNode* pNode;        // physical plan of current subplan
  SDataSinkNode* pDataSink;    // data of the subplan flow into the datasink
} SSubplan;

typedef struct SQueryPlan {
  ENodeType type;;
  uint64_t queryId;
X
Xiaoyu Wang 已提交
227 228
  int32_t numOfSubplans;
  SNodeList* pSubplans; // Element is SNodeListNode. The execution level of subplan, starting from 0.
X
Xiaoyu Wang 已提交
229 230
} SQueryPlan;

X
Xiaoyu Wang 已提交
231 232 233 234 235
#ifdef __cplusplus
}
#endif

#endif /*_TD_PLANN_NODES_H_*/