Because the number of selected children of each node is restricted,
and not the overall number of nodes in the FacetResult, facets not selected
into FacetResult might have better values, or ordinals, (typically,
higher counts), than facets that are selected into the FacetResult.

Method Detail

fetchPartitionResult

Recursively explore all facets that can be potentially included in the
FacetResult to be generated, and that belong to the given
partition, so that values can be examined and collected. For each such
node, gather its top K (FacetRequest.getNumResults()) children
among its children that are encountered in the given particular partition
(aka current counting list).

arrays - the already filled in count array, potentially only covering
one partition: the ordinals ranging from

offset - to offset + the length of the count arrays
within arrays (exclusive)

Returns:

IntermediateFacetResult consisting of
IntToObjectMap that maps potential
FacetResult nodes to their top K children encountered in
the current partition. Note that the mapped potential tree nodes
need not belong to the given partition, only the top K children
mapped to. The aim is to identify nodes that are certainly excluded
from the FacetResult to be eventually (after going through
all the partitions) returned by this handler, because they have K
better siblings, already identified in this partition. For the
identified excluded nodes, we only count number of their
descendants in the subtree (to be included in
FacetResult.getNumValidDescendants()), but not bother with
selecting top K in these generations, which, by definition, are,
too, excluded from the FacetResult tree.

rearrangeFacetResult

Perform any rearrangement as required on a facet result that has changed after
it was rendered.

Possible use case: a sampling facets accumulator invoked another
other facets accumulator on a sample set of documents, obtained
rendered facet results, fixed their counts, and now it is needed
to sort the results differently according to the fixed counts.