-
Notifications
You must be signed in to change notification settings - Fork 150
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
WIP: Add views of OrderMap #47
Conversation
`OrderMap::view() -> OrderMapView` and `view_mut() -> OrderMapViewMut` provide access to items in the map, but no ability to add/remove items. These views can be sub-divided with `split_at` etc., which may be useful to enable parallelism.
Views were suggested here: #45 (comment) The two views have different contents, so I thought I should explain why, and we can decide how to proceed.
This setup also means that One idea is that |
The other thing I wanted to point out is that sadly I don't think it's possible to allow |
Hey, I'm thrilled! Just love to see an idea tried out and come to life |
Yes the Rust limitations for views is something I know well from ndarray 😄 I also have a preconceived notion from ndarray's view design: it would use |
OK, splitting by value works. |
if let Some((i, hash_proxy)) = self.indices[probe].resolve::<Sz>() { | ||
// Unfortunately, we can only look at indexes within our slice | ||
// of entries, which might mean we'll keep probing farther than | ||
// it would be strictly necessary. |
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.
We can remedy this (often); by asking for the short hash that is stored in the indices; it is accessible when usize is 64-bit and the entry capacity fits in 32 bits. It requires breaking down get_short_hash
and using something like this:
/// Get the hash from the indices if possible.
fn try_short_hash<K, V>(&self) -> Option<ShortHash<Sz>> {
if Sz::is_64_bit() {
None
} else {
Some(ShortHash(self.0, PhantomData))
}
}
Is this still in works or decided against in post-OrderMap world? (I wouldn't generally ping on issues/PRs but seems that this was inactive for half a year) |
I haven't thought about it in a while. Is this a feature you would like? |
@RReverser I haven't had much time for github, that goes up and down sometimes. @cuviper Right, so how do we decide if this is actually useful or just a ridiculously cool idea :-) I'd say we want this, thanks for all the implementation work but if you want to you can leave it for me to finish it, that's fine with me. (These kinds of view definitions in Rust, they don't feel entirely perfect in general, not sure if we are missing language features or what we are missing to really express this in a better way; having multiple kinds of equivalent read-only IndexMap-ish types then later demands traits that treats the two as equal and so on..) |
@cuviper Initially I thought I do need this, but then realised it's not what I thought it is :) |
#177 did this better. |
OrderMap::view() -> OrderMapView
andview_mut() -> OrderMapViewMut
provide access to items in the map, but no ability to add/remove items.
These views can be sub-divided with
split_at
etc., which may be usefulto enable parallelism.