libcudf  24.04.00
byte_range_info.hpp
1 /*
2  * Copyright (c) 2022-2023, 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 
21 #include <cstdint>
22 #include <vector>
23 
24 namespace cudf {
25 namespace io {
26 namespace text {
27 
32  private:
33  int64_t _offset;
34  int64_t _size;
35 
36  public:
37  constexpr byte_range_info() noexcept : _offset(0), _size(0) {}
44  constexpr byte_range_info(int64_t offset, int64_t size) : _offset(offset), _size(size)
45  {
46  CUDF_EXPECTS(offset >= 0, "offset must be non-negative");
47  CUDF_EXPECTS(size >= 0, "size must be non-negative");
48  }
49 
55  constexpr byte_range_info(byte_range_info const& other) noexcept = default;
62  constexpr byte_range_info& operator=(byte_range_info const& other) noexcept = default;
63 
69  [[nodiscard]] constexpr int64_t offset() { return _offset; }
70 
76  [[nodiscard]] constexpr int64_t size() { return _size; }
77 
83  [[nodiscard]] constexpr bool empty() { return size() == 0; }
84 };
85 
96 std::vector<byte_range_info> create_byte_range_infos_consecutive(int64_t total_bytes,
97  int64_t range_count);
98 
105 byte_range_info create_byte_range_info_max();
106 
107 } // namespace text
108 } // namespace io
109 } // namespace 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.
#define CUDF_EXPECTS(...)
Macro for checking (pre-)conditions that throws an exception when a condition is violated.
Definition: error.hpp:177
cuDF interfaces
Definition: aggregation.hpp:34