epotyom commented on code in PR #13645: URL: https://github.com/apache/lucene/pull/13645#discussion_r1714080529
########## lucene/facet/src/java/org/apache/lucene/facet/DrillSideways.java: ########## @@ -240,46 +242,43 @@ public DrillSidewaysResult search(DrillDownQuery query, Collector hitCollector) int numDims = drillDownDims.size(); FacetsCollectorManager drillDownCollectorManager = createDrillDownFacetsCollectorManager(); + final CollectorOwner<FacetsCollector, FacetsCollector> drillDownCollectorOwner; + if (drillDownCollectorManager != null) { + drillDownCollectorOwner = new CollectorOwner<>(drillDownCollectorManager); + } else { + drillDownCollectorOwner = null; + } - FacetsCollectorManager[] drillSidewaysFacetsCollectorManagers = - new FacetsCollectorManager[numDims]; + final List<CollectorOwner<?, ?>> drillSidewaysCollectorOwners = new ArrayList<>(numDims); for (int i = 0; i < numDims; i++) { - drillSidewaysFacetsCollectorManagers[i] = new FacetsCollectorManager(); + drillSidewaysCollectorOwners.add( + new CollectorOwner<>(createDrillSidewaysFacetsCollectorManager())); } DrillSidewaysQuery dsq = new DrillSidewaysQuery( baseQuery, - drillDownCollectorManager, - drillSidewaysFacetsCollectorManagers, + drillDownCollectorOwner, + drillSidewaysCollectorOwners, drillDownQueries, scoreSubDocsAtOnce()); searcher.search(dsq, hitCollector); FacetsCollector drillDownCollector; - if (drillDownCollectorManager != null) { - drillDownCollector = drillDownCollectorManager.reduce(dsq.managedDrillDownCollectors); + if (drillDownCollectorOwner != null) { + drillDownCollector = drillDownCollectorOwner.getResult(); } else { drillDownCollector = null; } - FacetsCollector[] drillSidewaysCollectors = new FacetsCollector[numDims]; - int numSlices = dsq.managedDrillSidewaysCollectors.size(); - + final String[] drillSidewaysDims = query.getDims().keySet().toArray(new String[0]); + final FacetsCollector[] drillSidewaysCollectors = new FacetsCollector[numDims]; for (int dim = 0; dim < numDims; dim++) { - List<FacetsCollector> facetsCollectorsForDim = new ArrayList<>(numSlices); - - for (int slice = 0; slice < numSlices; slice++) { - facetsCollectorsForDim.add(dsq.managedDrillSidewaysCollectors.get(slice)[dim]); - } - drillSidewaysCollectors[dim] = - drillSidewaysFacetsCollectorManagers[dim].reduce(facetsCollectorsForDim); + (FacetsCollector) drillSidewaysCollectorOwners.get(dim).getResult(); Review Comment: [nit] I think we can avoid casting here if we add types to `drillSidewaysCollectorOwners`, but given that this method is to be deprecated, I think it's fine to keep casting. ``` final List<CollectorOwner<FacetsCollector, FacetsCollector>> drillSidewaysCollectorOwners = ... ``` -- 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