public class MapReduceCommand extends Object
Modifier and Type | Class | Description |
---|---|---|
static class |
MapReduceCommand.OutputType |
Represents the different options available for outputting the results of a map-reduce operation.
|
Constructor | Description |
---|---|
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
|
Modifier and Type | Method | Description |
---|---|---|
Boolean |
getBypassDocumentValidation() |
Gets whether to bypass document validation, or null if unspecified.
|
Collation |
getCollation() |
Returns the collation
|
String |
getFinalize() |
Gets the Finalize JS Function
|
String |
getInput() |
Get the name of the collection the MapReduce will read from
|
Boolean |
getJsMode() |
Gets the (optional) JavaScript mode
|
int |
getLimit() |
Gets the (optional) limit on input
|
String |
getMap() |
Get the map function, as a JS String
|
long |
getMaxTime(TimeUnit timeUnit) |
Gets the max execution time for this command, in the given time unit.
|
String |
getOutputDB() |
Gets the (optional) database name where the output collection should reside
|
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<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 |
setBypassDocumentValidation(Boolean bypassDocumentValidation) |
Sets whether to bypass document validation.
|
void |
setCollation(Collation collation) |
Sets the collation options
|
void |
setFinalize(String finalize) |
Sets the Finalize JS Function
|
void |
setJsMode(Boolean jsMode) |
Sets the (optional) JavaScript Mode
|
void |
setLimit(int limit) |
Sets the (optional) limit on input
|
void |
setMaxTime(long maxTime,
TimeUnit timeUnit) |
Sets the max execution time for this command, in the given time unit.
|
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<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() |
Turns this command into a DBObject representation of this map reduce command.
|
String |
toString() |
public MapReduceCommand(DBCollection inputCollection, String map, String reduce, @Nullable String outputCollection, MapReduceCommand.OutputType type, DBObject query)
inputCollection
- collection to use as the source documents to perform the map reduce operation.map
- a JavaScript function that associates or "maps" a value with a key and emits the key and value pair.reduce
- a JavaScript function that "reduces" to a single object all the values associated with a particular key.outputCollection
- optional - leave null if want to get the result inlinetype
- the type of outputquery
- specifies the selection criteria using query operators for determining the documents input to the map
function.public void setVerbose(Boolean verbose)
verbose
- The verbosity level.public Boolean isVerbose()
public String getInput()
public String getMap()
public String getReduce()
@Nullable public String getOutputTarget()
public MapReduceCommand.OutputType getOutputType()
@Nullable public String getFinalize()
public void setFinalize(@Nullable String finalize)
finalize
- The finalize function (as a JS String)@Nullable public DBObject getQuery()
@Nullable public DBObject getSort()
public void setSort(@Nullable DBObject sort)
sort
- The sort specification objectpublic int getLimit()
public void setLimit(int limit)
limit
- The limit specification objectpublic long getMaxTime(TimeUnit timeUnit)
timeUnit
- the time unit to return the value in.public void setMaxTime(long maxTime, TimeUnit timeUnit)
maxTime
- the maximum execution time. A non-zero value requires a server version >= 2.6timeUnit
- the time unit that maxTime is specified in@Nullable public Map<String,Object> getScope()
public void setScope(@Nullable Map<String,Object> scope)
scope
- The JavaScript scope@Nullable public Boolean getJsMode()
public void setJsMode(@Nullable Boolean jsMode)
jsMode
- Specifies whether to convert intermediate data into BSON format between the execution of the map and reduce functions@Nullable public String getOutputDB()
public void setOutputDB(@Nullable String outputDB)
outputDB
- the name of the database to send the Map Reduce output to@Nullable public Boolean getBypassDocumentValidation()
public void setBypassDocumentValidation(@Nullable Boolean bypassDocumentValidation)
bypassDocumentValidation
- whether to bypass document validation, or null if unspecifiedpublic DBObject toDBObject()
public void setReadPreference(@Nullable ReadPreference preference)
ReadPreference
for more information.preference
- Read Preference to use@Nullable public ReadPreference getReadPreference()
@Nullable public Collation getCollation()
@Nullable public void setCollation(Collation collation)
collation
- the collation options