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

fix clippy, fmt #2162

Merged
merged 1 commit into from
Aug 30, 2023
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
1 change: 1 addition & 0 deletions src/aggregation/bucket/histogram/histogram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ impl SegmentHistogramCollector {
let buckets_mem = self.buckets.memory_consumption();
self_mem + sub_aggs_mem + buckets_mem
}
/// Converts the collector result into a intermediate bucket result.
pub fn into_intermediate_bucket_result(
self,
agg_with_accessor: &AggregationWithAccessor,
Expand Down
2 changes: 0 additions & 2 deletions src/aggregation/bucket/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ mod term_agg;

use std::collections::HashMap;

pub(crate) use histogram::SegmentHistogramCollector;
pub use histogram::*;
pub(crate) use range::SegmentRangeCollector;
pub use range::*;
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
pub use term_agg::*;
Expand Down
2 changes: 1 addition & 1 deletion src/aggregation/metric/percentiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ mod tests {

fn test_aggregation_percentiles(merge_segments: bool) -> crate::Result<()> {
use rand_distr::Distribution;
let num_values_in_segment = vec![100, 30_000, 8000];
let num_values_in_segment = [100, 30_000, 8000];
let lg_norm = rand_distr::LogNormal::new(2.996f64, 0.979f64).unwrap();
let mut rng = StdRng::from_seed([1u8; 32]);

Expand Down
10 changes: 5 additions & 5 deletions src/core/json_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -619,21 +619,21 @@ mod tests {

#[test]
fn test_split_json_path_escaped_dot() {
let json_path = split_json_path(r#"toto\.titi"#);
let json_path = split_json_path(r"toto\.titi");
assert_eq!(&json_path, &["toto.titi"]);
let json_path_2 = split_json_path(r#"k8s\.container\.name"#);
let json_path_2 = split_json_path(r"k8s\.container\.name");
assert_eq!(&json_path_2, &["k8s.container.name"]);
}

#[test]
fn test_split_json_path_escaped_backslash() {
let json_path = split_json_path(r#"toto\\titi"#);
assert_eq!(&json_path, &[r#"toto\titi"#]);
let json_path = split_json_path(r"toto\\titi");
assert_eq!(&json_path, &[r"toto\titi"]);
}

#[test]
fn test_split_json_path_escaped_normal_letter() {
let json_path = split_json_path(r#"toto\titi"#);
let json_path = split_json_path(r"toto\titi");
assert_eq!(&json_path, &[r#"tototiti"#]);
}
}
6 changes: 3 additions & 3 deletions src/fastfield/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ mod tests {
.unwrap()
.first_or_default_col(0);

let numbers = vec![100, 200, 300];
let numbers = [100, 200, 300];
let test_range = |range: RangeInclusive<u64>| {
let expexted_count = numbers.iter().filter(|num| range.contains(num)).count();
let mut vec = vec![];
Expand Down Expand Up @@ -1013,7 +1013,7 @@ mod tests {
.unwrap()
.first_or_default_col(0);

let numbers = vec![1000, 1001, 1003];
let numbers = [1000, 1001, 1003];
let test_range = |range: RangeInclusive<u64>| {
let expexted_count = numbers.iter().filter(|num| range.contains(num)).count();
let mut vec = vec![];
Expand Down Expand Up @@ -1098,7 +1098,7 @@ mod tests {
.unwrap()
.is_none());
let column = fast_field_reader
.column_opt::<i64>(r#"json.attr\.age"#)
.column_opt::<i64>(r"json.attr\.age")
.unwrap()
.unwrap();
let vals: Vec<i64> = column.values_for_doc(0u32).collect();
Expand Down
4 changes: 2 additions & 2 deletions src/indexer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ mod tests_mmap {
let parse_query = QueryParser::for_index(&index, Vec::new());
{
let query = parse_query
.parse_query(r#"json.k8s\.container\.name:prometheus"#)
.parse_query(r"json.k8s\.container\.name:prometheus")
.unwrap();
let num_docs = searcher.search(&query, &Count).unwrap();
assert_eq!(num_docs, 1);
Expand Down Expand Up @@ -127,7 +127,7 @@ mod tests_mmap {
}
{
let query = parse_query
.parse_query(r#"json.k8s\.container\.name:prometheus"#)
.parse_query(r"json.k8s\.container\.name:prometheus")
.unwrap();
let num_docs = searcher.search(&query, &Count).unwrap();
assert_eq!(num_docs, 1);
Expand Down
2 changes: 1 addition & 1 deletion src/positions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub mod tests {
serializer.close_term()?;
serializer.close()?;
let position_delta = OwnedBytes::new(positions_buffer);
let mut output_delta_pos_buffer = vec![0u32; 5];
let mut output_delta_pos_buffer = [0u32; 5];
let mut position_reader = PositionReader::open(position_delta)?;
position_reader.read(0, &mut output_delta_pos_buffer[..]);
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion src/query/phrase_query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub mod tests {
let index = create_index(&["a b b d c g c", "a b a b c"])?;
let text_field = index.schema().get_field("text").unwrap();
let searcher = index.reader()?.searcher();
let terms: Vec<Term> = vec!["a", "b", "c"]
let terms: Vec<Term> = ["a", "b", "c"]
.iter()
.map(|text| Term::from_field_text(text_field, text))
.collect();
Expand Down
6 changes: 3 additions & 3 deletions src/query/query_parser/query_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1305,7 +1305,7 @@ mod test {
"k8s\u{1}node\u{1}name\0shello"
);
assert_eq!(
extract_query_term_json_path(r#"json.k8s\.node\.name:hello"#),
extract_query_term_json_path(r"json.k8s\.node\.name:hello"),
"k8s.node.name\0shello"
);
}
Expand Down Expand Up @@ -1731,10 +1731,10 @@ mod test {
#[test]
fn test_escaped_field() {
let mut schema_builder = Schema::builder();
schema_builder.add_text_field(r#"a\.b"#, STRING);
schema_builder.add_text_field(r"a\.b", STRING);
let schema = schema_builder.build();
let query_parser = QueryParser::new(schema, Vec::new(), TokenizerManager::default());
let query = query_parser.parse_query(r#"a\.b:hello"#).unwrap();
let query = query_parser.parse_query(r"a\.b:hello").unwrap();
assert_eq!(
format!("{query:?}"),
"TermQuery(Term(field=0, type=Str, \"hello\"))"
Expand Down
4 changes: 2 additions & 2 deletions src/schema/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -514,8 +514,8 @@ mod tests {
#[test]
fn test_locate_splitting_dots() {
assert_eq!(&super::locate_splitting_dots("a.b.c"), &[1, 3]);
assert_eq!(&super::locate_splitting_dots(r#"a\.b.c"#), &[4]);
assert_eq!(&super::locate_splitting_dots(r#"a\..b.c"#), &[3, 5]);
assert_eq!(&super::locate_splitting_dots(r"a\.b.c"), &[4]);
assert_eq!(&super::locate_splitting_dots(r"a\..b.c"), &[3, 5]);
}

#[test]
Expand Down