vvellanki commented on a change in pull request #11287:
URL: https://github.com/apache/arrow/pull/11287#discussion_r746227035
##########
File path: cpp/src/gandiva/gdv_function_stubs.cc
##########
@@ -798,14 +797,14 @@ const char* gdv_fn_initcap_utf8(int64_t context, const
char* data, int32_t data_
}
GANDIVA_EXPORT
-int32_t gdv_fn_instr_utf8(int64_t context, const char* string, int32_t
string_len,
- const char* substring, int32_t substring_len) {
+int32_t gdv_fn_instr_utf8(const char* string, int32_t string_len,
+ const char* substring, int32_t substring_len) {
if (substring_len == 0) {
return 1;
}
- for(int i = 0; i < string_len; i++) {
- if (string[i] == substring[0] && gandiva::string_matches(string + 1,
substring + 1, i, substring_len - 1)) {
+ for (int i = 0; i < string_len - substring_len; i++) {
Review comment:
Also, add test cases for string_len < substring_len
##########
File path: cpp/src/gandiva/gdv_function_stubs.cc
##########
@@ -798,14 +797,14 @@ const char* gdv_fn_initcap_utf8(int64_t context, const
char* data, int32_t data_
}
GANDIVA_EXPORT
-int32_t gdv_fn_instr_utf8(int64_t context, const char* string, int32_t
string_len,
- const char* substring, int32_t substring_len) {
+int32_t gdv_fn_instr_utf8(const char* string, int32_t string_len,
+ const char* substring, int32_t substring_len) {
if (substring_len == 0) {
return 1;
}
- for(int i = 0; i < string_len; i++) {
- if (string[i] == substring[0] && gandiva::string_matches(string + 1,
substring + 1, i, substring_len - 1)) {
+ for (int i = 0; i < string_len - substring_len; i++) {
Review comment:
Please handle the case where string_len is less than substring_len
--
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]