Kùzu C++ API
Loading...
Searching...
No Matches
unary_function_executor.h
Go to the documentation of this file.
1#pragma once
2
3#include "value_vector.h"
5
6namespace kuzu {
7namespace function {
8
15 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
16 static inline void operation(void* inputVector, uint64_t inputPos, void* resultVector,
17 uint64_t resultPos, void* /*dataPtr*/) {
18 auto& inputVector_ = *(common::ValueVector*)inputVector;
19 auto& resultVector_ = *(common::ValueVector*)resultVector;
20 FUNC::operation(inputVector_.getValue<OPERAND_TYPE>(inputPos),
21 resultVector_.getValue<RESULT_TYPE>(resultPos));
22 }
23};
24
26 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
27 static inline void operation(void* inputVector, uint64_t inputPos, void* resultVector,
28 uint64_t /* resultPos */, void* dataPtr) {
29 auto& inputVector_ = *(common::ValueVector*)inputVector;
30 auto& resultVector_ = *(common::ValueVector*)resultVector;
31 FUNC::operation(inputVector_.getValue<OPERAND_TYPE>(inputPos), resultVector_, dataPtr);
32 }
33};
34
36 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
37 static void operation(void* inputVector, uint64_t inputPos, void* resultVector,
38 uint64_t resultPos, void* /*dataPtr*/) {
39 auto& inputVector_ = *(common::ValueVector*)inputVector;
40 auto& resultVector_ = *(common::ValueVector*)resultVector;
41 FUNC::operation(inputVector_.getValue<OPERAND_TYPE>(inputPos),
42 resultVector_.getValue<RESULT_TYPE>(resultPos), resultVector_);
43 }
44};
45
47 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
48 static void operation(void* inputVector, uint64_t inputPos, void* resultVector,
49 uint64_t resultPos, void* dataPtr) {
50 auto& inputVector_ = *(common::ValueVector*)inputVector;
51 auto resultVector_ = (common::ValueVector*)resultVector;
52 // TODO(Ziyi): the reinterpret_cast is not safe since we don't always pass
53 // CastFunctionBindData
54 FUNC::operation(inputVector_.getValue<OPERAND_TYPE>(inputPos),
55 resultVector_->getValue<RESULT_TYPE>(resultPos), resultVector_, inputPos,
56 &reinterpret_cast<CastFunctionBindData*>(dataPtr)->option);
57 }
58};
59
61 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
62 static inline void operation(void* inputVector, uint64_t inputPos, void* resultVector,
63 uint64_t resultPos, void* /*dataPtr*/) {
64 auto& inputVector_ = *(common::ValueVector*)inputVector;
65 auto& resultVector_ = *(common::ValueVector*)resultVector;
66 FUNC::operation(inputVector_.getValue<OPERAND_TYPE>(inputPos),
67 resultVector_.getValue<RESULT_TYPE>(resultPos), inputVector_, resultVector_);
68 }
69};
70
72 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
73 static void operation(void* inputVector, uint64_t inputPos, void* resultVector,
74 uint64_t resultPos, void* /*dataPtr*/) {
75 auto& inputVector_ = *(common::ValueVector*)inputVector;
76 auto& resultVector_ = *(common::ValueVector*)resultVector;
77 FUNC::operation(inputVector_.getValue<OPERAND_TYPE>(inputPos),
78 resultVector_.getValue<RESULT_TYPE>(resultPos), inputVector_, resultVector_);
79 }
80};
81
83 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
84 static void operation(void* inputVector, uint64_t inputPos, void* resultVector,
85 uint64_t resultPos, void* /*dataPtr*/) {
86 auto& inputVector_ = *(common::ValueVector*)inputVector;
87 auto& resultVector_ = *(common::ValueVector*)resultVector;
89 inputVector_.getValue<OPERAND_TYPE>(inputPos), inputVector_, inputPos,
90 resultVector_.getValue<RESULT_TYPE>(resultPos), resultVector_, resultPos);
91 }
92};
93
95 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
96 static inline void operation(void* inputVector, uint64_t inputPos, void* resultVector,
97 uint64_t resultPos, void* dataPtr) {
98 auto& inputVector_ = *(common::ValueVector*)inputVector;
99 auto& resultVector_ = *(common::ValueVector*)resultVector;
100 FUNC::operation(inputVector_.getValue<OPERAND_TYPE>(inputPos),
101 resultVector_.getValue<RESULT_TYPE>(resultPos), dataPtr);
102 }
103};
104
106 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC, typename OP_WRAPPER>
107 static void executeOnValue(common::ValueVector& inputVector, uint64_t inputPos,
108 common::ValueVector& resultVector, uint64_t resultPos, void* dataPtr) {
109 OP_WRAPPER::template operation<OPERAND_TYPE, RESULT_TYPE, FUNC>((void*)&inputVector,
110 inputPos, (void*)&resultVector, resultPos, dataPtr);
111 }
112
113 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC, typename OP_WRAPPER>
115 void* dataPtr) {
116 result.resetAuxiliaryBuffer();
117 auto& operandSelVector = operand.state->getSelVector();
118 if (operand.state->isFlat()) {
119 auto inputPos = operandSelVector[0];
120 auto resultPos = result.state->getSelVector()[0];
121 result.setNull(resultPos, operand.isNull(inputPos));
122 if (!result.isNull(resultPos)) {
124 result, resultPos, dataPtr);
125 }
126 } else {
127 if (operand.hasNoNullsGuarantee()) {
128 if (operandSelVector.isUnfiltered()) {
129 for (auto i = 0u; i < operandSelVector.getSelSize(); i++) {
131 result, i, dataPtr);
132 }
133 } else {
134 for (auto i = 0u; i < operandSelVector.getSelSize(); i++) {
135 auto pos = operandSelVector[i];
137 result, pos, dataPtr);
138 }
139 }
140 } else {
141 if (operandSelVector.isUnfiltered()) {
142 for (auto i = 0u; i < operandSelVector.getSelSize(); i++) {
143 result.setNull(i, operand.isNull(i));
144 if (!result.isNull(i)) {
146 result, i, dataPtr);
147 }
148 }
149 } else {
150 for (auto i = 0u; i < operandSelVector.getSelSize(); i++) {
151 auto pos = operandSelVector[i];
152 result.setNull(pos, operand.isNull(pos));
153 if (!result.isNull(pos)) {
155 pos, result, pos, dataPtr);
156 }
157 }
158 }
159 }
160 }
161 }
162
163 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
164 static void execute(common::ValueVector& operand, common::ValueVector& result) {
166 nullptr /* dataPtr */);
167 }
168
169 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
171 void* dataPtr) {
173 dataPtr);
174 }
175
176 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
178 void* dataPtr) {
179 result.resetAuxiliaryBuffer();
180 auto inputPos = operand.state->getSelVector()[0];
181 auto resultPos = result.state->getSelVector()[0];
183 inputPos, result, resultPos, dataPtr);
184 }
185};
186
187} // namespace function
188} // namespace kuzu
Definition value_vector.h:20
uint8_t isNull(uint32_t pos) const
Definition value_vector.h:47
bool hasNoNullsGuarantee() const
Definition value_vector.h:41
void setNull(uint32_t pos, bool isNull)
std::shared_ptr< DataChunkState > state
Definition value_vector.h:105
Definition alter_type.h:5
Definition cast_function_bind_data.h:9
common::CSVOption option
Definition cast_function_bind_data.h:12
Definition unary_function_executor.h:71
static void operation(void *inputVector, uint64_t inputPos, void *resultVector, uint64_t resultPos, void *)
Definition unary_function_executor.h:73
Definition unary_function_executor.h:46
static void operation(void *inputVector, uint64_t inputPos, void *resultVector, uint64_t resultPos, void *dataPtr)
Definition unary_function_executor.h:48
Definition unary_function_executor.h:105
static void executeOnValue(common::ValueVector &inputVector, uint64_t inputPos, common::ValueVector &resultVector, uint64_t resultPos, void *dataPtr)
Definition unary_function_executor.h:107
static void execute(common::ValueVector &operand, common::ValueVector &result)
Definition unary_function_executor.h:164
static void executeSwitch(common::ValueVector &operand, common::ValueVector &result, void *dataPtr)
Definition unary_function_executor.h:114
static void executeUDF(common::ValueVector &operand, common::ValueVector &result, void *dataPtr)
Definition unary_function_executor.h:170
static void executeSequence(common::ValueVector &operand, common::ValueVector &result, void *dataPtr)
Definition unary_function_executor.h:177
Definition unary_function_executor.h:14
static void operation(void *inputVector, uint64_t inputPos, void *resultVector, uint64_t resultPos, void *)
Definition unary_function_executor.h:16
Definition unary_function_executor.h:60
static void operation(void *inputVector, uint64_t inputPos, void *resultVector, uint64_t resultPos, void *)
Definition unary_function_executor.h:62
Definition unary_function_executor.h:82
static void operation(void *inputVector, uint64_t inputPos, void *resultVector, uint64_t resultPos, void *)
Definition unary_function_executor.h:84
Definition unary_function_executor.h:25
static void operation(void *inputVector, uint64_t inputPos, void *resultVector, uint64_t, void *dataPtr)
Definition unary_function_executor.h:27
Definition unary_function_executor.h:35
static void operation(void *inputVector, uint64_t inputPos, void *resultVector, uint64_t resultPos, void *)
Definition unary_function_executor.h:37
Definition unary_function_executor.h:94
static void operation(void *inputVector, uint64_t inputPos, void *resultVector, uint64_t resultPos, void *dataPtr)
Definition unary_function_executor.h:96