You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "pie-humble-pie (via GitHub)" <gi...@apache.org> on 2025/12/25 12:38:08 UTC
[PR] Optimize splitPart To Reduce Allocations [pinot]
pie-humble-pie opened a new pull request, #17428:
URL: https://github.com/apache/pinot/pull/17428
The splitPart function is very allocation heavy. It first calculates all splits and then only returns the one indexed as requested by its argument. That is very allocation expensive when the index is very small and the separator is repeated several times.
This change optimizes splitPart to tokenize to a limit based on the index specified to reduce allocations
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Optimize splitPart To Reduce Allocations [pinot]
Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang closed pull request #17428: Optimize splitPart To Reduce Allocations
URL: https://github.com/apache/pinot/pull/17428
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Optimize splitPart To Reduce Allocations [pinot]
Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on code in PR #17428:
URL: https://github.com/apache/pinot/pull/17428#discussion_r2673823281
##########
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/StringFunctions.java:
##########
@@ -551,17 +555,234 @@ public static String[] suffixesWithSuffix(String input, int maxlength, @Nullable
*/
@ScalarFunction
public static String splitPart(String input, String delimiter, int index) {
- String[] splitString = StringUtils.splitByWholeSeparator(input, delimiter);
- if (index >= 0 && index < splitString.length) {
- return splitString[index];
- } else if (index < 0 && index >= -splitString.length) {
- return splitString[splitString.length + index];
- } else {
- return "null";
- }
+ if (input == null || delimiter == null) {
Review Comment:
We don't need to handle `null` as the scalar function framework is able to handle them
##########
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/StringFunctions.java:
##########
@@ -551,17 +555,234 @@ public static String[] suffixesWithSuffix(String input, int maxlength, @Nullable
*/
@ScalarFunction
public static String splitPart(String input, String delimiter, int index) {
- String[] splitString = StringUtils.splitByWholeSeparator(input, delimiter);
- if (index >= 0 && index < splitString.length) {
- return splitString[index];
- } else if (index < 0 && index >= -splitString.length) {
- return splitString[splitString.length + index];
- } else {
- return "null";
- }
+ if (input == null || delimiter == null) {
Review Comment:
Please follow [Pinot Style](https://docs.pinot.apache.org/developers/developers-and-contributors/code-setup#set-up-ide)
##########
pinot-common/src/main/java/org/apache/pinot/common/function/scalar/StringFunctions.java:
##########
@@ -551,17 +555,234 @@ public static String[] suffixesWithSuffix(String input, int maxlength, @Nullable
*/
@ScalarFunction
public static String splitPart(String input, String delimiter, int index) {
- String[] splitString = StringUtils.splitByWholeSeparator(input, delimiter);
- if (index >= 0 && index < splitString.length) {
- return splitString[index];
- } else if (index < 0 && index >= -splitString.length) {
- return splitString[splitString.length + index];
- } else {
- return "null";
- }
+ if (input == null || delimiter == null) {
+ return "null";
+ }
+
+ int delimiterLength = delimiter.length();
+ if (delimiterLength == 0) {
+ return input;
+ }
+
+ String[] splitString;
+ if (index >= 0) {
+ int limit = index + 2;
+ splitString = splitBySeparatorTillLimitForward(input, delimiter, limit);
Review Comment:
Is it possible to directly find the index instead of returning an array then look up the index? Same for the backward search
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Optimize splitPart To Reduce Allocations [pinot]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #17428:
URL: https://github.com/apache/pinot/pull/17428#issuecomment-3740771151
## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/17428?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `41.00719%` with `82 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 55.65%. Comparing base ([`4e8ebf3`](https://app.codecov.io/gh/apache/pinot/commit/4e8ebf364f07039f7a342017fa2cf64a00df3b3b?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`574c83b`](https://app.codecov.io/gh/apache/pinot/commit/574c83b8d80046878acd3e94adebe80ddb707457?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 55 commits behind head on master.
| [Files with missing lines](https://app.codecov.io/gh/apache/pinot/pull/17428?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [.../pinot/common/function/scalar/StringFunctions.java](https://app.codecov.io/gh/apache/pinot/pull/17428?src=pr&el=tree&filepath=pinot-common%2Fsrc%2Fmain%2Fjava%2Forg%2Fapache%2Fpinot%2Fcommon%2Ffunction%2Fscalar%2FStringFunctions.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vZnVuY3Rpb24vc2NhbGFyL1N0cmluZ0Z1bmN0aW9ucy5qYXZh) | 41.00% | [71 Missing and 11 partials :warning: ](https://app.codecov.io/gh/apache/pinot/pull/17428?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
> :exclamation: There is a different number of reports uploaded between BASE (4e8ebf3) and HEAD (574c83b). Click for more details.
>
> <details><summary>HEAD has 36 uploads less than BASE</summary>
>
>| Flag | BASE (4e8ebf3) | HEAD (574c83b) |
>|------|------|------|
>|java-21|5|1|
>|unittests1|2|1|
>|unittests|4|1|
>|temurin|10|1|
>|java-11|5|0|
>|unittests2|2|0|
>|integration|6|0|
>|integration2|2|0|
>|integration1|2|0|
>|custom-integration1|2|0|
></details>
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #17428 +/- ##
============================================
- Coverage 63.25% 55.65% -7.60%
+ Complexity 1474 702 -772
============================================
Files 3154 2463 -691
Lines 187964 139148 -48816
Branches 28779 22200 -6579
============================================
- Hits 118888 77440 -41448
+ Misses 59862 55175 -4687
+ Partials 9214 6533 -2681
```
| [Flag](https://app.codecov.io/gh/apache/pinot/pull/17428/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
|---|---|---|
| [custom-integration1](https://app.codecov.io/gh/apache/pinot/pull/17428/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration](https://app.codecov.io/gh/apache/pinot/pull/17428/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration1](https://app.codecov.io/gh/apache/pinot/pull/17428/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [integration2](https://app.codecov.io/gh/apache/pinot/pull/17428/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [java-11](https://app.codecov.io/gh/apache/pinot/pull/17428/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [java-21](https://app.codecov.io/gh/apache/pinot/pull/17428/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.65% <41.00%> (-7.57%)` | :arrow_down: |
| [temurin](https://app.codecov.io/gh/apache/pinot/pull/17428/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.65% <41.00%> (-7.60%)` | :arrow_down: |
| [unittests](https://app.codecov.io/gh/apache/pinot/pull/17428/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.65% <41.00%> (-7.60%)` | :arrow_down: |
| [unittests1](https://app.codecov.io/gh/apache/pinot/pull/17428/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.65% <41.00%> (-0.03%)` | :arrow_down: |
| [unittests2](https://app.codecov.io/gh/apache/pinot/pull/17428/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/pinot/pull/17428?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
Re: [PR] Optimize splitPart To Reduce Allocations [pinot]
Posted by "Jackie-Jiang (via GitHub)" <gi...@apache.org>.
Jackie-Jiang commented on PR #17428:
URL: https://github.com/apache/pinot/pull/17428#issuecomment-4138739762
Adopted #17660
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org