org.apache.lucene.facet.old
Class OldFacetsAccumulator

java.lang.Object
  extended by org.apache.lucene.facet.search.FacetsAccumulator
      extended by org.apache.lucene.facet.search.TaxonomyFacetsAccumulator
          extended by org.apache.lucene.facet.old.OldFacetsAccumulator
Direct Known Subclasses:
AdaptiveFacetsAccumulator, SamplingAccumulator, SamplingWrapper

public class OldFacetsAccumulator
extends TaxonomyFacetsAccumulator

A FacetsAccumulator which supports partitions, sampling and complement counting.

NOTE: this accumulator still uses the old API and will be removed eventually in favor of dedicated accumulators which support the above features ovee the new FacetsAggregator API. It provides Aggregator implementations for CountFacetRequest, SumScoreFacetRequest and Sampler.OverSampledFacetRequest. If you need to use it in conjunction with other facet requests, you should override createAggregator(FacetRequest, FacetArrays).

WARNING: This API is experimental and might change in incompatible ways in the next release.

Field Summary
static double DEFAULT_COMPLEMENT_THRESHOLD
          Default threshold for using the complements optimization.
static double DISABLE_COMPLEMENT
          Passing this to setComplementThreshold(double) will disable using complement optimization.
static double FORCE_COMPLEMENT
          Passing this to setComplementThreshold(double) will force using complement optimization.
protected  boolean isUsingComplements
           
protected  int maxPartitions
           
protected  int partitionSize
           
 
Fields inherited from class org.apache.lucene.facet.search.TaxonomyFacetsAccumulator
facetArrays, indexReader, taxonomyReader
 
Fields inherited from class org.apache.lucene.facet.search.FacetsAccumulator
searchParams
 
Constructor Summary
OldFacetsAccumulator(FacetSearchParams searchParams, IndexReader indexReader, TaxonomyReader taxonomyReader)
           
OldFacetsAccumulator(FacetSearchParams searchParams, IndexReader indexReader, TaxonomyReader taxonomyReader, FacetArrays facetArrays)
           
 
Method Summary
 List<FacetResult> accumulate(List<FacetsCollector.MatchingDocs> matchingDocs)
          Used by FacetsCollector to build the list of facet results that match the facet requests that were given in the constructor.
 List<FacetResult> accumulate(ScoredDocIDs docids)
           
protected  ScoredDocIDs actualDocsToAccumulate(ScoredDocIDs docids)
          Set the actual set of documents over which accumulation should take place.
protected  Aggregator createAggregator(FacetRequest fr, FacetArrays facetArrays)
           
 PartitionsFacetResultsHandler createFacetResultsHandler(FacetRequest fr, OrdinalValueResolver resolver)
          Creates a FacetResultsHandler that matches the given FacetRequest, using the OrdinalValueResolver.
 OrdinalValueResolver createOrdinalValueResolver(FacetRequest fr)
          Creates an OrdinalValueResolver for the given FacetRequest.
protected  HashMap<CategoryListIterator,Aggregator> getCategoryListMap(FacetArrays facetArrays, int partition)
          Create an Aggregator and a CategoryListIterator for each and every FacetRequest.
 double getComplementThreshold()
          Returns the complement threshold.
protected  double getTotalCountsFactor()
          Expert: factor by which counts should be multiplied when initializing the count arrays from total counts.
 boolean isUsingComplements()
          Returns true if complements are enabled.
protected  boolean mayComplement()
          check if all requests are complementable
 void setComplementThreshold(double complementThreshold)
          Set the complement threshold.
protected  boolean shouldComplement(ScoredDocIDs docids)
          Check if it is worth to use complements
 
Methods inherited from class org.apache.lucene.facet.search.TaxonomyFacetsAccumulator
getAggregator, groupRequests, requiresDocScores
 
Methods inherited from class org.apache.lucene.facet.search.FacetsAccumulator
create, create, emptyResult
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_COMPLEMENT_THRESHOLD

public static final double DEFAULT_COMPLEMENT_THRESHOLD
Default threshold for using the complements optimization. If accumulating facets for a document set larger than this ratio of the index size than perform the complement optimization.

See Also:
for more info on the complements optimization., Constant Field Values

DISABLE_COMPLEMENT

public static final double DISABLE_COMPLEMENT
Passing this to setComplementThreshold(double) will disable using complement optimization.

See Also:
Constant Field Values

FORCE_COMPLEMENT

public static final double FORCE_COMPLEMENT
Passing this to setComplementThreshold(double) will force using complement optimization.

