Skip to content

Commit a679de2

Browse files
committed
feedback
1 parent f397671 commit a679de2

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-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+
Op::AccessField(access_field) => f.debug_tuple("AccessField").field(field).finish(),
224+
Op::Cast(cast) => f.debug_tuple("Cast").field(cast).finish(),
225+
Op::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/rust/lenses/README.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<!--[metadata]
2-
title = "Transform recording stream example"
2+
title = "Lenses example"
33
-->
44

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

0 commit comments

Comments
 (0)