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 lint dead_code #1324

Merged
merged 1 commit into from
Feb 17, 2022
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 arrow/src/array/array_dictionary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ mod tests {
assert!(iter.next().is_none());
}

#[test]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice fix

fn test_try_new() {
let values: StringArray = [Some("foo"), Some("bar"), Some("baz")]
.into_iter()
Expand Down
9 changes: 0 additions & 9 deletions arrow/src/array/array_primitive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ use crate::{
util::trusted_len_unzip,
};

/// Number of seconds in a day
const SECONDS_IN_DAY: i64 = 86_400;
/// Number of milliseconds in a second
const MILLISECONDS: i64 = 1_000;
/// Number of microseconds in a second
const MICROSECONDS: i64 = 1_000_000;
/// Number of nanoseconds in a second
const NANOSECONDS: i64 = 1_000_000_000;

/// Array whose elements are of primitive types.
///
/// # Example: From an iterator of values
Expand Down
1 change: 1 addition & 0 deletions arrow/src/array/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1751,6 +1751,7 @@ impl Default for MapFieldNames {
}
}

#[allow(dead_code)]
impl<K: ArrayBuilder, V: ArrayBuilder> MapBuilder<K, V> {
pub fn new(
field_names: Option<MapFieldNames>,
Expand Down
2 changes: 2 additions & 0 deletions arrow/src/array/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ pub(crate) fn new_buffers(data_type: &DataType, capacity: usize) -> [MutableBuff
///
/// `buffer_index` is used in error messages to identify which buffer
/// had the invalid index
#[allow(dead_code)]
fn ensure_size(
data_type: &DataType,
min_size: usize,
Expand Down Expand Up @@ -1354,6 +1355,7 @@ enum BufferSpec {
BitMap,
/// Buffer is always null. Unused currently in Rust implementation,
/// (used in C++ for Union type)
#[allow(dead_code)]
AlwaysNull,
}

Expand Down
1 change: 1 addition & 0 deletions arrow/src/array/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ fn build_extend_null_bits(array: &ArrayData, use_nulls: bool) -> ExtendNullBits
/// assert_eq!(Int32Array::from(vec![2, 3, 1, 2, 3]), new_array);
/// ```
pub struct MutableArrayData<'a> {
#[allow(dead_code)]
arrays: Vec<&'a ArrayData>,
// The attributes in [_MutableArrayData] cannot be in [MutableArrayData] due to
// mutability invariants (interior mutability):
Expand Down
2 changes: 1 addition & 1 deletion arrow/src/compute/kernels/cast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4281,7 +4281,7 @@ mod tests {
Arc::new(Int32Array::from(vec![42, 28, 19, 31])),
),
])),
//Arc::new(make_union_array()),
Arc::new(make_union_array()),
Arc::new(NullArray::new(10)),
Arc::new(StringArray::from(vec!["foo", "bar"])),
Arc::new(LargeStringArray::from(vec!["foo", "bar"])),
Expand Down
2 changes: 2 additions & 0 deletions arrow/src/compute/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub(super) fn combine_option_bitmap(
///
/// This function is useful when implementing operations on higher level arrays.
#[allow(clippy::unnecessary_wraps)]
#[allow(dead_code)]
pub(super) fn compare_option_bitmap(
left_data: &ArrayData,
right_data: &ArrayData,
Expand Down Expand Up @@ -343,6 +344,7 @@ pub(super) mod tests {
GenericListArray::<S>::from(list_data)
}

#[allow(dead_code)]
pub(crate) fn build_fixed_size_list<T>(
data: Vec<Option<Vec<T::Native>>>,
length: <Int32Type as ArrowPrimitiveType>::Native,
Expand Down
2 changes: 2 additions & 0 deletions arrow/src/csv/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,7 @@ fn parse_decimal_with_parameter(s: &str, precision: usize, scale: usize) -> Resu

// Parse the string format decimal value to i128 format without checking the precision and scale.
// Like "125.12" to 12512_i128.
#[cfg(test)]
fn parse_decimal(s: &str) -> Result<i128> {
if PARSE_DECIMAL_RE.is_match(s) {
let mut offset = s.len();
Expand Down Expand Up @@ -1055,6 +1056,7 @@ pub struct ReaderBuilder {
/// The default batch size when using the `ReaderBuilder` is 1024 records
batch_size: usize,
/// The bounds over which to scan the reader. `None` starts from 0 and runs until EOF.
#[allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a bug?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it looks more like an omission in the builder. Reader::from_csv_reader() correctly processes the bounds parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bounds: Bounds,
/// Optional projection for which columns to load (zero-based column indices)
projection: Option<Vec<usize>>,
Expand Down
2 changes: 2 additions & 0 deletions arrow/src/csv/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub struct Writer<W: Write> {
/// The object to write to
writer: csv_crate::Writer<W>,
/// Column delimiter. Defaults to `b','`
#[allow(dead_code)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems a bug (not to use the delimiter option) . I think we should add a note or fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this time the delimiter is configured via the builder, but gets completely ignored

impl<W: Write> Writer<W> {
    /// Create a new CsvWriter from a writable object, with default options
    pub fn new(writer: W) -> Self {
        let delimiter = b',';
        let mut builder = csv_crate::WriterBuilder::new();
        let writer = builder.delimiter(delimiter).from_writer(writer);
...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delimiter: u8,
/// Whether file should be written with headers. Defaults to `true`
has_headers: bool,
Expand All @@ -107,6 +108,7 @@ pub struct Writer<W: Write> {
/// The timestamp format for timestamp arrays
timestamp_format: String,
/// The timestamp format for timestamp (with timezone) arrays
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi @sum12

#[allow(dead_code)]
timestamp_tz_format: String,
/// The time format for time arrays
time_format: String,
Expand Down
1 change: 1 addition & 0 deletions arrow/src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ unsafe extern "C" fn release_array(array: *mut FFI_ArrowArray) {
}

struct ArrayPrivateData {
#[allow(dead_code)]
buffers: Vec<Option<Buffer>>,
buffers_ptr: Box<[*const c_void]>,
children: Box<[*mut FFI_ArrowArray]>,
Expand Down
3 changes: 0 additions & 3 deletions arrow/src/ipc/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -534,8 +534,6 @@ pub struct StreamWriter<W: Write> {
writer: BufWriter<W>,
/// IPC write options
write_options: IpcWriteOptions,
/// A reference to the schema, used in validating record batches
schema: Schema,
/// Whether the writer footer has been written, and the writer is finished
finished: bool,
/// Keeps track of dictionaries that have been written
Expand Down Expand Up @@ -564,7 +562,6 @@ impl<W: Write> StreamWriter<W> {
Ok(Self {
writer,
write_options,
schema: schema.clone(),
finished: false,
dictionary_tracker: DictionaryTracker::new(false),
data_gen,
Expand Down
1 change: 0 additions & 1 deletion arrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@
#![cfg_attr(feature = "avx512", feature(stdsimd))]
#![cfg_attr(feature = "avx512", feature(repr_simd))]
#![cfg_attr(feature = "avx512", feature(avx512_target_feature))]
#![allow(dead_code)]
#![deny(clippy::redundant_clone)]
#![warn(missing_debug_implementations)]

Expand Down