|
1 | 1 | /*
|
| 2 | + * Copyright 2023 Intel Corporation |
2 | 3 | * Copyright 2017 MapD Technologies, Inc.
|
3 | 4 | *
|
4 | 5 | * Licensed under the Apache License, Version 2.0 (the "License");
|
|
23 | 24 | * Copyright (c) 2016 MapD Technologies, Inc. All rights reserved.
|
24 | 25 | **/
|
25 | 26 |
|
26 |
| -#ifndef QUERYENGINE_RELALGEXECUTIONUNIT_H |
27 |
| -#define QUERYENGINE_RELALGEXECUTIONUNIT_H |
| 27 | +#pragma once |
28 | 28 |
|
29 | 29 | #include "CostModel/CostModel.h"
|
30 | 30 | #include "Descriptors/InputDescriptors.h"
|
@@ -64,14 +64,15 @@ using QueryPlanHash = size_t;
|
64 | 64 | // used to detect a correct cached hashtable
|
65 | 65 | struct HashTableBuildDag {
|
66 | 66 | public:
|
67 |
| - HashTableBuildDag(const JoinColumnsInfo& in_inner_cols_info, |
68 |
| - const JoinColumnsInfo& in_outer_cols_info, |
69 |
| - const QueryPlan& in_inner_cols_access_path, |
70 |
| - const QueryPlan& in_outer_cols_access_path) |
| 67 | + explicit HashTableBuildDag(const JoinColumnsInfo& in_inner_cols_info, |
| 68 | + const JoinColumnsInfo& in_outer_cols_info, |
| 69 | + const QueryPlan& in_inner_cols_access_path, |
| 70 | + const QueryPlan& in_outer_cols_access_path) |
71 | 71 | : inner_cols_info(in_inner_cols_info)
|
72 | 72 | , outer_cols_info(in_outer_cols_info)
|
73 | 73 | , inner_cols_access_path(in_inner_cols_access_path)
|
74 | 74 | , outer_cols_access_path(in_outer_cols_access_path) {}
|
| 75 | + |
75 | 76 | JoinColumnsInfo inner_cols_info;
|
76 | 77 | JoinColumnsInfo outer_cols_info;
|
77 | 78 | QueryPlan inner_cols_access_path;
|
@@ -127,7 +128,88 @@ struct JoinCondition {
|
127 | 128 |
|
128 | 129 | using JoinQualsPerNestingLevel = std::vector<JoinCondition>;
|
129 | 130 |
|
130 |
| -struct RelAlgExecutionUnit { |
| 131 | +class RelAlgExecutionUnit { |
| 132 | + public: |
| 133 | + RelAlgExecutionUnit( |
| 134 | + std::vector<InputDescriptor> input_descs, |
| 135 | + std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs, |
| 136 | + std::list<hdk::ir::ExprPtr> simple_quals, |
| 137 | + std::list<hdk::ir::ExprPtr> quals, |
| 138 | + const JoinQualsPerNestingLevel join_quals, |
| 139 | + std::list<hdk::ir::ExprPtr> groupby_exprs, |
| 140 | + std::vector<const hdk::ir::Expr*> target_exprs, |
| 141 | + const std::shared_ptr<hdk::ir::Estimator> estimator, |
| 142 | + const SortInfo sort_info, |
| 143 | + size_t scan_limit, |
| 144 | + QueryPlan query_plan_dag = {EMPTY_QUERY_PLAN}, |
| 145 | + HashTableBuildDagMap hash_table_build_plan_dag = {}, |
| 146 | + TableIdToNodeMap table_id_to_node_map = {}, |
| 147 | + const std::optional<bool> union_all = {}, |
| 148 | + std::optional<hdk::ir::ShuffleFunction> shuffle_fn = {}, |
| 149 | + hdk::ir::ExprPtr partition_offsets_col = nullptr, |
| 150 | + bool partitioned_aggregation = false, |
| 151 | + std::shared_ptr<costmodel::CostModel> cost_model = nullptr, |
| 152 | + std::vector<costmodel::AnalyticalTemplate> templs = {}) |
| 153 | + : input_descs(std::move(input_descs)) |
| 154 | + , input_col_descs(std::move(input_col_descs)) |
| 155 | + , simple_quals(std::move(simple_quals)) |
| 156 | + , quals(std::move(quals)) |
| 157 | + , join_quals(std::move(join_quals)) |
| 158 | + , groupby_exprs(std::move(groupby_exprs)) |
| 159 | + , target_exprs(std::move(target_exprs)) |
| 160 | + , estimator(std::move(estimator)) |
| 161 | + , sort_info(std::move(sort_info)) |
| 162 | + , scan_limit(scan_limit) |
| 163 | + , query_plan_dag(std::move(query_plan_dag)) |
| 164 | + , hash_table_build_plan_dag(std::move(hash_table_build_plan_dag)) |
| 165 | + , table_id_to_node_map(std::move(table_id_to_node_map)) |
| 166 | + , union_all(union_all) |
| 167 | + , shuffle_fn(std::move(shuffle_fn)) |
| 168 | + , partition_offsets_col(std::move(partition_offsets_col)) |
| 169 | + , partitioned_aggregation(partitioned_aggregation) |
| 170 | + , cost_model(std::move(cost_model)) |
| 171 | + , templs(std::move(templs)) {} |
| 172 | + |
| 173 | + RelAlgExecutionUnit(std::vector<InputDescriptor> input_descs, |
| 174 | + const SchemaProvider* schema_provider, |
| 175 | + std::list<hdk::ir::ExprPtr> simple_quals, |
| 176 | + std::list<hdk::ir::ExprPtr> quals, |
| 177 | + const JoinQualsPerNestingLevel join_quals, |
| 178 | + std::list<hdk::ir::ExprPtr> groupby_exprs, |
| 179 | + std::vector<const hdk::ir::Expr*> target_exprs, |
| 180 | + const std::shared_ptr<hdk::ir::Estimator> estimator, |
| 181 | + const SortInfo sort_info, |
| 182 | + size_t scan_limit, |
| 183 | + QueryPlan query_plan_dag = {EMPTY_QUERY_PLAN}, |
| 184 | + HashTableBuildDagMap hash_table_build_plan_dag = {}, |
| 185 | + TableIdToNodeMap table_id_to_node_map = {}, |
| 186 | + const std::optional<bool> union_all = {}, |
| 187 | + std::optional<hdk::ir::ShuffleFunction> shuffle_fn = {}, |
| 188 | + hdk::ir::ExprPtr partition_offsets_col = nullptr, |
| 189 | + bool partitioned_aggregation = false, |
| 190 | + std::shared_ptr<costmodel::CostModel> cost_model = nullptr, |
| 191 | + std::vector<costmodel::AnalyticalTemplate> templs = {}) |
| 192 | + : input_descs(std::move(input_descs)) |
| 193 | + , simple_quals(std::move(simple_quals)) |
| 194 | + , quals(std::move(quals)) |
| 195 | + , join_quals(std::move(join_quals)) |
| 196 | + , groupby_exprs(std::move(groupby_exprs)) |
| 197 | + , target_exprs(std::move(target_exprs)) |
| 198 | + , estimator(std::move(estimator)) |
| 199 | + , sort_info(std::move(sort_info)) |
| 200 | + , scan_limit(scan_limit) |
| 201 | + , query_plan_dag(std::move(query_plan_dag)) |
| 202 | + , hash_table_build_plan_dag(std::move(hash_table_build_plan_dag)) |
| 203 | + , table_id_to_node_map(std::move(table_id_to_node_map)) |
| 204 | + , union_all(union_all) |
| 205 | + , shuffle_fn(std::move(shuffle_fn)) |
| 206 | + , partition_offsets_col(std::move(partition_offsets_col)) |
| 207 | + , partitioned_aggregation(partitioned_aggregation) |
| 208 | + , cost_model(std::move(cost_model)) |
| 209 | + , templs(std::move(templs)) { |
| 210 | + calcInputColDescs(schema_provider); |
| 211 | + } |
| 212 | + |
131 | 213 | std::vector<InputDescriptor> input_descs;
|
132 | 214 | std::list<std::shared_ptr<const InputColDescriptor>> input_col_descs;
|
133 | 215 | std::list<hdk::ir::ExprPtr> simple_quals;
|
@@ -158,9 +240,11 @@ struct RelAlgExecutionUnit {
|
158 | 240 |
|
159 | 241 | bool isShuffleCount() const { return shuffle_fn && !partition_offsets_col; }
|
160 | 242 | bool isShuffle() const { return shuffle_fn && partition_offsets_col; }
|
| 243 | + |
| 244 | + private: |
| 245 | + // Method used for creation input_col_descs from qualifires and expressions |
| 246 | + void calcInputColDescs(const SchemaProvider* schema_provider); |
161 | 247 | };
|
162 | 248 |
|
163 | 249 | std::ostream& operator<<(std::ostream& os, const RelAlgExecutionUnit& ra_exe_unit);
|
164 | 250 | std::string ra_exec_unit_desc_for_caching(const RelAlgExecutionUnit& ra_exe_unit);
|
165 |
| - |
166 |
| -#endif // QUERYENGINE_RELALGEXECUTIONUNIT_H |
|
0 commit comments