public class Count extends BaseOperation<Pair<java.lang.Long[],Tuple>> implements Aggregator<Pair<java.lang.Long[],Tuple>>
Aggregator
that calculates the number of items in the current group.
Note the resulting value for count is always a long. So any comparisons should be against a long value.
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
FIELD_NAME
Field COUNT
|
fieldDeclaration, numArgs, trace
Constructor and Description |
---|
Count()
Constructor Count creates a new Count instance using the default field declaration of name 'count'.
|
Count(Fields fieldDeclaration)
Constructor Count creates a new Count instance and returns a field with the given fieldDeclaration name.
|
Modifier and Type | Method and Description |
---|---|
void |
aggregate(FlowProcess flowProcess,
AggregatorCall<Pair<java.lang.Long[],Tuple>> aggregatorCall)
Method aggregate is called for each
TupleEntry value in the current grouping. |
void |
complete(FlowProcess flowProcess,
AggregatorCall<Pair<java.lang.Long[],Tuple>> aggregatorCall)
Method complete will be issued last after every
TupleEntry has been passed to the
Aggregator.aggregate(cascading.flow.FlowProcess, AggregatorCall)
method. |
protected Tuple |
getResult(AggregatorCall<Pair<java.lang.Long[],Tuple>> aggregatorCall) |
void |
prepare(FlowProcess flowProcess,
OperationCall<Pair<java.lang.Long[],Tuple>> operationCall)
Method prepare does nothing, and may safely be overridden.
|
void |
start(FlowProcess flowProcess,
AggregatorCall<Pair<java.lang.Long[],Tuple>> aggregatorCall)
Method start initializes the aggregation procedure and is called for every unique grouping.
|
cleanup, equals, flush, getFieldDeclaration, getNumArgs, getTrace, hashCode, isSafe, printOperationInternal, toString, toStringInternal
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
cleanup, flush, getFieldDeclaration, getNumArgs, isSafe
public static final java.lang.String FIELD_NAME
public Count()
public void prepare(FlowProcess flowProcess, OperationCall<Pair<java.lang.Long[],Tuple>> operationCall)
BaseOperation
public void start(FlowProcess flowProcess, AggregatorCall<Pair<java.lang.Long[],Tuple>> aggregatorCall)
Aggregator
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.
start
in interface Aggregator<Pair<java.lang.Long[],Tuple>>
flowProcess
- of type FlowProcessaggregatorCall
- of type AggregatorCallpublic void aggregate(FlowProcess flowProcess, AggregatorCall<Pair<java.lang.Long[],Tuple>> 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<Pair<java.lang.Long[],Tuple>>
flowProcess
- of type FlowProcessaggregatorCall
- of type AggregatorCallpublic void complete(FlowProcess flowProcess, AggregatorCall<Pair<java.lang.Long[],Tuple>> 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<Pair<java.lang.Long[],Tuple>>
flowProcess
- of type FlowProcessaggregatorCall
- of type AggregatorCallprotected Tuple getResult(AggregatorCall<Pair<java.lang.Long[],Tuple>> aggregatorCall)
Copyright © 2007-2017 Cascading Maintainers. All Rights Reserved.