Skip to content

[Data] Dictionary-encode schema_data in MCAP blocks, and document the format - #65913

Closed
marwan116 wants to merge 3 commits into
masterfrom
marwan/mcap-schema-dedup
Closed

marwan116 wants to merge 3 commits into
masterfrom
marwan/mcap-schema-dedup

Conversation

@marwan116

@marwan116 marwan116 commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

A schema is a per-channel attribute in MCAP: the file stores each definition once in the data section, repeats it in the summary for lookup, and every channel that uses it refers to it by id. MCAPDatasource._message_to_dict copies the whole definition onto every row, so a block holds one value as many times as it has messages.

Real ROS 2 definitions are not small. In the recording used below, sensor_msgs/msg/Imu is 2,581 bytes and sensor_msgs/msg/CompressedImage is 1,505. On a high-rate topic with a small payload — IMU, odometry, transforms — that column dominates the block.

Fix. Dictionary-encode schema_data once per block, on the way out of _read_stream. Arrow keeps one copy of each distinct definition and gives every row an int32 index into it. The value a row reads back is byte-identical.

Measurements

A FAST-LIVO ROS 2 recording — 105 s, 24,456 messages: Livox IMU at ~200 Hz, Livox lidar, and two compressed camera streams. Before and after go through the same code path (read_mcap(...).materialize().size_bytes()), differing only in this change:

read rows before after smaller
one shard, all topics 286 11.95 MB 11.30 MB 5.5%
one shard, IMU only 247 741.0 KB 124.2 KB 83.2%
one shard, cameras only 26 4.95 MB 4.92 MB 0.5%
one shard, include_metadata=False 286 11.24 MB 11.24 MB 0.0%
full recording, IMU only 21,300 63.90 MB 9.00 MB 85.9%

The saving tracks payload size against schema size. It is large exactly where robotics pipelines read a high-rate, small-payload topic, and negligible where camera or lidar payloads outweigh the schema. Reading the recording whole gains 5.5%; reading only its IMU gains 85.9%, because 54.9 MB of that 63.9 MB was one 2,581-byte definition repeated 21,300 times.

include_metadata=False is byte-identical before and after, which is the column being absent rather than the encoding being skipped.

Scope and costs

Only schema_data is encoded. topic and schema_name repeat as well, but they are short enough that the saving is marginal, and callers sort by them — which Arrow cannot do on a dictionary-encoded column. Encoding them would trade a real capability for a rounding error.

What changes for callers. Verified on this branch merged with current master, by running each operation rather than reasoning about it.

Within one dataset:

  • Rows read back the same bytes. take, iter_rows, filter, groupby, unique, repartition, map_batches, and a write_parquet → read_parquet round trip are unchanged.
  • sort("schema_data") raises ArrowNotImplementedError.
  • to_pandas() and pandas batches return the column as category dtype rather than object; the values are unchanged. NumPy batches are unchanged.

Mixing blocks produced before and after this change — for example a union of a new read with a dataset materialized earlier:

  • Works: union itself, count, groupby, to_pandas, write_parquet, and map_batches as long as no batch spans an old and a new block.
  • Fails with Unable to merge: Field schema_data has incompatible types: dictionary<values=binary, indices=int32> vs binary: anything that concatenates an old block with a new one — map_batches or iter_batches with a batch_size that crosses the boundary, repartition, sort, random_shuffle.
  • A Parquet directory holding files written before and after this change fails to load with the same error, at read_parquet time. So appending the output of a new read to a Parquet dataset written by the old code breaks reads of that dataset. The escape hatch is a one-line cast back to binary in a map_batches before writing. Whether this warrants a release note, or an opt-in flag instead of a default, is the review question in this PR.

The mixed state is also the argument for doing this in one step rather than gradually: a corpus with both encodings is the state worth avoiding.

The helper leaves the column untouched when it is absent (include_metadata=False), already encoded, all-null (no schema on any message), or of a type Arrow declines to encode.

Also in this PR

