uschindler commented on PR #12135:
URL: https://github.com/apache/lucene/pull/12135#issuecomment-1424631344

   Hi,
   I fully agree with Robert here. I see no reason why you want to avoid a 
stupid no-op Arrays.sort(). Yes if the array is large, the sort takes some 
time, sorry. But what does this have to do with PrefixCodedTerms? Why is 
Elasticsearch using this private API?
   
   I would agree if we can internally have some special-case ctor that is 
package private (or it is shielded by using some shared-secrets approach if it 
needs to work cross-package), which allows to "reuse" an already existing 
PrefixCodedTerms instance internally when you build a TermInSetQuery from some 
case like building a TermInSetQuery for the joins module from a Term list. But 
PrefixCodedTerms should never ever be part of public APIs. If you want it 
"correct" use Java 8 streams API, although Adrien does not like it, but it is 
the "correct way" to do this kind of stuff.
   
   If Elasticsearch needs to do some internal stuff and can't live with a 
(cheap) resort of an array or using java.util.Stream (if it is already sorted, 
TimSort will just linear scan through the array), it should fork the query as 
this is a special case and does not need to be supported in Lucene. All APIs 
are public, so you could make a subclass/fork  of TermInSetQuery that relies on 
some Elasticsearch-internal array container clsses that have a defined sort 
order. It is not Lucene's task to add support in our public APIs for some 
misuse of Lucene (and those lists of terms for access rights is a misuse of 
Lucene: it is a search engine and not a US NASA-for-travel-to-mars certified 
FIPS-0815 foobar bullshit with high security compliant and unbreakable 
datastore with strict user access checks on millions of documents).
   
   Tell your customers that this is slower if you apply crappy access rights 
that should never have been in a serach engine!
   
   Keep in mind: In any public API we have for sure to either always sort it or 
alterantively if we require a presorted array, we have to actually check this. 
If one passes an array in a public parameter and the defintion says it has to 
be presorted: WE MUST CHECK THIS!. If one would pass an unsorted array we would 
need to throw exception, so we need to check correct order as part of param 
validation. But as checking that the array is in correct order is as expensive 
as just sorting it, we should simply sort it. There's no discussion possible!


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