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

Function repeat_utf8_int32

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

Source from the content-addressed store, hash-verified

847}
848
849FORCE_INLINE
850const char* repeat_utf8_int32(gdv_int64 context, const char* in, gdv_int32 in_len,
851 gdv_int32 repeat_number, gdv_int32* out_len) {
852 // if the repeat number is zero, then return empty string
853 if (repeat_number == 0 || in_len <= 0) {
854 *out_len = 0;
855 return "";
856 }
857 // if the repeat number is a negative number, an error is set on context
858 if (repeat_number < 0) {
859 char err_msg[96];
860 snprintf(err_msg, sizeof(err_msg), "REPEAT: Repeat number can't be negative, got %d",
861 repeat_number);
862 gdv_fn_context_set_error_msg(context, err_msg);
863 *out_len = 0;
864 return "";
865 }
866 if (ARROW_PREDICT_FALSE(
867 arrow::internal::MultiplyWithOverflow(repeat_number, in_len, out_len))) {
868 char err_msg[128];
869 snprintf(err_msg, sizeof(err_msg),
870 "REPEAT: Would overflow maximum output size "
871 "(repeat count %d * input length %d)",
872 repeat_number, in_len);
873 gdv_fn_context_set_error_msg(context, err_msg);
874 *out_len = 0;
875 return "";
876 }
877 char* ret = reinterpret_cast<char*>(gdv_fn_context_arena_malloc(context, *out_len));
878 if (ret == nullptr) {
879 gdv_fn_context_set_error_msg(context, "Could not allocate memory for output string");
880 *out_len = 0;
881 return "";
882 }
883 for (int i = 0; i < repeat_number; ++i) {
884 memcpy(ret + (i * in_len), in, in_len);
885 }
886 return ret;
887}
888
889FORCE_INLINE
890const 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