com.mongodb
Class MapReduceCommand

java.lang.Object
  extended by com.mongodb.MapReduceCommand

public class MapReduceCommand
extends Object

This class groups the argument for a map/reduce operation and can build the underlying command object


MongoDB Doc Links

Nested Class Summary
static class MapReduceCommand.OutputType
          INLINE - Return results inline, no result is written to the DB server REPLACE - Save the job output to a collection, replacing its previous content MERGE - Merge the job output with the existing contents of outputTarget collection REDUCE - Reduce the job output with the existing contents of outputTarget collection
 
Constructor Summary
MapReduceCommand(DBCollection inputCollection, String map, String reduce, String outputCollection, MapReduceCommand.OutputType type, DBObject query)
          Represents the command for a map reduce operation Runs the command in REPLACE output type to a named collection
 
Method Summary
 void addExtraOption(String name, Object value)
           
 DBObject getExtraOptions()
           
 String getFinalize()
          Gets the Finalize JS Function
 String getInput()
          Get the name of the collection the MapReduce will read from
 int getLimit()
          Gets the (optional) limit on input
 String getMap()
          Get the map function, as a JS String
 String getOutputTarget()
          Gets the output target (name of collection to save to) This value is nullable only if OutputType is set to INLINE
 MapReduceCommand.OutputType getOutputType()
          Gets the OutputType for this instance.
 DBObject getQuery()
          Gets the query to run for this MapReduce job
 String getReduce()
          Gets the reduce function, as a JS String
 Map<String,Object> getScope()
          Gets the (optional) JavaScript scope
 DBObject getSort()
          Gets the (optional) sort specification object
 Boolean isVerbose()
          Gets the verbosity of the MapReduce job.
 void setFinalize(String finalize)
          Sets the Finalize JS Function
 void setLimit(int limit)
          Sets the (optional) limit on input
 void setOutputDB(String outputDB)
          Sets the (optional) database name where the output collection should reside
 void setScope(Map<String,Object> scope)
          Sets the (optional) JavaScript scope
 void setSort(DBObject sort)
          Sets the (optional) sort specification object
 void setVerbose(Boolean verbose)
          Sets the verbosity of the MapReduce job, defaults to 'true'
 DBObject toDBObject()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MapReduceCommand

public MapReduceCommand(DBCollection inputCollection,
                        String map,
                        String reduce,
                        String outputCollection,
                        MapReduceCommand.OutputType type,
                        DBObject query)
                 throws MongoException
Represents the command for a map reduce operation Runs the command in REPLACE output type to a named collection

Parameters:
inputCollection - the collection to read from
map - map function in javascript code
reduce - reduce function in javascript code
outputCollection - optional - leave null if want to get the result inline
type - the type of output
query - the query to use on input
Throws:
MongoException
MongoDB Doc Links
Method Detail

setVerbose

public void setVerbose(Boolean verbose)
Sets the verbosity of the MapReduce job, defaults to 'true'

Parameters:
verbose - The verbosity level.

isVerbose

public Boolean isVerbose()
Gets the verbosity of the MapReduce job.

Returns:
the verbosity level.

getInput

public String getInput()
Get the name of the collection the MapReduce will read from

Returns:
name of the collection the MapReduce will read from

getMap

public String getMap()
Get the map function, as a JS String

Returns:
the map function (as a JS String)

getReduce

public String getReduce()
Gets the reduce function, as a JS String

Returns:
the reduce function (as a JS String)

getOutputTarget

public String getOutputTarget()
Gets the output target (name of collection to save to) This value is nullable only if OutputType is set to INLINE

Returns:
The outputTarget

getOutputType

public MapReduceCommand.OutputType getOutputType()
Gets the OutputType for this instance.

Returns:
The outputType.

getFinalize

public String getFinalize()
Gets the Finalize JS Function

Returns:
The finalize function (as a JS String).

setFinalize

public void setFinalize(String finalize)
Sets the Finalize JS Function

Parameters:
finalize - The finalize function (as a JS String)

getQuery

public DBObject getQuery()
Gets the query to run for this MapReduce job

Returns:
The query object

getSort

public DBObject getSort()
Gets the (optional) sort specification object

Returns:
the Sort DBObject

setSort

public void setSort(DBObject sort)
Sets the (optional) sort specification object

Parameters:
sort - The sort specification object

getLimit

public int getLimit()
Gets the (optional) limit on input

Returns:
The limit specification object

setLimit

public void setLimit(int limit)
Sets the (optional) limit on input

Parameters:
limit - The limit specification object

getScope

public Map<String,Object> getScope()
Gets the (optional) JavaScript scope

Returns:
The JavaScript scope

setScope

public void setScope(Map<String,Object> scope)
Sets the (optional) JavaScript scope

Parameters:
scope - The JavaScript scope

setOutputDB

public void setOutputDB(String outputDB)
Sets the (optional) database name where the output collection should reside

Parameters:
outputDB -

toDBObject

public DBObject toDBObject()

addExtraOption

public void addExtraOption(String name,
                           Object value)

getExtraOptions

public DBObject getExtraOptions()

toString

public String toString()
Overrides:
toString in class Object