MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / execFunc

Method execFunc

src/function/vector_string_functions.cpp:104–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

102}
103
104void ConcatFunction::execFunc(const std::vector<std::shared_ptr<common::ValueVector>>& parameters,
105 const std::vector<common::SelectionVector*>& parameterSelVectors, common::ValueVector& result,
106 common::SelectionVector* resultSelVector, void* /*dataPtr*/) {
107 result.resetAuxiliaryBuffer();
108 for (auto selectedPos = 0u; selectedPos < resultSelVector->getSelSize(); ++selectedPos) {
109 auto pos = (*resultSelVector)[selectedPos];
110 auto strLen = 0u;
111 for (auto i = 0u; i < parameters.size(); i++) {
112 const auto& parameter = *parameters[i];
113 const auto& parameterSelVector = parameterSelVectors[i];
114 auto paramPos = (*parameterSelVector)[parameter.state->isFlat() ? 0 : selectedPos];
115 if (!parameter.isNull(paramPos)) {
116 strLen += parameter.getValue<string_t>(paramPos).len;
117 }
118 }
119 auto& resultStr = result.getValue<string_t>(pos);
120 StringVector::reserveString(&result, resultStr, strLen);
121 auto dstData = strLen <= string_t::SHORT_STR_LENGTH ?
122 resultStr.prefix :
123 reinterpret_cast<uint8_t*>(resultStr.overflowPtr);
124 for (auto i = 0u; i < parameters.size(); i++) {
125 const auto& parameter = *parameters[i];
126 const auto& parameterSelVector = parameterSelVectors[i];
127 auto paramPos = (*parameterSelVector)[parameter.state->isFlat() ? 0 : selectedPos];
128 if (!parameter.isNull(paramPos)) {
129 auto srcStr = parameter.getValue<string_t>(paramPos);
130 memcpy(dstData, srcStr.getData(), srcStr.len);
131 dstData += srcStr.len;
132 }
133 }
134 if (strLen > string_t::SHORT_STR_LENGTH) {
135 memcpy(resultStr.prefix, resultStr.getData(), string_t::PREFIX_LENGTH);
136 }
137 }
138}
139
140function_set ConcatFunction::getFunctionSet() {
141 function_set functionSet;

Callers

nothing calls this directly

Calls 7

getSelSizeMethod · 0.80
getValue<string_t>Method · 0.80
resetAuxiliaryBufferMethod · 0.45
sizeMethod · 0.45
isFlatMethod · 0.45
isNullMethod · 0.45
getDataMethod · 0.45

Tested by

no test coverage detected