The module docstring becomes a brief on the format: the record layout, what a message, channel and schema each are, and the three properties of MCAP that this module's behaviour follows from — the summary section sitting at the end of the file behind a footer offset, schemas being stored once per file, and chunks being the unit of compression. Each is load-bearing for code in the file rather than general background.

Related issues

Related to #65640 (file-level packed output), #65641 and #65787 (batch_size) — none of which touches the row schema.

Overlaps #65912 (in-memory size estimation) in two places, both small:

Tests

PYTHONPATH=python/ray/data/tests python -u -m pytest \
    python/ray/data/tests/datasource/test_mcap.py -v

21 passed on this branch merged with current master; master alone is 18. An earlier run of this PR reported one failure, test_read_mcap_invalid_time_range — a pre-existing bad regex on master, since fixed by #65914. That PR also installed mcap in CI, so the CI run on the merge commit is the first for this PR that actually executes this file and type-checks it with mcap's types visible; before it, the whole module was skipped and the green was vacuous.

Three new tests: the column is dictionary-encoded and every row reads back the original definition; the encoded block is smaller than the unencoded schema column alone would be; and include_metadata=False omits the column with the encoding a no-op.

Lint: black, ruff clean. pyrefly check on both files with mcap installed: 0 errors.


AI assistance (Claude) was used for this change. I reviewed every changed line and ran the tests locally.

… format

A schema is a per-channel attribute in MCAP: the file stores each definition
once, and every channel using it refers to it by id. `_message_to_dict`
copies the whole definition onto every row, so a block holds one value as
many times as it has messages. Real ROS 2 definitions are not small --
`sensor_msgs/msg/Imu` is 2,581 bytes, `sensor_msgs/msg/CompressedImage`
1,505 -- so on a high-rate topic with a small payload the column dominates
the block.

Dictionary-encode the column once per block, on the way out of
`_read_stream`. Arrow keeps one copy of each distinct definition and gives
every row an int32 index into it; the value a row reads back is unchanged.

Measured on a FAST-LIVO ROS 2 recording (105 s, 24,456 messages: Livox IMU
at ~200 Hz, Livox lidar, two compressed camera streams), same code path on
both sides:

                                     rows      before      after   smaller
    one shard, all topics             286    11.95 MB   11.30 MB      5.5%
    one shard, IMU only               247   741.0 KB   124.2 KB      83.2%
    one shard, cameras only            26     4.95 MB    4.92 MB      0.5%
    one shard, include_metadata=False 286    11.24 MB   11.24 MB      0.0%
    full recording, IMU only       21,300    63.90 MB    9.00 MB     85.9%

The saving tracks payload size against schema size, so it is large exactly
where robotics pipelines read high-rate, small-payload topics and negligible
where camera or lidar payloads outweigh the schema. Reading the recording
whole gains 5.5%; reading only its IMU gains 85.9%.

Only `schema_data` is encoded. `topic` and `schema_name` repeat as well, but
they are short enough that the saving is marginal, and callers sort and group
by them, which Arrow cannot do on a dictionary-encoded column.

Two costs, both verified rather than assumed:
- `sort_by("schema_data")` now raises `ArrowNotImplementedError`.
- `pa.concat_tables` refuses an encoded block beside an unencoded one, so
  unioning a new read with a dataset cached before this change will fail.

Also expand the module docstring into a brief on the format: the record
layout, what a message, channel and schema each are, and the three
properties of MCAP this module's behaviour follows from -- the summary
section's position at the end of the file, schemas being stored once per
file, and chunks being the unit of compression.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
@marwan116
marwan116 requested a review from a team as a code owner September 4, 2026 03:08

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces dictionary encoding for the schema_data column in the MCAP datasource to optimize memory usage when reading MCAP files with large schema definitions. It also adds comprehensive unit tests to verify the behavior. The reviewer suggested a performance optimization to reverse the order of combine_chunks() and dictionary_encode() on PyArrow columns to avoid the overhead of unifying dictionaries across multiple chunks.

Review suggested reversing the order to
`column.combine_chunks().dictionary_encode()`, on the grounds that
concatenating unencoded chunks is a fast buffer copy and encoding once
afterwards avoids unifying per-chunk dictionaries.

