hdfs.hpp
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 #pragma once
6 
7 #include <optional>
8 
9 #include <kvikio/remote_handle.hpp>
10 
11 namespace kvikio {
12 
21  private:
22  std::string _url;
23  std::optional<std::string> _username;
24 
25  public:
38  explicit WebHdfsEndpoint(std::string url, std::optional<std::string> username = std::nullopt);
39 
53  explicit WebHdfsEndpoint(std::string host,
54  std::string port,
55  std::string remote_file_path,
56  std::optional<std::string> username = std::nullopt);
57 
58  ~WebHdfsEndpoint() override = default;
59  void setopt(CurlHandle& curl) override;
60  std::string str() const override;
61  std::size_t get_file_size() override;
62  void setup_range_request(CurlHandle& curl, std::size_t file_offset, std::size_t size) override;
63 
70  static bool is_url_valid(std::string const& url) noexcept;
71 };
72 } // namespace kvikio
Representation of a curl easy handle pointer and its operations.
Definition: libcurl.hpp:80
Abstract base class for remote endpoints.
A remote endpoint for Apache Hadoop WebHDFS.
Definition: hdfs.hpp:20
static bool is_url_valid(std::string const &url) noexcept
Whether the given URL is valid for the WebHDFS endpoints.
WebHdfsEndpoint(std::string host, std::string port, std::string remote_file_path, std::optional< std::string > username=std::nullopt)
Create an WebHDFS endpoint from the host, port, file path and optionally username.
std::string str() const override
Get a description of this remote point instance.
std::size_t get_file_size() override
Get the size of the remote file.
void setup_range_request(CurlHandle &curl, std::size_t file_offset, std::size_t size) override
Set up the range request in order to read part of a file given the file offset and read size.
WebHdfsEndpoint(std::string url, std::optional< std::string > username=std::nullopt)
Create an WebHDFS endpoint from a url.
void setopt(CurlHandle &curl) override
Set needed connection options on a curl handle.
KvikIO namespace.
Definition: batch.hpp:16