Skip to content

Commit

Permalink
use kvikio::remote_handle.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
madsbk committed Oct 29, 2024
1 parent 007c651 commit a875da8
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions cpp/src/io/utilities/datasource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <cudf/utilities/span.hpp>

#include <kvikio/file_handle.hpp>
#include <kvikio/remote_handle.hpp>

#include <rmm/device_buffer.hpp>

Expand Down Expand Up @@ -395,6 +396,12 @@ class user_datasource_wrapper : public datasource {
*/
class remote_file_source {
public:
static std::unique_ptr<kvikio::S3Endpoint> create_s3_endpoint(std::string const& filepath)
{
auto [bucket_name, bucket_object] = kvikio::S3Endpoint::parse_s3_url(filepath);
return std::make_unique<kvikio::S3Endpoint>(bucket_name, bucket_object);
}

/**
* @brief Is `url` referring to a remote file supported by KvikIO?
*
Expand Down Expand Up @@ -422,14 +429,16 @@ std::unique_ptr<datasource> datasource::create(std::string const& filepath,

CUDF_FAIL("Invalid LIBCUDF_MMAP_ENABLED value: " + policy);
}();
CUDF_EXPECTS(!remote_file_source::is_supported_remote_url(filepath),
"didn't expect a remote URL");
if (use_memory_mapping) {
if (remote_file_source::is_supported_remote_url(filepath)) {
remote_file_source::create_s3_endpoint(filepath);
CUDF_FAIL("is_supported_remote_url(): didn't expect a s3 url!");
} else if (use_memory_mapping) {
return std::make_unique<memory_mapped_source>(filepath.c_str(), offset, max_size_estimate);
} else {
// `file_source` reads the file directly, without memory mapping
return std::make_unique<file_source>(filepath.c_str());
}
return std::make_unique<file_source>(filepath.c_str());
}

std::unique_ptr<datasource> datasource::create(host_buffer const& buffer)
Expand Down

0 comments on commit a875da8

Please sign in to comment.