Skip to content

Commit 856b4de

Browse files
committed
clippy work
1 parent 3759a14 commit 856b4de

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
#![warn(clippy::pedantic, clippy::nursery)]
8383
#![warn(clippy::expect_used)]
8484
#![allow(clippy::missing_const_for_fn)]
85+
#![warn(clippy::multiple_crate_versions)]
8586

8687
mod blob_cache;
8788
mod compression;

src/manifest.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ impl SegmentManifest {
159159
&self,
160160
f: F,
161161
) -> crate::Result<()> {
162+
let mut prev_segments = self.segments.write().expect("lock is poisoned");
163+
162164
// NOTE: Create a copy of the levels we can operate on
163165
// without mutating the current level manifest
164166
// If persisting to disk fails, this way the level manifest
165167
// is unchanged
166-
let mut prev_segments = self.segments.write().expect("lock is poisoned");
167-
168168
let mut working_copy = prev_segments.clone();
169169

170170
f(&mut working_copy);
@@ -174,6 +174,10 @@ impl SegmentManifest {
174174
Self::write_to_disk(&self.path, &ids)?;
175175
*prev_segments = working_copy;
176176

177+
// NOTE: Lock needs to live until end of function because
178+
// writing to disk needs to be exclusive
179+
drop(prev_segments);
180+
177181
log::trace!("Swapped vLog segment list to: {ids:?}");
178182

179183
Ok(())
@@ -215,6 +219,10 @@ impl SegmentManifest {
215219
item_count: writer.item_count,
216220
compressed_bytes: writer.written_blob_bytes,
217221
total_uncompressed_bytes: writer.uncompressed_bytes,
222+
223+
// NOTE: We are checking for 0 items above
224+
// so first and last key need to exist
225+
#[allow(clippy::expect_used)]
218226
key_range: KeyRange::new((
219227
writer
220228
.first_key
@@ -336,6 +344,7 @@ impl SegmentManifest {
336344

337345
/// Returns the percent of dead bytes (uncompressed) in the value log
338346
#[must_use]
347+
#[allow(clippy::cast_precision_loss)]
339348
pub fn stale_ratio(&self) -> f32 {
340349
let total_bytes = self.total_bytes();
341350
if total_bytes == 0 {
@@ -355,6 +364,7 @@ impl SegmentManifest {
355364
///
356365
/// Returns 0.0 if there are no items or the entire value log is stale.
357366
#[must_use]
367+
#[allow(clippy::cast_precision_loss)]
358368
pub fn space_amp(&self) -> f32 {
359369
let total_bytes = self.total_bytes();
360370
if total_bytes == 0 {

src/value_log.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ impl ValueLog {
195195
/// Will return `Err` if an IO error occurs.
196196
pub fn register_writer(&self, writer: SegmentWriter) -> crate::Result<()> {
197197
let _lock = self.rollover_guard.lock().expect("lock is poisoned");
198-
199198
self.manifest.register(writer)?;
200199
Ok(())
201200
}
@@ -282,6 +281,7 @@ impl ValueLog {
282281
/// Tries to find a least-effort-selection of segments to
283282
/// merge to reach a certain space amplification.
284283
#[must_use]
284+
#[allow(clippy::cast_precision_loss, clippy::significant_drop_tightening)]
285285
pub fn select_segments_for_space_amp_reduction(&self, space_amp_target: f32) -> Vec<SegmentId> {
286286
let current_space_amp = self.space_amp();
287287

@@ -381,6 +381,7 @@ impl ValueLog {
381381
/// Will return `Err` if an IO error occurs.
382382
fn mark_as_stale(&self, ids: &[SegmentId]) {
383383
// NOTE: Read-locking is fine because we are dealing with an atomic bool
384+
#[allow(clippy::significant_drop_tightening)]
384385
let segments = self.manifest.segments.read().expect("lock is poisoned");
385386

386387
for id in ids {
@@ -401,6 +402,7 @@ impl ValueLog {
401402
}
402403

403404
#[doc(hidden)]
405+
#[allow(clippy::cast_precision_loss)]
404406
pub fn consume_scan_result(&self, segment_ids: &[u64], size_map: &SizeMap) {
405407
for (&id, counter) in size_map {
406408
let used_size = counter.size;

0 commit comments

Comments
 (0)