|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cascading.operation.BaseOperation<Average.Context> cascading.operation.aggregator.Average
public class Average
Class Average is an Aggregator
that returns the average of all numeric values in the current group.
Nested Class Summary | |
---|---|
protected static class |
Average.Context
Class Context is used to hold intermediate values. |
Field Summary | |
---|---|
static String |
FIELD_NAME
Field FIELD_NAME |
Fields inherited from class cascading.operation.BaseOperation |
---|
fieldDeclaration, numArgs, trace |
Fields inherited from interface cascading.operation.Operation |
---|
ANY |
Constructor Summary | |
---|---|
Average()
Constructs a new instance that returns the average of the values encountered in the field name "average". |
|
Average(Fields fieldDeclaration)
Constructs a new instance that returns the average of the values encountered in the given fieldDeclaration field name. |
Method Summary | |
---|---|
void |
aggregate(FlowProcess flowProcess,
AggregatorCall<Average.Context> aggregatorCall)
Method aggregate is called for each TupleEntry value in the current grouping. |
void |
complete(FlowProcess flowProcess,
AggregatorCall<Average.Context> aggregatorCall)
Method complete will be issued last after every TupleEntry has been passed to the
Aggregator.aggregate(cascading.flow.FlowProcess, AggregatorCall)
method. |
void |
prepare(FlowProcess flowProcess,
OperationCall<Average.Context> operationCall)
Method prepare does nothing, and may safely be overridden. |
void |
start(FlowProcess flowProcess,
AggregatorCall<Average.Context> aggregatorCall)
Method start initializes the aggregation procedure and is called for every unique grouping. |
Methods inherited from class cascading.operation.BaseOperation |
---|
cleanup, equals, flush, getFieldDeclaration, getNumArgs, getTrace, hashCode, isSafe, printOperationInternal, toString, toStringInternal |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface cascading.operation.Operation |
---|
cleanup, flush, getFieldDeclaration, getNumArgs, isSafe |
Field Detail |
---|
public static final String FIELD_NAME
Constructor Detail |
---|
public Average()
@ConstructorProperties(value="fieldDeclaration") public Average(Fields fieldDeclaration)
fieldDeclaration
- of type FieldsMethod Detail |
---|
public void prepare(FlowProcess flowProcess, OperationCall<Average.Context> operationCall)
BaseOperation
prepare
in interface Operation<Average.Context>
prepare
in class BaseOperation<Average.Context>
public void start(FlowProcess flowProcess, AggregatorCall<Average.Context> aggregatorCall)
Aggregator
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.
start
in interface Aggregator<Average.Context>
flowProcess
- of type FlowProcessaggregatorCall
- of type AggregatorCallpublic void aggregate(FlowProcess flowProcess, AggregatorCall<Average.Context> aggregatorCall)
Aggregator
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.
aggregate
in interface Aggregator<Average.Context>
flowProcess
- of type FlowProcessaggregatorCall
- of type AggregatorCallpublic void complete(FlowProcess flowProcess, AggregatorCall<Average.Context> aggregatorCall)
Aggregator
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.
complete
in interface Aggregator<Average.Context>
flowProcess
- of type FlowProcessaggregatorCall
- of type AggregatorCall
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |