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<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].
63 bool isVarLength = false;
64 bool isListLambda = false;
65
66 Function() : isVarLength{false}, isListLambda{false} {};
67 Function(std::string name, std::vector<common::LogicalTypeID> parameterTypeIDs)
68 : name{std::move(name)}, parameterTypeIDs{std::move(parameterTypeIDs)}, isVarLength{false},
69 isListLambda{false} {}
70 Function(const Function&) = default;
71
72 virtual ~Function() = default;
73
74 virtual std::string signatureToString() const {
76 }
77
78 template<class TARGET>
79 const TARGET* constPtrCast() const {
81 }
82 template<class TARGET>
83 TARGET* ptrCast() {
85 }
86};
87
91
92 ScalarOrAggregateFunction() : returnTypeID{common::LogicalTypeID::ANY}, bindFunc{nullptr} {}
93 ScalarOrAggregateFunction(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:246
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:57
std::vector< std::shared_ptr< Expression > > expression_vector
Definition expression.h:19
LogicalTypeID
Definition types.h:167
TO ku_dynamic_cast(FROM *old)
Definition cast.h:11
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 array_utils.h:7
static std::string toString(LogicalTypeID dataTypeID)
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:66
std::string name
Definition function.h:59
TARGET * ptrCast()
Definition function.h:83
const TARGET * constPtrCast() const
Definition function.h:79
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:67
virtual std::string signatureToString() const
Definition function.h:74
bool isVarLength
Definition function.h:63
bool isListLambda
Definition function.h:64
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
ScalarOrAggregateFunction()
Definition function.h:92
common::LogicalTypeID returnTypeID
Definition function.h:89
ScalarOrAggregateFunction(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
scalar_bind_func bindFunc
Definition function.h:90