hossman opened a new issue, #15497:
URL: https://github.com/apache/lucene/issues/15497
### Description
All Instances of `MatchAllDocsQuery` (and `MatchNoDocsQuery`) are
(respectively) equivalent, so it seems silly to for Lucene applications to use
`new MatchAllDocsQuery()` (and `new MatchNoDocsQuery()`) and create a lot of
identical objects instead of just re-using singleton `INSTANCE`. _(Unless i'm
missing something?)_
*
[MatchAllDocsQuery.MatchNoDocsQuery.singleton.patch](https://github.com/user-attachments/files/24089412/MatchAllDocsQuery.MatchNoDocsQuery.singleton.patch)
* really trivial patch adding a static `INSTANCE` to both classes and
deprecating the default constructors
*
[MatchAllDocsQuery.MatchNoDocsQuery.singleton.deprecation-cleanup.patch](https://github.com/user-attachments/files/24089411/MatchAllDocsQuery.MatchNoDocsQuery.singleton.deprecation-cleanup.patch)
* verbose patch cleaning up the deprecated usages through out the code
base
NOTE: I left the single arg constructor for `MatchNoDocsQuery(String)`
alone, but...
- I went ahead and add a note to it's javadocs that the `reason` argument
doesn't impact it's equality
- which i guess makes sense, but kind of surprised me -- not sure if
that's actually intentional or a bug?
- It's used in many places in Lucene, frequently as part of rewriting other
queries, but (AFAICT) always with (effectively) static arguments
- so It might make sense for those classes to define their own private
static instances for each "reason" ?
----
(I sent a question about this idea to the mailing list a couple of months
back but didn't get any response; so i figured i'd go ahead and create an issue
and see if that prompted any response since the patch was so easy to trivial)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]