Kuzu 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;
17 // TODO: the following two fields should be moved to FunctionLocalState.
19 int64_t count;
20
22 : resultType{std::move(dataType)}, clientContext{nullptr}, count{1} {}
23 FunctionBindData(std::vector<common::LogicalType> paramTypes, common::LogicalType resultType)
24 : paramTypes{std::move(paramTypes)}, resultType{std::move(resultType)},
25 clientContext{nullptr}, count{1} {}
27 virtual ~FunctionBindData() = default;
28
29 static std::unique_ptr<FunctionBindData> getSimpleBindData(
31
32 template<class TARGET>
33 TARGET& cast() {
35 }
36
37 virtual std::unique_ptr<FunctionBindData> copy() const {
38 return std::make_unique<FunctionBindData>(common::LogicalType::copy(paramTypes),
39 resultType.copy());
40 }
41};
42
43struct Function;
44using function_set = std::vector<std::unique_ptr<Function>>;
45
57
59 std::function<std::unique_ptr<FunctionBindData>(const ScalarBindFuncInput& bindInput)>;
60
62 std::string name;
63 std::vector<common::LogicalTypeID> parameterTypeIDs;
64 // Currently we only one variable-length function which is list creation. The expectation is
65 // that all parameters must have the same type as parameterTypes[0].
66 // For variable length function. A
67 bool isVarLength = false;
68 bool isListLambda = false;
69 bool isReadOnly = true;
70
71 Function() : isVarLength{false}, isListLambda{false}, isReadOnly{true} {};
72 Function(std::string name, std::vector<common::LogicalTypeID> parameterTypeIDs)
73 : name{std::move(name)}, parameterTypeIDs{std::move(parameterTypeIDs)}, isVarLength{false},
74 isListLambda{false} {}
75 Function(const Function&) = default;
76
77 virtual ~Function() = default;
78
79 virtual std::string signatureToString() const {
81 }
82
83 template<class TARGET>
84 const TARGET* constPtrCast() const {
86 }
87 template<class TARGET>
88 TARGET* ptrCast() {
90 }
91};
92
96
98 ScalarOrAggregateFunction(std::string name, std::vector<common::LogicalTypeID> parameterTypeIDs,
100 : Function{std::move(name), std::move(parameterTypeIDs)}, returnTypeID{returnTypeID} {}
101 ScalarOrAggregateFunction(std::string name, std::vector<common::LogicalTypeID> parameterTypeIDs,
103 : Function{std::move(name), std::move(parameterTypeIDs)}, returnTypeID{returnTypeID},
104 bindFunc{std::move(bindFunc)} {}
105
106 std::string signatureToString() const override {
107 auto result = Function::signatureToString();
109 return result;
110 }
111};
112
113} // namespace function
114} // namespace kuzu
#define KUZU_API
Definition api.h:25
Definition types.h:256
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:68
std::vector< std::shared_ptr< Expression > > expression_vector
Definition expression.h:20
LogicalTypeID
Definition types.h:177
@ ANY
Definition types.h:178
TO ku_dynamic_cast(FROM *old)
Definition cast.h:11
Definition binary_function_executor.h:6
std::vector< std::unique_ptr< Function > > function_set
Definition function.h:44
std::function< std::unique_ptr< FunctionBindData >(const ScalarBindFuncInput &bindInput)> scalar_bind_func
Definition function.h:58
Definition bind_input.h:16
Definition array_utils.h:7
static std::string toString(LogicalTypeID dataTypeID)
DELETE_COPY_AND_MOVE(FunctionBindData)
virtual std::unique_ptr< FunctionBindData > copy() const
Definition function.h:37
common::LogicalType resultType
Definition function.h:16
TARGET & cast()
Definition function.h:33
int64_t count
Definition function.h:19
virtual ~FunctionBindData()=default
std::vector< common::LogicalType > paramTypes
Definition function.h:15
FunctionBindData(std::vector< common::LogicalType > paramTypes, common::LogicalType resultType)
Definition function.h:23
main::ClientContext * clientContext
Definition function.h:18
FunctionBindData(common::LogicalType dataType)
Definition function.h:21
static std::unique_ptr< FunctionBindData > getSimpleBindData(const binder::expression_vector &params, const common::LogicalType &resultType)
Definition function.h:61
Function()
Definition function.h:71
std::string name
Definition function.h:62
TARGET * ptrCast()
Definition function.h:88
const TARGET * constPtrCast() const
Definition function.h:84
std::vector< common::LogicalTypeID > parameterTypeIDs
Definition function.h:63
Function(const Function &)=default
bool isReadOnly
Definition function.h:69
virtual ~Function()=default
Function(std::string name, std::vector< common::LogicalTypeID > parameterTypeIDs)
Definition function.h:72
virtual std::string signatureToString() const
Definition function.h:79
bool isVarLength
Definition function.h:67
bool isListLambda
Definition function.h:68
Definition function.h:46
std::vector< std::string > optionalArguments
Definition function.h:50
ScalarBindFuncInput(const binder::expression_vector &arguments, Function *definition, main::ClientContext *context, std::vector< std::string > optionalArguments)
Definition function.h:52
Function * definition
Definition function.h:48
const binder::expression_vector & arguments
Definition function.h:47
main::ClientContext * context
Definition function.h:49
ScalarOrAggregateFunction(std::string name, std::vector< common::LogicalTypeID > parameterTypeIDs, common::LogicalTypeID returnTypeID)
Definition function.h:98
ScalarOrAggregateFunction()
Definition function.h:97
common::LogicalTypeID returnTypeID
Definition function.h:94
ScalarOrAggregateFunction(std::string name, std::vector< common::LogicalTypeID > parameterTypeIDs, common::LogicalTypeID returnTypeID, scalar_bind_func bindFunc)
Definition function.h:101
std::string signatureToString() const override
Definition function.h:106
scalar_bind_func bindFunc
Definition function.h:95