-
Notifications
You must be signed in to change notification settings - Fork 1k
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
introduce support in KnnVectorQuery for getters #12029
introduce support in KnnVectorQuery for getters #12029
Conversation
queries should be immutable, see Query.java documentation. Hence I don't think we should add getter/setters or remove final keywords. |
Thanks @rmuir for the prompt answer, I took a look at Query.java, and couldn't find any particular reason for the Knn query to be immutable(aside from historical reasons?). Knn query has a sub-query that uses as an internal filter, and having access to that can make the Solr side of filter/post-filters processing much easier and performant. |
All queries need to be immutable for the query cache to work correctly and consistently. You are right, the docs need help here. Unfortunately docs on immutability were attached to deprecated methods and disappeared! https://github.com/apache/lucene-solr/blob/releases/lucene-solr/5.5.5/lucene/core/src/java/org/apache/lucene/search/Query.java#L95-L107 |
the |
Thanks, @rmuir for the explanation, it seems reasonable and definitely, I won't argue with that. |
@rmuir you are right again, I gave it another try, using copies(ArraysUtils for arrays and clone for byteref), this should be safe. |
BytesRef.clone won't do what we want here. it is a shallow clone. |
Completely agree with Robert -- Query subclasses ought to be immutable and the javadocs ought to be updated to scream this. Nasty/hard bugs happen when a Query is mutable. |
Thanks again @rmuir, moved to a deep copy! |
needs javadocs and tests, otherwise it looks like these getters are unnecessary and should be factored out. |
lucene/core/src/test/org/apache/lucene/search/TestKnnByteVectorQuery.java
Show resolved
Hide resolved
Hi, you had asked for my review, but I think you got lots of helpful feedback already. Anyway this looks fine to me. I added one comment about a test, we could tighten it up a bit. |
lucene/core/src/test/org/apache/lucene/search/TestKnnVectorQuery.java
Outdated
Show resolved
Hide resolved
waiting for the checks and then I'll merge tonight! |
Re: immutable Query in Solr - See https://issues.apache.org/jira/browse/SOLR-16509 and apache/solr#1146 |
Description
Knn Queries are locked currently, it would be beneficial for applications using them to have access to getters and setters.
An example is how filter queries are managed in Apache Solr:
the processing of pre-filters and post-filters could benefit from opening up the access to such variables.
Especially the pre-filter support introduced in Solr 9.1 could get great benefits from being able to set the filter, after the query has been parsed.
See:
apache/solr#1245
If there are no objections I would simply remove the final and add the getters/setters.
I may consider alternative if there's some valid concern in doing that.