OmniSciDB  a987f07e93
 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 2224 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 2229 of file RelAlgDag.h.

References RelAlgNode::inputs_.

2235  : function_name_(function_name)
2236  , fields_(fields)
2237  , col_inputs_(col_inputs)
2238  , table_func_inputs_(std::move(table_func_inputs))
2239  , target_exprs_(std::move(target_exprs)) {
2240  for (const auto& input : inputs) {
2241  inputs_.emplace_back(input);
2242  }
2243  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2353
std::string function_name_
Definition: RelAlgDag.h:2347
std::vector< const Rex * > col_inputs_
Definition: RelAlgDag.h:2350
std::vector< std::string > fields_
Definition: RelAlgDag.h:2348
RelAlgInputs inputs_
Definition: RelAlgDag.h:952
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2356
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:2353
RelAlgNode(RelAlgInputs inputs={})
Definition: RelAlgDag.h:840
std::string function_name_
Definition: RelAlgDag.h:2347
std::vector< const Rex * > col_inputs_
Definition: RelAlgDag.h:2350
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:2348
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:2356

+ 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:2353

+ Here is the caller graph for this function:

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

Implements RelAlgNode.

Definition at line 2293 of file RelAlgDag.h.

2293  {
2294  return std::make_shared<RelTableFunction>(*this);
2295  }
size_t RelTableFunction::getColInputsSize ( ) const
inline

Definition at line 2261 of file RelAlgDag.h.

References col_inputs_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

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

+ Here is the caller graph for this function:

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

Definition at line 2285 of file RelAlgDag.h.

References CHECK_LT, and fields_.

2285  {
2286  CHECK_LT(idx, fields_.size());
2287  return fields_[idx];
2288  }
std::vector< std::string > fields_
Definition: RelAlgDag.h:2348
#define CHECK_LT(x, y)
Definition: Logger.h:299
const std::vector<std::string>& RelTableFunction::getFields ( ) const
inline

Definition at line 2290 of file RelAlgDag.h.

References fields_.

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

Definition at line 2250 of file RelAlgDag.h.

References function_name_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

2250 { return function_name_; }
std::string function_name_
Definition: RelAlgDag.h:2347

+ Here is the caller graph for this function:

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

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

2265  {
2266  CHECK_LT(idx, table_func_inputs_.size());
2267  return table_func_inputs_[idx].get();
2268  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2353
#define CHECK_LT(x, y)
Definition: Logger.h:299

+ Here is the caller graph for this function:

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

Definition at line 2270 of file RelAlgDag.h.

References CHECK_LT, and table_func_inputs_.

2270  {
2271  // NOTE: as of 08/06/22, this appears to only be called by the bind_inputs free
2272  // function in RelAlgDag.cpp to disambituate inputs. If you follow the bind_inputs
2273  // path, it eventually could call this method in a bind_table_func_to_input lambda
2274  // According to that lambda, the released pointer released here is be immediately be
2275  // placed in a new vector of RexScalar unique_ptrs which is then ultimatey used as an
2276  // argument for the setTableFuncInputs method below. As such, if a table_func_input_
2277  // is released here that is being pointed to by one of the col_inputs_, then we can
2278  // keep that col_inputs_ pointer as that table_func_input_ should be returned back.
2279  CHECK_LT(idx, table_func_inputs_.size());
2280  return table_func_inputs_[idx].release();
2281  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2353
#define CHECK_LT(x, y)
Definition: Logger.h:299
size_t RelTableFunction::getTableFuncInputsSize ( ) const
inline

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

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

+ Here is the caller graph for this function:

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

Definition at line 2254 of file RelAlgDag.h.

References CHECK_LT, and target_exprs_.

2254  {
2255  CHECK_LT(idx, target_exprs_.size());
2256  return target_exprs_[idx].get();
2257  }
#define CHECK_LT(x, y)
Definition: Logger.h:299
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2356
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:2353
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:2356

+ Here is the call graph for this function:

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

Definition at line 2291 of file RelAlgDag.h.

References fields_.

2291 { fields_ = std::move(fields); }
std::vector< std::string > fields_
Definition: RelAlgDag.h:2348
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:2353
std::vector< const Rex * > col_inputs_
Definition: RelAlgDag.h:2350
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 2252 of file RelAlgDag.h.

References target_exprs_.

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

Implements RelAlgNode.

Definition at line 2328 of file RelAlgDag.h.

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

2328  {
2329  if (!hash_) {
2330  hash_ = typeid(RelTableFunction).hash_code();
2331  for (auto& table_func_input : table_func_inputs_) {
2332  boost::hash_combine(*hash_, table_func_input->toHash());
2333  }
2334  for (auto& target_expr : target_exprs_) {
2335  boost::hash_combine(*hash_, target_expr->toHash());
2336  }
2337  boost::hash_combine(*hash_, function_name_);
2338  boost::hash_combine(*hash_, ::toString(fields_));
2339  for (auto& node : inputs_) {
2340  boost::hash_combine(*hash_, node->toHash());
2341  }
2342  }
2343  return *hash_;
2344  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2353
std::string function_name_
Definition: RelAlgDag.h:2347
std::vector< std::string > fields_
Definition: RelAlgDag.h:2348
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:2297
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2356

+ Here is the call graph for this function:

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

Implements RelAlgNode.

Definition at line 2297 of file RelAlgDag.h.

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

Referenced by toHash().

2298  {
2299  auto ret = cat(::typeName(this), "(", function_name_);
2300  if (!config.skip_input_nodes) {
2301  ret += ", inputs=", ::toString(inputs_);
2302  } else {
2303  ret += ", input node id={";
2304  for (auto& input : inputs_) {
2305  auto node_id_in_plan = input->getIdInPlanTree();
2306  auto node_id_str = node_id_in_plan ? std::to_string(*node_id_in_plan)
2307  : std::to_string(input->getId());
2308  ret += node_id_str + " ";
2309  }
2310  ret += "}";
2311  }
2312  ret +=
2313  cat(", fields=", ::toString(fields_), ", col_inputs=...", ", table_func_inputs=");
2314  if (!config.skip_input_nodes) {
2316  } else {
2317  for (auto& expr : table_func_inputs_) {
2318  ret += expr->toString(config) + " ";
2319  }
2320  }
2321  ret += ", target_exprs=";
2322  for (auto& expr : target_exprs_) {
2323  ret += expr->toString(config) + " ";
2324  }
2325  return cat(ret, ")");
2326  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
Definition: RelAlgDag.h:2353
std::string cat(Ts &&...args)
std::string function_name_
Definition: RelAlgDag.h:2347
std::string to_string(char const *&&v)
unsigned getId() const
Definition: RelAlgDag.h:880
std::vector< std::string > fields_
Definition: RelAlgDag.h:2348
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:2297
std::vector< std::unique_ptr< const RexScalar > > target_exprs_
Definition: RelAlgDag.h:2356

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

Member Data Documentation

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

Definition at line 2350 of file RelAlgDag.h.

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

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

Definition at line 2348 of file RelAlgDag.h.

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

std::string RelTableFunction::function_name_
private

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

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


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