Skip to content

Commit f57fe17

Browse files
committed
feedback
1 parent f397671 commit f57fe17

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed

crates/top/re_sdk/src/lenses.rs

Lines changed: 25 additions & 6 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

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/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)