---
sidebar:
  hidden: true
title: roboto.experimental.topics.decode.mcap
---
## Module Contents

### McapFileDecoder

```python
class roboto.experimental.topics.decode.mcap.McapFileDecoder(
    group: roboto.experimental.topics.decode.common.ScanTaskGroup,
    partition: roboto.experimental.topics.read_plan.ReadPlanPartition,
    window: roboto.experimental.topics.read_plan.TimeWindow,
    params: roboto.experimental.topics.decode.common.FileDecodeParams,
)
```

`from roboto.experimental.topics.decode.mcap import McapFileDecoder`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/topics/decode/mcap.py#L40-L193)

Bases: [`roboto.experimental.topics.decode.common.FileDecoder`](/reference/python-sdk/roboto/experimental/topics/decode/common#roboto.experimental.topics.decode.common.FileDecoder)

Decodes one MCAP file of a partition through a cursor of the `mcap_codec` Rust extension.

The cursor reads the MCAP channel on the group's topic, or the file's only channel when the group names no topic. The codec reads the fields the group supplies, keeps only the rows at the positions of the partition's `data_range` when it has one, shifts each timestamp by the partition's `time_offset_ns`, and keeps the rows in the window. The cursor reads the file's summary when it opens, then only the chunks that hold the topic's messages (for a log-time timestamp, only those whose log times can fall in the window), all downloaded before the first batch is decoded.

Iterating [`batches()`](/reference/python-sdk/roboto/experimental/topics/decode/mcap#roboto.experimental.topics.decode.mcap.McapFileDecoder.batches) raises [`RobotoReadPlanExecutionException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoReadPlanExecutionException) with kind `invalid-timestamp` at the first row whose timestamp the codec cannot read as signed 64-bit nanoseconds once shifted (a value of the wrong type, NaN or infinite, or out of range), and [`RobotoInternalException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoInternalException) when the codec cannot read a message.

**Parameters**

- **group** (`roboto.experimental.topics.decode.common.ScanTaskGroup`)
- **partition** (`roboto.experimental.topics.read_plan.ReadPlanPartition`)
- **window** (`roboto.experimental.topics.read_plan.TimeWindow`)
- **params** (`roboto.experimental.topics.decode.common.FileDecodeParams`)

**Properties**

- **McapFileDecoder.value_fields** (`list[pyarrow.Field]`): The value columns, one per top-level field the file supplies, sorted by name, comparing Unicode code points.

  Each struct keeps the fields the file supplies, in the order the file stores them.

#### McapFileDecoder.batches()

```python
def batches() -> collections.abc.Iterator[pyarrow.RecordBatch]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/topics/decode/mcap.py#L127-L138)

The window's rows, in the file's stored row order; iterate it once.

A partition that declares a `data_range` gets only the window's rows inside that slice of the file. Each batch has the columns of [`topic_data_schema()`](/reference/python-sdk/roboto/experimental/topics/batch_transforms#roboto.experimental.topics.batch_transforms.topic_data_schema) over [`value_fields`](/reference/python-sdk/roboto/experimental/topics/decode/mcap#roboto.experimental.topics.decode.mcap.McapFileDecoder.value_fields): the row number, the timestamp, then the value columns. A row's number is its 0-based position among the file's rows of the topic, counting every stored row, including rows outside the window or the `data_range` and rows with a null timestamp, so a row has the same number in every file of its partition. The timestamp is absolute: the stored value in nanoseconds plus the partition's `time_offset_ns`. Batch boundaries carry no meaning.

**Returns**

- `collections.abc.Iterator[pyarrow.RecordBatch]`

#### McapFileDecoder.close()

```python
def close() -> None
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/topics/decode/mcap.py#L140-L142)

Release the file. Safe to call more than once.

**Returns**

- `None`

#### McapFileDecoder.struct_field_names()

```python
def struct_field_names(
    path: roboto.domain.topics.record.FieldPath,
) -> Optional[list[str]]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/experimental/topics/decode/mcap.py#L144-L155)

The names of the fields of the struct at `path` in the file, in the file's order.

`None` when the file has no struct at `path`.

**Parameters**

- **path** (`roboto.domain.topics.record.FieldPath`)

**Returns**

- `Optional[list[str]]`
