magibney commented on pull request #2:
URL: https://github.com/apache/solr/pull/2#issuecomment-801172368


   >Another option would be to make it final and eagerly compute it in the 
constructor
   
   Hmm. on second thought I think there's another practical problem with any 
approach seeking to eagerly build `cachedOrdIdxMap`, either as an arg to the 
ctor, or within the ctor. There are quite a few invocations of the existing 
ctors, many of which appear not to have a reference to the IndexReader (and its 
"leaves") readily-available.
   
   And even aside from the above problem, if thinking of this as an 
optimization, at time of construction it's often difficult (perhaps 
impossible?) to determine a priori which cases are temporary/transient and 
should thus _not_ have this array eagerly constructed.
   
   It's feeling like with the addition of `volatile` making this thread-safe, 
lazy build/cache is not so much an optimization as "the only practical way to 
go"? Perhaps I'm still missing something, though ...


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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to