Measured, it is the other way round: the buffer being copied is the
repeated schema definitions, which is the redundancy this function exists
to remove. Encoding per chunk shrinks the data before anything is
concatenated.

    rows    chunks   column   encode-then-combine   combine-then-encode
  60,000        21   147.2 MB   10.2 ms / 160.7 MB    28.7 ms / 295.0 MB
   5,000         2    12.3 MB    0.9 ms /  18.4 MB     1.1 ms /  24.6 MB
  21,300         1    52.3 MB    3.6 ms /  86.4 MB    10.2 ms / 104.7 MB

Medians of five runs after a warm-up; peak is the process high-water mark
from `pyarrow.default_memory_pool()`. Results are byte-identical either
way, so this is purely a cost question.

Record it in a comment so the ordering is not re-litigated. Note also that
`combine_chunks()` is what collapses one dictionary per chunk into one for
the block; it is not required for correctness -- `pa.concat_tables` accepts
either form -- but it is close to free once the column is encoded.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
@marwan116 marwan116 added the go add ONLY when ready to merge, run all tests label Sep 4, 2026
@marwan116 marwan116 self-assigned this Sep 4, 2026
@ray-gardener ray-gardener Bot added the data Ray Data-related issues label Sep 4, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had
any activity for 14 days. It will be closed in another 14 days if no further activity occurs.
Thank you for your contributions.

You can always ask for help on our discussion forum or Ray's public slack channel.

If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@github-actions github-actions Bot added the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Sep 18, 2026
@marwan116 marwan116 removed the stale The issue is stale. It will be closed within 7 days unless there are further conversation label Sep 23, 2026
@marwan116

Copy link
Copy Markdown
Contributor Author

Merged current master into the branch (a merge commit, no history rewrite) so CI runs test_mcap.py for real: #65914 has since installed mcap in CI, and the green run from Sep 4 predates it and never executed this file. On the merge locally: 21 passed, pyrefly check 0 errors, black/ruff clean.

I also ran every user-facing operation I could think of against the encoded column, including a corpus that mixes blocks from before and after this change, and rewrote the Scope and costs section of the description with the results. The case worth a reviewer's eye is the last bullet there: a Parquet directory that mixes files written before and after fails to load, so this may want a release note or an opt-in flag.

@marwan116 marwan116 added the unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it. label Oct 1, 2026
marwan116 added a commit that referenced this pull request Oct 2, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 2, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 2, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 2, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 2, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 5, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 6, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel of the
  sampled files is JSON-encoded; otherwise every payload stays bytes. Arrow
  has no column type for a mix of the two (the fallback is a pickled-object
  column the V2 path refuses), so the planned schema fixes the decision once
  and every reader follows it, failing with the message named on a payload
  that is not valid JSON or a channel the sample did not see with another
  encoding. The legacy path kept raw bytes for a message that failed to
  parse, which poisoned the column the same way.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 6, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel is
  JSON-encoded; otherwise every payload stays bytes. Arrow has no column
  type for a mix of the two (the fallback is a pickled-object column the V2
  path refuses), so the planned schema fixes the decision once and every
  reader follows it, failing with the message named on a payload that is
  not valid JSON or a channel planning did not see with another encoding.
  The legacy path kept raw bytes for a message that failed to parse, which
  poisoned the column the same way.
- `mcap_data_column` makes that decision. A selected channel that is not
  JSON in any sampled file plans `binary`, read from the summaries. The
  first sampled file with a selected message in `time_range` types the
  column from one chunk. A file whose summary cannot settle the selection
  is scanned, at most four per read. If the sample types nothing, up to 256
  more listed files are checked by summary only.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 6, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel is
  JSON-encoded; otherwise every payload stays bytes. Arrow has no column
  type for a mix of the two (the fallback is a pickled-object column the V2
  path refuses), so the planned schema fixes the decision once and every
  reader follows it, failing with the message named on a payload that is
  not valid JSON or a channel planning did not see with another encoding.
  The legacy path kept raw bytes for a message that failed to parse, which
  poisoned the column the same way.
