Kùzu C++ API
Loading...
Searching...
No Matches
table_functions.h
Go to the documentation of this file.
1#pragma once
2
3#include "data_chunk.h"
4#include "function.h"
5
6namespace kuzu {
7namespace main {
8class ClientContext;
9}
10
11namespace function {
12
13struct TableFuncBindData;
14struct TableFuncBindInput;
15
17 virtual ~TableFuncSharedState() = default;
18
19 template<class TARGET>
23};
24
26 virtual ~TableFuncLocalState() = default;
27
28 template<class TARGET>
32};
33
45
46// We are in the middle of merging different scan operators into table function. But they organize
47// output vectors in different ways. E.g.
48// - Call functions and scan file functions put all vectors into single data chunk
49// - Factorized table scan instead
50// We introduce this as a temporary solution to unify the interface. In the long term, we should aim
51// to use ResultSet as TableFuncOutput.
59
61 TableFuncBindData* bindData;
62
63 explicit TableFunctionInitInput(TableFuncBindData* bindData) : bindData{bindData} {}
64
65 virtual ~TableFunctionInitInput() = default;
66};
67
68using table_func_bind_t = std::function<std::unique_ptr<TableFuncBindData>(main::ClientContext*,
72 std::function<std::unique_ptr<TableFuncSharedState>(TableFunctionInitInput&)>;
73using table_func_init_local_t = std::function<std::unique_ptr<TableFuncLocalState>(
74 TableFunctionInitInput&, TableFuncSharedState*, storage::MemoryManager*)>;
75using table_func_can_parallel_t = std::function<bool()>;
76using table_func_progress_t = std::function<double(TableFuncSharedState* sharedState)>;
77
83 table_func_can_parallel_t canParallelFunc = [] { return true; };
84 table_func_progress_t progressFunc = [](TableFuncSharedState*) { return 0.0; };
85
87 : Function{}, tableFunc{nullptr}, bindFunc{nullptr}, initSharedStateFunc{nullptr},
88 initLocalStateFunc{nullptr} {};
89 TableFunction(std::string name, table_func_t tableFunc, table_func_bind_t bindFunc,
90 table_func_init_shared_t initSharedFunc, table_func_init_local_t initLocalFunc,
91 std::vector<common::LogicalTypeID> inputTypes)
92 : Function{std::move(name), std::move(inputTypes)}, tableFunc{tableFunc},
93 bindFunc{bindFunc}, initSharedStateFunc{initSharedFunc},
94 initLocalStateFunc{initLocalFunc} {}
95 TableFunction(std::string name, table_func_t tableFunc, table_func_bind_t bindFunc,
96 table_func_init_shared_t initSharedFunc, table_func_init_local_t initLocalFunc,
97 table_func_progress_t progressFunc, std::vector<common::LogicalTypeID> inputTypes)
98 : Function{std::move(name), std::move(inputTypes)}, tableFunc{tableFunc},
99 bindFunc{bindFunc}, initSharedStateFunc{initSharedFunc},
100 initLocalStateFunc{initLocalFunc}, progressFunc{progressFunc} {}
101
102 std::string signatureToString() const override {
103 return common::LogicalTypeUtils::toString(parameterTypeIDs);
104 }
105
106 std::unique_ptr<Function> copy() const override {
107 return std::make_unique<TableFunction>(*this);
108 }
109};
110
111} // namespace function
112} // namespace kuzu
#define KUZU_API
Definition api.h:25
Definition data_chunk.h:20
Contain client side configuration. We make profiler associated per query, so profiler is not maintain...
Definition client_context.h:51
TO ku_dynamic_cast(FROM old)
Definition cast.h:11
uint64_t offset_t
Definition internal_id_t.h:22
std::function< std::unique_ptr< TableFuncBindData >(main::ClientContext *, function::TableFuncBindInput *)> table_func_bind_t
Definition table_functions.h:68
std::function< std::unique_ptr< TableFuncSharedState >(TableFunctionInitInput &)> table_func_init_shared_t
Definition table_functions.h:71
std::function< bool()> table_func_can_parallel_t
Definition table_functions.h:75
std::function< std::unique_ptr< TableFuncLocalState >( TableFunctionInitInput &, TableFuncSharedState *, storage::MemoryManager *)> table_func_init_local_t
Definition table_functions.h:73
std::function< common::offset_t(TableFuncInput &, TableFuncOutput &)> table_func_t
Definition table_functions.h:70
std::function< double(TableFuncSharedState *sharedState)> table_func_progress_t
Definition table_functions.h:76
Definition alter_type.h:5
Definition function.h:58
Definition bind_input.h:16
Definition table_functions.h:34
TableFuncSharedState * sharedState
Definition table_functions.h:37
TableFuncBindData * bindData
Definition table_functions.h:35
DELETE_COPY_DEFAULT_MOVE(TableFuncInput)
TableFuncLocalState * localState
Definition table_functions.h:36
TableFuncInput(TableFuncBindData *bindData, TableFuncLocalState *localState, TableFuncSharedState *sharedState)
Definition table_functions.h:40
Definition table_functions.h:25
virtual ~TableFuncLocalState()=default
TARGET * ptrCast()
Definition table_functions.h:29
Definition table_functions.h:52
common::DataChunk dataChunk
Definition table_functions.h:53
DELETE_COPY_DEFAULT_MOVE(TableFuncOutput)
std::vector< common::ValueVector * > vectors
Definition table_functions.h:54
Definition table_functions.h:16
TARGET * ptrCast()
Definition table_functions.h:20
Definition table_functions.h:78
std::unique_ptr< Function > copy() const override
Definition table_functions.h:106
table_func_bind_t bindFunc
Definition table_functions.h:80
TableFunction()
Definition table_functions.h:86
table_func_init_local_t initLocalStateFunc
Definition table_functions.h:82
TableFunction(std::string name, table_func_t tableFunc, table_func_bind_t bindFunc, table_func_init_shared_t initSharedFunc, table_func_init_local_t initLocalFunc, std::vector< common::LogicalTypeID > inputTypes)
Definition table_functions.h:89
table_func_t tableFunc
Definition table_functions.h:79
TableFunction(std::string name, table_func_t tableFunc, table_func_bind_t bindFunc, table_func_init_shared_t initSharedFunc, table_func_init_local_t initLocalFunc, table_func_progress_t progressFunc, std::vector< common::LogicalTypeID > inputTypes)
Definition table_functions.h:95
std::string signatureToString() const override
Definition table_functions.h:102
table_func_init_shared_t initSharedStateFunc
Definition table_functions.h:81
Definition table_functions.h:60
TableFunctionInitInput(TableFuncBindData *bindData)
Definition table_functions.h:63
TableFuncBindData * bindData
Definition table_functions.h:61