OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RelTableFunction Class Reference

#include <RelAlgDag.h>

+ Inheritance diagram for RelTableFunction:
+ Collaboration diagram for RelTableFunction:

Public Member Functions

 RelTableFunction ()=default
 
 RelTableFunction (const std::string &function_name, RelAlgInputs inputs, std::vector< std::string > &fields, std::vector< const Rex * > col_inputs, std::vector< std::unique_ptr< const RexScalar >> &table_func_inputs, std::vector< std::unique_ptr< const RexScalar >> &target_exprs)
 
 RelTableFunction (RelTableFunction const &)
 
void replaceInput (std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input) override
 
std::string getFunctionName () const
 
size_t size () const override
 
const RexScalargetTargetExpr (size_t idx) const
 
size_t getTableFuncInputsSize () const
 
size_t getColInputsSize () const
 
int32_t countRexLiteralArgs () const
 
const RexScalargetTableFuncInputAt (const size_t idx) const
 
const RexScalargetTableFuncInputAtAndRelease (const size_t idx)
 
void setTableFuncInputs (std::vector< std::unique_ptr< const RexScalar >> &&exprs)
 
std::string getFieldName (const size_t idx) const
 
const std::vector< std::string > & getFields () const
 
void setFields (std::vector< std::string > &&fields)
 
std::shared_ptr< RelAlgNodedeepCopy () const override
 
