OmniSciDB  d2f719934e
 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
 
std::shared_ptr< RelAlgNodedeepCopy () const override
 
std::string toString () 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
 
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
 
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 > hash_
 

Detailed Description

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

References RelAlgNode::inputs_.

Referenced by toHash().

1908  : function_name_(function_name)
1909  , fields_(fields)
1910  , col_inputs_(col_inputs)
1911  , table_func_inputs_(std::move(table_func_inputs))
1912  , target_exprs_(std::move(target_exprs)) {
1913  for (const auto& input : inputs) {
1914  inputs_.emplace_back(input);
1915  }
1916  }
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 489 of file RelAlgDagBuilder.cpp.

References CHECK, col_inputs_, i, and table_func_inputs_.

490  : RelAlgNode(rhs)
491  , function_name_(rhs.function_name_)
492  , fields_(rhs.fields_)
493  , col_inputs_(rhs.col_inputs_)
494  , table_func_inputs_(copyRexScalars(rhs.table_func_inputs_))
495  , target_exprs_(copyRexScalars(rhs.target_exprs_)) {
496  std::unordered_map<const Rex*, const Rex*> old_to_new_input;
497  for (size_t i = 0; i < table_func_inputs_.size(); ++i) {
498  old_to_new_input.emplace(rhs.table_func_inputs_[i].get(),
499  table_func_inputs_[i].get());
500  }
501  for (auto& target : col_inputs_) {
502  auto target_it = old_to_new_input.find(target);
503  CHECK(target_it != old_to_new_input.end());
504  target = target_it->second;
505  }
506 }
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:211
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 478 of file RelAlgDagBuilder.cpp.

References table_func_inputs_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

478  {
479  int32_t literal_args = 0;
480  for (const auto& arg : table_func_inputs_) {
481  const auto rex_literal = dynamic_cast<const RexLiteral*>(arg.get());
482  if (rex_literal) {
483  literal_args += 1;
484  }
485  }
486  return literal_args;
487 }
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 1959 of file RelAlgDagBuilder.h.

1959  {
1960  return std::make_shared<RelTableFunction>(*this);
1961  }
size_t RelTableFunction::getColInputsSize ( ) const
inline

Definition at line 1934 of file RelAlgDagBuilder.h.

References col_inputs_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

1934 { 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 1952 of file RelAlgDagBuilder.h.

References CHECK_LT, and fields_.

1952  {
1953  CHECK_LT(idx, fields_.size());
1954  return fields_[idx];
1955  }
std::vector< std::string > fields_
#define CHECK_LT(x, y)
Definition: Logger.h:221
const std::vector<std::string>& RelTableFunction::getFields ( ) const
inline

Definition at line 1957 of file RelAlgDagBuilder.h.

References fields_.

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

Definition at line 1923 of file RelAlgDagBuilder.h.

References function_name_.

Referenced by RelAlgExecutor::createTableFunctionWorkUnit().

1923 { 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 1938 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().

1938  {
1939  CHECK_LT(idx, table_func_inputs_.size());
1940  return table_func_inputs_[idx].get();
1941  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
#define CHECK_LT(x, y)
Definition: Logger.h:221

+ Here is the caller graph for this function:

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

Definition at line 1943 of file RelAlgDagBuilder.h.

References CHECK_LT, and table_func_inputs_.

1943  {
1944  CHECK_LT(idx, table_func_inputs_.size());
1945  return table_func_inputs_[idx].release();
1946  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
#define CHECK_LT(x, y)
Definition: Logger.h:221
size_t RelTableFunction::getTableFuncInputsSize ( ) const
inline

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

1932 { 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 1927 of file RelAlgDagBuilder.h.

References CHECK_LT, and target_exprs_.

1927  {
1928  CHECK_LT(idx, target_exprs_.size());
1929  return target_exprs_[idx].get();
1930  }
#define CHECK_LT(x, y)
Definition: Logger.h:221
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 466 of file RelAlgDagBuilder.cpp.

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

467  {
468  RelAlgNode::replaceInput(old_input, input);
469  RexRebindInputsVisitor rebind_inputs(old_input.get(), input.get());
470  for (const auto& target_expr : target_exprs_) {
471  rebind_inputs.visit(target_expr.get());
472  }
473  for (const auto& func_input : table_func_inputs_) {
474  rebind_inputs.visit(func_input.get());
475  }
476 }
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::setTableFuncInputs ( std::vector< std::unique_ptr< const RexScalar >> &  exprs)
inline

Definition at line 1948 of file RelAlgDagBuilder.h.

References table_func_inputs_.

1948  {
1949  table_func_inputs_ = std::move(exprs);
1950  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
size_t RelTableFunction::size ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1925 of file RelAlgDagBuilder.h.

References target_exprs_.

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

Implements RelAlgNode.

Definition at line 1979 of file RelAlgDagBuilder.h.

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

1979  {
1980  if (!hash_) {
1981  hash_ = typeid(RelTableFunction).hash_code();
1982  for (auto& table_func_input : table_func_inputs_) {
1983  boost::hash_combine(*hash_, table_func_input->toHash());
1984  }
1985  for (auto& target_expr : target_exprs_) {
1986  boost::hash_combine(*hash_, target_expr->toHash());
1987  }
1988  boost::hash_combine(*hash_, function_name_);
1989  boost::hash_combine(*hash_, ::toString(fields_));
1990  for (auto& node : inputs_) {
1991  boost::hash_combine(*hash_, node->toHash());
1992  }
1993  }
1994  return *hash_;
1995  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
std::string toString() const override
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::vector< std::unique_ptr< const RexScalar > > target_exprs_

+ Here is the call graph for this function:

std::string RelTableFunction::toString ( ) const
inlineoverridevirtual

Implements RelAlgNode.

Definition at line 1963 of file RelAlgDagBuilder.h.

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

Referenced by toHash().

1963  {
1964  return cat(::typeName(this),
1965  "(",
1967  ", inputs=",
1968  ::toString(inputs_),
1969  ", fields=",
1970  ::toString(fields_),
1971  ", col_inputs=...",
1972  ", table_func_inputs=",
1974  ", target_exprs=",
1976  ")");
1977  }
std::vector< std::unique_ptr< const RexScalar > > table_func_inputs_
std::string toString() const override
std::string cat(Ts &&...args)
std::string function_name_
std::vector< std::string > fields_
std::string typeName(const T *v)
Definition: toString.h:93
RelAlgInputs inputs_
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 2002 of file RelAlgDagBuilder.h.

Referenced by getColInputsSize(), and RelTableFunction().

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

Definition at line 1999 of file RelAlgDagBuilder.h.

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

std::string RelTableFunction::function_name_
private

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

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


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