StandardFacetsAccumulator (Lucene 3.6.2 API)
Keywords: org.apache.lucene.facet.search.StandardFacetsAccumulator class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.facet.search
Class StandardFacetsAccumulator

    java.lang.Object
      org.apache.lucene.facet.search.FacetsAccumulator
          org.apache.lucene.facet.search.StandardFacetsAccumulator

Direct Known Subclasses:
  AdaptiveFacetsAccumulator, SamplingAccumulator

    public class StandardFacetsAccumulator

extends FacetsAccumulator

Standard implementation for `FacetsAccumulator`, utilizing partitions to save on memory.

Why partitions? Because if there are say 100M categories out of which only top K are required, we must first compute value for all 100M categories (going over all documents) and only then could we select top K. This is made easier on memory by working in partitions of distinct categories: Once a values for a partition are found, we take the top K for that partition and work on the next partition, them merge the top K of both, and so forth, thereby computing top K with RAM needs for the size of a single partition rather than for the size of all the 100M categories.

Decision on partitions size is done at indexing time, and the facet information for each partition is maintained separately.

Implementation detail: Since facets information of each partition is maintained in a separate "category list", we can be more efficient at search time, because only the facet info for a single partition need to be read while processing that partition.

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

Field Summary
`protected FloatArrayAllocator` | `floatArrayAllocator`
`protected IntArrayAllocator` | `intArrayAllocator`
`protected boolean` | `isUsingComplements`
`protected int` | `maxPartitions`
`protected int` | `partitionSize`

Fields inherited from class org.apache.lucene.facet.search.FacetsAccumulator
`DEFAULT_COMPLEMENT_THRESHOLD, DISABLE_COMPLEMENT, FORCE_COMPLEMENT, indexReader, searchParams, taxonomyReader`

Constructor Summary
`StandardFacetsAccumulator(FacetSearchParams searchParams, org.apache.lucene.index.IndexReader indexReader, TaxonomyReader taxonomyReader)`
`StandardFacetsAccumulator(FacetSearchParams searchParams, org.apache.lucene.index.IndexReader indexReader, TaxonomyReader taxonomyReader, IntArrayAllocator intArrayAllocator, FloatArrayAllocator floatArrayAllocator)`

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 HashMap<CategoryListIterator,Aggregator>` | `getCategoryListMap(FacetArrays facetArrays, int partition)` Create an `Aggregator` and a `CategoryListIterator` for each and every `FacetRequest`.
`protected double` | `getTotalCountsFactor()` Expert: factor by which counts should be multiplied when initializing the count arrays from total counts.
`protected boolean` | `shouldComplement(ScoredDocIDs docids)` Check if it is worth to use complements

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`

Field Detail

### intArrayAllocator

    protected final IntArrayAllocator intArrayAllocator

### floatArrayAllocator

    protected final FloatArrayAllocator floatArrayAllocator

### partitionSize

    protected int partitionSize

### maxPartitions

    protected int maxPartitions

### isUsingComplements

    protected boolean isUsingComplements

Constructor Detail

### StandardFacetsAccumulator

    public StandardFacetsAccumulator(FacetSearchParams searchParams,
                                     org.apache.lucene.index.IndexReader indexReader,
                                     TaxonomyReader taxonomyReader,
                                     IntArrayAllocator intArrayAllocator,
                                     FloatArrayAllocator floatArrayAllocator)

### StandardFacetsAccumulator

    public StandardFacetsAccumulator(FacetSearchParams searchParams,
                                     org.apache.lucene.index.IndexReader indexReader,
                                     TaxonomyReader taxonomyReader)

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.

  Specified by:
    `accumulate` in class `FacetsAccumulator`
  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

  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

### 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

### 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`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD