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

Method NextPage

cpp/src/parquet/column_reader.cc:400–550  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

398}
399
400std::shared_ptr<Page> SerializedPageReader::NextPage() {
401 ThriftDeserializer deserializer(properties_);
402
403 // Loop here because there may be unhandled page types that we skip until
404 // finding a page that we do know what to do with
405 while (seen_num_values_ < total_num_values_) {
406 uint32_t header_size = 0;
407 uint32_t allowed_page_size = kDefaultPageHeaderSize;
408
409 // Page headers can be very large because of page statistics
410 // We try to deserialize a larger buffer progressively
411 // until a maximum allowed header limit
412 while (true) {
413 PARQUET_ASSIGN_OR_THROW(auto view, stream_->Peek(allowed_page_size));
414 if (view.size() == 0) return nullptr;
415
416 // This gets used, then set by DeserializeThriftMsg
417 header_size = static_cast<uint32_t>(view.size());
418 try {
419 if (meta_decryptor_ != nullptr) {
420 UpdateDecryption(meta_decryptor_.get(), encryption::kDictionaryPageHeader,
421 &data_page_header_aad_);
422 }
423 // Reset current page header to avoid unclearing the __isset flag.
424 current_page_header_ = format::PageHeader();
425 deserializer.DeserializeMessage(reinterpret_cast<const uint8_t*>(view.data()),
426 &header_size, &current_page_header_,
427 meta_decryptor_.get());
428 break;
429 } catch (std::exception& e) {
430 // Failed to deserialize. Double the allowed page header size and try again
431 std::stringstream ss;
432 ss << e.what();
433 allowed_page_size *= 2;
434 if (allowed_page_size > max_page_header_size_) {
435 ss << "Deserializing page header failed.\n";
436 throw ParquetException(ss.str());
437 }
438 }
439 }
440 // Advance the stream offset
441 PARQUET_THROW_NOT_OK(stream_->Advance(header_size));
442
443 int32_t compressed_len = current_page_header_.compressed_page_size;
444 int32_t uncompressed_len = current_page_header_.uncompressed_page_size;
445 if (compressed_len < 0 || uncompressed_len < 0) {
446 throw ParquetException("Invalid page header");
447 }
448
449 EncodedStatistics data_page_statistics;
450 if (ShouldSkipPage(&data_page_statistics)) {
451 PARQUET_THROW_NOT_OK(stream_->Advance(compressed_len));
452 continue;
453 }
454
455 if (data_decryptor_ != nullptr) {
456 UpdateDecryption(data_decryptor_.get(), encryption::kDictionaryPage,
457 &data_page_aad_);

Callers 15

CheckCorrectCrcMethod · 0.45
CheckCorrectDictCrcMethod · 0.45
CheckNextPageCorruptMethod · 0.45
TEST_FFunction · 0.45
TESTFunction · 0.45
TESTFunction · 0.45
ASSERT_OK_AND_ASSIGNFunction · 0.45
GetColumnParquetInfoFunction · 0.45
ReadNewPageMethod · 0.45
TestPageSerdeCrcMethod · 0.45
TEST_FFunction · 0.45
TYPED_TESTFunction · 0.45

Calls 15

PageHeaderClass · 0.85
ParquetExceptionFunction · 0.85
LoadEnumSafeFunction · 0.85
PageCanUseChecksumFunction · 0.85
crc32Function · 0.85
to_stringFunction · 0.85
AddWithOverflowFunction · 0.85
DeserializeMessageMethod · 0.80
strMethod · 0.80
AllocateBufferFunction · 0.70
sizeMethod · 0.45

Tested by 14

CheckCorrectCrcMethod · 0.36
CheckCorrectDictCrcMethod · 0.36
CheckNextPageCorruptMethod · 0.36
TEST_FFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
ASSERT_OK_AND_ASSIGNFunction · 0.36
GetColumnParquetInfoFunction · 0.36
TestPageSerdeCrcMethod · 0.36
TEST_FFunction · 0.36
TYPED_TESTFunction · 0.36