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

compute: avoid needless allocations of strings in text-to-varchar conversion #27112

Merged
merged 3 commits into from
May 22, 2024

Conversation

mgree
Copy link
Contributor

@mgree mgree commented May 15, 2024

While working with @frankmcsherry, we noticed that text_to_varchar was allocating a fresh string every time, even though VarChar<S> accepts &str.

Motivation

  • This PR fixes a previously unreported bug.

Even when the text fits in the varchar limit, we would allocate a new string. There's no need to do this: just pass a reference.

Checklist

@mgree mgree requested review from a team May 15, 2024 20:57
Copy link
Member

@antiguru antiguru left a comment

Choose a reason for hiding this comment

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

Looks good +/- suggested changes.

src/expr/src/scalar/func/impls/string.rs Outdated Show resolved Hide resolved
src/expr/src/scalar/func/impls/string.rs Outdated Show resolved Hide resolved
@mgree
Copy link
Contributor Author

mgree commented May 22, 2024

Huh... I could have sworn I compiled it on my machine first. 😅

Main's CI seems to be broken, will rebase once a fix lands.

mgree and others added 3 commits May 22, 2024 10:50
Co-authored-by: Moritz Hoffmann <antiguru@gmail.com>
Co-authored-by: Moritz Hoffmann <antiguru@gmail.com>
@mgree mgree merged commit 192dac2 into MaterializeInc:main May 22, 2024
73 checks passed
@mgree mgree deleted the text_to_varchar_byref branch May 22, 2024 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants