Skip to content

Commit

Permalink
Fix Clippy lints 1.73 (qdrant#2760)
Browse files Browse the repository at this point in the history
  • Loading branch information
agourlay authored and generall committed Oct 6, 2023
1 parent 3bc9178 commit 325cac6
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/collection/src/collection_manager/segments_searcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl SegmentsSearcher {
// without sampling on that segment.
searches_to_rerun
.entry(segment_id)
.or_insert_with(Vec::new)
.or_default()
.push(batch_id);
}
}
Expand Down
5 changes: 1 addition & 4 deletions lib/collection/src/operations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ where
let mut op_vec_by_shard: HashMap<ShardId, Vec<O>> = HashMap::new();
for operation in iter {
let shard_id = point_to_shard(id_extractor(&operation), ring);
op_vec_by_shard
.entry(shard_id)
.or_insert_with(Vec::new)
.push(operation);
op_vec_by_shard.entry(shard_id).or_default().push(operation);
}
OperationToShard::by_shard(op_vec_by_shard)
}
Expand Down
10 changes: 2 additions & 8 deletions lib/collection/src/operations/point_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,7 @@ impl SplitByShard for Batch {
for (name, vector) in named_vector {
let name = name.into_owned();
let vector = vector.into_owned();
batch_vectors
.entry(name)
.or_insert_with(Vec::new)
.push(vector);
batch_vectors.entry(name).or_default().push(vector);
}
batch.payloads.as_mut().unwrap().push(payload);
}
Expand Down Expand Up @@ -411,10 +408,7 @@ impl SplitByShard for Batch {
for (name, vector) in named_vector {
let name = name.into_owned();
let vector = vector.into_owned();
batch_vectors
.entry(name)
.or_insert_with(Vec::new)
.push(vector);
batch_vectors.entry(name).or_default().push(vector);
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions lib/collection/src/operations/vector_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,13 @@ impl SplitByShard for VectorOperations {
let shard_id = point_to_shard(point.id, ring);
(shard_id, point)
})
.fold(HashMap::new(), |mut map, (shard_id, points)| {
map.entry(shard_id).or_insert(vec![]).push(points);
map
});
.fold(
HashMap::new(),
|mut map: HashMap<u32, Vec<PointVectors>>, (shard_id, points)| {
map.entry(shard_id).or_default().push(points);
map
},
);
let shard_ops = shard_points.into_iter().map(|(shard_id, points)| {
(
shard_id,
Expand Down
2 changes: 1 addition & 1 deletion lib/segment/src/index/field_index/geo_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ impl GeoMapIndex {
for geo_hash in &geo_hashes {
self.points_map
.entry(geo_hash.to_owned())
.or_insert_with(HashSet::new)
.or_default()
.insert(idx);

self.increment_hash_value_counts(geo_hash);
Expand Down
2 changes: 1 addition & 1 deletion lib/storage/src/content_manager/consensus_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ impl<C: CollectionContainer> ConsensusManager<C> {
let mut message_send_failures = self.message_send_failures.write();
let entry = message_send_failures
.entry(peer_address.to_string())
.or_insert_with(Default::default);
.or_default();
// Log only first error
if entry.count == 0 {
log::warn!("Failed to send message to {peer_address} with error: {error}")
Expand Down
4 changes: 1 addition & 3 deletions src/common/telemetry_ops/requests_telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@ impl WebApiTelemetry {
for (method, status_codes) in &other.responses {
let status_codes_map = self.responses.entry(method.clone()).or_default();
for (status_code, statistics) in status_codes {
let entry = status_codes_map
.entry(*status_code)
.or_insert_with(OperationDurationStatistics::default);
let entry = status_codes_map.entry(*status_code).or_default();
*entry = entry.clone() + statistics.clone();
}
}
Expand Down

0 comments on commit 325cac6

Please sign in to comment.