Repository navigation
feat(read): prune Parquet row groups for multi-file data evolution #607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ | |
| #include "paimon/format/reader_builder.h" | ||
| #include "paimon/fs/file_system.h" | ||
| #include "paimon/memory/memory_pool.h" | ||
| #include "paimon/reader/file_batch_reader.h" | ||
|
|
||
| namespace arrow { | ||
| class Schema; | ||
|
|
@@ -961,6 +962,40 @@ std::shared_ptr<Metrics> PrefetchFileBatchReaderImpl::GetReaderMetrics() const { | |
| result->Merge(readers_[0]->GetReaderMetrics()); | ||
| } | ||
|
|
||
| CollectPrefetchMetrics(result); | ||
| return result; | ||
| } | ||
|
|
||
| std::shared_ptr<Metrics> PrefetchFileBatchReaderImpl::GetSkippedReaderMetrics( | ||
| bool count_row_groups, std::optional<uint64_t> storage_read_bytes) const { | ||
| const auto* first_filter = dynamic_cast<const RowGroupFilter*>(GetFirstReader()); | ||
| if (first_filter == nullptr) { | ||
| return GetReaderMetrics(); | ||
| } | ||
|
|
||
| auto result = std::make_shared<MetricsImpl>(); | ||
| CollectPrefetchMetrics(result); | ||
| if (!storage_read_bytes && cache_) { | ||
| // Only footer reads have run. The cache counters separate storage fetches from | ||
| // requests served by the cache and from misses that fell back to a direct read. | ||
| storage_read_bytes = result->GetCounter(ReadAheadCacheMetrics::IO_BYTES).value() + | ||
| result->GetCounter(ReadAheadCacheMetrics::READ_MISS_BYTES).value(); | ||
| } | ||
| if (storage_read_bytes) { | ||
| result->Merge(first_filter->GetSkippedReaderMetrics(count_row_groups, storage_read_bytes)); | ||
| } else { | ||
| result->Merge(first_filter->GetSkippedReaderMetrics(count_row_groups)); | ||
| for (size_t i = 1; i < readers_.size(); ++i) { | ||
| if (const auto* filter = dynamic_cast<const RowGroupFilter*>(readers_[i].get())) { | ||
| result->Merge(filter->GetSkippedReaderMetrics(/*count_row_groups=*/false)); | ||
| } | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
|
|
||
| void PrefetchFileBatchReaderImpl::CollectPrefetchMetrics( | ||
| const std::shared_ptr<Metrics>& result) const { | ||
| auto set_prefetch_counter = [&result](const char* name, const std::atomic<uint64_t>& value) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since |
||
| result->SetCounter(name, value.load(kMetricsMemoryOrder)); | ||
| }; | ||
|
|
@@ -996,7 +1031,7 @@ std::shared_ptr<Metrics> PrefetchFileBatchReaderImpl::GetReaderMetrics() const { | |
| } | ||
|
|
||
| if (!io_metrics_) { | ||
| return result; | ||
| return; | ||
| } | ||
| auto set_io_counter = [&result](const char* name, const std::atomic<uint64_t>& value) { | ||
| result->SetCounter(name, value.load(kMetricsMemoryOrder)); | ||
|
|
@@ -1016,7 +1051,6 @@ std::shared_ptr<Metrics> PrefetchFileBatchReaderImpl::GetReaderMetrics() const { | |
| set_io_counter(PrefetchIoMetrics::ASYNC_LATENCY_SUM_US, io_metrics_->async_latency_sum_us); | ||
| result->SetGauge(PrefetchIoMetrics::ASYNC_PENDING, | ||
| static_cast<double>(io_metrics_->async_pending.load(kMetricsMemoryOrder))); | ||
| return result; | ||
| } | ||
|
|
||
| Result<std::unique_ptr<::ArrowSchema>> PrefetchFileBatchReaderImpl::GetFileSchema() const { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,6 +128,17 @@ class AbstractSplitRead : public SplitRead { | |
| const std::map<std::string, std::string>& extra_format_options, | ||
| bool attach_blob_context) const; | ||
|
|
||
| Result<std::unique_ptr<FileBatchReader>> OpenDataFileReader( | ||
| const std::shared_ptr<DataFileMeta>& file, | ||
| const DataFilePathFactory& data_file_path_factory) const; | ||
|
|
||
| Result<std::unique_ptr<FileBatchReader>> ConfigureOpenedFileReader( | ||
| const BinaryRow& partition, const std::shared_ptr<DataFileMeta>& file, | ||
| const std::shared_ptr<arrow::Schema>& read_schema, DeletionVector::Factory dv_factory, | ||
| const std::optional<std::vector<Range>>& row_ranges, | ||
| const std::shared_ptr<DataFilePathFactory>& data_file_path_factory, | ||
| std::unique_ptr<FileBatchReader> file_reader) const; | ||
|
|
||
| Result<std::unique_ptr<BatchReader>> ApplyPredicateFilterIfNeeded( | ||
| std::unique_ptr<BatchReader>&& reader, const std::shared_ptr<Predicate>& predicate) const; | ||
|
|
||
|
|
@@ -193,7 +204,8 @@ class AbstractSplitRead : public SplitRead { | |
| const FieldMappingBuilder* field_mapping_builder, DeletionVector::Factory dv_factory, | ||
| const std::optional<std::vector<Range>>& row_ranges, | ||
| const std::shared_ptr<DataFilePathFactory>& data_file_path_factory, | ||
| const RoaringBitmap32* exact_selection) const; | ||
| const RoaringBitmap32* exact_selection, | ||
| std::unique_ptr<FileBatchReader> opened_reader = nullptr) const; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please avoid default parameters, or alternatively add a new overload and remove unrelated parameters like |
||
|
|
||
| /// The returned field ID set contains MAP fields handled by shredding read plans. It tells | ||
| /// FieldMappingReader to skip its generic selected-key filtering because the plans have already | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid using default parameters in production code under
src. If the change is relatively large, consider adding an overloaded constructor instead.