public abstract class Sampler extends Object
The Sampler uses TAKMI style counting to provide a 'best guess' top-K result set of the facets accumulated.
Note: Sampling accumulation (Accumulation over a sampled-set of the results),
does not guarantee accurate values for
FacetResult.getNumValidDescendants()
.
Modifier and Type | Class and Description |
---|---|
static class |
Sampler.SampleResult
Result of sample computation
|
Modifier and Type | Field and Description |
---|---|
protected SamplingParams |
samplingParams |
Constructor and Description |
---|
Sampler()
Construct with
SamplingParams |
Sampler(SamplingParams params)
Construct with certain
SamplingParams |
Modifier and Type | Method and Description |
---|---|
protected abstract Sampler.SampleResult |
createSample(ScoredDocIDs docids,
int actualSize,
int sampleSetSize)
Create and return a sample of the input set
|
SampleFixer |
getSampleFixer(IndexReader indexReader,
TaxonomyReader taxonomyReader,
FacetSearchParams searchParams)
Get a fixer of sample facet accumulation results.
|
Sampler.SampleResult |
getSampleSet(ScoredDocIDs docids)
Compute a sample set out of the input set, based on the
SamplingParams.getSampleRatio()
in effect. |
SamplingParams |
getSamplingParams()
Return the sampling params in effect
|
FacetSearchParams |
overSampledSearchParams(FacetSearchParams original)
Over-sampled search params, wrapping each request with an over-sampled one.
|
boolean |
shouldSample(ScoredDocIDs docIds)
Check if this sampler would complement for the input docIds
|
FacetResult |
trimResult(FacetResult facetResult)
Trim the input facet result.
Note: It is only valid to call this method with result obtained for a facet request created through overSampledSearchParams(FacetSearchParams) . |
protected final SamplingParams samplingParams
public Sampler()
SamplingParams
public Sampler(SamplingParams params) throws IllegalArgumentException
SamplingParams
params
- sampling params in effectIllegalArgumentException
- if the provided SamplingParams are not validpublic boolean shouldSample(ScoredDocIDs docIds)
public Sampler.SampleResult getSampleSet(ScoredDocIDs docids) throws IOException
SamplingParams.getSampleRatio()
in effect. Sub classes can override to alter how the sample set is
computed.
If the input set is of size smaller than SamplingParams.getMinSampleSize()
,
the input set is returned (no sampling takes place).
Other than that, the returned set size will not be larger than SamplingParams.getMaxSampleSize()
nor smaller than SamplingParams.getMinSampleSize()
.
docids
- full set of matching documents out of which a sample is needed.IOException
protected abstract Sampler.SampleResult createSample(ScoredDocIDs docids, int actualSize, int sampleSetSize) throws IOException
docids
- input set out of which a sample is to be createdactualSize
- original size of set, prior to samplingsampleSetSize
- required size of sample setIOException
public SampleFixer getSampleFixer(IndexReader indexReader, TaxonomyReader taxonomyReader, FacetSearchParams searchParams)
TakmiSampleFixer
which is adequate only for
counting. For any other accumulator, provide a different fixer.public final SamplingParams getSamplingParams()
public FacetResult trimResult(FacetResult facetResult) throws IllegalArgumentException
overSampledSearchParams(FacetSearchParams)
.IllegalArgumentException
- if called with results not obtained for requests created
through overSampledSearchParams(FacetSearchParams)
public FacetSearchParams overSampledSearchParams(FacetSearchParams original)
Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.