cascading.operation.aggregator
Class ExtremaValueBase

java.lang.Object
  extended by cascading.operation.BaseOperation<ExtremaValueBase.Context>
      extended by cascading.operation.aggregator.ExtremaValueBase
All Implemented Interfaces:
DeclaresResults, Aggregator<ExtremaValueBase.Context>, Operation<ExtremaValueBase.Context>, Traceable, Serializable
Direct Known Subclasses:
MaxValue, MinValue

public abstract class ExtremaValueBase
extends BaseOperation<ExtremaValueBase.Context>
implements Aggregator<ExtremaValueBase.Context>

Class ExtremaValueBase is the base class for MaxValue and MinValue where the values are expected to by Comparable types and the Comparable.compareTo(Object) result is use for max/min comparison.

See Also:
Serialized Form

Nested Class Summary
protected static class ExtremaValueBase.Context
           
 
Field Summary
protected  Collection ignoreValues
          Field ignoreValues
 
Fields inherited from class cascading.operation.BaseOperation
fieldDeclaration, numArgs, trace
 
Fields inherited from interface cascading.operation.Operation
ANY
 
Constructor Summary
  ExtremaValueBase(Fields fieldDeclaration)
           
protected ExtremaValueBase(Fields fieldDeclaration, Object... ignoreValues)
           
  ExtremaValueBase(int numArgs, Fields fieldDeclaration)
           
 
Method Summary
 void aggregate(FlowProcess flowProcess, AggregatorCall<ExtremaValueBase.Context> aggregatorCall)
          Method aggregate is called for each TupleEntry value in the current grouping.
protected abstract  boolean compare(Comparable lhs, Comparable rhs)
          Allows subclasses to provide own comparison method.
 void complete(FlowProcess flowProcess, AggregatorCall<ExtremaValueBase.Context> aggregatorCall)
          Method complete will be issued last after every TupleEntry has been passed to the Aggregator.aggregate(cascading.flow.FlowProcess, AggregatorCall) method.
 boolean equals(Object object)
           
 Collection getIgnoreValues()
           
protected  Tuple getResult(AggregatorCall<ExtremaValueBase.Context> aggregatorCall)
           
 int hashCode()
           
 void prepare(FlowProcess flowProcess, OperationCall<ExtremaValueBase.Context> operationCall)
          Method prepare does nothing, and may safely be overridden.
 void start(FlowProcess flowProcess, AggregatorCall<ExtremaValueBase.Context> aggregatorCall)
          Method start initializes the aggregation procedure and is called for every unique grouping.
 
Methods inherited from class cascading.operation.BaseOperation
cleanup, flush, getFieldDeclaration, getNumArgs, getTrace, 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

ignoreValues

protected final Collection ignoreValues
Field ignoreValues

Constructor Detail

ExtremaValueBase

@ConstructorProperties(value="fieldDeclaration")
public ExtremaValueBase(Fields fieldDeclaration)

ExtremaValueBase

@ConstructorProperties(value={"numArgs","fieldDeclaration"})
public ExtremaValueBase(int numArgs,
                                                   Fields fieldDeclaration)

ExtremaValueBase

@ConstructorProperties(value={"fieldDeclaration","ignoreValues"})
protected ExtremaValueBase(Fields fieldDeclaration,
                                                      Object... ignoreValues)
Method Detail

getIgnoreValues

public Collection getIgnoreValues()

prepare

public void prepare(FlowProcess flowProcess,
                    OperationCall<ExtremaValueBase.Context> operationCall)
Description copied from class: BaseOperation
Method prepare does nothing, and may safely be overridden.

Specified by:
prepare in interface Operation<ExtremaValueBase.Context>
Overrides:
prepare in class BaseOperation<ExtremaValueBase.Context>

start

public void start(FlowProcess flowProcess,
                  AggregatorCall<ExtremaValueBase.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<ExtremaValueBase.Context>
Parameters:
flowProcess - of type FlowProcess
aggregatorCall - of type AggregatorCall

aggregate

public void aggregate(FlowProcess flowProcess,
                      AggregatorCall<ExtremaValueBase.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<ExtremaValueBase.Context>
Parameters:
flowProcess - of type FlowProcess
aggregatorCall - of type AggregatorCall

compare

protected abstract boolean compare(Comparable lhs,
                                   Comparable rhs)
Allows subclasses to provide own comparison method.

Parameters:
lhs - Comparable type
rhs - Comparable type
Returns:
true if the rhs should be retained as the result value

complete

public void complete(FlowProcess flowProcess,
                     AggregatorCall<ExtremaValueBase.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<ExtremaValueBase.Context>
Parameters:
flowProcess - of type FlowProcess
aggregatorCall - of type AggregatorCall

getResult

protected Tuple getResult(AggregatorCall<ExtremaValueBase.Context> aggregatorCall)

equals

public boolean equals(Object object)
Overrides:
equals in class BaseOperation<ExtremaValueBase.Context>

hashCode

public int hashCode()
Overrides:
hashCode in class BaseOperation<ExtremaValueBase.Context>


Copyright © 2007-2015 Concurrent, Inc. All Rights Reserved.