---
name: "mtbl_metadata"
section: "3"
platform: "linux"
package: "libmtbl-dev"
version: "1.6.1-1+b1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/mtbl_metadata"
---

# mtbl\_metadata(3)

get MTBL file metadata

## NAME

mtbl\_metadata - get MTBL file metadata

## SYNOPSIS

**#include \<mtbl.h\>**

```
mtbl_file_version
mtbl_metadata_file_version(const struct mtbl_metadata *m);
```

```
uint64_t
mtbl_metadata_index_block_offset(const struct mtbl_metadata *m);
```

```
uint64_t
mtbl_metadata_data_block_size(const struct mtbl_metadata *m);
```

```
mtbl_compression_type
mtbl_metadata_compression_algorithm(const struct mtbl_metadata *m);
```

```
uint64_t
mtbl_metadata_count_entries(const struct mtbl_metadata *m);
```

```
uint64_t
mtbl_metadata_count_data_blocks(const struct mtbl_metadata *m);
```

```
uint64_t
mtbl_metadata_bytes_data_blocks(const struct mtbl_metadata *m);
```

```
uint64_t
mtbl_metadata_bytes_index_block(const struct mtbl_metadata *m);
```

```
uint64_t
mtbl_metadata_bytes_keys(const struct mtbl_metadata *m);
```

```
uint64_t
mtbl_metadata_bytes_values(const struct mtbl_metadata *m);
```

## DESCRIPTION

An **mtbl\_metadata** object may be obtained from an [**mtbl\_reader**(3)](/mtbl_reader/3.md). Its accessors export attributes and file statistics that are recorded in the metadata block.

## RETURN VALUE

### mtbl\_metadata\_file\_version()

File format version of the MTBL file. Either MTBL\_FORMAT\_V1 or MTBL\_FORMAT\_V2.

### mtbl\_metadata\_index\_block\_offset()

Byte offset in the MTBL file where the index begins.

### mtbl\_metadata\_data\_block\_size()

Maximum size of an uncompressed data block, see [**mtbl\_writer**(3)](/mtbl_writer/3.md).

### mtbl\_metadata\_compression\_algorithm()

One of the **compression** values allowed by [**mtbl\_writer**(3)](/mtbl_writer/3.md).

### mtbl\_metadata\_count\_entries()

Total number of key-value entries.

### mtbl\_metadata\_count\_data\_blocks()

Total number of data blocks.

### mtbl\_metadata\_bytes\_data\_blocks()

Total number of bytes consumed by data blocks.

### mtbl\_metadata\_bytes\_index\_block()

Total number of bytes consumed by the index.

### mtbl\_metadata\_bytes\_keys()

Total number of bytes that all keys would occupy if stored end-to-end in a byte array with no delimiters.

### mtbl\_metadata\_bytes\_values()

Total number of bytes that all values in the file would occupy if stored end-to-end in a byte array with no delimiters.
