com.basho.riak.client.query
Class MapReduce

java.lang.Object
  extended by com.basho.riak.client.query.MapReduce
All Implemented Interfaces:
RiakOperation<MapReduceResult>
Direct Known Subclasses:
BucketKeyMapReduce, BucketMapReduce, IndexMapReduce, SearchMapReduce

public abstract class MapReduce
extends Object
implements RiakOperation<MapReduceResult>

An operation for defining and runnig a Map/Reduce query on Riak.

See Map/Reduce for details.

Author:
russell
See Also:
IRiakClient.mapReduce(), IRiakClient.mapReduce(String)

Constructor Summary
MapReduce(RawClient client)
          Create the MapRedcue operation with the RawClient to delegate to.
 
Method Summary
 MapReduce addLinkPhase(String bucket, String tag)
          Create a Link Phase that points to bucket / tag keep will be false
 MapReduce addLinkPhase(String bucket, String tag, boolean keep)
          Add a Link Phase that points to bucket / tag .
 MapReduce addMapPhase(Function phaseFunction)
          Add a MapPhase
 MapReduce addMapPhase(Function phaseFunction, boolean keep)
          Add MapPhase to the query
 MapReduce addMapPhase(Function phaseFunction, Object arg)
          Add a MapPhase
 MapReduce addMapPhase(Function phaseFunction, Object arg, boolean keep)
          Add a MapPhase
 MapReduce addReducePhase(Function phaseFunction)
          Add a ReducePhase
 MapReduce addReducePhase(Function phaseFunction, boolean keep)
          Add ReducePhase to the query
 MapReduce addReducePhase(Function phaseFunction, Object arg)
          Add a ReducePhase
 MapReduce addReducePhase(Function phaseFunction, Object arg, boolean keep)
          Add a ReducePhase
 MapReduceResult execute()
          Run the Map/Reduce job against the RawClient the operation was constructed with.
 MapReduce timeout(long timeout)
          Set the operations timeout
protected  void validate()
          Check that this map/reduce job is valid
protected abstract  void writeInput(org.codehaus.jackson.JsonGenerator jsonGenerator)
          Override to write the input specification of the M/R job.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MapReduce

public MapReduce(RawClient client)
Create the MapRedcue operation with the RawClient to delegate to.

Parameters:
client - a RawClient
See Also:
IRiakClient.mapReduce(), IRiakClient.mapReduce(String)
Method Detail

execute

public MapReduceResult execute()
                        throws RiakException
Run the Map/Reduce job against the RawClient the operation was constructed with.

Specified by:
execute in interface RiakOperation<MapReduceResult>
Returns:
a MapReduceResult containing the results of the query.
Throws:
RiakException
InvalidMapReduceException

validate

protected void validate()
Check that this map/reduce job is valid

Throws:
InvalidMapReduceException

timeout

public MapReduce timeout(long timeout)
Set the operations timeout

Parameters:
timeout -
Returns:
this

addMapPhase

public MapReduce addMapPhase(Function phaseFunction,
                             boolean keep)
Add MapPhase to the query

Parameters:
phaseFunction - the Function
keep - keep the results and return them with the query results?
Returns:
this

addMapPhase

public MapReduce addMapPhase(Function phaseFunction,
                             Object arg,
                             boolean keep)
Add a MapPhase

Parameters:
phaseFunction - the Function
arg - an argument that will be passed to the phase verbatim (Object#toString)
keep - if the result should be returned or merely provide input for the next phase.
Returns:
this

addMapPhase

public MapReduce addMapPhase(Function phaseFunction,
                             Object arg)
Add a MapPhase

Parameters:
phaseFunction - the Function
arg - an argument that will be passed to the phase verbatim (Object#toString)
Returns:
this

addMapPhase

public MapReduce addMapPhase(Function phaseFunction)
Add a MapPhase

Parameters:
phaseFunction - the Function
Returns:
this

addReducePhase

public MapReduce addReducePhase(Function phaseFunction,
                                boolean keep)
Add ReducePhase to the query

Parameters:
phaseFunction - the Function
keep - keep the results and return them with the query results?
Returns:
this

addReducePhase

public MapReduce addReducePhase(Function phaseFunction,
                                Object arg,
                                boolean keep)
Add a ReducePhase

Parameters:
phaseFunction - the Function
arg - an argument that will be passed to the phase verbatim (Object#toString)
keep - if the result should be returned or merely provide input for the next phase.
Returns:
this

addReducePhase

public MapReduce addReducePhase(Function phaseFunction,
                                Object arg)
Add a ReducePhase

Parameters:
phaseFunction - the Function
arg - an argument that will be passed to the phase verbatim
Returns:
this

addReducePhase

public MapReduce addReducePhase(Function phaseFunction)
Add a ReducePhase

Parameters:
phaseFunction -
Returns:
this

addLinkPhase

public MapReduce addLinkPhase(String bucket,
                              String tag,
                              boolean keep)
Add a Link Phase that points to bucket / tag .

Parameters:
bucket - the bucket at the end of the link (or "_" or "" for wildcard)
tag - the tag (or ("_", or "" for wildcard)
keep - to keep the result of this phase and return it at the end of the operation

addLinkPhase

public MapReduce addLinkPhase(String bucket,
                              String tag)
Create a Link Phase that points to bucket / tag keep will be false

Parameters:
bucket - the bucket at the end of the link (or "_" or "" for wildcard)
tag - the tag (or ("_", or "" for wildcard)

writeInput

protected abstract void writeInput(org.codehaus.jackson.JsonGenerator jsonGenerator)
                            throws IOException
Override to write the input specification of the M/R job.

Parameters:
jsonGenerator - a Jackson JsonGenerator to write the input spec to
Throws:
IOException


Copyright © 2012. All Rights Reserved.