mapleFU commented on code in PR #36967:
URL: https://github.com/apache/arrow/pull/36967#discussion_r1280105317
##########
cpp/src/arrow/dataset/file_parquet.cc:
##########
@@ -779,6 +787,28 @@ Result<std::vector<int>>
ParquetFileFragment::FilterRowGroups(
return row_groups;
}
+Result<std::vector<int>> ParquetFileFragment::FilterRangeRowGroups(
+ int64_t start_offset, int64_t length) {
+ std::vector<int> row_groups;
+ for (int row_group : *row_groups_) {
+ auto rg_metadata = metadata_->RowGroup(row_group);
Review Comment:
`RowGroupMetadata` has a optional `file_offset()`, when `file_offset() ==
0`, would that be ok?
##########
cpp/src/arrow/dataset/file_parquet.cc:
##########
@@ -779,6 +787,28 @@ Result<std::vector<int>>
ParquetFileFragment::FilterRowGroups(
return row_groups;
}
+Result<std::vector<int>> ParquetFileFragment::FilterRangeRowGroups(
+ int64_t start_offset, int64_t length) {
+ std::vector<int> row_groups;
+ for (int row_group : *row_groups_) {
+ auto rg_metadata = metadata_->RowGroup(row_group);
+ std::shared_ptr<parquet::ColumnChunkMetaData> cc0 =
rg_metadata->ColumnChunk(0);
+ int64_t r_start = cc0->data_page_offset();
+ if (cc0->has_dictionary_page() && r_start > cc0->dictionary_page_offset())
{
+ r_start = cc0->dictionary_page_offset();
+ }
+ int64_t r_bytes = 0L;
+ for (int col_id = 0; col_id < rg_metadata->num_columns(); col_id++) {
+ r_bytes += rg_metadata->ColumnChunk(col_id)->total_compressed_size();
Review Comment:
Could the begining of next rowgroup be used here?
##########
cpp/src/arrow/dataset/file_parquet.cc:
##########
@@ -523,6 +523,10 @@ Result<RecordBatchGenerator>
ParquetFileFormat::ScanBatchesAsync(
ARROW_ASSIGN_OR_RAISE(row_groups,
parquet_fragment->FilterRowGroups(options->filter));
pre_filtered = true;
if (row_groups.empty()) return
MakeEmptyGenerator<std::shared_ptr<RecordBatch>>();
+ if (options->start_offset != kDefaultStartOffset) {
+ ARROW_ASSIGN_OR_RAISE(row_groups,
Review Comment:
when `row_groups` is not empty, they means the row-groups after applying
`options->filter`. Here it will recreate `row_groups`, which may contain
rowgroups not in `FilterRowGroups`
##########
cpp/src/arrow/dataset/scanner.h:
##########
@@ -55,6 +55,7 @@ constexpr int64_t kDefaultBatchSize = 1 << 17; // 128Ki rows
constexpr int32_t kDefaultBatchReadahead = 16;
constexpr int32_t kDefaultFragmentReadahead = 4;
constexpr int32_t kDefaultBytesReadahead = 1 << 25; // 32MiB
+constexpr int64_t kDefaultStartOffset = -1;
Review Comment:
Would `std::optional` be better here?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]