From 69c84d17c39df57cf82e696d155b386717696418 Mon Sep 17 00:00:00 2001 From: Luca Cominardi Date: Thu, 25 Apr 2024 16:06:37 +0200 Subject: [PATCH 1/3] Remove keyexpr with_parameters --- .../src/replica/aligner.rs | 8 ++++---- .../src/replica/storage.rs | 2 +- zenoh/src/key_expr.rs | 16 +--------------- zenoh/src/selector.rs | 7 +++++-- 4 files changed, 11 insertions(+), 22 deletions(-) diff --git a/plugins/zenoh-plugin-storage-manager/src/replica/aligner.rs b/plugins/zenoh-plugin-storage-manager/src/replica/aligner.rs index 3392bf28e8..75368783b5 100644 --- a/plugins/zenoh-plugin-storage-manager/src/replica/aligner.rs +++ b/plugins/zenoh-plugin-storage-manager/src/replica/aligner.rs @@ -316,10 +316,10 @@ impl Aligner { async fn perform_query(&self, from: &str, properties: String) -> (Vec, bool) { let mut no_err = true; - let selector = KeyExpr::from(&self.digest_key) - .join(&from) - .unwrap() - .with_parameters(&properties); + let selector = Selector::new( + KeyExpr::from(&self.digest_key).join(&from).unwrap(), + properties, + ); tracing::trace!("[ALIGNER] Sending Query '{}'...", selector); let mut return_val = Vec::new(); match self diff --git a/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs b/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs index 14425f4c28..0dd43c5266 100644 --- a/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs +++ b/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs @@ -638,7 +638,7 @@ impl StorageService { // with `_time=[..]` to get historical data (in case of time-series) let replies = match self .session - .get(KeyExpr::from(&self.key_expr).with_parameters("_time=[..]")) + .get(Selector::new(KeyExpr::from(&self.key_expr), "_time=[..]")) .target(QueryTarget::All) .consolidation(ConsolidationMode::None) .res() diff --git a/zenoh/src/key_expr.rs b/zenoh/src/key_expr.rs index c1c0504208..419918d547 100644 --- a/zenoh/src/key_expr.rs +++ b/zenoh/src/key_expr.rs @@ -57,7 +57,7 @@ use zenoh_protocol::{ }; use zenoh_result::ZResult; -use crate::{net::primitives::Primitives, prelude::Selector, Session, Undeclarable}; +use crate::{net::primitives::Primitives, Session, Undeclarable}; #[derive(Clone, Debug)] pub(crate) enum KeyExprInner<'a> { @@ -301,20 +301,6 @@ impl<'a> KeyExpr<'a> { Ok(r.into()) } } - - pub fn with_parameters(self, selector: &'a str) -> Selector<'a> { - Selector { - key_expr: self, - parameters: selector.into(), - } - } - - pub fn with_owned_parameters(self, selector: String) -> Selector<'a> { - Selector { - key_expr: self, - parameters: selector.into(), - } - } } impl FromStr for KeyExpr<'static> { diff --git a/zenoh/src/selector.rs b/zenoh/src/selector.rs index 2c7fc2d782..343f5fda1d 100644 --- a/zenoh/src/selector.rs +++ b/zenoh/src/selector.rs @@ -239,7 +239,7 @@ impl TryFrom for Selector<'_> { Some(qmark_position) => { let parameters = s[qmark_position + 1..].to_owned(); s.truncate(qmark_position); - Ok(KeyExpr::try_from(s)?.with_owned_parameters(parameters)) + Ok(Selector::new(KeyExpr::try_from(s)?, parameters)) } None => Ok(KeyExpr::try_from(s)?.into()), } @@ -252,7 +252,10 @@ impl<'a> TryFrom<&'a str> for Selector<'a> { match s.find('?') { Some(qmark_position) => { let params = &s[qmark_position + 1..]; - Ok(KeyExpr::try_from(&s[..qmark_position])?.with_parameters(params)) + Ok(Selector::new( + KeyExpr::try_from(&s[..qmark_position])?, + params, + )) } None => Ok(KeyExpr::try_from(s)?.into()), } From d56269c712fafcabd4e9519e28a358d3813d5462 Mon Sep 17 00:00:00 2001 From: Luca Cominardi Date: Thu, 25 Apr 2024 16:15:57 +0200 Subject: [PATCH 2/3] Fix nextest.toml --- .config/nextest.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.config/nextest.toml b/.config/nextest.toml index b2ed4cde98..4999dce0d3 100644 --- a/.config/nextest.toml +++ b/.config/nextest.toml @@ -16,7 +16,7 @@ test(=three_node_combination) | test(=watchdog_alloc_concurrent) | test(=header_check_memory_concurrent) | test(=header_link_concurrent) | -test(=header_link_failure_concurrent) +test(=header_link_failure_concurrent) | test(=downsampling_by_keyexpr) """ threads-required = 'num-cpus' From 8f3de09ee93dfa6798264254e3a926b440e4a710 Mon Sep 17 00:00:00 2001 From: Luca Cominardi Date: Thu, 25 Apr 2024 16:27:54 +0200 Subject: [PATCH 3/3] Update plugins/zenoh-plugin-storage-manager/src/replica/storage.rs Co-authored-by: Joseph Perez --- plugins/zenoh-plugin-storage-manager/src/replica/storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs b/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs index 0dd43c5266..0dc8bcb79d 100644 --- a/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs +++ b/plugins/zenoh-plugin-storage-manager/src/replica/storage.rs @@ -638,7 +638,7 @@ impl StorageService { // with `_time=[..]` to get historical data (in case of time-series) let replies = match self .session - .get(Selector::new(KeyExpr::from(&self.key_expr), "_time=[..]")) + .get(Selector::new(&self.key_expr, "_time=[..]")) .target(QueryTarget::All) .consolidation(ConsolidationMode::None) .res()