mirror of https://github.com/apache/lucene.git
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:
parent
3c065d3922
commit
0d8da94624
|
@ -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.
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue