Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@roberto-bayardo
Copy link
Collaborator

@roberto-bayardo roberto-bayardo commented Aug 21, 2025

resolves #1447

@roberto-bayardo roberto-bayardo force-pushed the metadata-in-commit branch 4 times, most recently from 321b594 to 242bfdd Compare August 21, 2025 17:27
@roberto-bayardo roberto-bayardo changed the title [storage] support associating uint64 metadata w/ variable-store commit ops [storage] support associating metadata w/ variable-store commit ops Aug 21, 2025
@roberto-bayardo roberto-bayardo marked this pull request as ready for review August 21, 2025 18:20
Copy link
Contributor

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 adds support for associating arbitrary metadata with commit operations in variable-store databases. The key change is that commit operations now carry a metadata value of type V instead of being parameterless.

  • Modified Commit and CommitFloor operation variants to include metadata parameters
  • Added commit_with_metadata() methods alongside existing commit() methods (which now use default metadata)
  • Added get_metadata() methods to retrieve metadata from the last commit operation

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
storage/src/store/operation.rs Core operation types updated to include metadata in commit variants and corresponding serialization/display logic
storage/src/store/mod.rs Store implementation updated with new commit methods and metadata retrieval functionality
storage/src/store/benches/restart.rs Benchmark code updated to use new commit API with metadata
storage/src/adb/keyless.rs Keyless database updated to support metadata in commit operations
storage/src/adb/immutable/sync/mod.rs Synchronization tests updated to use new commit API with metadata
storage/src/adb/immutable/mod.rs Immutable database updated with metadata support and last commit tracking
storage/src/adb/any/variable/mod.rs Variable database implementation updated with metadata commit support
examples/sync/src/databases/immutable.rs Example code updated to use new commit API with metadata

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

assert_eq!(db.op_count(), 3);

// Make sure we can still get metadata.
assert_eq!(db.get_metadata().await.unwrap(), Some(metadata));
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, would be great to add a test for get on the commit op

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Immutable doesn't (yet) support get by location, only by key.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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


/// Get the metadata associated with the last commit, or None if no commit has been made or
/// there is no metadata associated with the last commit.
pub async fn get_metadata(&self) -> Result<Option<V>, Error> {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Option<(u64, V)>

Copy link
Contributor

Choose a reason for hiding this comment

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

I originally suggested for the other dbs but noted your comment about how it wasn't supported to fetch by position.

Copy link
Collaborator Author

@roberto-bayardo roberto-bayardo Aug 22, 2025

Choose a reason for hiding this comment

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

I changed it to Option<(u64, Option<V>)>, because there is a case where there are no commit ops. That ok?

/// Get the metadata associated with the last commit, or None if no commit has been made or
/// there is no metadata associated with the last commit.
pub async fn get_metadata(&self) -> Result<Option<V>, Error> {
pub async fn get_metadata(&self) -> Result<Option<(u64, Option<V>)>, Error> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, this makes sense

@patrick-ogrady patrick-ogrady merged commit 1549f3d into main Aug 22, 2025
36 checks passed
@patrick-ogrady patrick-ogrady deleted the metadata-in-commit branch August 22, 2025 02:14
@codecov
Copy link

codecov bot commented Aug 22, 2025

Codecov Report

❌ Patch coverage is 87.78281% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.72%. Comparing base (301b331) to head (f36b829).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
storage/src/store/operation.rs 50.00% 19 Missing ⚠️
storage/src/adb/any/variable/mod.rs 95.45% 2 Missing ⚠️
storage/src/adb/immutable/sync/mod.rs 91.30% 2 Missing ⚠️
storage/src/adb/keyless.rs 93.93% 2 Missing ⚠️
storage/src/adb/immutable/mod.rs 97.67% 1 Missing ⚠️
storage/src/store/mod.rs 97.43% 1 Missing ⚠️
@@            Coverage Diff             @@
##             main    #1450      +/-   ##
==========================================
- Coverage   91.73%   91.72%   -0.02%     
==========================================
  Files         276      276              
  Lines       69729    69826      +97     
==========================================
+ Hits        63968    64049      +81     
- Misses       5761     5777      +16     
Files with missing lines Coverage Δ
storage/src/adb/any/fixed/mod.rs 98.54% <100.00%> (ø)
storage/src/adb/immutable/mod.rs 96.95% <97.67%> (-0.02%) ⬇️
storage/src/store/mod.rs 96.13% <97.43%> (-0.04%) ⬇️
storage/src/adb/any/variable/mod.rs 96.57% <95.45%> (-0.18%) ⬇️
storage/src/adb/immutable/sync/mod.rs 98.07% <91.30%> (-0.13%) ⬇️
storage/src/adb/keyless.rs 93.76% <93.93%> (+0.03%) ⬆️
storage/src/store/operation.rs 86.33% <50.00%> (-3.38%) ⬇️

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 301b331...f36b829. 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.

[storage/adb] Expose Commit Number

2 participants