diff --git a/arrow-array/src/ffi.rs b/arrow-array/src/ffi.rs index 2ee2fd379ed8..83eaa3d6544a 100644 --- a/arrow-array/src/ffi.rs +++ b/arrow-array/src/ffi.rs @@ -525,7 +525,7 @@ impl ImportedArrowArray<'_> { unsafe { create_buffer(self.owner.clone(), self.array, 0, buffer_len) } } - fn dictionary(&self) -> Result> { + fn dictionary(&self) -> Result>> { match (self.array.dictionary(), &self.data_type) { (Some(array), DataType::Dictionary(_, value_type)) => Ok(Some(ImportedArrowArray { array, diff --git a/arrow-buffer/src/buffer/boolean.rs b/arrow-buffer/src/buffer/boolean.rs index 42d5ef22a254..8456f184a74f 100644 --- a/arrow-buffer/src/buffer/boolean.rs +++ b/arrow-buffer/src/buffer/boolean.rs @@ -104,7 +104,7 @@ impl BooleanBuffer { /// Returns a `BitChunks` instance which can be used to iterate over /// this buffer's bits in `u64` chunks #[inline] - pub fn bit_chunks(&self) -> BitChunks { + pub fn bit_chunks(&self) -> BitChunks<'_> { BitChunks::new(self.values(), self.offset, self.len) } diff --git a/arrow-buffer/src/buffer/immutable.rs b/arrow-buffer/src/buffer/immutable.rs index 2b55bf6604e6..57f30edf1eb8 100644 --- a/arrow-buffer/src/buffer/immutable.rs +++ b/arrow-buffer/src/buffer/immutable.rs @@ -350,7 +350,7 @@ impl Buffer { /// Returns a `BitChunks` instance which can be used to iterate over this buffers bits /// in larger chunks and starting at arbitrary bit offsets. /// Note that both `offset` and `length` are measured in bits. - pub fn bit_chunks(&self, offset: usize, len: usize) -> BitChunks { + pub fn bit_chunks(&self, offset: usize, len: usize) -> BitChunks<'_> { BitChunks::new(self.as_slice(), offset, len) } diff --git a/arrow-cast/src/pretty.rs b/arrow-cast/src/pretty.rs index c3fc00e4b911..eee1bd959198 100644 --- a/arrow-cast/src/pretty.rs +++ b/arrow-cast/src/pretty.rs @@ -1240,9 +1240,10 @@ mod tests { // Pretty formatting let opts = FormatOptions::default().with_null("null"); let opts = opts.with_duration_format(DurationFormat::Pretty); - let pretty = pretty_format_columns_with_options("pretty", &[array.clone()], &opts) - .unwrap() - .to_string(); + let pretty = + pretty_format_columns_with_options("pretty", std::slice::from_ref(&array), &opts) + .unwrap() + .to_string(); // Expected output let expected_pretty = vec![ diff --git a/arrow-data/src/transform/boolean.rs b/arrow-data/src/transform/boolean.rs index d93fa15a4e0f..b99fd91ed403 100644 --- a/arrow-data/src/transform/boolean.rs +++ b/arrow-data/src/transform/boolean.rs @@ -19,7 +19,7 @@ use super::{Extend, _MutableArrayData, utils::resize_for_bits}; use crate::bit_mask::set_bits; use crate::ArrayData; -pub(super) fn build_extend(array: &ArrayData) -> Extend { +pub(super) fn build_extend(array: &ArrayData) -> Extend<'_> { let values = array.buffers()[0].as_slice(); Box::new( move |mutable: &mut _MutableArrayData, _, start: usize, len: usize| { diff --git a/arrow-data/src/transform/fixed_binary.rs b/arrow-data/src/transform/fixed_binary.rs index 44c6f46ebf7e..83aea16fdf87 100644 --- a/arrow-data/src/transform/fixed_binary.rs +++ b/arrow-data/src/transform/fixed_binary.rs @@ -19,7 +19,7 @@ use super::{Extend, _MutableArrayData}; use crate::ArrayData; use arrow_schema::DataType; -pub(super) fn build_extend(array: &ArrayData) -> Extend { +pub(super) fn build_extend(array: &ArrayData) -> Extend<'_> { let size = match array.data_type() { DataType::FixedSizeBinary(i) => *i as usize, _ => unreachable!(), diff --git a/arrow-data/src/transform/fixed_size_list.rs b/arrow-data/src/transform/fixed_size_list.rs index 8eef7bce9bb3..44d7eb5ff8b0 100644 --- a/arrow-data/src/transform/fixed_size_list.rs +++ b/arrow-data/src/transform/fixed_size_list.rs @@ -20,7 +20,7 @@ use arrow_schema::DataType; use super::{Extend, _MutableArrayData}; -pub(super) fn build_extend(array: &ArrayData) -> Extend { +pub(super) fn build_extend(array: &ArrayData) -> Extend<'_> { let size = match array.data_type() { DataType::FixedSizeList(_, i) => *i as usize, _ => unreachable!(), diff --git a/arrow-data/src/transform/list.rs b/arrow-data/src/transform/list.rs index d9a1c62a8e8e..2a3cb1c207da 100644 --- a/arrow-data/src/transform/list.rs +++ b/arrow-data/src/transform/list.rs @@ -23,7 +23,9 @@ use crate::ArrayData; use arrow_buffer::ArrowNativeType; use num::{CheckedAdd, Integer}; -pub(super) fn build_extend(array: &ArrayData) -> Extend { +pub(super) fn build_extend( + array: &ArrayData, +) -> Extend<'_> { let offsets = array.buffer::(0); Box::new( move |mutable: &mut _MutableArrayData, index: usize, start: usize, len: usize| { diff --git a/arrow-data/src/transform/mod.rs b/arrow-data/src/transform/mod.rs index 5071bf8c4113..d23e458accae 100644 --- a/arrow-data/src/transform/mod.rs +++ b/arrow-data/src/transform/mod.rs @@ -73,7 +73,7 @@ impl _MutableArrayData<'_> { } } -fn build_extend_null_bits(array: &ArrayData, use_nulls: bool) -> ExtendNullBits { +fn build_extend_null_bits(array: &ArrayData, use_nulls: bool) -> ExtendNullBits<'_> { if let Some(nulls) = array.nulls() { let bytes = nulls.validity(); Box::new(move |mutable, start, len| { @@ -190,7 +190,7 @@ impl std::fmt::Debug for MutableArrayData<'_> { /// Builds an extend that adds `offset` to the source primitive /// Additionally validates that `max` fits into the /// the underlying primitive returning None if not -fn build_extend_dictionary(array: &ArrayData, offset: usize, max: usize) -> Option { +fn build_extend_dictionary(array: &ArrayData, offset: usize, max: usize) -> Option> { macro_rules! validate_and_build { ($dt: ty) => {{ let _: $dt = max.try_into().ok()?; @@ -215,7 +215,7 @@ fn build_extend_dictionary(array: &ArrayData, offset: usize, max: usize) -> Opti } /// Builds an extend that adds `buffer_offset` to any buffer indices encountered -fn build_extend_view(array: &ArrayData, buffer_offset: u32) -> Extend { +fn build_extend_view(array: &ArrayData, buffer_offset: u32) -> Extend<'_> { let views = array.buffer::(0); Box::new( move |mutable: &mut _MutableArrayData, _, start: usize, len: usize| { @@ -234,7 +234,7 @@ fn build_extend_view(array: &ArrayData, buffer_offset: u32) -> Extend { ) } -fn build_extend(array: &ArrayData) -> Extend { +fn build_extend(array: &ArrayData) -> Extend<'_> { match array.data_type() { DataType::Null => null::build_extend(array), DataType::Boolean => boolean::build_extend(array), diff --git a/arrow-data/src/transform/null.rs b/arrow-data/src/transform/null.rs index 5d1535564d9e..242c930b3af1 100644 --- a/arrow-data/src/transform/null.rs +++ b/arrow-data/src/transform/null.rs @@ -18,7 +18,7 @@ use super::{Extend, _MutableArrayData}; use crate::ArrayData; -pub(super) fn build_extend(_: &ArrayData) -> Extend { +pub(super) fn build_extend(_: &ArrayData) -> Extend<'_> { Box::new(move |_, _, _, _| {}) } diff --git a/arrow-data/src/transform/primitive.rs b/arrow-data/src/transform/primitive.rs index 627dc00de1df..43b8ee269dca 100644 --- a/arrow-data/src/transform/primitive.rs +++ b/arrow-data/src/transform/primitive.rs @@ -22,7 +22,7 @@ use std::ops::Add; use super::{Extend, _MutableArrayData}; -pub(super) fn build_extend(array: &ArrayData) -> Extend { +pub(super) fn build_extend(array: &ArrayData) -> Extend<'_> { let values = array.buffer::(0); Box::new( move |mutable: &mut _MutableArrayData, _, start: usize, len: usize| { @@ -33,7 +33,7 @@ pub(super) fn build_extend(array: &ArrayData) -> Extend { ) } -pub(super) fn build_extend_with_offset(array: &ArrayData, offset: T) -> Extend +pub(super) fn build_extend_with_offset(array: &ArrayData, offset: T) -> Extend<'_> where T: ArrowNativeType + Add, { diff --git a/arrow-data/src/transform/run.rs b/arrow-data/src/transform/run.rs index 1ab6d0d31936..f962a5009845 100644 --- a/arrow-data/src/transform/run.rs +++ b/arrow-data/src/transform/run.rs @@ -181,7 +181,7 @@ fn process_extends_batch( /// Returns a function that extends the run encoded array. /// /// It finds the physical indices in the source array that correspond to the logical range to copy, and adjusts the runs to the logical indices of the array to extend. The values are copied from the source array to the destination array verbatim. -pub fn build_extend(array: &ArrayData) -> Extend { +pub fn build_extend(array: &ArrayData) -> Extend<'_> { Box::new( move |mutable: &mut _MutableArrayData, array_idx: usize, start: usize, len: usize| { if len == 0 { diff --git a/arrow-data/src/transform/structure.rs b/arrow-data/src/transform/structure.rs index 7330dcaa3705..8c20bd44da8d 100644 --- a/arrow-data/src/transform/structure.rs +++ b/arrow-data/src/transform/structure.rs @@ -18,7 +18,7 @@ use super::{Extend, _MutableArrayData}; use crate::ArrayData; -pub(super) fn build_extend(_: &ArrayData) -> Extend { +pub(super) fn build_extend(_: &ArrayData) -> Extend<'_> { Box::new( move |mutable: &mut _MutableArrayData, index: usize, start: usize, len: usize| { mutable diff --git a/arrow-data/src/transform/union.rs b/arrow-data/src/transform/union.rs index d7083588d782..a920a41e814c 100644 --- a/arrow-data/src/transform/union.rs +++ b/arrow-data/src/transform/union.rs @@ -18,7 +18,7 @@ use super::{Extend, _MutableArrayData}; use crate::ArrayData; -pub(super) fn build_extend_sparse(array: &ArrayData) -> Extend { +pub(super) fn build_extend_sparse(array: &ArrayData) -> Extend<'_> { let type_ids = array.buffer::(0); Box::new( @@ -36,7 +36,7 @@ pub(super) fn build_extend_sparse(array: &ArrayData) -> Extend { ) } -pub(super) fn build_extend_dense(array: &ArrayData) -> Extend { +pub(super) fn build_extend_dense(array: &ArrayData) -> Extend<'_> { let type_ids = array.buffer::(0); let offsets = array.buffer::(1); let arrow_schema::DataType::Union(src_fields, _) = array.data_type() else { diff --git a/arrow-data/src/transform/variable_size.rs b/arrow-data/src/transform/variable_size.rs index ec0174bf8cb2..083ee7c74dbf 100644 --- a/arrow-data/src/transform/variable_size.rs +++ b/arrow-data/src/transform/variable_size.rs @@ -41,7 +41,7 @@ fn extend_offset_values>( pub(super) fn build_extend>( array: &ArrayData, -) -> Extend { +) -> Extend<'_> { let offsets = array.buffer::(0); let values = array.buffers()[1].as_slice(); Box::new( diff --git a/arrow-flight/src/sql/metadata/sql_info.rs b/arrow-flight/src/sql/metadata/sql_info.rs index 58b228530942..b8c7035e3ad5 100644 --- a/arrow-flight/src/sql/metadata/sql_info.rs +++ b/arrow-flight/src/sql/metadata/sql_info.rs @@ -444,7 +444,7 @@ pub struct GetSqlInfoBuilder<'a> { impl CommandGetSqlInfo { /// Create a builder suitable for constructing a response - pub fn into_builder(self, infos: &SqlInfoData) -> GetSqlInfoBuilder { + pub fn into_builder(self, infos: &SqlInfoData) -> GetSqlInfoBuilder<'_> { GetSqlInfoBuilder { info: self.info, infos, diff --git a/arrow-flight/src/sql/metadata/xdbc_info.rs b/arrow-flight/src/sql/metadata/xdbc_info.rs index a3a18ca10888..62e2de9e5d97 100644 --- a/arrow-flight/src/sql/metadata/xdbc_info.rs +++ b/arrow-flight/src/sql/metadata/xdbc_info.rs @@ -299,7 +299,7 @@ pub struct GetXdbcTypeInfoBuilder<'a> { impl CommandGetXdbcTypeInfo { /// Create a builder suitable for constructing a response - pub fn into_builder(self, infos: &XdbcTypeInfoData) -> GetXdbcTypeInfoBuilder { + pub fn into_builder(self, infos: &XdbcTypeInfoData) -> GetXdbcTypeInfoBuilder<'_> { GetXdbcTypeInfoBuilder { data_type: self.data_type, infos, diff --git a/arrow-ipc/src/lib.rs b/arrow-ipc/src/lib.rs index aa10031933c6..bbc82e79cd95 100644 --- a/arrow-ipc/src/lib.rs +++ b/arrow-ipc/src/lib.rs @@ -56,6 +56,7 @@ mod compression; #[allow(clippy::redundant_static_lifetimes)] #[allow(clippy::redundant_field_names)] #[allow(non_camel_case_types)] +#[allow(mismatched_lifetime_syntaxes)] #[allow(missing_docs)] // Because this is autogenerated pub mod gen; diff --git a/arrow-ipc/src/reader.rs b/arrow-ipc/src/reader.rs index de200a206d4e..7bef71f32dce 100644 --- a/arrow-ipc/src/reader.rs +++ b/arrow-ipc/src/reader.rs @@ -742,7 +742,7 @@ fn read_block(mut reader: R, block: &Block) -> Result -fn parse_message(buf: &[u8]) -> Result { +fn parse_message(buf: &[u8]) -> Result, ArrowError> { let buf = match buf[..4] == CONTINUATION_MARKER { true => &buf[8..], false => &buf[4..], diff --git a/arrow-row/src/lib.rs b/arrow-row/src/lib.rs index cfb2462e738b..9508249324ee 100644 --- a/arrow-row/src/lib.rs +++ b/arrow-row/src/lib.rs @@ -561,7 +561,7 @@ impl Codec { }, _ => unreachable!(), }; - let rows = converter.convert_columns(&[values.clone()])?; + let rows = converter.convert_columns(std::slice::from_ref(values))?; Ok(Encoder::RunEndEncoded(rows)) } } @@ -3141,7 +3141,9 @@ mod tests { for array in arrays.iter() { rows.clear(); - converter.append(&mut rows, &[array.clone()]).unwrap(); + converter + .append(&mut rows, std::slice::from_ref(array)) + .unwrap(); let back = converter.convert_rows(&rows).unwrap(); assert_eq!(&back[0], array); } @@ -3179,7 +3181,9 @@ mod tests { rows.clear(); let array = Arc::new(dict_array) as ArrayRef; - converter.append(&mut rows, &[array.clone()]).unwrap(); + converter + .append(&mut rows, std::slice::from_ref(&array)) + .unwrap(); let back = converter.convert_rows(&rows).unwrap(); dictionary_eq(&back[0], &array); diff --git a/arrow/examples/dynamic_types.rs b/arrow/examples/dynamic_types.rs index b866cb7e6b1a..df5fe5ae654e 100644 --- a/arrow/examples/dynamic_types.rs +++ b/arrow/examples/dynamic_types.rs @@ -63,7 +63,7 @@ fn main() -> Result<()> { // build a record batch let batch = RecordBatch::try_new(Arc::new(schema), vec![Arc::new(id), Arc::new(nested)])?; - print_batches(&[batch.clone()]).unwrap(); + print_batches(std::slice::from_ref(&batch)).unwrap(); process(&batch); Ok(()) diff --git a/parquet-variant-compute/src/variant_array.rs b/parquet-variant-compute/src/variant_array.rs index 843352d1ff01..a60f7ad0ceab 100644 --- a/parquet-variant-compute/src/variant_array.rs +++ b/parquet-variant-compute/src/variant_array.rs @@ -141,7 +141,7 @@ impl VariantArray { /// /// Note: Does not do deep validation of the [`Variant`], so it is up to the /// caller to ensure that the metadata and value were constructed correctly. - pub fn value(&self, index: usize) -> Variant { + pub fn value(&self, index: usize) -> Variant<'_, '_> { let metadata = self.metadata_field().as_binary_view().value(index); let value = self.value_field().as_binary_view().value(index); Variant::new(metadata, value) diff --git a/parquet-variant-compute/src/variant_array_builder.rs b/parquet-variant-compute/src/variant_array_builder.rs index 6a8dba06f15d..7bd189ed4397 100644 --- a/parquet-variant-compute/src/variant_array_builder.rs +++ b/parquet-variant-compute/src/variant_array_builder.rs @@ -185,7 +185,7 @@ impl VariantArrayBuilder { /// assert_eq!(variant_array.value(0), Variant::from("Hello, World!")); /// assert!(variant_array.value(1).as_object().is_some()); /// ``` - pub fn variant_builder(&mut self) -> VariantArrayVariantBuilder { + pub fn variant_builder(&mut self) -> VariantArrayVariantBuilder<'_> { // append directly into the metadata and value buffers let metadata_buffer = std::mem::take(&mut self.metadata_buffer); let value_buffer = std::mem::take(&mut self.value_buffer); @@ -222,11 +222,11 @@ impl<'a> VariantBuilderExt for VariantArrayVariantBuilder<'a> { self.variant_builder.append_value(value); } - fn new_list(&mut self) -> ListBuilder { + fn new_list(&mut self) -> ListBuilder<'_> { self.variant_builder.new_list() } - fn new_object(&mut self) -> ObjectBuilder { + fn new_object(&mut self) -> ObjectBuilder<'_> { self.variant_builder.new_object() } } diff --git a/parquet-variant-json/src/from_json.rs b/parquet-variant-json/src/from_json.rs index 67b69186068d..134bafe953a4 100644 --- a/parquet-variant-json/src/from_json.rs +++ b/parquet-variant-json/src/from_json.rs @@ -145,11 +145,11 @@ impl VariantBuilderExt for ObjectFieldBuilder<'_, '_, '_> { self.builder.insert(self.key, value); } - fn new_list(&mut self) -> ListBuilder { + fn new_list(&mut self) -> ListBuilder<'_> { self.builder.new_list(self.key) } - fn new_object(&mut self) -> ObjectBuilder { + fn new_object(&mut self) -> ObjectBuilder<'_> { self.builder.new_object(self.key) } } diff --git a/parquet-variant/src/builder.rs b/parquet-variant/src/builder.rs index 6d0fb1a0d03c..b1607f8f306d 100644 --- a/parquet-variant/src/builder.rs +++ b/parquet-variant/src/builder.rs @@ -1036,7 +1036,7 @@ impl VariantBuilder { } // Returns validate_unique_fields because we can no longer reference self once this method returns. - fn parent_state(&mut self) -> (ParentState, bool) { + fn parent_state(&mut self) -> (ParentState<'_>, bool) { let state = ParentState::Variant { buffer: &mut self.buffer, metadata_builder: &mut self.metadata_builder, @@ -1047,7 +1047,7 @@ impl VariantBuilder { /// Create an [`ListBuilder`] for creating [`Variant::List`] values. /// /// See the examples on [`VariantBuilder`] for usage. - pub fn new_list(&mut self) -> ListBuilder { + pub fn new_list(&mut self) -> ListBuilder<'_> { let (parent_state, validate_unique_fields) = self.parent_state(); ListBuilder::new(parent_state, validate_unique_fields) } @@ -1055,7 +1055,7 @@ impl VariantBuilder { /// Create an [`ObjectBuilder`] for creating [`Variant::Object`] values. /// /// See the examples on [`VariantBuilder`] for usage. - pub fn new_object(&mut self) -> ObjectBuilder { + pub fn new_object(&mut self) -> ObjectBuilder<'_> { let (parent_state, validate_unique_fields) = self.parent_state(); ObjectBuilder::new(parent_state, validate_unique_fields) } @@ -1151,7 +1151,7 @@ impl<'a> ListBuilder<'a> { } // Returns validate_unique_fields because we can no longer reference self once this method returns. - fn parent_state(&mut self) -> (ParentState, bool) { + fn parent_state(&mut self) -> (ParentState<'_>, bool) { let (buffer, metadata_builder) = self.parent_state.buffer_and_metadata_builder(); let state = ParentState::List { @@ -1166,7 +1166,7 @@ impl<'a> ListBuilder<'a> { /// Returns an object builder that can be used to append a new (nested) object to this list. /// /// WARNING: The builder will have no effect unless/until [`ObjectBuilder::finish`] is called. - pub fn new_object(&mut self) -> ObjectBuilder { + pub fn new_object(&mut self) -> ObjectBuilder<'_> { let (parent_state, validate_unique_fields) = self.parent_state(); ObjectBuilder::new(parent_state, validate_unique_fields) } @@ -1174,7 +1174,7 @@ impl<'a> ListBuilder<'a> { /// Returns a list builder that can be used to append a new (nested) list to this list. /// /// WARNING: The builder will have no effect unless/until [`ListBuilder::finish`] is called. - pub fn new_list(&mut self) -> ListBuilder { + pub fn new_list(&mut self) -> ListBuilder<'_> { let (parent_state, validate_unique_fields) = self.parent_state(); ListBuilder::new(parent_state, validate_unique_fields) } @@ -1542,9 +1542,9 @@ impl Drop for ObjectBuilder<'_> { pub trait VariantBuilderExt { fn append_value<'m, 'v>(&mut self, value: impl Into>); - fn new_list(&mut self) -> ListBuilder; + fn new_list(&mut self) -> ListBuilder<'_>; - fn new_object(&mut self) -> ObjectBuilder; + fn new_object(&mut self) -> ObjectBuilder<'_>; } impl VariantBuilderExt for ListBuilder<'_> { @@ -1552,11 +1552,11 @@ impl VariantBuilderExt for ListBuilder<'_> { self.append_value(value); } - fn new_list(&mut self) -> ListBuilder { + fn new_list(&mut self) -> ListBuilder<'_> { self.new_list() } - fn new_object(&mut self) -> ObjectBuilder { + fn new_object(&mut self) -> ObjectBuilder<'_> { self.new_object() } } @@ -1566,11 +1566,11 @@ impl VariantBuilderExt for VariantBuilder { self.append_value(value); } - fn new_list(&mut self) -> ListBuilder { + fn new_list(&mut self) -> ListBuilder<'_> { self.new_list() } - fn new_object(&mut self) -> ObjectBuilder { + fn new_object(&mut self) -> ObjectBuilder<'_> { self.new_object() } } diff --git a/parquet-variant/src/decoder.rs b/parquet-variant/src/decoder.rs index 5d6a06479376..21069cdc02fc 100644 --- a/parquet-variant/src/decoder.rs +++ b/parquet-variant/src/decoder.rs @@ -308,7 +308,10 @@ pub(crate) fn decode_long_string(data: &[u8]) -> Result<&str, ArrowError> { } /// Decodes a short string from the value section of a variant. -pub(crate) fn decode_short_string(metadata: u8, data: &[u8]) -> Result { +pub(crate) fn decode_short_string( + metadata: u8, + data: &[u8], +) -> Result, ArrowError> { let len = (metadata >> 2) as usize; let string = string_from_slice(data, 0, 0..len)?; ShortString::try_new(string) diff --git a/parquet-variant/src/path.rs b/parquet-variant/src/path.rs index ddbfc5e469a4..204b322b2640 100644 --- a/parquet-variant/src/path.rs +++ b/parquet-variant/src/path.rs @@ -73,7 +73,7 @@ impl<'a> VariantPath<'a> { } /// Return the inner path elements. - pub fn path(&self) -> &Vec { + pub fn path(&self) -> &Vec> { &self.0 } diff --git a/parquet-variant/src/variant.rs b/parquet-variant/src/variant.rs index 24f453c80a37..82de637b0697 100644 --- a/parquet-variant/src/variant.rs +++ b/parquet-variant/src/variant.rs @@ -1061,7 +1061,7 @@ impl<'m, 'v> Variant<'m, 'v> { /// Return the metadata associated with this variant, if any. /// /// Returns `Some(&VariantMetadata)` for object and list variants, - pub fn metadata(&self) -> Option<&'m VariantMetadata> { + pub fn metadata(&self) -> Option<&'m VariantMetadata<'_>> { match self { Variant::Object(VariantObject { metadata, .. }) | Variant::List(VariantList { metadata, .. }) => Some(metadata), @@ -1101,7 +1101,7 @@ impl<'m, 'v> Variant<'m, 'v> { /// let path = VariantPath::from("foo").join(0); /// assert_eq!(variant.get_path(&path).unwrap(), bar); /// ``` - pub fn get_path(&self, path: &VariantPath) -> Option { + pub fn get_path(&self, path: &VariantPath) -> Option> { path.iter() .try_fold(self.clone(), |output, element| match element { VariantPathElement::Field { name } => output.get_object_field(name), diff --git a/parquet/src/arrow/async_writer/mod.rs b/parquet/src/arrow/async_writer/mod.rs index faec427907a7..3a74aa7c9c20 100644 --- a/parquet/src/arrow/async_writer/mod.rs +++ b/parquet/src/arrow/async_writer/mod.rs @@ -296,7 +296,6 @@ mod tests { use arrow_array::{ArrayRef, BinaryArray, Int32Array, Int64Array, RecordBatchReader}; use bytes::Bytes; use std::sync::Arc; - use tokio::pin; use crate::arrow::arrow_reader::{ParquetRecordBatchReader, ParquetRecordBatchReaderBuilder}; @@ -365,49 +364,6 @@ mod tests { assert_eq!(sync_buffer, async_buffer); } - struct TestAsyncSink { - sink: Vec, - min_accept_bytes: usize, - expect_total_bytes: usize, - } - - impl AsyncWrite for TestAsyncSink { - fn poll_write( - self: std::pin::Pin<&mut Self>, - cx: &mut std::task::Context<'_>, - buf: &[u8], - ) -> std::task::Poll> { - let written_bytes = self.sink.len(); - if written_bytes + buf.len() < self.expect_total_bytes { - assert!(buf.len() >= self.min_accept_bytes); - } else { - assert_eq!(written_bytes + buf.len(), self.expect_total_bytes); - } - - let sink = &mut self.get_mut().sink; - pin!(sink); - sink.poll_write(cx, buf) - } - - fn poll_flush( - self: std::pin::Pin<&mut Self>, - cx: &mut std::task::Context<'_>, - ) -> std::task::Poll> { - let sink = &mut self.get_mut().sink; - pin!(sink); - sink.poll_flush(cx) - } - - fn poll_shutdown( - self: std::pin::Pin<&mut Self>, - cx: &mut std::task::Context<'_>, - ) -> std::task::Poll> { - let sink = &mut self.get_mut().sink; - pin!(sink); - sink.poll_shutdown(cx) - } - } - #[tokio::test] async fn test_async_writer_bytes_written() { let col = Arc::new(Int64Array::from_iter_values([1, 2, 3])) as ArrayRef; diff --git a/parquet/src/encryption/decrypt.rs b/parquet/src/encryption/decrypt.rs index 43b2bb493a1d..d9b9ff0326b4 100644 --- a/parquet/src/encryption/decrypt.rs +++ b/parquet/src/encryption/decrypt.rs @@ -361,7 +361,7 @@ impl FileDecryptionProperties { /// Get the encryption key for decrypting a file's footer, /// and also column data if uniform encryption is used. - pub fn footer_key(&self, key_metadata: Option<&[u8]>) -> Result>> { + pub fn footer_key(&self, key_metadata: Option<&[u8]>) -> Result>> { match &self.keys { DecryptionKeys::Explicit(keys) => Ok(Cow::Borrowed(&keys.footer_key)), DecryptionKeys::ViaRetriever(retriever) => { @@ -376,7 +376,7 @@ impl FileDecryptionProperties { &self, column_name: &str, key_metadata: Option<&[u8]>, - ) -> Result>> { + ) -> Result>> { match &self.keys { DecryptionKeys::Explicit(keys) => match keys.column_keys.get(column_name) { None => Err(general_err!( diff --git a/parquet/src/file/reader.rs b/parquet/src/file/reader.rs index 400441f0c9cd..7e2b149ad3fb 100644 --- a/parquet/src/file/reader.rs +++ b/parquet/src/file/reader.rs @@ -153,7 +153,7 @@ pub trait FileReader: Send + Sync { /// /// Projected schema can be a subset of or equal to the file schema, when it is None, /// full file schema is assumed. - fn get_row_iter(&self, projection: Option) -> Result; + fn get_row_iter(&self, projection: Option) -> Result>; } /// Parquet row group reader API. With this, user can get metadata information about the @@ -211,7 +211,7 @@ pub trait RowGroupReader: Send + Sync { /// /// Projected schema can be a subset of or equal to the file schema, when it is None, /// full file schema is assumed. - fn get_row_iter(&self, projection: Option) -> Result; + fn get_row_iter(&self, projection: Option) -> Result>; } // ---------------------------------------------------------------------- diff --git a/parquet/src/file/serialized_reader.rs b/parquet/src/file/serialized_reader.rs index 2edb38deb3e0..d198a34227fa 100644 --- a/parquet/src/file/serialized_reader.rs +++ b/parquet/src/file/serialized_reader.rs @@ -263,7 +263,7 @@ impl FileReader for SerializedFileReader { )?)) } - fn get_row_iter(&self, projection: Option) -> Result { + fn get_row_iter(&self, projection: Option) -> Result> { RowIter::from_file(projection, self) } } @@ -334,7 +334,7 @@ impl RowGroupReader for SerializedRowGroupReader<'_, R self.bloom_filters[i].as_ref() } - fn get_row_iter(&self, projection: Option) -> Result { + fn get_row_iter(&self, projection: Option) -> Result> { RowIter::from_row_group(projection, self) } } diff --git a/parquet/src/record/api.rs b/parquet/src/record/api.rs index 4ed53ba29d9e..04325576a8bc 100644 --- a/parquet/src/record/api.rs +++ b/parquet/src/record/api.rs @@ -98,7 +98,7 @@ impl Row { /// println!("column index: {}, column name: {}, column value: {}", idx, name, field); /// } /// ``` - pub fn get_column_iter(&self) -> RowColumnIter { + pub fn get_column_iter(&self) -> RowColumnIter<'_> { RowColumnIter { fields: &self.fields, curr: 0, diff --git a/parquet/src/schema/types.rs b/parquet/src/schema/types.rs index 68492e19f437..05df9536bfc5 100644 --- a/parquet/src/schema/types.rs +++ b/parquet/src/schema/types.rs @@ -78,12 +78,15 @@ impl HeapSize for Type { impl Type { /// Creates primitive type builder with provided field name and physical type. - pub fn primitive_type_builder(name: &str, physical_type: PhysicalType) -> PrimitiveTypeBuilder { + pub fn primitive_type_builder( + name: &str, + physical_type: PhysicalType, + ) -> PrimitiveTypeBuilder<'_> { PrimitiveTypeBuilder::new(name, physical_type) } /// Creates group type builder with provided column name. - pub fn group_type_builder(name: &str) -> GroupTypeBuilder { + pub fn group_type_builder(name: &str) -> GroupTypeBuilder<'_> { GroupTypeBuilder::new(name) }