OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RelAlgExecutionDescriptor.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <boost/graph/adjacency_list.hpp>
20 
23 #include "QueryEngine/ResultSet.h"
24 #include "Shared/TargetInfo.h"
25 
26 class ResultSet;
27 
29  public:
30  ExecutionResult(const std::shared_ptr<ResultSet>& rows,
31  const std::vector<TargetMetaInfo>& targets_meta);
32 
33  ExecutionResult(ResultSetPtr&& result, const std::vector<TargetMetaInfo>& targets_meta);
34 
35  ExecutionResult(const ExecutionResult& that);
36 
38 
39  ExecutionResult(const std::vector<PushedDownFilterInfo>& pushed_down_filter_info,
40  bool filter_push_down_enabled);
41 
43 
44  const std::shared_ptr<ResultSet>& getRows() const { return result_; }
45 
46  bool empty() const { return !result_; }
47 
48  const ResultSetPtr& getDataPtr() const { return result_; }
49 
50  const std::vector<TargetMetaInfo>& getTargetsMeta() const { return targets_meta_; }
51 
52  const std::vector<PushedDownFilterInfo>& getPushedDownFilterInfo() const;
53 
54  const bool isFilterPushDownEnabled() const { return filter_push_down_enabled_; }
55 
56  void setQueueTime(const int64_t queue_time_ms) {
57  CHECK(result_);
58  result_->setQueueTime(queue_time_ms);
59  }
60 
61  private:
63  std::vector<TargetMetaInfo> targets_meta_;
64  // filters chosen to be pushed down
65  std::vector<PushedDownFilterInfo> pushed_down_filter_info_;
66  // whether or not it was allowed to look for filters to push down
68 };
69 
70 class RelAlgNode;
71 
73  public:
75  : body_(body)
76  , result_(std::make_shared<ResultSet>(std::vector<TargetInfo>{},
79  nullptr,
80  nullptr),
81  {}) {}
82 
83  const ExecutionResult& getResult() const { return result_; }
84 
85  void setResult(const ExecutionResult& result);
86 
87  const RelAlgNode* getBody() const;
88 
89  private:
90  const RelAlgNode* body_;
92 };
93 
94 using DAG = boost::
95  adjacency_list<boost::setS, boost::vecS, boost::bidirectionalS, const RelAlgNode*>;
96 using Vertex = DAG::vertex_descriptor;
97 
107  public:
108  RaExecutionSequence(const RelAlgNode*, const bool build_sequence = true);
109  RaExecutionSequence(std::unique_ptr<RaExecutionDesc> exec_desc);
110 
116 
122  ssize_t nextStepId(const bool after_reduction) const;
123 
124  bool executionFinished() const;
125 
126  RaExecutionDesc* getDescriptor(size_t idx) const {
127  CHECK_LT(idx, descs_.size());
128  return descs_[idx].get();
129  }
130 
131  size_t size() const { return descs_.size(); }
132  bool empty() const { return descs_.empty(); }
133 
134  size_t totalDescriptorsCount() const;
135 
136  private:
138 
139  std::unordered_set<Vertex> joins_;
140  std::vector<Vertex> ordering_; // reverse order topological sort of graph_
141  size_t current_vertex_ = 0;
142  size_t scan_count_ = 0;
143 
152  size_t stepsToNextReduction() const;
153 
154  // The execution descriptors hold the pointers to their results. We need to push them
155  // back into this vector as they are created, so we don't lose the intermediate results
156  // later.
157  std::vector<std::unique_ptr<RaExecutionDesc>> descs_;
158 };
RaExecutionDesc * getDescriptor(size_t idx) const
ExecutionResult & operator=(const ExecutionResult &that)
void setQueueTime(const int64_t queue_time_ms)
const RelAlgNode * body_
const ResultSetPtr & getDataPtr() const
std::shared_ptr< ResultSet > ResultSetPtr
std::unordered_set< Vertex > joins_
ssize_t nextStepId(const bool after_reduction) const
ResultSet(const std::vector< TargetInfo > &targets, const ExecutorDeviceType device_type, const QueryMemoryDescriptor &query_mem_desc, const std::shared_ptr< RowSetMemoryOwner > row_set_mem_owner, const Executor *executor)
Definition: ResultSet.cpp:91
CHECK(cgen_state)
RaExecutionSequence(const RelAlgNode *, const bool build_sequence=true)
std::vector< std::unique_ptr< RaExecutionDesc > > descs_
A container for relational algebra descriptors defining the execution order for a relational algebra ...
const std::vector< TargetMetaInfo > & getTargetsMeta() const
const std::shared_ptr< ResultSet > & getRows() const
RaExecutionDesc(const RelAlgNode *body)
ExecutionResult(const std::shared_ptr< ResultSet > &rows, const std::vector< TargetMetaInfo > &targets_meta)
std::vector< PushedDownFilterInfo > pushed_down_filter_info_
#define CHECK_LT(x, y)
Definition: Logger.h:200
const std::vector< PushedDownFilterInfo > & getPushedDownFilterInfo() const
std::vector< Vertex > ordering_
Descriptor for the result set buffer layout.
const bool isFilterPushDownEnabled() const
const RelAlgNode * getBody() const
Basic constructors and methods of the row set interface.
boost::adjacency_list< boost::setS, boost::vecS, boost::bidirectionalS, const RelAlgNode * > DAG
DAG::vertex_descriptor Vertex
std::vector< TargetMetaInfo > targets_meta_