From b4c907b9401bf4e1a85ba66d7c053ea2a4cac0cf Mon Sep 17 00:00:00 2001 From: Neville Dipale Date: Fri, 7 May 2021 09:50:21 +0200 Subject: [PATCH] 1.52 clippy fixes --- arrow/src/array/data.rs | 1 + arrow/src/compute/kernels/regexp.rs | 6 ++---- arrow/src/json/reader.rs | 2 +- parquet/src/arrow/array_reader.rs | 8 +++----- parquet/src/arrow/schema.rs | 6 ++---- parquet/src/schema/parser.rs | 8 ++++---- 6 files changed, 13 insertions(+), 18 deletions(-) diff --git a/arrow/src/array/data.rs b/arrow/src/array/data.rs index 7ae3858e35c1..9d5b0ee023db 100644 --- a/arrow/src/array/data.rs +++ b/arrow/src/array/data.rs @@ -500,6 +500,7 @@ impl ArrayDataBuilder { } #[inline] + #[allow(clippy::len_without_is_empty)] pub const fn len(mut self, n: usize) -> Self { self.len = n; self diff --git a/arrow/src/compute/kernels/regexp.rs b/arrow/src/compute/kernels/regexp.rs index 446d71d9f4a5..5093dcede8fe 100644 --- a/arrow/src/compute/kernels/regexp.rs +++ b/arrow/src/compute/kernels/regexp.rs @@ -82,10 +82,8 @@ pub fn regexp_match( }; match re.captures(value) { Some(caps) => { - for m in caps.iter().skip(1) { - if let Some(v) = m { - list_builder.values().append_value(v.as_str())?; - } + for m in caps.iter().skip(1).flatten() { + list_builder.values().append_value(m.as_str())?; } list_builder.append(true)? } diff --git a/arrow/src/json/reader.rs b/arrow/src/json/reader.rs index 31c496c9293b..d0b9c19013b0 100644 --- a/arrow/src/json/reader.rs +++ b/arrow/src/json/reader.rs @@ -654,7 +654,7 @@ impl Decoder { projection .iter() .map(|name| self.schema.column_with_name(name)) - .filter_map(|c| c) + .flatten() .map(|(_, field)| field.clone()) .collect() }; diff --git a/parquet/src/arrow/array_reader.rs b/parquet/src/arrow/array_reader.rs index 943820f57100..d125cf6924bb 100644 --- a/parquet/src/arrow/array_reader.rs +++ b/parquet/src/arrow/array_reader.rs @@ -1405,11 +1405,9 @@ impl<'a> ArrayReaderBuilder { self.file_reader.clone(), )?); - let arrow_type: Option = match self.get_arrow_field(&cur_type, context) - { - Some(f) => Some(f.data_type().clone()), - _ => None, - }; + let arrow_type: Option = self + .get_arrow_field(&cur_type, context) + .map(|f| f.data_type().clone()); match cur_type.get_physical_type() { PhysicalType::BOOLEAN => Ok(Box::new(PrimitiveArrayReader::::new( diff --git a/parquet/src/arrow/schema.rs b/parquet/src/arrow/schema.rs index b15bb7e41402..6c04b7048b01 100644 --- a/parquet/src/arrow/schema.rs +++ b/parquet/src/arrow/schema.rs @@ -172,7 +172,7 @@ where FieldType::Arrow(f) => Ok(Some(f)), }) .collect::>>>() - .map(|result| result.into_iter().filter_map(|f| f).collect::>()) + .map(|result| result.into_iter().flatten().collect::>()) .map(|fields| Schema::new_with_metadata(fields, metadata)) } @@ -827,9 +827,7 @@ impl ParquetTypeConverter<'_> { .iter() .map(|field_ptr| self.clone_with_schema(field_ptr).to_field()) .collect::>>>() - .map(|result| { - result.into_iter().filter_map(|f| f).collect::>() - }) + .map(|result| result.into_iter().flatten().collect::>()) .map(|fields| { if fields.is_empty() { None diff --git a/parquet/src/schema/parser.rs b/parquet/src/schema/parser.rs index 3ce347c8745b..41f6290f89d9 100644 --- a/parquet/src/schema/parser.rs +++ b/parquet/src/schema/parser.rs @@ -372,15 +372,15 @@ impl<'a> Parser<'a> { )?; assert_token(self.tokenizer.next(), ")")?; logical = Some(LogicalType::DECIMAL(DecimalType { - precision, scale, + precision, })); converted = ConvertedType::from(logical.clone()); } else { scale = 0; logical = Some(LogicalType::DECIMAL(DecimalType { - precision, scale, + precision, })); converted = ConvertedType::from(logical.clone()); } @@ -401,8 +401,8 @@ impl<'a> Parser<'a> { )?; assert_token(self.tokenizer.next(), ")")?; logical = Some(LogicalType::TIME(TimeType { - unit, is_adjusted_to_u_t_c, + unit, })); converted = ConvertedType::from(logical.clone()); } else { @@ -426,8 +426,8 @@ impl<'a> Parser<'a> { )?; assert_token(self.tokenizer.next(), ")")?; logical = Some(LogicalType::TIMESTAMP(TimestampType { - unit, is_adjusted_to_u_t_c, + unit, })); converted = ConvertedType::from(logical.clone()); } else {