- `mcap_data_column` makes that decision. A selected channel that is not
  JSON in any sampled file plans `binary`, read from the summaries. The
  first sampled file with a selected message in `time_range` types the
  column from one chunk. A file whose summary cannot settle the selection
  is scanned, at most four per read. If the sample types nothing, up to 256
  more listed files are checked by summary only.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
marwan116 added a commit that referenced this pull request Oct 6, 2026
…, row_id

`read_mcap` reads a file in one task, so a job's parallelism is capped by
its file count: ten 30 GB recordings are ten tasks on a 200-core cluster,
and a GPU stage downstream waits for the first whole file. Every file is
opened even when its summary already says it holds nothing the read
selects. And no row has a stable identity, so a checkpointed pipeline has
nothing to resume on.

Put the reader on Datasource V2, where listing, sizing and pushdown are the
framework's job, under `DataContext.use_datasource_v2` (the switch Parquet
already uses). The legacy `MCAPDatasource` stays as the fallback.

- `MCAPSummaryIndexer` lists files, reads each summary (two seeks, a few
  KB) and emits one listing row per chunk: the chunk's byte offset as its
  unit id, its uncompressed size as its weight. A file whose channels or
  time bounds cannot match the selection is dropped before any payload is
  read. A file with no summary is one whole-file row.
- `OnlineBinPacker` groups chunks into read tasks of about 128 MiB
  uncompressed (`RAY_DATA_MCAP_BIN_PACKING_BYTES`), so a large recording
  is read by many tasks and small ones share one.
- `MCAPReader` seeks straight to its chunks. With `log_time_order` it
  merges them through one heap of chunk indexes and messages, so only the
  chunks that overlap in time are decompressed at once; without it, file
  order. Tables are cut at `target_max_block_size`.
- `row_id` (`include_row_id`, or automatically when the checkpoint config's
  `id_column` is `row_id`) names a message by its file, its chunk's byte
  offset and its position in the chunk, so the same message gets the same
  id however the read is split and whatever it selects.
- Column pruning skips building (and for JSON channels, decoding) columns
  a projection dropped; a pushed limit stops a task early.
- `data` holds decoded JSON values only when every selected channel is
  JSON-encoded; otherwise every payload stays bytes. Arrow has no column
  type for a mix of the two (the fallback is a pickled-object column the V2
  path refuses), so the planned schema fixes the decision once and every
  reader follows it, failing with the message named on a payload that is
  not valid JSON or a channel planning did not see with another encoding.
  The legacy path kept raw bytes for a message that failed to parse, which
  poisoned the column the same way.
- `mcap_data_column` makes that decision. A selected channel that is not
  JSON in any sampled file plans `binary`, read from the summaries. The
  first sampled file with a selected message in `time_range` types the
  column from one chunk. A file whose summary cannot settle the selection
  is scanned, at most four per read. If the sample types nothing, up to 256
  more listed files are checked by summary only.

Rows keep the legacy columns and types. Two additions: `schema_data` is
dictionary-encoded (a schema is stored once per file but repeated on every
row; ROS 2 definitions run kilobytes each) and `channel_metadata` carries
the channel's metadata as a `map<string, string>`, the same changes #65913
and #65916 make to the legacy path. `TimeRange` moves next to the V2
datasource so `datasource_v2` does not import the legacy module; the old
import path still works.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
@marwan116

Copy link
Copy Markdown
Contributor Author

