OmniSciDB  c0231cc57d
 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 (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 2097 of file RelAlgDag.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 2099 of file RelAlgDag.h.

References RelAlgNode::inputs_.

Referenced by toHash().

2105  : function_name_(function_name)
2106  , fields_(fields)
2107  , col_inputs_(col_inputs)
2108  , table_func_inputs_(std::move(table_func_inputs))
2109  , target_exprs_(std::move(target_exprs)) {
2110  for (const auto& input : inputs) {
2111  inputs_.emplace_back(input);
2112  }
2113  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2217
std::string function_name_
Definition: RelAlgDag.h:2211
std::vector< const Rex * > col_inputs_
Definition: RelAlgDag.h:2215
std::vector< std::string > fields_
Definition: RelAlgDag.h:2212
RelAlgInputs inputs_
Definition: RelAlgDag.h:886
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2220

+ Here is the caller graph for this function:

RelTableFunction::RelTableFunction ( RelTableFunction const &  rhs)

Definition at line 707 of file RelAlgDag.cpp.

References CHECK, col_inputs_, and table_func_inputs_.

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

Member Function Documentation

int32_t RelTableFunction::countRexLiteralArgs ( ) const

Definition at line 696 of file RelAlgDag.cpp.

References table_func_inputs_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

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

+ Here is the caller graph for this function:

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

Implements RelAlgNode.

Definition at line 2157 of file RelAlgDag.h.

2157  {
2158  return std::make_shared<RelTableFunction>(*this);
2159  }
size_t RelTableFunction::getColInputsSize ( ) const
inline

Definition at line 2131 of file RelAlgDag.h.

References col_inputs_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

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

+ Here is the caller graph for this function:

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

Definition at line 2149 of file RelAlgDag.h.

References CHECK_LT, and fields_.

2149  {
2150  CHECK_LT(idx, fields_.size());
2151  return fields_[idx];
2152  }
std::vector< std::string > fields_
Definition: RelAlgDag.h:2212
#define CHECK_LT(x, y)
Definition: Logger.h:232
const std::vector<std::string>& RelTableFunction::getFields ( ) const
inline

Definition at line 2154 of file RelAlgDag.h.

References fields_.

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

Definition at line 2120 of file RelAlgDag.h.

References function_name_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

2120 { return function_name_; }
std::string function_name_
Definition: RelAlgDag.h:2211

+ Here is the caller graph for this function:

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

Definition at line 2135 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().

2135  {
2136  CHECK_LT(idx, table_func_inputs_.size());
2137  return table_func_inputs_[idx].get();
2138  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2217
#define CHECK_LT(x, y)
Definition: Logger.h:232

+ Here is the caller graph for this function:

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

Definition at line 2140 of file RelAlgDag.h.

References CHECK_LT, and table_func_inputs_.

2140  {
2141  CHECK_LT(idx, table_func_inputs_.size());
2142  return table_func_inputs_[idx].release();
2143  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2217
#define CHECK_LT(x, y)
Definition: Logger.h:232
size_t RelTableFunction::getTableFuncInputsSize ( ) const
inline

Definition at line 2129 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().

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

+ Here is the caller graph for this function:

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

Definition at line 2124 of file RelAlgDag.h.

References CHECK_LT, and target_exprs_.

2124  {
2125  CHECK_LT(idx, target_exprs_.size());
2126  return target_exprs_[idx].get();
2127  }
#define CHECK_LT(x, y)
Definition: Logger.h:232
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2220
void RelTableFunction::replaceInput ( std::shared_ptr< const RelAlgNode old_input,
std::shared_ptr< const RelAlgNode input 
)
overridevirtual

Reimplemented from RelAlgNode.

Definition at line 684 of file RelAlgDag.cpp.

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

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

+ Here is the call graph for this function:

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

Definition at line 2155 of file RelAlgDag.h.

References fields_.

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

Definition at line 2145 of file RelAlgDag.h.

References table_func_inputs_.

2145  {
2146  table_func_inputs_ = std::move(exprs);
2147  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2217
size_t RelTableFunction::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 2122 of file RelAlgDag.h.

References target_exprs_.

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

Implements RelAlgNode.

Definition at line 2192 of file RelAlgDag.h.

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

2192  {
2193  if (!hash_) {
2194  hash_ = typeid(RelTableFunction).hash_code();
2195  for (auto& table_func_input : table_func_inputs_) {
2196  boost::hash_combine(*hash_, table_func_input->toHash());
2197  }
2198  for (auto& target_expr : target_exprs_) {
2199  boost::hash_combine(*hash_, target_expr->toHash());
2200  }
2201  boost::hash_combine(*hash_, function_name_);
2202  boost::hash_combine(*hash_, ::toString(fields_));
2203  for (auto& node : inputs_) {
2204  boost::hash_combine(*hash_, node->toHash());
2205  }
2206  }
2207  return *hash_;
2208  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2217
std::string function_name_
Definition: RelAlgDag.h:2211
std::vector< std::string > fields_
Definition: RelAlgDag.h:2212
std::optional< size_t > hash_
Definition: RelAlgDag.h:889
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)
Definition: RelAlgDag.h:2099
RelAlgInputs inputs_
Definition: RelAlgDag.h:886
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:2161
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2220

+ Here is the call graph for this function:

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

Implements RelAlgNode.

Definition at line 2161 of file RelAlgDag.h.

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

Referenced by toHash().

2162  {
2163  auto ret = cat(::typeName(this), "(", function_name_);
2164  if (!config.skip_input_nodes) {
2165  ret += ", inputs=", ::toString(inputs_);
2166  } else {
2167  ret += ", input node id={";
2168  for (auto& input : inputs_) {
2169  auto node_id_in_plan = input->getIdInPlanTree();
2170  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
2171  : std::to_string(input->getId());
2172  ret += node_id_str + " ";
2173  }
2174  ret += "}";
2175  }
2176  ret +=
2177  cat(", fields=", ::toString(fields_), ", col_inputs=...", ", table_func_inputs=");
2178  if (!config.skip_input_nodes) {
2180  } else {
2181  for (auto& expr : table_func_inputs_) {
2182  ret += expr->toString(config) + " ";
2183  }
2184  }
2185  ret += ", target_exprs=";
2186  for (auto& expr : target_exprs_) {
2187  ret += expr->toString(config) + " ";
2188  }
2189  return cat(ret, ")");
2190  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2217
std::string cat(Ts &&...args)
std::string function_name_
Definition: RelAlgDag.h:2211
std::string to_string(char const *&&v)
unsigned getId() const
Definition: RelAlgDag.h:814
std::vector< std::string > fields_
Definition: RelAlgDag.h:2212
std::string typeName(const T *v)
Definition: toString.h:103
RelAlgInputs inputs_
Definition: RelAlgDag.h:886
std::string toString(RelRexToStringConfig config=RelRexToStringConfig::defaults()) const override
Definition: RelAlgDag.h:2161
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2220

+ 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 2215 of file RelAlgDag.h.

Referenced by getColInputsSize(), and RelTableFunction().

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

Definition at line 2212 of file RelAlgDag.h.

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

std::string RelTableFunction::function_name_
private

Definition at line 2211 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 2220 of file RelAlgDag.h.

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


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