cascading.pipe.assembly
Class AverageBy.AverageFinal
java.lang.Object
cascading.operation.BaseOperation<AverageBy.AverageFinal.Context>
cascading.pipe.assembly.AverageBy.AverageFinal
- All Implemented Interfaces:
- DeclaresResults, Aggregator<AverageBy.AverageFinal.Context>, Operation<AverageBy.AverageFinal.Context>, Traceable, Serializable
- Enclosing class:
- AverageBy
public static class AverageBy.AverageFinal
- extends BaseOperation<AverageBy.AverageFinal.Context>
- implements Aggregator<AverageBy.AverageFinal.Context>
Class AverageFinal is used to finalize the average operation on the Reduce side of the process. It must be used
in tandem with a AverageBy.AveragePartials
Functor.
- See Also:
- Serialized Form
Fields inherited from interface cascading.operation.Operation |
ANY |
Constructor Summary |
AverageBy.AverageFinal(Fields fieldDeclaration)
Constructs a new instance that returns the average of the values encountered in the given fieldDeclaration field name. |
Methods inherited from class cascading.operation.BaseOperation |
cleanup, equals, flush, getFieldDeclaration, getNumArgs, getTrace, hashCode, isSafe, printOperationInternal, toString, toStringInternal |
AverageBy.AverageFinal
public AverageBy.AverageFinal(Fields fieldDeclaration)
- Constructs a new instance that returns the average of the values encountered in the given fieldDeclaration field name.
- Parameters:
fieldDeclaration
- of type Fields
prepare
public void prepare(FlowProcess flowProcess,
OperationCall<AverageBy.AverageFinal.Context> operationCall)
- Description copied from class:
BaseOperation
- Method prepare does nothing, and may safely be overridden.
- Specified by:
prepare
in interface Operation<AverageBy.AverageFinal.Context>
- Overrides:
prepare
in class BaseOperation<AverageBy.AverageFinal.Context>
start
public void start(FlowProcess flowProcess,
AggregatorCall<AverageBy.AverageFinal.Context> aggregatorCall)
- Description copied from interface:
Aggregator
- Method start initializes the aggregation procedure and is called for every unique grouping.
The AggregatorCall context should be initialized here if necessary.
The first time this method is called for a given 'process', the AggregatorCall context will be null. This method should
set a new instance of the user defined context object. When the AggregatorCall context is not null, it is up to
the developer to create a new instance, or 'recycle' the given instance. If recycled, it must be re-initialized to
remove any previous state/values.
For example, if a Map is used to hold the intermediate data for each subsequent
Aggregator.aggregate(cascading.flow.FlowProcess, AggregatorCall)
call,
new HashMap() should be set on the AggregatorCall instance when OperationCall.getContext()
is null.
On the next grouping, start() will be called again, but this time with the old Map instance. In this case,
map.clear() should be invoked before returning.
- Specified by:
start
in interface Aggregator<AverageBy.AverageFinal.Context>
- Parameters:
flowProcess
- of type FlowProcessaggregatorCall
- of type AggregatorCall
aggregate
public void aggregate(FlowProcess flowProcess,
AggregatorCall<AverageBy.AverageFinal.Context> aggregatorCall)
- Description copied from interface:
Aggregator
- Method aggregate is called for each
TupleEntry
value in the current grouping.
TupleEntry entry, or entry.getTuple() should not be stored directly in the context. A copy of the tuple
should be made via the new Tuple( entry.getTuple() )
copy constructor.
- Specified by:
aggregate
in interface Aggregator<AverageBy.AverageFinal.Context>
- Parameters:
flowProcess
- of type FlowProcessaggregatorCall
- of type AggregatorCall
complete
public void complete(FlowProcess flowProcess,
AggregatorCall<AverageBy.AverageFinal.Context> aggregatorCall)
- Description copied from interface:
Aggregator
- Method complete will be issued last after every
TupleEntry
has been passed to the
Aggregator.aggregate(cascading.flow.FlowProcess, AggregatorCall)
method. Any final calculation should be completed here and passed to the outputCollector.
- Specified by:
complete
in interface Aggregator<AverageBy.AverageFinal.Context>
- Parameters:
flowProcess
- of type FlowProcessaggregatorCall
- of type AggregatorCall
Copyright © 2007-2014 Concurrent, Inc. All Rights Reserved.