public class ReductionCollectionManager extends Object
ReductionDataCollector
s which will be updated together.
The manager assumes a non-distributed request. MergingReductionCollectionManager
is used for distributed requests.
Modifier and Type | Class and Description |
---|---|
static class |
ReductionCollectionManager.ReductionDataCollection
Holds the collection of
ReductionData that will be updated together. |
Modifier and Type | Field and Description |
---|---|
protected ReductionDataCollector<?>[] |
reductionDataCollectors |
Constructor and Description |
---|
ReductionCollectionManager() |
ReductionCollectionManager(ReductionDataCollector<?>[] reductionDataCollectors,
Iterable<AnalyticsField> fields)
Create a Manager to oversee the given
ReductionDataCollector s. |
Modifier and Type | Method and Description |
---|---|
void |
addCollectTarget(ReductionCollectionManager.ReductionDataCollection target)
Add a
ReductionCollectionManager.ReductionDataCollection to target while collecting the next document. |
void |
addLastingCollectTarget(ReductionCollectionManager.ReductionDataCollection target)
Add a
ReductionCollectionManager.ReductionDataCollection to target while collecting documents. |
void |
apply()
Apply the values of the collected fields through the expressions' logic to the managed data collectors.
|
void |
clearLastingCollectTargets()
Clear lasting collection targets.
|
void |
collect(int doc)
Collect the values from the used
AnalyticsField s. |
protected ReductionCollectionManager |
createNewManager(ReductionDataCollector<?>[] reductionDataCollectors,
Iterable<AnalyticsField> fields)
Create an
ReductionCollectionManager to manage the given collectors and fields. |
void |
doSetNextReader(LeafReaderContext context)
Set the context of the readers of the used
AnalyticsField s. |
void |
exportData()
Export the data from the set IO data collectors to the given shard output stream.
|
Iterable<AnalyticsField> |
getUsedFields()
Get the
AnalyticsField s used in the managed expressions. |
ReductionCollectionManager |
merge(Iterable<ReductionCollectionManager> reductionManagers)
Merge this collection manager with others.
|
void |
mergeData()
Merge the data from the given shard input stream into the set IO data collectors.
|
boolean |
needsCollection()
Return whether or not the manager needs collection done, which is false if no collectors are
being managed and true if at least one is.
|
ReductionCollectionManager.ReductionDataCollection |
newDataCollection()
Construct a new data collection holding data for all managed data collectors.
|
ReductionCollectionManager.ReductionDataCollection |
newDataCollectionIO()
Create a new
ReductionCollectionManager.ReductionDataCollection to merge to or export from. |
ReductionCollectionManager.ReductionDataCollection |
newDataCollectionTarget()
Add a new
ReductionCollectionManager.ReductionDataCollection to target while collecting the next document. |
void |
prepareReductionDataIO(ReductionCollectionManager.ReductionDataCollection col)
Set the given data collection to be used for either merging or exporting
|
void |
setData(ReductionCollectionManager.ReductionDataCollection dataCollection)
Finalize the reductions with the collected data stored in the parameter.
|
void |
setShardInput(DataInput input)
Sets the stream of shard data to merge with.
|
void |
setShardOutput(DataOutput output)
Sets the stream to export shard data to.
|
protected final ReductionDataCollector<?>[] reductionDataCollectors
public ReductionCollectionManager()
public ReductionCollectionManager(ReductionDataCollector<?>[] reductionDataCollectors, Iterable<AnalyticsField> fields)
ReductionDataCollector
s.reductionDataCollectors
- array of collectors that are collecting over the same set of datafields
- all fields used by the given collectorspublic boolean needsCollection()
public ReductionCollectionManager merge(Iterable<ReductionCollectionManager> reductionManagers)
reductionManagers
- the collection managers to merge withprotected ReductionCollectionManager createNewManager(ReductionDataCollector<?>[] reductionDataCollectors, Iterable<AnalyticsField> fields)
ReductionCollectionManager
to manage the given collectors and fields.reductionDataCollectors
- Reduction collectorsfields
- fields used by the reductionspublic Iterable<AnalyticsField> getUsedFields()
AnalyticsField
s used in the managed expressions.public void doSetNextReader(LeafReaderContext context) throws IOException
AnalyticsField
s.context
- the reader contextIOException
- if an error occurs while setting the fields' contextpublic void collect(int doc) throws IOException
AnalyticsField
s.doc
- the document to collect values forIOException
- if an error occurs during field collectionpublic void addLastingCollectTarget(ReductionCollectionManager.ReductionDataCollection target)
ReductionCollectionManager.ReductionDataCollection
to target while collecting documents.
This target is valid until the lasting targets are cleared.target
- data collection to add document data toopublic void clearLastingCollectTargets()
public ReductionCollectionManager.ReductionDataCollection newDataCollectionTarget()
ReductionCollectionManager.ReductionDataCollection
to target while collecting the next document.
This target is only valid for the next apply()
call.public void addCollectTarget(ReductionCollectionManager.ReductionDataCollection target)
ReductionCollectionManager.ReductionDataCollection
to target while collecting the next document.
This target is only valid for the next apply()
call.target
- data collection to add document data toopublic void apply()
collect(int)
has been called and the collection targets have been added.public void setData(ReductionCollectionManager.ReductionDataCollection dataCollection)
ReductionFunction
s that use these
ReductionDataCollector
s act like regular AnalyticsValue
classes that
can be accessed through their get<value-type>
methods.dataCollection
- the collection of reduction data to compute results forpublic ReductionCollectionManager.ReductionDataCollection newDataCollection()
public void setShardInput(DataInput input)
input
- the stream of shard datapublic void mergeData() throws IOException
setShardInput(DataInput)
and either prepareReductionDataIO(ReductionDataCollection)
or newDataCollectionIO()
have been called.IOException
- if an error occurs while reading the shard datapublic void setShardOutput(DataOutput output)
output
- the stream of shard datapublic void exportData() throws IOException
setShardOutput(DataOutput)
and prepareReductionDataIO(ReductionDataCollection)
.IOException
- if an error occurs while writing the shard datapublic void prepareReductionDataIO(ReductionCollectionManager.ReductionDataCollection col)
col
- collection to export from or merge topublic ReductionCollectionManager.ReductionDataCollection newDataCollectionIO()
ReductionCollectionManager.ReductionDataCollection
to merge to or export from.
Mainly used for creating facet value collectors when merging shard data.Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.