From dca25982430497675de0c156eb14e96f95120169 Mon Sep 17 00:00:00 2001 From: Liang-Chi Hsieh Date: Wed, 12 Oct 2022 01:00:32 -0700 Subject: [PATCH] Fix some clippy errors --- arrow-array/src/array/primitive_array.rs | 2 +- arrow-buffer/src/buffer/mutable.rs | 2 +- arrow-flight/src/lib.rs | 3 +++ arrow/src/csv/writer.rs | 1 + arrow/src/lib.rs | 2 +- arrow/src/pyarrow.rs | 2 +- arrow/src/util/test_util.rs | 4 ++-- integration-testing/src/util/mod.rs | 2 +- parquet/src/arrow/arrow_writer/levels.rs | 2 +- parquet/src/encodings/rle.rs | 14 +++++++------- parquet/src/format.rs | 4 ++-- parquet_derive/src/parquet_field.rs | 12 ++++++------ 12 files changed, 27 insertions(+), 23 deletions(-) diff --git a/arrow-array/src/array/primitive_array.rs b/arrow-array/src/array/primitive_array.rs index e362f0d7e84..928135463cc 100644 --- a/arrow-array/src/array/primitive_array.rs +++ b/arrow-array/src/array/primitive_array.rs @@ -786,7 +786,7 @@ impl PrimitiveArray { } impl PrimitiveArray { - /// Construct a timestamp array from a vec of Option values and an optional timezone + /// Construct a timestamp array from a vec of `Option` values and an optional timezone pub fn from_opt_vec(data: Vec>, timezone: Option) -> Self { // TODO: duplicated from def_numeric_from_vec! macro, it looks possible to convert to generic let data_len = data.len(); diff --git a/arrow-buffer/src/buffer/mutable.rs b/arrow-buffer/src/buffer/mutable.rs index 80644b63d11..bd139466ae9 100644 --- a/arrow-buffer/src/buffer/mutable.rs +++ b/arrow-buffer/src/buffer/mutable.rs @@ -365,7 +365,7 @@ impl MutableBuffer { /// Extends the buffer with a new item, without checking for sufficient capacity /// # Safety - /// Caller must ensure that the capacity()-len()>=size_of() + /// Caller must ensure that the capacity()-len()>=`size_of`() #[inline] pub unsafe fn push_unchecked(&mut self, item: T) { let additional = std::mem::size_of::(); diff --git a/arrow-flight/src/lib.rs b/arrow-flight/src/lib.rs index 54f4d24b65a..05498170708 100644 --- a/arrow-flight/src/lib.rs +++ b/arrow-flight/src/lib.rs @@ -15,6 +15,8 @@ // specific language governing permissions and limitations // under the License. +#![allow(rustdoc::invalid_html_tags)] + use arrow::datatypes::Schema; use arrow::error::{ArrowError, Result as ArrowResult}; use arrow::ipc::{convert, writer, writer::EncodedData, writer::IpcWriteOptions}; @@ -27,6 +29,7 @@ use std::{ }; #[allow(clippy::derive_partial_eq_without_eq)] + mod gen { include!("arrow.flight.protocol.rs"); } diff --git a/arrow/src/csv/writer.rs b/arrow/src/csv/writer.rs index 1b377c38b37..eb7a8fd5be8 100644 --- a/arrow/src/csv/writer.rs +++ b/arrow/src/csv/writer.rs @@ -103,6 +103,7 @@ pub struct Writer { /// The datetime format for datetime arrays datetime_format: String, /// The timestamp format for timestamp arrays + #[allow(dead_code)] timestamp_format: String, /// The timestamp format for timestamp (with timezone) arrays #[allow(dead_code)] diff --git a/arrow/src/lib.rs b/arrow/src/lib.rs index 8967efce50b..324803cb1a9 100644 --- a/arrow/src/lib.rs +++ b/arrow/src/lib.rs @@ -248,7 +248,7 @@ #![deny(clippy::redundant_clone)] #![warn(missing_debug_implementations)] - +#![allow(rustdoc::invalid_html_tags)] pub use arrow_array::{downcast_dictionary_array, downcast_primitive_array}; pub use arrow_buffer::{alloc, buffer}; diff --git a/arrow/src/pyarrow.rs b/arrow/src/pyarrow.rs index d8d5eee532e..7c365a4344a 100644 --- a/arrow/src/pyarrow.rs +++ b/arrow/src/pyarrow.rs @@ -219,7 +219,7 @@ impl PyArrowConvert for ArrowArrayStreamReader { unsafe { ArrowArrayStreamReader::from_raw(stream_ptr).unwrap() }; unsafe { - Box::from_raw(stream_ptr); + drop(Box::from_raw(stream_ptr)); } Ok(stream_reader) diff --git a/arrow/src/util/test_util.rs b/arrow/src/util/test_util.rs index cae148a53d5..836bda6f98c 100644 --- a/arrow/src/util/test_util.rs +++ b/arrow/src/util/test_util.rs @@ -167,8 +167,8 @@ pub struct BadIterator { } impl BadIterator { - /// Create a new iterator for items, but that reports to - /// produce items. Must provide at least 1 item. + /// Create a new iterator for `` items, but that reports to + /// produce `` items. Must provide at least 1 item. pub fn new(limit: usize, claimed: usize, items: Vec) -> Self { assert!(!items.is_empty()); Self { diff --git a/integration-testing/src/util/mod.rs b/integration-testing/src/util/mod.rs index f9ddc0e6f4b..c0eb80a3571 100644 --- a/integration-testing/src/util/mod.rs +++ b/integration-testing/src/util/mod.rs @@ -978,7 +978,7 @@ pub fn dictionary_array_from_json( } } -/// A helper to create a null buffer from a Vec +/// A helper to create a null buffer from a `Vec` fn create_null_buf(json_col: &ArrowJsonColumn) -> Buffer { let num_bytes = bit_util::ceil(json_col.count, 8); let mut null_buf = MutableBuffer::new(num_bytes).with_bitset(num_bytes, false); diff --git a/parquet/src/arrow/arrow_writer/levels.rs b/parquet/src/arrow/arrow_writer/levels.rs index f5e26a7281b..5736f05fdcf 100644 --- a/parquet/src/arrow/arrow_writer/levels.rs +++ b/parquet/src/arrow/arrow_writer/levels.rs @@ -213,7 +213,7 @@ impl LevelInfoBuilder { /// Write `range` elements from ListArray `array` /// - /// Note: MapArrays are ListArray under the hood and so are dispatched to this method + /// Note: MapArrays are `ListArray` under the hood and so are dispatched to this method fn write_list( &mut self, offsets: &[O], diff --git a/parquet/src/encodings/rle.rs b/parquet/src/encodings/rle.rs index 39a0aa4d03d..93dd4ab565c 100644 --- a/parquet/src/encodings/rle.rs +++ b/parquet/src/encodings/rle.rs @@ -27,17 +27,17 @@ use crate::util::{ /// The grammar for this encoding looks like the following (copied verbatim /// from ): /// -/// rle-bit-packed-hybrid: -/// length := length of the in bytes stored as 4 bytes little endian -/// encoded-data := * -/// run := | -/// bit-packed-run := -/// bit-packed-header := varint-encode( << 1 | 1) +/// rle-bit-packed-hybrid: `` `` +/// length := length of the `` in bytes stored as 4 bytes little endian +/// encoded-data := ``* +/// run := `` | `` +/// bit-packed-run := `` `` +/// bit-packed-header := varint-encode(`` << 1 | 1) /// we always bit-pack a multiple of 8 values at a time, so we only store the number of /// values / 8 /// bit-pack-count := (number of values in this run) / 8 /// bit-packed-values := *see 1 below* -/// rle-run := +/// rle-run := `` `` /// rle-header := varint-encode( (number of times repeated) << 1) /// repeated-value := value that is repeated, using a fixed-width of /// round-up-to-next-byte(bit-width) diff --git a/parquet/src/format.rs b/parquet/src/format.rs index 00a89a4c7e8..6fb2e32ebcf 100644 --- a/parquet/src/format.rs +++ b/parquet/src/format.rs @@ -4452,7 +4452,7 @@ impl OffsetIndex { // /// Description for ColumnIndex. -/// Each \[i\] refers to the page at OffsetIndex.page_locations\[i\] +/// Each ``\[i\] refers to the page at OffsetIndex.page_locations\[i\] #[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] pub struct ColumnIndex { /// A list of Boolean values to determine the validity of the corresponding @@ -4905,7 +4905,7 @@ pub struct FileMetaData { /// Optional key/value metadata * pub key_value_metadata: Option>, /// String for application that wrote this file. This should be in the format - /// version (build ). + /// `` version `` (build ``). /// e.g. impala version 1.0 (build 6cf94d29b2b7115df4de2c06e2ab4326d721eb55) /// pub created_by: Option, diff --git a/parquet_derive/src/parquet_field.rs b/parquet_derive/src/parquet_field.rs index 0642e23327f..82e3b5112fe 100644 --- a/parquet_derive/src/parquet_field.rs +++ b/parquet_derive/src/parquet_field.rs @@ -68,7 +68,7 @@ impl Field { /// /// struct Record { /// a_bool: bool, - /// maybe_a_bool: Option + /// maybe_a_bool: `Option` /// } /// /// but not @@ -355,9 +355,9 @@ impl Type { /// Helper to simplify a nested field definition to its leaf type /// /// Ex: - /// Option<&String> => Type::TypePath(String) - /// &Option => Type::TypePath(i32) - /// Vec> => Type::Vec(u8) + /// `Option<&String>` => Type::TypePath(String) + /// `&Option` => Type::TypePath(i32) + /// `Vec>` => Type::Vec(u8) /// /// Useful in determining the physical type of a field and the /// definition levels. @@ -404,7 +404,7 @@ impl Type { /// /// Ex: /// std::string::String => String - /// Vec => Vec + /// `Vec` => `Vec` /// chrono::NaiveDateTime => NaiveDateTime /// /// Does run the risk of mis-identifying a type if import @@ -427,7 +427,7 @@ impl Type { /// /// Ex: /// [u8; 10] => FIXED_LEN_BYTE_ARRAY - /// Vec => BYTE_ARRAY + /// `Vec` => BYTE_ARRAY /// String => BYTE_ARRAY /// i32 => INT32 fn physical_type(&self) -> parquet::basic::Type {