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

Method NextPage

cpp/src/parquet/column_reader.cc:396–546  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

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