Indexes 1: Change Package and related traits to not return references to fields#1336
Indexes 1: Change Package and related traits to not return references to fields#1336
Conversation
…nces to internal fields. This allows alternate package implementations to use the traits, like the forthcoming indexed based packages. Adds ArcCompat helper for serializing and deserializing Arc<Compat> fields Signed-off-by: David Gilligan-Cook <dcook@imageworks.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
| fn compat(&self) -> Arc<Compat> { | ||
| self.compat.clone() |
There was a problem hiding this comment.
We've discussed this elsewhere already, but for the record the suggestion is to use Cow instead of Arc to provide a way for some implementations to be able to return an owned value without sacrificing some places (like this one) from being able to return a cheap reference instead of cloning.
A perhaps even better alternative would be to change this method to return impl SomeNewTrait where that trait contains methods to access whatever is needed from whatever is currently calling this compat() method. Then implementers of Versioned are free to return anything that conforms to that trait.
There was a problem hiding this comment.
Todo:
- Swap the updated Arc<..> return values out for Cow<..>.
Note: for info on benefits of indexing for spk solves see #1340 (5 of 5). Maybe start there and work back down to this PR if you prefer to review PRs top down.
Changes various Package traits' methods to return Arc's instead of references to internal fields. This allows other package implementations, without matching fields, to use the traits. This is one of the changes that supports adding indexes and index based packages to Spk repositories.
This also adds the
ArcCompatobject as helper for serializing and deserializingArc<Compat>fields.This is 1 of 5 chained PRs for adding indexes to spk solves:
new_unchecked()constructors to spk schema objects #1337spk repo indexsubcommand for index generation and updates #1340