-
Notifications
You must be signed in to change notification settings - Fork 3
Batch work #153
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
base: develop
Are you sure you want to change the base?
Batch work #153
Changes from 7 commits
65493da
e768ee5
6900efc
8bb88a8
a1b2b25
d9b0ad0
90ad992
c823b03
64050b0
94f7945
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ members = ["crate/findex", "crate/memories"] | |
| resolver = "2" | ||
|
|
||
| [workspace.package] | ||
| version = "8.0.1" | ||
| version = "8.1.0" | ||
| authors = [ | ||
| "Bruno Grieder <[email protected]>", | ||
| "Célia Corsin <[email protected]>", | ||
|
|
@@ -30,3 +30,4 @@ cosmian_crypto_core = { version = "10.2", default-features = false, features = [ | |
| criterion = { version = "0.6" } | ||
| smol-macros = { version = "0.1" } | ||
| tokio = { version = "1.46" } | ||
| futures = "0.3.31" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,6 +51,39 @@ pub trait VectorADT: Send { | |
| fn read(&self) -> impl Send + Future<Output = Result<Vec<Self::Value>, Self::Error>>; | ||
| } | ||
|
|
||
| /// This trait provides methods that let an index operate on multiple keywords or entries simultaneously. | ||
| #[cfg(feature = "batch")] | ||
| pub trait IndexBatcher<Keyword, Value> { | ||
| type Error: std::error::Error; | ||
|
|
||
| /// Search the index for the values bound to the given keywords. | ||
| fn batch_search( | ||
| &self, | ||
| keywords: Vec<&Keyword>, | ||
| ) -> impl Future<Output = Result<Vec<HashSet<Value>>, Self::Error>>; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hasn't "async in trait" become stable by now? Maybe try with
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hell yeah looks like it, I will update the adequate traits https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits/ UPDATE : this won't be possible with all traits on this code since the async in trait does not garantee the send - I did a try on the branch called test/async_trait , which is pushed to the remot |
||
|
|
||
| /// Binds each value to their associated keyword in this index. | ||
| fn batch_insert<Values, Entries>( | ||
| &self, | ||
| entries: Entries, | ||
| ) -> impl Send + Future<Output = Result<(), Self::Error>> | ||
| where | ||
| Values: Send + IntoIterator<Item = Value>, | ||
| Entries: Send + IntoIterator<Item = (Keyword, Values)>, | ||
| Entries::IntoIter: ExactSizeIterator, | ||
| <Entries as IntoIterator>::IntoIter: Send; | ||
|
|
||
| /// Removes the given values from the index. | ||
| fn batch_delete<Values, Entries>( | ||
| &self, | ||
| entries: Entries, | ||
| ) -> impl Send + Future<Output = Result<(), Self::Error>> | ||
| where | ||
| Values: Send + IntoIterator<Item = Value>, | ||
| Entries: Send + IntoIterator<Item = (Keyword, Values)>, | ||
| Entries::IntoIter: ExactSizeIterator + Send; | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
| pub mod tests { | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| #![allow(clippy::type_complexity)] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. an outdated lint, for some reason |
||
|
|
||
| use std::{ | ||
| collections::HashSet, | ||
| fmt::Debug, | ||
|
|
||
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.
Best not to use a vector to avoid imposing needless collection upon the client.
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 think I tried that, and probably stopped because of this. Not because we can't use lifetime specefier, but more because I think we cummonly try to avoid their usage
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 to github bugs, A comment I wrote here was lost
I remember saying that we had 3 solutions :
close this if you think we should keep it like it now
By the way,I agree with your comment and that I have implemented it for the other functions (batch_insert, etc...)
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.
Just a general note
I found myself also obliged to add "ExactSizeIterator" bound - basically garantees that we can call len() . This is mandatory, to know how big the memory should be instantiated