From febc1538ffb1abcc95b4d49ea781a5e27a37afa4 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" <193874+carols10cents@users.noreply.github.com> Date: Thu, 6 May 2021 18:07:10 -0400 Subject: [PATCH] chore: Update Rust version (#1445) * chore: Update Rust version * refactor: Make struct constructor field orderings consistent Sometimes I changed the struct definition, sometimes changed the struct construction instance, depending on consistency with code around each (other similar structs, function argument orders, etc) More info: https://rust-lang.github.io/rust-clippy/master/index.html#inconsistent_struct_constructor * refactor: Use flatten where appropriate One instance is a false positive with a clippy bug. More info: - https://rust-lang.github.io/rust-clippy/master/index.html#filter_map_identity - https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten * refactor: Use Option map instead of match More info: https://rust-lang.github.io/rust-clippy/master/index.html#manual_map Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- influxdb_iox_client/src/client/management.rs | 2 +- influxdb_tsm/src/reader.rs | 1 + internal_types/src/arrow/sort.rs | 2 +- metrics/src/lib.rs | 8 +++----- metrics/src/metrics.rs | 4 ++-- query/src/exec/seriesset.rs | 7 ++----- rust-toolchain | 2 +- server/src/db.rs | 4 ++-- 8 files changed, 13 insertions(+), 17 deletions(-) diff --git a/influxdb_iox_client/src/client/management.rs b/influxdb_iox_client/src/client/management.rs index d197f6b90e..b8dbaeac76 100644 --- a/influxdb_iox_client/src/client/management.rs +++ b/influxdb_iox_client/src/client/management.rs @@ -474,8 +474,8 @@ impl Client { self.inner .new_partition_chunk(NewPartitionChunkRequest { db_name, - table_name, partition_key, + table_name, }) .await .map_err(|status| match status.code() { diff --git a/influxdb_tsm/src/reader.rs b/influxdb_tsm/src/reader.rs index 03bc48497c..54a730b4dc 100644 --- a/influxdb_tsm/src/reader.rs +++ b/influxdb_tsm/src/reader.rs @@ -459,6 +459,7 @@ impl BlockData { /// overwrites previous values. Therefore, in order to have "last write /// wins" semantics it is important that the provided vector of blocks /// is ordered by the wall-clock time the blocks were created. + #[allow(clippy::manual_flatten)] // https://github.com/rust-lang/rust-clippy/issues/6784 pub fn merge(mut blocks: Vec) -> Self { if blocks.is_empty() { panic!("merge called with zero blocks"); diff --git a/internal_types/src/arrow/sort.rs b/internal_types/src/arrow/sort.rs index 4bdeb78ace..e57578070a 100644 --- a/internal_types/src/arrow/sort.rs +++ b/internal_types/src/arrow/sort.rs @@ -36,7 +36,7 @@ pub type Result = std::result::Result; /// pub fn estimate_cardinality(array: &DictionaryArray) -> usize { let keys = array.keys(); - let group: HashSet<_> = keys.iter().filter_map(|x| x).collect(); + let group: HashSet<_> = keys.iter().flatten().collect(); group.len() } diff --git a/metrics/src/lib.rs b/metrics/src/lib.rs index fef5d343b2..1aa4cc59a9 100644 --- a/metrics/src/lib.rs +++ b/metrics/src/lib.rs @@ -162,11 +162,9 @@ impl Domain { suffix: Option<&str>, ) -> String { let mut ret = self.name.to_string(); - for s in &[subname, Some(metric_name), unit, suffix] { - if let Some(s) = s { - ret.push('.'); - ret.push_str(s) - } + for s in [subname, Some(metric_name), unit, suffix].iter().flatten() { + ret.push('.'); + ret.push_str(s); } ret } diff --git a/metrics/src/metrics.rs b/metrics/src/metrics.rs index 062144f4b6..bb01facbeb 100644 --- a/metrics/src/metrics.rs +++ b/metrics/src/metrics.rs @@ -71,9 +71,9 @@ impl Display for RedRequestStatus { /// Using a `REDMetric` makes following this methodology easy because it handles /// updating the three components for you. pub struct RedMetric { - default_labels: Vec, requests: OTCounter, duration: OTHistogram, + default_labels: Vec, } impl RedMetric { @@ -370,8 +370,8 @@ impl Gauge { /// A Histogram is a metric exposing a distribution of observations. #[derive(Debug)] pub struct Histogram { - default_labels: Vec, histogram: OTHistogram, + default_labels: Vec, } impl Histogram { diff --git a/query/src/exec/seriesset.rs b/query/src/exec/seriesset.rs index 3eb03e4d7f..1d47a7ac19 100644 --- a/query/src/exec/seriesset.rs +++ b/query/src/exec/seriesset.rs @@ -348,11 +348,8 @@ impl SeriesSetConverter { batch.schema().fields()[*column_index] ), }; - if let Some(tag_value) = tag_value { - Some((Arc::clone(&column_name), Arc::from(tag_value.as_str()))) - } else { - None - } + + tag_value.map(|tag_value| (Arc::clone(&column_name), Arc::from(tag_value.as_str()))) }) .collect() } diff --git a/rust-toolchain b/rust-toolchain index d2d62553b3..d4f820371f 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.51.0 \ No newline at end of file +1.52.0 \ No newline at end of file diff --git a/server/src/db.rs b/server/src/db.rs index 8e5e31a944..1e3931e5da 100644 --- a/server/src/db.rs +++ b/server/src/db.rs @@ -158,9 +158,9 @@ pub enum Error { source ))] ReadBufferChunkTimestampError { - chunk_id: u32, - table_name: String, source: read_buffer::Error, + table_name: String, + chunk_id: u32, }, #[snafu(display("Error writing to object store: {}", source))]