Repository navigation
Conversation
… format
A schema is a per-channel attribute in MCAP: the file stores each definition
once, and every channel using it refers to it by id. `_message_to_dict`
copies the whole definition onto every row, so a block holds one value as
many times as it has messages. Real ROS 2 definitions are not small --
`sensor_msgs/msg/Imu` is 2,581 bytes, `sensor_msgs/msg/CompressedImage`
1,505 -- so on a high-rate topic with a small payload the column dominates
the block.
Dictionary-encode the column once per block, on the way out of
`_read_stream`. Arrow keeps one copy of each distinct definition and gives
every row an int32 index into it; the value a row reads back is unchanged.
Measured on a FAST-LIVO ROS 2 recording (105 s, 24,456 messages: Livox IMU
at ~200 Hz, Livox lidar, two compressed camera streams), same code path on
both sides:
rows before after smaller
one shard, all topics 286 11.95 MB 11.30 MB 5.5%
one shard, IMU only 247 741.0 KB 124.2 KB 83.2%
one shard, cameras only 26 4.95 MB 4.92 MB 0.5%
one shard, include_metadata=False 286 11.24 MB 11.24 MB 0.0%
full recording, IMU only 21,300 63.90 MB 9.00 MB 85.9%
The saving tracks payload size against schema size, so it is large exactly
where robotics pipelines read high-rate, small-payload topics and negligible
where camera or lidar payloads outweigh the schema. Reading the recording
whole gains 5.5%; reading only its IMU gains 85.9%.
Only `schema_data` is encoded. `topic` and `schema_name` repeat as well, but
they are short enough that the saving is marginal, and callers sort and group
by them, which Arrow cannot do on a dictionary-encoded column.
Two costs, both verified rather than assumed:
- `sort_by("schema_data")` now raises `ArrowNotImplementedError`.
- `pa.concat_tables` refuses an encoded block beside an unencoded one, so
unioning a new read with a dataset cached before this change will fail.
Also expand the module docstring into a brief on the format: the record
layout, what a message, channel and schema each are, and the three
properties of MCAP this module's behaviour follows from -- the summary
section's position at the end of the file, schemas being stored once per
file, and chunks being the unit of compression.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
There was a problem hiding this comment.
Code Review
This pull request introduces dictionary encoding for the schema_data column in the MCAP datasource to optimize memory usage when reading MCAP files with large schema definitions. It also adds comprehensive unit tests to verify the behavior. The reviewer suggested a performance optimization to reverse the order of combine_chunks() and dictionary_encode() on PyArrow columns to avoid the overhead of unifying dictionaries across multiple chunks.
Review suggested reversing the order to
`column.combine_chunks().dictionary_encode()`, on the grounds that
concatenating unencoded chunks is a fast buffer copy and encoding once
afterwards avoids unifying per-chunk dictionaries.
Measured, it is the other way round: the buffer being copied is the
repeated schema definitions, which is the redundancy this function exists
to remove. Encoding per chunk shrinks the data before anything is
concatenated.
rows chunks column encode-then-combine combine-then-encode
60,000 21 147.2 MB 10.2 ms / 160.7 MB 28.7 ms / 295.0 MB
5,000 2 12.3 MB 0.9 ms / 18.4 MB 1.1 ms / 24.6 MB
21,300 1 52.3 MB 3.6 ms / 86.4 MB 10.2 ms / 104.7 MB
Medians of five runs after a warm-up; peak is the process high-water mark
from `pyarrow.default_memory_pool()`. Results are byte-identical either
way, so this is purely a cost question.
Record it in a comment so the ordering is not re-litigated. Note also that
`combine_chunks()` is what collapses one dictionary per chunk into one for
the block; it is not required for correctness -- `pa.concat_tables` accepts
either form -- but it is close to free once the column is encoded.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: Marwan Sarieddine <[email protected]>
|
This pull request has been automatically marked as stale because it has not had 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. |
…dedup Signed-off-by: Marwan Sarieddine <[email protected]>
|
Merged current master into the branch (a merge commit, no history rewrite) so CI runs I also ran every user-facing operation I could think of against the encoded column, including a corpus that mixes blocks from before and after this change, and rewrote the Scope and costs section of the description with the results. The case worth a reviewer's eye is the last bullet there: a Parquet directory that mixes files written before and after fails to load, so this may want a release note or an opt-in flag. |
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
…, 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]>
|
Closing: DataSource V2 (#66654) already dictionary-encodes |
…, 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]>
Description
A schema is a per-channel attribute in MCAP: the file stores each definition once in the data section, repeats it in the summary for lookup, and every channel that uses it refers to it by id.
MCAPDatasource._message_to_dictcopies the whole definition onto every row, so a block holds one value as many times as it has messages.Real ROS 2 definitions are not small. In the recording used below,
sensor_msgs/msg/Imuis 2,581 bytes andsensor_msgs/msg/CompressedImageis 1,505. On a high-rate topic with a small payload — IMU, odometry, transforms — that column dominates the block.Fix. Dictionary-encode
schema_dataonce per block, on the way out of_read_stream. Arrow keeps one copy of each distinct definition and gives every row an int32 index into it. The value a row reads back is byte-identical.Measurements
A FAST-LIVO ROS 2 recording — 105 s, 24,456 messages: Livox IMU at ~200 Hz, Livox lidar, and two compressed camera streams. Before and after go through the same code path (
read_mcap(...).materialize().size_bytes()), differing only in this change:include_metadata=FalseThe saving tracks payload size against schema size. It is large exactly where robotics pipelines read a high-rate, small-payload topic, and negligible where camera or lidar payloads outweigh the schema. Reading the recording whole gains 5.5%; reading only its IMU gains 85.9%, because 54.9 MB of that 63.9 MB was one 2,581-byte definition repeated 21,300 times.
include_metadata=Falseis byte-identical before and after, which is the column being absent rather than the encoding being skipped.Scope and costs
Only
schema_datais encoded.topicandschema_namerepeat as well, but they are short enough that the saving is marginal, and callers sort by them — which Arrow cannot do on a dictionary-encoded column. Encoding them would trade a real capability for a rounding error.What changes for callers. Verified on this branch merged with current master, by running each operation rather than reasoning about it.
Within one dataset:
bytes.take,iter_rows,filter,groupby,unique,repartition,map_batches, and awrite_parquet→read_parquetround trip are unchanged.sort("schema_data")raisesArrowNotImplementedError.to_pandas()and pandas batches return the column ascategorydtype rather thanobject; the values are unchanged. NumPy batches are unchanged.Mixing blocks produced before and after this change — for example a
unionof a new read with a dataset materialized earlier:unionitself,count,groupby,to_pandas,write_parquet, andmap_batchesas long as no batch spans an old and a new block.Unable to merge: Field schema_data has incompatible types: dictionary<values=binary, indices=int32> vs binary: anything that concatenates an old block with a new one —map_batchesoriter_batcheswith abatch_sizethat crosses the boundary,repartition,sort,random_shuffle.read_parquettime. So appending the output of a new read to a Parquet dataset written by the old code breaks reads of that dataset. The escape hatch is a one-line cast back tobinaryin amap_batchesbefore writing. Whether this warrants a release note, or an opt-in flag instead of a default, is the review question in this PR.The mixed state is also the argument for doing this in one step rather than gradually: a corpus with both encodings is the state worth avoiding.
The helper leaves the column untouched when it is absent (
include_metadata=False), already encoded, all-null (no schema on any message), or of a type Arrow declines to encode.Also in this PR
The module docstring becomes a brief on the format: the record layout, what a message, channel and schema each are, and the three properties of MCAP that this module's behaviour follows from — the summary section sitting at the end of the file behind a footer offset, schemas being stored once per file, and chunks being the unit of compression. Each is load-bearing for code in the file rather than general background.
Related issues
Related to #65640 (file-level packed output), #65641 and #65787 (
batch_size) — none of which touches the row schema.Overlaps #65912 (in-memory size estimation) in two places, both small:
_read_stream, so once both are in it should also call_dictionary_encode_schema_datato keep its estimate faithful. Without that line the estimate overstates by roughly the saving above. I will add it in whichever of the two rebases second.Tests
21 passed on this branch merged with current master; master alone is 18. An earlier run of this PR reported one failure,
test_read_mcap_invalid_time_range— a pre-existing bad regex on master, since fixed by #65914. That PR also installedmcapin CI, so the CI run on the merge commit is the first for this PR that actually executes this file and type-checks it withmcap's types visible; before it, the whole module was skipped and the green was vacuous.Three new tests: the column is dictionary-encoded and every row reads back the original definition; the encoded block is smaller than the unencoded schema column alone would be; and
include_metadata=Falseomits the column with the encoding a no-op.Lint:
black,ruffclean.pyrefly checkon both files withmcapinstalled: 0 errors.AI assistance (Claude) was used for this change. I reviewed every changed line and ran the tests locally.