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

Function repeat_utf8_int32

cpp/src/gandiva/precompiled/string_ops.cc:832–862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

830}
831
832FORCE_INLINE
833const char* repeat_utf8_int32(gdv_int64 context, const char* in, gdv_int32 in_len,
834 gdv_int32 repeat_number, gdv_int32* out_len) {
835 // if the repeat number is zero, then return empty string
836 if (repeat_number == 0 || in_len <= 0) {
837 *out_len = 0;
838 return "";
839 }
840 // if the repeat number is a negative number, an error is set on context
841 if (repeat_number < 0) {
842 gdv_fn_context_set_error_msg(context, "Repeat number can't be negative");
843 *out_len = 0;
844 return "";
845 }
846 if (ARROW_PREDICT_FALSE(
847 arrow::internal::MultiplyWithOverflow(repeat_number, in_len, out_len))) {
848 gdv_fn_context_set_error_msg(context, "Would overflow maximum output size");
849 *out_len = 0;
850 return "";
851 }
852 char* ret = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, *out_len));
853 if (ret == nullptr) {
854 gdv_fn_context_set_error_msg(context, "Could not allocate memory for output string");
855 *out_len = 0;
856 return "";
857 }
858 for (int i = 0; i < repeat_number; ++i) {
859 memcpy(ret + (i * in_len), in, in_len);
860 }
861 return ret;
862}
863
864FORCE_INLINE
865const char* concat_utf8_utf8(gdv_int64 context, const char* left, gdv_int32 left_len,

Callers 1

TESTFunction · 0.85

Calls 3

MultiplyWithOverflowFunction · 0.85

Tested by 1

TESTFunction · 0.68