-
Notifications
You must be signed in to change notification settings - Fork 39
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
Add protocol validation, rename mod features
to table_features
#454
base: main
Are you sure you want to change the base?
Add protocol validation, rename mod features
to table_features
#454
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #454 +/- ##
==========================================
+ Coverage 78.08% 78.20% +0.11%
==========================================
Files 55 55
Lines 11605 11730 +125
Branches 11605 11730 +125
==========================================
+ Hits 9062 9173 +111
- Misses 2043 2056 +13
- Partials 500 501 +1 ☔ View full report in Codecov by Sentry. |
@@ -481,4 +555,66 @@ mod tests { | |||
)])); | |||
assert_eq!(schema, expected); | |||
} | |||
|
|||
#[test] | |||
fn test_validate_protocol() { |
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.
Would like to see the feature subset check get exercised. Would also like to see the min_reader_version == 1
or 2 get checked as well.
|
||
/// Check if reading a table with this protocol is supported. That is: does the kernel support | ||
/// the specified protocol reader version and all enabled reader features? | ||
// TODO: should this return result so we can say _why_ it isn't supported? |
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.
Seems like yes?
Some(reader_features) if self.min_reader_version == 3 => { | ||
let parsed_features: Result<HashSet<_>, _> = reader_features | ||
.iter() | ||
.map(|s| s.parse::<ReaderFeatures>()) |
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.
Maybe this is cleaner?
.map(|s| s.parse::<ReaderFeatures>()) | |
.map(ReaderFeatures::from_str) |
match &self.reader_features { | ||
// check that all reader features are subset of supported | ||
Some(reader_features) if self.min_reader_version == 3 => { | ||
let parsed_features: Result<HashSet<_>, _> = reader_features |
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.
Is it really an arbitrary Result
? Or would this work?
let parsed_features: Result<HashSet<_>, _> = reader_features | |
let parsed_features: DeltaResult<HashSet<_>> = reader_features |
} | ||
|
||
impl Protocol { | ||
pub fn new( |
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.
pub fn new( | |
pub fn try_new( |
assert!(matches!( | ||
Protocol::new( | ||
min_reader_version, | ||
min_writer_version, | ||
reader_features, | ||
writer_features | ||
), | ||
Err(Error::InvalidProtocol(_)), | ||
)); |
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.
If you aren't worried about the specific error, can also do:
Protocol::try_new(...).expect_err("invalid protocol")
Some(vec![ReaderFeatures::V2Checkpoint.to_string()]), | ||
Some(vec![ReaderFeatures::V2Checkpoint.to_string()]), |
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.
Since we anyway have a method now, maybe consider having it take:
reader_features: Option<impl` IntoIterator<Item = impl Into<String>>>,
writer_features: Option<impl` IntoIterator<Item = impl Into<String>>>,
... and then this code here simplifies to:
Some(vec![ReaderFeatures::V2Checkpoint.to_string()]), | |
Some(vec![ReaderFeatures::V2Checkpoint.to_string()]), | |
Some([&ReaderFeatures::V2Checkpoint]), | |
Some([&ReaderFeatures::V2Checkpoint]), |
(again below)
What changes are proposed in this pull request?
Protocol
validation (as soon as aProtocol
is constructed via our visitor, do the following validation:)a. Check that table min reader/writer version <= kernel reader/writer version
b. Fail if V2Checkpoint reader feature is enabled (since we don't yet implement it)
c. Check that reader features and writer features are present for reader version 3 and writer version 7, respectively
VacuumProtocolCheck
reader/writer feature (but this is allowed as reader feature since it's a noop so we trivially support it)features
module totable_features
(less confusing with cargo's notion of features)This PR affects the following public APIs
New error classes for invalid protocol and unsupported features. Add
VacuumProtocolCheck
reader/writer feature. Fields inProtocol
are now private.How was this change tested?
new ut