Skip to content

Commit

Permalink
Don't unnecessarily retrieve offsets from strings columns for unslice…
Browse files Browse the repository at this point in the history
…d columns during overflow checking.
  • Loading branch information
nvdbaranec committed Aug 4, 2021
1 parent fa3ae36 commit 25d2d11
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cpp/src/copying/concatenate.cu
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,15 @@ void traverse_children::operator()<cudf::string_view>(host_span<column_view cons
strings_column_view scv(b);
return a + (b.is_empty()
? 0
: cudf::detail::get_value<offset_type>(
scv.offsets(), scv.offset() + b.size(), stream) -
/*
: cudf::detail::get_value<offset_type>(scv.offsets(), scv.offset() + b.size(), stream) -
cudf::detail::get_value<offset_type>(scv.offsets(), scv.offset(), stream));
*/
// if the column is unsliced, skip the offset retrieval.
: scv.offset() > 0 ?
cudf::detail::get_value<offset_type>(scv.offsets(), scv.offset() + b.size(), stream) -
cudf::detail::get_value<offset_type>(scv.offsets(), scv.offset(), stream)
: scv.chars_size());
});
// note: output text must include "exceeds size_type range" for python error handling
CUDF_EXPECTS(total_char_count <= static_cast<size_t>(std::numeric_limits<size_type>::max()),
Expand Down

1 comment on commit 25d2d11

@davidwendt
Copy link

Choose a reason for hiding this comment

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

A sliced column could be sliced by size only which would mean the offset would be 0.
You may want to check scv.size()==scv.offsets().size()+1 as well as scv.offset() > 0

Please sign in to comment.