OmniSciDB  d2f719934e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PlanState Struct Reference

#include <PlanState.h>

+ Collaboration diagram for PlanState:

Public Types

using TableId = int
 
using ColumnId = int
 
using DeletedColumnsMap = std::unordered_map< TableId, const ColumnDescriptor * >
 
using HoistedFiltersSet = std::unordered_set< std::shared_ptr< Analyzer::Expr >>
 

Public Member Functions

 PlanState (const bool allow_lazy_fetch, const std::vector< InputTableInfo > &query_infos, const DeletedColumnsMap &deleted_columns, const Executor *executor)
 
 deleted_columns_ (deleted_columns)
 
 query_infos_ (query_infos)
 
 executor_ (executor)
 
void allocateLocalColumnIds (const std::list< std::shared_ptr< const InputColDescriptor >> &global_col_ids)
 
int getLocalColumnId (const Analyzer::ColumnVar *col_var, const bool fetch_column)
 
bool isLazyFetchColumn (const Analyzer::Expr *target_expr) const
 
bool isLazyFetchColumn (const InputColDescriptor &col_desc)
 
const ColumnDescriptorgetDeletedColForTable (const TableId table_id)
 
void addSimpleQual (std::shared_ptr< Analyzer::Expr > simple_qual)
 
std::list< std::shared_ptr
< Analyzer::Expr > > 
getSimpleQuals () const
 
void addNonHashtableQualForLeftJoin (size_t idx, std::shared_ptr< Analyzer::Expr > expr)
 

Public Attributes

std::vector< int64_t > init_agg_vals_
 
std::vector< Analyzer::Expr * > target_exprs_
 
HoistedFiltersSet hoisted_filters_
 
std::unordered_map
< InputColDescriptor, size_t > 
global_to_local_col_ids_
 
std::set< std::pair< TableId,
ColumnId > > 
columns_to_fetch_
 
std::set< std::pair< TableId,
ColumnId > > 
columns_to_not_fetch_
 
std::unordered_map< size_t,
std::vector< std::shared_ptr
< Analyzer::Expr > > > 
left_join_non_hashtable_quals_
 
bool allow_lazy_fetch_
 
JoinInfo join_info_
 
const DeletedColumnsMap deleted_columns_
 
const std::vector
< InputTableInfo > & 
query_infos_
 
std::list< std::shared_ptr
< Analyzer::Expr > > 
simple_quals_
 
const Executorexecutor_
 

Detailed Description

Definition at line 41 of file PlanState.h.

Member Typedef Documentation

using PlanState::ColumnId = int

Definition at line 43 of file PlanState.h.

Definition at line 44 of file PlanState.h.

using PlanState::HoistedFiltersSet = std::unordered_set<std::shared_ptr<Analyzer::Expr>>

Definition at line 45 of file PlanState.h.

using PlanState::TableId = int

Definition at line 42 of file PlanState.h.

Constructor & Destructor Documentation

PlanState::PlanState ( const bool  allow_lazy_fetch,
const std::vector< InputTableInfo > &  query_infos,
const DeletedColumnsMap deleted_columns,
const Executor executor 
)
inline

Definition at line 47 of file PlanState.h.

51  : allow_lazy_fetch_(allow_lazy_fetch)
52  , join_info_({std::vector<std::shared_ptr<Analyzer::BinOper>>{}, {}})
JoinInfo join_info_
Definition: PlanState.h:66
bool allow_lazy_fetch_
Definition: PlanState.h:65

Member Function Documentation

void PlanState::addNonHashtableQualForLeftJoin ( size_t  idx,
std::shared_ptr< Analyzer::Expr expr 
)

Definition at line 77 of file PlanState.cpp.

References left_join_non_hashtable_quals_.

78  {
79  auto it = left_join_non_hashtable_quals_.find(idx);
80  if (it == left_join_non_hashtable_quals_.end()) {
81  std::vector<std::shared_ptr<Analyzer::Expr>> expr_vec{expr};
82  left_join_non_hashtable_quals_.emplace(idx, std::move(expr_vec));
83  } else {
84  it->second.emplace_back(expr);
85  }
86 }
std::unordered_map< size_t, std::vector< std::shared_ptr< Analyzer::Expr > > > left_join_non_hashtable_quals_
Definition: PlanState.h:64
void PlanState::addSimpleQual ( std::shared_ptr< Analyzer::Expr simple_qual)
inline

