GridGain™ 3.6.0e
Enterprise Edition

org.gridgain.grid.lang
Class GridReducer<E1,R>

java.lang.Object
  extended by org.gridgain.grid.lang.GridMetadataAwareAdapter
      extended by org.gridgain.grid.lang.GridLambdaAdapter
          extended by org.gridgain.grid.lang.GridOutClosure<R>
              extended by org.gridgain.grid.lang.GridReducer<E1,R>
Type Parameters:
E1 - Type of the free variable, i.e. the element the closure is called on.
R - Type of the closure's return value.
All Implemented Interfaces:
Serializable, Cloneable, Callable<R>, GridJob, GridMetadataAware, GridPeerDeployAware, GridLambda
Direct Known Subclasses:
GridReducerX, R1

public abstract class GridReducer<E1,R>
extends GridOutClosure<R>

Defines generic for-all or reduce type of closure. Unlike for-each type of closure that returns optional value on each execution of the closure - the reducer returns a single value for one or more collected values.

Closures are a first-class functions that are defined with (or closed over) their free variables that are bound to the closure scope at execution. Since Java 6 doesn't provide a language construct for first-class function the closures are implemented as abstract classes.

Thread Safety

Note that this interface does not impose or assume any specific thread-safety by its implementations. Each implementation can elect what type of thread-safety it provides, if any.

Wiki & Forum:


Wiki
Forum

See Also:
Serialized Form
 

Constructor Summary
GridReducer()
           
 
Method Summary
abstract  boolean collect(E1 e)
          Collects given value.
 GridOutClosure<R> curry(E1... e1)
          Curries this closure with given value.
<E2> GridReducer2<E1,E2,R>
uncurry2()
          Gets reducer that ignores its second argument passed to method GridReducer2.collect(Object, Object) and works as this reducer with just one first argument.
<E2,E3> GridReducer3<E1,E2,E3,R>
uncurry3()
          Gets reducer that ignores its second and third argument passed to method GridReducer3.collect(Object, Object, Object) and works as this reducer with just one first argument.
 
Methods inherited from class org.gridgain.grid.lang.GridOutClosure
andThen, andThen, apply, call, cancel, execute, uncurry, uncurry2, uncurry3
 
Methods inherited from class org.gridgain.grid.lang.GridLambdaAdapter
classLoader, deployClass, peerDeployLike, withMeta
 
Methods inherited from class org.gridgain.grid.lang.GridMetadataAwareAdapter
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, clone, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, readExternalMeta, removeMeta, removeMeta, replaceMeta, writeExternalMeta
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.gridgain.grid.GridMetadataAware
addMeta, addMetaIfAbsent, addMetaIfAbsent, allMeta, copyMeta, copyMeta, hasMeta, hasMeta, meta, putMetaIfAbsent, putMetaIfAbsent, removeMeta, removeMeta, replaceMeta
 

Constructor Detail

GridReducer

public GridReducer()
Method Detail

collect

public abstract boolean collect(E1 e)
Collects given value. All values will be reduced by GridOutClosure.apply() method.

Parameters:
e - Value to collect.
Returns:
true to continue collecting, false to instruct caller to stop collecting and call GridOutClosure.apply() method.

curry

public GridOutClosure<R> curry(E1... e1)
Curries this closure with given value. When result closure is called it will be executed with given value.

Parameters:
e1 - Values to curry with.
Returns:
Curried or partially applied closure with given value.

uncurry2

public <E2> GridReducer2<E1,E2,R> uncurry2()
Gets reducer that ignores its second argument passed to method GridReducer2.collect(Object, Object) and works as this reducer with just one first argument.

Type Parameters:
E2 - Type of 2nd argument that is ignored.
Returns:
Reducer that ignores its second argument passed to method GridReducer2.collect(Object, Object) and works as this reducer with just one first argument.

uncurry3

public <E2,E3> GridReducer3<E1,E2,E3,R> uncurry3()
Gets reducer that ignores its second and third argument passed to method GridReducer3.collect(Object, Object, Object) and works as this reducer with just one first argument.

Type Parameters:
E2 - Type of 2nd argument that is ignored.
E3 - Type of 3d argument that is ignored.
Returns:
Reducer that ignores its second and third argument passed to method GridReducer3.collect(Object, Object, Object) and works as this reducer with just one first argument.

GridGain™ 3.6.0e
Enterprise Edition

GridGain - Real Time Big Data
Enterprise Edition, ver. 3.6.0e.13012012
2012 Copyright © GridGain Systems
Follow us:   Follow GridGain on Github Follow GridGain on Facebook Join GridGain User Group Follow GridGain on Twitter Follow GridGain on YouTube