-
Notifications
You must be signed in to change notification settings - Fork 112
[codec] Add CodecFixed
#1423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[codec] Add CodecFixed
#1423
Conversation
| pub struct Any< | ||
| E: Storage + Clock + Metrics, | ||
| K: Array, | ||
| V: CodecFixed<Cfg = ()>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future, we can debate whether we want to allow Cfg to be passed here (this just minimizes the diff).
There was a problem hiding this 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 introduces a new trait CodecFixed that combines Codec and EncodeFixed traits, providing a convenient interface for types that can be both encoded and decoded from fixed-size byte sequences. The change replaces the generic Array constraint with CodecFixed across the storage layer to enable more flexible value types while maintaining fixed-size encoding capabilities.
Key changes include:
- Addition of the
CodecFixedtrait in the codec module - Replacement of
Arraytype constraints withCodecFixedfor value types throughout storage operations - Updates to Display implementations to use hex encoding for value representation
- Enhanced error handling in ordinal storage record validation
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| codec/src/codec.rs | Introduces the new CodecFixed trait combining Codec and EncodeFixed |
| storage/src/store/operation.rs | Replaces Array with CodecFixed for value types and updates display formatting |
| storage/src/ordinal/storage.rs | Updates value type constraints and improves record validation error handling |
| storage/src/journal/fixed.rs | Changes type constraints from Codec + FixedSize to CodecFixed |
| storage/src/adb/verify.rs | Adds utility functions for proof construction and digest calculation |
| storage/src/adb/sync/resolver.rs | Updates type constraints to use CodecFixed with additional trait bounds |
| storage/src/adb/immutable/mod.rs | Simplifies snapshot operations by removing redundant helper function |
| storage/src/adb/current.rs | Updates type constraints for current database implementation |
| storage/src/adb/any/fixed/sync.rs | Updates journal initialization functions to use CodecFixed |
| storage/src/adb/any/fixed/mod.rs | Updates the main Any struct type constraints |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
| /// during this call. | ||
| pub async fn set(&mut self, key: K, value: V) -> Result<(), Error> { | ||
| let loc = self.log_size; | ||
| Immutable::<E, K, V, H, T>::set_loc(&mut self.snapshot, &key, loc).await?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous approach didn't end up pruning any useless info.
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #1423 +/- ##
==========================================
- Coverage 91.72% 91.70% -0.02%
==========================================
Files 275 275
Lines 69392 69443 +51
==========================================
+ Hits 63651 63685 +34
- Misses 5741 5758 +17
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Related: #1417
Resolves: #1418