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

Method ParseFooterLength

cpp/src/parquet/file_reader.cc:491–512  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 4

FromLittleEndianFunction · 0.50
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected