Skip to content

Commit

Permalink
implement TransportChunk
Browse files Browse the repository at this point in the history
  • Loading branch information
teh-cmc committed May 29, 2024
1 parent 80aa2a3 commit 4a9b5cd
Show file tree
Hide file tree
Showing 4 changed files with 708 additions and 5 deletions.
13 changes: 11 additions & 2 deletions crates/re_chunk/src/chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub type ChunkId = re_tuid::Tuid;
/// Its time columns might or might not be ascendingly sorted, depending on how the data was logged.
///
/// This is the in-memory representation of a chunk, optimized for efficient manipulation of the
/// data within.
/// data within. For transport, see [`crate::TransportChunk`] instead.
#[derive(Debug, Clone)]
pub struct Chunk {
pub(crate) id: ChunkId,
Expand Down Expand Up @@ -337,7 +337,16 @@ impl Chunk {
}
}

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

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

Expand Down
2 changes: 2 additions & 0 deletions crates/re_chunk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

mod chunk;
mod shuffle;
mod transport;
mod util;

pub use self::chunk::{Chunk, ChunkError, ChunkId, ChunkResult, ChunkTimeline};
pub use self::transport::TransportChunk;
pub use self::util::arrays_to_list_array;

pub mod external {
Expand Down
6 changes: 3 additions & 3 deletions crates/re_chunk/src/shuffle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ mod tests {
components.clone().into_iter().collect(),
)?;

// eprintln!("{chunk_sorted}");
eprintln!("{chunk_sorted}");

assert!(chunk_sorted.is_sorted());
assert!(chunk_sorted.is_sorted_uncached());
Expand All @@ -355,7 +355,7 @@ mod tests {
chunk_shuffled
};

// eprintln!("{chunk_shuffled}");
eprintln!("{chunk_shuffled}");

assert!(!chunk_shuffled.is_sorted());
assert!(!chunk_shuffled.is_sorted_uncached());
Expand All @@ -367,7 +367,7 @@ mod tests {
chunk_resorted
};

// eprintln!("{chunk_resorted}");
eprintln!("{chunk_resorted}");

assert!(chunk_resorted.is_sorted());
assert!(chunk_resorted.is_sorted_uncached());
Expand Down
Loading

0 comments on commit 4a9b5cd

Please sign in to comment.