Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove keyexpr with_parameters #979

Merged
merged 3 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading