Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding strrpos Presto function #2903

Closed
wants to merge 1 commit into from

Conversation

gosharz
Copy link
Contributor

@gosharz gosharz commented Oct 20, 2022

Summary: Adding strrpos Presto function

Differential Revision: D40527007

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 20, 2022
@netlify
Copy link

netlify bot commented Oct 20, 2022

Deploy Preview for meta-velox canceled.

Name Link
🔨 Latest commit e624204
🔍 Latest deploy log https://app.netlify.com/sites/meta-velox/deploys/636035ff5703a7000b7822bb

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D40527007

@gosharz gosharz mentioned this pull request Oct 20, 2022
Copy link
Contributor

@pedroerp pedroerp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, looks promising! I have an overall question on the vector/simple API, then I'll look more closely.

const std::string_view string,
const std::string_view subString,
const size_t instance = 1) {
assert(instance > 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use VELOX_CHECK_GT() instead of assert

* must be a positive number. Positions start with 1. If not found, 0 is
* returned.
**/
class StringPositionFromEnd : public exec::VectorFunction {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need a vector function? This can likely be written using the simple function API with the same level of performance.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pedroerp , this is a good question. Actually initially I implemented using simple API but then discovered strpos implemented in this way so I decided to mimick the behavior. I think if the agreement is that vector function does provide any added-value we can have a follow-up PR with switching all implementations that rely on it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that the reason is that the strpos function was written before the simple function API was in place. To avoid us from iterating and reviewing the vector code (which is more complicated and might end up not being needed), could we either converge into the simple function version, or write a small micro-benchmark to justify if the vectorized version actually has perf benefits?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we see that the simple function version is just as fast, we could also refactor the strpos function to simplify it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pedroerp It seems like all functions in that file are implemented as VectorFunctions actually(at first glance hard to spot obvious perf gain). I'd prefer adding strrpos following the same pattern to have a consistent file and have a separate activity of assessing/moving all those to simple function API. As far as the review is concerned the actual implementation in StringCore is going to stay the same as well as the the test cases. We'll have to review only declaration part in the follow-up pr which should be pretty straightforward bulk activity.

@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D40527007

gosharz pushed a commit to gosharz/velox that referenced this pull request Oct 31, 2022
…acebookincubator#2903)

Summary:
Pull Request resolved: facebookincubator#2903

Based on the usage and benchmark analysis:
1. Move strpos Presto function implementation to use Simple Function API
2. Add strrpos Presto function based on Simple Function API
3. Add test coverage

Reviewed By: mbasmanova

Differential Revision: D40527007

fbshipit-source-id: f4c897be39f51b951bd32e29e6be34b61f3a088d
…acebookincubator#2903)

Summary:
Pull Request resolved: facebookincubator#2903

Based on the usage and benchmark analysis:
1. Move strpos Presto function implementation to use Simple Function API
2. Add strrpos Presto function based on Simple Function API
3. Add test coverage

Reviewed By: mbasmanova

Differential Revision: D40527007

fbshipit-source-id: 70ad282fa8d18683e1e36db004acf38c1207fee2
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D40527007

marin-ma pushed a commit to marin-ma/velox-oap that referenced this pull request Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants