Backport #25122: [FEA] Replace Ambiguous char-span with `mutable_string_view` #25597
Conflict resolution was required here. The main branch has
template <typename T>
requires(cuda::std::same_as<cuda::std::remove_cv_t<T>, mutable_string_view>)
Conflict resolution was required here. The main branch has
template <cudf::concepts::mutable_string_view T>
<!-- coderabbit-ai-generated:v1 -->
<!-- This is an auto-generated comment: summarize by coderabbit.ai -->
<!-- review_stack_entry_start -->
<a href="https://app.coderabbit.ai/change-stack/NVIDIA/cudf/pull/25597?scope=ghh_OusAJGA4HG8ljoOV0wJvVx8NmnZIjc2DdjmxOu0xZWA&cs_source=review_comment"><picture><source media="(prefers-color-scheme: dark)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg"><img src="https://storage.googleapis.com/coderabbit_public_assets/review-stack-buttons-v1/explain-change.svg" alt="Explain Change →" height="32"></picture></a>
<!-- review_stack_entry_end -->
<!-- walkthrough_start -->
<details>
<summary><strong>Summary</strong></summary>
<dl>
<dd>
<br>
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
Added a mutable string view for working with existing device-backed string data, with access to its character buffer and byte length.
String transforms can now write into preallocated output buffers using the mutable view, including URL component outputs.
Added support for copying strings into preallocated output buffers, with coverage for empty and multibyte strings.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
The PR adds cudf::mutable_string_view and replaces cuda::std::span<char> in mutable string output paths. It updates device access, JIT reflection, URL transform examples, and transform tests. It also adds a copy fragment and an LTO test for preallocated string offsets.
Changes: Mutable String Output
|Layer / File(s)|Summary|
|:---|:---|
|Mutable string view contract <br> cpp/include/cudf/strings/mutable_string_view.hpp, cpp/include/cudf/types.hpp, cpp/include/cudf/utilities/concepts.hpp, cpp/include/cudf/strings/string_view.hpp, cpp/src/strings/strings_column_view.cpp|Adds the non-owning mutable_string_view type, its concept, and its forward declaration. Makes UNKNOWN_STRING_LENGTH public and checks that the mutable and immutable view types have equal size.|
|Device and JIT output handling <br> cpp/include/cudf/column/column_device_view_base.cuh, cpp/src/jit/column_accessor.cuh, cpp/src/jit/reflect.cpp, cpp/CMakeLists.txt, cpp/include/cudf/transform.hpp|Device access and JIT reflection use mutable_string_view for mutable string outputs. Fragment precompilation and transform documentation use the same type.|
|URL transform example <br> cpp/examples/string_transforms/url_logs/fragments.cu, cpp/examples/string_transforms/url_logs/transforms.cpp|URL component-writing functions accept mutable_string_view output buffers. Parsing and component-copy behavior remain unchanged.|
|Transform integration and LTO validation <br> cpp/tests/CMakeLists.txt, cpp/tests/transform/fragments/copy_string.cu, cpp/tests/transform/integration/unary_transform_test.cpp, cpp/tests/transform/transform_lto_test.cpp|Adds a string-copy fragment and an LTO test with preallocated offsets. Existing transform UDF output parameters change to mutable_string_view.|
<!-- change_assessment_start -->
Estimated code review effort: 3 (Moderate) | ~20 minutes
<!-- change_assessment_commit:"05ec027b0a19b0d3c7cde67741c6fcc35e628f99" -->
<!-- change_assessment_priority:{"version":1,"urgency":"p2","manual":false} -->
Change: Refactor
<!-- change_assessment_end -->
Suggested reviewers: lamarrr
</dd>
</dl>
</details>
<!-- walkthrough_end -->
<details>
<summary><strong>Merge Risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-unassessed-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Minimal</strong> · up to <code>05ec0</code></summary>
<dl>
<dd>
<br>
<!-- final_review_risk_start -->
<!-- final_review_risk_label
Merge Risk: ⚪ Minimal · up to 05ec0
-->
<!-- final_review_risk_coverage:{"sourceCommitId":"05ec027b0a19b0d3c7cde67741c6fcc35e628f99","coveredCommitId":"05ec027b0a19b0d3c7cde67741c6fcc35e628f99","kind":"reviewed"} -->
This change swaps the ambiguous character-span type for a clearer mutable string view in preallocated string outputs for transforms. The removed span type was only present in unreleased development code, so no released user code is affected. No concrete defect remains. Apply the category and breaking labels the label check asks for before merging.
<!-- final_review_risk_end -->
</dd>
</dl>
</details>
<details>
<summary><strong>Security architecture risk:</strong> <strong><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/review-comment-icons-v1/risk-low-16.svg" width="16" height="16" align="absmiddle" alt=""></picture> Low</strong> · up to <code>05ec0</code></summary>
<dl>
<dd>
<br>
<!-- architecture_review_start -->
<!-- architecture_review_label
Security Architecture Review
Security architecture risk: 🔵 Low · up to 05ec0
-->
Applications that use preallocated string outputs need to update their transform functions and rebuild compiled fragments for this release. The change keeps writes in the existing output storage, but it also changes how the byte count is represented for very large individual outputs.
Retained concerns
View findings in the submitted review
<details>
<summary><strong>Security review details</strong></summary>
<dl>
<dd>
<br>
Security Blast Radius
Trust Boundaries and Controls
Hardening Proposals
</dd>
</dl>
</details>
<!-- architecture_review_end -->
</dd>
</dl>
</details>
<!-- pre_merge_checks_walkthrough_start -->
<details>
<summary><strong>Pre-merge checks: <sup><picture><img src="https://storage.googleapis.com/coderabbit_public_assets/pre-merge-checks-counter-passed-14-v2.svg" width="14" height="14" align="middle" alt="Passed" title="Passed"></picture></sup> 4</strong></summary>
<dl>
<dd>
<br>
| Check name | Status | Explanation |
| :------------------------ | :--------------------------------------------------------------------------------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Title check | !Passed | The title names the main change: the backport of #25122, which replaces ambiguous cuda::std::span<char> uses with cudf::mutable_string_view. The changeset adds mutable_string_view.hpp, updates column_… |
| Description check | !Passed | The description states that the PR backports upstream #25122, and it names the dependent PRs #25421 and #25384. This relates to the changeset, which replaces span<char> with mutable_string_view across… |
| Linked Issues check | !Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | !Passed | Check skipped because no linked issues were found for this pull request. |
<details>
<summary><strong>Full details: Title check</strong></summary>
<dl>
<dd>
<br>
Explanation
The title names the main change: the backport of #25122, which replaces ambiguous cuda::std::span<char> uses with cudf::mutable_string_view. The changeset adds mutable_string_view.hpp, updates column_device_view_base.cuh, the JIT reflection, the transform fragments, and the examples to use it. The title is specific and accurate, and it identifies the upstream PR.
</dd>
</dl>
</details>
<details>
<summary><strong>Full details: Description check</strong></summary>
<dl>
<dd>
<br>
Explanation
The description states that the PR backports upstream #25122, and it names the dependent PRs #25421 and #25384. This relates to the changeset, which replaces span<char> with mutable_string_view across the codebase. The description is brief but relevant.
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<!-- pre_merge_checks_walkthrough_end -->
<!-- finishing_touch_checkbox_start -->
<details>
<summary><strong>Finishing Touches</strong></summary>
<dl>
<dd>
<br>
<details open>
<summary><strong>Generate unit tests (beta)</strong></summary>
<dl>
<dd>
<br>
</dd>
</dl>
</details>
<!-- finishing_touch_suggestion:fix_ci -->
<details open>
<summary><strong>Fix failing CI checks</strong></summary>
<dl>
<dd>
<br>
</dd>
</dl>
</details>
</dd>
</dl>
</details>
<!-- finishing_touch_checkbox_end -->
<!-- autopilot:start -->
<!-- autopilot:end -->
pre-commit.ci run
vyasr
paul-aiyedun
Description
Backport of https://github.com/NVIDIA/cudf/pull/25122. Required for backporting https://github.com/NVIDIA/cudf/pull/25421 and https://github.com/NVIDIA/cudf/pull/25384.
Checklist