Skip to content

Commit e0ed672

Browse files
committed
feedback
1 parent f397671 commit e0ed672

File tree

5 files changed

+30
-17
lines changed

5 files changed

+30
-17
lines changed

Cargo.lock

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5704,8 +5704,6 @@ version = "0.26.0-alpha.1+dev"
57045704
dependencies = [
57055705
"anyhow",
57065706
"arrow",
5707-
"clap",
5708-
"insta",
57095707
"rerun",
57105708
]
57115709

crates/top/re_sdk/src/lenses.rs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ mod op {
121121
use super::Error;
122122

123123
/// Extracts a specific field from a struct component within a `ListArray`.
124+
#[derive(Debug)]
124125
pub struct AccessField {
125126
pub(super) field_name: String,
126127
}
@@ -157,6 +158,7 @@ mod op {
157158
}
158159

159160
/// Casts the `value_type` (inner array) of a `ListArray` to a different data type.
161+
#[derive(Debug)]
160162
pub struct Cast {
161163
pub(super) to_inner_type: DataType,
162164
}
@@ -215,6 +217,16 @@ pub enum Op {
215217
Func(Box<dyn Fn(ListArray) -> Result<ListArray, Error> + Sync + Send>),
216218
}
217219

220+
impl std::fmt::Debug for Op {
221+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
222+
match self {
223+
Self::AccessField(inner) => f.debug_tuple("AccessField").field(inner).finish(),
224+
Self::Cast(inner) => f.debug_tuple("Cast").field(inner).finish(),
225+
Self::Func(_) => f.debug_tuple("Func").field(&"<function>").finish(),
226+
}
227+
}
228+
}
229+
218230
impl Op {
219231
/// Extracts a specific field from a `StructArray`.
220232
pub fn access_field(field_name: impl Into<String>) -> Self {
@@ -378,12 +390,19 @@ impl Lens {
378390

379391
let mut list_array_result = list_array.clone();
380392
for op in &output.ops {
381-
if let Ok(result) = op.call(list_array_result) {
382-
list_array_result = result;
383-
} else {
384-
// TODO: context!
385-
re_log::error!("failed");
386-
return vec![];
393+
match op.call(list_array_result) {
394+
Ok(result) => {
395+
list_array_result = result;
396+
}
397+
Err(err) => {
398+
re_log::error!(
399+
"Lens operation '{:?}' failed for output column '{}' on entity '{}': {err}",
400+
op,
401+
output.entity_path,
402+
output.component_descr.component
403+
);
404+
return vec![];
405+
}
387406
}
388407
}
389408

@@ -399,7 +418,7 @@ impl Lens {
399418
chunk.timelines().clone()
400419
};
401420

402-
// TODO: In case of static, should we use sparse rows instead?
421+
// TODO(grtlr): In case of static, should we use sparse rows instead?
403422
Chunk::from_auto_row_ids(ChunkId::new(), entity_path.clone(), timelines, components)
404423
.inspect_err(|err| {
405424
re_log::error_once!(

examples/manifest.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ examples = [
152152
"graphs",
153153
"camera_video_stream",
154154
"log_file",
155+
"lenses",
155156
"openstreetmap_data",
156157
"minimal",
157158
"multiprocess_logging",

examples/rust/lenses/Cargo.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,3 @@ rerun = { path = "../../../crates/top/rerun", features = [
1414

1515
anyhow.workspace = true
1616
arrow.workspace = true
17-
clap = { workspace = true, features = ["derive"] }
18-
19-
[dev-dependencies]
20-
insta.workspace = true

examples/rust/lenses/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<!--[metadata]
2-
title = "Transform recording stream example"
2+
title = "Lenses example"
3+
channel = "main"
34
-->
45

5-
<!-- TODO: -->
6-
7-
Demonstrates how to transform log messages before forwarding them to the sink the SDK.
6+
Demonstrates how to use lenses to transform log messages before forwarding them to an underlying sink.
87
```bash
98
cargo run -p lenses
109
```

0 commit comments

Comments
 (0)