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

Method ParseFooterLength

cpp/src/parquet/file_reader.cc:493–514  ·  view source on GitHub ↗

Validate the magic bytes and get the length of the full footer.

Source from the content-addressed store, hash-verified

491
492 // Validate the magic bytes and get the length of the full footer.
493 uint32_t ParseFooterLength(const std::shared_ptr<::arrow::Buffer>& footer_buffer,
494 const int64_t footer_read_size) {
495 // Check if all bytes are read. Check if last 4 bytes read have the magic bits
496 if (footer_buffer->size() != footer_read_size ||
497 (memcmp(footer_buffer->data() + footer_read_size - 4, kParquetMagic, 4) != 0 &&
498 memcmp(footer_buffer->data() + footer_read_size - 4, kParquetEMagic, 4) != 0)) {
499 throw ParquetInvalidOrCorruptedFileException(
500 "Parquet magic bytes not found in footer. Either the file is corrupted or this "
501 "is not a parquet file.");
502 }
503 // Both encrypted/unencrypted footers have the same footer length check.
504 uint32_t metadata_len =
505 ::arrow::bit_util::FromLittleEndian(::arrow::util::SafeLoadAs<uint32_t>(
506 reinterpret_cast<const uint8_t*>(footer_buffer->data()) + footer_read_size -
507 kFooterSize));
508 if (metadata_len > source_size_ - kFooterSize) {
509 throw ParquetInvalidOrCorruptedFileException(
510 "Parquet file size is ", source_size_,
511 " bytes, smaller than the size reported by footer's (", metadata_len, "bytes)");
512 }
513 return metadata_len;
514 }
515
516 // Does not throw.
517 Future<> ParseMetaDataAsync() {

Callers

nothing calls this directly

Calls 4

FromLittleEndianFunction · 0.50
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected