Skip to content

Rust: remove legacy send_columns and update everything left #8804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions crates/store/re_types/src/archetypes/asset_video.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/store/re_types/src/archetypes/points3d.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/store/re_types/src/archetypes/scalar.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions crates/store/re_types/src/archetypes/video_frame_reference.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 1 addition & 48 deletions crates/top/re_sdk/src/recording_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -983,53 +983,6 @@ impl RecordingStream {
self.log_with_static(ent_path, false, as_components)
}

/// Lower-level logging API to provide data spanning multiple timepoints.
///
/// Unlike the regular `log` API, which is row-oriented, this API lets you submit the data
/// in a columnar form. The lengths of all of the [`TimeColumn`] and the component batches
/// must match. All data that occurs at the same index across the different time and components
/// arrays will act as a single logical row.
///
/// Note that this API ignores any stateful time set on the log stream via the
/// [`Self::set_timepoint`]/[`Self::set_time_nanos`]/etc. APIs.
/// Furthermore, this will _not_ inject the default timelines `log_tick` and `log_time` timeline columns.
///
/// TODO(#7167): Unlike Python and C++, this API does not yet support arbitrary partitions of the incoming
/// component arrays. Each component will be individually associated with a single timepoint, rather
/// than offering how big the component arrays are that are associated with each timepoint.
#[inline]
pub fn send_columns<'a>(
&self,
ent_path: impl Into<EntityPath>,
timelines: impl IntoIterator<Item = TimeColumn>,
components: impl IntoIterator<Item = &'a dyn re_types_core::ComponentBatch>,
) -> RecordingStreamResult<()> {
let id = ChunkId::new();

let timelines = timelines
.into_iter()
.map(|timeline| (*timeline.timeline(), timeline))
.collect::<IntMap<_, _>>();

let components: Result<Vec<_>, ChunkError> = components
.into_iter()
.map(|batch| {
Ok((
batch.descriptor().into_owned(),
batch.to_arrow_list_array()?,
))
})
.collect();

let components: ChunkComponents = components?.into_iter().collect();

let chunk = Chunk::from_auto_row_ids(id, ent_path.into(), timelines, components)?;

self.send_chunk(chunk);

Ok(())
}

