hybrid_scan.hpp
Go to the documentation of this file.
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 
17 #pragma once
18 
19 #include <cudf/io/parquet.hpp>
22 #include <cudf/io/types.hpp>
23 #include <cudf/types.hpp>
24 #include <cudf/utilities/export.hpp>
25 
26 #include <thrust/host_vector.h>
27 
28 #include <memory>
29 #include <utility>
30 #include <vector>
31 
32 namespace CUDF_EXPORT cudf {
33 namespace io::parquet::experimental::detail {
38 class hybrid_scan_reader_impl;
39 } // namespace io::parquet::experimental::detail
40 } // namespace CUDF_EXPORT cudf
41 
44 
45 namespace CUDF_EXPORT cudf {
46 namespace io::parquet::experimental {
57 enum class use_data_page_mask : bool {
58  YES = true,
59  NO = false
60 };
61 
278  public:
287  parquet_reader_options const& options);
288 
293 
302  [[nodiscard]] FileMetaData parquet_metadata() const;
303 
309  [[nodiscard]] byte_range_info page_index_byte_range() const;
310 
320  void setup_page_index(cudf::host_span<uint8_t const> page_index_bytes) const;
321 
328  [[nodiscard]] std::vector<size_type> all_row_groups(parquet_reader_options const& options) const;
329 
337  cudf::host_span<size_type const> row_group_indices) const;
338 
347  [[nodiscard]] std::vector<size_type> filter_row_groups_with_stats(
348  cudf::host_span<size_type const> row_group_indices,
349  parquet_reader_options const& options,
350  rmm::cuda_stream_view stream) const;
351 
364  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<byte_range_info>>
366  parquet_reader_options const& options) const;
367 
378  [[nodiscard]] std::vector<size_type> filter_row_groups_with_dictionary_pages(
379  cudf::host_span<rmm::device_buffer> dictionary_page_data,
380  cudf::host_span<size_type const> row_group_indices,
381  parquet_reader_options const& options,
382  rmm::cuda_stream_view stream) const;
383 
397  [[nodiscard]] std::vector<size_type> filter_row_groups_with_bloom_filters(
398  cudf::host_span<rmm::device_buffer> bloom_filter_data,
399  cudf::host_span<size_type const> row_group_indices,
400  parquet_reader_options const& options,
401  rmm::cuda_stream_view stream) const;
402 
414  [[nodiscard]] std::unique_ptr<cudf::column> build_row_mask_with_page_index_stats(
415  cudf::host_span<size_type const> row_group_indices,
416  parquet_reader_options const& options,
417  rmm::cuda_stream_view stream,
419 
427  [[nodiscard]] std::vector<byte_range_info> filter_column_chunks_byte_ranges(
428  cudf::host_span<size_type const> row_group_indices,
429  parquet_reader_options const& options) const;
430 
444  cudf::host_span<size_type const> row_group_indices,
445  std::vector<rmm::device_buffer> column_chunk_buffers,
446  cudf::mutable_column_view row_mask,
447  use_data_page_mask mask_data_pages,
448  parquet_reader_options const& options,
449  rmm::cuda_stream_view stream) const;
450 
458  [[nodiscard]] std::vector<byte_range_info> payload_column_chunks_byte_ranges(
459  cudf::host_span<size_type const> row_group_indices,
460  parquet_reader_options const& options) const;
461 
474  cudf::host_span<size_type const> row_group_indices,
475  std::vector<rmm::device_buffer> column_chunk_buffers,
476  cudf::column_view row_mask,
477  use_data_page_mask mask_data_pages,
478  parquet_reader_options const& options,
479  rmm::cuda_stream_view stream) const;
480 
481  private:
482  std::unique_ptr<detail::hybrid_scan_reader_impl> _impl;
483 };
484  // end of group
486 
487 } // namespace io::parquet::experimental
488 } // namespace CUDF_EXPORT cudf
A non-owning, immutable view of device data as a column of elements, some of which may be null as ind...
The experimental parquet reader class to optimally read parquet files subject to highly selective fil...
std::unique_ptr< cudf::column > build_row_mask_with_page_index_stats(cudf::host_span< size_type const > row_group_indices, parquet_reader_options const &options, rmm::cuda_stream_view stream, rmm::device_async_resource_ref mr) const
Builds a boolean column indicating which rows survive the page statistics in the page index.
std::vector< size_type > filter_row_groups_with_dictionary_pages(cudf::host_span< rmm::device_buffer > dictionary_page_data, cudf::host_span< size_type const > row_group_indices, parquet_reader_options const &options, rmm::cuda_stream_view stream) const
Filter the row groups using column chunk dictionary pages.
void setup_page_index(cudf::host_span< uint8_t const > page_index_bytes) const
Setup the page index within the Parquet file metadata (FileMetaData)
std::vector< byte_range_info > payload_column_chunks_byte_ranges(cudf::host_span< size_type const > row_group_indices, parquet_reader_options const &options) const
Get byte ranges of column chunks of payload columns.
byte_range_info page_index_byte_range() const
Get the byte range of the page index in the Parquet file.
hybrid_scan_reader(cudf::host_span< uint8_t const > footer_bytes, parquet_reader_options const &options)
Constructor for the experimental parquet reader class to optimally read Parquet files subject to high...
std::pair< std::vector< byte_range_info >, std::vector< byte_range_info > > secondary_filters_byte_ranges(cudf::host_span< size_type const > row_group_indices, parquet_reader_options const &options) const
Get byte ranges of bloom filters and dictionary pages (secondary filters) for row group pruning.
table_with_metadata materialize_payload_columns(cudf::host_span< size_type const > row_group_indices, std::vector< rmm::device_buffer > column_chunk_buffers, cudf::column_view row_mask, use_data_page_mask mask_data_pages, parquet_reader_options const &options, rmm::cuda_stream_view stream) const
Materialize payload columns and applies the row mask to the output table.
FileMetaData parquet_metadata() const
Get the Parquet file footer metadata.
std::vector< size_type > filter_row_groups_with_bloom_filters(cudf::host_span< rmm::device_buffer > bloom_filter_data, cudf::host_span< size_type const > row_group_indices, parquet_reader_options const &options, rmm::cuda_stream_view stream) const
Filter the row groups using column chunk bloom filters.
std::vector< size_type > filter_row_groups_with_stats(cudf::host_span< size_type const > row_group_indices, parquet_reader_options const &options, rmm::cuda_stream_view stream) const
Filter the input row groups using column chunk statistics.
std::vector< size_type > all_row_groups(parquet_reader_options const &options) const
Get all available row groups from the parquet file.
table_with_metadata materialize_filter_columns(cudf::host_span< size_type const > row_group_indices, std::vector< rmm::device_buffer > column_chunk_buffers, cudf::mutable_column_view row_mask, use_data_page_mask mask_data_pages, parquet_reader_options const &options, rmm::cuda_stream_view stream) const
Materializes filter columns and updates the input row mask to only the rows that exist in the output ...
size_type total_rows_in_row_groups(cudf::host_span< size_type const > row_group_indices) const
Get the total number of top-level rows in the row groups.
std::vector< byte_range_info > filter_column_chunks_byte_ranges(cudf::host_span< size_type const > row_group_indices, parquet_reader_options const &options) const
Get byte ranges of column chunks of filter columns.
~hybrid_scan_reader()
Destructor for the experimental parquet reader class.
Settings for read_parquet().
Definition: parquet.hpp:78
stores offset and size used to indicate a byte range
A non-owning, mutable view of device data as a column of elements, some of which may be null as indic...
use_data_page_mask
Whether to compute and use a page mask using the row mask to skip decompression and decoding of the m...
Definition: hybrid_scan.hpp:57
@ YES
Compute and use a data page mask.
@ NO
Do not compute or use a data page mask.
cuda::mr::async_resource_ref< cuda::mr::device_accessible > device_async_resource_ref
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:95
cuDF-IO API type definitions
cuDF interfaces
Definition: host_udf.hpp:37
Parquet footer schema structs.
C++20 std::span with reduced feature set.
Definition: span.hpp:194
Thrift-derived struct describing file-level metadata.
Table with table metadata used by io readers to return the metadata by value.
Definition: io/types.hpp:303
Type declarations for libcudf.