diff --git a/cpp/src/copying/concatenate.cu b/cpp/src/copying/concatenate.cu index f5f3937089f..f4b6a8bf5fd 100644 --- a/cpp/src/copying/concatenate.cu +++ b/cpp/src/copying/concatenate.cu @@ -374,11 +374,18 @@ void traverse_children::operator()(host_span size_t { strings_column_view scv(b); - return a + (b.is_empty() - ? 0 - : cudf::detail::get_value( - scv.offsets(), scv.offset() + b.size(), stream) - - cudf::detail::get_value(scv.offsets(), scv.offset(), stream)); + return a + (scv.is_empty() ? 0 + // if the column is unsliced, skip the offset retrieval. + : scv.offset() > 0 + ? cudf::detail::get_value( + scv.offsets(), scv.offset() + scv.size(), stream) - + cudf::detail::get_value(scv.offsets(), scv.offset(), stream) + // if the offset() is 0, it can still be sliced to a shorter length. in this case + // we only need to read a single offset. otherwise just return the full length + // (chars_size()) + : scv.size() + 1 == scv.offsets().size() + ? scv.chars_size() + : cudf::detail::get_value(scv.offsets(), scv.size(), stream)); }); // note: output text must include "exceeds size_type range" for python error handling CUDF_EXPECTS(total_char_count <= static_cast(std::numeric_limits::max()),