See Also:
Constant Field Values

partitionSize

protected int partitionSize

maxPartitions

protected int maxPartitions

isUsingComplements

protected boolean isUsingComplements
Constructor Detail

OldFacetsAccumulator

public OldFacetsAccumulator(FacetSearchParams searchParams,
                            IndexReader indexReader,
                            TaxonomyReader taxonomyReader)

OldFacetsAccumulator

public OldFacetsAccumulator(FacetSearchParams searchParams,
                            IndexReader indexReader,
                            TaxonomyReader taxonomyReader,
                            FacetArrays facetArrays)
Method Detail

accumulate

public List<FacetResult> accumulate(ScoredDocIDs docids)
                             throws IOException
Throws:
IOException

mayComplement

protected boolean mayComplement()
check if all requests are complementable


createFacetResultsHandler

public PartitionsFacetResultsHandler createFacetResultsHandler(FacetRequest fr,
                                                               OrdinalValueResolver resolver)
Description copied from class: TaxonomyFacetsAccumulator
Creates a FacetResultsHandler that matches the given FacetRequest, using the OrdinalValueResolver.

Overrides:
createFacetResultsHandler in class TaxonomyFacetsAccumulator

actualDocsToAccumulate

protected ScoredDocIDs actualDocsToAccumulate(ScoredDocIDs docids)
                                       throws IOException
Set the actual set of documents over which accumulation should take place.

Allows to override the set of documents to accumulate for. Invoked just before actual accumulating starts. From this point that set of documents remains unmodified. Default implementation just returns the input unchanged.

Parameters:
docids - candidate documents to accumulate for
Returns:
actual documents to accumulate for
Throws:
IOException

shouldComplement

protected boolean shouldComplement(ScoredDocIDs docids)
Check if it is worth to use complements


createOrdinalValueResolver

public OrdinalValueResolver createOrdinalValueResolver(FacetRequest fr)
Creates an OrdinalValueResolver for the given FacetRequest. By default this method supports CountFacetRequest and SumScoreFacetRequest. You should override if you are using other requests with this accumulator.


getTotalCountsFactor

protected double getTotalCountsFactor()
Expert: factor by which counts should be multiplied when initializing the count arrays from total counts. Default implementation for this returns 1, which is a no op.

Returns:
a factor by which total counts should be multiplied

createAggregator

protected Aggregator createAggregator(FacetRequest fr,
                                      FacetArrays facetArrays)

getCategoryListMap

protected HashMap<CategoryListIterator,Aggregator> getCategoryListMap(FacetArrays facetArrays,
                                                                      int partition)
                                                               throws IOException
Create an Aggregator and a CategoryListIterator for each and every FacetRequest. Generating a map, matching each categoryListIterator to its matching aggregator.

If two CategoryListIterators are served by the same aggregator, a single aggregator is returned for both. NOTE: If a given category list iterator is needed with two different aggregators (e.g counting and association) - an exception is thrown as this functionality is not supported at this time.

Throws:
IOException

accumulate

public List<FacetResult> accumulate(List<FacetsCollector.MatchingDocs> matchingDocs)
                             throws IOException
Description copied from class: TaxonomyFacetsAccumulator
Used by FacetsCollector to build the list of facet results that match the facet requests that were given in the constructor.

Overrides:
accumulate in class TaxonomyFacetsAccumulator
Parameters:
matchingDocs - the documents that matched the query, per-segment.
Throws:
IOException

getComplementThreshold

public double getComplementThreshold()
Returns the complement threshold.

See Also:
setComplementThreshold(double)

setComplementThreshold

public void setComplementThreshold(double complementThreshold)
Set the complement threshold. This threshold will dictate whether the complements optimization is applied. The optimization is to count for less documents. It is useful when the same FacetSearchParams are used for varying sets of documents. The first time complements is used the "total counts" are computed - counting for all the documents in the collection. Then, only the complementing set of documents is considered, and used to decrement from the overall counts, thereby walking through less documents, which is faster.

For the default settings see DEFAULT_COMPLEMENT_THRESHOLD.

To forcing complements in all cases pass FORCE_COMPLEMENT. This is mostly useful for testing purposes, as forcing complements when only tiny fraction of available documents match the query does not make sense and would incur performance degradations.

To disable complements pass DISABLE_COMPLEMENT.

Parameters:
complementThreshold - the complement threshold to set
See Also:
getComplementThreshold()

isUsingComplements

public boolean isUsingComplements()
Returns true if complements are enabled.



Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.