public class

MapReduceCommand

extends Object
java.lang.Object
   ↳ com.mongodb.MapReduceCommand

Class Overview

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

Summary

Nested Classes
enum 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  
Public Constructors
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@return
Public Methods
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
ReadPreference getReadPreference()
Gets the read preference
String getReduce()
Gets the reduce function, as a JS String
Map<StringObject> 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 setReadPreference(ReadPreference preference)
Sets the read preference for this command.
void setScope(Map<StringObject> 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()
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public 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@return

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
MongoException

Public Methods

public void addExtraOption (String name, Object value)

public DBObject getExtraOptions ()

public String getFinalize ()

Gets the Finalize JS Function

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

public String getInput ()

Get the name of the collection the MapReduce will read from

Returns
  • name of the collection the MapReduce will read from

public int getLimit ()

Gets the (optional) limit on input

Returns
  • The limit specification object

public String getMap ()

Get the map function, as a JS String

Returns
  • the map function (as a JS String)

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

public MapReduceCommand.OutputType getOutputType ()

Gets the OutputType for this instance.

Returns
  • The outputType.

public DBObject getQuery ()

Gets the query to run for this MapReduce job

Returns
  • The query object

public ReadPreference getReadPreference ()

Gets the read preference

public String getReduce ()

Gets the reduce function, as a JS String

Returns
  • the reduce function (as a JS String)

public Map<StringObject> getScope ()

Gets the (optional) JavaScript scope

Returns
  • The JavaScript scope

public DBObject getSort ()

Gets the (optional) sort specification object

Returns
  • the Sort DBObject

public Boolean isVerbose ()

Gets the verbosity of the MapReduce job.

Returns
  • the verbosity level.

public void setFinalize (String finalize)

Sets the Finalize JS Function

Parameters
finalize The finalize function (as a JS String)

public void setLimit (int limit)

Sets the (optional) limit on input

Parameters
limit The limit specification object

public void setOutputDB (String outputDB)

Sets the (optional) database name where the output collection should reside

public void setReadPreference (ReadPreference preference)

Sets the read preference for this command. See the * documentation for ReadPreference for more information.

Parameters
preference Read Preference to use

public void setScope (Map<StringObject> scope)

Sets the (optional) JavaScript scope

Parameters
scope The JavaScript scope

public void setSort (DBObject sort)

Sets the (optional) sort specification object

Parameters
sort The sort specification object

public void setVerbose (Boolean verbose)

Sets the verbosity of the MapReduce job, defaults to 'true'

Parameters
verbose The verbosity level.

public DBObject toDBObject ()

public String toString ()