-
Notifications
You must be signed in to change notification settings - Fork 109
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
incr-join, find_updates: avoid unncecessary clones & use partition #988
Conversation
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.
Beautiful. The unnecessary clones in this code path have been bugging me for a while. Thanks for getting rid of them!
Minor comment-related crap, plus a question about reborrowing.
let partition_into = |ds: &mut Vec<_>, is: &mut Vec<_>, updates: &DatabaseTableUpdate| { | ||
for update in &updates.ops { | ||
if update.op_type == 0 { &mut *ds } else { &mut *is }.push(update.row.clone()); | ||
} | ||
}; |
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.
What's up with the reborrows on line 343? Why can't this be
let partition_into = |ds: &mut Vec<_>, is: &mut Vec<_>, updates: &DatabaseTableUpdate| {
for update in &updates.ops {
if update.op_type == 0 { ds } else { is }.push(update.row.clone());
}
};
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.
Also, ugh, I hate all these 0
s and 1
s. If I get some spare time, I'll make a follow-up that defines constants OP_TYPE_DELETE
and OP_TYPE_INSERT
(assuming we don't have those already...).
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.
So the reborrow here is due to the compiler failing to insert a reborrowing coercion on its own, apparently due to interactions with generic code. It's rather obscure, but this is the best I could find, rust-lang/rust#62112.
db3a690
to
68c4f1e
Compare
Description of Changes
First commit: Only clone once per
TableOp
infind_ops
, achieved usingIterator::partition
:Second commit: Clone even less and have
JoinSide
holdVec<PV>
instead:All numbers are vs. master baseline.
(i7-7700K, 64GB RAM)
API and ABI breaking changes
None
Expected complexity level and risk
1
Testing
No semantic changes.