hdfs.hpp
1 /*
2  * Copyright (c) 2025, NVIDIA CORPORATION.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 #pragma once
17 
18 #include <optional>
19 
20 #include <kvikio/remote_handle.hpp>
21 
22 namespace kvikio {
23 
31  private:
32  std::string _url;
33  std::optional<std::string> _username;
34 
35  public:
41  explicit WebHdfsEndpoint(std::string url);
42 
51  explicit WebHdfsEndpoint(std::string host,
52  std::string port,
53  std::string remote_file_path,
54  std::optional<std::string> username = std::nullopt);
55 
56  ~WebHdfsEndpoint() override = default;
57  void setopt(CurlHandle& curl) override;
58  std::string str() const override;
59  std::size_t get_file_size() override;
60  void setup_range_request(CurlHandle& curl, std::size_t file_offset, std::size_t size) override;
61 
68  static bool is_url_valid(std::string const& url) noexcept;
69 };
70 } // namespace kvikio
Representation of a curl easy handle pointer and its operations.
Definition: libcurl.hpp:91
Abstract base class for remote endpoints.
A remote endpoint for Apache Hadoop WebHDFS.
Definition: hdfs.hpp:30
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.
WebHdfsEndpoint(std::string url)
Create an WebHDFS endpoint from a url.
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.
void setopt(CurlHandle &curl) override
Set needed connection options on a curl handle.
KvikIO namespace.
Definition: batch.hpp:27