OmniSciDB  a5dc49c757
 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 &)
 
virtual void acceptChildren (Visitor &v) const override
 
virtual void accept (Visitor &v, std::string name) const override
 
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
 
virtual 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
 
bool hasContextData () const
 
const RaExecutionDescgetContextData () const
 
const size_t inputCount () const
 
const RelAlgNodegetInput (const size_t idx) const
 
const std::vector< RelAlgNode
const * > 
getInputs () 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
 
- Public Member Functions inherited from RelAlgDagNode
 RelAlgDagNode ()
 
virtual size_t getStepNumber () const
 
virtual void setStepNumber (size_t step) const
 
std::optional< size_t > getIdInPlanTree () const
 
void setIdInPlanTree (size_t id) 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
 
std::size_t hash_value (RelTableFunction const &)
 

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 > hash_
 
- Protected Attributes inherited from RelAlgDagNode
size_t step_ {0}
 
std::optional< size_t > id_in_plan_tree_
 

Detailed Description

Definition at line 2502 of file RelAlgDag.h.

Constructor & Destructor Documentation

RelTableFunction::RelTableFunction ( )
default
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 2507 of file RelAlgDag.h.

References RelAlgNode::inputs_.

2513  : function_name_(function_name)
2514  , fields_(fields)
2515  , col_inputs_(col_inputs)
2516  , table_func_inputs_(std::move(table_func_inputs))
2517  , target_exprs_(std::move(target_exprs)) {
2518  for (const auto& input : inputs) {
2519  inputs_.emplace_back(input);
2520  }
2521  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2645
std::string function_name_
Definition: RelAlgDag.h:2639
std::vector< const Rex * > col_inputs_
Definition: RelAlgDag.h:2642
std::vector< std::string > fields_
Definition: RelAlgDag.h:2640
RelAlgInputs inputs_
Definition: RelAlgDag.h:945
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2648
RelTableFunction::RelTableFunction ( RelTableFunction const &  rhs)

Definition at line 740 of file RelAlgDag.cpp.

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

741  : RelAlgNode(rhs)
742  , function_name_(rhs.function_name_)
743  , fields_(rhs.fields_)
744  , col_inputs_(rhs.col_inputs_)
745  , table_func_inputs_(copyRexScalars(rhs.table_func_inputs_))
746  , target_exprs_(copyRexScalars(rhs.target_exprs_)) {
748 }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2645
RelAlgNode(RelAlgInputs inputs={})
Definition: RelAlgDag.h:830
std::string function_name_
Definition: RelAlgDag.h:2639
std::vector< const Rex * > col_inputs_
Definition: RelAlgDag.h:2642
std::vector< std::unique_ptr< const RexScalar > > copyRexScalars(std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources)
Definition: RelAlgDag.cpp:627
std::vector< std::string > fields_
Definition: RelAlgDag.h:2640
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:711
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2648

+ Here is the call graph for this function:

Member Function Documentation

virtual void RelTableFunction::accept ( Visitor v,
std::string  name 
) const
inlineoverridevirtual

Implements RelAlgDagNode.

Definition at line 2542 of file RelAlgDag.h.

References acceptChildren(), and RelAlgDagNode::Visitor::visit().

Referenced by TableFunctionsFactory_node.PrintNode::__str__().

2542  {
2543  if (v.visit(this, std::move(name))) {
2544  acceptChildren(v);
2545  }
2546  }
virtual void acceptChildren(Visitor &v) const override
Definition: RelAlgDag.h:2525
string name
Definition: setup.in.py:72

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void RelTableFunction::acceptChildren ( Visitor v) const
inlineoverridevirtual

Implements RelAlgDagNode.

Definition at line 2525 of file RelAlgDag.h.

References RelAlgDagNode::accept(), RelAlgNode::getInputs(), getTableFuncInputAt(), getTableFuncInputsSize(), getTargetExpr(), anonymous_namespace{Utm.h}::n, and size().

Referenced by accept().

2525  {
2526  for (size_t i = 0; i < getTableFuncInputsSize(); ++i) {
2527  if (getTableFuncInputAt(i)) {
2528  getTableFuncInputAt(i)->accept(v, "argument");
2529  }
2530  }
2531  for (size_t i = 0; i < size(); ++i) {
2532  if (getTargetExpr(i)) {
2533  getTargetExpr(i)->accept(v, "target");
2534  }
2535  }
2536  for (auto& n : getInputs()) {
2537  if (n) {
2538  n->accept(v, "input");
2539  }
2540  }
2541  }
size_t getTableFuncInputsSize() const
Definition: RelAlgDag.h:2560
size_t size() const override
Definition: RelAlgDag.h:2553
virtual void accept(Visitor &v, std::string name) const =0
const std::vector< RelAlgNode const * > getInputs() const
Definition: RelAlgDag.h:882
const RexScalar * getTableFuncInputAt(const size_t idx) const
Definition: RelAlgDag.h:2566
constexpr double n
Definition: Utm.h:38
const RexScalar * getTargetExpr(size_t idx) const
Definition: RelAlgDag.h:2555

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int32_t RelTableFunction::countRexLiteralArgs ( ) const

Definition at line 698 of file RelAlgDag.cpp.

References table_func_inputs_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

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

+ Here is the caller graph for this function:

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

Implements RelAlgNode.

Definition at line 2594 of file RelAlgDag.h.

2594  {
2595  return std::make_shared<RelTableFunction>(*this);
2596  }
size_t RelTableFunction::getColInputsSize ( ) const
inline

Definition at line 2562 of file RelAlgDag.h.

References col_inputs_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

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

+ Here is the caller graph for this function:

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

Definition at line 2586 of file RelAlgDag.h.

References CHECK_LT, and fields_.

2586  {
2587  CHECK_LT(idx, fields_.size());
2588  return fields_[idx];
2589  }
std::vector< std::string > fields_
Definition: RelAlgDag.h:2640
#define CHECK_LT(x, y)
Definition: Logger.h:303
const std::vector<std::string>& RelTableFunction::getFields ( ) const
inline

Definition at line 2591 of file RelAlgDag.h.

References fields_.

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

Definition at line 2551 of file RelAlgDag.h.

References function_name_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

2551 { return function_name_; }
std::string function_name_
Definition: RelAlgDag.h:2639

+ Here is the caller graph for this function:

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

Definition at line 2566 of file RelAlgDag.h.

References CHECK_LT, and table_func_inputs_.

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

2566  {
2567  CHECK_LT(idx, table_func_inputs_.size());
2568  return table_func_inputs_[idx].get();
2569  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2645
#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 2571 of file RelAlgDag.h.

References CHECK_LT, and table_func_inputs_.

2571  {
2572  // NOTE: as of 08/06/22, this appears to only be called by the bind_inputs free
2573  // function in RelAlgDag.cpp to disambituate inputs. If you follow the bind_inputs
2574  // path, it eventually could call this method in a bind_table_func_to_input lambda
2575  // According to that lambda, the released pointer released here is be immediately be
2576  // placed in a new vector of RexScalar unique_ptrs which is then ultimatey used as an
2577  // argument for the setTableFuncInputs method below. As such, if a table_func_input_
2578  // is released here that is being pointed to by one of the col_inputs_, then we can
2579  // keep that col_inputs_ pointer as that table_func_input_ should be returned back.
2580  CHECK_LT(idx, table_func_inputs_.size());
2581  return table_func_inputs_[idx].release();
2582  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2645
#define CHECK_LT(x, y)
Definition: Logger.h:303
size_t RelTableFunction::getTableFuncInputsSize ( ) const
inline

Definition at line 2560 of file RelAlgDag.h.

References table_func_inputs_.

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

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

+ Here is the caller graph for this function:

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

Definition at line 2555 of file RelAlgDag.h.

References CHECK_LT, and target_exprs_.

Referenced by acceptChildren().

2555  {
2556  CHECK_LT(idx, target_exprs_.size());
2557  return target_exprs_[idx].get();
2558  }
#define CHECK_LT(x, y)
Definition: Logger.h:303
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2648

+ Here is the caller graph for this function:

void RelTableFunction::replaceInput ( std::shared_ptr< const RelAlgNode old_input,
std::shared_ptr< const RelAlgNode input 
)
overridevirtual

Reimplemented from RelAlgNode.

Definition at line 686 of file RelAlgDag.cpp.

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

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

+ Here is the call graph for this function:

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

Definition at line 2592 of file RelAlgDag.h.

References fields_.

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

Definition at line 730 of file RelAlgDag.cpp.

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

731  {
732  // this should only be called in the event of disambiguating inputs, which means the
733  // RexScalar types in the exprs argument should be the exact same as those previously.
734  // So we can then assume all col_inputs_ would be in the same place. So just re-adjust
735  // the pointers.
737  table_func_inputs_ = std::move(exprs);
738 }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2645
std::vector< const Rex * > col_inputs_
Definition: RelAlgDag.h:2642
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:711

+ Here is the call graph for this function:

size_t RelTableFunction::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 2553 of file RelAlgDag.h.

References target_exprs_.

Referenced by acceptChildren().

2553 { return target_exprs_.size(); }
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2648

+ Here is the caller graph for this function:

virtual size_t RelTableFunction::toHash ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 2634 of file RelAlgDag.h.

References hash_value.

2634 { return hash_value(*this); }
friend std::size_t hash_value(RelTableFunction const &)
Definition: RelAlgDag.cpp:3819
std::string RelTableFunction::toString ( RelRexToStringConfig  config = RelRexToStringConfig::defaults()) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 2598 of file RelAlgDag.h.

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

2599  {
2600  if (!config.attributes_only) {
2601  auto ret = cat(::typeName(this), "(", function_name_);
2602  if (!config.skip_input_nodes) {
2603  ret += ", inputs=", ::toString(inputs_);
2604  } else {
2605  ret += ", input node id={";
2606  for (auto& input : inputs_) {
2607  auto node_id_in_plan = input->getIdInPlanTree();
2608  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
2609  : std::to_string(input->getId());
2610  ret += node_id_str + " ";
2611  }
2612  ret += "}";
2613  }
2614  ret += cat(
2615  ", fields=", ::toString(fields_), ", col_inputs=...", ", table_func_inputs=");
2616  if (!config.skip_input_nodes) {
2618  } else {
2619  for (auto& expr : table_func_inputs_) {
2620  ret += expr->toString(config) + " ";
2621  }
2622  }
2623  ret += ", target_exprs=";
2624  for (auto& expr : target_exprs_) {
2625  ret += expr->toString(config) + " ";
2626  }
2627  return cat(ret, ")");
2628  } else {
2629  return cat(
2630  ::typeName(this), "(", function_name_, ", fields=", ::toString(fields_), ")");
2631  }
2632  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2645
std::string cat(Ts &&...args)
std::string function_name_
Definition: RelAlgDag.h:2639
std::string to_string(char const *&&v)
unsigned getId() const
Definition: RelAlgDag.h:869
std::vector< std::string > fields_
Definition: RelAlgDag.h:2640
std::string typeName(const T *v)
Definition: toString.h:106
RelAlgInputs inputs_
Definition: RelAlgDag.h:945
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:2598
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2648

+ Here is the call graph for this function:

Friends And Related Function Documentation

std::size_t hash_value ( RelTableFunction const &  rel_tf)
friend

Definition at line 3819 of file RelAlgDag.cpp.

Referenced by toHash().

3819  {
3820  if (rel_tf.hash_) {
3821  return *rel_tf.hash_;
3822  }
3823  rel_tf.hash_ = typeid(RelTableFunction).hash_code();
3824  boost::hash_combine(*rel_tf.hash_, rel_tf.function_name_);
3825  boost::hash_combine(*rel_tf.hash_, rel_tf.table_func_inputs_);
3826  boost::hash_combine(*rel_tf.hash_, rel_tf.target_exprs_);
3827  boost::hash_combine(*rel_tf.hash_, rel_tf.fields_);
3828  boost::hash_combine(*rel_tf.hash_, rel_tf.inputs_);
3829  return *rel_tf.hash_;
3830 }
RelTableFunction()=default
friend struct RelAlgDagSerializer
friend

Definition at line 2651 of file RelAlgDag.h.

Member Data Documentation

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

Definition at line 2642 of file RelAlgDag.h.

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

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

Definition at line 2640 of file RelAlgDag.h.

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

std::string RelTableFunction::function_name_
private

Definition at line 2639 of file RelAlgDag.h.

Referenced by getFunctionName(), hash_value(), 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 2648 of file RelAlgDag.h.

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


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