org.apache.lucene.facet.search.sampling
Class SamplingAccumulator

java.lang.Object
  extended by org.apache.lucene.facet.search.FacetsAccumulator
      extended by org.apache.lucene.facet.search.StandardFacetsAccumulator
          extended by org.apache.lucene.facet.search.sampling.SamplingAccumulator

public class SamplingAccumulator
extends StandardFacetsAccumulator

Facets accumulation with sampling.

Note two major differences between this class and SamplingWrapper:

  1. Latter can wrap any other FacetsAccumulator while this class directly extends StandardFacetsAccumulator.
  2. This class can effectively apply sampling on the complement set of matching document, thereby working efficiently with the complement optimization - see FacetsAccumulator.getComplementThreshold().

Note: Sampling accumulation (Accumulation over a sampled-set of the results), does not guarantee accurate values for FacetResult.getNumValidDescendants() & FacetResultNode.getResidue().

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

Field Summary
 
Fields inherited from class org.apache.lucene.facet.search.StandardFacetsAccumulator
floatArrayAllocator, intArrayAllocator, isUsingComplements, maxPartitions, partitionSize
 
Fields inherited from class org.apache.lucene.facet.search.FacetsAccumulator
DEFAULT_COMPLEMENT_THRESHOLD, DISABLE_COMPLEMENT, FORCE_COMPLEMENT, indexReader, searchParams, taxonomyReader
 
Constructor Summary
SamplingAccumulator(Sampler sampler, FacetSearchParams searchParams, IndexReader indexReader, TaxonomyReader taxonomyReader)
          Constructor...
SamplingAccumulator(Sampler sampler, FacetSearchParams searchParams, IndexReader indexReader, TaxonomyReader taxonomyReader, IntArrayAllocator intArrayAllocator, FloatArrayAllocator floatArrayAllocator)
          Constructor...
 
Method Summary
 List<FacetResult> accumulate(ScoredDocIDs docids)
          Accumulate facets over given documents, according to facet requests in effect.
protected  ScoredDocIDs actualDocsToAccumulate(ScoredDocIDs docids)
          Set the actual set of documents over which accumulation should take place.
protected  double getTotalCountsFactor()
          Expert: factor by which counts should be multiplied when initializing the count arrays from total counts.
 
Methods inherited from class org.apache.lucene.facet.search.StandardFacetsAccumulator
getCategoryListMap, shouldComplement
 
Methods inherited from class org.apache.lucene.facet.search.FacetsAccumulator
getComplementThreshold, isAllowLabeling, mayComplement, setAllowLabeling, setComplementThreshold
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SamplingAccumulator

public SamplingAccumulator(Sampler sampler,
                           FacetSearchParams searchParams,
                           IndexReader indexReader,
                           TaxonomyReader taxonomyReader,
                           IntArrayAllocator intArrayAllocator,
                           FloatArrayAllocator floatArrayAllocator)
Constructor...


SamplingAccumulator

public SamplingAccumulator(Sampler sampler,
                           FacetSearchParams searchParams,
                           IndexReader indexReader,
                           TaxonomyReader taxonomyReader)
Constructor...

Method Detail

accumulate

public List<FacetResult> accumulate(ScoredDocIDs docids)
                             throws IOException
Description copied from class: FacetsAccumulator
Accumulate facets over given documents, according to facet requests in effect.

Overrides:
accumulate in class StandardFacetsAccumulator
Parameters:
docids - documents (and their scores) for which facets are Accumulated.
Returns:
Accumulated facets.
Throws:
IOException - on error.

actualDocsToAccumulate

protected ScoredDocIDs actualDocsToAccumulate(ScoredDocIDs docids)
                                       throws IOException
Description copied from class: StandardFacetsAccumulator
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.

Overrides:
actualDocsToAccumulate in class StandardFacetsAccumulator
Parameters:
docids - candidate documents to accumulate for
Returns:
actual documents to accumulate for
Throws:
IOException

getTotalCountsFactor

protected double getTotalCountsFactor()
Description copied from class: StandardFacetsAccumulator
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.

Overrides:
getTotalCountsFactor in class StandardFacetsAccumulator
Returns:
a factor by which total counts should be multiplied