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

# mtbl(7)

immutable sorted string library

## NAME

mtbl - immutable sorted string library

## SYNOPSIS

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

**gcc \[***flags***\]** *files* **-lmtbl \[***libraries***\]**

## DESCRIPTION

The mtbl library provides interfaces for creating, searching, and merging Sorted String Table (SSTable) files in the *MTBL* format, which provide an immutable mapping of keys to values. Sorted String Tables are compact and provide fast random access to keys and key ranges. Keys and values are arbitrary byte arrays, and MTBL SSTables may not contain duplicate keys.

The six main interfaces provided by the mtbl library are:

[**mtbl\_iter**(3)](/mtbl_iter/3.md)

Iterator objects provide a consistent interface for iterating over the key-value entries returned by other interfaces.

[**mtbl\_source**(3)](/mtbl_source/3.md)

Source objects provide functions for obtaining iterators from an underlying data source. The **mtbl\_reader** and **mtbl\_merger** interfaces provide functions for obtaining references to a source object. The source methods return an **mtbl\_iter** object.

[**mtbl\_reader**(3)](/mtbl_reader/3.md)

Reader objects provide read-only access to *MTBL* files.

[**mtbl\_writer**(3)](/mtbl_writer/3.md)

Writer objects initialize a new *MTBL* file from a sequence of key-value entries provided by the caller. Keys must be in sorted order based on lexicographical byte value, and keys may not be duplicated.

[**mtbl\_merger**(3)](/mtbl_merger/3.md)

Merger objects receive multiple sequences of key-value entries from one or more **mtbl\_source** objects and combine them into a single, sorted sequence. The combined, merged output sequence is provided via the **mtbl\_source** interface.

[**mtbl\_sorter**(3)](/mtbl_sorter/3.md)

Sorter objects receive a sequence of key-value entries provided by the caller and return them in sorted order. The caller must provide a callback function to merge values in the case of entries with duplicate keys. The sorted output sequence may be retrieved via the **mtbl\_iter** interface or be dumped to an **mtbl\_writer** object.

[**mtbl\_fileset**(3)](/mtbl_fileset/3.md)

Fileset objects automatically maintain an **mtbl\_source** built on top of the **mtbl\_merger** and **mtbl\_reader** interfaces. The set of underlying **mtbl\_reader** objects is kept synchronized with a "setfile" on disk listing *MTBL* files.

Additionally, several utility interfaces are provided:

[**mtbl\_crc32c**(3)](/mtbl_crc32c/3.md)

Calculates the CRC32C checksum of a byte array.

[**mtbl\_fixed**(3)](/mtbl_fixed/3.md)

Functions for fixed-width encoding and decoding of 32 and 64 bit integers.

[**mtbl\_varint**(3)](/mtbl_varint/3.md)

Functions for varint encoding and decoding of 32 and 64 bit integers.
