From 43cd830ea3d074a021cb91af2cfa96d101f3b040 Mon Sep 17 00:00:00 2001 From: Will Jones Date: Thu, 23 Jan 2025 11:39:50 -0800 Subject: [PATCH] chore: fix clippy lints (#3414) --- rust/lance-arrow/src/lib.rs | 5 +---- rust/lance-file/src/datatypes.rs | 5 +---- rust/lance-file/src/page_table.rs | 2 +- rust/lance-index/src/scalar/inverted/index.rs | 2 +- rust/lance-io/src/object_store.rs | 2 +- rust/lance-table/src/rowids.rs | 5 +---- rust/lance/src/dataset/cleanup.rs | 2 +- rust/lance/src/dataset/scanner.rs | 4 ++-- rust/lance/src/index/vector/pq.rs | 4 ++-- 9 files changed, 11 insertions(+), 20 deletions(-) diff --git a/rust/lance-arrow/src/lib.rs b/rust/lance-arrow/src/lib.rs index 78c2b224e9..d08992bf3b 100644 --- a/rust/lance-arrow/src/lib.rs +++ b/rust/lance-arrow/src/lib.rs @@ -930,10 +930,7 @@ mod tests { DataType::Struct(fields.clone()), false, )]); - let children = types - .iter() - .map(|ty| new_empty_array(ty)) - .collect::>(); + let children = types.iter().map(new_empty_array).collect::>(); let batch = RecordBatch::try_new( Arc::new(schema.clone()), vec![Arc::new(StructArray::new(fields, children, None)) as ArrayRef], diff --git a/rust/lance-file/src/datatypes.rs b/rust/lance-file/src/datatypes.rs index 6560c73f7c..0b32faf9bb 100644 --- a/rust/lance-file/src/datatypes.rs +++ b/rust/lance-file/src/datatypes.rs @@ -250,10 +250,7 @@ async fn load_field_dictionary<'a>(field: &mut Field, reader: &dyn Reader) -> Re /// Load dictionary value array from manifest files. // TODO: pub(crate) -pub async fn populate_schema_dictionary<'a>( - schema: &mut Schema, - reader: &dyn Reader, -) -> Result<()> { +pub async fn populate_schema_dictionary(schema: &mut Schema, reader: &dyn Reader) -> Result<()> { for field in schema.fields.as_mut_slice() { load_field_dictionary(field, reader).await?; } diff --git a/rust/lance-file/src/page_table.rs b/rust/lance-file/src/page_table.rs index 43ea263168..e49d87546c 100644 --- a/rust/lance-file/src/page_table.rs +++ b/rust/lance-file/src/page_table.rs @@ -51,7 +51,7 @@ impl PageTable { /// Non-existent pages will be represented as (0, 0) in the page table. Pages /// can be non-existent because they are not present in the file, or because /// they are struct fields which have no data pages. - pub async fn load<'a>( + pub async fn load( reader: &dyn Reader, position: usize, min_field_id: i32, diff --git a/rust/lance-index/src/scalar/inverted/index.rs b/rust/lance-index/src/scalar/inverted/index.rs index 4be5634332..1219960e59 100644 --- a/rust/lance-index/src/scalar/inverted/index.rs +++ b/rust/lance-index/src/scalar/inverted/index.rs @@ -1105,7 +1105,7 @@ pub fn flat_bm25_search_stream( let score_col = scored_batch[SCORE_COL].as_primitive::(); let mask = score_col .iter() - .map(|score| score.map_or(false, |score| score > 0.0)) + .map(|score| score.is_some_and(|score| score > 0.0)) .collect::>(); let mask = BooleanArray::from(mask); let batch = arrow::compute::filter_record_batch(&scored_batch, &mask)?; diff --git a/rust/lance-io/src/object_store.rs b/rust/lance-io/src/object_store.rs index 88e2b8ac1d..589dee10ba 100644 --- a/rust/lance-io/src/object_store.rs +++ b/rust/lance-io/src/object_store.rs @@ -1230,7 +1230,7 @@ mod tests { #[case] uri: &str, #[case] storage_options: Option>, ) { - test_block_size_used_test_helper(&uri, storage_options, 64 * 1024).await; + test_block_size_used_test_helper(uri, storage_options, 64 * 1024).await; } #[rstest] diff --git a/rust/lance-table/src/rowids.rs b/rust/lance-table/src/rowids.rs index 1375f0526f..0486df0e19 100644 --- a/rust/lance-table/src/rowids.rs +++ b/rust/lance-table/src/rowids.rs @@ -204,10 +204,7 @@ impl RowIdSequence { // If we've cycled through all segments, we know the row id is not in the sequence. while i < self.0.len() { let (segment_idx, segment) = segment_iter.next().unwrap(); - if segment - .range() - .map_or(false, |range| range.contains(&row_id)) - { + if segment.range().is_some_and(|range| range.contains(&row_id)) { if let Some(offset) = segment.position(row_id) { segment_matches.get_mut(segment_idx).unwrap().push(offset); } diff --git a/rust/lance/src/dataset/cleanup.rs b/rust/lance/src/dataset/cleanup.rs index 16dd432c86..78565ddd93 100644 --- a/rust/lance/src/dataset/cleanup.rs +++ b/rust/lance/src/dataset/cleanup.rs @@ -556,7 +556,7 @@ mod tests { pub clock: MockClock<'a>, } - impl<'a> MockDatasetFixture<'a> { + impl MockDatasetFixture<'_> { fn try_new() -> Result { let tmpdir = tempdir()?; // let tmpdir_uri = to_obj_store_uri(tmpdir.path())?; diff --git a/rust/lance/src/dataset/scanner.rs b/rust/lance/src/dataset/scanner.rs index 265c9a2220..93cdf3ae34 100644 --- a/rust/lance/src/dataset/scanner.rs +++ b/rust/lance/src/dataset/scanner.rs @@ -1119,9 +1119,9 @@ impl Scanner { let byte_width = field.data_type().byte_width_opt(); let is_cloud = self.dataset.object_store().is_cloud(); if is_cloud { - byte_width.map_or(false, |bw| bw < 1000) + byte_width.is_some_and(|bw| bw < 1000) } else { - byte_width.map_or(false, |bw| bw < 10) + byte_width.is_some_and(|bw| bw < 10) } } } diff --git a/rust/lance/src/index/vector/pq.rs b/rust/lance/src/index/vector/pq.rs index 731c1be94e..3fd7658759 100644 --- a/rust/lance/src/index/vector/pq.rs +++ b/rust/lance/src/index/vector/pq.rs @@ -242,10 +242,10 @@ impl VectorIndex for PQIndex { for idx in indices.values().iter() { let dist = distances.value(*idx as usize); let id = row_ids.value(*idx as usize); - if query.lower_bound.map_or(false, |lb| dist < lb) { + if query.lower_bound.is_some_and(|lb| dist < lb) { continue; } - if query.upper_bound.map_or(false, |ub| dist >= ub) { + if query.upper_bound.is_some_and(|ub| dist >= ub) { break; }