}
private List<FacetResult> accumulate() throws IOException {
// aggregate facets per category list (usually only one category list)
FacetsAggregator aggregator = getAggregator();
for (CategoryListParams clp : getCategoryLists()) {
for (MatchingDocs md : matchingDocs) {
aggregator.aggregate(md, clp, facetArrays);
}
}
ParallelTaxonomyArrays arrays = taxonomyReader.getParallelTaxonomyArrays();
// compute top-K
final int[] children = arrays.children();
final int[] siblings = arrays.siblings();
List<FacetResult> res = new ArrayList<>();
for (FacetRequest fr : searchParams.facetRequests) {
int rootOrd = taxonomyReader.getOrdinal(fr.categoryPath);
// category does not exist
if (rootOrd == TaxonomyReader.INVALID_ORDINAL) {
// Add empty FacetResult
res.add(emptyResult(rootOrd, fr));
continue;
}
CategoryListParams clp = searchParams.indexingParams.getCategoryListParams(fr.categoryPath);
// someone might ask to aggregate ROOT category
if (fr.categoryPath.length > 0) {
OrdinalPolicy ordinalPolicy = clp.getOrdinalPolicy(fr.categoryPath.components[0]);
if (ordinalPolicy == OrdinalPolicy.NO_PARENTS) {
// rollup values
aggregator.rollupValues(fr, rootOrd, children, siblings, facetArrays);
}
}
FacetResultsHandler frh = createFacetResultsHandler(fr);
res.add(frh.compute());