LUCENE-4831: Association facets aggregators should not support rollupValues

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1456653 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shai Erera 2013-03-14 20:21:01 +00:00
parent 3c065d3922
commit 0d8da94624
2 changed files with 13 additions and 32 deletions

View File

@ -7,7 +7,6 @@ import org.apache.lucene.facet.search.FacetArrays;
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 @@ import org.apache.lucene.util.BytesRef;
* 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}.
* <p>
* <b>NOTE:</b> 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 @@ public class SumFloatAssociationFacetsAggregator implements FacetsAggregator {
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.
}
}

View File

@ -7,7 +7,6 @@ import org.apache.lucene.facet.search.FacetArrays;
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 @@ import org.apache.lucene.util.BytesRef;
/**
* 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}.
* <p>
* <b>NOTE:</b> 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 @@ public class SumIntAssociationFacetsAggregator implements FacetsAggregator {
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.
}
}