-
Notifications
You must be signed in to change notification settings - Fork 38
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
Improve RefineFlatIndex #60
Conversation
Co-authored-by: Eduardo Pinho <enet4mikeenet@gmail.com>
I revert your suggestion commits. |
src/index/pretransform.rs
Outdated
@@ -89,7 +89,7 @@ impl<I> NativeIndex for PreTransformIndexImpl<I> { | |||
} | |||
} | |||
|
|||
impl<I> FromInnerPtr for PreTransformIndexImpl<I> { | |||
impl<IndexImpl> FromInnerPtr for PreTransformIndexImpl<IndexImpl> { |
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.
If making this impl generic is absolutely necessary, please use type parameter names which does not clash with existing types.
impl<IndexImpl> FromInnerPtr for PreTransformIndexImpl<IndexImpl> { | |
impl FromInnerPtr for PreTransformIndexImpl<IndexImpl> { |
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.
It's existing type IndexImpl
.
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.
Hmm. In that case it should be this, no? (note the lack of type parameters)
impl FromInnerPtr for PreTransformIndexImpl<IndexImpl> {
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.
It does not work. It needs type parameter
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 tried it a07ca9b
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.
OK, so that error was:
error[E0277]: the trait bound `RefineFlatIndexImpl<BI>: index::FromInnerPtr` is not satisfied
--> src/index/refine_flat.rs:225:20
|
225 | impl<BI: TryClone> TryClone for RefineFlatIndexImpl<BI> {}
| ^^^^^^^^ the trait `index::FromInnerPtr` is not implemented for `RefineFlatIndexImpl<BI>`
|
note: required by a bound in `index::TryClone`
--> src/index/mod.rs:339:21
|
339 | pub trait TryClone: FromInnerPtr {
| ^^^^^^^^^^^^ required by this bound in `index::TryClone`
help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement
|
[22](https://github.com/Enet4/faiss-rs/actions/runs/3280362393/jobs/5401039258#step:6:23)5 | impl<BI: TryClone> TryClone for RefineFlatIndexImpl<BI> where RefineFlatIndexImpl<BI>: index::FromInnerPtr {}
| ++++++++++++++++++++++++++++++++++++++++++++++++++
The error message already suggests a way to fix the problem, but the way I see it, the TryClone
trait is overly restrictive right now due to its default implementation of try_clone
. So we can either do what the error suggests or move the default implementation onto those that actually depend on it. The steps would be:
- Create a helper function
try_clone_from_inner_ptr
with the default implementation inTryClone::try_clone
. - Remove default implementation body of method
TryClone::try_clone
. - Remove
FromInnerPtr
as a supertrait ofTryClone
- In each
TryClone
implementation with a missingtry_clone
, add the implementation to make them calltry_clone_from_inner_ptr
.
Adding a type parameter might make the error go away, but it's not what we want.
src/index/refine_flat.rs
Outdated
@@ -71,7 +71,7 @@ impl<BI> NativeIndex for RefineFlatIndexImpl<BI> { | |||
} | |||
} | |||
|
|||
impl<BI> FromInnerPtr for RefineFlatIndexImpl<BI> { | |||
impl<IndexImpl> FromInnerPtr for RefineFlatIndexImpl<IndexImpl> { |
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.
impl<IndexImpl> FromInnerPtr for RefineFlatIndexImpl<IndexImpl> { | |
impl FromInnerPtr for RefineFlatIndexImpl<IndexImpl> { |
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 updated the suggested changes above.
I checked in local PC
|
I think trait C++ faiss it is function of |
Yes, we need to change the |
remove FromInnerPtr as super trait
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.
All right, it is good to enter now! Thanks! 👍
No description provided.