Skip to content

Conversation

roberto-bayardo
Copy link
Collaborator

@roberto-bayardo roberto-bayardo commented Jun 14, 2025

  • Makes initialization re-use delete() code when replaying delete operations to reduce code duplication.

  • Replace 2-arm match clauses with let/else.

  • Add additional assertion checking ensuring data consistency.

  • Better document invariants.

@roberto-bayardo roberto-bayardo marked this pull request as ready for review June 14, 2025 23:43
@roberto-bayardo roberto-bayardo requested a review from Copilot June 14, 2025 23:43
Copilot

This comment was marked as outdated.

@roberto-bayardo roberto-bayardo force-pushed the anydb-cleanup branch 8 times, most recently from 7926feb to 699d315 Compare June 15, 2025 02:59
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors delete and update replay logic to reduce duplication, simplifies pattern matching, and aligns update handling with other operations.

  • Extracts common delete logic into a new delete_key helper and updates initialization replay to use it
  • Replaces two-arm match statements with let ... else or if let for more concise control flow
  • Updates the in-snapshot update logic to directly destructure Operation::Update and adjust cursor updates
Comments suppressed due to low confidence (3)

storage/src/adb/any.rs:414

  • [nitpick] The variable name r is ambiguous; consider renaming it to something more descriptive like deleted_loc or prev_location to clarify its purpose.
let r = Self::delete_key(&mut self.snapshot, &self.log, &key).await?;

storage/src/adb/any.rs:424

  • Add unit tests for delete_key covering both cases (key present vs. absent) and verify that the snapshot and bitmap updates behave as expected after refactoring.
async fn delete_key(

storage/src/adb/any.rs:259

  • [nitpick] This binding shadows the outer bitmap variable, which can be confusing; consider renaming the inner binding (e.g., if let Some(bm) = &mut bitmap) to improve readability.
if let Some(ref mut bitmap) = bitmap {

@roberto-bayardo roberto-bayardo force-pushed the anydb-cleanup branch 4 times, most recently from d9cb9b4 to eafce72 Compare June 15, 2025 14:55
@roberto-bayardo roberto-bayardo changed the title [storage/adb/any] remove anydb code duplication [storage/adb/any] anydb code cleanup Jun 15, 2025
@roberto-bayardo roberto-bayardo force-pushed the anydb-cleanup branch 7 times, most recently from 9acce86 to b05b23e Compare June 15, 2025 15:31
@roberto-bayardo roberto-bayardo force-pushed the anydb-cleanup branch 2 times, most recently from 86a77c0 to 0fc44b7 Compare June 15, 2025 15:46
///
/// # Warning
///
/// Panics if the location does not reference an update operation.
Copy link
Contributor

@patrick-ogrady patrick-ogrady Jun 16, 2025

Choose a reason for hiding this comment

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

nit: add a bit more context that this should not happen if the snapshot is correctly managed? Maybe that's overkill...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no makes sense. done

}
cursor.delete();
break;
let delete_result =
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think you can just call this result

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done. also renamed the "update_result" below to just "result"

@patrick-ogrady patrick-ogrady merged commit 31c895b into main Jun 16, 2025
15 checks passed
@patrick-ogrady patrick-ogrady deleted the anydb-cleanup branch June 16, 2025 17:50
Copy link

codecov bot commented Jun 16, 2025

Codecov Report

Attention: Patch coverage is 98.07692% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.01%. Comparing base (c46312f) to head (f9f666e).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
storage/src/adb/any.rs 98.07% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #1107      +/-   ##
==========================================
+ Coverage   90.99%   91.01%   +0.01%     
==========================================
  Files         191      191              
  Lines       55227    55217      -10     
==========================================
- Hits        50255    50253       -2     
+ Misses       4972     4964       -8     
Files with missing lines Coverage Δ
storage/src/adb/any.rs 99.35% <98.07%> (+1.13%) ⬆️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c46312f...f9f666e. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants