MCPcopy Create free account
hub / github.com/apache/arrow / CheckPageIndex

Method CheckPageIndex

cpp/src/parquet/encryption/test_encryption_util.cc:569–676  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

567}
568
569void FileDecryptor::CheckPageIndex(
570 parquet::ParquetFileReader* file_reader,
571 const std::shared_ptr<FileDecryptionProperties>& file_decryption_properties) {
572 std::shared_ptr<PageIndexReader> page_index_reader = file_reader->GetPageIndexReader();
573 ASSERT_NE(page_index_reader, nullptr);
574
575 const std::shared_ptr<parquet::FileMetaData> file_metadata = file_reader->metadata();
576 const int num_row_groups = file_metadata->num_row_groups();
577 const int num_columns = file_metadata->num_columns();
578 ASSERT_EQ(num_columns, 8);
579
580 // We cannot read page index of encrypted columns in the plaintext mode
581 std::vector<int32_t> need_row_groups(num_row_groups);
582 std::iota(need_row_groups.begin(), need_row_groups.end(), 0);
583 std::vector<int32_t> need_columns;
584 if (file_decryption_properties == nullptr) {
585 need_columns = {0, 1, 2, 3, 6, 7};
586 } else {
587 need_columns = {0, 1, 2, 3, 4, 5, 6, 7};
588 }
589
590 // Provide hint of requested columns to avoid accessing encrypted columns without
591 // decryption properties.
592 page_index_reader->WillNeed(
593 need_row_groups, need_columns,
594 PageIndexSelection{/*column_index=*/true, /*offset_index=*/true});
595
596 // Iterate over all the RowGroups in the file.
597 for (int r = 0; r < num_row_groups; ++r) {
598 auto row_group_page_index_reader = page_index_reader->RowGroup(r);
599 ASSERT_NE(row_group_page_index_reader, nullptr);
600
601 for (int c = 0; c < num_columns; ++c) {
602 // Skip reading encrypted columns without decryption properties.
603 if (file_decryption_properties == nullptr && (c == 4 || c == 5)) {
604 continue;
605 }
606
607 constexpr size_t kExpectedNumPages = 1;
608
609 // Check offset index.
610 auto offset_index = row_group_page_index_reader->GetOffsetIndex(c);
611 ASSERT_NE(offset_index, nullptr);
612 ASSERT_EQ(offset_index->page_locations().size(), kExpectedNumPages);
613 const auto& first_page = offset_index->page_locations()[0];
614 ASSERT_EQ(first_page.first_row_index, 0);
615 ASSERT_GT(first_page.compressed_page_size, 0);
616
617 // Int96 column does not have column index.
618 if (c == 3) {
619 continue;
620 }
621
622 // Check column index
623 auto column_index = row_group_page_index_reader->GetColumnIndex(c);
624 ASSERT_NE(column_index, nullptr);
625 ASSERT_EQ(column_index->null_pages().size(), kExpectedNumPages);
626 ASSERT_EQ(column_index->null_pages()[0], false);

Callers

nothing calls this directly

Calls 15

ByteArrayClass · 0.85
UnreachableFunction · 0.85
to_stringFunction · 0.85
GetOffsetIndexMethod · 0.80
has_null_countsMethod · 0.80
GetPageIndexReaderMethod · 0.45
metadataMethod · 0.45
num_row_groupsMethod · 0.45
num_columnsMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
WillNeedMethod · 0.45

Tested by

no test coverage detected