dweiss commented on PR #15508:
URL: https://github.com/apache/lucene/pull/15508#issuecomment-3675832904

   It's not what I had in mind, sorry for being vague. I have a strong feeling 
that the entire thing should be implemented using standard ServiceLoader 
mechanisms. So the default singleton in VectorizationProvider.Holder.INSTANCE 
should be instantiated using a service and the logic of this method -
   ```
    static VectorizationProvider lookup(boolean testMode) {
   ```
   
   should be moved to individual service implementations (verification if a 
particular implementation can be used in the current environment, along with 
the instantiation of that implementation). The "singleton lookup" should only 
load all service providers, filter out what cannot be used for whatever reason 
and then pick one of the remaining candidates in their preferred order (which 
can be controlled by a system property, for example 
lucene.vectorization-provider=*,panama,default would indicate the desired 
ordering among available implementations).
   
   So, by default we'd have the "default" (DefaultVectorizationProvider) 
fallback and "panama" (PanamaVectorizationProvider) but you could add another 
service implementation (native). The service would need to implement two 
methods - one to check if it can be used and the other to provide an instance 
of VectorizedProvider.
   
   It isn't a straightforward patch because a lot of the code is currently 
package private and intentionally hidden (and won't allow subclassing). But I 
have a gut feeling it's possible and it would be a lot more elegant in the long 
run. 
   
   It's also related to PRs like this one - 
https://github.com/apache/lucene/pull/15294/ which would like to "know" which 
service implementation is being used. This could be the name (or class) of the 
service provider, for example.
   
   I'm unfortunately away this week and won't be able to contribute directly. I 
would hold this patch until the above avenue can be explored though (either 
turns out to indeed work out nicely or won't work, for some odd reason).


-- 
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: [email protected]

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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to