public class TopKInEachNodeHandler extends PartitionsFacetResultsHandler
FacetArraysaggregated for a particular
FacetRequest. The generated
FacetResultis a subtree of the taxonomy tree. Its root node,
FacetResult.getFacetResultNode(), is the facet specified by
FacetRequest.categoryPath, and the enumerated children,
FacetResultNode.subResults, of each node in that
FacetResultare the top K ( =
FacetRequest.numResults) among its children in the taxonomy. The depth (number of levels excluding the root) of the
FacetResulttree is specified by
Because the number of selected children of each node is restricted, and not
the overall number of nodes in the
FacetResult, facets not selected
FacetResult might have better values, or ordinals, (typically,
higher counts), than facets that are selected into the
FacetResult also provides with
FacetResult.getNumValidDescendants(), which returns the total number
of facets that are descendants of the root node, no deeper than
FacetRequest.getDepth(), and which have valid value. The rootnode
itself is not counted here. Valid value is determined by the
TopKInEachNodeHandler defines valid as
NOTE: this code relies on the assumption that
TaxonomyReader.INVALID_ORDINAL == -1, a smaller value than any valid
|Modifier and Type||Class and Description|
Maintains an array of
Intermediate result to hold counts from one or more partitions processed thus far.
|Constructor and Description|
|Modifier and Type||Method and Description|
Recursively explore all facets that can be potentially included in the
Merge several partitions'
Perform any rearrangement as required on a facet result that has changed after it was rendered.
Create a facet result from the temporary result.
public IntermediateFacetResult fetchPartitionResult(int offset) throws IOException
FacetResultto 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.numResults) children among its children that are encountered in the given particular partition (aka current counting list).
offset+ the length of the count arrays within
IntToObjectMapthat maps potential
FacetResultnodes 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
FacetResultto 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.
IOException- in case
public IntermediateFacetResult mergeResults(IntermediateFacetResult... tmpResults)
IntermediateFacetResult-s into one of the same format
tmpResults- one or more temporary results created by this handler.
public void labelResult(FacetResult facetResult) throws IOException
FacetRequest, such as
FacetRequest.getNumLabel(). Usually invoked by
public FacetResult rearrangeFacetResult(FacetResult facetResult)
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.
public FacetResult renderFacetResult(IntermediateFacetResult tmpResult) throws IOException
Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.