Skip to content

Commit

Permalink
Promote create_string_vector_from_column to public api as needed by p…
Browse files Browse the repository at this point in the history
…ython
  • Loading branch information
robertmaynard committed Jun 24, 2024
1 parent 98e241c commit 3c78154
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
17 changes: 17 additions & 0 deletions cpp/include/cudf/strings/utilities.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,28 @@
*/
#pragma once

#include <cudf/strings/strings_column_view.hpp>
#include <cudf/utilities/export.hpp>

#include <rmm/mr/device/per_device_resource.hpp>
#include <rmm/resource_ref.hpp>

namespace CUDF_EXPORT cudf {
namespace strings {

/**
* @brief Creates a string_view vector from a strings column.
*
* @param strings Strings column instance.
* @param stream CUDA stream used for device memory operations and kernel launches.
* @param mr Device memory resource used to allocate the returned vector's device memory.
* @return Device vector of string_views
*/
rmm::device_uvector<string_view> create_string_vector_from_column(
cudf::strings_column_view const strings,
rmm::cuda_stream_view stream = cudf::get_default_stream(),
rmm::device_async_resource_ref mr = rmm::mr::get_current_device_resource());

/**
* @brief Return the threshold size for a strings column to use int64 offsets
*
Expand Down
9 changes: 9 additions & 0 deletions cpp/src/strings/utilities.cu
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <cudf/column/column_device_view.cuh>
#include <cudf/column/column_factories.hpp>
#include <cudf/detail/get_value.cuh>
#include <cudf/detail/nvtx/ranges.hpp>
#include <cudf/strings/detail/char_tables.hpp>
#include <cudf/strings/detail/utilities.cuh>
#include <cudf/strings/detail/utilities.hpp>
Expand Down Expand Up @@ -161,6 +162,14 @@ int64_t get_offset_value(cudf::column_view const& offsets,

} // namespace detail

rmm::device_uvector<string_view> create_string_vector_from_column(
cudf::strings_column_view const input,
rmm::cuda_stream_view stream,
rmm::device_async_resource_ref mr)
{
CUDF_FUNC_RANGE();
return detail::create_string_vector_from_column(input, stream, mr);
}

int64_t get_offset64_threshold()
{
Expand Down
4 changes: 2 additions & 2 deletions python/cudf/udf_cpp/strings/src/strings/udf/udf_apis.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
*/

#include <cudf/column/column_factories.hpp>
#include <cudf/strings/detail/utilities.hpp>
#include <cudf/strings/string_view.cuh>
#include <cudf/strings/udf/udf_apis.hpp>
#include <cudf/strings/udf/udf_string.cuh>
#include <cudf/strings/utilities.hpp>
#include <cudf/utilities/default_stream.hpp>

#include <rmm/device_uvector.hpp>
Expand Down Expand Up @@ -57,7 +57,7 @@ std::unique_ptr<rmm::device_buffer> to_string_view_array(cudf::column_view const
rmm::cuda_stream_view stream)
{
return std::make_unique<rmm::device_buffer>(
std::move(cudf::strings::detail::create_string_vector_from_column(
std::move(cudf::strings::create_string_vector_from_column(
cudf::strings_column_view(input), stream, rmm::mr::get_current_device_resource())
.release()));
}
Expand Down

0 comments on commit 3c78154

Please sign in to comment.