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

Function translate_utf8_utf8_utf8

cpp/src/gandiva/gdv_string_function_stubs.cc:613–838  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

611 return out;
612}
613GANDIVA_EXPORT
614const char* translate_utf8_utf8_utf8(int64_t context, const char* in, int32_t in_len,
615 const char* from, int32_t from_len, const char* to,
616 int32_t to_len, int32_t* out_len) {
617 if (in_len <= 0) {
618 *out_len = 0;
619 return "";
620 }
621
622 if (from_len <= 0) {
623 *out_len = in_len;
624 return in;
625 }
626
627 int32_t alloc_length = 0;
628
629 // This variable is to control if there are multi-byte utf8 entries
630 bool has_multi_byte = false;
631
632 // This variable is to store the final result
633 char* result;
634 int32_t result_len;
635
636 // Searching multi-bytes in In
637 for (int32_t i = 0; i < in_len; i++) {
638 unsigned char char_single_byte = in[i];
639 if (char_single_byte > 127) {
640 // found a multi-byte utf-8 char
641 has_multi_byte = true;
642 break;
643 }
644 }
645
646 // Searching multi-bytes in From
647 if (!has_multi_byte) {
648 for (int32_t i = 0; i < from_len; i++) {
649 unsigned char char_single_byte = from[i];
650 if (char_single_byte > 127) {
651 // found a multi-byte utf-8 char
652 has_multi_byte = true;
653 break;
654 }
655 }
656 }
657
658 // Searching multi-bytes in To
659 if (!has_multi_byte) {
660 for (int32_t i = 0; i < to_len; i++) {
661 unsigned char char_single_byte = to[i];
662 if (char_single_byte > 127) {
663 // found a multi-byte utf-8 char
664 has_multi_byte = true;
665 break;
666 }
667 }
668 }
669
670 // If there are no multibytes in the input, work only with char

Callers 1

TESTFunction · 0.85

Calls 8

MultiplyWithOverflowFunction · 0.85
gdv_fn_utf8_char_lengthFunction · 0.85
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
lengthMethod · 0.45

Tested by 1

TESTFunction · 0.68