epotyom commented on code in PR #12862:
URL: https://github.com/apache/lucene/pull/12862#discussion_r1420792687
##########
lucene/facet/src/java/org/apache/lucene/facet/MultiFacets.java:
##########
@@ -77,6 +80,39 @@ public Number getSpecificValue(String dim, String... path)
throws IOException {
return facets.getSpecificValue(dim, path);
}
+ @Override
+ public Number[] getBulkSpecificValues(FacetLabel[] facetLabels) throws
IOException {
+ if (facetLabels.length == 0) {
+ return new Number[0];
+ }
+ // Split facetLabels into chunks by the Facets they belog to
+ Map<Facets, IntArrayList> labelsPerFacet = new HashMap<>();
+ for (int i = 0; i < facetLabels.length; i++) {
+ String dim = facetLabels[i].components[0];
+ Facets facets = dimToFacets.get(dim);
+ if (facets == null) {
+ if (defaultFacets == null) {
+ throw new IllegalArgumentException("invalid dim \"" + dim + "\"");
+ }
+ facets = defaultFacets;
+ }
+ labelsPerFacet.computeIfAbsent(facets, f -> new IntArrayList()).add(i);
+ }
+ // Call getBulkSpecificValues for each chunk and reconcile results
+ Number[] result = new Number[facetLabels.length];
+ for (Map.Entry<Facets, IntArrayList> fl : labelsPerFacet.entrySet()) {
+ FacetLabel[] labelsForFacet = new FacetLabel[fl.getValue().size()];
+ for (IntCursor ordI : fl.getValue()) {
+ labelsForFacet[ordI.index] = facetLabels[ordI.value];
+ }
+ Number[] ords = fl.getKey().getBulkSpecificValues(labelsForFacet);
Review Comment:
Hmm, re-read your message. I don't think we can change `getSpecificValue`
behavior as users might not check for `null`. But we can choose to implement
`null` for the new method. I think it's more intuitive to use `null`, but It
could be a little weird that 2 sibling methods behave differently?
--
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]