Add ComposedNamedPhysicalExtensionCodec - #24826
Conversation
|
Thank you for opening this pull request! Reviewer note: cargo-semver-checks reported the current version number is not SemVer-compatible with the changes in this pull request (compared against the base branch). Details |
| #[deprecated( | ||
| since = "56.0.0", | ||
| note = "Please use `ComposedNamedPhysicalExtensionCodec`" | ||
| )] |
There was a problem hiding this comment.
Still not sure if it's worth to deprecate this one, FWIW both could live together.
| /// A PhysicalExtensionCodec that tries one of multiple inner codecs until one works. | ||
| /// The name of the codec that successfully encoded an [`ExecutionPlan`] is stored in the | ||
| /// encoded payload, and the codec with that exact name will be used for decoding. | ||
| #[derive(Default, Debug)] | ||
| pub struct ComposedNamedPhysicalExtensionCodec { | ||
| codecs: HashMap<Cow<'static, str>, Arc<dyn PhysicalExtensionCodec>>, | ||
| } |
There was a problem hiding this comment.
cc @milenkovicm, do you have any opinions about this?
There was a problem hiding this comment.
Could string make encoded message too big? Could you consider u8 keys
There was a problem hiding this comment.
Or even u16 or u32, as the keys
There was a problem hiding this comment.
If you consider sorted keys, you can implement codec priority as well. I know strings are more flexible than numbers but they won't remove synchronisation between orgs and they can be abused with key size
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #24826 +/- ##
==========================================
- Coverage 81.58% 81.56% -0.03%
==========================================
Files 1123 1123
Lines 406610 406707 +97
Branches 406610 406707 +97
==========================================
- Hits 331719 331715 -4
- Misses 55453 55554 +101
Partials 19438 19438 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Which issue does this PR close?
Rationale for this change
The
ComposedPhysicalExtensionCodecallowed to register multiple codecs, which are tried one by one until one works. When one works, the index of the list that occupies the codec that works is stored in the encoded payload for later decoding:The issue with this setup is that codecs can only be added to the end of the list, otherwise, while decoding, the index will be messed up and decoding will fail. In a setup with progressive rollouts this is very likely to happen.
While working in a small team, it's reasonable to expect developers to behave and just add new codecs at the end, however, when there are many teams contributing to the same list, with a non-centralized piece of code that has mutable access to it, it's easy to be in the situation where new codecs are not added at the end.
What changes are included in this PR?
Introduces a new
ComposedNamedPhysicalExtensionCodecthat identifies encoded payloads by codec name instead of by index in a list. This way, registration order does not matter, and this problem becomes irrepresentable:What is the testing strategy for this PR?
TODO
Are there any user-facing changes?
New
ComposedNamedPhysicalExtensionCodecis added to the public API, while keeping the previousComposedPhysicalExtensionCodecstill available.