OmniSciDB  dfae7c3b14
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 * >
 

Public Member Functions

 PlanState (const bool allow_lazy_fetch, const std::vector< InputTableInfo > &query_infos, const DeletedColumnsMap &deleted_columns, const 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)
 
const ColumnDescriptorgetDeletedColForTable (const TableId table_id)
 

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 DeletedColumnsMap deleted_columns_
 
const std::vector< InputTableInfo > & query_infos_
 
const Executorexecutor_
 

Detailed Description

Definition at line 41 of file PlanState.h.

Member Typedef Documentation

◆ ColumnId

using PlanState::ColumnId = int

Definition at line 43 of file PlanState.h.

◆ DeletedColumnsMap

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

Definition at line 44 of file PlanState.h.

◆ TableId

using PlanState::TableId = int

Definition at line 42 of file PlanState.h.

Constructor & Destructor Documentation

◆ PlanState()

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>>{}, {}})
52  , deleted_columns_(deleted_columns)
53  , query_infos_(query_infos)
54  , executor_(executor) {}
JoinInfo join_info_
Definition: PlanState.h:62
bool allow_lazy_fetch_
Definition: PlanState.h:61
const Executor * executor_
Definition: PlanState.h:65
const std::vector< InputTableInfo > & query_infos_
Definition: PlanState.h:64
const DeletedColumnsMap deleted_columns_
Definition: PlanState.h:63

Member Function Documentation

◆ allocateLocalColumnIds()

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_.

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:58
#define CHECK(condition)
Definition: Logger.h:197

◆ getDeletedColForTable()

const ColumnDescriptor* PlanState::getDeletedColForTable ( const TableId  table_id)
inline

Definition at line 82 of file PlanState.h.

Referenced by Executor::buildIsDeletedCb().

82  {
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  }
const DeletedColumnsMap deleted_columns_
Definition: PlanState.h:63
+ Here is the caller graph for this function:

◆ getLocalColumnId()

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_.

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_column_id() const
Definition: Analyzer.h:195
std::unordered_map< InputColDescriptor, size_t > global_to_local_col_ids_
Definition: PlanState.h:58
std::set< std::pair< TableId, ColumnId > > columns_to_fetch_
Definition: PlanState.h:59
int get_rte_idx() const
Definition: Analyzer.h:196
int get_table_id() const
Definition: Analyzer.h:194
#define CHECK(condition)
Definition: Logger.h:197
+ Here is the call graph for this function:

◆ isLazyFetchColumn() [1/2]

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().

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:61
std::set< std::pair< TableId, ColumnId > > columns_to_fetch_
Definition: PlanState.h:59
const Executor * executor_
Definition: PlanState.h:65
std::set< std::pair< TableId, ColumnId > > columns_to_not_fetch_
Definition: PlanState.h:60
const ColumnDescriptor * get_column_descriptor(const int col_id, const int table_id, const Catalog_Namespace::Catalog &cat)
Definition: Execute.h:154
+ Here is the call graph for this function:

◆ isLazyFetchColumn() [2/2]

bool PlanState::isLazyFetchColumn ( const InputColDescriptor col_desc)
inline

Definition at line 74 of file PlanState.h.

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

74  {
76  col_desc.getScanDesc().getTableId(),
77  col_desc.getColId(),
78  col_desc.getScanDesc().getNestLevel());
79  return isLazyFetchColumn(&column);
80  }
int getTableId() const
const InputDescriptor & getScanDesc() const
int getNestLevel() const
bool isLazyFetchColumn(const Analyzer::Expr *target_expr)
Definition: PlanState.cpp:20
+ Here is the call graph for this function:

Member Data Documentation

◆ allow_lazy_fetch_

bool PlanState::allow_lazy_fetch_

Definition at line 61 of file PlanState.h.

Referenced by isLazyFetchColumn().

◆ columns_to_fetch_

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

Definition at line 59 of file PlanState.h.

Referenced by getLocalColumnId(), and isLazyFetchColumn().

◆ columns_to_not_fetch_

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

Definition at line 60 of file PlanState.h.

Referenced by isLazyFetchColumn().

◆ deleted_columns_

const DeletedColumnsMap PlanState::deleted_columns_

Definition at line 63 of file PlanState.h.

◆ executor_

const Executor* PlanState::executor_

◆ global_to_local_col_ids_

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

◆ init_agg_vals_

std::vector<int64_t> PlanState::init_agg_vals_

Definition at line 56 of file PlanState.h.

◆ join_info_

JoinInfo PlanState::join_info_

Definition at line 62 of file PlanState.h.

Referenced by Executor::buildCurrentLevelHashTable().

◆ query_infos_

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

Definition at line 64 of file PlanState.h.

Referenced by CodeGenerator::checkExpressionRanges().

◆ target_exprs_

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: