MCPcopy Create free account
hub / github.com/apache/arrow / gdv_fn_base64_encode_binary

Function gdv_fn_base64_encode_binary

cpp/src/gandiva/gdv_function_stubs.cc:232–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232GANDIVA_EXPORT
233const char* gdv_fn_base64_encode_binary(int64_t context, const char* in, int32_t in_len,
234 int32_t* out_len) {
235 if (in_len < 0) {
236 gdv_fn_context_set_error_msg(context, "Buffer length cannot be negative");
237 *out_len = 0;
238 return "";
239 }
240 if (in_len == 0) {
241 *out_len = 0;
242 return "";
243 }
244 // use arrow method to encode base64 string
245 std::string encoded_str = arrow::util::base64_encode(std::string_view(in, in_len));
246 *out_len = static_cast<int32_t>(encoded_str.length());
247 // allocate memory for response
248 char* ret = reinterpret_cast<char*>(
249 gdv_fn_context_arena_malloc(context, static_cast<int32_t>(*out_len)));
250 if (ret == nullptr) {
251 gdv_fn_context_set_error_msg(context, "Could not allocate memory");
252 *out_len = 0;
253 return "";
254 }
255 memcpy(ret, encoded_str.data(), *out_len);
256 return ret;
257}
258
259GANDIVA_EXPORT
260const char* gdv_fn_base64_decode_utf8(int64_t context, const char* in, int32_t in_len,

Callers 1

TESTFunction · 0.85

Calls 4

lengthMethod · 0.45
dataMethod · 0.45

Tested by 1

TESTFunction · 0.68