Kùzu C++ API
Loading...
Searching...
No Matches
function.h
Go to the documentation of this file.
1#pragma once
2
3#include "expression.h"
4#include "api.h"
5
6namespace kuzu {
7
8namespace main {
9class ClientContext;
10}
11
12namespace function {
13
15 std::vector<common::LogicalType> paramTypes;
18 int64_t count;
19
21 : resultType{std::move(dataType)}, clientContext{nullptr}, count{1} {}
22 FunctionBindData(std::vector<common::LogicalType> paramTypes, common::LogicalType resultType)
23 : paramTypes{std::move(paramTypes)}, resultType{std::move(resultType)},
24 clientContext{nullptr}, count{1} {}
26 virtual ~FunctionBindData() = default;
27
28 static std::unique_ptr<FunctionBindData> getSimpleBindData(
29 const binder::expression_vector& params, const common::LogicalType& resultType);
30
31 template<class TARGET>
32 TARGET& cast() {
33 return common::ku_dynamic_cast<FunctionBindData&, TARGET&>(*this);
34 }
35
36 virtual std::unique_ptr<FunctionBindData> copy() const {
37 return std::make_unique<FunctionBindData>(common::LogicalType::copy(paramTypes),
38 resultType.copy());
39 }
40};
41
42struct Function;
43using function_set = std::vector<std::unique_ptr<Function>>;
44
54
56 std::function<std::unique_ptr<FunctionBindData>(ScalarBindFuncInput bindInput)>;
57
58struct Function {
59 std::string name;
60 std::vector<common::LogicalTypeID> parameterTypeIDs;
61 // Currently we only one variable-length function which is list creation. The expectation is
62 // that all parameters must have the same type as parameterTypes[0].
64
65 Function() : isVarLength{false} {};
66 Function(std::string name, std::vector<common::LogicalTypeID> parameterTypeIDs)
67 : name{std::move(name)}, parameterTypeIDs{std::move(parameterTypeIDs)}, isVarLength{false} {
68 }
69 Function(const Function&) = default;
70
71 virtual ~Function() = default;
72
73 virtual std::string signatureToString() const {
75 }
76
77 virtual std::unique_ptr<Function> copy() const = 0;
78
79 template<class TARGET>
80 const TARGET* constPtrCast() const {
82 }
83 template<class TARGET>
84 TARGET* ptrCast() {
86 }
87};
88
92
93 BaseScalarFunction(std::string name, std::vector<common::LogicalTypeID> parameterTypeIDs,
95 : Function{std::move(name), std::move(parameterTypeIDs)}, returnTypeID{returnTypeID},
96 bindFunc{std::move(bindFunc)} {}
97
98 std::string signatureToString() const override {
99 auto result = Function::signatureToString();
101 return result;
102 }
103};
104
105} // namespace function
106} // namespace kuzu
#define KUZU_API
Definition api.h:25
Definition types.h:201
static KUZU_API std::vector< LogicalType > copy(const std::vector< LogicalType > &types)
Contain client side configuration. We make profiler associated per query, so profiler is not maintain...
Definition client_context.h:51
std::vector< std::shared_ptr< Expression > > expression_vector
Definition expression.h:19
TO ku_dynamic_cast(FROM old)
Definition cast.h:11
LogicalTypeID
Definition types.h:126
std::vector< std::unique_ptr< Function > > function_set
Definition function.h:43
std::function< std::unique_ptr< FunctionBindData >(ScalarBindFuncInput bindInput)> scalar_bind_func
Definition function.h:55
Definition alter_type.h:5
static std::string toString(LogicalTypeID dataTypeID)
Definition function.h:89
BaseScalarFunction(std::string name, std::vector< common::LogicalTypeID > parameterTypeIDs, common::LogicalTypeID returnTypeID, scalar_bind_func bindFunc)
Definition function.h:93
std::string signatureToString() const override
Definition function.h:98
common::LogicalTypeID returnTypeID
Definition function.h:90
scalar_bind_func bindFunc
Definition function.h:91
Definition function.h:14
DELETE_COPY_AND_MOVE(FunctionBindData)
virtual std::unique_ptr< FunctionBindData > copy() const
Definition function.h:36
common::LogicalType resultType
Definition function.h:16
TARGET & cast()
Definition function.h:32
int64_t count
Definition function.h:18
virtual ~FunctionBindData()=default
std::vector< common::LogicalType > paramTypes
Definition function.h:15
FunctionBindData(std::vector< common::LogicalType > paramTypes, common::LogicalType resultType)
Definition function.h:22
main::ClientContext * clientContext
Definition function.h:17
FunctionBindData(common::LogicalType dataType)
Definition function.h:20
static std::unique_ptr< FunctionBindData > getSimpleBindData(const binder::expression_vector &params, const common::LogicalType &resultType)
Definition function.h:58
Function()
Definition function.h:65
std::string name
Definition function.h:59
TARGET * ptrCast()
Definition function.h:84
const TARGET * constPtrCast() const
Definition function.h:80
std::vector< common::LogicalTypeID > parameterTypeIDs
Definition function.h:60
Function(const Function &)=default
virtual ~Function()=default
Function(std::string name, std::vector< common::LogicalTypeID > parameterTypeIDs)
Definition function.h:66
virtual std::string signatureToString() const
Definition function.h:73
bool isVarLength
Definition function.h:63
virtual std::unique_ptr< Function > copy() const =0
Definition function.h:45
Function * definition
Definition function.h:47
const binder::expression_vector & arguments
Definition function.h:46
ScalarBindFuncInput(const binder::expression_vector &expressionVectors, Function *definition, main::ClientContext *context)
Definition function.h:50
main::ClientContext * context
Definition function.h:48