-
Notifications
You must be signed in to change notification settings - Fork 355
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
Generalize UniqueIndex keys #207
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.
Looks good. I would make the key less opaque now (no need for index_int
hidden away... at least for UniqueIndex).
Otherwise, I would add a testcase for composite index. I don't know, maybe another type... where (first_name, last_name)
must be unique, but each alone can exist.
John Doe
John Wayne
Maria Doe
are all fine, but adding a second John Doe will return an error.
Also note these storage-plus changes may be api breaking... If any contracts have to be modified when doing so, please label that api breaking in the title (meaning it must be v0.5.0 not v0.4.1) |
Good point. This doesn't happen here AFAIK, but it can happen with changes to |
Given that I'm thinking that a good way forward could be to create a Something like you're already doing in |
Done in the latest commits. Not with a new |
Fix comments Remove commented code
c58ef15
to
ee9e147
Compare
These commits are mostly a rebase from master. I would like to merge this, as I think it's stable. |
Prefix::new_de_fn(top_name, sub_names, deserialize_kv) | ||
} | ||
|
||
pub fn new_de_fn( |
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.
I would use a different name, but I see this extension, and good to keep the default behavior the same.
Definitely need more time to review this
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.
Yes, I was struggling when naming it.
Maybe new_custom_de
?
Another option would be to keep only new
, and add a helper method set_de_fn
or so. But I think it's more confusing / unclear.
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.
Take your time to review this. It's a more complex variant of the unique index case, but in the end it's the same mechanism: when creating the Prefix
, a custom deserialization function is passed, which handles the indirection.
I couldn't make it simpler, because of the different maps / namespaces, and the need to access the store.
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.
I meant, the related PR for the multi index.
Closes #209.
Use generic index keys in
UniqueIndex
, so we canprefix()
andrange()
over them.