sohami commented on PR #12374: URL: https://github.com/apache/lucene/pull/12374#issuecomment-1593825909
> hi @sohami thanks for opening this PR! I have been considering a different approach, in the attempt of not adding additional constructors to IndexSearcher, as it already has quite some. > > I am thinking that pre-computing the slices in the constructor may not be so important. How about removing that and computing the slices each time they are retrieved? There's only three methods where that is used between searchAfter and search. If needed, subclasses can still pre-compute and cache the slices if that's considered important. This way, subclasses are free to override how slices are computed, and the change is a little less invasive. @javanna Thanks for the suggestion. I would think the base implementation will want to avoid computing it on every usage specially for the immutable indices where [IndexSearcher is suggested to be reused](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java#L54). If it is not cached then for each search it will compute the slices which seems redundant and also deviating from current baseline. If we want to cache the computed slices in base class but remove it from getting initialized from constructor, then essentially we are making `leafSlices` variable non-final and relying on users of the `leafSlice` variable across the methods to use `getSlices()` atleast once which doesn't seem clean as well. I think if the concern is to avoid adding yet another constructor then other way could be to make the `leafSlice` variable `protected` and `non-final` and initialize it in constructor of base class. The subclasses can then choose to override it as needed with the understanding that it should not be changed in between the execution (not clean but probably a middle ground and similar to how `similarity` implementation is provided to `IndexSearcher`) -- 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