public class MapReduceBuilder extends Object
Constructor and Description |
---|
MapReduceBuilder() |
MapReduceBuilder(RiakClient riak) |
Modifier and Type | Method and Description |
---|---|
void |
addRiakObject(String bucket,
String key)
Adds a Riak object (bucket name/key pair) to the map/reduce job as inputs
|
void |
clearRiakObjects()
Remove all Riak objects from the input list
|
String |
getBucket()
Gets the name of the Riak bucket the map/reduce job will process
|
RiakClient |
getRiakClient()
The
RiakClient to which this map reduce job will be submitted to
when submit() is called. |
Map<String,Set<String>> |
getRiakObjects()
Returns a copy of the Riak objects on the input list for a map/reduce job
|
String |
getSearch()
Gets the search query the map/reduce job will process
|
int |
getTimeout()
Gets the currently assigned timeout
|
MapReduceBuilder |
keyFilter(MapReduceFilter... filters)
Adds a map phase to the job
|
MapReduceBuilder |
link(String bucket,
boolean keep)
Adds a link phase to the job
|
MapReduceBuilder |
link(String bucket,
String tag,
boolean keep)
Adds a link phase to the job
|
MapReduceBuilder |
map(MapReduceFunction function,
boolean keep)
Adds a map phase to the job
|
MapReduceBuilder |
map(MapReduceFunction function,
Object arg,
boolean keep)
Adds a map phase to the job
|
MapReduceBuilder |
reduce(MapReduceFunction function,
boolean keep)
Adds a reduce phase to the job
|
MapReduceBuilder |
reduce(MapReduceFunction function,
Object arg,
boolean keep)
Adds a reduce phase to the job
|
void |
removeRiakObject(String bucket,
String key)
Removes a Riak object (bucket name/key pair) for the job's input list
|
MapReduceBuilder |
setBucket(String newBucket)
Sets the name of the Riak bucket the map/reduce job will process
|
MapReduceBuilder |
setRiakClient(RiakClient client) |
MapReduceBuilder |
setRiakObjects(Collection<RiakObject> objects) |
MapReduceBuilder |
setRiakObjects(Map<String,Set<String>> objects)
Sets a collection of Riak object (bucket name/key pair) as the map/reduce
job as inputs
|
MapReduceBuilder |
setSearch(String search)
Sets the search query the map/reduce job will process
|
void |
setTimeout(int timeout)
How long the map/reduce job is allowed to execute Time is in milliseconds
|
MapReduceResponse |
submit() |
MapReduceResponse |
submit(RequestMeta meta)
Submits the job to the Riak server
|
org.json.JSONObject |
toJSON()
Builds the JSON representation of a map/reduce job
|
public MapReduceBuilder(RiakClient riak)
riak
- RiakClient instance which is pointing to the map/reduce URLpublic MapReduceBuilder()
public RiakClient getRiakClient()
RiakClient
to which this map reduce job will be submitted to
when submit()
is called.public MapReduceBuilder setRiakClient(RiakClient client)
public String getBucket()
public MapReduceBuilder setBucket(String newBucket)
IllegalStateException
- - If objects have already been added to the jobpublic String getSearch()
public MapReduceBuilder setSearch(String search)
IllegalStateException
- - If objects or bucket has already been addedpublic void addRiakObject(String bucket, String key)
IllegalStateException
- - If a bucket name has already been set on the jobpublic void removeRiakObject(String bucket, String key)
public Map<String,Set<String>> getRiakObjects()
public MapReduceBuilder setRiakObjects(Map<String,Set<String>> objects)
IllegalStateException
- - If a bucket name has already been set on the jobpublic MapReduceBuilder setRiakObjects(Collection<RiakObject> objects)
public void clearRiakObjects()
public void setTimeout(int timeout)
public int getTimeout()
public MapReduceBuilder keyFilter(MapReduceFilter... filters)
function
- function to run for the phasekeep
- should the server keep and return the resultspublic MapReduceBuilder map(MapReduceFunction function, boolean keep)
function
- function to run for the phasekeep
- should the server keep and return the resultspublic MapReduceBuilder map(MapReduceFunction function, Object arg, boolean keep)
function
- function to run for the phasearg
- Static argument to pass to the function. Should be an
object easily converted to JSONkeep
- should the server keep and return the resultspublic MapReduceBuilder reduce(MapReduceFunction function, boolean keep)
function
- function to run for the phasekeep
- should the server keep and return the resultspublic MapReduceBuilder reduce(MapReduceFunction function, Object arg, boolean keep)
function
- function to run for the phasearg
- Static argument to pass to the function. Should be an
object easily converted to JSONkeep
- should the server keep and return the resultspublic MapReduceBuilder link(String bucket, boolean keep)
bucket
- bucket to link walkkeep
- should the server keep and return the resultspublic MapReduceBuilder link(String bucket, String tag, boolean keep)
bucket
- bucket to link walktag
- link tag to matchkeep
- should the server keep and return the resultspublic MapReduceResponse submit(RequestMeta meta)
meta
- Extra metadata to attach to the request such as HTTP headers
or query parameters.MapReduceResponse
containing job resultsIllegalStateException
- If this job has not been associated with a Riak instance by
calling setRiakClient(RiakClient)
RiakIORuntimeException
- If an error occurs during communication with the Riak server.RiakResponseRuntimeException
- If the Riak server returns a malformed response.public MapReduceResponse submit() throws org.json.JSONException
org.json.JSONException
public org.json.JSONObject toJSON()
Copyright © 2013. All Rights Reserved.