Skip to content

Commit

Permalink
chore: fix clippy lints (#3414)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjones127 authored Jan 23, 2025
1 parent a3434ca commit 43cd830
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 20 deletions.
5 changes: 1 addition & 4 deletions rust/lance-arrow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -930,10 +930,7 @@ mod tests {
DataType::Struct(fields.clone()),
false,
)]);
let children = types
.iter()
.map(|ty| new_empty_array(ty))
.collect::<Vec<_>>();
let children = types.iter().map(new_empty_array).collect::<Vec<_>>();
let batch = RecordBatch::try_new(
Arc::new(schema.clone()),
vec![Arc::new(StructArray::new(fields, children, None)) as ArrayRef],
Expand Down
5 changes: 1 addition & 4 deletions rust/lance-file/src/datatypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
}
Expand Down
2 changes: 1 addition & 1 deletion rust/lance-file/src/page_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion rust/lance-index/src/scalar/inverted/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,7 @@ pub fn flat_bm25_search_stream(
let score_col = scored_batch[SCORE_COL].as_primitive::<Float32Type>();
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::<Vec<_>>();
let mask = BooleanArray::from(mask);
let batch = arrow::compute::filter_record_batch(&scored_batch, &mask)?;
Expand Down
2 changes: 1 addition & 1 deletion rust/lance-io/src/object_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ mod tests {
#[case] uri: &str,
#[case] storage_options: Option<HashMap<String, String>>,
) {
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]
Expand Down
5 changes: 1 addition & 4 deletions rust/lance-table/src/rowids.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion rust/lance/src/dataset/cleanup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ mod tests {
pub clock: MockClock<'a>,
}

impl<'a> MockDatasetFixture<'a> {
impl MockDatasetFixture<'_> {
fn try_new() -> Result<Self> {
let tmpdir = tempdir()?;
// let tmpdir_uri = to_obj_store_uri(tmpdir.path())?;
Expand Down
4 changes: 2 additions & 2 deletions rust/lance/src/dataset/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions rust/lance/src/index/vector/pq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 43cd830

Please sign in to comment.