epotyom commented on code in PR #13568: URL: https://github.com/apache/lucene/pull/13568#discussion_r1694907952
########## lucene/sandbox/src/java/org/apache/lucene/sandbox/facet/FacetFieldCollectorManager.java: ########## @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.lucene.sandbox.facet; + +import java.io.IOException; +import java.util.Collection; +import org.apache.lucene.sandbox.facet.cutters.FacetCutter; +import org.apache.lucene.sandbox.facet.misc.FacetRollup; +import org.apache.lucene.sandbox.facet.recorders.FacetRecorder; +import org.apache.lucene.search.CollectorManager; + +/** + * Collector manager for {@link FacetFieldCollector}. Returns the same extension of {@link + * FacetRecorder} that was used to collect results. + */ +public final class FacetFieldCollectorManager<V extends FacetRecorder> + implements CollectorManager<FacetFieldCollector, V> { + + private final FacetCutter facetCutter; + private final V facetRecorder; + private final FacetRollup facetRollup; + + /** Create collector for a cutter + recorder pair */ + public FacetFieldCollectorManager( Review Comment: The issue with passing `FacetRollup` to `FacetRecorder`s directly is that users have to remember to pass it to all FacetRecorders that need it. If they don't, and the field requires rollup, recorder results will be incorrect. Ideally users don't have to know about rollup at all - it should happen automatically when it is required for the field. I initially implemented rollup as part of FacetCutter (which I think makes sense, as FacetCutter is what generates facet ordinals, it might as well generate ordinals for rollup?) But then there was some use case that made me think that it's better to have it as a separate interface, and propagate it to all recorders (in case MulitFacetRecorder is used) in FacetFieldCollectorManager. Unfortunately, I don't remember very well what was the use case. It might have been a performance issue. In Amazon we don't have fields that require rollup , and even just checking that rollup is not required might be expensive, as it requires iterating through all dimensions in a FacetsConfig? I'll experiment with `FacetFieldCollectorManager` getting rollup info from its `FacetCutter` and passing it to `FacetRecorder` instead of getting it as a separate constructor argument. We can add something like `forceDisableRollup` to `TaxonomyFacetCutter` that can be used in an "expert" mode, and all other users will have rollup enabled by default. WDYT? -- 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