Skip to content

Commit

Permalink
Fix downsampling with wildcards
Browse files Browse the repository at this point in the history
  • Loading branch information
sashacmc committed Jul 11, 2024
1 parent 9e1c4a8 commit a7c93ff
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions zenoh/src/net/routing/interceptor/downsampling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,12 @@ pub(crate) struct DownsamplingInterceptor {
impl InterceptorTrait for DownsamplingInterceptor {
fn compute_keyexpr_cache(&self, key_expr: &KeyExpr<'_>) -> Option<Box<dyn Any + Send + Sync>> {
let ke_id = zlock!(self.ke_id);
if let Some(id) = ke_id.weight_at(&key_expr.clone()) {
Some(Box::new(Some(*id)))
} else {
Some(Box::new(None::<usize>))
if let Some(node) = ke_id.intersecting_keys(key_expr).next() {
if let Some(id) = ke_id.weight_at(&node) {
return Some(Box::new(Some(*id)));
}
}
return Some(Box::new(None::<usize>));
}

fn intercept(
Expand Down Expand Up @@ -188,6 +189,11 @@ impl DownsamplingInterceptor {
latest_message_timestamp,
},
);
tracing::debug!(
"New downsampler rule enabled: key_expr={:?}, threshold={:?}",
rule.key_expr,
threshold
);
}
Self {
ke_id: Arc::new(Mutex::new(ke_id)),
Expand Down

0 comments on commit a7c93ff

Please sign in to comment.