std::string toString (RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
 
size_t toHash () const override
 
- Public Member Functions inherited from RelAlgNode
 RelAlgNode (RelAlgInputs inputs={})
 
virtual ~RelAlgNode ()
 
void resetQueryExecutionState ()
 
void setContextData (const RaExecutionDesc *context_data) const
 
void setOutputMetainfo (std::vector< TargetMetaInfo > targets_metainfo) const
 
void setQueryPlanDag (const std::string &extracted_query_plan_dag) const
 
std::string getQueryPlanDag () const
 
size_t getQueryPlanDagHash () const
 
const std::vector
< TargetMetaInfo > & 
getOutputMetainfo () const
 
unsigned getId () const
 
void setIdInPlanTree (size_t id) const
 
std::optional< size_t > getIdInPlanTree () const
 
bool hasContextData () const
 
const RaExecutionDescgetContextData () const
 
const size_t inputCount () const
 
const RelAlgNodegetInput (const size_t idx) const
 
std::shared_ptr< const RelAlgNodegetAndOwnInput (const size_t idx) const
 
void addManagedInput (std::shared_ptr< const RelAlgNode > input)
 
bool hasInput (const RelAlgNode *needle) const
 
void setRelNodeDagId (const size_t id) const
 
size_t getRelNodeDagId () const
 
bool isNop () const
 
void markAsNop ()
 
void clearContextData () const
 

Private Attributes

std::string function_name_
 
std::vector< std::string > fields_
 
std::vector< const Rex * > col_inputs_
 
std::vector< std::unique_ptr
< const RexScalar > > 
table_func_inputs_
 
std::vector< std::unique_ptr
< const RexScalar > > 
target_exprs_
 

Friends

struct RelAlgDagSerializer
 

Additional Inherited Members

- Static Public Member Functions inherited from RelAlgNode
static void resetRelAlgFirstId () noexcept
 
- Protected Attributes inherited from RelAlgNode
RelAlgInputs inputs_
 
unsigned id_
 
std::optional< size_t > id_in_plan_tree_
 
std::optional< size_t > hash_
 

Detailed Description

Definition at line 2249 of file RelAlgDag.h.

Constructor & Destructor Documentation

RelTableFunction::RelTableFunction ( )
default

Referenced by toHash().

+ Here is the caller graph for this function:

RelTableFunction::RelTableFunction ( const std::string &  function_name,
RelAlgInputs  inputs,
std::vector< std::string > &  fields,
std::vector< const Rex * >  col_inputs,
std::vector< std::unique_ptr< const RexScalar >> &  table_func_inputs,
std::vector< std::unique_ptr< const RexScalar >> &  target_exprs 
)
inline

Definition at line 2254 of file RelAlgDag.h.

References RelAlgNode::inputs_.

2260  : function_name_(function_name)
2261  , fields_(fields)
2262  , col_inputs_(col_inputs)
2263  , table_func_inputs_(std::move(table_func_inputs))
2264  , target_exprs_(std::move(target_exprs)) {
2265  for (const auto& input : inputs) {
2266  inputs_.emplace_back(input);
2267  }
2268  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2378
std::string function_name_
Definition: RelAlgDag.h:2372
std::vector< const Rex * > col_inputs_
Definition: RelAlgDag.h:2375
std::vector< std::string > fields_
Definition: RelAlgDag.h:2373
RelAlgInputs inputs_
Definition: RelAlgDag.h:952
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2381
RelTableFunction::RelTableFunction ( RelTableFunction const &  rhs)

Definition at line 739 of file RelAlgDag.cpp.

References col_inputs_, anonymous_namespace{RelAlgDag.cpp}::reset_table_function_inputs(), and table_func_inputs_.

740  : RelAlgNode(rhs)
741  , function_name_(rhs.function_name_)
742  , fields_(rhs.fields_)
743  , col_inputs_(rhs.col_inputs_)
744  , table_func_inputs_(copyRexScalars(rhs.table_func_inputs_))
745  , target_exprs_(copyRexScalars(rhs.target_exprs_)) {
747 }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2378
RelAlgNode(RelAlgInputs inputs={})
Definition: RelAlgDag.h:840
std::string function_name_
Definition: RelAlgDag.h:2372
std::vector< const Rex * > col_inputs_
Definition: RelAlgDag.h:2375
std::vector< std::unique_ptr< const RexScalar > > copyRexScalars(std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources)
Definition: RelAlgDag.cpp:626
std::vector< std::string > fields_
Definition: RelAlgDag.h:2373
void reset_table_function_inputs(std::vector< const Rex * > &column_inputs, const std::vector< std::unique_ptr< const RexScalar >> &old_table_func_inputs, const std::vector< std::unique_ptr< const RexScalar >> &new_table_func_inputs)
Definition: RelAlgDag.cpp:710
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2381

+ Here is the call graph for this function:

Member Function Documentation

int32_t RelTableFunction::countRexLiteralArgs ( ) const

Definition at line 697 of file RelAlgDag.cpp.

References table_func_inputs_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

697  {
698  int32_t literal_args = 0;
699  for (const auto& arg : table_func_inputs_) {
700  const auto rex_literal = dynamic_cast<const RexLiteral*>(arg.get());
701  if (rex_literal) {
702  literal_args += 1;
703  }
704  }
705  return literal_args;
706 }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2378

+ Here is the caller graph for this function:

std::shared_ptr<RelAlgNode> RelTableFunction::deepCopy ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 2318 of file RelAlgDag.h.

2318  {
2319  return std::make_shared<RelTableFunction>(*this);
2320  }
size_t RelTableFunction::getColInputsSize ( ) const
inline

Definition at line 2286 of file RelAlgDag.h.

References col_inputs_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

2286 { return col_inputs_.size(); }
std::vector< const Rex * > col_inputs_
Definition: RelAlgDag.h:2375

+ Here is the caller graph for this function:

std::string RelTableFunction::getFieldName ( const size_t  idx) const
inline

Definition at line 2310 of file RelAlgDag.h.

References CHECK_LT, and fields_.

2310  {
2311  CHECK_LT(idx, fields_.size());
2312  return fields_[idx];
2313  }
std::vector< std::string > fields_
Definition: RelAlgDag.h:2373
#define CHECK_LT(x, y)
Definition: Logger.h:303
const std::vector<std::string>& RelTableFunction::getFields ( ) const
inline

Definition at line 2315 of file RelAlgDag.h.

References fields_.

2315 { return fields_; }
std::vector< std::string > fields_
Definition: RelAlgDag.h:2373
std::string RelTableFunction::getFunctionName ( ) const
inline

Definition at line 2275 of file RelAlgDag.h.

References function_name_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

2275 { return function_name_; }
std::string function_name_
Definition: RelAlgDag.h:2372

+ Here is the caller graph for this function:

const RexScalar* RelTableFunction::getTableFuncInputAt ( const size_t  idx) const
inline

Definition at line 2290 of file RelAlgDag.h.

References CHECK_LT, and table_func_inputs_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit(), anonymous_namespace{RelAlgExecutor.cpp}::get_used_inputs(), anonymous_namespace{RelAlgExecutor.cpp}::scalar_at(), and RelRexDagVisitor::visit().

2290  {
2291  CHECK_LT(idx, table_func_inputs_.size());
2292  return table_func_inputs_[idx].get();
2293  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2378
#define CHECK_LT(x, y)
Definition: Logger.h:303

+ Here is the caller graph for this function:

const RexScalar* RelTableFunction::getTableFuncInputAtAndRelease ( const size_t  idx)
inline

Definition at line 2295 of file RelAlgDag.h.

References CHECK_LT, and table_func_inputs_.

2295  {
2296  // NOTE: as of 08/06/22, this appears to only be called by the bind_inputs free
2297  // function in RelAlgDag.cpp to disambituate inputs. If you follow the bind_inputs
2298  // path, it eventually could call this method in a bind_table_func_to_input lambda
2299  // According to that lambda, the released pointer released here is be immediately be
2300  // placed in a new vector of RexScalar unique_ptrs which is then ultimatey used as an
2301  // argument for the setTableFuncInputs method below. As such, if a table_func_input_
2302  // is released here that is being pointed to by one of the col_inputs_, then we can
2303  // keep that col_inputs_ pointer as that table_func_input_ should be returned back.
2304  CHECK_LT(idx, table_func_inputs_.size());
2305  return table_func_inputs_[idx].release();
2306  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2378
#define CHECK_LT(x, y)
Definition: Logger.h:303
size_t RelTableFunction::getTableFuncInputsSize ( ) const
inline

Definition at line 2284 of file RelAlgDag.h.

References table_func_inputs_.

Referenced by anonymous_namespace{RelAlgExecutor.cpp}::get_scalar_sources_size(), anonymous_namespace{RelAlgExecutor.cpp}::get_used_inputs(), and RelRexDagVisitor::visit().

2284 { return table_func_inputs_.size(); }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2378

+ Here is the caller graph for this function:

const RexScalar* RelTableFunction::getTargetExpr ( size_t  idx) const
inline

Definition at line 2279 of file RelAlgDag.h.

References CHECK_LT, and target_exprs_.

2279  {
2280  CHECK_LT(idx, target_exprs_.size());
2281  return target_exprs_[idx].get();
2282  }
#define CHECK_LT(x, y)
Definition: Logger.h:303
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2381
void RelTableFunction::replaceInput ( std::shared_ptr< const RelAlgNode old_input,
std::shared_ptr< const RelAlgNode input 
)
overridevirtual

Reimplemented from RelAlgNode.

Definition at line 685 of file RelAlgDag.cpp.

References RelAlgNode::replaceInput(), table_func_inputs_, and target_exprs_.

686  {
687  RelAlgNode::replaceInput(old_input, input);
688  RexRebindInputsVisitor rebind_inputs(old_input.get(), input.get());
689  for (const auto& target_expr : target_exprs_) {
690  rebind_inputs.visit(target_expr.get());
691  }
692  for (const auto& func_input : table_func_inputs_) {
693  rebind_inputs.visit(func_input.get());
694  }
695 }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2378
virtual void replaceInput(std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input)
Definition: RelAlgDag.h:915
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2381

+ Here is the call graph for this function:

void RelTableFunction::setFields ( std::vector< std::string > &&  fields)
inline

Definition at line 2316 of file RelAlgDag.h.

References fields_.

2316 { fields_ = std::move(fields); }
std::vector< std::string > fields_
Definition: RelAlgDag.h:2373
void RelTableFunction::setTableFuncInputs ( std::vector< std::unique_ptr< const RexScalar >> &&  exprs)

Definition at line 729 of file RelAlgDag.cpp.

References col_inputs_, anonymous_namespace{RelAlgDag.cpp}::reset_table_function_inputs(), and table_func_inputs_.

730  {
731  // this should only be called in the event of disambiguating inputs, which means the
732  // RexScalar types in the exprs argument should be the exact same as those previously.
733  // So we can then assume all col_inputs_ would be in the same place. So just re-adjust
734  // the pointers.
736  table_func_inputs_ = std::move(exprs);
737 }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2378
std::vector< const Rex * > col_inputs_
Definition: RelAlgDag.h:2375
void reset_table_function_inputs(std::vector< const Rex * > &column_inputs, const std::vector< std::unique_ptr< const RexScalar >> &old_table_func_inputs, const std::vector< std::unique_ptr< const RexScalar >> &new_table_func_inputs)
Definition: RelAlgDag.cpp:710

+ Here is the call graph for this function:

size_t RelTableFunction::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 2277 of file RelAlgDag.h.

References target_exprs_.

2277 { return target_exprs_.size(); }
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2381
size_t RelTableFunction::toHash ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 2353 of file RelAlgDag.h.

References fields_, function_name_, RelAlgNode::hash_, RelAlgNode::inputs_, RelTableFunction(), table_func_inputs_, target_exprs_, and toString().

2353  {
2354  if (!hash_) {
2355  hash_ = typeid(RelTableFunction).hash_code();
2356  for (auto& table_func_input : table_func_inputs_) {
2357  boost::hash_combine(*hash_, table_func_input->toHash());
2358  }
2359  for (auto& target_expr : target_exprs_) {
2360  boost::hash_combine(*hash_, target_expr->toHash());
2361  }
2362  boost::hash_combine(*hash_, function_name_);
2363  boost::hash_combine(*hash_, ::toString(fields_));
2364  for (auto& node : inputs_) {
2365  boost::hash_combine(*hash_, node->toHash());
2366  }
2367  }
2368  return *hash_;
2369  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2378
std::string function_name_
Definition: RelAlgDag.h:2372
std::vector< std::string > fields_
Definition: RelAlgDag.h:2373
std::optional< size_t > hash_
Definition: RelAlgDag.h:955
RelTableFunction()=default
RelAlgInputs inputs_
Definition: RelAlgDag.h:952
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:2322
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2381

+ Here is the call graph for this function:

std::string RelTableFunction::toString ( RelRexToStringConfig  config = RelRexToStringConfig::defaults()) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 2322 of file RelAlgDag.h.

References cat(), fields_, function_name_, RelAlgNode::inputs_, table_func_inputs_, target_exprs_, to_string(), and typeName().

Referenced by toHash().

2323  {
2324  auto ret = cat(::typeName(this), "(", function_name_);
2325  if (!config.skip_input_nodes) {
2326  ret += ", inputs=", ::toString(inputs_);
2327  } else {
2328  ret += ", input node id={";
2329  for (auto& input : inputs_) {
2330  auto node_id_in_plan = input->getIdInPlanTree();
2331  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
2332  : std::to_string(input->getId());
2333  ret += node_id_str + " ";
2334  }
2335  ret += "}";
2336  }
2337  ret +=
2338  cat(", fields=", ::toString(fields_), ", col_inputs=...", ", table_func_inputs=");
2339  if (!config.skip_input_nodes) {
2341  } else {
2342  for (auto& expr : table_func_inputs_) {
2343  ret += expr->toString(config) + " ";
2344  }
2345  }
2346  ret += ", target_exprs=";
2347  for (auto& expr : target_exprs_) {
2348  ret += expr->toString(config) + " ";
2349  }
2350  return cat(ret, ")");
2351  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2378
std::string cat(Ts &&...args)
std::string function_name_
Definition: RelAlgDag.h:2372
std::string to_string(char const *&&v)
unsigned getId() const
Definition: RelAlgDag.h:880
std::vector< std::string > fields_
Definition: RelAlgDag.h:2373
std::string typeName(const T *v)
Definition: toString.h:103
RelAlgInputs inputs_
Definition: RelAlgDag.h:952
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:2322
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2381

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend struct RelAlgDagSerializer
friend

Definition at line 2384 of file RelAlgDag.h.

Member Data Documentation

std::vector<const Rex*> RelTableFunction::col_inputs_
private

Definition at line 2375 of file RelAlgDag.h.

Referenced by getColInputsSize(), RelTableFunction(), and setTableFuncInputs().

std::vector<std::string> RelTableFunction::fields_
private

Definition at line 2373 of file RelAlgDag.h.

Referenced by getFieldName(), getFields(), setFields(), toHash(), and toString().

std::string RelTableFunction::function_name_
private

Definition at line 2372 of file RelAlgDag.h.

Referenced by getFunctionName(), toHash(), and toString().

std::vector<std::unique_ptr<const RexScalar> > RelTableFunction::table_func_inputs_
private
std::vector<std::unique_ptr<const RexScalar> > RelTableFunction::target_exprs_
private

Definition at line 2381 of file RelAlgDag.h.

Referenced by getTargetExpr(), replaceInput(), size(), toHash(), and toString().


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