OmniSciDB  c1a53651b2
 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 DeletedColumnsMap = std::unordered_map< shared::TableKey, 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 shared::TableKey &table_key)
 
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< shared::ColumnKeycolumns_to_fetch_
 
std::set< shared::ColumnKeycolumns_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 42 of file PlanState.h.

Member Typedef Documentation

using PlanState::DeletedColumnsMap = std::unordered_map<shared::TableKey, const ColumnDescriptor*>

Definition at line 43 of file PlanState.h.

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

Definition at line 44 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 46 of file PlanState.h.

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

Member Function Documentation

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

Definition at line 74 of file PlanState.cpp.

References left_join_non_hashtable_quals_.

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

Definition at line 94 of file PlanState.h.

References simple_quals_.

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

Definition at line 47 of file PlanState.cpp.

References CHECK, and global_to_local_col_ids_.

Referenced by ScalarCodeGenerator::prepare().

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

+ Here is the caller graph for this function:

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

Definition at line 54 of file PlanState.h.

54 {}
const ColumnDescriptor* PlanState::getDeletedColForTable ( const shared::TableKey table_key)
inline

Definition at line 86 of file PlanState.h.

References deleted_columns_.

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

Definition at line 59 of file PlanState.cpp.

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

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

60  {
61  CHECK(col_var);
62  const auto& global_col_key = col_var->getColumnKey();
63  const int scan_idx = col_var->get_rte_idx();
64  InputColDescriptor scan_col_desc(
65  global_col_key.column_id, global_col_key.table_id, global_col_key.db_id, scan_idx);
66  const auto it = global_to_local_col_ids_.find(scan_col_desc);
67  CHECK(it != global_to_local_col_ids_.end()) << "Expected to find " << scan_col_desc;
68  if (fetch_column) {
69  columns_to_fetch_.insert(global_col_key);
70  }
71  return it->second;
72 }
std::unordered_map< InputColDescriptor, size_t > global_to_local_col_ids_
Definition: PlanState.h:59
const shared::ColumnKey & getColumnKey() const
Definition: Analyzer.h:198
#define CHECK(condition)
Definition: Logger.h:291
std::set< shared::ColumnKey > columns_to_fetch_
Definition: PlanState.h:60
int32_t get_rte_idx() const
Definition: Analyzer.h:202

+ 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 98 of file PlanState.h.

References simple_quals_.

Referenced by CodeGenerator::codegen().

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

+ 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_, get_column_descriptor(), and Analyzer::ColumnVar::getColumnKey().

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  const auto& column_key = do_not_fetch_column->getColumnKey();
29  if (column_key.table_id > 0) {
30  const auto cd = get_column_descriptor(column_key);
31  if (cd->isVirtualCol) {
32  return false;
33  }
34  }
35  std::set<shared::ColumnKey> intersect;
36  std::set_intersection(columns_to_fetch_.begin(),
37  columns_to_fetch_.end(),
38  columns_to_not_fetch_.begin(),
40  std::inserter(intersect, intersect.begin()));
41  if (!intersect.empty()) {
43  }
44  return columns_to_fetch_.find(column_key) == columns_to_fetch_.end();
45 }
bool allow_lazy_fetch_
Definition: PlanState.h:64
const ColumnDescriptor * get_column_descriptor(const shared::ColumnKey &column_key)
Definition: Execute.h:192
std::set< shared::ColumnKey > columns_to_not_fetch_
Definition: PlanState.h:61
const shared::ColumnKey & getColumnKey() const
Definition: Analyzer.h:198
std::set< shared::ColumnKey > columns_to_fetch_
Definition: PlanState.h:60

+ 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 78 of file PlanState.h.

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

78  {
79  Analyzer::ColumnVar column(
80  SQLTypeInfo(),
81  {col_desc.getScanDesc().getTableKey(), col_desc.getColId()},
82  col_desc.getScanDesc().getNestLevel());
83  return isLazyFetchColumn(&column);
84  }
int32_t getNestLevel() const
bool isLazyFetchColumn(const Analyzer::Expr *target_expr) const
Definition: PlanState.cpp:20
int getColId() const
const shared::TableKey & getTableKey() 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 64 of file PlanState.h.

Referenced by isLazyFetchColumn().

std::set<shared::ColumnKey> PlanState::columns_to_fetch_

Definition at line 60 of file PlanState.h.

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

std::set<shared::ColumnKey> PlanState::columns_to_not_fetch_

Definition at line 61 of file PlanState.h.

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

const DeletedColumnsMap PlanState::deleted_columns_

Definition at line 66 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 58 of file PlanState.h.

std::vector<int64_t> PlanState::init_agg_vals_

Definition at line 56 of file PlanState.h.

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

Definition at line 63 of file PlanState.h.

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

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

Definition at line 67 of file PlanState.h.

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

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

Definition at line 68 of file PlanState.h.

Referenced by addSimpleQual(), and getSimpleQuals().

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

Definition at line 57 of file PlanState.h.


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