Skip to content

[Data] Surface MCAP channel metadata as a map column - #65916

Closed
marwan116 wants to merge 3 commits into
masterfrom
marwan/mcap-chan-metadata
Closed

marwan116 wants to merge 3 commits into
masterfrom
marwan/mcap-chan-metadata

Conversation

@marwan116

@marwan116 marwan116 commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Description

A Channel record carries a metadata field of type Map<string, string> — MCAP specification, op=0x04, "Metadata about this channel" — holding whatever the recorder chose to record about the topic. ROS 2 writes offered_qos_profiles there, and rigs commonly add sensor serials or calibration identifiers.

No message record reproduces it, so today it is not reachable from the dataset at all. include_metadata=True adds channel_id, message_encoding, schema_name, schema_encoding and schema_data — the schema and the channel's id, but not the channel's own metadata map. A caller who needs it has to re-open the file with the mcap library alongside the Ray Data read.

This adds a channel_metadata column under the existing include_metadata flag.

The column is typed, not inferred

Arrow reads a Python dict as a struct whose fields are the union of the keys it happens to see. Two consequences, both verified:

file A: struct<serial: string>
file B: struct<offered_qos_profiles: string>
pa.concat_tables([A, B]) -> ArrowInvalid: Schema at index 1 was different
  • Blocks from two files recording different keys carry different types and fail to concatenate (only promote_options="permissive" gets past it).
  • A channel that never recorded a key becomes indistinguishable from one whose value is null, because the union fills the missing field with None.

A map<string, string> matches the specification's own type, keeps the block schema stable whatever the keys are, and concatenates across files without promotion. It is built explicitly in _add_channel_metadata rather than added in _message_to_dict, since the builder would otherwise infer the struct.

Verified on a real recording

A FAST-LIVO ROS 2 recording (Livox IMU + lidar + two compressed camera streams):

dtype: map<string, string>
  /left_camera/image/compressed    {'offered_qos_profiles': ''}
  /livox/imu                       {'offered_qos_profiles': ''}
  /livox/lidar                     {'offered_qos_profiles': ''}
  /right_camera/image/compressed   {'offered_qos_profiles': ''}

concat across files: 1457 rows from 40 blocks

Every rosbag2-produced MCAP populates this field, so this is the common case rather than a corner one.

Why this is not a duplicate

I checked issues and PRs for mcap, channel_metadata and metadata in all states.

Compatibility

include_metadata=True is the default, so this adds a column to the default output. read_mcap is @PublicAPI(stability="alpha"). Verified on this branch merged with current master, by running each operation rather than reasoning about it:

  • Additive. Code selecting named columns is unaffected; code asserting an exact schema sees one more column.
  • Mixing blocks from before and after this change is safe. Ray's block concatenation fills the missing column with nulls, so union, repartition, sort, random_shuffle and batches spanning old and new blocks all work, and a Parquet directory holding files written before and after this change loads and reads normally.
  • Rows read the column back as a list of (key, value) pairs, the shape pyarrow gives a map. to_pandas() uses the Arrow-backed map<string, string> dtype. A pandas map_batches round trip preserves the type; a NumPy round trip comes back as list<list<string>>, because NumPy has no map type.
  • Sorting by the column raises ArrowTypeError: Sorting not supported for type map, which is Arrow's rule for maps, not something this PR can change.

Happy to move it behind a separate flag if maintainers prefer.

Review follow-up

The helper used to return a non-Arrow block unchanged, which would have dropped the column silently. That branch was unreachable — _read_stream only ever builds Arrow blocks — and is now an assertion, so a non-Arrow block fails instead of losing data.

Tests

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

22 passed on this branch merged with current master; master alone is 18. An earlier run 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.

Four new tests: the column carries the channel's metadata and is typed map; include_metadata=False omits it; blocks from files with different metadata keys still concatenate (the reason for map over struct); and a channel recording no metadata yields an empty map rather than failing.

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

AI assistance

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

A Channel record carries a `metadata` field of type `Map<string, string>`
(MCAP specification, op=0x04) holding whatever the recorder chose to
record about the topic. ROS 2 writes `offered_qos_profiles` there, and
rigs commonly add sensor serials or calibration identifiers. No message
record reproduces it, so it was not reachable from the dataset at all:
`include_metadata` added the schema and channel *ids*, but not the
channel's own metadata map.

Add it as a `channel_metadata` column under `include_metadata`.

The column is typed explicitly as `map<string, string>` rather than left
to inference. Arrow reads a Python dict as a `struct` whose fields are
the union of the keys it happens to see, which has two consequences:
blocks from two files recording different keys carry different types and
raise ArrowInvalid on concat_tables, and a channel that never recorded a
key becomes indistinguishable from one whose value is null. A map matches
the specification's own type, keeps the block schema stable whatever the
keys are, and concatenates across files.

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 04:31

@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 adds support for extracting and appending MCAP channel metadata as a map<string, string> column (named channel_metadata) when reading MCAP files via ray.data.read_mcap. This ensures that channel-level metadata, such as ROS 2 QoS profiles or sensor serials, is preserved and accessible across concatenated blocks. The review feedback suggests two key improvements: handling fallback pandas DataFrame blocks to prevent the metadata column from being silently omitted, and defensively handling cases where channel.metadata might be None or missing.

@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 and others added 2 commits September 23, 2026 08:24
…lock

_read_stream builds its blocks from dict rows, which DelegatingBlockBuilder
always turns into an Arrow table, so the early return for other block types
in _add_channel_metadata was unreachable -- and had it been reached, it would
have returned the block without the column, silently. Replace it with an
assertion, which also narrows the type for the checker.

Raised in review on #65916.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
@marwan116 marwan116 added go add ONLY when ready to merge, run all tests and removed stale The issue is stale. It will be closed within 7 days unless there are further conversation labels 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 Sep 4 microcheck predates it and never executed this file. Added the go label so premerge runs too. On the merge locally: 22 passed, pyrefly check 0 errors, black/ruff clean.

Both review threads are answered: the non-Arrow branch was unreachable and is now an assertion (a33c0bd), and channel.metadata is always a dict per Channel.read. I also ran the new column through mixed old/new blocks and Parquet directories; it is additive in every case, results in the Compatibility section of the description.

@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) returns channel metadata as channel_metadata, 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