# thrift.parquet_footer

> A module of thrift's API.

Locating and decoding the Parquet footer and page headers.

A Parquet file is `PAR1 <data...> <thrift FileMetaData> <i32 length> PAR1`,
where the length is little-endian and covers just the serialised metadata.
Page headers are the same compact-protocol encoding, written inline in the
data area with no length prefix — the decoder tells you how many bytes it
consumed so you can find the page body that follows.

```mojo
from thrift import read_footer, read_parquet_file

var bytes = read_parquet_file("part-0.parquet")
var meta = read_footer(Span(bytes))
print(meta.num_rows, len(meta.row_groups))
```

## Functions

### `read_parquet_file`

```mojo
def read_parquet_file(path: StringSpan) -> List[UInt8]
```

Slurp a whole file. Convenience for the CLI and the tests.

### `footer_length`

```mojo
def footer_length(data: Span[UInt8]) -> Int
```

The declared byte length of the serialised `FileMetaData`.

### `read_footer`

```mojo
def read_footer(file_bytes: Span[UInt8]) -> FileMetaData
```

Decode the `FileMetaData` at the end of a whole Parquet file.

### `read_footer_bytes`

```mojo
def read_footer_bytes(metadata_bytes: Span[UInt8]) -> FileMetaData
```

Decode a `FileMetaData` that has already been sliced out of a file.

### `write_footer`

```mojo
def write_footer(meta: FileMetaData) -> List[UInt8]
```

Serialise a `FileMetaData` with the compact protocol.

This is the footer body only — no magic, no length trailer. Use
`write_footer_trailer` to append the 8-byte tail a writer needs.

### `write_footer_trailer`

```mojo
def write_footer_trailer(mut out: List[UInt8], metadata_length: Int)
```

Append the little-endian i32 length and the trailing `PAR1`.

### `read_page_header`

```mojo
def read_page_header(data: Span[UInt8], offset: Int) -> Tuple[PageHeader, Int]
```

Decode one page header at `offset`, and say how long it was.

The second element is the header's byte length, so the page body starts
at `offset + header_len` and runs for `compressed_page_size` bytes.

## Aliases

### `PARQUET_MAGIC`

```mojo
comptime PARQUET_MAGIC = "PAR1"
```

### `PARQUET_MAGIC_ENCRYPTED`

```mojo
comptime PARQUET_MAGIC_ENCRYPTED = "PARE"
```

### `FOOTER_TRAILER_SIZE`

```mojo
comptime FOOTER_TRAILER_SIZE = 8
```