/// Lower-level logging API to provide data spanning multiple timepoints.
///
/// Unlike the regular `log` API, which is row-oriented, this API lets you submit the data
Expand All @@ -1040,7 +993,7 @@ impl RecordingStream {
/// Note that this API ignores any stateful time set on the log stream via the
/// [`Self::set_timepoint`]/[`Self::set_time_nanos`]/etc. APIs.
/// Furthermore, this will _not_ inject the default timelines `log_tick` and `log_time` timeline columns.
pub fn send_columns_v2(
pub fn send_columns(
&self,
ent_path: impl Into<EntityPath>,
indexes: impl IntoIterator<Item = TimeColumn>,
Expand Down
37 changes: 15 additions & 22 deletions docs/snippets/all/archetypes/image_send_columns.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use ndarray::{s, Array, ShapeBuilder};
use rerun::Archetype as _;

fn main() -> Result<(), Box<dyn std::error::Error>> {
let rec = rerun::RecordingStreamBuilder::new("rerun_example_image_send_columns").spawn()?;
Expand All @@ -21,33 +20,27 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.fill(255);
}

// Log the ImageFormat and indicator once, as static.
// Send the ImageFormat and indicator once, as static.
let format = rerun::components::ImageFormat::rgb8([width as _, height as _]);
rec.log_static(
rec.send_columns(
"images",
&[
&format as &dyn rerun::ComponentBatch,
&rerun::Image::indicator(),
],
[],
rerun::Image::update_fields()
.with_format(format)
.columns_of_unit_batches()?,
)?;

// Split up the image data into several components referencing the underlying data.
let image_size_in_bytes = width * height * 3;
let blob = rerun::datatypes::Blob::from(images.into_raw_vec_and_offset().0);
let image_column = times
.iter()
.map(|&t| {
let byte_offset = image_size_in_bytes * (t as usize);
rerun::components::ImageBuffer::from(
blob.clone() // Clone is only a reference count increase, not a full copy.
.sliced(byte_offset..(byte_offset + image_size_in_bytes)),
)
})
.collect::<Vec<_>>();

// Send all images at once.
let timeline_values = rerun::TimeColumn::new_sequence("step", times);
rec.send_columns("images", [timeline_values], [&image_column as _])?;
let timeline_values = rerun::TimeColumn::new_sequence("step", times.clone());
let buffer = images.into_raw_vec_and_offset().0;
rec.send_columns(
"images",
[timeline_values],
rerun::Image::update_fields()
.with_many_buffer(buffer.chunks(image_size_in_bytes))
.columns_of_unit_batches()?,
)?;

Ok(())
}
2 changes: 1 addition & 1 deletion docs/snippets/all/archetypes/points3d_send_columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.with_radii(radii)
.columns_of_unit_batches()?;

rec.send_columns_v2("points", [times], position.chain(color_and_radius))?;
rec.send_columns("points", [times], position.chain(color_and_radius))?;

Ok(())
}
2 changes: 1 addition & 1 deletion docs/snippets/all/archetypes/scalar_send_columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
let times = TimeColumn::new_sequence("step", 0..STEPS);
let scalars = (0..STEPS).map(|step| (step as f64 / 10.0).sin());

rec.send_columns_v2(
rec.send_columns(
"scalars",
[times],
rerun::Scalar::update_fields()
Expand Down
9 changes: 4 additions & 5 deletions docs/snippets/all/archetypes/video_auto_frames.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ fn main() -> anyhow::Result<()> {
// Note timeline values don't have to be the same as the video timestamps.
frame_timestamps_ns,
);
let frame_reference_indicators =
<rerun::VideoFrameReference as rerun::Archetype>::Indicator::new_array(
time_column.num_rows(),
);

rec.send_columns(
"video",
[time_column],
[&frame_reference_indicators as _, &video_timestamps_ns as _],
rerun::VideoFrameReference::update_fields()
.with_many_timestamp(video_timestamps_ns)
.columns_of_unit_batches()?,
)?;

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/howto/any_batch_value_send_columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
rerun::ComponentDescriptor::new("custom_component_multi"),
);

rec.send_columns_v2(
rec.send_columns(
"/",
[times],
[
Expand Down
2 changes: 1 addition & 1 deletion docs/snippets/all/howto/any_values_send_columns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
rerun::ComponentDescriptor::new("cos"),
);

rec.send_columns_v2(
rec.send_columns(
"/",
[times],
[
Expand Down
8 changes: 3 additions & 5 deletions tests/rust/plot_dashboard_stress/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,9 @@ fn run(rec: &rerun::RecordingStream, args: &Args) -> anyhow::Result<()> {
rec.send_columns(
path,
[rerun::TimeColumn::new_seconds("sim_time", seconds.copied())],
[&values
.copied()
.map(Into::into)
.collect::<Vec<rerun::components::Scalar>>()
as _],
rerun::Scalar::update_fields()
.with_many_scalar(values.copied())
.columns_of_unit_batches()?,
)?;
} else {
rec.log(path, &rerun::Scalar::new(series_values[offset]))?;
Expand Down
22 changes: 9 additions & 13 deletions tests/rust/test_temporal_batch/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
//! Very minimal test of using the send columns APIs.

use re_chunk::TimeColumn;
use rerun::components::Scalar;

fn main() -> Result<(), Box<dyn std::error::Error>> {
let rec = rerun::RecordingStreamBuilder::new("rerun_example_send_columns").spawn()?;

// Native time / scalars
let timeline_values = (0..64).collect::<Vec<_>>();
let timeline_values = TimeColumn::new_sequence("step", 0..64);
let scalar_data = (0..64).map(|step| (step as f64 / 10.0).sin());

let scalar_data: Vec<f64> = timeline_values
.iter()
.map(|step| (*step as f64 / 10.0).sin())
.collect();

// Convert to rerun time / scalars
let timeline_values = TimeColumn::new_sequence("step", timeline_values);
let scalar_data: Vec<Scalar> = scalar_data.into_iter().map(Into::into).collect();

rec.send_columns("scalar", [timeline_values], [&scalar_data as _])?;
rec.send_columns(
"scalar",
[timeline_values],
rerun::Scalar::update_fields()
.with_many_scalar(scalar_data)
.columns_of_unit_batches()?,
)?;

Ok(())
}
Loading