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& resultVector_ = *(common::ValueVector*)resultVector;
51 FUNC::operation(resultVector_.getValue<RESULT_TYPE>(resultPos), resultVector_, dataPtr);
52 }
53};
54
56 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
57 static void operation(void* inputVector, uint64_t inputPos, void* resultVector,
58 uint64_t resultPos, void* dataPtr) {
59 auto& inputVector_ = *(common::ValueVector*)inputVector;
60 auto resultVector_ = (common::ValueVector*)resultVector;
61 // TODO(Ziyi): the reinterpret_cast is not safe since we don't always pass
62 // CastFunctionBindData
63 FUNC::operation(inputVector_.getValue<OPERAND_TYPE>(inputPos),
64 resultVector_->getValue<RESULT_TYPE>(resultPos), resultVector_, inputPos,
65 &reinterpret_cast<CastFunctionBindData*>(dataPtr)->option);
66 }
67};
68
70 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
71 static inline void operation(void* inputVector, uint64_t inputPos, void* resultVector,
72 uint64_t resultPos, void* /*dataPtr*/) {
73 auto& inputVector_ = *(common::ValueVector*)inputVector;
74 auto& resultVector_ = *(common::ValueVector*)resultVector;
75 FUNC::operation(inputVector_.getValue<OPERAND_TYPE>(inputPos),
76 resultVector_.getValue<RESULT_TYPE>(resultPos), inputVector_, resultVector_);
77 }
78};
79
81 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
82 static void operation(void* inputVector, uint64_t inputPos, void* resultVector,
83 uint64_t resultPos, void* /*dataPtr*/) {
84 auto& inputVector_ = *(common::ValueVector*)inputVector;
85 auto& resultVector_ = *(common::ValueVector*)resultVector;
86 FUNC::operation(inputVector_.getValue<OPERAND_TYPE>(inputPos),
87 resultVector_.getValue<RESULT_TYPE>(resultPos), inputVector_, resultVector_);
88 }
89};
90
92 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
93 static inline void operation(void* inputVector, uint64_t inputPos, void* resultVector,
94 uint64_t resultPos, void* dataPtr) {
95 auto& inputVector_ = *(common::ValueVector*)inputVector;
96 auto& resultVector_ = *(common::ValueVector*)resultVector;
97 FUNC::operation(inputVector_.getValue<OPERAND_TYPE>(inputPos),
98 resultVector_.getValue<RESULT_TYPE>(resultPos), dataPtr);
99 }
100};
101
103 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC, typename OP_WRAPPER>
104 static void executeOnValue(common::ValueVector& inputVector, uint64_t inputPos,
105 common::ValueVector& resultVector, uint64_t resultPos, void* dataPtr) {
106 OP_WRAPPER::template operation<OPERAND_TYPE, RESULT_TYPE, FUNC>((void*)&inputVector,
107 inputPos, (void*)&resultVector, resultPos, dataPtr);
108 }
109
110 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC, typename OP_WRAPPER>
112 void* dataPtr) {
113 result.resetAuxiliaryBuffer();
114 auto& operandSelVector = operand.state->getSelVector();
115 if (operand.state->isFlat()) {
116 auto inputPos = operandSelVector[0];
117 auto resultPos = result.state->getSelVector()[0];
118 result.setNull(resultPos, operand.isNull(inputPos));
119 if (!result.isNull(resultPos)) {
121 result, resultPos, dataPtr);
122 }
123 } else {
124 if (operand.hasNoNullsGuarantee()) {
125 if (operandSelVector.isUnfiltered()) {
126 for (auto i = 0u; i < operandSelVector.getSelSize(); i++) {
128 result, i, dataPtr);
129 }
130 } else {
131 for (auto i = 0u; i < operandSelVector.getSelSize(); i++) {
132 auto pos = operandSelVector[i];
134 result, pos, dataPtr);
135 }
136 }
137 } else {
138 if (operandSelVector.isUnfiltered()) {
139 for (auto i = 0u; i < operandSelVector.getSelSize(); i++) {
140 result.setNull(i, operand.isNull(i));
141 if (!result.isNull(i)) {
143 result, i, dataPtr);
144 }
145 }
146 } else {
147 for (auto i = 0u; i < operandSelVector.getSelSize(); i++) {
148 auto pos = operandSelVector[i];
149 result.setNull(pos, operand.isNull(pos));
150 if (!result.isNull(pos)) {
152 pos, result, pos, dataPtr);
153 }
154 }
155 }
156 }
157 }
158 }
159
160 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
161 static void execute(common::ValueVector& operand, common::ValueVector& result) {
163 nullptr /* dataPtr */);
164 }
165
166 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
168 void* dataPtr) {
170 dataPtr);
171 }
172
173 template<typename OPERAND_TYPE, typename RESULT_TYPE, typename FUNC>
175 void* dataPtr) {
176 result.resetAuxiliaryBuffer();
177 auto inputPos = operand.state->getSelVector()[0];
178 auto resultPos = result.state->getSelVector()[0];
180 inputPos, result, resultPos, dataPtr);
181 }
182};
183
184} // namespace function
185} // namespace kuzu
Definition value_vector.h:21
uint8_t isNull(uint32_t pos) const
Definition value_vector.h:76
bool hasNoNullsGuarantee() const
Definition value_vector.h:70
void setNull(uint32_t pos, bool isNull)
std::shared_ptr< DataChunkState > state
Definition value_vector.h:134
Definition array_utils.h:7
Definition cast_function_bind_data.h:9
common::CSVOption option
Definition cast_function_bind_data.h:12
Definition unary_function_executor.h:80
static void operation(void *inputVector, uint64_t inputPos, void *resultVector, uint64_t resultPos, void *)
Definition unary_function_executor.h:82
Definition unary_function_executor.h:55
static void operation(void *inputVector, uint64_t inputPos, void *resultVector, uint64_t resultPos, void *dataPtr)
Definition unary_function_executor.h:57
Definition unary_function_executor.h:102
static void executeOnValue(common::ValueVector &inputVector, uint64_t inputPos, common::ValueVector &resultVector, uint64_t resultPos, void *dataPtr)
Definition unary_function_executor.h:104
static void execute(common::ValueVector &operand, common::ValueVector &result)
Definition unary_function_executor.h:161
static void executeSwitch(common::ValueVector &operand, common::ValueVector &result, void *dataPtr)
Definition unary_function_executor.h:111
static void executeUDF(common::ValueVector &operand, common::ValueVector &result, void *dataPtr)
Definition unary_function_executor.h:167
static void executeSequence(common::ValueVector &operand, common::ValueVector &result, void *dataPtr)
Definition unary_function_executor.h:174
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:69
static void operation(void *inputVector, uint64_t inputPos, void *resultVector, uint64_t resultPos, void *)
Definition unary_function_executor.h:71
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:46
static void operation(void *, uint64_t, void *resultVector, uint64_t resultPos, void *dataPtr)
Definition unary_function_executor.h:48
Definition unary_function_executor.h:91
static void operation(void *inputVector, uint64_t inputPos, void *resultVector, uint64_t resultPos, void *dataPtr)
Definition unary_function_executor.h:93