Index: lucene/facet/src/java/org/apache/lucene/facet/associations/SumFloatAssociationFacetsAggregator.java =================================================================== --- lucene/facet/src/java/org/apache/lucene/facet/associations/SumFloatAssociationFacetsAggregator.java (revision 1456396) +++ lucene/facet/src/java/org/apache/lucene/facet/associations/SumFloatAssociationFacetsAggregator.java (working copy) @@ -7,7 +7,6 @@ import org.apache.lucene.facet.search.FacetRequest; import org.apache.lucene.facet.search.FacetsAggregator; import org.apache.lucene.facet.search.FacetsCollector.MatchingDocs; -import org.apache.lucene.facet.taxonomy.TaxonomyReader; import org.apache.lucene.index.BinaryDocValues; import org.apache.lucene.util.BytesRef; @@ -32,6 +31,10 @@ * A {@link FacetsAggregator} which computes the weight of a category as the sum * of the float values associated with it in the result documents. Assumes that * the association encoded for each ordinal is {@link CategoryFloatAssociation}. + *
+ * NOTE: this aggregator does not support + * {@link #rollupValues(FacetRequest, int, int[], int[], FacetArrays)}. It only + * aggregates the categories for which you added a {@link CategoryAssociation}. * * @lucene.experimental */ @@ -77,22 +80,9 @@ return false; } - private float rollupValues(int ordinal, int[] children, int[] siblings, float[] scores) { - float Value = 0f; - while (ordinal != TaxonomyReader.INVALID_ORDINAL) { - float childValue = scores[ordinal]; - childValue += rollupValues(children[ordinal], children, siblings, scores); - scores[ordinal] = childValue; - Value += childValue; - ordinal = siblings[ordinal]; - } - return Value; - } - @Override public void rollupValues(FacetRequest fr, int ordinal, int[] children, int[] siblings, FacetArrays facetArrays) { - float[] values = facetArrays.getFloatArray(); - values[ordinal] += rollupValues(children[ordinal], children, siblings, values); + // NO-OP: this aggregator does no rollup values to the parents. } } Index: lucene/facet/src/java/org/apache/lucene/facet/associations/SumIntAssociationFacetsAggregator.java =================================================================== --- lucene/facet/src/java/org/apache/lucene/facet/associations/SumIntAssociationFacetsAggregator.java (revision 1456396) +++ lucene/facet/src/java/org/apache/lucene/facet/associations/SumIntAssociationFacetsAggregator.java (working copy) @@ -7,7 +7,6 @@ import org.apache.lucene.facet.search.FacetRequest; import org.apache.lucene.facet.search.FacetsAggregator; import org.apache.lucene.facet.search.FacetsCollector.MatchingDocs; -import org.apache.lucene.facet.taxonomy.TaxonomyReader; import org.apache.lucene.index.BinaryDocValues; import org.apache.lucene.util.BytesRef; @@ -30,8 +29,13 @@ /** * A {@link FacetsAggregator} which computes the weight of a category as the sum - * of the integer values associated with it in the result documents. Assumes that - * the association encoded for each ordinal is {@link CategoryIntAssociation}. + * of the integer values associated with it in the result documents. Assumes + * that the association encoded for each ordinal is + * {@link CategoryIntAssociation}. + *
+ * NOTE: this aggregator does not support + * {@link #rollupValues(FacetRequest, int, int[], int[], FacetArrays)}. It only + * aggregates the categories for which you added a {@link CategoryAssociation}. */ public class SumIntAssociationFacetsAggregator implements FacetsAggregator { @@ -75,22 +79,9 @@ return false; } - private float rollupValues(int ordinal, int[] children, int[] siblings, float[] scores) { - float Value = 0f; - while (ordinal != TaxonomyReader.INVALID_ORDINAL) { - float childValue = scores[ordinal]; - childValue += rollupValues(children[ordinal], children, siblings, scores); - scores[ordinal] = childValue; - Value += childValue; - ordinal = siblings[ordinal]; - } - return Value; - } - @Override public void rollupValues(FacetRequest fr, int ordinal, int[] children, int[] siblings, FacetArrays facetArrays) { - float[] values = facetArrays.getFloatArray(); - values[ordinal] += rollupValues(children[ordinal], children, siblings, values); + // NO-OP: this aggregator does no rollup values to the parents. } }