OmniSciDB  f632821e96
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 <unordered_set>
20 
21 #include "Analyzer/Analyzer.h"
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  using TableId = int;
43  using ColumnId = int;
44  using DeletedColumnsMap = std::unordered_map<TableId, const ColumnDescriptor*>;
45 
46  PlanState(const bool allow_lazy_fetch,
47  const std::vector<InputTableInfo>& query_infos,
48  const DeletedColumnsMap& deleted_columns,
49  const Executor* executor)
50  : allow_lazy_fetch_(allow_lazy_fetch)
51  , join_info_({std::vector<std::shared_ptr<Analyzer::BinOper>>{}, {}})
52  , deleted_columns_(deleted_columns)
53  , query_infos_(query_infos)
54  , executor_(executor) {}
55 
56  std::vector<int64_t> init_agg_vals_;
57  std::vector<Analyzer::Expr*> target_exprs_;
58  std::unordered_map<InputColDescriptor, size_t> global_to_local_col_ids_;
59  std::set<std::pair<TableId, ColumnId>> columns_to_fetch_;
60  std::set<std::pair<TableId, ColumnId>> columns_to_not_fetch_;
64  const std::vector<InputTableInfo>& query_infos_;
65  const Executor* executor_;
66 
67  void allocateLocalColumnIds(
68  const std::list<std::shared_ptr<const InputColDescriptor>>& global_col_ids);
69 
70  int getLocalColumnId(const Analyzer::ColumnVar* col_var, const bool fetch_column);
71 
72  bool isLazyFetchColumn(const Analyzer::Expr* target_expr);
73 
74  bool isLazyFetchColumn(const InputColDescriptor& col_desc) {
76  col_desc.getScanDesc().getTableId(),
77  col_desc.getColId(),
78  col_desc.getScanDesc().getNestLevel());
79  return isLazyFetchColumn(&column);
80  }
81 
83  auto deleted_cols_it = deleted_columns_.find(table_id);
84  if (deleted_cols_it != deleted_columns_.end()) {
85  return deleted_cols_it->second;
86  }
87  return nullptr;
88  }
89 };
Defines data structures for the semantic analysis phase of query processing.
JoinInfo join_info_
Definition: PlanState.h:62
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:58
bool allow_lazy_fetch_
Definition: PlanState.h:61
int getTableId() const
std::set< std::pair< TableId, ColumnId > > columns_to_fetch_
Definition: PlanState.h:59
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:65
std::vector< int64_t > init_agg_vals_
Definition: PlanState.h:56
std::set< std::pair< TableId, ColumnId > > columns_to_not_fetch_
Definition: PlanState.h:60
const InputDescriptor & getScanDesc() const
std::vector< std::shared_ptr< Analyzer::BinOper > > equi_join_tautologies_
Definition: PlanState.h:34
std::unordered_map< TableId, const ColumnDescriptor * > DeletedColumnsMap
Definition: PlanState.h:44
int getNestLevel() const
bool isLazyFetchColumn(const InputColDescriptor &col_desc)
Definition: PlanState.h:74
PlanState(const bool allow_lazy_fetch, const std::vector< InputTableInfo > &query_infos, const DeletedColumnsMap &deleted_columns, const Executor *executor)
Definition: PlanState.h:46
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
const std::vector< InputTableInfo > & query_infos_
Definition: PlanState.h:64
specifies the content in-memory of a row in the column metadata table
int TableId
Definition: PlanState.h:42
const ColumnDescriptor * getDeletedColForTable(const TableId table_id)
Definition: PlanState.h:82
const DeletedColumnsMap deleted_columns_
Definition: PlanState.h:63
std::vector< Analyzer::Expr * > target_exprs_
Definition: PlanState.h:57
Executor(const ExecutorId id, const size_t block_size_x, const size_t grid_size_x, const size_t max_gpu_slab_size, const std::string &debug_dir, const std::string &debug_file)
Definition: Execute.cpp:131
int ColumnId
Definition: PlanState.h:43