-
Notifications
You must be signed in to change notification settings - Fork 223
Add extend_from_iter into growable trait #773
Conversation
Codecov Report
@@ Coverage Diff @@
## main #773 +/- ##
==========================================
- Coverage 70.99% 70.99% -0.01%
==========================================
Files 316 316
Lines 16733 16736 +3
==========================================
+ Hits 11879 11881 +2
- Misses 4854 4855 +1
Continue to review full report at Codecov.
|
packed_simd is broken in the latest rust nightly toolchain. |
BTW, packed_simd seems superseded by stdsimd. |
@@ -40,6 +40,13 @@ pub trait Growable<'a> { | |||
/// Extends this [`Growable`] with null elements, disregarding the bound arrays | |||
fn extend_validity(&mut self, additional: usize); | |||
|
|||
/// Extends this [`Growable`] by iterator. | |||
fn extend_from_iter(&mut self, iter: Box<dyn Iterator<Item = (usize, usize, usize)>>) { |
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.
Yeap, I think that this won't work as intended because .extend
will still be dynamically dispatched.
We do something like what you intend here: https://github.com/jorgecarleitao/arrow2/blob/main/src/compute/filter.rs#L87
Essentially, specialize the implementation based on the physical type, and use a generic one (https://github.com/jorgecarleitao/arrow2/blob/main/src/compute/filter.rs#L101) for all others.
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.
https://users.rust-lang.org/t/is-this-a-curiously-recurring-template-pattern/31004/6
As User @ExpHP said:
trait Trait {
fn foo(&mut self);
fn call_foo_twice(&mut self) {
self.foo(); // <-- this is statically dispatched
self.foo();
}
fn wrap(self) -> Wrapper<Self> { // <-- we can name Self
Wrapper(self)
}
}
so .extend
is statically dispatched?
An idea: create a simple function |
This should be done via extension trait to avoid object safety issue. |
closing to search for better ideas. |
Did not achieve expected performance.
We can't make
extend_from_iter
accept generic iterator, it'll make this trait none object-safety.Fixes #772