Definition at line 95 of file PlanState.h.

References simple_quals_.

95  {
96  simple_quals_.push_back(simple_qual);
97  }
std::list< std::shared_ptr< Analyzer::Expr > > simple_quals_
Definition: PlanState.h:69
void PlanState::allocateLocalColumnIds ( const std::list< std::shared_ptr< const InputColDescriptor >> &  global_col_ids)

Definition at line 50 of file PlanState.cpp.

References CHECK, and global_to_local_col_ids_.

Referenced by ScalarCodeGenerator::prepare().

51  {
52  for (const auto& col_id : global_col_ids) {
53  CHECK(col_id);
54  const auto local_col_id = global_to_local_col_ids_.size();
55  const auto it_ok =
56  global_to_local_col_ids_.insert(std::make_pair(*col_id, local_col_id));
57  // enforce uniqueness of the column ids in the scan plan
58  CHECK(it_ok.second);
59  }
60 }
std::unordered_map< InputColDescriptor, size_t > global_to_local_col_ids_
Definition: PlanState.h:60
#define CHECK(condition)
Definition: Logger.h:211

+ Here is the caller graph for this function:

PlanState::deleted_columns_ ( deleted_columns  )
PlanState::executor_ ( executor  )
inline

Definition at line 55 of file PlanState.h.

55 {}
const ColumnDescriptor* PlanState::getDeletedColForTable ( const TableId  table_id)
inline

Definition at line 87 of file PlanState.h.

References deleted_columns_.

87  {
88  auto deleted_cols_it = deleted_columns_.find(table_id);
89  if (deleted_cols_it != deleted_columns_.end()) {
90  return deleted_cols_it->second;
91  }
92  return nullptr;
93  }
const DeletedColumnsMap deleted_columns_
Definition: PlanState.h:67
int PlanState::getLocalColumnId ( const Analyzer::ColumnVar col_var,
const bool  fetch_column 
)

Definition at line 62 of file PlanState.cpp.

References CHECK, columns_to_fetch_, Analyzer::ColumnVar::get_column_id(), Analyzer::ColumnVar::get_rte_idx(), Analyzer::ColumnVar::get_table_id(), and global_to_local_col_ids_.

Referenced by ScalarCodeGenerator::codegenColumn(), CodeGenerator::codegenColVar(), and CodeGenerator::colByteStream().

63  {
64  CHECK(col_var);
65  const int table_id = col_var->get_table_id();
66  int global_col_id = col_var->get_column_id();
67  const int scan_idx = col_var->get_rte_idx();
68  InputColDescriptor scan_col_desc(global_col_id, table_id, scan_idx);
69  const auto it = global_to_local_col_ids_.find(scan_col_desc);
70  CHECK(it != global_to_local_col_ids_.end()) << "Expected to find " << scan_col_desc;
71  if (fetch_column) {
72  columns_to_fetch_.insert(std::make_pair(table_id, global_col_id));
73  }
74  return it->second;
75 }
int get_table_id() const
Definition: Analyzer.h:193
std::unordered_map< InputColDescriptor, size_t > global_to_local_col_ids_
Definition: PlanState.h:60
std::set< std::pair< TableId, ColumnId > > columns_to_fetch_
Definition: PlanState.h:61
int get_rte_idx() const
Definition: Analyzer.h:195
#define CHECK(condition)
Definition: Logger.h:211
int get_column_id() const
Definition: Analyzer.h:194

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::list<std::shared_ptr<Analyzer::Expr> > PlanState::getSimpleQuals ( ) const
inline

Definition at line 99 of file PlanState.h.

References simple_quals_.

Referenced by CodeGenerator::codegen().

99  {
100  return simple_quals_;
101  }
std::list< std::shared_ptr< Analyzer::Expr > > simple_quals_
Definition: PlanState.h:69

+ Here is the caller graph for this function:

bool PlanState::isLazyFetchColumn ( const Analyzer::Expr target_expr) const

Definition at line 20 of file PlanState.cpp.

References allow_lazy_fetch_, columns_to_fetch_, columns_to_not_fetch_, executor_, and get_column_descriptor().

Referenced by CodeGenerator::codegenColVar(), and isLazyFetchColumn().

