-
Notifications
You must be signed in to change notification settings - Fork 60
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
Define and use new AsAny trait #450
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #450 +/- ##
==========================================
- Coverage 79.64% 79.60% -0.04%
==========================================
Files 57 57
Lines 12324 12330 +6
Branches 12324 12330 +6
==========================================
Hits 9815 9815
- Misses 1981 1987 +6
Partials 528 528 ☔ View full report in Codecov by Sentry. |
Apparently our codecov doesn't consider doc tests? Because the doc test just a few lines above definitely exercises the supposedly not-covered method. |
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.
Thanks, this will be useful
regarding coverage of doctests I made an issue for us to follow up: #484 |
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.
LGTM only question is does AsAny
communicate enough information about our traits? Maybe consider calling SendSyncAny
or something?
I'm not sure the "fatter" name is really helpful? |
yea agree - could just leave and make that change later if we think it's necessary :) |
What changes are proposed in this pull request?
As part of implementing various kernel operations, engines need the ability to downcast kernel engine traits to their true concrete types. The rust
Any
trait can help with struct downcasting, but it isn't quite strong enough once traits are involved. For example, giventrait Foo: Any + Send + Sync
, andstruct Bar
that implementsFoo
, the following fails to compile:... as does this:
We solve the trait downcasting problem with a new
trait AsAny: Any + Send + Sync
-- automatically implemented for allT: Any + Send + Sync
-- which defines methods for downcasting itself todyn Any + Send + Sync
(reference, box, or arc).This PR affects the following public APIs
The various engine traits (
ParquetHandler
,EngineData
, etc.) are now constrained to beAsAny
(which impliesAny + Send + Sync
) rather than merelySend + Sync
).This change should be source compatible in the vast majority of cases, because most types implement
Any
automatically.How was this change tested?
Doc tests, and it also replaces similar special-case code in the arrow default engine data implementation.