bjacobowitz opened a new pull request, #13109: URL: https://github.com/apache/lucene/pull/13109
### Description <!-- If this is your first contribution to Lucene, please make sure you have reviewed the contribution guide. https://github.com/apache/lucene/blob/main/CONTRIBUTING.md --> Create a `WrappedCandidateMatcher`, along with a factory for creating these objects and a default implementation of the factory, to assist users in creating their own composite matchers. ### Problem The current access protections on `CandidateMatcher` make it infeasible for a user of the Lucene Monitor library to create their own composite `CandidateMatcher` (for example, an alternate version of `ParallelMatcher`) on top of existing `CandidateMatcher` instances if they are outside the package. As an example, the existing implementation of `ParallelMatcher` makes use of delegate `CandidateMatcher` instances, but a user would not be able to write their own version of this in their own package, because `matchQuery()`, `finish()` and `reportError()` all have package-private access ([see this gist](https://gist.github.com/bjacobowitz/be9a54663217c46cc239cc9f9f580de8#file-parallelmatcher-java), comments labeled "PROBLEM"). ### Solution The simplest solution to this problem would be to increase the visibility of those functions in `CandidateMatcher` (either to `protected` or `public`), but it runs the risk of violating encapsulation, so I've tried to avoid that here. The solution I've put together here introduces a `WrappedCandidateMatcher`, which can be used to increase visibility when creating a composite matcher. `WrappedCandidateMatcher` does **NOT** extend from `CandidateMatcher` but has nearly the same interface, with increased visibility on `matchQuery()`, `finish()` and `reportError()`. A user building a new `CandidateMatcher` by composing existing `CandidateMatcher` instances could make full use of those `CandidateMatchers` by wrapping them with `WrappedCandidateMatcher`, allowing them to be used internally to the composite matcher ([see this gist](https://gist.github.com/bjacobowitz/be9a54663217c46cc239cc9f9f580de8#file-parallelmatcherusingwrapped-java), comments labeled "SOLUTION"). On a certain level, this solution also violates existing encapsulation, but it requires the user to jump through a few hoops to get there, so it would limit the potential for misuse of a `CandidateMatcher`. If we would instead prefer to increase the visibility on `CandidateMatcher`, let me know and I can do that instead. ### Merge Request If this PR gets merged, can you please use my `bjacobowi...@bloomberg.net` email address for the squash+merge. Thank you. -- 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: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org