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

transform-sdk/cpp: add string_view conversion from bytes_view #17249

Merged
merged 2 commits into from
Mar 22, 2024

Conversation

rockwotj
Copy link
Contributor

A small QoL improvement for the C++ SDK.

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v23.3.x
  • v23.2.x

Release Notes

  • none

@rockwotj rockwotj requested a review from oleiman March 21, 2024 21:34
@github-actions github-actions bot added the area/wasm WASM Data Transforms label Mar 21, 2024
This will probably be a common operation, so make it easier for users.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
If you want to abort use the abort function.

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
Copy link
Member

@oleiman oleiman left a comment

Choose a reason for hiding this comment

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

nice

Comment on lines +275 to +277
.transform([](bytes_view buf) {
return std::string_view{buf};
})
Copy link
Member

Choose a reason for hiding this comment

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

don't know how I missed this in the first round of CR but 🔥 🔥 🔥

Copy link
Member

Choose a reason for hiding this comment

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

optional<T>::transform I mean. so good

@@ -424,6 +420,10 @@ bytes::value_type bytes_view::operator[](size_t n) const { return _start[n]; }
bool bytes_view::operator==(const bytes_view& other) const {
return std::ranges::equal(*this, other);
}
bytes_view::operator std::string_view() const {
Copy link
Member

Choose a reason for hiding this comment

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

nit: looks like you're using this explicit...should it be declared so?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No explicit doesn't take place in overlod resolution and it's only allowed at declaration

Copy link
Member

Choose a reason for hiding this comment

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

Oh, it is declared explicit. My mistake. Thought I was looking at the declaration right here 👍

@rockwotj rockwotj merged commit ef2e194 into redpanda-data:dev Mar 22, 2024
18 checks passed
@rockwotj rockwotj deleted the string_view_conversion branch March 22, 2024 00:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/wasm WASM Data Transforms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants