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

#include <PlanState.h>

+ Collaboration diagram for PlanState:

Public Types

using TableId = int
 
using ColumnId = int
 

Public Member Functions

 PlanState (const bool allow_lazy_fetch, const Executor *executor)
 
 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)
 
bool isLazyFetchColumn (const InputColDescriptor &col_desc)
 

Public Attributes

std::vector< int64_t > init_agg_vals_
 
std::vector< Analyzer::Expr * > target_exprs_
 
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_
 
bool allow_lazy_fetch_
 
JoinInfo join_info_
 
const Executorexecutor_
 

Detailed Description

Definition at line 41 of file PlanState.h.

Member Typedef Documentation

using PlanState::ColumnId = int

Definition at line 48 of file PlanState.h.

using PlanState::TableId = int

Definition at line 47 of file PlanState.h.

Constructor & Destructor Documentation

PlanState::PlanState ( const bool  allow_lazy_fetch,
const Executor executor 
)
inline

Definition at line 42 of file PlanState.h.

43  : allow_lazy_fetch_(allow_lazy_fetch)
44  , join_info_({std::vector<std::shared_ptr<Analyzer::BinOper>>{}, {}})
JoinInfo join_info_
Definition: PlanState.h:56
bool allow_lazy_fetch_
Definition: PlanState.h:55

Member Function Documentation

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:52
CHECK(cgen_state)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

PlanState::executor_ ( executor  )
inline

Definition at line 45 of file PlanState.h.

45 {}
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());
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:194
std::unordered_map< InputColDescriptor, size_t > global_to_local_col_ids_
Definition: PlanState.h:52
std::set< std::pair< TableId, ColumnId > > columns_to_fetch_
Definition: PlanState.h:53
CHECK(cgen_state)
int get_rte_idx() const
Definition: Analyzer.h:196
int get_column_id() const
Definition: Analyzer.h:195

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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:55
std::set< std::pair< TableId, ColumnId > > columns_to_fetch_
Definition: PlanState.h:53
const Executor * executor_
Definition: PlanState.h:57
std::set< std::pair< TableId, ColumnId > > columns_to_not_fetch_
Definition: PlanState.h:54
const ColumnDescriptor * get_column_descriptor(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:142

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

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

66  {
68  col_desc.getScanDesc().getTableId(),
69  col_desc.getColId(),
70  col_desc.getScanDesc().getNestLevel());
71  return isLazyFetchColumn(&column);
72  }
int getColId() const
int getTableId() const
SQLTypeInfoCore< ArrayContextTypeSizer, ExecutorTypePackaging, DateTimeFacilities > SQLTypeInfo
Definition: sqltypes.h:852
bool isLazyFetchColumn(const Analyzer::Expr *target_expr)
Definition: PlanState.cpp:20
int getNestLevel() const
const InputDescriptor & getScanDesc() const

+ Here is the call graph for this function:

Member Data Documentation

bool PlanState::allow_lazy_fetch_

Definition at line 55 of file PlanState.h.

Referenced by isLazyFetchColumn().

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

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

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

const Executor* PlanState::executor_

Definition at line 57 of file PlanState.h.

Referenced by isLazyFetchColumn().

std::unordered_map<InputColDescriptor, size_t> PlanState::global_to_local_col_ids_

Definition at line 52 of file PlanState.h.

Referenced by allocateLocalColumnIds(), and getLocalColumnId().

std::vector<int64_t> PlanState::init_agg_vals_

Definition at line 50 of file PlanState.h.

JoinInfo PlanState::join_info_

Definition at line 56 of file PlanState.h.

Referenced by CodeGenerator::hashJoinLhs().

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

Definition at line 51 of file PlanState.h.


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