Skip to content

Commit

Permalink
Remove keyexpr with_parameters (#979)
Browse files Browse the repository at this point in the history
* Remove keyexpr with_parameters

* Fix nextest.toml

* Update plugins/zenoh-plugin-storage-manager/src/replica/storage.rs

Co-authored-by: Joseph Perez <[email protected]>

---------

Co-authored-by: Joseph Perez <[email protected]>
  • Loading branch information
Mallets and wyfo authored Apr 25, 2024
1 parent afacf77 commit 193e223
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 4 additions & 4 deletions plugins/zenoh-plugin-storage-manager/src/replica/aligner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,10 +316,10 @@ impl Aligner {

async fn perform_query(&self, from: &str, properties: String) -> (Vec<Sample>, 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(&self.key_expr, "_time=[..]"))
.target(QueryTarget::All)
.consolidation(ConsolidationMode::None)
.res()
Expand Down
16 changes: 1 addition & 15 deletions zenoh/src/key_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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> {
Expand Down
7 changes: 5 additions & 2 deletions zenoh/src/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl TryFrom<String> 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()),
}
Expand All @@ -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()),
}
Expand Down

0 comments on commit 193e223

Please sign in to comment.