| 376 | using ParquetInfo = std::vector<ColumnInfo>; |
| 377 | |
| 378 | ParquetInfo GetColumnParquetInfo(const std::shared_ptr<Buffer>& data, int column_index) { |
| 379 | // Read the parquet data out of the buffer and get the sizes and lengths of the |
| 380 | // data pages in given column. We assert on the sizes and lengths of the pages |
| 381 | // to ensure that the chunking is done correctly. |
| 382 | ParquetInfo result; |
| 383 | |
| 384 | auto buffer_reader = std::make_shared<BufferReader>(data); |
| 385 | auto parquet_reader = ParquetFileReader::Open(std::move(buffer_reader)); |
| 386 | |
| 387 | auto metadata = parquet_reader->metadata(); |
| 388 | for (int rg = 0; rg < metadata->num_row_groups(); rg++) { |
| 389 | auto page_reader = parquet_reader->RowGroup(rg)->GetColumnPageReader(column_index); |
| 390 | ColumnInfo column_info; |
| 391 | while (auto page = page_reader->NextPage()) { |
| 392 | if (page->type() == PageType::DATA_PAGE || page->type() == PageType::DATA_PAGE_V2) { |
| 393 | auto data_page = static_cast<DataPage*>(page.get()); |
| 394 | column_info.page_sizes.push_back(data_page->uncompressed_size()); |
| 395 | column_info.page_lengths.push_back(data_page->num_values()); |
| 396 | } else if (page->type() == PageType::DICTIONARY_PAGE) { |
| 397 | column_info.has_dictionary_page = true; |
| 398 | } |
| 399 | } |
| 400 | result.push_back(column_info); |
| 401 | } |
| 402 | |
| 403 | return result; |
| 404 | } |
| 405 | |
| 406 | // A git-hunk like side-by-side data structure to represent the differences between two |
| 407 | // vectors of uint64_t values. |
no test coverage detected