Skip to content

Commit f1ad3fb

Browse files
committed
option to recompute manifests in rrd route
1 parent ad593f9 commit f1ad3fb

File tree

1 file changed

+30
-5
lines changed
  • crates/top/rerun/src/commands/rrd

1 file changed

+30
-5
lines changed

crates/top/rerun/src/commands/rrd/route.rs

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ pub struct RouteCommand {
3535
/// output.
3636
#[clap(long = "recording-id")]
3737
recording_id: Option<String>,
38+
39+
/// If set, this will compute an RRD footer with the appropriate manifest for the routed data.
40+
///
41+
/// By default, `rerun rrd route` will always drop all existing RRD manifests when routing data,
42+
/// as doing so invalidates their contents.
43+
/// This flag makes it possible to recompute an RRD manifest for the routed data, but beware
44+
/// that it has to decode the data, which means it is A) much slower and B) will migrate
45+
/// the data to the latest Sorbet specification automatically.
46+
#[clap(long = "recompute-manifests", default_value_t = false)]
47+
recompute_manifests: bool,
3848
}
3949

4050
struct Rewrites {
@@ -50,6 +60,7 @@ impl RouteCommand {
5060
continue_on_error,
5161
application_id,
5262
recording_id,
63+
recompute_manifests,
5364
} = self;
5465

5566
let rewrites = Rewrites {
@@ -70,6 +81,7 @@ impl RouteCommand {
7081
if let Some(path) = path_to_output_rrd {
7182
let writer = BufWriter::new(File::create(path)?);
7283
process_messages(
84+
*recompute_manifests,
7385
&rewrites,
7486
*continue_on_error,
7587
writer,
@@ -81,6 +93,7 @@ impl RouteCommand {
8193
let lock = stdout.lock();
8294
let writer = BufWriter::new(lock);
8395
process_messages(
96+
*recompute_manifests,
8497
&rewrites,
8598
*continue_on_error,
8699
writer,
@@ -93,7 +106,9 @@ impl RouteCommand {
93106
}
94107
}
95108

109+
#[expect(clippy::fn_params_excessive_bools)]
96110
fn process_messages<W: std::io::Write>(
111+
recompute_manifests: bool,
97112
rewrites: &Rewrites,
98113
continue_on_error: bool,
99114
writer: W,
@@ -105,6 +120,9 @@ fn process_messages<W: std::io::Write>(
105120
let mut num_unexpected_msgs = 0;
106121
let mut num_blueprint_activations = 0;
107122

123+
// Only used if recomputing manifests.
124+
let mut app_id_injector = re_log_encoding::CachingApplicationIdInjector::default();
125+
108126
// TODO(grtlr): encoding should match the original (just like in `rrd stats`).
109127
let options = re_log_encoding::rrd::EncodingOptions::PROTOBUF_COMPRESSED;
110128
let version = re_build_info::CrateVersion::LOCAL;
@@ -173,11 +191,18 @@ fn process_messages<W: std::io::Write>(
173191
}
174192
}
175193

176-
// Safety: we're just forwarding an existing message, we didn't change its payload
177-
// in any meaningful way.
178-
#[expect(unsafe_code)]
179-
unsafe {
180-
encoder.append_transport(&msg)?;
194+
if recompute_manifests {
195+
use re_log_encoding::ToApplication as _;
196+
let msg = msg.to_application((&mut app_id_injector, None))?;
197+
encoder.append(&msg)?;
198+
} else {
199+
// Safety: we're just forwarding an existing message, we didn't change its payload
200+
// in any meaningful way.
201+
#[expect(unsafe_code)]
202+
unsafe {
203+
// Reminder: this will implicitly discard RRD footers.
204+
encoder.append_transport(&msg)?;
205+
}
181206
}
182207
}
183208
Err(err) => {

0 commit comments

Comments
 (0)