20  {
21  if (!allow_lazy_fetch_) {
22  return false;
23  }
24  const auto do_not_fetch_column = dynamic_cast<const Analyzer::ColumnVar*>(target_expr);
25  if (!do_not_fetch_column || dynamic_cast<const Analyzer::Var*>(do_not_fetch_column)) {
26  return false;
27  }
28  if (do_not_fetch_column->get_table_id() > 0) {
29  auto cd = get_column_descriptor(do_not_fetch_column->get_column_id(),
30  do_not_fetch_column->get_table_id(),
31  *executor_->getCatalog());
32  if (cd->isVirtualCol) {
33  return false;
34  }
35  }
36  std::set<std::pair<int, int>> intersect;
37  std::set_intersection(columns_to_fetch_.begin(),
38  columns_to_fetch_.end(),
39  columns_to_not_fetch_.begin(),
41  std::inserter(intersect, intersect.begin()));
42  if (!intersect.empty()) {
44  }
45  return columns_to_fetch_.find(std::make_pair(do_not_fetch_column->get_table_id(),
46  do_not_fetch_column->get_column_id())) ==
47  columns_to_fetch_.end();
48 }
bool allow_lazy_fetch_
Definition: PlanState.h:65
std::set< std::pair< TableId, ColumnId > > columns_to_fetch_
Definition: PlanState.h:61
const Executor * executor_
Definition: PlanState.h:70
std::set< std::pair< TableId, ColumnId > > columns_to_not_fetch_
Definition: PlanState.h:62
const ColumnDescriptor * get_column_descriptor(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool PlanState::isLazyFetchColumn ( const InputColDescriptor col_desc)
inline

Definition at line 79 of file PlanState.h.

References InputColDescriptor::getColId(), InputDescriptor::getNestLevel(), InputColDescriptor::getScanDesc(), InputDescriptor::getTableId(), and isLazyFetchColumn().

79  {
81  col_desc.getScanDesc().getTableId(),
82  col_desc.getColId(),
83  col_desc.getScanDesc().getNestLevel());
84  return isLazyFetchColumn(&column);
85  }
bool isLazyFetchColumn(const Analyzer::Expr *target_expr) const
Definition: PlanState.cpp:20
int getColId() const
int getTableId() const
int getNestLevel() const
const InputDescriptor & getScanDesc() const

+ Here is the call graph for this function:

PlanState::query_infos_ ( query_infos  )

Member Data Documentation

bool PlanState::allow_lazy_fetch_

Definition at line 65 of file PlanState.h.

Referenced by isLazyFetchColumn().

std::set<std::pair<TableId, ColumnId> > PlanState::columns_to_fetch_

Definition at line 61 of file PlanState.h.

Referenced by CodeGenerator::codegenColVar(), getLocalColumnId(), and isLazyFetchColumn().

std::set<std::pair<TableId, ColumnId> > PlanState::columns_to_not_fetch_

Definition at line 62 of file PlanState.h.

Referenced by CodeGenerator::codegenColVar(), and isLazyFetchColumn().

const DeletedColumnsMap PlanState::deleted_columns_

Definition at line 67 of file PlanState.h.

Referenced by getDeletedColForTable().

const Executor* PlanState::executor_
std::unordered_map<InputColDescriptor, size_t> PlanState::global_to_local_col_ids_
HoistedFiltersSet PlanState::hoisted_filters_

Definition at line 59 of file PlanState.h.

std::vector<int64_t> PlanState::init_agg_vals_

Definition at line 57 of file PlanState.h.

JoinInfo PlanState::join_info_

Definition at line 66 of file PlanState.h.

Referenced by CodeGenerator::hashJoinLhs().

std::unordered_map<size_t, std::vector<std::shared_ptr<Analyzer::Expr> > > PlanState::left_join_non_hashtable_quals_

Definition at line 64 of file PlanState.h.

Referenced by addNonHashtableQualForLeftJoin(), and Executor::buildJoinLoops().

const std::vector<InputTableInfo>& PlanState::query_infos_

Definition at line 68 of file PlanState.h.

Referenced by CodeGenerator::checkExpressionRanges(), and CodeGenerator::codegen().

std::list<std::shared_ptr<Analyzer::Expr> > PlanState::simple_quals_

Definition at line 69 of file PlanState.h.

Referenced by addSimpleQual(), and getSimpleQuals().

std::vector<Analyzer::Expr*> PlanState::target_exprs_

Definition at line 58 of file PlanState.h.


The documentation for this struct was generated from the following files: