OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PlanState.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 "../Analyzer/Analyzer.h"
21 #include "JoinHashTableInterface.h"
22 
23 #include <unordered_set>
24 
25 class Executor;
26 
27 struct JoinInfo {
28  JoinInfo(const std::vector<std::shared_ptr<Analyzer::BinOper>>& equi_join_tautologies,
29  const std::vector<std::shared_ptr<JoinHashTableInterface>>& join_hash_tables)
30  : equi_join_tautologies_(equi_join_tautologies)
32 
33  std::vector<std::shared_ptr<Analyzer::BinOper>>
34  equi_join_tautologies_; // expressions we equi-join on are true by
35  // definition when using a hash join; we'll
36  // fold them to true during code generation
37  std::vector<std::shared_ptr<JoinHashTableInterface>> join_hash_tables_;
38  std::unordered_set<size_t> sharded_range_table_indices_;
39 };
40 
41 struct PlanState {
42  PlanState(const bool allow_lazy_fetch, const Executor* executor)
43  : allow_lazy_fetch_(allow_lazy_fetch)
44  , join_info_({std::vector<std::shared_ptr<Analyzer::BinOper>>{}, {}})
45  , executor_(executor) {}
46 
47  using TableId = int;
48  using ColumnId = int;
49 
50  std::vector<int64_t> init_agg_vals_;
51  std::vector<Analyzer::Expr*> target_exprs_;
52  std::unordered_map<InputColDescriptor, size_t> global_to_local_col_ids_;
53  std::set<std::pair<TableId, ColumnId>> columns_to_fetch_;
54  std::set<std::pair<TableId, ColumnId>> columns_to_not_fetch_;
58 
60  const std::list<std::shared_ptr<const InputColDescriptor>>& global_col_ids);
61 
62  int getLocalColumnId(const Analyzer::ColumnVar* col_var, const bool fetch_column);
63 
64  bool isLazyFetchColumn(const Analyzer::Expr* target_expr);
65 
66  bool isLazyFetchColumn(const InputColDescriptor& col_desc) {
68  col_desc.getScanDesc().getTableId(),
69  col_desc.getColId(),
70  col_desc.getScanDesc().getNestLevel());
71  return isLazyFetchColumn(&column);
72  }
73 };
JoinInfo join_info_
Definition: PlanState.h:56
const int8_t const int64_t const uint64_t const int32_t const int64_t int64_t uint32_t const int64_t * join_hash_tables
std::unordered_map< InputColDescriptor, size_t > global_to_local_col_ids_
Definition: PlanState.h:52
bool allow_lazy_fetch_
Definition: PlanState.h:55
std::set< std::pair< TableId, ColumnId > > columns_to_fetch_
Definition: PlanState.h:53
PlanState(const bool allow_lazy_fetch, const Executor *executor)
Definition: PlanState.h:42
std::vector< std::shared_ptr< JoinHashTableInterface > > join_hash_tables_
Definition: PlanState.h:37
std::unordered_set< size_t > sharded_range_table_indices_
Definition: PlanState.h:38
const Executor * executor_
Definition: PlanState.h:57
std::vector< int64_t > init_agg_vals_
Definition: PlanState.h:50
std::set< std::pair< TableId, ColumnId > > columns_to_not_fetch_
Definition: PlanState.h:54
executor_(executor)
Definition: PlanState.h:45
std::vector< std::shared_ptr< Analyzer::BinOper > > equi_join_tautologies_
Definition: PlanState.h:34
int getLocalColumnId(const Analyzer::ColumnVar *col_var, const bool fetch_column)
Definition: PlanState.cpp:62
int getColId() const
int getTableId() const
bool isLazyFetchColumn(const InputColDescriptor &col_desc)
Definition: PlanState.h:66
JoinInfo(const std::vector< std::shared_ptr< Analyzer::BinOper >> &equi_join_tautologies, const std::vector< std::shared_ptr< JoinHashTableInterface >> &join_hash_tables)
Definition: PlanState.h:28
void allocateLocalColumnIds(const std::list< std::shared_ptr< const InputColDescriptor >> &global_col_ids)
Definition: PlanState.cpp:50
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
Definition: sqltypes.h:852
int TableId
Definition: PlanState.h:47
std::vector< Analyzer::Expr * > target_exprs_
Definition: PlanState.h:51
bool isLazyFetchColumn(const Analyzer::Expr *target_expr)
Definition: PlanState.cpp:20
int ColumnId
Definition: PlanState.h:48
int getNestLevel() const
const InputDescriptor & getScanDesc() const