hybrid_scan.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2025, NVIDIA CORPORATION.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #pragma once
7 
8 #include <cudf/io/parquet.hpp>
11 #include <cudf/io/types.hpp>
12 #include <cudf/types.hpp>
13 #include <cudf/utilities/export.hpp>
14 
15 #include <thrust/host_vector.h>
16 
17 #include <memory>
18 #include <utility>
19 #include <vector>
20 
21 namespace CUDF_EXPORT cudf {
22 namespace io::parquet::experimental::detail {
27 class hybrid_scan_reader_impl;
28 } // namespace io::parquet::experimental::detail
29 } // namespace CUDF_EXPORT cudf
30 
33 
34 namespace CUDF_EXPORT cudf {
35 namespace io::parquet::experimental {
46 enum class use_data_page_mask : bool {
47  YES = true,
48  NO = false
49 };
50 
274  public:
283  parquet_reader_options const& options);
284 
293  parquet_reader_options const& options);
294 
299 
308  [[nodiscard]] FileMetaData parquet_metadata() const;
309 
315  [[nodiscard]] byte_range_info page_index_byte_range() const;
316 
326  void setup_page_index(cudf::host_span<uint8_t const> page_index_bytes) const;
327 
334  [[nodiscard]] std::vector<size_type> all_row_groups(parquet_reader_options const& options) const;
335 
343  cudf::host_span<size_type const> row_group_indices) const;
344 
356  [[nodiscard]] std::vector<size_type> filter_row_groups_with_byte_range(
357  cudf::host_span<size_type const> row_group_indices,
358  parquet_reader_options const& options) const;
359 
368  [[nodiscard]] std::vector<size_type> filter_row_groups_with_stats(
369  cudf::host_span<size_type const> row_group_indices,
370  parquet_reader_options const& options,
371  rmm::cuda_stream_view stream) const;
372 
385  [[nodiscard]] std::pair<std::vector<byte_range_info>, std::vector<byte_range_info>>
387  parquet_reader_options const& options) const;
388 
399  [[nodiscard]] std::vector<size_type> filter_row_groups_with_dictionary_pages(
400  cudf::host_span<rmm::device_buffer> dictionary_page_data,
401  cudf::host_span<size_type const> row_group_indices,
402  parquet_reader_options const& options,
403  rmm::cuda_stream_view stream) const;
404 
418  [[nodiscard]] std::vector<size_type> filter_row_groups_with_bloom_filters(
419  cudf::host_span<rmm::device_buffer> bloom_filter_data,
420  cudf::host_span<size_type const> row_group_indices,
421  parquet_reader_options const& options,
422  rmm::cuda_stream_view stream) const;
423 
435  [[nodiscard]] std::unique_ptr<cudf::column> build_row_mask_with_page_index_stats(
436  cudf::host_span<size_type const> row_group_indices,
437  parquet_reader_options const& options,
438  rmm::cuda_stream_view stream,
440 
448  [[nodiscard]] std::vector<byte_range_info> filter_column_chunks_byte_ranges(
449  cudf::host_span<size_type const> row_group_indices,
450  parquet_reader_options const& options) const;
451 
465  cudf::host_span<size_type const> row_group_indices,
466  std::vector<rmm::device_buffer>&& column_chunk_buffers,
467  cudf::mutable_column_view& row_mask,
468  use_data_page_mask mask_data_pages,
469  parquet_reader_options const& options,
470  rmm::cuda_stream_view stream) const;
471 
479  [[nodiscard]] std::vector<byte_range_info> payload_column_chunks_byte_ranges(
480  cudf::host_span<size_type const> row_group_indices,
481  parquet_reader_options const& options) const;
482 
495  cudf::host_span<size_type const> row_group_indices,
496  std::vector<rmm::device_buffer>&& column_chunk_buffers,
497  cudf::column_view const& row_mask,
498  use_data_page_mask mask_data_pages,
499  parquet_reader_options const& options,
500  rmm::cuda_stream_view stream) const;
501 
516  void setup_chunking_for_filter_columns(std::size_t chunk_read_limit,
517  std::size_t pass_read_limit,
518  cudf::host_span<size_type const> row_group_indices,
519  cudf::column_view const& row_mask,
520  use_data_page_mask mask_data_pages,
521  std::vector<rmm::device_buffer>&& column_chunk_buffers,
522  parquet_reader_options const& options,
523  rmm::cuda_stream_view stream) const;
524 
535  cudf::mutable_column_view& row_mask, rmm::cuda_stream_view stream) const;
536 
551  void setup_chunking_for_payload_columns(std::size_t chunk_read_limit,
552  std::size_t pass_read_limit,
553  cudf::host_span<size_type const> row_group_indices,
554  cudf::column_view const& row_mask,
555  use_data_page_mask mask_data_pages,
556  std::vector<rmm::device_buffer>&& column_chunk_buffers,
557  parquet_reader_options const& options,
558  rmm::cuda_stream_view stream) const;
559 
570  cudf::column_view const& row_mask, rmm::cuda_stream_view stream) const;
571 
577  [[nodiscard]] bool has_next_table_chunk() const;
578 
579  private:
580  std::unique_ptr<detail::hybrid_scan_reader_impl> _impl;
581 };
582  // end of group
584 
585 } // namespace io::parquet::experimental
586 } // 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 surviving rows using page-level 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.
std::vector< size_type > filter_row_groups_with_byte_range(cudf::host_span< size_type const > row_group_indices, parquet_reader_options const &options) const
Filter the row groups using the specified byte range specified by [bytes_to_skip, bytes_to_skip + byt...
hybrid_scan_reader(FileMetaData const &parquet_metadata, parquet_reader_options const &options)
Constructor for the experimental parquet reader class to optimally read Parquet files subject to high...
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.
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 const &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.
table_with_metadata materialize_filter_columns_chunk(cudf::mutable_column_view &row_mask, rmm::cuda_stream_view stream) const
Materializes a chunk of filter columns and updates the corresponding range of input row mask to only ...
void setup_chunking_for_payload_columns(std::size_t chunk_read_limit, std::size_t pass_read_limit, cudf::host_span< size_type const > row_group_indices, cudf::column_view const &row_mask, use_data_page_mask mask_data_pages, std::vector< rmm::device_buffer > &&column_chunk_buffers, parquet_reader_options const &options, rmm::cuda_stream_view stream) const
Setup chunking information for payload columns and preprocess the input data pages.
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.
table_with_metadata materialize_payload_columns_chunk(cudf::column_view const &row_mask, rmm::cuda_stream_view stream) const
Materializes a chunk of payload columns and applies the corresponding range of input row mask to the ...
std::vector< size_type > all_row_groups(parquet_reader_options const &options) const
Get all available row groups from the parquet file.
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.
bool has_next_table_chunk() const
Check if there is any parquet data left to read for the current setup.
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.
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 ...
void setup_chunking_for_filter_columns(std::size_t chunk_read_limit, std::size_t pass_read_limit, cudf::host_span< size_type const > row_group_indices, cudf::column_view const &row_mask, use_data_page_mask mask_data_pages, std::vector< rmm::device_buffer > &&column_chunk_buffers, parquet_reader_options const &options, rmm::cuda_stream_view stream) const
Setup chunking information for filter columns and preprocess the input data pages.
~hybrid_scan_reader()
Destructor for the experimental parquet reader class.
Information about content of a parquet file.
Settings for read_parquet().
Definition: parquet.hpp:66
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:46
@ YES
Compute and use a data page mask.
@ NO
Do not compute or use a data page mask.
detail::cccl_async_resource_ref< cuda::mr::resource_ref< cuda::mr::device_accessible > > device_async_resource_ref
int32_t size_type
Row index type for columns and tables.
Definition: types.hpp:84
cuDF-IO API type definitions
cuDF interfaces
Definition: host_udf.hpp:26
Parquet footer schema structs.
C++20 std::span with reduced feature set.
Definition: span.hpp:182
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:292
Type declarations for libcudf.