jpountz commented on PR #12374: URL: https://github.com/apache/lucene/pull/12374#issuecomment-1599430801
> Is there any utility in Lucene like this [memoizing supplier](https://github.com/google/guava/blob/master/guava/src/com/google/common/base/Suppliers.java#L157-L201) in Guava? (I couldn't find one but I'm not super familiar with the code base). Hand rolling the memoization logic inside IndexSearch is an option too, we'll just need to take some care to ensure that it is thread safe. No, Lucene doesn't have such a utility. +1 to hand rolling the memoization logic. I don't think it needs to be fancy in terms of concurrency, IndexSearcher is expected to spend much more time scoring hits than computing slices, so making it synchronized should be good enough? > With that in mind I guess its cleaner to compute slices always and remove the member leafSlices. Thoughts ? I am happy either way. Caching feels like it has less potential for being perceived as a regression by some users. One approach could be to do the caching approach now which is a bit safer, and then move to the approach that you're suggesting on the `main` branch only so that it goes in the next major where changes in runtime behavior would be less surprising. I don't have strong feelings about this. > Also wondering what is the disadvantage in making leafSlices, protected and non final. I don't like this approach because it exposes internals of IndexSearcher than I'd like users to not touch or have to know about. For instance if we made it protected and non-final, and later made a change to compute slices lazily instead of eagerly in the constructor, this could be perceived as a breaking change as there would be cases when leafSlices would now be `null` when it wasn't before. -- 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