byte_range_info.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022-2024, 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 
17 #pragma once
18 
19 #include <cudf/utilities/error.hpp>
20 #include <cudf/utilities/export.hpp>
21 
22 #include <cstdint>
23 #include <vector>
24 
25 namespace CUDF_EXPORT cudf {
26 namespace io {
27 namespace text {
38  private:
39  int64_t _offset{};
40  int64_t _size{};
41 
42  public:
43  constexpr byte_range_info() = default;
50  constexpr byte_range_info(int64_t offset, int64_t size) : _offset(offset), _size(size)
51  {
52  CUDF_EXPECTS(offset >= 0, "offset must be non-negative");
53  CUDF_EXPECTS(size >= 0, "size must be non-negative");
54  }
55 
61  constexpr byte_range_info(byte_range_info const& other) noexcept = default;
68  constexpr byte_range_info& operator=(byte_range_info const& other) noexcept = default;
69 
75  [[nodiscard]] constexpr int64_t offset() { return _offset; }
76 
82  [[nodiscard]] constexpr int64_t size() { return _size; }
83 
89  [[nodiscard]] constexpr bool empty() { return size() == 0; }
90 };
91 
102 std::vector<byte_range_info> create_byte_range_infos_consecutive(int64_t total_bytes,
103  int64_t range_count);
104 
112  // end of group
114 
115 } // namespace text
116 } // namespace io
117 } // namespace CUDF_EXPORT cudf
stores offset and size used to indicate a byte range
constexpr byte_range_info(byte_range_info const &other) noexcept=default
Copy constructor.
constexpr int64_t size()
Get the size in bytes.
constexpr byte_range_info & operator=(byte_range_info const &other) noexcept=default
Copy assignment operator.
constexpr byte_range_info(int64_t offset, int64_t size)
Constructs a byte_range_info object.
constexpr int64_t offset()
Get the offset in bytes.
constexpr bool empty()
Returns whether the span is empty.
byte_range_info create_byte_range_info_max()
Create a byte_range_info which represents as much of a file as possible. Specifically,...
std::vector< byte_range_info > create_byte_range_infos_consecutive(int64_t total_bytes, int64_t range_count)
Create a collection of consecutive ranges between [0, total_bytes).
#define CUDF_EXPECTS(...)
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
Definition: error.hpp:178
cuDF interfaces
Definition: aggregation.hpp:35