rkavanap commented on a change in pull request #11016:
URL: https://github.com/apache/arrow/pull/11016#discussion_r743021359



##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -1790,8 +1816,10 @@ const char* lpad_utf8_int32_utf8(gdv_int64 context, 
const char* text, gdv_int32
     // case (return_length > text_char_count)
     // case where it needs to copy "fill_text" on the string left. The total 
number
     // of chars to copy is given by (return_length -  text_char_count)
-    char* ret =
-        reinterpret_cast<gdv_binary>(gdv_fn_context_arena_malloc(context, 
return_length));
+    gdv_int32 return_char_length = evaluate_return_char_length(

Review comment:
       return_char_length seems to be used only for allocation. Shouldn't the 
while loop in 1832 also use return_char_length?

##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -1851,8 +1881,10 @@ const char* rpad_utf8_int32_utf8(gdv_int64 context, 
const char* text, gdv_int32
   } else {
     // case (return_length > text_char_count)
     // case where it needs to copy "fill_text" on the string right
-    char* ret =
-        reinterpret_cast<gdv_binary>(gdv_fn_context_arena_malloc(context, 
return_length));
+    gdv_int32 return_char_length = evaluate_return_char_length(
+        text_len, text_char_count, return_length, fill_text, fill_text_len);
+    char* ret = reinterpret_cast<gdv_binary>(
+        gdv_fn_context_arena_malloc(context, return_char_length));

Review comment:
       same comment as above. Shouldn't the while loop in 1899 use 
return_char_length instead of return length?

##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -1790,8 +1816,10 @@ const char* lpad_utf8_int32_utf8(gdv_int64 context, 
const char* text, gdv_int32
     // case (return_length > text_char_count)
     // case where it needs to copy "fill_text" on the string left. The total 
number
     // of chars to copy is given by (return_length -  text_char_count)
-    char* ret =
-        reinterpret_cast<gdv_binary>(gdv_fn_context_arena_malloc(context, 
return_length));
+    gdv_int32 return_char_length = evaluate_return_char_length(

Review comment:
       return_char_length seems to be used only for allocation. Shouldn't the 
while loop in 1832 also use return_char_length?
   
   Never mind, the text_char_count was confusing. I think the text_char_count 
is actually text_len - invalid utf8..maybe rename 'text_char_count' to 
'actual_text_len'

##########
File path: cpp/src/gandiva/precompiled/string_ops.cc
##########
@@ -1851,8 +1881,10 @@ const char* rpad_utf8_int32_utf8(gdv_int64 context, 
const char* text, gdv_int32
   } else {
     // case (return_length > text_char_count)
     // case where it needs to copy "fill_text" on the string right
-    char* ret =
-        reinterpret_cast<gdv_binary>(gdv_fn_context_arena_malloc(context, 
return_length));
+    gdv_int32 return_char_length = evaluate_return_char_length(
+        text_len, text_char_count, return_length, fill_text, fill_text_len);
+    char* ret = reinterpret_cast<gdv_binary>(
+        gdv_fn_context_arena_malloc(context, return_char_length));

Review comment:
       same comment as above. Shouldn't the while loop in 1899 use 
return_char_length instead of return length?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to