Skip to content

Commit

Permalink
Use get_offset_value utility in strings shift function (#14743)
Browse files Browse the repository at this point in the history
Updates `cudf::strings::detail::shift` to support int32 or int64 offset types by changing calls to `get_value` to `get_offset_value`.

Authors:
  - David Wendt (https://github.com/davidwendt)

Approvers:
  - Nghia Truong (https://github.com/ttnghia)
  - Yunsong Wang (https://github.com/PointKernel)

URL: #14743
  • Loading branch information
davidwendt authored Jan 23, 2024
1 parent 8167f77 commit bc706af
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cpp/src/strings/copying/shift.cu
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ struct output_sizes_fn {
struct shift_chars_fn {
column_device_view const d_column; // input strings column
string_view const d_filler;
size_type const offset;
int64_t const offset;

__device__ char operator()(size_type idx)
__device__ char operator()(int64_t idx)
{
if (offset < 0) {
auto const last_index = -offset;
Expand Down Expand Up @@ -110,7 +110,7 @@ std::unique_ptr<column> shift(strings_column_view const& input,
// compute the shift-offset for the output characters child column
auto const shift_offset = [&] {
auto const index = (offset < 0) ? input.size() + offset : offset;
return (offset < 0 ? -1 : 1) * cudf::detail::get_value<size_type>(offsets_view, index, stream);
return (offset < 0 ? -1 : 1) * get_offset_value(offsets_view, index, stream);
}();

// create output chars child column
Expand All @@ -119,8 +119,8 @@ std::unique_ptr<column> shift(strings_column_view const& input,

// run kernel to shift all the characters
thrust::transform(rmm::exec_policy(stream),
thrust::counting_iterator<size_type>(0),
thrust::counting_iterator<size_type>(total_bytes),
thrust::counting_iterator<int64_t>(0),
thrust::counting_iterator<int64_t>(total_bytes),
d_chars,
shift_chars_fn{*d_input, d_fill_str, shift_offset});

Expand Down

0 comments on commit bc706af

Please sign in to comment.