libcudf  24.02.00
data_chunk_source.hpp
1 /*
2  * Copyright (c) 2021-2022, 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/span.hpp>
20 
21 #include <rmm/cuda_stream_pool.hpp>
22 #include <rmm/device_buffer.hpp>
23 
24 namespace cudf {
25 namespace io {
26 namespace text {
27 
38  public:
39  virtual ~device_data_chunk() = default;
45  [[nodiscard]] virtual char const* data() const = 0;
51  [[nodiscard]] virtual std::size_t size() const = 0;
57  virtual operator device_span<char const>() const = 0;
58 };
59 
70  public:
71  virtual ~data_chunk_reader() = default;
77  virtual void skip_bytes(std::size_t size) = 0;
78 
93  virtual std::unique_ptr<device_data_chunk> get_next_chunk(std::size_t size,
94  rmm::cuda_stream_view stream) = 0;
95 };
96 
102  public:
103  virtual ~data_chunk_source() = default;
104 
110  [[nodiscard]] virtual std::unique_ptr<data_chunk_reader> create_reader() const = 0;
111 };
112 
113 } // namespace text
114 } // namespace io
115 } // namespace cudf
a reader capable of producing views over device memory.
virtual std::unique_ptr< device_data_chunk > get_next_chunk(std::size_t size, rmm::cuda_stream_view stream)=0
Get the next chunk of bytes from the data source.
virtual void skip_bytes(std::size_t size)=0
Skips the specified number of bytes in the data source.
a data source capable of creating a reader which can produce views of the data source in device memor...
virtual std::unique_ptr< data_chunk_reader > create_reader() const =0
Get a reader for the data source.
A contract guaranteeing stream-ordered memory access to the underlying device data.
virtual char const * data() const =0
Returns a pointer to the underlying device data.
virtual std::size_t size() const =0
Returns the size of the underlying device data.
cuDF interfaces
Definition: aggregation.hpp:34
APIs for spans.
Device version of C++20 std::span with reduced feature set.
Definition: span.hpp:291