imay commented on a change in pull request #1445: Add string function split_part
URL: https://github.com/apache/incubator-doris/pull/1445#discussion_r301368087
##########
File path: be/src/exprs/string_functions.cpp
##########
@@ -761,4 +761,61 @@ StringVal StringFunctions::money_format(FunctionContext
*context, const LargeInt
return do_money_format(context, ss.str());
}
+static int indexOf(const uint8_t* source, int sourceOffset, int sourceCount,
+ const uint8_t* target, int targetOffset, int targetCount,
+ int fromIndex) {
+ if (fromIndex >= sourceCount) {
+ return (targetCount == 0 ? sourceCount : -1);
+ }
+ if (fromIndex < 0) {
+ fromIndex = 0;
+ }
+ if (targetCount == 0) {
+ return fromIndex;
+ }
+ const uint8_t first = target[targetOffset];
+ int max = sourceOffset + (sourceCount - targetCount);
+ for (int i = sourceOffset + fromIndex; i <= max; i++) {
+ if (source[i] != first) { // Look for first character
+ while (++i <= max && source[i] != first);
+ }
+ if (i <= max) { // Found first character, now look at the rest of v2
+ int j = i + 1;
+ int end = j + targetCount - 1;
+ for (int k = targetOffset + 1; j < end && source[j] == target[k];
j++, k++);
+ if (j == end) {
+ return i - sourceOffset; // Found whole string.
+ }
+ }
+ }
+ return -1;
+}
+
+
+StringVal StringFunctions::split_part(FunctionContext* context,const
StringVal& content,
Review comment:
```suggestion
StringVal StringFunctions::split_part(FunctionContext* context, const
StringVal& content,
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]