andrross commented on PR #12374:
URL: https://github.com/apache/lucene/pull/12374#issuecomment-1597890665

   +1 to not having two ways to customize slicing.
   
   > the approach to override a method to compute slices given a list of 
segments looks more user-friendly to me than having to compute slices up-front?
   
   @jpountz I agree. I think the basic problem here is that the protected 
method is called from the constructor of the parent class, which really limits 
the flexibility and can lead to unexpected behavior. The simplest approach is 
to just compute the slices on every call to `#search`. If we want to be more 
defensive about possible performance regressions, then lazy computation + 
caching like you said is the way to go (i.e. memoization). 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.


-- 
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

Reply via email to