taco-db  0.1.0
FuncCallOperator.h
Go to the documentation of this file.
1 #ifndef EXPR_FUNCCALLOPERATOR_H
2 #define EXPR_FUNCCALLOPERATOR_H
3 
4 #include "expr/ExprNode.h"
5 
6 namespace taco {
7 
8 class FuncCallOperator: public ExprNode {
9 public:
10  template<class ...UniquePtrs>
11  static std::unique_ptr<FuncCallOperator>
12  Create(Oid funcid, UniquePtrs&& ...arg_exprs) {
13  std::shared_ptr<const SysTable_Type> rettyp;
14  FunctionInfo finfo =
15  CheckAndLookupFunction(funcid, rettyp, arg_exprs...);
16  return absl::WrapUnique(
17  new FuncCallOperator(std::move(finfo),
18  funcid,
19  std::move(rettyp),
20  std::forward<UniquePtrs>(arg_exprs)...));
21  }
22 
23  ~FuncCallOperator() override {}
24 
25  Datum Eval(const std::vector<NullableDatumRef>& record) const override;
26 
27  Datum Eval(const char* record) const override;
28 
29  void node_properties_to_string(std::string &buf, int indent) const override;
30 
31 private:
32  template<class ...UniquePtrs>
34  Oid funcid,
35  std::shared_ptr<const SysTable_Type> rettyp,
36  UniquePtrs&& ...arg_exprs):
37  ExprNode(TAG(FuncCallOperator), std::forward<UniquePtrs>(arg_exprs)...),
38  m_func(std::move(func)),
39  m_funcid(funcid),
40  m_nargs((int16_t) sizeof...(UniquePtrs)) {
41  m_type = std::move(rettyp);
42  }
43 
44  template<class ...UniquePtrs>
45  static FunctionInfo
47  std::shared_ptr<const SysTable_Type> &rettyp,
48  const UniquePtrs&... arg_exprs) {
49  std::vector<const ExprNode*> arg_expr_ptrs {{
50  &*arg_exprs...
51  }};
52 
53  return CheckAndLookupFunctionImpl(funcid, rettyp, arg_expr_ptrs);
54  }
55 
57  Oid funcid,
58  std::shared_ptr<const SysTable_Type> &rettyp,
59  std::vector<const ExprNode*> arg_expr_ptrs);
60 
63  int16_t m_nargs;
64 };
65 
66 }
67 
68 #endif
#define TAG(nodeclsname)
Definition: NodeTag.h:26
A Datum stores and possibly manage the memory resource of a read-only value of a plain fixed-length C...
Definition: datum.h:250
ExprNode is an abstract class of all expressions.
Definition: ExprNode.h:29
std::shared_ptr< const SysTable_Type > m_type
Definition: ExprNode.h:61
Definition: FuncCallOperator.h:8
static FunctionInfo CheckAndLookupFunctionImpl(Oid funcid, std::shared_ptr< const SysTable_Type > &rettyp, std::vector< const ExprNode * > arg_expr_ptrs)
Definition: FuncCallOperator.cpp:8
FuncCallOperator(FunctionInfo &&func, Oid funcid, std::shared_ptr< const SysTable_Type > rettyp, UniquePtrs &&...arg_exprs)
Definition: FuncCallOperator.h:33
~FuncCallOperator() override
Definition: FuncCallOperator.h:23
static FunctionInfo CheckAndLookupFunction(Oid funcid, std::shared_ptr< const SysTable_Type > &rettyp, const UniquePtrs &... arg_exprs)
Definition: FuncCallOperator.h:46
FunctionInfo m_func
Definition: FuncCallOperator.h:61
static std::unique_ptr< FuncCallOperator > Create(Oid funcid, UniquePtrs &&...arg_exprs)
Definition: FuncCallOperator.h:12
Oid m_funcid
Definition: FuncCallOperator.h:62
Datum Eval(const std::vector< NullableDatumRef > &record) const override
Evaluate function upon a deserialized record.
Definition: FuncCallOperator.cpp:47
void node_properties_to_string(std::string &buf, int indent) const override
Definition: FuncCallOperator.cpp:77
int16_t m_nargs
Definition: FuncCallOperator.h:63
Definition: Record.h:148
Definition: datum.h:28
uint32_t Oid
Definition: tdb_base.h:210
std::function< Datum(FunctionCallInfo &)> FunctionInfo
An FMGR managed function should be declared as.
Definition: fmgr.h:50