Closing: DataSource V2 (#66654) already dictionary-encodes schema_data, and the old reader only runs when V2 is turned off.

@marwan116 marwan116 closed this Oct 7, 2026
richardliaw pushed a commit that referenced this pull request Nov 6, 2026
…, row_id (#66654)

## Description

Part 1 of 3 of the `read_mcap` move to Datasource V2, based on master.
#67166 is stacked on it, and #67167 on #67166. The rest of the
`read_mcap` stack (#67189 onward) sits on top.

**Problem.** One task reads one whole file:

- Parallelism is capped by the file count: ten 30 GB recordings are ten
tasks.
- Every file is opened, even when its index shows it holds nothing
selected.
- Rows have no stable id, so a checkpointed pipeline cannot resume.

**Change.** `read_mcap` moves to Datasource V2, on by default as for
`read_parquet` (`DataContext.use_datasource_v2`). The legacy datasource
stays as the fallback.

```
files
  │  listing: read each file's index (a few ranged reads)
  │           one row per chunk, weighted by the memory reading it takes
  │           drop chunks that cannot match topics / time_range
  ▼
chunk rows
  │  packing: about 128 MiB per read task
  │           one big file ──► many tasks;  small files ──► one task
  │           with preserve_order: one task per file, in listing order
  ▼
read tasks: seek to their chunks, merge them by log time
```

- New code lives in `datasource_v2/formats/mcap/`. The V2 interfaces do
not change.
- Columns and types match the legacy path, with two changes.
`schema_data` is dictionary-encoded. A new `channel_metadata` column
holds each channel's metadata map as JSON text, dictionary-encoded, so a
block stores it once per channel.
- `data` holds decoded JSON only when every selected channel is JSON.
Otherwise it holds bytes. Planning types it from the selected messages
of the first chunk that holds one, as a read task types the messages it
holds.
- `row_id` is `<path>#c=<chunk offset>:<index>`, stable however the read
is split. It is on with `include_row_id=True`, or automatically under
`CheckpointConfig(id_column="row_id")`.
- New `log_time_order` argument, default `True`. Each task returns each
of its files in `log_time` order. With `preserve_order`, each file is
read by one task, so it comes out in order from start to end, and files
come out in the order they were listed. #67166 splits a large file there
too, only where its order holds.
- A file whose summary cannot be read gets a read task of its own, so
`max_errored_blocks` can skip it alone.
- The task size is `RAY_DATA_MCAP_BIN_PACKING_BYTES` (128 MiB).

**Changed after the first review round.** Each is its own commit:

- Summaries and chunks are read in a few ranged requests, not a few
bytes per GET.
- An unreadable file gets a read task of its own.
- Tables are built column by column, cut counting every column, and
chunks are weighted by the memory reading them takes.
- The read stops at the row limit.
- A file without a chunk index is sorted by log time.
- `channel_metadata` is JSON text, stored once per block.
- With `preserve_order`, each file is kept in one read task, and files
keep their listing order.
- Planning skips a chunk it cannot decode, and types `data` from the
first chunk's messages.

**Measured** on an 845 MB recording with 1,052 chunks: reading its 125
KB summary took about 20,000 GETs and now takes 3.

**Decisions to confirm:**

- Splitting is on by default. Block boundaries change; rows do not.
- With `preserve_order`, this PR reads each file in one task, as the
legacy reader does. #67166 lets it split a large file where its log-time
order holds.
- `ds.schema()` comes from the first chunk that holds a selected
message. A field that first appears later is missing from it; the
docstring says so.

## Related issues

- Related to #65640 and #65641.
- No open PR moves MCAP to Datasource V2. #66524 (ORC) and #66182
(Iceberg) are other formats moving to V2.
- The generated-ID stack (#65886 to #65888) is orthogonal.
- `log_time_order` comes from my #66653, now closed. My legacy-path PRs
#65912, #65913 and #65916 are closed in favour of this one.

## Additional information

```
PYTHONPATH=python/ray/data/tests pytest python/ray/data/tests/datasource/test_mcap.py \
  python/ray/data/tests/unit/datasource_v2/test_mcap_*.py \
  python/ray/data/tests/unit/datasource_v2/test_online_bin_packer.py
```

178 passed, 3 skipped. pre-commit and pyrefly clean.

AI assistance (Claude Code) was used to draft this change; I reviewed
every line and ran the tests above locally.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Marwan Sarieddine <[email protected]>
Co-authored-by: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

data Ray Data-related issues go add ONLY when ready to merge, run all tests unstale A PR that has been marked unstale. It will not get marked stale again if this label is on it.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant