Skip to content

Commit b4b7ec4

Browse files
authored
Client-side chunks 2: introduce TransportChunk (#6439)
A `TransportChunk` is a `Chunk` that is ready for transport and/or storage. It is very cheap to go from `Chunk` to a `TransportChunk` and vice-versa. A `TransportChunk` maps 1:1 to a native Arrow `RecordBatch`. It has a stable ABI, and can be cheaply send across process boundaries. `arrow2` has no `RecordBatch` type; we will get one once we migrate to `arrow-rs`. A `TransportChunk` is self-describing: it contains all the data _and_ metadata needed to index it into storage. We rely heavily on chunk-level and field-level metadata to communicate Rerun-specific semantics over the wire, e.g. whether some columns are already properly sorted. The Arrow metadata system is fairly limited -- it's all untyped strings --, but for now that seems good enough. It will be trivial to switch to something else later, if need be. - Fixes #1760 - Fixes #1692 - Fixes #3360 - Fixes #1696 --- Part of a PR series to implement our new chunk-based data model on the client-side (SDKs): - #6437 - #6438 - #6439 - #6440 - #6441
1 parent 6d94947 commit b4b7ec4

File tree

6 files changed

+835
-5
lines changed

6 files changed

+835
-5
lines changed

crates/re_chunk/src/chunk.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub type ChunkId = re_tuid::Tuid;
3535
/// Its time columns might or might not be ascendingly sorted, depending on how the data was logged.
3636
///
3737
/// This is the in-memory representation of a chunk, optimized for efficient manipulation of the
38-
/// data within.
38+
/// data within. For transport, see [`crate::TransportChunk`] instead.
3939
#[derive(Debug, Clone)]
4040
pub struct Chunk {
4141
pub(crate) id: ChunkId,
@@ -337,7 +337,16 @@ impl Chunk {
337337
}
338338
}
339339

340-
// TODO(cmc): display impl
340+
impl std::fmt::Display for Chunk {
341+
#[inline]
342+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
343+
let chunk = self.to_transport().map_err(|err| {
344+
re_log::error_once!("couldn't display Chunk: {err}");
345+
std::fmt::Error
346+
})?;
347+
chunk.fmt(f)
348+
}
349+
}
341350

342351
// TODO(cmc): sizebytes impl + sizebytes caching + sizebytes in transport metadata
343352

crates/re_chunk/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
77
mod chunk;
88
mod shuffle;
9+
mod transport;
910
mod util;
1011

1112
pub use self::chunk::{Chunk, ChunkError, ChunkId, ChunkResult, ChunkTimeline};
13+
pub use self::transport::TransportChunk;
1214
pub use self::util::arrays_to_list_array;
1315

1416
pub mod external {

crates/re_chunk/src/shuffle.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ mod tests {
297297
components.clone().into_iter().collect(),
298298
)?;
299299

300-
// eprintln!("{chunk_sorted}");
300+
eprintln!("{chunk_sorted}");
301301

302302
assert!(chunk_sorted.is_sorted());
303303
assert!(chunk_sorted.is_sorted_uncached());
@@ -308,7 +308,7 @@ mod tests {
308308
chunk_shuffled
309309
};
310310

311-
// eprintln!("{chunk_shuffled}");
311+
eprintln!("{chunk_shuffled}");
312312

313313
assert!(!chunk_shuffled.is_sorted());
314314
assert!(!chunk_shuffled.is_sorted_uncached());
@@ -320,7 +320,7 @@ mod tests {
320320
chunk_resorted
321321
};
322322

323-
// eprintln!("{chunk_resorted}");
323+
eprintln!("{chunk_resorted}");
324324

325325
assert!(chunk_resorted.is_sorted());
326326
assert!(chunk_resorted.is_sorted_uncached());

0 commit comments

Comments
 (0)