cascading.operation.buffer
Class FirstNBuffer

java.lang.Object
  extended by cascading.operation.BaseOperation
      extended by cascading.operation.buffer.FirstNBuffer
All Implemented Interfaces:
Buffer, Operation, Serializable

public class FirstNBuffer
extends BaseOperation
implements Buffer

Class FirstNBuffer will return the first N tuples seen in a given grouping. After the tuples are returned the Buffer stops iterating the arguments unlike the First Aggregator which by contract sees all the values in the grouping.

By default it returns one Tuple.

Order can be controlled through the prior GroupBy or CoGroup pipes.

This class is used by Unique.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class cascading.operation.BaseOperation
fieldDeclaration, numArgs, trace
 
Fields inherited from interface cascading.operation.Operation
ANY
 
Constructor Summary
FirstNBuffer()
          Selects and returns the first argument Tuple encountered.
FirstNBuffer(Fields fieldDeclaration)
          Selects and returns the first argument Tuple encountered.
FirstNBuffer(Fields fieldDeclaration, int firstN)
          Selects and returns the first N argument Tuples encountered.
FirstNBuffer(int firstN)
          Selects and returns the first N argument Tuples encountered.
 
Method Summary
 int getFirstN()
           
 void operate(FlowProcess flowProcess, BufferCall bufferCall)
          Method operate is called once for each grouping.
 
Methods inherited from class cascading.operation.BaseOperation
cleanup, equals, flush, getFieldDeclaration, getNumArgs, getTrace, hashCode, isSafe, prepare, 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, prepare
 

Constructor Detail

FirstNBuffer

public FirstNBuffer()
Selects and returns the first argument Tuple encountered.


FirstNBuffer

@ConstructorProperties(value="firstN")
public FirstNBuffer(int firstN)
Selects and returns the first N argument Tuples encountered.

Parameters:
firstN - of type int

FirstNBuffer

@ConstructorProperties(value="fieldDeclaration")
public FirstNBuffer(Fields fieldDeclaration)
Selects and returns the first argument Tuple encountered.

Parameters:
fieldDeclaration - of type Fields

FirstNBuffer

@ConstructorProperties(value={"fieldDeclaration","firstN"})
public FirstNBuffer(Fields fieldDeclaration,
                                               int firstN)
Selects and returns the first N argument Tuples encountered.

Parameters:
fieldDeclaration - of type Fields
firstN - of type int
Method Detail

getFirstN

public int getFirstN()

operate

public void operate(FlowProcess flowProcess,
                    BufferCall bufferCall)
Description copied from interface: Buffer
Method operate is called once for each grouping. BufferCall passes in an Iterator that returns an argument TupleEntry for each value in the grouping defined by the argument selector on the parent Every pipe instance.

TupleEntry entry, or entry.getTuple() should not be stored directly in a collection or modified. A copy of the tuple should be made via the new Tuple( entry.getTuple() ) copy constructor.

This method is called for every unique group, whether or not there are values in the arguments Iterator.

Specified by:
operate in interface Buffer
Parameters:
flowProcess - of type FlowProcess
bufferCall - of type BufferCall


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