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

#include <RelAlgDagBuilder.h>

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

Public Member Functions

 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 (const 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_
 

Additional Inherited Members

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

Detailed Description

Definition at line 2033 of file RelAlgDagBuilder.h.

Constructor & Destructor Documentation

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 2035 of file RelAlgDagBuilder.h.

References RelAlgNode::inputs_.

Referenced by toHash().

2041  : function_name_(function_name)
2042  , fields_(fields)
2043  , col_inputs_(col_inputs)
2044  , table_func_inputs_(std::move(table_func_inputs))
2045  , target_exprs_(std::move(target_exprs)) {
2046  for (const auto& input : inputs) {
2047  inputs_.emplace_back(input);
2048  }
2049  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
std::string function_name_
std::vector< const Rex * > col_inputs_
std::vector< std::string > fields_
RelAlgInputs inputs_
std::vector< std::unique_ptr< const RexScalar > > target_exprs_

+ Here is the caller graph for this function:

RelTableFunction::RelTableFunction ( RelTableFunction const &  rhs)

Definition at line 708 of file RelAlgDagBuilder.cpp.

References CHECK, col_inputs_, and table_func_inputs_.

709  : RelAlgNode(rhs)
710  , function_name_(rhs.function_name_)
711  , fields_(rhs.fields_)
712  , col_inputs_(rhs.col_inputs_)
713  , table_func_inputs_(copyRexScalars(rhs.table_func_inputs_))
714  , target_exprs_(copyRexScalars(rhs.target_exprs_)) {
715  std::unordered_map<const Rex*, const Rex*> old_to_new_input;
716  for (size_t i = 0; i < table_func_inputs_.size(); ++i) {
717  old_to_new_input.emplace(rhs.table_func_inputs_[i].get(),
718  table_func_inputs_[i].get());
719  }
720  for (auto& target : col_inputs_) {
721  auto target_it = old_to_new_input.find(target);
722  CHECK(target_it != old_to_new_input.end());
723  target = target_it->second;
724  }
725 }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
RelAlgNode(RelAlgInputs inputs={})
std::string function_name_
std::vector< const Rex * > col_inputs_
std::vector< std::string > fields_
#define CHECK(condition)
Definition: Logger.h:223
std::vector< std::unique_ptr< const RexScalar > > copyRexScalars(std::vector< std::unique_ptr< const RexScalar >> const &scalar_sources)
std::vector< std::unique_ptr< const RexScalar > > target_exprs_

Member Function Documentation

int32_t RelTableFunction::countRexLiteralArgs ( ) const

Definition at line 697 of file RelAlgDagBuilder.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_

+ Here is the caller graph for this function:

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

Implements RelAlgNode.

Definition at line 2093 of file RelAlgDagBuilder.h.

2093  {
2094  return std::make_shared<RelTableFunction>(*this);
2095  }
size_t RelTableFunction::getColInputsSize ( ) const
inline

Definition at line 2067 of file RelAlgDagBuilder.h.

References col_inputs_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

2067 { return col_inputs_.size(); }
std::vector< const Rex * > col_inputs_

+ Here is the caller graph for this function:

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

Definition at line 2085 of file RelAlgDagBuilder.h.

References CHECK_LT, and fields_.

2085  {
2086  CHECK_LT(idx, fields_.size());
2087  return fields_[idx];
2088  }
std::vector< std::string > fields_
#define CHECK_LT(x, y)
Definition: Logger.h:233
const std::vector<std::string>& RelTableFunction::getFields ( ) const
inline

Definition at line 2090 of file RelAlgDagBuilder.h.

References fields_.

2090 { return fields_; }
std::vector< std::string > fields_
std::string RelTableFunction::getFunctionName ( ) const
inline

Definition at line 2056 of file RelAlgDagBuilder.h.

References function_name_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

2056 { return function_name_; }
std::string function_name_

+ Here is the caller graph for this function:

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

Definition at line 2071 of file RelAlgDagBuilder.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().

2071  {
2072  CHECK_LT(idx, table_func_inputs_.size());
2073  return table_func_inputs_[idx].get();
2074  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
#define CHECK_LT(x, y)
Definition: Logger.h:233

+ Here is the caller graph for this function:

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

Definition at line 2076 of file RelAlgDagBuilder.h.

References CHECK_LT, and table_func_inputs_.

2076  {
2077  CHECK_LT(idx, table_func_inputs_.size());
2078  return table_func_inputs_[idx].release();
2079  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
#define CHECK_LT(x, y)
Definition: Logger.h:233
size_t RelTableFunction::getTableFuncInputsSize ( ) const
inline

Definition at line 2065 of file RelAlgDagBuilder.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().

2065 { return table_func_inputs_.size(); }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_

+ Here is the caller graph for this function:

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

Definition at line 2060 of file RelAlgDagBuilder.h.

References CHECK_LT, and target_exprs_.

2060  {
2061  CHECK_LT(idx, target_exprs_.size());
2062  return target_exprs_[idx].get();
2063  }
#define CHECK_LT(x, y)
Definition: Logger.h:233
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
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 RelAlgDagBuilder.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_
virtual void replaceInput(std::shared_ptr< const RelAlgNode > old_input, std::shared_ptr< const RelAlgNode > input)
std::vector< std::unique_ptr< const RexScalar > > target_exprs_

+ Here is the call graph for this function:

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

Definition at line 2091 of file RelAlgDagBuilder.h.

References fields_.

2091 { fields_ = std::move(fields); }
std::vector< std::string > fields_
void RelTableFunction::setTableFuncInputs ( std::vector< std::unique_ptr< const RexScalar >> &  exprs)
inline

Definition at line 2081 of file RelAlgDagBuilder.h.

References table_func_inputs_.

2081  {
2082  table_func_inputs_ = std::move(exprs);
2083  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
size_t RelTableFunction::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 2058 of file RelAlgDagBuilder.h.

References target_exprs_.

2058 { return target_exprs_.size(); }
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
size_t RelTableFunction::toHash ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 2128 of file RelAlgDagBuilder.h.

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

2128  {
2129  if (!hash_) {
2130  hash_ = typeid(RelTableFunction).hash_code();
2131  for (auto& table_func_input : table_func_inputs_) {
2132  boost::hash_combine(*hash_, table_func_input->toHash());
2133  }
2134  for (auto& target_expr : target_exprs_) {
2135  boost::hash_combine(*hash_, target_expr->toHash());
2136  }
2137  boost::hash_combine(*hash_, function_name_);
2138  boost::hash_combine(*hash_, ::toString(fields_));
2139  for (auto& node : inputs_) {
2140  boost::hash_combine(*hash_, node->toHash());
2141  }
2142  }
2143  return *hash_;
2144  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
std::string function_name_
std::vector< std::string > fields_
std::optional< size_t > hash_
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)
RelAlgInputs inputs_
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
std::vector< std::unique_ptr< const RexScalar > > target_exprs_

+ Here is the call graph for this function:

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

Implements RelAlgNode.

Definition at line 2097 of file RelAlgDagBuilder.h.

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

Referenced by toHash().

2098  {
2099  auto ret = cat(::typeName(this), "(", function_name_);
2100  if (!config.skip_input_nodes) {
2101  ret += ", inputs=", ::toString(inputs_);
2102  } else {
2103  ret += ", input node id={";
2104  for (auto& input : inputs_) {
2105  auto node_id_in_plan = input->getIdInPlanTree();
2106  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
2107  : std::to_string(input->getId());
2108  ret += node_id_str + " ";
2109  }
2110  ret += "}";
2111  }
2112  ret +=
2113  cat(", fields=", ::toString(fields_), ", col_inputs=...", ", table_func_inputs=");
2114  if (!config.skip_input_nodes) {
2116  } else {
2117  for (auto& expr : table_func_inputs_) {
2118  ret += expr->toString(config) + " ";
2119  }
2120  }
2121  ret += ", target_exprs=";
2122  for (auto& expr : target_exprs_) {
2123  ret += expr->toString(config) + " ";
2124  }
2125  return cat(ret, ")");
2126  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
std::string cat(Ts &&...args)
std::string function_name_
std::string to_string(char const *&&v)
unsigned getId() const
std::vector< std::string > fields_
std::string typeName(const T *v)
Definition: toString.h:102
RelAlgInputs inputs_
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
std::vector< std::unique_ptr< const RexScalar > > target_exprs_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 2151 of file RelAlgDagBuilder.h.

Referenced by getColInputsSize(), and RelTableFunction().

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

Definition at line 2148 of file RelAlgDagBuilder.h.

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

std::string RelTableFunction::function_name_
private

Definition at line 2147 of file RelAlgDagBuilder.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 2156 of file RelAlgDagBuilder.h.

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


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